3b1b / 3b1b/manim

Get current frame with caching enabled

Đang mở
#2,020 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
93.8k
Fork
7.7k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.