3b1b / manim

Animation engine for explanatory math videos
MIT License
70.79k stars 6.23k forks source link

The get_all_mobjects_to_update method in the Animation class will result in returning duplicate Mobjects. #2039

Open LinZezh1 opened 1 year ago

LinZezh1 commented 1 year ago

Describe the error

When the always_rotate function and the FadeIn function are applied to a mobject simultaneously, some errors may occur. In the Animation class, the get_all_mobjects_to_update method would cause duplicate Mobjects to be returned, and update was performed on all of them.

Code and Error

Code:

class AnimationIssue(ThreeDScene):

    def construct(self) -> None:
        day_texture = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Whole_world_-_land_and_oceans.jpg/1280px-Whole_world_-_land_and_oceans.jpg"
        night_texture = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/The_earth_at_night.jpg/1280px-The_earth_at_night.jpg"
        sphere = Sphere(radius=RADIUS)

        surface = TexturedSurface(sphere, day_texture, night_texture)
        always_rotate(surface)
        self.play(FadeIn(surface, run_time=2))
        self.wait(3)

Error: In the Animation class, the get_all_mobjects_to_update method would cause duplicate Mobjects to be returned, and update was performed on all of them.

Solution

https://github.com/3b1b/manim/pull/2036

Environment

OS System: windows 11 manim version: v1.6.1 python version: 3.11