diff --git a/manimlib/camera/camera_frame.py b/manimlib/camera/camera_frame.py index 78a7d095..96a58f61 100644 --- a/manimlib/camera/camera_frame.py +++ b/manimlib/camera/camera_frame.py @@ -38,6 +38,7 @@ class CameraFrame(Mobject): self.default_orientation = Rotation.identity() self.view_matrix = np.identity(4) + self.id4x4 = np.identity(4) self.camera_location = OUT # This will be updated by set_points self.euler_axes = euler_axes @@ -100,17 +101,15 @@ class CameraFrame(Mobject): into the camera's internal coordinate system """ if self._data_has_changed: - shift = np.identity(4) - rotation = np.identity(4) - scale_mat = np.identity(4) + shift = self.id4x4.copy() + rotation = self.id4x4.copy() + scale = self.get_scale() shift[:3, 3] = -self.get_center() rotation[:3, :3] = self.get_inverse_camera_rotation_matrix() - scale = self.get_scale() + np.dot(rotation, shift, out=self.view_matrix) if scale > 0: - scale_mat[:3, :3] /= self.get_scale() - - self.view_matrix = np.dot(scale_mat, np.dot(rotation, shift)) + self.view_matrix[:3, :4] /= scale return self.view_matrix