mirror of
https://github.com/3b1b/manim.git
synced 2025-07-31 14:03:59 +08:00
Fixed some ThreeDCamera bugs
This commit is contained in:
@ -348,7 +348,7 @@ class Camera(object):
|
|||||||
def set_cairo_context_path(self, ctx, vmobject):
|
def set_cairo_context_path(self, ctx, vmobject):
|
||||||
ctx.new_path()
|
ctx.new_path()
|
||||||
for vmob in it.chain([vmobject], vmobject.get_subpath_mobjects()):
|
for vmob in it.chain([vmobject], vmobject.get_subpath_mobjects()):
|
||||||
points = vmob.points
|
points = self.transform_points_pre_display(vmob.points)
|
||||||
ctx.new_sub_path()
|
ctx.new_sub_path()
|
||||||
ctx.move_to(*points[0][:2])
|
ctx.move_to(*points[0][:2])
|
||||||
for triplet in zip(points[1::3], points[2::3], points[3::3]):
|
for triplet in zip(points[1::3], points[2::3], points[3::3]):
|
||||||
@ -543,7 +543,13 @@ class Camera(object):
|
|||||||
points[violator_indices] = rescaled
|
points[violator_indices] = rescaled
|
||||||
return points
|
return points
|
||||||
|
|
||||||
|
def transform_points_pre_display(self, points):
|
||||||
|
# Subclasses (like ThreeDCamera) may want to
|
||||||
|
# adjust points before they're shown
|
||||||
|
return points
|
||||||
|
|
||||||
def points_to_pixel_coords(self, points):
|
def points_to_pixel_coords(self, points):
|
||||||
|
points = self.transform_points_pre_display(points)
|
||||||
shifted_points = points - self.get_frame_center()
|
shifted_points = points - self.get_frame_center()
|
||||||
|
|
||||||
result = np.zeros((len(points), 2))
|
result = np.zeros((len(points), 2))
|
||||||
|
@ -80,7 +80,7 @@ class ThreeDCamera(MovingCamera):
|
|||||||
else:
|
else:
|
||||||
target[:, :3] = 0
|
target[:, :3] = 0
|
||||||
alpha = -self.shading_factor * brightness
|
alpha = -self.shading_factor * brightness
|
||||||
return interpolate(rgb, target, alpha)
|
return interpolate(rgbas, target, alpha)
|
||||||
|
|
||||||
def get_unit_normal_vect(self, vmobject):
|
def get_unit_normal_vect(self, vmobject):
|
||||||
anchors = vmobject.get_anchors()
|
anchors = vmobject.get_anchors()
|
||||||
@ -172,9 +172,9 @@ class ThreeDCamera(MovingCamera):
|
|||||||
rotation_about_z(-self.get_theta() - np.pi / 2),
|
rotation_about_z(-self.get_theta() - np.pi / 2),
|
||||||
)
|
)
|
||||||
|
|
||||||
def points_to_pixel_coords(self, points):
|
def transform_points_pre_display(self, points):
|
||||||
matrix = self.get_view_transformation_matrix()
|
matrix = self.get_view_transformation_matrix()
|
||||||
new_points = np.dot(points, matrix.T)
|
return np.dot(points, matrix.T)
|
||||||
self.frame_center = self.moving_center.points[0]
|
|
||||||
|
|
||||||
return MovingCamera.points_to_pixel_coords(self, new_points)
|
def get_frame_center(self):
|
||||||
|
return self.moving_center.points[0]
|
Reference in New Issue
Block a user