manim camera.move_to 和 camera.scale 同时不起作用

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

这是一个示例代码:

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()

我不明白的是为什么它只是缩小而不是同时向左移动和缩小,只是以 circle_left 为中心并缩小。 self.camera.frame.animate.move_to(circle_left.get_center()) 似乎被忽略了。

我知道将它们分成两个 self.play 是可行的,但我希望同时进行缩小和向左移动:/

感谢您的帮助!

Manim 不会以这种方式处理在同一对象上调用的同步动画。相反,您实际上可以使用 .animate 语法链接动画以获得您想要的效果。所以:

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

有关更多上下文,请参阅文档中的教程:

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