Download source/src/game/microduck/sampleEmotion.js from FormaLau/microduck-reachy-simulator: direct link, hf CLI and curl.
- Browser
- Download file 620 Bytes
-
https://huggingface.co/spaces/FormaLau/microduck-reachy-simulator/resolve/main/source/src/game/microduck/sampleEmotion.js
- Command line
-
hf download hf://spaces/FormaLau/microduck-reachy-simulator/source/src/game/microduck/sampleEmotion.js
-
curl -L -o sampleEmotion.js https://huggingface.co/spaces/FormaLau/microduck-reachy-simulator/resolve/main/source/src/game/microduck/sampleEmotion.js
620 Bytes
| export function sampleEmotion(frames, time) { | |
| let index = 0; | |
| while (index + 1 < frames.length && frames[index + 1].t <= time) index++; | |
| const a = frames[index], b = frames[Math.min(index + 1, frames.length - 1)]; | |
| const mix = b.t > a.t ? Math.max(0, Math.min(1, (time - a.t) / (b.t - a.t))) : 0; | |
| const frame = { ...a }; | |
| for (const key of ["neck", "head_pitch", "head_yaw", "head_roll", "body_pitch", "body_roll", "body_z", "mouth"]) frame[key] = (a[key] || 0) + ((b[key] || 0) - (a[key] || 0)) * mix; | |
| frame.twist = (a.twist || [0, 0, 0]).map((v, i) => v + ((b.twist?.[i] || 0) - v) * mix); | |
| return frame; | |
| } | |