Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Got rid of ContinualUpdate

Grant Sanderson82f0afb4dd6f
diff --git a/big_ol_pile_of_manim_imports.py b/big_ol_pile_of_manim_imports.py
index 7ac299141..bc2ad705c 100644
--- a/big_ol_pile_of_manim_imports.py
+++ b/big_ol_pile_of_manim_imports.py
@@ -34,9 +34,6 @@ from manimlib.camera.mapping_camera import *
from manimlib.camera.moving_camera import *
from manimlib.camera.three_d_camera import *
-from manimlib.continual_animation.continual_animation import *
-from manimlib.continual_animation.update import *
-
from manimlib.mobject.coordinate_systems import *
from manimlib.mobject.frame import *
from manimlib.mobject.functions import *
diff --git a/manimlib/continual_animation/update.py b/manimlib/continual_animation/update.py
deleted file mode 100644
index 4b7dffd5c..000000000
--- a/manimlib/continual_animation/update.py
+++ /dev/null
@@ -1,32 +0,0 @@
-from manimlib.animation.update import MaintainPositionRelativeTo
-from manimlib.continual_animation.continual_animation import ContinualAnimation
-from manimlib.mobject.value_tracker import ValueTracker
-
-
-class ContinualMaintainPositionRelativeTo(ContinualAnimation):
- # TODO: Possibly reimplement using CycleAnimation?
- def __init__(self, mobject, tracked_mobject, **kwargs):
- self.anim = MaintainPositionRelativeTo(
- mobject, tracked_mobject, **kwargs)
- ContinualAnimation.__init__(self, mobject, **kwargs)
-
- def update_mobject(self, dt):
- self.anim.update(0) # 0 is arbitrary
-
-
-# TODO, maybe factor into a different file
-class ContinualGrowValue(ContinualAnimation):
- CONFIG = {
- "rate": 1,
- }
-
- def __init__(self, value_tracker, **kwargs):
- if not isinstance(value_tracker, ValueTracker):
- raise Exception("ContinualGrowValue must take a ValueTracker as its mobject")
- self.value_tracker = value_tracker
- ContinualAnimation.__init__(self, value_tracker, **kwargs)
-
- def update_mobject(self, dt):
- self.value_tracker.set_value(
- self.value_tracker.get_value() + self.rate * dt
- )
diff --git a/manimlib/mobject/coordinate_systems.py b/manimlib/mobject/coordinate_systems.py
index af063f8de..fd91db328 100644
--- a/manimlib/mobject/coordinate_systems.py
+++ b/manimlib/mobject/coordinate_systems.py
@@ -169,7 +169,7 @@ class ThreeDAxes(Axes):
angle_of_vector(self.z_normal), OUT,
about_point=ORIGIN
)
- self.axes.append(z_axis)
+ self.axes.add(z_axis)
self.add(z_axis)
self.add_3d_pieces()
diff --git a/manimlib/scene/three_d_scene.py b/manimlib/scene/three_d_scene.py
index 8cff6fb66..ccf047d89 100644
--- a/manimlib/scene/three_d_scene.py
+++ b/manimlib/scene/three_d_scene.py
@@ -2,7 +2,6 @@ from manimlib.animation.transform import ApplyMethod
from manimlib.camera.three_d_camera import ThreeDCamera
from manimlib.constants import DEGREES
from manimlib.constants import PRODUCTION_QUALITY_CAMERA_CONFIG
-from manimlib.continual_animation.update import ContinualGrowValue
from manimlib.mobject.coordinate_systems import ThreeDAxes
from manimlib.mobject.geometry import Line
from manimlib.mobject.three_dimensions import Sphere
@@ -34,16 +33,15 @@ class ThreeDScene(Scene):
self.camera.set_gamma(gamma)
def begin_ambient_camera_rotation(self, rate=0.02):
- self.ambient_camera_rotation = ContinualGrowValue(
- self.camera.theta_tracker,
- rate=rate
+ # TODO, use a ValueTracker for rate, so that it
+ # can begin and end smoothly
+ self.camera.theta_tracker.add_updater(
+ lambda m, dt: m.increment_value(rate * dt)
)
- self.add(self.ambient_camera_rotation)
+ self.add(self.camera.theta_tracker)
def stop_ambient_camera_rotation(self):
- if self.ambient_camera_rotation is not None:
- self.remove(self.ambient_camera_rotation)
- self.ambient_camera_rotation = None
+ self.camera.theta_tracker.clear_updaters()
def move_camera(self,
phi=None,
diff --git a/old_projects/alt_calc.py b/old_projects/alt_calc.py
index 3fd0bb1a1..8177bae44 100644
--- a/old_projects/alt_calc.py
+++ b/old_projects/alt_calc.py
@@ -927,8 +927,14 @@ class ChangingVectorField(Scene):
plane.add_coordinates()
self.add(plane)
+ # Obviously a silly thing to do, but I'm sweeping
+ # through trying to make sure old scenes don't
+ # completely break in spots which used to have
+ # Continual animations
time_tracker = self.time_tracker = ValueTracker(0)
- self.add(ContinualGrowValue(time_tracker))
+ time_tracker.add_updater(
+ lambda t: t.set_value(self.get_time())
+ )
vectors = self.get_vectors()
vectors.add_updater(self.update_vectors)
diff --git a/old_projects/quaternions.py b/old_projects/quaternions.py
index fdef69a7a..ce205f7c8 100644
--- a/old_projects/quaternions.py
+++ b/old_projects/quaternions.py
@@ -2428,8 +2428,8 @@ class IntroduceStereographicProjection(MovingCameraScene):
frame = self.camera_frame
frame_height_tracker = ValueTracker(frame.get_height())
- frame_height_growth = ContinualGrowValue(
- frame_height_tracker, rate=0.4
+ frame_height_growth = frame_height_tracker.add_updater(
+ lambda m, dt: m.set_value(m.get_value + 0.5 * dt)
)
neg_one_tangent = VGroup(
@@ -2484,7 +2484,6 @@ class IntroduceStereographicProjection(MovingCameraScene):
self.add(frame, frame_height_growth)
elif arc is arc2:
self.play(dot.move_to, neg_i_point)
- frame_height_growth.begin_wind_down()
self.wait(2)
self.play(*map(ShowCreation, neg_one_tangent))
self.wait()