Spaces:
Running
Running
Download src/anim.js from cloudronin/astara: direct link, hf CLI and curl.
- Browser
- Download file 659 Bytes
-
https://huggingface.co/spaces/cloudronin/astara/resolve/main/src/anim.js
- Command line
-
hf download hf://spaces/cloudronin/astara/src/anim.js
-
curl -L -o anim.js https://huggingface.co/spaces/cloudronin/astara/resolve/main/src/anim.js
659 Bytes
| // Clip playback. Rate and frame count come from the manifest; this file has no | |
| // opinion about either. | |
| export function createPlayer(clip) { | |
| return { | |
| clip, | |
| time: 0, | |
| reset() { this.time = 0; }, | |
| advance(dt) { this.time += dt; }, | |
| get index() { | |
| const raw = Math.floor(this.time * this.clip.fps); | |
| if (!this.clip.loop) return Math.min(Math.max(raw, 0), this.clip.count - 1); | |
| return ((raw % this.clip.count) + this.clip.count) % this.clip.count; | |
| }, | |
| get finished() { | |
| return !this.clip.loop && this.time * this.clip.fps >= this.clip.count - 1; | |
| }, | |
| frame() { return this.clip.frames[this.index]; }, | |
| }; | |
| } | |