Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fixed some ThreeDCamera bugs

Grant Sanderson3ba33d543e94
diff --git a/camera/camera.py b/camera/camera.py
index 6a3c832bc..701dd64f1 100644
--- a/camera/camera.py
+++ b/camera/camera.py
@@ -348,7 +348,7 @@ class Camera(object):
def set_cairo_context_path(self, ctx, vmobject):
ctx.new_path()
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.move_to(*points[0][:2])
for triplet in zip(points[1::3], points[2::3], points[3::3]):
@@ -543,7 +543,13 @@ class Camera(object):
points[violator_indices] = rescaled
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):
+ points = self.transform_points_pre_display(points)
shifted_points = points - self.get_frame_center()
result = np.zeros((len(points), 2))
diff --git a/camera/three_d_camera.py b/camera/three_d_camera.py
index 2494340d6..c899c6cce 100644
--- a/camera/three_d_camera.py
+++ b/camera/three_d_camera.py
@@ -80,7 +80,7 @@ class ThreeDCamera(MovingCamera):
else:
target[:, :3] = 0
alpha = -self.shading_factor * brightness
- return interpolate(rgb, target, alpha)
+ return interpolate(rgbas, target, alpha)
def get_unit_normal_vect(self, vmobject):
anchors = vmobject.get_anchors()
@@ -172,9 +172,9 @@ class ThreeDCamera(MovingCamera):
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()
- new_points = np.dot(points, matrix.T)
- self.frame_center = self.moving_center.points[0]
+ return np.dot(points, matrix.T)
- return MovingCamera.points_to_pixel_coords(self, new_points)
+ def get_frame_center(self):
+ return self.moving_center.points[0]
\ No newline at end of file