- Split into yarn workspaces: packages/pet-pet (npm package: ESM, UMD, IIFE, d.ts, optional pet-pet/react hook + component) and apps/demo. - Demo "Installation" page: install tabs, vanilla/React/script usage, live reaction chips, options, methods, events. - Release workflow on v* tags: npm publish with provenance and a GitHub Release with the tarball. Pages deploy now type-checks and lints. - Head bump is now a real head merged into the body path; face and ears follow it instead of sitting under a bump. - Ragdoll forces go through torque-consistent impulses and the grab is a point constraint, so holding it no longer spins it up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.1 KiB
Rendering
Flat style, no outline: a rounded rectangle on 4 legs, 3/4 view facing right (+x), feet on y = 0, y down, units of u.
Layers (render/layers.ts, render/face.ts)
Painter order: far legs (shaded) → ears → tail → body (+ head) → belly → stripe → highlight → face (muzzle, blush, eyes, nose, mouth, whiskers, prop) → near legs.
Appearance = palette (fur belly line paws inner blush eyes nose) + shape (roundness chubby legLength headBump stripe bellyStyle bellyWidth) + face (face earSize eyeSize cheekSize whiskers).
SHAPESpresets:soft(default, mix of loaf and block, belly ellipse),loaf(rounder, belly band),head(head bump),stripe(dorsal stripe),block(square, no belly).headBump(0–1): grows a head circle (headCircle) at the front-top, merged into the body path so belly, stripe and pouch clip to one silhouette. The face (HEADoffset inface.ts) and the ears move up and forward with it.bellyStyle:patch(centered ellipse clipped by the body,bellyWidth= its x radius),band,none.face:mochi(default: oval glossy eyes, small muzzle),classic(big muzzle),pouch(cheek pouch clipped by the body). Geometry per style inFACES(face.ts).
Pose (render/pose.ts)
One flat object; animations return partial poses.
- Body:
bx byoffset,rotaroundpiv(−1 rear, 1 front, on the belly line),sx sysquash from the belly line,leanskew. - Legs: foot offsets
fbx fby ffx ffy nbx nby nfx nfy(far/near, back/front). Feet are planted on the ground unlessfloat(follow the body),grip(front paws stay planted),arm(front paws held in front of the chest).feetoverrides absolute positions (ragdoll). back: lying on its back (body flipped, legs up, face kept upright).- Face:
fx fy tilt,upright(counter-rotates bodyrot),eyestyle +eyeOpen lookX lookY,mouthstyle +mouthOpen,cheekpuff,blush,earF earN earDown,tail,phase,prop.
Strips (render/strips.ts)
Each animation is baked lazily into one horizontal image strip (fw × frames) at the current u and DPR. SpriteBank is an LRU with a pixel budget (12 M px); locomotion strips are pinned and prewarmed on idle. Appearance/size changes clear it.
View (render/View.ts)
A fixed layer (data-pet-ignore) holding the shadow, a wrapper moved with translate3d, the canvas (CANVAS box in u) and an invisible hitbox. drawStrip blits one frame; drawPose draws a blended pose during transitions; drawLive draws the ragdoll through render/ragdoll.ts, which picks the drawing frame so the face stays upright and switches to back from the legs' side.
Facing turns are a CSS rotation fake: an angle goes 0 → π in motion.turnTime (0.18 s), the canvas gets scaleX(cos) (never thinner than 0.14) plus a small hop. It snaps when leaving the ragdoll.
FX
fx/Fx.ts spawns small SVG/DOM particles animated with WAAPI (transform/opacity only). fx/Bubble.ts is the speech bubble, fx/Seed.ts the falling seed.