You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Manim CE v0.10中TracedPath生成轨迹后如何关闭自动追踪功能

Manim CE v0.10 关闭TracedPath追踪的解决方案

TracedPath默认会通过绑定的更新器每帧从传入的点对象获取位置,追加绘制轨迹,要停止追踪可以采用以下两种方案:

方案1:移除TracedPath的更新器

完成需要的追踪动画后,直接调用remove_updater方法移除绑定的轨迹更新逻辑,后续不管是移动原TracedPath还是它的拷贝,都不会再继续追踪。
修改后的示例代码如下:

class TracedPathProblem(Scene):
    def construct(self):
        dot = Dot(color=RED)
        trace = TracedPath(dot.get_center,stroke_color=RED)
        self.add(dot,trace)
        self.play(dot.animate.shift(RIGHT),run_time=2)
        # 移除trace的更新器,停止追踪
        trace.remove_updater(trace.updaters[0])
        path = trace.copy()
        self.play(path.animate.shift(2*UP+RIGHT)) # 此时不会再产生新的追踪轨迹
        self.wait()

方案2:将已有轨迹转为普通VMobject

如果不需要再保留原TracedPath的追踪能力,可以直接提取已绘制的点生成普通的路径对象,完全脱离追踪逻辑,适合需要对历史轨迹做大量变换的场景:

class TracedPathProblem(Scene):
    def construct(self):
        dot = Dot(color=RED)
        trace = TracedPath(dot.get_center,stroke_color=RED)
        self.add(dot,trace)
        self.play(dot.animate.shift(RIGHT),run_time=2)
        # 提取已有轨迹生成普通VMobject
        static_path = VMobject(stroke_color=RED).set_points(trace.get_points())
        self.play(static_path.animate.shift(2*UP+RIGHT))
        self.wait()

注意:如果是v0.14及以上版本的Manim,TracedPath已经内置了update_on参数可以直接控制是否开启追踪,v0.10版本需使用上述方法实现。

内容的提问来源于stack exchange,提问作者DJElectric

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.04 23:12:00