Skip to content

Bug: Using AnimationGroup(Add(...), ...) spawns extra mobject #4426

@AlleyNorthward

Description

@AlleyNorthward

Description of bug / unexpected behavior

When using AnimationGroup with Add(mobject), an unexpected duplicate of the mobject is created at the bottom of the scene.

Expected behavior

In most cases, there is no issue. However, if the mobject is compressed or scaled down, this bug may occur. While directly calling self.add() on the object in the scene can solve the problem, I don’t want to always combine self.add() with self.play() just to avoid it.

How to reproduce the issue

Example code:
class Test(Scene):
def construct(self):
A = ACreature("plain")
self.play(
AnimationGroup(
Add(A),
A.left_eye.animate.blink(),
)
)

Code for reproducing the problem
Paste your code here.
Source code: def blink(self): pass
@override_animate(blink)
def _blink_animation(self, **anim_kwargs):

    return AnimationGroup(
        # TODO 这里的Add()总是搞不定, 不知道为啥.眼睛总是在身体下方多出来一对
        # TODO 无法解决.感觉可能是因为多组的原因造成的.因为才CreatureEye中
        # TODO 返回的是组中组,这里可能存在问题.

        # HACK 所以生成对象后,必须添加self.add(ACreature())
        # FIXME 待修复

        # INFO 发现是AnimationGroup的问题,与Add一起可能存在问题.解决方法是将scene添加到场景中.
        # 直接解决方案是在scene中添加对象.
        # 可是还是为了与manim动画思想保持一致,play与add尽量不共存,虽然没有任何影响.
        Add(self),
        self.left_eye.animate.blink(),
        self.right_eye.animate.blink(),
        **anim_kwargs
    )

Additional media files

Nonthing

Images/GIFs

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): 3.12.2
  • Installed modules (provide output from pip list):
PASTE HERE
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020):
  • Installed LaTeX packages:

Additional comments

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions