Download src/shared/actor-slots.mjs from xlt99/EmboDi: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/xlt99/EmboDi/resolve/main/src/shared/actor-slots.mjs
- Command line
-
hf download hf://spaces/xlt99/EmboDi/src/shared/actor-slots.mjs
-
curl -L -o actor-slots.mjs https://huggingface.co/spaces/xlt99/EmboDi/resolve/main/src/shared/actor-slots.mjs
1.04 kB
| const CAST_SIZE = 5; | |
| function castSlots(actors) { | |
| if (actors.length > CAST_SIZE) throw new Error(`This demo uses ${CAST_SIZE} actors. Remove extra actors first; existing actors are not deleted automatically.`); | |
| const used = /* @__PURE__ */ new Set(); | |
| for (const actor of actors) if (actor.castSlot !== void 0) { | |
| if (!Number.isInteger(actor.castSlot) || actor.castSlot < 1 || actor.castSlot > CAST_SIZE || used.has(actor.castSlot)) throw new Error("Invalid or duplicate actor motion slot"); | |
| used.add(actor.castSlot); | |
| } | |
| return actors.map((actor) => { | |
| if (actor.castSlot !== void 0) return { ...actor }; | |
| const slot = Array.from({ length: CAST_SIZE }, (_, i) => i + 1).find((i) => !used.has(i)); | |
| used.add(slot); | |
| return { ...actor, castSlot: slot }; | |
| }); | |
| } | |
| function nextCastSlot(actors) { | |
| const used = new Set(castSlots(actors).map((a) => a.castSlot)); | |
| return Array.from({ length: CAST_SIZE }, (_, i) => i + 1).find((i) => !used.has(i)) ?? null; | |
| } | |
| export { | |
| CAST_SIZE, | |
| castSlots, | |
| nextCastSlot | |
| }; | |