mirror of
https://github.com/3b1b/manim.git
synced 2025-07-31 05:52:34 +08:00
Adds MovingCameraScene
This commit is contained in:
23
scene/moving_camera_scene.py
Normal file
23
scene/moving_camera_scene.py
Normal file
@ -0,0 +1,23 @@
|
||||
from helpers import *
|
||||
|
||||
from camera import MovingCamera
|
||||
from scene import Scene
|
||||
from topics.geometry import ScreenRectangle
|
||||
|
||||
class MovingCameraScene(Scene):
|
||||
def setup(self):
|
||||
self.camera_frame = ScreenRectangle(height = 2*SPACE_HEIGHT)
|
||||
self.camera_frame.set_stroke(width = 0)
|
||||
self.camera = MovingCamera(
|
||||
self.camera_frame, **self.camera_config
|
||||
)
|
||||
return self
|
||||
|
||||
def get_moving_mobjects(self, *animations):
|
||||
# TODO: Code repetition from ZoomedScene
|
||||
moving_mobjects = Scene.get_moving_mobjects(self, *animations)
|
||||
if self.camera_frame in moving_mobjects:
|
||||
# When the camera is moving, so is everything,
|
||||
return self.mobjects
|
||||
else:
|
||||
return moving_mobjects
|
@ -122,6 +122,7 @@ class ZoomedScene(Scene):
|
||||
self.zoomed_camera.capture_mobjects(
|
||||
mobjects, **kwargs
|
||||
)
|
||||
|
||||
def get_moving_mobjects(self, *animations):
|
||||
moving_mobjects = Scene.get_moving_mobjects(self, *animations)
|
||||
if self.zoom_activated and self.little_rectangle in moving_mobjects:
|
||||
|
Reference in New Issue
Block a user