Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Updaters fix (#838)

Devin Nealf42bd0579d35
diff --git a/manim/scene/scene.py b/manim/scene/scene.py
index dd6307d98..3a0217448 100644
--- a/manim/scene/scene.py
+++ b/manim/scene/scene.py
@@ -319,6 +319,11 @@ class Scene(Container):
mobjects = [*mobjects, *self.foreground_mobjects]
self.restructure_mobjects(to_remove=mobjects)
self.mobjects += mobjects
+ if self.moving_mobjects:
+ self.restructure_mobjects(
+ to_remove=mobjects, mobject_list_name="moving_mobjects"
+ )
+ self.moving_mobjects += mobjects
return self
def add_mobjects_from_animations(self, animations):
diff --git a/tests/control_data/graphical_units_data/updaters/UpdateSceneDuringAnimationTest.npz b/tests/control_data/graphical_units_data/updaters/UpdateSceneDuringAnimationTest.npz
new file mode 100644
index 000000000..59e78df02
Binary files /dev/null and b/tests/control_data/graphical_units_data/updaters/UpdateSceneDuringAnimationTest.npz differ
diff --git a/tests/test_graphical_units/test_updaters.py b/tests/test_graphical_units/test_updaters.py
index dd166c306..addb95046 100644
--- a/tests/test_graphical_units/test_updaters.py
+++ b/tests/test_graphical_units/test_updaters.py
@@ -24,6 +24,15 @@ class ValueTrackerTest(Scene):
line_2.rotate(theta.get_value(), about_point=ORIGIN)
+class UpdateSceneDuringAnimationTest(Scene):
+ def construct(self):
+ def f(mob):
+ self.add(Square())
+
+ s = Circle().add_updater(f)
+ self.play(ShowCreation(s))
+
+
MODULE_NAME = "updaters"