From 0b994db0ec550506bb9a6f03a6ee1b2b15edaad6 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 14 Dec 2022 17:14:53 -0800 Subject: [PATCH] Make camera_config changable as a class variable --- example_scenes.py | 4 +--- manimlib/scene/scene.py | 12 +++++------- manimlib/scene/three_d_scene.py | 6 +----- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/example_scenes.py b/example_scenes.py index d297ca33..d4caa1c2 100644 --- a/example_scenes.py +++ b/example_scenes.py @@ -493,9 +493,7 @@ class GraphExample(Scene): class SurfaceExample(Scene): - CONFIG = { - "camera_class": ThreeDCamera, - } + camera_config = dict(samples=4) def construct(self): surface_text = Text("For 3d scenes, try using surfaces") diff --git a/manimlib/scene/scene.py b/manimlib/scene/scene.py index a4ad31fe..c023264f 100644 --- a/manimlib/scene/scene.py +++ b/manimlib/scene/scene.py @@ -53,6 +53,7 @@ class Scene(object): random_seed: int = 0 pan_sensitivity: float = 3.0 max_num_saved_states: int = 50 + camera_config: dict = dict() def __init__( self, @@ -78,23 +79,20 @@ class Scene(object): self.presenter_mode = presenter_mode self.show_animation_progress = show_animation_progress - # # Overwrite class variables with configuration - # for key, value in config.items(): - # setattr(self, key, value) - # Initialize window, if applicable if self.preview: from manimlib.window import Window self.window = Window(scene=self, **window_config) - camera_config["ctx"] = self.window.ctx - camera_config["fps"] = 30 # Where's that 30 from? + self.camera_config.update(camera_config) + self.camera_config["ctx"] = self.window.ctx + self.camera_config["fps"] = 30 # Where's that 30 from? self.undo_stack = [] self.redo_stack = [] else: self.window = None # Core state of the scene - self.camera: Camera = camera_class(**camera_config) + self.camera: Camera = camera_class(**self.camera_config) self.file_writer = SceneFileWriter(self, **file_writer_config) self.mobjects: list[Mobject] = [self.camera.frame] self.id_to_mobject_map: dict[int, Mobject] = dict() diff --git a/manimlib/scene/three_d_scene.py b/manimlib/scene/three_d_scene.py index 2d29fff8..3b73134d 100644 --- a/manimlib/scene/three_d_scene.py +++ b/manimlib/scene/three_d_scene.py @@ -2,11 +2,7 @@ from manimlib.scene.scene import Scene class ThreeDScene(Scene): - CONFIG = { - "camera_config": { - "samples": 4, - } - } + camera_config = dict(samples=4) def begin_ambient_camera_rotation(self, rate=0.02): pass # TODO