3b1b / 3b1b/manim

Get current frame with caching enabled

Aperta
#2,020 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Python
Stelle
93.8k
Fork
7.7k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

### 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
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.