简体   繁体   中英

manim camera.move_to and camera.scale at the same time don't work

Here is a sample code:

from manim import *
import numpy as np


class Problem(MovingCameraScene):
    def construct(self):
        circle_left = Circle(radius=2).move_to(np.array([-3, 0, 0]))
        circle_right = Circle(radius=2).move_to(np.array([3, 0, 0]))
        self.add(circle_left, circle_right)
        self.wait()
        self.play(self.camera.frame.animate.move_to(circle_left.get_center()), self.camera.frame.animate.scale(2))
        self.wait()

What I don't understand is why it just zooms out and doesn't moves to the left and zooms out at the same time, only to end up centered around circle_left AND zoomed out. It looks like self.camera.frame.animate.move_to(circle_left.get_center()) was ignored.

I know that separating them in two self.play works but I would like both the zooming out and the moving to the left circle happening at the same time:/

Thanks for the help!

Manim doesn't handle simultaneous animations called on the same mobject in that manner. Instead, you can actually chain animations with the .animate syntax to get the effect you want. So:

self.camera.frame.animate.move_to(<code>).scale(<code>)

Refer to the tutorial in the docs for more context:

https://docs.manim.community/en/stable/tutorials/building_blocks.html#animating-methods

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM