Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Update Camera variants

Devin Neala74313f78629
diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst
index 6a46f018d..5ffddca16 100644
--- a/docs/source/examples/3d.rst
+++ b/docs/source/examples/3d.rst
@@ -32,7 +32,7 @@
]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2,
checkerboard_colors=[RED_D, RED_E], resolution=(15, 32)
)
- self.camera.light_source.move_to(3*IN) # changes the source of the light
+ self.renderer.camera.light_source.move_to(3*IN) # changes the source of the light
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(axes, sphere)
diff --git a/manim/camera/moving_camera.py b/manim/camera/moving_camera.py
index f5d649f9e..9cf891ff3 100644
--- a/manim/camera/moving_camera.py
+++ b/manim/camera/moving_camera.py
@@ -46,7 +46,7 @@ class MovingCamera(Camera):
"default_frame_stroke_width": 0,
}
- def __init__(self, frame=None, **kwargs):
+ def __init__(self, video_quality_config, frame=None, **kwargs):
"""
frame is a Mobject, (should almost certainly be a rectangle)
determining which region of space the camera displys
@@ -59,7 +59,7 @@ class MovingCamera(Camera):
self.default_frame_stroke_width,
)
self.frame = frame
- Camera.__init__(self, **kwargs)
+ Camera.__init__(self, video_quality_config, **kwargs)
# TODO, make these work for a rotated frame
@property
diff --git a/manim/camera/multi_camera.py b/manim/camera/multi_camera.py
index a503a849a..1cec58462 100644
--- a/manim/camera/multi_camera.py
+++ b/manim/camera/multi_camera.py
@@ -14,7 +14,9 @@ class MultiCamera(MovingCamera):
"allow_cameras_to_capture_their_own_display": False,
}
- def __init__(self, *image_mobjects_from_cameras, **kwargs):
+ def __init__(
+ self, video_quality_config, image_mobjects_from_cameras=None, **kwargs
+ ):
"""Initalises the MultiCamera
Parameters:
@@ -25,9 +27,10 @@ class MultiCamera(MovingCamera):
Any valid keyword arguments of MovingCamera.
"""
self.image_mobjects_from_cameras = []
- for imfc in image_mobjects_from_cameras:
- self.add_image_mobject_from_camera(imfc)
- MovingCamera.__init__(self, **kwargs)
+ if image_mobjects_from_cameras is not None:
+ for imfc in image_mobjects_from_cameras:
+ self.add_image_mobject_from_camera(imfc)
+ MovingCamera.__init__(self, video_quality_config, **kwargs)
def add_image_mobject_from_camera(self, image_mobject_from_camera):
"""Adds an ImageMobject that's been obtained from the camera
diff --git a/manim/scene/moving_camera_scene.py b/manim/scene/moving_camera_scene.py
index 31dc76a09..231df40c8 100644
--- a/manim/scene/moving_camera_scene.py
+++ b/manim/scene/moving_camera_scene.py
@@ -11,6 +11,7 @@ __all__ = ["MovingCameraScene"]
from ..camera.moving_camera import MovingCamera
from ..scene.scene import Scene
from ..utils.iterables import list_update
+from ..utils.family import extract_mobject_family_members
class MovingCameraScene(Scene):
@@ -31,8 +32,8 @@ class MovingCameraScene(Scene):
to set up the scene for proper use.
"""
Scene.setup(self)
- assert isinstance(self.camera, MovingCamera)
- self.camera_frame = self.camera.frame
+ assert isinstance(self.renderer.camera, MovingCamera)
+ self.camera_frame = self.renderer.camera.frame
# Hmm, this currently relies on the fact that MovingCamera
# willd default to a full-sized frame. Is that okay?
return self
@@ -48,10 +49,8 @@ class MovingCameraScene(Scene):
The Animations whose mobjects will be checked.
"""
moving_mobjects = Scene.get_moving_mobjects(self, *animations)
- all_moving_mobjects = self.camera.extract_mobject_family_members(
- moving_mobjects
- )
- movement_indicators = self.camera.get_mobjects_indicating_movement()
+ all_moving_mobjects = extract_mobject_family_members(moving_mobjects)
+ movement_indicators = self.renderer.camera.get_mobjects_indicating_movement()
for movement_indicator in movement_indicators:
if movement_indicator in all_moving_mobjects:
# When one of these is moving, the camera should
diff --git a/manim/scene/zoomed_scene.py b/manim/scene/zoomed_scene.py
index acbf1997f..e88bfa504 100644
--- a/manim/scene/zoomed_scene.py
+++ b/manim/scene/zoomed_scene.py
@@ -47,7 +47,7 @@ class ZoomedScene(MovingCameraScene):
"""
MovingCameraScene.setup(self)
# Initialize camera and display
- zoomed_camera = MovingCamera(**self.zoomed_camera_config)
+ zoomed_camera = MovingCamera({}, **self.zoomed_camera_config)
zoomed_display = ImageMobjectFromCamera(
zoomed_camera, **self.zoomed_camera_image_mobject_config
)
@@ -81,7 +81,7 @@ class ZoomedScene(MovingCameraScene):
of the zoomed camera.
"""
self.zoom_activated = True
- self.camera.add_image_mobject_from_camera(self.zoomed_display)
+ self.renderer.camera.add_image_mobject_from_camera(self.zoomed_display)
if animate:
self.play(self.get_zoom_in_animation())
self.play(self.get_zoomed_display_pop_out_animation())