diff --git a/manim/scene/scene.py b/manim/scene/scene.py index fc3d3ede54..ffe3fc4e24 100644 --- a/manim/scene/scene.py +++ b/manim/scene/scene.py @@ -848,7 +848,18 @@ def get_moving_mobjects(self, *animations: Animation): # as soon as there's one that needs updating of # some kind per frame, return the list from that # point forward. - animation_mobjects = [anim.mobject for anim in animations] + + # Imported inside the method to avoid cyclic import + from ..animation.composition import AnimationGroup + + animation_mobjects = [] + for anim in animations: + if isinstance(anim, AnimationGroup): + for sub in anim.animations: + animation_mobjects.append(sub.mobject) + else: + animation_mobjects.append(anim.mobject) + mobjects = self.get_mobject_family_members() for i, mob in enumerate(mobjects): update_possibilities = [ diff --git a/tests/test_graphical_units/control_data/geometry/negative_z_index_AnimationGroup.npz b/tests/test_graphical_units/control_data/geometry/negative_z_index_AnimationGroup.npz new file mode 100644 index 0000000000..80ba71a0eb Binary files /dev/null and b/tests/test_graphical_units/control_data/geometry/negative_z_index_AnimationGroup.npz differ diff --git a/tests/test_graphical_units/control_data/geometry/negative_z_index_LaggedStart.npz b/tests/test_graphical_units/control_data/geometry/negative_z_index_LaggedStart.npz new file mode 100644 index 0000000000..13aba250f3 Binary files /dev/null and b/tests/test_graphical_units/control_data/geometry/negative_z_index_LaggedStart.npz differ diff --git a/tests/test_graphical_units/test_geometry.py b/tests/test_graphical_units/test_geometry.py index fef2ca0951..7bc65561cb 100644 --- a/tests/test_graphical_units/test_geometry.py +++ b/tests/test_graphical_units/test_geometry.py @@ -174,6 +174,21 @@ def test_ZIndex(scene): scene.play(ApplyMethod(triangle.shift, 2 * UP)) +@frames_comparison(last_frame=False) +def test_negative_z_index_AnimationGroup(scene): + # https://github.com/ManimCommunity/manim/issues/3334 + s = Square().set_z_index(-1) + scene.play(AnimationGroup(GrowFromCenter(s))) + + +@frames_comparison(last_frame=False) +def test_negative_z_index_LaggedStart(scene): + # https://github.com/ManimCommunity/manim/issues/3914 + background = Rectangle(z_index=-1) + line = Line(2 * LEFT, 2 * RIGHT, color=RED_D, z_index=-1) + scene.play(LaggedStart(FadeIn(background), FadeIn(line), lag_ratio=0.5)) + + @frames_comparison def test_Angle(scene): l1 = Line(ORIGIN, RIGHT)