Skip to content

fix: AnimationGroup with negative z_index #4277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
09dc7e7
Fixed negative z_index in AnimationGroup issue
Merzlikin-Matvey Jun 8, 2025
8712c17
Added tests for negative z_index in animations
Merzlikin-Matvey Jun 8, 2025
26e0fc9
Fixed the test on Linux and MacOS
Merzlikin-Matvey Jun 8, 2025
c079386
Slightly modified the test
Merzlikin-Matvey Jun 8, 2025
139c5c7
Merge branch 'main' into main
Merzlikin-Matvey Jun 9, 2025
ccefe48
Merge branch 'main' into main
Merzlikin-Matvey Jun 14, 2025
e4b1d10
Rename misleading function dot_position to update_label in .add_updat…
irvanalhaq9 Jun 19, 2025
3377f6c
Replace exceptions, remove unused parameters, and fix type hints in `…
irvanalhaq9 Jun 20, 2025
23a2df1
use the same opacity to init the super class obj of DecimalNumber (#4…
ishu9bansal Jun 21, 2025
c9707f2
Introduce seed in `random_color` method to produce colors determinist…
ishu9bansal Jun 21, 2025
6486299
Refactor `Rotating` and add docstrings to `Mobject.rotate()` and `Rot…
irvanalhaq9 Jun 22, 2025
a8458cb
Fix default config of manim init project to use correct pixel_height …
StevenH34 Jun 23, 2025
325fa08
Fixing files with few typing (mypy) errors (#4263)
henrikmidtiby Jun 23, 2025
a1bb049
Fix Microsoft typo in `TexFontTemplateLibrary` scene in `example_scen…
alterdim Jun 24, 2025
0cec802
Explicit mention all files that mypy should ignore in the mypy.ini co…
henrikmidtiby Jun 24, 2025
c4b7a80
Remove dead code from `scene.py` and `vector_space_scene.py` (#4310)
henrikmidtiby Jun 24, 2025
ea16d22
Add type annotations to `scene.py` and `vector_space_scene.py` (#4260)
henrikmidtiby Jun 24, 2025
9c43ad0
Store the original alpha channel from the image when creating the Ima…
henrikmidtiby Jun 26, 2025
a234ff3
Replace setup-texlive-action in CI workflow (#4326)
behackl Jul 3, 2025
f63ba71
Gracefully fall back when version metadata is missing (#4324)
mohiuddin-khan-shiam Jul 10, 2025
3d029c1
Fix for issue 4255 - Arrow3D: get_start() and get_end() methods both …
henrikmidtiby Jul 10, 2025
3721fb1
Use utf-8 encoding to read generated .tex files. (#4334)
OliverStrait Jul 20, 2025
9e74ee7
Add zero to remove negative zeros (#4332)
elshorbagyx Jul 20, 2025
f124235
Adding type annotations to polyhedra.py and matrix.py (#4322)
henrikmidtiby Jul 20, 2025
b83410a
Ensure that the stroke_width property of SVGMobject is not set to Non…
henrikmidtiby Jul 20, 2025
e54113e
Handling typing errors in text/numbers.py (#4317)
henrikmidtiby Jul 20, 2025
ec501b9
Remove manim.gui and move configure_pygui into Scene as a method (#4314)
chopan050 Jul 20, 2025
fdb5cb9
Add typing annotations to svg_mobject.py (#4318)
henrikmidtiby Jul 20, 2025
2790a70
Improved readability, grammar, as well as added docstrings for consis…
NASAnerd05 Jul 20, 2025
c1663f1
Bump astral-sh/setup-uv from 5 to 6 (#4234)
dependabot[bot] Jul 21, 2025
2f02eb9
Fix Prism rendering with wrong dimensions in OpenGL (#4003)
ra1u Jul 24, 2025
047db45
Add type annotations to `mobject/svg/brace.py` (#4309)
henrikmidtiby Jul 24, 2025
fd8ab62
Fix `BraceLabel.change_label()` and document `BraceText` (#4347)
henrikmidtiby Jul 24, 2025
e73b659
Add classes `MethodWithArgs`, `SceneInteractContinue` and `SceneInter…
chopan050 Jul 24, 2025
4ddf777
Include `Text.gradient` in hash to properly regenerate `Text` when it…
AbhilashaTandon Jul 25, 2025
b65b0f2
Fixed surface animations in OpenGL (#4286)
nubDotDev Jul 25, 2025
83d4301
Add docstrings for `ChangingDecimal` and `ChangeDecimalToValue` (#4346)
haveheartt Jul 25, 2025
a8c16fb
Add type hints to `mobject/value_tracker.py` (#4129)
fmuenkel Jul 25, 2025
dea245a
Fix duplicate references in `Scene.mobjects` after `ReplacementTransf…
irvanalhaq9 Jul 26, 2025
c7ff795
Add support for arithmetic operators `//`, `%`, `*`, `**` and `/` on …
fmuenkel Jul 26, 2025
088affd
Fix typo in import of OpenGLCamera (#4352)
fmuenkel Jul 26, 2025
21fe73b
Add type annotations to `manim/renderer/shader.py` (#4350)
henrikmidtiby Jul 27, 2025
7ea765a
Optimize Mobject.become() (#4357)
chopan050 Jul 29, 2025
df36f4f
Add type annotations to `tex_mobject.py` (#4355)
henrikmidtiby Jul 29, 2025
dba6fa8
Add type annotations to `three_d_camera.py` (#4356)
henrikmidtiby Jul 29, 2025
a9b65ee
Revert change of default value (#4358)
henrikmidtiby Jul 29, 2025
aa0cd4f
Add type hints to `scene_file_writer.py`, `section.py`, and `zoomed_s…
fmuenkel Jul 30, 2025
7eb8856
Add type annotations for most of `camera` and `mobject.graphing` (#4125)
henrikmidtiby Aug 1, 2025
d18dc8f
Add `VectorNDLike` type aliases (#4068)
chopan050 Aug 1, 2025
9c9ebf4
Add type annotations to `dot_cloud.py`, `vectorized_mobject_rendering…
henrikmidtiby Aug 1, 2025
04503ad
Fix Sphinx exceptions when trying to build documentation via latex / …
behackl Aug 6, 2025
ded54e4
Add type annotations to `indication.py` (#4367)
henrikmidtiby Aug 6, 2025
c887b51
Add type annotations to `composition.py` (#4366)
henrikmidtiby Aug 6, 2025
e339a68
Add type annotations to `growing.py` (#4368)
henrikmidtiby Aug 6, 2025
d0521fa
Add type annotations to `movement.py` (#4371)
henrikmidtiby Aug 6, 2025
fc68c10
Add info-level logging for config files read and enhance output (#4375)
xnov18 Aug 7, 2025
2d8d81c
[pre-commit.ci] pre-commit autoupdate (#4204)
pre-commit-ci[bot] Aug 9, 2025
d8a7e55
Exclude check for cyclic imports by CodeQL (#4384)
behackl Aug 9, 2025
cb8af6f
Bevel cube corners (#4361)
nubDotDev Aug 9, 2025
b3df1cf
Properly define init_points methods (#4360)
chopan050 Aug 9, 2025
05cc414
Refactor imports from `collections.abc`, `typing` and `typing_extensi…
chopan050 Aug 9, 2025
48d5a36
Typing `opengl_renderer_window.py` (#4363)
fmuenkel Aug 9, 2025
b8844b4
fix: nested groups work fine
Merzlikin-Matvey Aug 10, 2025
0884fea
Merge
Merzlikin-Matvey Aug 10, 2025
654068a
fix: add return type hints for animation methods
Merzlikin-Matvey Aug 10, 2025
2d13eba
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 10, 2025
d10fb37
fix: update return type hints for animation methods to include OpenGL…
Merzlikin-Matvey Aug 10, 2025
1082089
Merge remote-tracking branch 'origin/main'
Merzlikin-Matvey Aug 10, 2025
6d65242
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion manim/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,18 @@
# 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like (without testing it) there might perhaps still be issues with nested groups?

Could you try whether assembling the animation_mobjects list as a flattened list of all (recursively enumerated) mobjects in the potentially nested groups still has your fix work as intended?

The easiest way to do this is probably by doing something along the lines of

for anim in animations:
    animation_mobjects.extend(anim.mobject.get_family())

Copy link
Author

@Merzlikin-Matvey Merzlikin-Matvey Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review! I am going to fix it in a few days, but I think I will open another PR for this (because there are problems with merge conflicts etc)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened new PR. Nested groups now work fine. Please review it
#4389


mobjects = self.get_mobject_family_members()
for i, mob in enumerate(mobjects):
update_possibilities = [
Expand Down
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/test_graphical_units/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down