feat(web): mascot physics juice (bounce, skid, spring squash, hop) + typewriter speech bubble
Some checks failed
ci / build-test (push) Has been cancelled
ci / docker-build (push) Has been cancelled
ci / web (push) Has been cancelled
Desktop App / Build Linux (amd64) (push) Has been cancelled
Desktop App / Attach to Release (push) Has been cancelled

This commit is contained in:
2026-07-21 00:06:44 +02:00
parent d82095213a
commit eb3d2de1ca
7 changed files with 509 additions and 50 deletions

View File

@@ -16,13 +16,13 @@
**Status of this Model:** the subsystem it describes is **implemented**
in `web/src/lib/mascot/` and `web/public/mascot/` (as of 2026-07-20).
Views below are marked **Implemented** where the code matches; a small
number of requirements (distinct adult art, reaction speech-bubble
rendering, a squash frame on `land`) remain **Planned** as polish
items. The corresponding implementation plan is
[plans/2026-07-20-desktop-mascot.md](../../plans/2026-07-20-desktop-mascot.md),
number of requirements (distinct adult art, a true round radial menu)
remain **Planned** as polish items. The corresponding implementation plan
is [plans/2026-07-20-desktop-mascot.md](../../plans/2026-07-20-desktop-mascot.md),
which carries a deviation note at the top covering the changes made
during implementation (hatch-on-naming, PNG-sheet art, button-column
radial menu, 60fps loop).
radial menu, 60fps loop), and the physics audit/follow-up is
[plans/2026-07-20-mascot-physics-audit.md](../../plans/2026-07-20-mascot-physics-audit.md).
## Views in this model
@@ -94,7 +94,7 @@ Traced from the original feature request. Status reflects the
| MASC-5 | The mascot SHALL have a tamagotchi lifecycle: egg → chick → adult, with a user-assignable name; the egg → chick transition fires on first naming, not on a timed incubation | User request | Implemented |
| MASC-6 | The mascot's stage, name, and stats SHALL persist across reloads | User request (implied by "tamagotchi") | Implemented |
| MASC-7 | The mascot SHALL have idle states (autonomous behavior when untouched) and interactive states (drag, click, menu) | User request | Implemented |
| MASC-8 | The mascot SHALL react visibly to real application activity: chat streaming, knowledge-graph writes, critical signals | User request ("aware of its environment... feels alive and connected") | Implemented (bubble overlay rendering still Planned) |
| MASC-8 | The mascot SHALL react visibly to real application activity: chat streaming, knowledge-graph writes, critical signals | User request ("aware of its environment... feels alive and connected") | Implemented |
| MASC-9 | Animations, behaviors, menu actions, and reactions SHALL each be defined in a single data-driven registry, so a new one can be added without touching the engine code | User request ("easily expansible") | Implemented |
| MASC-10 (NFR) | The mascot's game loop SHALL run via `setTimeout`, not `requestAnimationFrame`, matching the repo's existing [`GraphBackground.svelte`](../../web/src/lib/components/GraphBackground.svelte) convention (rAF suspends in some hidden-tab embeddings); runs at ~60fps (relaxed from 30fps for smoother drag/fall — see plan deviation note) | Codebase convention | Implemented |
| MASC-11 (NFR) | The mascot SHALL never write to the API; all mutation is local (localStorage) | Design decision, this document §1 | Implemented |
@@ -220,14 +220,17 @@ stateDiagram-v2
wander --> idle
idle --> peck : weighted random pick
peck --> idle
idle --> hop : weighted random pick
hop --> idle : touchdown\n(off-edge mid-hop hands to falling)
idle --> sleep : weighted random pick
sleep --> idle
wander --> falling : y below ground\n(off a dragged edge, etc.)
idle --> dragged : pointerdown + move\npast 5px threshold
wander --> dragged : pointerdown + move
sleep --> dragged : pointerdown + move\n(interrupts sleep)
dragged --> falling : pointerup, released mid-air
falling --> land : y reaches ground
dragged --> falling : pointerup, released mid-air\n(toss velocity from pointer history)
falling --> falling : hard impact\n(one diminished bounce)
falling --> land : y reaches ground\n(sideways momentum -> skid)
land --> idle
[*] --> react : stimulus dispatched\n(priority/cooldown gated)
react --> idle : durationMs elapsed,\nreturns to prior-or-idle
@@ -244,6 +247,19 @@ returns null past `behaviorUntil` — see
[plans/2026-07-20-desktop-mascot.md](../../plans/2026-07-20-desktop-mascot.md)
for the concrete weights.
**Physics feel (implemented 2026-07-20, second pass):** the fall is a
losing attempt at flight, not a drop — wing-beat impulses on a
speed-scaled, jittered flap cycle (panic flapping) shave the descent;
falls faster than terminal velocity (hard downward tosses) decay back
under drag instead of clamping; hard impacts bounce once, squash via a
damped-spring render layer scaled by impact speed, and poof a burst of
feather pixels; sideways momentum becomes a friction skid on touchdown
and ricochets off the surface's side bounds mid-fall; the sprite
stretches along its motion in the air and tilts into horizontal velocity
(fall, drag, and skid); walking bobs at step frequency. All of it is
tuning in `behavior.ts` plus the pure render layer in `Mascot.svelte`'s
`updateJuice()` — no new assets, no new states beyond `hop`.
### 4.2 Tamagotchi lifecycle (long-lived state)
```mermaid