mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 02:07:45 +00:00
Got rid of ContinualUpdate
This commit is contained in:
parent
52d4eb2e9e
commit
82f0afb4dd
6 changed files with 16 additions and 48 deletions
|
|
@ -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 *
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue