- Pose blending between anims (render/blend.ts): the on-screen pose is lerped into the next anim, drawn live, only when the pose change is abrupt; fast and physics-driven anims (jumps, land, startle, happy...) opt out with ease: 0 - Left/right turns animate as a quick fake rotation (CSS scaleX + small hop) - Follow: hysteresis on look up/down/sniff, no flip when the cursor is right above - New `motion` config (blend multiplier, turnTime) + Leva "Transitions" folder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2.4 KiB
Animations
render/anims/* define AnimDef { frames, fps, loop, box?, ease?, pose(p, i) }: p is progress (0..1, exclusive end when looping), i the frame index, pose returns a partial pose. box (in u) sizes the baked frame; default { w: 1.5, up: 1.05, down: 0.1 }, it must fit in the View CANVAS. ease is the longest transition the anim accepts.
Helpers in anims/kit.ts: sitUp(t) (rear up on hind legs, paws as arms, face upright), steps (diagonal gait), paddle (legs flailing), blink(i, at), boxes SIT_BOX, HOP_BOX. Easing helpers live in pose.ts.
| file | anims |
|---|---|
locomotion.ts (pinned) |
idle walk run crouch jumpUp jumpDown fall land landHard climb hang |
idle.ts |
sit groom stretch yawn look sniff curious curiousDown sleep fallAsleep wake eat |
interact.ts |
happy purr roll squish unsquish startle dizzy dizzyBack getup getupBack |
reactions.ts |
the 12 reactions |
Transitions
render/blend.ts, driven by AnimPlayer. When the anim changes, the pose on screen is blended into the new anim's frames (numbers lerped with easeInOut, discrete fields like eye/mouth switch half way), drawn live through View.drawPose, then the baked strip takes over pixel-exactly.
- Only abrupt changes blend:
poseDiff(weighted max delta, inu) under 0.03 snaps; the duration ismin(from.ease, to.ease)(default 0.24 s) scaled by the diff (half under 0.3). ease: 0opts out: crouch, jumps, fall, land(s), climb, hang, startle, surprised, squish, happy. Walk/run use 0.14.- No blend across
backchanges, ragdollfeet, same-anim restarts, or right after a ragdoll (snap()). motion.blendscales every duration (0 = off). Left/right turns are separate: see rendering.
Reactions
approve cancel delete error success warning thinking love wave surprised confused sad. Looping ones (thinking love wave confused sad) run duration seconds (2.6 default) or until replaced with hold. FX cues per reaction (check, cross, poof, sweat, confetti, hearts…) are timed in brain/social.ts.
Adding one
- Add the def to the right file (keep files under ~300 lines).
- If it is a reaction, add its name to
REACTION_NAMES(types.ts) and its cues toCUES(brain/social.ts). - Trigger it from a brain task with
once(c, name)/hold(c, name, s)(brain).