Skip to content

Commit a74313f

Browse files
committed
Update Camera variants
1 parent 067f0c1 commit a74313f

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

docs/source/examples/3d.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
]), v_min=0, v_max=TAU, u_min=-PI / 2, u_max=PI / 2,
3333
checkerboard_colors=[RED_D, RED_E], resolution=(15, 32)
3434
)
35-
self.camera.light_source.move_to(3*IN) # changes the source of the light
35+
self.renderer.camera.light_source.move_to(3*IN) # changes the source of the light
3636
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
3737
self.add(axes, sphere)
3838

manim/camera/moving_camera.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class MovingCamera(Camera):
4646
"default_frame_stroke_width": 0,
4747
}
4848

49-
def __init__(self, frame=None, **kwargs):
49+
def __init__(self, video_quality_config, frame=None, **kwargs):
5050
"""
5151
frame is a Mobject, (should almost certainly be a rectangle)
5252
determining which region of space the camera displys
@@ -59,7 +59,7 @@ def __init__(self, frame=None, **kwargs):
5959
self.default_frame_stroke_width,
6060
)
6161
self.frame = frame
62-
Camera.__init__(self, **kwargs)
62+
Camera.__init__(self, video_quality_config, **kwargs)
6363

6464
# TODO, make these work for a rotated frame
6565
@property

manim/camera/multi_camera.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class MultiCamera(MovingCamera):
1414
"allow_cameras_to_capture_their_own_display": False,
1515
}
1616

17-
def __init__(self, *image_mobjects_from_cameras, **kwargs):
17+
def __init__(
18+
self, video_quality_config, image_mobjects_from_cameras=None, **kwargs
19+
):
1820
"""Initalises the MultiCamera
1921
2022
Parameters:
@@ -25,9 +27,10 @@ def __init__(self, *image_mobjects_from_cameras, **kwargs):
2527
Any valid keyword arguments of MovingCamera.
2628
"""
2729
self.image_mobjects_from_cameras = []
28-
for imfc in image_mobjects_from_cameras:
29-
self.add_image_mobject_from_camera(imfc)
30-
MovingCamera.__init__(self, **kwargs)
30+
if image_mobjects_from_cameras is not None:
31+
for imfc in image_mobjects_from_cameras:
32+
self.add_image_mobject_from_camera(imfc)
33+
MovingCamera.__init__(self, video_quality_config, **kwargs)
3134

3235
def add_image_mobject_from_camera(self, image_mobject_from_camera):
3336
"""Adds an ImageMobject that's been obtained from the camera

manim/scene/moving_camera_scene.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ..camera.moving_camera import MovingCamera
1212
from ..scene.scene import Scene
1313
from ..utils.iterables import list_update
14+
from ..utils.family import extract_mobject_family_members
1415

1516

1617
class MovingCameraScene(Scene):
@@ -31,8 +32,8 @@ def setup(self):
3132
to set up the scene for proper use.
3233
"""
3334
Scene.setup(self)
34-
assert isinstance(self.camera, MovingCamera)
35-
self.camera_frame = self.camera.frame
35+
assert isinstance(self.renderer.camera, MovingCamera)
36+
self.camera_frame = self.renderer.camera.frame
3637
# Hmm, this currently relies on the fact that MovingCamera
3738
# willd default to a full-sized frame. Is that okay?
3839
return self
@@ -48,10 +49,8 @@ def get_moving_mobjects(self, *animations):
4849
The Animations whose mobjects will be checked.
4950
"""
5051
moving_mobjects = Scene.get_moving_mobjects(self, *animations)
51-
all_moving_mobjects = self.camera.extract_mobject_family_members(
52-
moving_mobjects
53-
)
54-
movement_indicators = self.camera.get_mobjects_indicating_movement()
52+
all_moving_mobjects = extract_mobject_family_members(moving_mobjects)
53+
movement_indicators = self.renderer.camera.get_mobjects_indicating_movement()
5554
for movement_indicator in movement_indicators:
5655
if movement_indicator in all_moving_mobjects:
5756
# When one of these is moving, the camera should

manim/scene/zoomed_scene.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def setup(self):
4747
"""
4848
MovingCameraScene.setup(self)
4949
# Initialize camera and display
50-
zoomed_camera = MovingCamera(**self.zoomed_camera_config)
50+
zoomed_camera = MovingCamera({}, **self.zoomed_camera_config)
5151
zoomed_display = ImageMobjectFromCamera(
5252
zoomed_camera, **self.zoomed_camera_image_mobject_config
5353
)
@@ -81,7 +81,7 @@ def activate_zooming(self, animate=False):
8181
of the zoomed camera.
8282
"""
8383
self.zoom_activated = True
84-
self.camera.add_image_mobject_from_camera(self.zoomed_display)
84+
self.renderer.camera.add_image_mobject_from_camera(self.zoomed_display)
8585
if animate:
8686
self.play(self.get_zoom_in_animation())
8787
self.play(self.get_zoomed_display_pop_out_animation())

0 commit comments

Comments
 (0)