3b1b-manim/scene/moving_camera_scene.py

33 lines
1.2 KiB
Python
Raw Normal View History

from __future__ import absolute_import
from scene.scene import Scene
2018-03-31 15:20:30 -07:00
from camera.moving_camera import MovingCamera
from utils.iterables import list_update
2018-02-23 11:05:57 -08:00
2018-02-23 11:05:57 -08:00
class MovingCameraScene(Scene):
2018-05-11 11:23:08 -07:00
CONFIG = {
"camera_class": MovingCamera
}
2018-02-23 11:05:57 -08:00
def setup(self):
2018-05-11 11:23:08 -07:00
Scene.setup(self)
assert(isinstance(self.camera, MovingCamera))
self.camera_frame = self.camera.frame
# Hmm, this currently relies on the fact that MovingCamera
# willd default to a full-sized frame. Is that okay?
2018-02-23 11:05:57 -08:00
return self
def get_moving_mobjects(self, *animations):
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()
for movement_indicator in movement_indicators:
if movement_indicator in all_moving_mobjects:
# When one of these is moving, the camera should
# consider all mobjects to be moving
return list_update(self.mobjects, moving_mobjects)
return moving_mobjects