diff --git a/manim/animation/creation.py b/manim/animation/creation.py index f79b6ec197..b18158032c 100644 --- a/manim/animation/creation.py +++ b/manim/animation/creation.py @@ -136,6 +136,11 @@ def interpolate_submobject( def _get_bounds(self, alpha: float) -> tuple[float, float]: raise NotImplementedError("Please use Create or ShowPassingFlash") + def update_mobjects(self, dt: float) -> None: + if self.suspend_mobject_updating: + dt = 0 + super().update_mobjects(dt) + class Create(ShowPartial): """Incrementally show a VMobject. diff --git a/tests/module/animation/test_creation.py b/tests/module/animation/test_creation.py index d2a0b08666..4736d6d358 100644 --- a/tests/module/animation/test_creation.py +++ b/tests/module/animation/test_creation.py @@ -3,7 +3,7 @@ import numpy as np import pytest -from manim import AddTextLetterByLetter, Text +from manim import RIGHT, AddTextLetterByLetter, Create, Dot, Text def test_non_empty_text_creation(): @@ -32,3 +32,21 @@ def test_run_time_for_non_empty_text(config): expected_run_time = np.max((1 / config.frame_rate, run_time_per_char)) * len(s.text) anim = AddTextLetterByLetter(s, time_per_char=run_time_per_char) assert anim.run_time == expected_run_time + + +def test_create_suspends_mobject_updaters(): + """Ensure Create honors suspend_mobject_updating for time-based updaters.""" + control = Dot() + control_animation = Create(control, suspend_mobject_updating=True) + control_animation.begin() + control_animation.interpolate(0.5) + + dot = Dot() + dot.add_updater(lambda mobject, dt: mobject.shift(RIGHT * dt)) + + animation = Create(dot, suspend_mobject_updating=True) + animation.begin() + animation.update_mobjects(1) + animation.interpolate(0.5) + + assert np.allclose(dot.get_center(), control.get_center())