3b1b / 3b1b/manim

Get current frame with caching enabled

オープン
#2,020 コメント 0 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。