Fixed some ThreeDCamera bugs

This commit is contained in:
Grant Sanderson
2018-08-12 19:04:52 -07:00
parent b04bddf35b
commit 3ba33d543e
2 changed files with 12 additions and 6 deletions

View File

@ -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))

View File

@ -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]