3b1b / 3b1b/manim

Get current frame with caching enabled

未关闭
#2,020 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
Python
星标
93.8k
派生
7.7k
PR 合并指标
PR 指标待抓取

描述

### Describe the bug

I’d like to get the current frame number of an animation (start/stop) to sync it in another tool with other stuff. uwezi suggested to use:
```
self.framenumber=0
def sceneUpdater(dt):
self.framenumber += 1
self.add_updater(sceneUpdater)
```
to count frames: this seems to work great when the caching is disabled with `--disable_caching`, but otherwise even a basic scene would fail to render.

**Code**:
```
from manim import *

class CreateCircle(Scene):
def construct(self):
self.framenumber=0
def sceneUpdater(dt):
self.framenumber += 1
self.add_updater(sceneUpdater)

circle = Circle() # create a circle
circle.set_fill(PINK, opacity=0.5).scale(.5) # Change the scale to get different frame numbers
self.play(Create(circle))
print(f"Current frame is {self.framenumber}", flush=True)
self.play(Uncreate(circle))
print(f"Current frame is {self.framenumber}", flush=True)
```
**Wrong display or Error traceback**:
```
$ manimanim -pql test_manim.py CreateCircle | rg "Current frame"
Current frame is 1
Current frame is 2
$ manim -pql test_manim.py CreateCircle --disable_caching | rg "Current frame"
Current frame is 15
Current frame is 30
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。