Skip to content
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

Remove duplicate items #2036

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

LinZezh1
Copy link

@LinZezh1 LinZezh1 commented Jun 29, 2023

Motivation

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.

Proposed changes

Add items = list(set(items)) in the get_all_mobjects_to_update method of the Animation class to achieve the purpose of removing duplicate items.

Code and test

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)


After running the above code, the Earth in the video will first rotate quickly and then decelerate. This is due to the get_all_mobjects_to_update method (TransForm.get_all_mobjects) in the Animation class returning duplicate mobjects(TransForm.get_all_mobjects.target_copy).

default.mp4

Therefore, I used the set function in the get_all_mobjects_to_update method of the Animation class to remove duplicate mobjects, which prevented the issue from occurring(fixed video)

default.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant