Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Redid SpecialThreeDScene low quality configuration

Grant Sanderson72d5bb27028f
diff --git a/scene/three_d_scene.py b/scene/three_d_scene.py
index fdce06100..60cd3a824 100644
--- a/scene/three_d_scene.py
+++ b/scene/three_d_scene.py
@@ -108,40 +108,30 @@ class ThreeDScene(Scene):
class SpecialThreeDScene(ThreeDScene):
CONFIG = {
"cut_axes_at_radius": True,
- }
-
- def __init__(self, **kwargs):
- digest_config(self, kwargs)
- if self.frame_duration == PRODUCTION_QUALITY_FRAME_DURATION:
- high_quality = True
- else:
- high_quality = False
- default_config = self.get_quality_dependent_config(high_quality)
- config = merge_config([self.CONFIG, kwargs, default_config])
- ThreeDScene.__init__(self, **config)
-
- def get_quality_dependent_config(self, high_quality=True):
- hq_config = {
- "camera_config": {
- "should_apply_shading": True,
- "exponential_projection": True,
- },
- "three_d_axes_config": {
- "num_axis_pieces": 1,
- "number_line_config": {
- "unit_size": 2,
- # "tick_frequency": 0.5,
- "tick_frequency": 1,
- "numbers_with_elongated_ticks": [0, 1, 2],
- "stroke_width": 2,
- }
- },
- "sphere_config": {
- "radius": 2,
- "resolution": (24, 48),
+ "camera_config": {
+ "should_apply_shading": True,
+ "exponential_projection": True,
+ },
+ "three_d_axes_config": {
+ "num_axis_pieces": 1,
+ "number_line_config": {
+ "unit_size": 2,
+ "tick_frequency": 1,
+ "numbers_with_elongated_ticks": [0, 1, 2],
+ "stroke_width": 2,
}
- }
- lq_added_config = {
+ },
+ "sphere_config": {
+ "radius": 2,
+ "resolution": (24, 48),
+ },
+ "default_angled_camera_position": {
+ "phi": 70 * DEGREES,
+ "theta": -110 * DEGREES,
+ },
+ # When scene is extracted with -l flag, this
+ # configuration will override the above configuration.
+ "low_quality_config": {
"camera_config": {
"should_apply_shading": False,
},
@@ -152,13 +142,15 @@ class SpecialThreeDScene(ThreeDScene):
"resolution": (12, 24),
}
}
- if high_quality:
- return hq_config
+ }
+
+ def __init__(self, **kwargs):
+ digest_config(self, kwargs)
+ if self.frame_duration == PRODUCTION_QUALITY_FRAME_DURATION:
+ config = {}
else:
- return merge_config([
- lq_added_config,
- hq_config
- ])
+ config = self.low_quality_config
+ ThreeDScene.__init__(self, **merge_config([kwargs, config]))
def get_axes(self):
axes = ThreeDAxes(**self.three_d_axes_config)
@@ -181,16 +173,15 @@ class SpecialThreeDScene(ThreeDScene):
))
return axes
- def get_sphere(self):
- return Sphere(**self.sphere_config)
+ def get_sphere(self, **kwargs):
+ config = dict(self.sphere_config)
+ config.update(kwargs)
+ return Sphere(**config)
def get_default_camera_position(self):
- return {
- "phi": 70 * DEGREES,
- "theta": -110 * DEGREES,
- }
+ return self.default_angled_camera_position
def set_camera_to_default_position(self):
self.set_camera_orientation(
- **self.get_default_camera_position()
+ **self.default_angled_camera_position
)