mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Make camera_config changable as a class variable
This commit is contained in:
parent
69b0b0727e
commit
0b994db0ec
3 changed files with 7 additions and 15 deletions
|
@ -493,9 +493,7 @@ class GraphExample(Scene):
|
||||||
|
|
||||||
|
|
||||||
class SurfaceExample(Scene):
|
class SurfaceExample(Scene):
|
||||||
CONFIG = {
|
camera_config = dict(samples=4)
|
||||||
"camera_class": ThreeDCamera,
|
|
||||||
}
|
|
||||||
|
|
||||||
def construct(self):
|
def construct(self):
|
||||||
surface_text = Text("For 3d scenes, try using surfaces")
|
surface_text = Text("For 3d scenes, try using surfaces")
|
||||||
|
|
|
@ -53,6 +53,7 @@ class Scene(object):
|
||||||
random_seed: int = 0
|
random_seed: int = 0
|
||||||
pan_sensitivity: float = 3.0
|
pan_sensitivity: float = 3.0
|
||||||
max_num_saved_states: int = 50
|
max_num_saved_states: int = 50
|
||||||
|
camera_config: dict = dict()
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -78,23 +79,20 @@ class Scene(object):
|
||||||
self.presenter_mode = presenter_mode
|
self.presenter_mode = presenter_mode
|
||||||
self.show_animation_progress = show_animation_progress
|
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
|
# Initialize window, if applicable
|
||||||
if self.preview:
|
if self.preview:
|
||||||
from manimlib.window import Window
|
from manimlib.window import Window
|
||||||
self.window = Window(scene=self, **window_config)
|
self.window = Window(scene=self, **window_config)
|
||||||
camera_config["ctx"] = self.window.ctx
|
self.camera_config.update(camera_config)
|
||||||
camera_config["fps"] = 30 # Where's that 30 from?
|
self.camera_config["ctx"] = self.window.ctx
|
||||||
|
self.camera_config["fps"] = 30 # Where's that 30 from?
|
||||||
self.undo_stack = []
|
self.undo_stack = []
|
||||||
self.redo_stack = []
|
self.redo_stack = []
|
||||||
else:
|
else:
|
||||||
self.window = None
|
self.window = None
|
||||||
|
|
||||||
# Core state of the scene
|
# 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.file_writer = SceneFileWriter(self, **file_writer_config)
|
||||||
self.mobjects: list[Mobject] = [self.camera.frame]
|
self.mobjects: list[Mobject] = [self.camera.frame]
|
||||||
self.id_to_mobject_map: dict[int, Mobject] = dict()
|
self.id_to_mobject_map: dict[int, Mobject] = dict()
|
||||||
|
|
|
@ -2,11 +2,7 @@ from manimlib.scene.scene import Scene
|
||||||
|
|
||||||
|
|
||||||
class ThreeDScene(Scene):
|
class ThreeDScene(Scene):
|
||||||
CONFIG = {
|
camera_config = dict(samples=4)
|
||||||
"camera_config": {
|
|
||||||
"samples": 4,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def begin_ambient_camera_rotation(self, rate=0.02):
|
def begin_ambient_camera_rotation(self, rate=0.02):
|
||||||
pass # TODO
|
pass # TODO
|
||||||
|
|
Loading…
Add table
Reference in a new issue