mirror of
https://github.com/3b1b/manim.git
synced 2025-08-02 19:46:21 +08:00
fix(animation): time_span
doesn't work for mobjects with submobjects
This commit is contained in:
@ -62,9 +62,6 @@ class Animation(object):
|
||||
if self.time_span is not None:
|
||||
start, end = self.time_span
|
||||
self.run_time = max(end, self.run_time)
|
||||
self.rate_func = squish_rate_func(
|
||||
self.rate_func, start / self.run_time, end / self.run_time,
|
||||
)
|
||||
self.mobject.set_animating_status(True)
|
||||
self.starting_mobject = self.create_starting_mobject()
|
||||
if self.suspend_mobject_updating:
|
||||
@ -150,9 +147,15 @@ class Animation(object):
|
||||
"""
|
||||
self.interpolate(alpha)
|
||||
|
||||
def time_spanned_alpha(self, alpha: float) -> float:
|
||||
if self.time_span is not None:
|
||||
start, end = self.time_span
|
||||
return clip(alpha * self.run_time - start, 0, end - start) / (end - start)
|
||||
return alpha
|
||||
|
||||
def interpolate_mobject(self, alpha: float) -> None:
|
||||
for i, mobs in enumerate(self.families):
|
||||
sub_alpha = self.get_sub_alpha(alpha, i, len(self.families))
|
||||
sub_alpha = self.get_sub_alpha(self.time_spanned_alpha(alpha), i, len(self.families))
|
||||
self.interpolate_submobject(*mobs, sub_alpha)
|
||||
|
||||
def interpolate_submobject(
|
||||
|
@ -48,7 +48,7 @@ class Rotating(Animation):
|
||||
for key in sm1.pointlike_data_keys:
|
||||
sm1.data[key][:] = sm2.data[key]
|
||||
self.mobject.rotate(
|
||||
self.rate_func(alpha) * self.angle,
|
||||
self.rate_func(self.time_spanned_alpha(alpha)) * self.angle,
|
||||
axis=self.axis,
|
||||
about_point=self.about_point,
|
||||
about_edge=self.about_edge,
|
||||
|
Reference in New Issue
Block a user