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

发布于 2025-01-10 05:50:16 字数 705 浏览 0 评论 0原文

这是一个示例代码:

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 是可行的,但我希望缩小和移动到左侧圆圈同时发生:/

感谢您的帮助!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白衬杉格子梦 2025-01-17 05:50:16

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

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

请参阅文档中的教程以获取更多上下文:

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文