ManimCommunity / ManimCommunity/manim

ReplacementTransform and z_index issue

Open
#3,110 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior

When I use the `ReplacementTransform(source_mobject, target_mobject)` function to transform a mobject, I find that `target_mobject.z_index` is unchanged, but the `target_mobject` will show as that `target_mobject.z_index` is changed to `source_mobject.z_index`.

Please see the code and gif below, I expect that the blue circle is above the red circle because the z_index of the blue circle is greater, but the result show that the blue circle is below the red circle.

## Expected behavior

The blue circle is above the red circle.

## How to reproduce the issue

Code for reproducing the problem

```py
from manim import *

class zIndexBug(Scene):
def construct(self):
circle = Circle(color=RED, fill_opacity=1).move_to(UP*0.5)
circle.set_z_index(3)
circle2 = Circle(color=BLUE, fill_opacity=1)
circle2.set_z_index(6)

circle3 = Circle(color=GREEN, fill_opacity=1).move_to(LEFT*3)
circle3.set_z_index(1)

self.play(FadeIn(circle3), FadeIn(circle))
self.play(ReplacementTransform(circle3, circle2))

```

## Additional media files

Images/GIFs

![](https://i.imgur.com/VB0KCrP.gif)

## Logs
Terminal output

```
PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR
```

## System specifications

System Details

- OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)):
- RAM:
- Python version (`python/py/python3 --version`):
- Installed modules (provide output from `pip list`):
```
PASTE HERE
```

LaTeX details

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:

FFMPEG

Output of `ffmpeg -version`:

```
PASTE HERE
```

## Additional comments

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Scene reproduction and inspect ReplacementTransform's handling of source_mobject and target_mobject z_index during the animation. Done means the blue target circle renders above the red circle according to its higher z_index, while the reported target_mobject.z_index behavior is consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.