mirror of
https://github.com/3b1b/manim.git
synced 2025-08-01 08:54:38 +08:00
Bug fix to how Succession behave when Scene.play changes its runtime
This commit is contained in:
@ -382,6 +382,10 @@ class Succession(Animation):
|
|||||||
run_time = sum(self.run_times)
|
run_time = sum(self.run_times)
|
||||||
self.num_anims = len(animations)
|
self.num_anims = len(animations)
|
||||||
self.animations = animations
|
self.animations = animations
|
||||||
|
self.last_index = 0
|
||||||
|
#Have to keep track of this run_time, because Scene.play
|
||||||
|
#might very well mess with it.
|
||||||
|
self.original_run_time = run_time
|
||||||
|
|
||||||
mobject = Group(*[anim.mobject for anim in self.animations])
|
mobject = Group(*[anim.mobject for anim in self.animations])
|
||||||
Animation.__init__(self, mobject, run_time = run_time, **kwargs)
|
Animation.__init__(self, mobject, run_time = run_time, **kwargs)
|
||||||
@ -392,11 +396,17 @@ class Succession(Animation):
|
|||||||
return
|
return
|
||||||
run_times = self.run_times
|
run_times = self.run_times
|
||||||
index = 0
|
index = 0
|
||||||
time = alpha*self.run_time
|
time = alpha*self.original_run_time
|
||||||
while sum(run_times[:index+1]) < time:
|
while sum(run_times[:index+1]) < time:
|
||||||
index += 1
|
index += 1
|
||||||
|
if index > self.last_index:
|
||||||
|
self.animations[self.last_index].update(1)
|
||||||
|
self.animations[self.last_index].clean_up()
|
||||||
|
self.last_index = index
|
||||||
curr_anim = self.animations[index]
|
curr_anim = self.animations[index]
|
||||||
sub_alpha = (time - sum(run_times[:index]))/run_times[index]
|
sub_alpha = np.clip(
|
||||||
|
(time - sum(run_times[:index]))/run_times[index], 0, 1
|
||||||
|
)
|
||||||
curr_anim.update(sub_alpha)
|
curr_anim.update(sub_alpha)
|
||||||
|
|
||||||
class AnimationGroup(Animation):
|
class AnimationGroup(Animation):
|
||||||
|
Reference in New Issue
Block a user