@adatechnology/game-player 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/physics-controller.ts","../src/foot-rest.ts","../src/walker.ts","../src/furniture-push.ts","../src/door-use.ts","../src/hands.ts","../src/lift.ts","../src/hand-math.ts","../src/item-grip.ts","../src/take-sequence.ts","../src/step-pose.ts","../src/gesture.ts","../src/gesture-hands.ts"],"sourcesContent":["import type { CharacterId, PhysicsWorld, Vec3 } from '@adatechnology/game-physics'\n\nimport type { PlayerCollider } from './player'\nimport type { PlayerController } from './types'\n\n/** The part of the physics contract the player's body uses: any `PhysicsWorld` (or the loop's `SeamWorld`) has it. */\nexport type PlayerPhysicsWorld = Pick<PhysicsWorld, 'createCharacter' | 'moveCharacter' | 'pushCharacter' | 'readCharacter' | 'teleportCharacter' | 'removeCharacter' | 'characterSupported'>\n\nexport type PhysicsControllerOptions = {\n /** Where the feet are. */\n readonly position: Vec3\n /** What `player.collider()` says: the capsule is made as tall and as wide as the standing body. */\n readonly collider: PlayerCollider\n /** Kilograms, default 75. */\n readonly mass?: number\n /** Most force (N) it pushes a prop with, default 400: a 30 kg crate over wood, not a wardrobe. */\n readonly strength?: number\n}\n\nexport type PhysicsPlayerController = PlayerController & {\n readonly id: CharacterId\n /** Shoves the body: `impulse` in N s (a blow, a blast, a car's bumper); the controller feels it as impulse / mass, fading in a quarter of a second. */\n push(impulse: Vec3): void\n supported(): boolean\n dispose(): void\n}\n\nexport const PLAYER_MASS_KG = 75\nexport const PLAYER_PUSH_STRENGTH_NEWTONS = 400\n/** The most a person puts into what is in the way just by walking into it, without leaning on it on purpose: about the sustained push force of ISO 11228-2 for a man (100 N), the order of what a walk can keep up. A thing whose floor grip is above it (a 28 kg sofa on wood: 115 N) stops the walk; a lighter one is shoved along. */\nexport const PLAYER_WALK_PUSH_NEWTONS = 100\n\n/**\n * The player's controller in a physics world: a capsule as tall as the standing body (a crouch does not shrink it) that steps up, climbs, pushes props and is\n * pushed. Put it in `PlayerWorld.controller` and call `player.update(h, input)` from a `beforeStep(h)` of the loop's `actors` phase, never with the frame's `dt`.\n */\nexport const createPhysicsController = (world: PlayerPhysicsWorld, options: PhysicsControllerOptions): PhysicsPlayerController => {\n const { radiusMetres, heightMetres } = options.collider\n const id = world.createCharacter({\n position: options.position,\n radius: radiusMetres,\n halfHeight: Math.max(0, (heightMetres - 2 * radiusMetres) / 2),\n mass: options.mass ?? PLAYER_MASS_KG,\n strength: options.strength ?? PLAYER_PUSH_STRENGTH_NEWTONS,\n })\n return {\n id,\n move: (velocityX, velocityZ, dt) => world.moveCharacter(id, velocityX, velocityZ, dt),\n read: (out) => world.readCharacter(id, out, 0),\n teleport: (x, y, z) => world.teleportCharacter(id, [x, y, z]),\n push: (impulse) => world.pushCharacter(id, impulse),\n supported: () => world.characterSupported(id),\n dispose: () => world.removeCharacter(id),\n }\n}\n","/** Samples of the ground across the foot's disc, per radius: the disc is walked in rings of this many steps. */\nconst RINGS = 32\nconst SAMPLES_PER_RING = 48\n\n/**\n * The height a round foot of `radius` comes to rest at over ground `heightAt` (the lower sphere of the capsule): the highest, over the points of the disc under it, of\n * the ground there less how far the sphere's underside rises above its lowest point at that distance. Flat ground gives its own height; a bowl holds the foot above its middle.\n */\nexport const footRestHeight = (heightAt: (x: number, z: number) => number, x: number, z: number, radius: number): number => {\n let rest = heightAt(x, z)\n for (let ring = 1; ring <= RINGS; ring++) {\n const distance = (radius * ring) / RINGS\n const lift = radius - Math.sqrt(radius * radius - distance * distance)\n for (let sample = 0; sample < SAMPLES_PER_RING; sample++) {\n const angle = (2 * Math.PI * sample) / SAMPLES_PER_RING\n rest = Math.max(rest, heightAt(x + distance * Math.cos(angle), z + distance * Math.sin(angle)) - lift)\n }\n }\n return rest\n}\n","import type { BodyId, CharacterId, CharacterShape, Layer, PhysicsServices, Quat, Vec3 } from '@adatechnology/game-physics'\n\nimport { PLAYER_MASS_KG, PLAYER_PUSH_STRENGTH_NEWTONS } from './physics-controller'\nimport type { PlayerCollider } from './player'\n\n/** The vertical speed (m/s) of a jump under the world's 9.81: it rises 0.81 m, as high as the walker's own jump always did. */\nexport const WALKER_JUMP_SPEED = 3.99\n\nexport type WalkerStance = 'standing' | 'crouched' | 'prone'\n\n/** A stance is this fraction of the standing height: 1.80, 1.20 and 0.60 m for a person 1.80 m tall. */\nconst STANCE_HEIGHT_RATIO: Readonly<Record<WalkerStance, number>> = { standing: 1, crouched: 2 / 3, prone: 1 / 3 }\nconst NO_ROTATION: Quat = [0, 0, 0, 1]\n/** The probe sits this much (m) above the feet: the floor it will stand on touches the capsule and is not an overlap. */\nconst PROBE_LIFT = 0.03\nconst SOLID_LAYERS: readonly Layer[] = ['static', 'debris', 'prop', 'vehicle', 'character']\n\nexport type WalkerOptions = {\n /** Where the feet are. */\n readonly position: Vec3\n /** The standing body: `player.collider()` while standing. */\n readonly collider: PlayerCollider\n /** Kilograms, default 75. */\n readonly mass?: number\n /** Most force (N) it pushes a prop with, default 400. */\n readonly strength?: number\n /** Default 0.4 m. */\n readonly stepHeight?: number\n readonly maxSlopeDegrees?: number\n /** Default 9.81. */\n readonly gravity?: number\n /** The layer of the body the world sees of the walker (`agent`: a vehicle does not stop on it). */\n readonly shadow?: Layer\n /** The shadow's `user`. */\n readonly user?: number\n /** What `unpark` may not stand in (default static, debris, prop, vehicle and character). */\n readonly solidLayers?: readonly Layer[]\n}\n\nexport type Walker = {\n /** The character in the world: another one after `unpark`. */\n readonly id: CharacterId\n readonly stance: WalkerStance\n readonly parked: boolean\n /** The wanted horizontal velocity (m/s, world x and z), kept until it is changed: the key of the frame, not of the step. */\n setIntent(velocityX: number, velocityZ: number): void\n /** A jump when the feet stand on something; false in the air or parked. */\n jump(): boolean\n /** Changes the stance; false (the stance stays) when the new capsule would penetrate something. */\n setStance(stance: WalkerStance): boolean\n /** Shoves the body: `impulse` in N s. */\n push(impulse: Vec3): void\n supported(): boolean\n /** The feet of the last fixed step into `out` (x, y, z). */\n read(out: Float32Array | Float64Array): void\n /** The feet between the last two fixed steps, `alpha` (0 to 1) of the way: the scheduler's alpha, not the loop's (`stepFixed` zeroes that one). */\n drawn(alpha: number, out: Float32Array | Float64Array): void\n /** Puts the feet here at once, with no sweep and no speed carried over, and the drawn feet with them (a respawn, a scripted step). Nothing happens while parked. */\n teleport(feet: Vec3): void\n /** Takes the body out of the world (a seat, an aircraft, a vehicle): it no longer moves or blocks. */\n park(): void\n /** Puts the body back at the first of `candidates` (feet) where the capsule overlaps nothing solid, in this order (the door, the far side, the roof); false, still parked, when none fits. */\n unpark(candidates: readonly Vec3[]): boolean\n /** Leaves the loop and the world. */\n dispose(): void\n}\n\nexport type WalkerServices = Pick<PhysicsServices, 'loop' | 'world'>\n\nconst shapeOf = (collider: PlayerCollider, stance: WalkerStance): CharacterShape => {\n const height = collider.heightMetres * STANCE_HEIGHT_RATIO[stance]\n const radius = Math.min(collider.radiusMetres, height / 3)\n return { radius, halfHeight: (height - 2 * radius) / 2 }\n}\n\n/**\n * The player's body in the physics world, walking in the loop's `actors` phase: the intent is set when the key changes, every fixed step walks it with the step's\n * `h`, and the feet of the last two steps are kept for drawing between them. No allocation after the first call.\n */\nexport const createWalker = (services: WalkerServices, options: WalkerOptions): Walker => {\n const { loop, world } = services\n const mass = options.mass ?? PLAYER_MASS_KG\n const shapes: Readonly<Record<WalkerStance, CharacterShape>> = { standing: shapeOf(options.collider, 'standing'), crouched: shapeOf(options.collider, 'crouched'), prone: shapeOf(options.collider, 'prone') }\n const solid = options.solidLayers ?? SOLID_LAYERS\n const found: BodyId[] = []\n const previous = new Float64Array(3)\n const current = new Float64Array(3)\n let intentX = 0\n let intentZ = 0\n let stance: WalkerStance = 'standing'\n let parked = false\n\n const create = (feet: Vec3): CharacterId =>\n world.createCharacter({\n position: feet,\n radius: shapes[stance].radius,\n halfHeight: shapes[stance].halfHeight,\n mass,\n strength: options.strength ?? PLAYER_PUSH_STRENGTH_NEWTONS,\n ...(options.stepHeight !== undefined ? { stepHeight: options.stepHeight } : {}),\n ...(options.maxSlopeDegrees !== undefined ? { maxSlopeDegrees: options.maxSlopeDegrees } : {}),\n ...(options.gravity !== undefined ? { gravity: options.gravity } : {}),\n ...(options.shadow !== undefined ? { shadow: options.shadow } : {}),\n ...(options.user !== undefined ? { user: options.user } : {}),\n })\n\n let id = create(options.position)\n world.readCharacter(id, current, 0)\n previous.set(current)\n\n const stopLoop = loop.add(\n {\n beforeStep: (h) => {\n if (parked) return\n previous.set(current)\n world.moveCharacter(id, intentX, intentZ, h)\n world.readCharacter(id, current, 0)\n },\n },\n 'actors',\n )\n\n const fitsAt = (feet: Vec3): boolean => {\n const shape = shapes[stance]\n const centre: Vec3 = [feet[0], feet[1] + PROBE_LIFT + shape.halfHeight + shape.radius, feet[2]]\n return world.overlapShape({ kind: 'capsule', halfHeight: shape.halfHeight, radius: shape.radius }, centre, NO_ROTATION, found, { layers: solid }) === 0\n }\n\n return {\n get id() {\n return id\n },\n get stance() {\n return stance\n },\n get parked() {\n return parked\n },\n setIntent: (velocityX, velocityZ) => {\n intentX = velocityX\n intentZ = velocityZ\n },\n jump: () => {\n if (parked || !world.characterSupported(id)) return false\n world.pushCharacter(id, [0, mass * WALKER_JUMP_SPEED, 0])\n return true\n },\n setStance: (next) => {\n if (parked) return false\n if (!world.setCharacterShape(id, shapes[next])) return false\n stance = next\n return true\n },\n push: (impulse) => world.pushCharacter(id, impulse),\n supported: () => world.characterSupported(id),\n read: (out) => {\n out[0] = current[0] as number\n out[1] = current[1] as number\n out[2] = current[2] as number\n },\n drawn: (alpha, out) => {\n const t = alpha < 0 ? 0 : alpha > 1 ? 1 : alpha\n for (let axis = 0; axis < 3; axis++) out[axis] = (previous[axis] as number) + ((current[axis] as number) - (previous[axis] as number)) * t\n },\n teleport: (feet) => {\n if (parked) return\n world.teleportCharacter(id, feet)\n world.readCharacter(id, current, 0)\n previous.set(current)\n },\n park: () => {\n if (parked) return\n parked = true\n world.removeCharacter(id)\n },\n unpark: (candidates) => {\n if (!parked) return true\n for (const feet of candidates) {\n if (!fitsAt(feet)) continue\n id = create(feet)\n parked = false\n world.readCharacter(id, current, 0)\n previous.set(current)\n return true\n }\n return false\n },\n dispose: () => {\n stopLoop()\n if (!parked) world.removeCharacter(id)\n parked = true\n },\n }\n}\n","/**\n * Pushing furniture on foot: hold the interaction button against a piece, a timer that grows with its mass fills, and the player then walks with it.\n * Engine-agnostic: the host says where the player wants to go and answers whether the volume of the piece can go there; this says how fast, and when it locks.\n */\n\nimport type { SurfaceId } from '@adatechnology/game-contracts'\n\n/** What dragging a piece leaves on a floor: a strip of this colour and width (metres) under each side of its base. */\nexport type DragMark = { readonly color: number; readonly width: number }\n\nexport type FurniturePushPhase = 'idle' | 'grip' | 'push' | 'strain'\nexport type FurniturePushBlock = 'too_heavy' | 'obstacle' | null\n\n/** Every number of the push; a game overrides what it wants (`createFurniturePush(rules)`). */\nexport interface FurniturePushRules {\n /** The most the player's legs put on the floor, newtons: with the friction it says the heaviest thing that moves. */\n readonly forceN: number\n readonly gravity: number\n /** Static friction of a base on a floor, by the material of the piece. */\n readonly frictionByMaterial: Readonly<Record<string, number>>\n readonly defaultFriction: number\n /** The hold before the push: `base + perKg * mass`, at most `max` seconds. */\n readonly gripSeconds: { readonly base: number; readonly perKg: number; readonly max: number }\n /** Metres per second: `max` with nothing on the hands, `min` at the limit of the force. */\n readonly speed: { readonly max: number; readonly min: number }\n /**\n * How fast the walk with the piece changes, m/s²: `max` the most a person speeds it up (the force left over the friction, over the mass, may give less), `brake` the\n * most it slows it (stopping, turning back). Below what holds a thing on top (friction × g, about 3.4 m/s² for the softest), so a cup on a pushed table rides along.\n */\n readonly accel: { readonly max: number; readonly brake: number; readonly min: number }\n /** A press shorter than this is not a push (the host keeps it for a tap, such as grabbing). */\n readonly tapSeconds: number\n /** How long the effort stays after the last step that was refused, so that it does not flicker. */\n readonly strainHoldSeconds: number\n /**\n * The scratch a dragged piece leaves, by the floor it is dragged on (`SurfaceId` of game-contracts): wood and tile scratch lighter, concrete scuffs darker,\n * dirt and sand take a furrow; a floor left out (carpet, grass, gravel, asphalt, water) keeps no mark.\n */\n readonly dragMarks: Readonly<Partial<Record<SurfaceId, DragMark>>>\n}\n\nexport const FURNITURE_PUSH_DEFAULTS: FurniturePushRules = {\n forceN: 500,\n gravity: 9.81,\n frictionByMaterial: { wood_soft: 0.4, wood_hard: 0.4, mdf: 0.4, plywood: 0.4, steel: 0.35, aluminium: 0.35, cast_iron: 0.4, copper: 0.35, plastic: 0.35, rubber: 0.8, fabric: 0.45, foam: 0.5, ceramic: 0.5, glass: 0.3, tempered_glass: 0.3, brick: 0.6, concrete: 0.65 },\n defaultFriction: 0.45,\n gripSeconds: { base: 0.4, perKg: 0.015, max: 2.5 },\n speed: { max: 1.8, min: 0.35 },\n accel: { max: 1.5, brake: 3, min: 0.2 },\n tapSeconds: 0.2,\n strainHoldSeconds: 0.25,\n dragMarks: {\n wood: { color: 0xd8c4a0, width: 0.012 },\n tile: { color: 0x9a9a96, width: 0.01 },\n concrete: { color: 0x45433f, width: 0.02 },\n metal: { color: 0xd0d4d8, width: 0.008 },\n glass: { color: 0xf2f2f2, width: 0.006 },\n dirt: { color: 0x4a3524, width: 0.04 },\n sand: { color: 0x8d7a5c, width: 0.05 },\n },\n}\n\nexport type FurniturePushTarget = { readonly massKg: number; readonly material?: string }\n\n/** Static friction of a thing of `material` on what it stands on (the floor, a table top). */\nexport const frictionFor = (material: string | undefined, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => (material !== undefined ? rules.frictionByMaterial[material] : undefined) ?? rules.defaultFriction\n\nconst frictionOf = (target: FurniturePushTarget, rules: FurniturePushRules): number => frictionFor(target.material, rules)\n\n/** A piece, or a row of pieces pushed one against the next (a sofa shoving a chair): their frictions on the floor add up against the legs. */\nexport type FurniturePushLoad = FurniturePushTarget | readonly FurniturePushTarget[]\n\nconst piecesOf = (load: FurniturePushLoad): readonly FurniturePushTarget[] => (Array.isArray(load) ? load : [load as FurniturePushTarget])\nconst frictionForceOf = (load: FurniturePushLoad, rules: FurniturePushRules): number => piecesOf(load).reduce((sum, t) => sum + frictionOf(t, rules) * t.massKg * rules.gravity, 0)\nconst massOf = (load: FurniturePushLoad): number => piecesOf(load).reduce((sum, t) => sum + t.massKg, 0)\nconst loadShare = (load: FurniturePushLoad, rules: FurniturePushRules): number => frictionForceOf(load, rules) / rules.forceN\n\nexport const gripSecondsFor = (massKg: number, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => Math.min(rules.gripSeconds.max, rules.gripSeconds.base + rules.gripSeconds.perKg * Math.max(0, massKg))\n\n/** Whether the legs overcome the friction of the piece (or of the row of pieces) on the floor. */\nexport const canPush = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): boolean => loadShare(target, rules) <= 1\n\n/** Metres per second with the piece on the hands: slower the closer it is to the limit of the force, 0 past it. */\nexport const pushSpeedFor = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => {\n const share = loadShare(target, rules)\n return share > 1 ? 0 : rules.speed.max + (rules.speed.min - rules.speed.max) * share\n}\n\n/** How fast the walk with the piece speeds up, m/s²: the force left over its friction, over its mass, at most what a person does (`accel.max`). */\nexport const pushAccelerationFor = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => {\n const spare = (rules.forceN - frictionForceOf(target, rules)) / Math.max(1e-3, massOf(target))\n return Math.max(rules.accel.min, Math.min(rules.accel.max, spare))\n}\n\n/** The scratch dragging leaves on `surface`, or null where the floor keeps none (carpet, grass). */\nexport const dragMarkFor = (surface: SurfaceId, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): DragMark | null => rules.dragMarks[surface] ?? null\n\n/** Whether a thing resting on a moving piece slides on it: the piece changes speed faster than the friction under the thing can follow (`accelMps2` > friction × g). */\nexport const slipsOnTop = (accelMps2: number, friction: number, gravity = FURNITURE_PUSH_DEFAULTS.gravity): boolean => accelMps2 > friction * gravity\n\nexport type FurniturePushInput = {\n /** Where the player wants to go on the floor: a unit vector, or `[0, 0]` standing. */\n readonly walk: readonly [number, number]\n /** Whether the volume of the piece (and the player behind it) can move by this offset. */\n readonly isFree: (dx: number, dz: number) => boolean\n}\n\nexport type FurniturePushStep = {\n readonly dx: number\n readonly dz: number\n /** The grip closed on this update. */\n readonly engaged: boolean\n /** A step was refused now and the one before was not: the moment the piece hits something. */\n readonly hitObstacle: boolean\n /** The velocity of the piece after this update, m/s on the floor. */\n readonly velocity: readonly [number, number]\n /** How fast its velocity changed in this update, m/s²: what a thing on top feels. */\n readonly acceleration: number\n /** The velocity it had when it hit something and stopped at once (what rests on it keeps it and slides on), or null. */\n readonly stoppedFrom: readonly [number, number] | null\n}\n\nexport interface FurniturePush {\n readonly phase: FurniturePushPhase\n /** How far the hold timer is, 0 to 1. */\n readonly progress: number\n readonly block: FurniturePushBlock\n readonly heldSeconds: number\n /** Whether the hold is still short enough to be a tap. */\n readonly isTap: boolean\n /** The velocity of the piece now, m/s on the floor. */\n readonly velocity: readonly [number, number]\n begin(target: FurniturePushTarget): void\n /** The load changed while pushing (the piece met another and shoves it along): the speed and the speeding up follow the whole row. */\n setLoad(load: FurniturePushLoad): void\n release(): void\n update(dt: number, input: FurniturePushInput): FurniturePushStep\n}\n\nconst STILL: FurniturePushStep = { dx: 0, dz: 0, engaged: false, hitObstacle: false, velocity: [0, 0], acceleration: 0, stoppedFrom: null }\n\nexport function createFurniturePush(overrides: Partial<FurniturePushRules> = {}): FurniturePush {\n const rules: FurniturePushRules = { ...FURNITURE_PUSH_DEFAULTS, ...overrides }\n let phase: FurniturePushPhase = 'idle'\n let target: FurniturePushTarget = { massKg: 0 }\n let held = 0\n let gripSeconds = 1\n let speed = 0\n let accel = rules.accel.max\n let vx = 0\n let vz = 0\n let block: FurniturePushBlock = null\n let refused = 0\n let wasRefused = false\n\n /** The velocity goes toward the walk, no faster than the push speeds it up (or the legs brake it). Answers the change, m/s². */\n const steer = (dt: number, walk: readonly [number, number]): number => {\n const wantX = walk[0] * speed\n const wantZ = walk[1] * speed\n const braking = wantX * vx + wantZ * vz < vx * vx + vz * vz\n let dvx = wantX - vx\n let dvz = wantZ - vz\n const change = Math.hypot(dvx, dvz)\n const most = (braking ? rules.accel.brake : accel) * dt\n if (change > most) {\n dvx *= most / change\n dvz *= most / change\n }\n vx += dvx\n vz += dvz\n return Math.min(change, most) / dt\n }\n\n const walkWith = (dt: number, input: FurniturePushInput): FurniturePushStep => {\n refused = Math.max(0, refused - dt)\n if (block === 'too_heavy' || dt <= 0) return STILL\n const acceleration = steer(dt, input.walk)\n if (Math.hypot(vx, vz) < 1e-4) {\n vx = vz = 0\n if (refused === 0) {\n phase = 'push'\n block = null\n wasRefused = false\n }\n return { ...STILL, acceleration }\n }\n const dx = vx * dt\n const dz = vz * dt\n if (input.isFree(dx, dz)) {\n if (refused === 0) {\n phase = 'push'\n block = null\n }\n wasRefused = false\n return { dx, dz, engaged: false, hitObstacle: false, velocity: [vx, vz], acceleration, stoppedFrom: null }\n }\n const from: readonly [number, number] = [vx, vz]\n vx = vz = 0\n const hitObstacle = !wasRefused\n wasRefused = true\n refused = rules.strainHoldSeconds\n phase = 'strain'\n block = 'obstacle'\n return { ...STILL, hitObstacle, acceleration: Math.hypot(from[0], from[1]) / dt, stoppedFrom: hitObstacle ? from : null }\n }\n\n return {\n get phase() {\n return phase\n },\n get progress() {\n return phase === 'idle' ? 0 : Math.min(1, held / gripSeconds)\n },\n get block() {\n return block\n },\n get heldSeconds() {\n return held\n },\n get velocity(): readonly [number, number] {\n return [vx, vz]\n },\n get isTap() {\n return phase === 'grip' && held < rules.tapSeconds\n },\n begin(next) {\n target = next\n phase = 'grip'\n held = 0\n block = null\n refused = 0\n wasRefused = false\n gripSeconds = gripSecondsFor(next.massKg, rules)\n speed = pushSpeedFor(next, rules)\n accel = pushAccelerationFor(next, rules)\n vx = vz = 0\n },\n setLoad(load) {\n speed = pushSpeedFor(load, rules)\n accel = pushAccelerationFor(load, rules)\n },\n release() {\n phase = 'idle'\n vx = vz = 0\n held = 0\n block = null\n },\n update(dt, input) {\n if (phase === 'idle') return STILL\n held += dt\n if (phase !== 'grip') return walkWith(dt, input)\n if (held < gripSeconds) return STILL\n if (canPush(target, rules)) phase = 'push'\n else {\n phase = 'strain'\n block = 'too_heavy'\n }\n return { ...STILL, engaged: true }\n },\n }\n}\n","/**\n * Opening and closing a hinged or sliding leaf by hand (a house door, a wardrobe or fridge door, a drawer, a car door, a hood): the hand reaches the handle, the leaf\n * follows the hand at a speed set by its mass, stops where something is in its way, and a locked leaf only rattles.\n * The player does not follow the leaf: when the handle leaves arm reach a leaf that goes away is shoved on (`push`) and one that comes toward the body is let go (`release`),\n * and either one finishes its swing on its own.\n * Engine-agnostic: the host says how open the leaf is (0 closed, 1 open) and answers whether it can go to a new opening; this says how far it goes each step.\n */\n\nexport type DoorUsePhase = 'idle' | 'reach' | 'swing' | 'push' | 'release' | 'rattle'\nexport type DoorUseBlock = 'locked' | 'obstacle' | null\n\n/** Every number of the use; a game overrides what it wants (`createDoorUse(rules)`). */\nexport interface DoorUseRules {\n /** The hand going to the handle before the leaf moves, seconds. */\n readonly reachSeconds: number\n /** A full swing: `base + perKg * mass` of the leaf, between `min` and `max` seconds (a fridge door is quick, a car door slower, a steel door slower still). */\n readonly swingSeconds: { readonly base: number; readonly perKg: number; readonly min: number; readonly max: number }\n /** The shove of a leaf that goes away once the handle is out of reach, seconds. */\n readonly pushSeconds: number\n /** The hand letting go and coming back, seconds. */\n readonly releaseSeconds: number\n /** How long a locked leaf is shaken before the hand gives up, seconds. */\n readonly rattleSeconds: number\n /** The part of the swing tested at a time against what is around (smaller is finer and costs more). */\n readonly stepFraction: number\n /** Within this of closed or open a leaf counts as there: the last use's way no longer turns it round. */\n readonly endTolerance: number\n}\n\nexport const DOOR_USE_DEFAULTS: DoorUseRules = {\n reachSeconds: 0.3,\n swingSeconds: { base: 0.45, perKg: 0.02, min: 0.45, max: 1.6 },\n pushSeconds: 0.18,\n releaseSeconds: 0.22,\n // the length of the recorded handle shaken (game-audio door_locked_rattle, 0.6 to 0.83 s): the hand lets go as the sound ends\n rattleSeconds: 0.75,\n stepFraction: 0.04,\n endTolerance: 0.02,\n}\n\n/** The body's shoulder, metres over the feet (the avatar's door pose is drawn for it). */\nexport const DOOR_SHOULDER_HEIGHT = 1.42\n/** The farthest a handle is from the shoulder joint for the palm to stay on it (measured on the body in both views: the palm is 0.06 m off up to 0.5, 0.11 at 0.55, 0.24 at 0.65). */\nexport const DOOR_ARM_REACH = 0.55\n\nexport type DoorUseTarget = {\n /** How open the leaf is now, 0 closed to 1 open. */\n readonly opening: number\n readonly massKg: number\n readonly locked?: boolean\n /** Where the last use sent this leaf: a leaf stopped between closed and open goes the other way (a door blocked half open closes). */\n readonly lastGoal?: 0 | 1\n}\n\nexport type DoorUseStep = {\n readonly phase: DoorUsePhase\n /** How open the leaf is after the step. */\n readonly opening: number\n /** The phase's own progress, 0 to 1 (how far the hand is to the handle, how far the swing went, how much of the rattle is left). */\n readonly progress: number\n /** Set on the step the leaf stopped short or would not move. */\n readonly block: DoorUseBlock\n /** The leaf got where it was going on this step (fully open or fully closed). */\n readonly arrived: boolean\n}\n\n/** Seconds of a full swing for a leaf of this mass. */\nexport const swingSecondsFor = (massKg: number, rules: DoorUseRules = DOOR_USE_DEFAULTS): number =>\n Math.min(rules.swingSeconds.max, Math.max(rules.swingSeconds.min, rules.swingSeconds.base + rules.swingSeconds.perKg * Math.max(0, massKg)))\n\nexport type DoorUseHand = { readonly reaches: () => boolean; readonly pull: boolean }\n\nexport interface DoorUse {\n readonly phase: DoorUsePhase\n /** Where the leaf is going: 1 opening, 0 closing. */\n readonly goal: 0 | 1\n readonly opening: number\n /**\n * Starts using a leaf: the other way from where the last use sent it (`lastGoal`), else a closed or half-open leaf opens and an open\n * one closes. A use in the middle of a swing turns it round.\n * Answers the goal (1 open, 0 closed), or null when the leaf is locked (it rattles instead).\n */\n begin(target: DoorUseTarget): 0 | 1 | null\n /**\n * Advances the use; `isFree(from, to)` answers whether the leaf can go from one opening to the other (nothing in the way of its sweep). `hand` says whether the handle is still\n * within arm reach after the step and whether the leaf comes toward the body (`pull`): once the handle is out of reach the swing hands over to `push` (a leaf going away is shoved\n * on) or `release` (a leaf coming toward the body is let go) and the leaf finishes on its own. Without `hand` the hand never lets go.\n */\n step(dt: number, isFree: (from: number, to: number) => boolean, hand?: DoorUseHand): DoorUseStep\n /** Lets go at once. */\n cancel(): void\n}\n\nexport function createDoorUse(rules: Partial<DoorUseRules> = {}): DoorUse {\n const r: DoorUseRules = { ...DOOR_USE_DEFAULTS, ...rules, swingSeconds: { ...DOOR_USE_DEFAULTS.swingSeconds, ...rules.swingSeconds } }\n let phase: DoorUsePhase = 'idle'\n let goal: 0 | 1 = 1\n let opening = 0\n let time = 0\n let swing = 1\n let start = 0\n /** The hand let go and the leaf is still going to its goal on its own. */\n let coasting = false\n\n const out = (progress: number, arrived = false, b: DoorUseBlock = null): DoorUseStep => ({ phase, opening, progress: Math.max(0, Math.min(1, progress)), block: b, arrived })\n\n /** Moves the leaf toward its goal for `dt` seconds, a little at a time so it stops at the first thing in its way and not past it. */\n const advance = (dt: number, isFree: (from: number, to: number) => boolean): 'moving' | 'stopped' | 'arrived' => {\n const want = goal - opening\n const reach = Math.min(Math.abs(want), dt / swing)\n let moved = 0\n while (moved < reach - 1e-9) {\n const inc = Math.min(r.stepFraction, reach - moved)\n const next = opening + Math.sign(want) * inc\n if (!isFree(opening, next)) return 'stopped'\n opening = next\n moved += inc\n }\n return Math.abs(goal - opening) < 1e-6 ? 'arrived' : 'moving'\n }\n\n /** The hand coming back to rest; it waits there (progress 1) while the leaf still goes on its own. */\n const releaseOut = (arrived: boolean, b: DoorUseBlock = null): DoorUseStep => {\n const p = time / r.releaseSeconds\n if (p >= 1 && !coasting) phase = 'idle'\n return out(p, arrived, b)\n }\n\n return {\n get phase() {\n return phase\n },\n get goal() {\n return goal\n },\n get opening() {\n return opening\n },\n begin(target) {\n opening = Math.max(0, Math.min(1, target.opening))\n time = 0\n coasting = false\n if (target.locked) {\n phase = 'rattle'\n return null\n }\n // in the middle of a swing the hand is already on the handle: the leaf turns round at once\n if (phase === 'swing' || phase === 'reach') goal = goal === 1 ? 0 : 1\n else if (target.lastGoal !== undefined && opening > r.endTolerance && opening < 1 - r.endTolerance) goal = target.lastGoal === 1 ? 0 : 1\n else goal = opening > 0.5 ? 0 : 1\n swing = swingSecondsFor(target.massKg, r)\n start = opening\n phase = phase === 'swing' ? 'swing' : 'reach'\n return goal\n },\n step(dt, isFree, hand) {\n if (phase === 'idle') return out(0)\n time += dt\n if (phase === 'rattle') {\n const p = time / r.rattleSeconds\n if (p >= 1) {\n phase = 'idle'\n return out(1, false, 'locked')\n }\n return out(p, false, time === dt ? 'locked' : null)\n }\n if (phase === 'reach') {\n const p = time / r.reachSeconds\n if (p < 1) return out(p)\n phase = 'swing'\n time = 0\n start = opening\n }\n if (phase === 'swing' || phase === 'push' || coasting) {\n const result = advance(dt, isFree)\n const travel = Math.abs(goal - start) || 1\n const progress = 1 - Math.abs(goal - opening) / travel\n const inHand = phase !== 'release'\n if (result === 'stopped' || result === 'arrived') {\n if (result === 'arrived') opening = goal\n coasting = false\n if (inHand) {\n phase = 'release'\n time = 0\n }\n if (result === 'arrived') return inHand ? out(1, true) : releaseOut(true)\n return inHand ? out(progress, false, 'obstacle') : releaseOut(false, 'obstacle')\n }\n if (inHand && hand && !hand.reaches()) {\n time = 0\n if (hand.pull) {\n phase = 'release'\n coasting = true\n } else phase = 'push'\n return out(0)\n }\n if (phase === 'push') {\n if (time >= r.pushSeconds) {\n phase = 'release'\n time = 0\n coasting = true\n return out(0)\n }\n return out(time / r.pushSeconds)\n }\n if (phase === 'swing') return out(progress)\n }\n return releaseOut(false)\n },\n cancel() {\n phase = 'idle'\n time = 0\n },\n }\n}\n","/**\n * The hands and the weapon (decision of the owner, 2026-11-24): an interaction of one hand (a small thing picked up, a door, a switch) takes the free hand, the one that does not\n * hold the weapon, and the weapon stays in its hand; one of both hands (a big thing carried, a push, a climb) first puts the weapon away in a slot of the body that takes it\n * (a holster at the hip, a sling or back slot for a long gun) and, with none, lets it fall to the ground. A two-handed weapon (a rifle, a shotgun) leaves no hand free, so any\n * interaction puts it away or drops it. When the interaction ends, what was put away comes back to its hand; what fell stays on the ground.\n * A long gun on its sling (decision of the owner, 2026-11-25) is not put away: it swings onto the sling and hangs on the body (`sling`), and stays there after the interaction until\n * the player brings it back to the hands; with no sling worn it goes to the next slot that takes it (`SLOT_FALLBACKS`: the back).\n * A second weapon of the belt (a pistol or a knife in the other hand, decision of the owner 2026-11-27) is not thrown away when the holster is taken: it is tucked in the\n * belt (`SLOT_FALLBACKS`: hip, then belt) and comes back after, as the holstered one does. Picking something up never drops a weapon the body has a place for.\n * Engine-agnostic: the host says what is in each hand and which slots the body wears; this says which hand acts and what happens to each weapon.\n */\n\n/** `R` the weapon hand, `L` the other one. */\nexport type BodyHand = 'R' | 'L'\n\n/** A weapon in a hand: `hands` it takes (0 the bare hand, 1, 2) and the slot of the body that takes it (`hip`, `back`...), null when none does. */\nexport interface HandWeapon {\n readonly id: string\n readonly hands: 0 | 1 | 2\n readonly slot: string | null\n}\n\nexport interface HandsRules {\n /** A thing up to `maxKg` whose longest side is up to `maxLength` metres goes in one hand; anything bigger or heavier takes both. */\n readonly oneHand: { readonly maxKg: number; readonly maxLength: number }\n /**\n * A thing with a carry handle (a bucket of water, a jerrycan, a toolbox) hangs from one hand by it up to `maxKg`, whatever its size. Optional, so rules written\n * before it keep working: without it the default (`HANDS_BY_HANDLE`) holds.\n */\n readonly byHandle?: { readonly maxKg: number }\n}\n\n/** How much a hand carries by a handle when the rules say nothing of it: a 20 L jerrycan full, a bucket of water. */\nexport const HANDS_BY_HANDLE = { maxKg: 25 } as const\n\nexport const HANDS_DEFAULTS: HandsRules = { oneHand: { maxKg: 4, maxLength: 0.7 }, byHandle: HANDS_BY_HANDLE }\n\n/** The slot a weapon goes to when the body wears none of its own (or it is taken): a long gun with no sling goes across the back, a second handgun or knife into the belt. */\nexport const SLOT_FALLBACKS: Readonly<Record<string, readonly string[]>> = { sling: ['back'], hip: ['belt'] }\n\n/** The belt: where a one-handed weapon is tucked when its own place on the body is taken. */\nexport const BELT_SLOT = 'belt'\n\n/** The slot of a long gun that hangs on its sling. */\nexport const SLING_SLOT = 'sling'\n\n/**\n * What a weapon does when the hands are wanted: `holster` goes to `slot` and comes back after; `sling` hangs on the body by its sling and stays there until it is brought back;\n * `drop` falls to the ground and stays there.\n */\nexport type HandsMoveKind = 'holster' | 'sling' | 'drop'\n\nexport interface HandsMove {\n readonly hand: BodyHand\n readonly weapon: string\n readonly move: HandsMoveKind\n readonly slot?: string\n}\n\nexport interface HandsPlan {\n /** The hand the interaction takes, or `both`. */\n readonly hand: BodyHand | 'both'\n /** What happens to each weapon that is in the way, the weapon hand first. */\n readonly moves: readonly HandsMove[]\n}\n\nexport interface PlanHandsParams {\n /** The hands the interaction takes (`interactionHandsFor` for a thing picked up). */\n readonly hands: 1 | 2\n /** What each hand holds; absent or null is an empty hand. */\n readonly weapons: { readonly R?: HandWeapon | null; readonly L?: HandWeapon | null }\n /** The slots the body wears and that are empty (a holster, a sling); one weapon each. */\n readonly slots: readonly string[]\n /** The slots tried when a weapon's own is not worn; default `SLOT_FALLBACKS`. */\n readonly fallbacks?: Readonly<Record<string, readonly string[]>>\n}\n\n/** How many hands it takes to carry a thing of `massKg` and `size` (metres, any order); by its carry handle (`handle`), one up to `byHandle.maxKg`. */\nexport function interactionHandsFor(thing: { readonly massKg: number; readonly size?: readonly number[]; readonly handle?: boolean }, rules: HandsRules = HANDS_DEFAULTS): 1 | 2 {\n if (thing.handle) return thing.massKg > (rules.byHandle ?? HANDS_BY_HANDLE).maxKg ? 2 : 1\n const longest = Math.max(0, ...(thing.size ?? []))\n return thing.massKg > rules.oneHand.maxKg || longest > rules.oneHand.maxLength ? 2 : 1\n}\n\nconst holds = (weapon: HandWeapon | null | undefined): weapon is HandWeapon => !!weapon && weapon.hands > 0\n\n/** Which hand acts and what happens to each weapon in the way. */\nexport function planHands(params: PlanHandsParams): HandsPlan {\n const { R, L } = params.weapons\n const free = [...params.slots]\n const fallbacks = params.fallbacks ?? SLOT_FALLBACKS\n const stow = (hand: BodyHand, weapon: HandWeapon): HandsMove => {\n const own = weapon.slot === null ? [] : [weapon.slot, ...(fallbacks[weapon.slot] ?? [])]\n // a one-handed weapon (a second handgun, a compact SMG, a hatchet) is tucked in the belt when its own places are taken, never thrown away\n const tried = weapon.hands === 1 && !own.includes(BELT_SLOT) ? [...own, BELT_SLOT] : own\n const slot = tried.find((name) => free.includes(name))\n if (slot === undefined) return { hand, weapon: weapon.id, move: 'drop' }\n free.splice(free.indexOf(slot), 1)\n return { hand, weapon: weapon.id, move: slot === SLING_SLOT ? 'sling' : 'holster', slot }\n }\n if (params.hands === 2) {\n const moves = [...(holds(R) ? [stow('R', R)] : []), ...(holds(L) ? [stow('L', L)] : [])]\n return { hand: 'both', moves }\n }\n if (holds(L)) return { hand: 'L', moves: [stow('L', L)] }\n if (!holds(R)) return { hand: 'R', moves: [] }\n return { hand: 'L', moves: R.hands === 2 ? [stow('R', R)] : [] }\n}\n\n/** What comes back to the hands once the interaction ends: the weapons that were put away, each to its hand; the slung ones stay on the sling and the dropped ones on the ground. */\nexport function drawBackOf(plan: HandsPlan): readonly { readonly hand: BodyHand; readonly weapon: string }[] {\n return plan.moves.filter((move) => move.move === 'holster').map((move) => ({ hand: move.hand, weapon: move.weapon }))\n}\n","/**\n * Whether one person lifts a thing off the floor with the hands, from its mass and its size (the mass comes from the material of the SDK: density times volume, or\n * the real mass of the catalogue). The strength is the most a person lifts held against the body; a bulky thing is held away from it, and the back takes the load\n * times its lever (the horizontal multiplier of the NIOSH lifting equation: what is held at `H` metres from the spine is `closeReach / H` of what is held against\n * it). The thing is held the easiest way: its thinnest side away from the body, the hands around the middle one. A sofa (45 kg, 2 x 0.9 x 0.85 m) is held at\n * 0.58 m and weighs more than the 26 kg a person lifts that far out: it is pushed or dragged, not picked up. A gas bottle (16 kg, 0.36 m across) goes up.\n * Engine-agnostic: the host passes the mass and the box of the thing.\n */\n\nexport interface LiftRules {\n /** The most a person lifts held against the body, kg. */\n readonly maxKg: number\n /** Distance (m) from the spine to a load held against the body: NIOSH's 25 cm, where the lever costs nothing. */\n readonly closeReach: number\n /** Distance (m) from the spine to the near face of what is held: the front of the trunk. */\n readonly bodyDepth: number\n /** The widest a person holds between the hands around a thing, metres: the arms hugging it. */\n readonly maxSpan: number\n}\n\nexport const LIFT_DEFAULTS: LiftRules = { maxKg: 60, closeReach: 0.25, bodyDepth: 0.15, maxSpan: 1.3 }\n\n/** `ok` it goes up; `too_heavy` heavier than the strength even against the body; `too_bulky` too wide for the arms or too far out for its weight. */\nexport type LiftVerdict = 'ok' | 'too_heavy' | 'too_bulky'\n\nexport interface LiftCheck {\n readonly verdict: LiftVerdict\n /** The most this thing could weigh and still go up, held its easiest way, kg. */\n readonly liftableKg: number\n}\n\n/** Whether a thing of `massKg` and `size` (metres, any order; without it, a thing held against the body) goes up in one person's hands. */\nexport function liftCheckFor(thing: { readonly massKg: number; readonly size?: readonly number[] }, rules: Partial<LiftRules> = {}): LiftCheck {\n const r = { ...LIFT_DEFAULTS, ...rules }\n const [, middle = 0, thinnest = 0] = [...(thing.size ?? [])].sort((a, b) => b - a)\n const reach = r.bodyDepth + Math.max(0, thinnest) / 2\n const liftableKg = r.maxKg * Math.min(1, r.closeReach / Math.max(reach, 1e-6))\n if (thing.massKg > r.maxKg) return { verdict: 'too_heavy', liftableKg }\n if (middle > r.maxSpan || thing.massKg > liftableKg) return { verdict: 'too_bulky', liftableKg }\n return { verdict: 'ok', liftableKg }\n}\n","/**\n * The little pose algebra the hands need, engine-agnostic: a pose is a position and a unit quaternion `[x, y, z, w]` (local to world), as `HandPose` of game-contracts.\n */\n\nexport type Vec3Tuple = readonly [number, number, number]\nexport type QuatTuple = readonly [number, number, number, number]\n\nexport interface Pose {\n readonly position: Vec3Tuple\n readonly quaternion: QuatTuple\n}\n\n/** The rotation whose local x, y and z go to `x`, `y` and `z` (an orthonormal, right-handed basis). */\nexport function quaternionOfBasis(x: readonly number[], y: readonly number[], z: readonly number[]): [number, number, number, number] {\n const [m00, m10, m20] = [x[0] ?? 0, x[1] ?? 0, x[2] ?? 0]\n const [m01, m11, m21] = [y[0] ?? 0, y[1] ?? 0, y[2] ?? 0]\n const [m02, m12, m22] = [z[0] ?? 0, z[1] ?? 0, z[2] ?? 0]\n const trace = m00 + m11 + m22\n if (trace > 0) {\n const s = 0.5 / Math.sqrt(trace + 1)\n return [(m21 - m12) * s, (m02 - m20) * s, (m10 - m01) * s, 0.25 / s]\n }\n if (m00 > m11 && m00 > m22) {\n const s = 2 * Math.sqrt(1 + m00 - m11 - m22)\n return [0.25 * s, (m01 + m10) / s, (m02 + m20) / s, (m21 - m12) / s]\n }\n if (m11 > m22) {\n const s = 2 * Math.sqrt(1 + m11 - m00 - m22)\n return [(m01 + m10) / s, 0.25 * s, (m12 + m21) / s, (m02 - m20) / s]\n }\n const s = 2 * Math.sqrt(1 + m22 - m00 - m11)\n return [(m02 + m20) / s, (m12 + m21) / s, 0.25 * s, (m10 - m01) / s]\n}\n\nexport function multiplyQuaternions(a: QuatTuple, b: QuatTuple): [number, number, number, number] {\n const [ax, ay, az, aw] = a\n const [bx, by, bz, bw] = b\n return [ax * bw + aw * bx + ay * bz - az * by, ay * bw + aw * by + az * bx - ax * bz, az * bw + aw * bz + ax * by - ay * bx, aw * bw - ax * bx - ay * by - az * bz]\n}\n\nexport function conjugateQuaternion(q: QuatTuple): [number, number, number, number] {\n return [-q[0], -q[1], -q[2], q[3]]\n}\n\nexport function rotateVector(q: QuatTuple, v: Vec3Tuple): [number, number, number] {\n const [x, y, z, w] = q\n const tx = 2 * (y * v[2] - z * v[1])\n const ty = 2 * (z * v[0] - x * v[2])\n const tz = 2 * (x * v[1] - y * v[0])\n return [v[0] + w * tx + (y * tz - z * ty), v[1] + w * ty + (z * tx - x * tz), v[2] + w * tz + (x * ty - y * tx)]\n}\n\n/** `parent` then `local`: the pose of a thing given in the frame of `parent`. */\nexport function composePose(parent: Pose, local: Pose): Pose {\n const offset = rotateVector(parent.quaternion, local.position)\n return {\n position: [parent.position[0] + offset[0], parent.position[1] + offset[1], parent.position[2] + offset[2]],\n quaternion: multiplyQuaternions(parent.quaternion, local.quaternion),\n }\n}\n\n/** The pose whose frame puts `local` at `world`: `composePose(result, local)` is `world`. */\nexport function poseHolding(world: Pose, local: Pose): Pose {\n const quaternion = multiplyQuaternions(world.quaternion, conjugateQuaternion(local.quaternion))\n const offset = rotateVector(quaternion, local.position)\n return { position: [world.position[0] - offset[0], world.position[1] - offset[1], world.position[2] - offset[2]], quaternion }\n}\n\n/** Between `a` (k 0) and `b` (k 1): the position on the line, the turn the short way round. */\nexport function blendPoses(a: Pose, b: Pose, k: number): Pose {\n const lerp = (i: 0 | 1 | 2): number => a.position[i] + (b.position[i] - a.position[i]) * k\n const dot = a.quaternion[0] * b.quaternion[0] + a.quaternion[1] * b.quaternion[1] + a.quaternion[2] * b.quaternion[2] + a.quaternion[3] * b.quaternion[3]\n const sign = dot < 0 ? -1 : 1\n const mixed = [0, 1, 2, 3].map((i) => (a.quaternion[i] ?? 0) * (1 - k) + (b.quaternion[i] ?? 0) * sign * k)\n const length = Math.hypot(...mixed) || 1\n return { position: [lerp(0), lerp(1), lerp(2)], quaternion: [(mixed[0] ?? 0) / length, (mixed[1] ?? 0) / length, (mixed[2] ?? 0) / length, (mixed[3] ?? 1) / length] }\n}\n\n/** Slow in, slow out: a hand speeds up off its start and settles on its target. */\nexport function easeInOut(t: number): number {\n const k = Math.min(1, Math.max(0, t))\n return k * k * (3 - 2 * k)\n}\n","/**\n * How a hand closes on a thing it picks up (decision of the owner, 2026-11-25: the hand on the thing's real grip, the fingers closed around it, the thing in the palm, aligned with\n * the hand in both views). Engine-agnostic: the thing is its box (`size`, metres, in its own frame), the hand frame is the one of `HandTargets`: +x along the fingers, +y the back\n * of the hand, the thumb at -z for a right hand and +z for a left one. The thing's longest side runs through the fist along the thumb (a bottle stands up in a hand held thumb up),\n * its thinnest side across the palm (the palm lies on its broad face), and its middle sits a palm's thickness plus half that side under the middle of the palm.\n */\nimport type { BodyHand } from './hands'\nimport { composePose, poseHolding, quaternionOfBasis } from './hand-math'\nimport type { Pose, Vec3Tuple } from './hand-math'\n\nexport const ITEM_GRIP = {\n /** Half the thickness of a palm (m): what lies between the middle of the palm and the thing. */\n palm: 0.011,\n /** The closure of the fingers (0 open, 1 a fist) on a thing this thick (m) or thinner. */\n fistAt: 0.03,\n closed: 0.95,\n /** How much the closure opens per metre the thing is thicker than `fistAt`, and the most it opens to. */\n openPerMetre: 4,\n open: 0.35,\n /** The fingers before they close on it, as the hand comes to the thing. */\n reaching: 0.15,\n} as const\n\nexport interface ItemGrip {\n /** The thing's middle and turn in the frame of the hand. */\n readonly local: Pose\n /** How closed the fingers are on it (`HandTargets.grip`). */\n readonly grip: number\n /** The hand holds it by a carry handle (a bucket's bail) and it hangs under the hand, upright: carried with the arm down at the side, not in front of the chest. */\n readonly hanging?: boolean\n}\n\nconst AXES: readonly Vec3Tuple[] = [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n]\n\nconst cross = (a: Vec3Tuple, b: Vec3Tuple): Vec3Tuple => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]\nconst scaled = (v: Vec3Tuple, k: number): Vec3Tuple => [v[0] * k, v[1] * k, v[2] * k]\n\n/**\n * The grip of a hand on the carry handle of a thing (a bucket's bail, a jerrycan's or a toolbox's handle), `handle` the middle of the handle in the thing's own frame (metres from its\n * middle): the fist closes round the handle, the thing upright (its +y up, along the thumb) and hanging under the hand, its handle along the fingers.\n */\nexport function gripOnHandle(handle: readonly number[], hand: BodyHand): ItemGrip {\n // the thing's +y goes up the hand (-z of a right hand, the thumb side; +z of a left one), its +x along the fingers, +z the third axis of a right-handed frame\n const up: Vec3Tuple = hand === 'R' ? [0, 0, -1] : [0, 0, 1]\n const along: Vec3Tuple = [1, 0, 0]\n const quaternion = quaternionOfBasis(along, up, cross(along, up))\n const local: Pose = { position: [0, 0, 0], quaternion }\n // the middle of the thing sits so that its handle is in the palm\n const handleInHand = composePose(local, { position: [handle[0] ?? 0, handle[1] ?? 0, handle[2] ?? 0], quaternion: [0, 0, 0, 1] }).position\n return { local: { position: [-handleInHand[0], -handleInHand[1] - ITEM_GRIP.palm, -handleInHand[2]], quaternion }, grip: ITEM_GRIP.closed, hanging: true }\n}\n\n/** The grip of a hand on a thing of box `size` (its own frame, metres); by its carry handle when it has one (`gripOnHandle`). */\nexport function gripOfItem(size: readonly number[], hand: BodyHand, handle?: readonly number[] | null): ItemGrip {\n if (handle) return gripOnHandle(handle, hand)\n const sides = [0, 1, 2].map((axis) => ({ axis, length: Math.max(0, size[axis] ?? 0) })).sort((a, b) => b.length - a.length)\n const [long, mid, thin] = sides as [(typeof sides)[0], (typeof sides)[0], (typeof sides)[0]]\n const thumb: Vec3Tuple = hand === 'R' ? [0, 0, -1] : [0, 0, 1]\n // where each of the thing's own axes goes in the hand: the long one along the thumb, the thin one across the palm, the last one keeps the frame right-handed\n const columns: Vec3Tuple[] = [AXES[0] as Vec3Tuple, AXES[1] as Vec3Tuple, AXES[2] as Vec3Tuple]\n columns[long.axis] = thumb\n columns[thin.axis] = [0, 1, 0]\n const next = (axis: number): number => (axis + 1) % 3\n // x × y = z for the thing's frame: the column after `mid` crossed with the one after that names it\n const before = columns[next(next(mid.axis))] as Vec3Tuple\n const after = columns[next(mid.axis)] as Vec3Tuple\n columns[mid.axis] = cross(after, before)\n const quaternion = quaternionOfBasis(columns[0] as Vec3Tuple, columns[1] as Vec3Tuple, columns[2] as Vec3Tuple)\n const depth = ITEM_GRIP.palm + thin.length / 2\n const across = (mid.length + thin.length) / 2\n const grip = Math.max(ITEM_GRIP.open, Math.min(ITEM_GRIP.closed, ITEM_GRIP.closed - ITEM_GRIP.openPerMetre * Math.max(0, across - ITEM_GRIP.fistAt)))\n return { local: { position: scaled([0, -1, 0], depth), quaternion }, grip }\n}\n\n/** Where the thing is with the hand at `hand` holding it by `grip`. */\nexport function itemPoseInHand(hand: Pose, grip: ItemGrip): Pose {\n return composePose(hand, grip.local)\n}\n\n/** Where the hand goes to take the thing where it lies (`item`, its middle and turn) by `grip`. */\nexport function handPoseOnItem(item: Pose, grip: ItemGrip): Pose {\n return poseHolding(item, grip.local)\n}\n","/**\n * The hands take a thing in steps one can see (decision of the owner, 2026-11-25): first each weapon in the way goes off the hands (`stow` to its holster, `sling` onto its sling, or\n * `drop`: tossed to the ground), then the hand `reach`es the thing's grip, the fingers `close` on it, and it is `lift`ed to where it is carried. A weapon comes back to the hands the\n * same way round (`draw`). Engine-agnostic and clock-free: the host advances it by its own frame's `dt` and does what each step says.\n */\nimport type { HandsMove, HandsPlan } from './hands'\nimport { easeInOut } from './hand-math'\n\n/** Seconds each step takes. */\nexport interface HandsTiming {\n readonly stow: number\n readonly sling: number\n readonly drop: number\n readonly reach: number\n readonly close: number\n readonly lift: number\n readonly draw: number\n}\n\nexport const HANDS_TIMING: HandsTiming = { stow: 0.5, sling: 0.45, drop: 0.4, reach: 0.38, close: 0.16, lift: 0.3, draw: 0.5 }\n\nexport type TakeStepKind = 'stow' | 'sling' | 'drop' | 'reach' | 'close' | 'lift' | 'draw'\n\nexport interface TakeStep {\n readonly kind: TakeStepKind\n /** The weapon the step moves (`stow`, `sling`, `drop`, `draw`). */\n readonly move?: HandsMove\n readonly start: number\n readonly end: number\n}\n\nexport interface TakeSequence {\n readonly steps: readonly TakeStep[]\n readonly duration: number\n}\n\nconst KIND_OF_MOVE: Readonly<Record<HandsMove['move'], 'stow' | 'sling' | 'drop'>> = { holster: 'stow', sling: 'sling', drop: 'drop' }\n\nconst lay = (parts: readonly { readonly kind: TakeStepKind; readonly seconds: number; readonly move?: HandsMove }[]): TakeSequence => {\n let at = 0\n const steps = parts.map((part) => {\n const step: TakeStep = { kind: part.kind, start: at, end: at + part.seconds, ...(part.move ? { move: part.move } : {}) }\n at = step.end\n return step\n })\n return { steps, duration: at }\n}\n\n/** The steps of taking a thing with `plan`: the weapons off the hands (the off hand first), then reach, close and lift. `take` false leaves the thing out (a push). */\nexport function planTakeSequence(plan: HandsPlan, options: { readonly timing?: HandsTiming; readonly take?: boolean } = {}): TakeSequence {\n const timing = options.timing ?? HANDS_TIMING\n const moves = [...plan.moves].reverse().map((move) => ({ kind: KIND_OF_MOVE[move.move], seconds: timing[KIND_OF_MOVE[move.move]], move }))\n const take = options.take === false ? [] : [\n { kind: 'reach' as const, seconds: timing.reach },\n { kind: 'close' as const, seconds: timing.close },\n { kind: 'lift' as const, seconds: timing.lift },\n ]\n return lay([...moves, ...take])\n}\n\n/** The steps of bringing weapons back to the hands, one after the other. */\nexport function planDrawSequence(moves: readonly HandsMove[], timing: HandsTiming = HANDS_TIMING): TakeSequence {\n return lay(moves.map((move) => ({ kind: 'draw' as const, seconds: timing.draw, move })))\n}\n\nexport interface TakeProgress {\n /** The step going on now, null once the sequence is over. */\n readonly step: TakeStep | null\n /** How far into it, 0..1, eased (slow in, slow out). */\n readonly progress: number\n /** The steps that began during this advance, in order. */\n readonly started: readonly TakeStep[]\n /** The steps that ended during this advance, in order. */\n readonly ended: readonly TakeStep[]\n readonly done: boolean\n}\n\nexport interface TakeTimeline {\n readonly sequence: TakeSequence\n /** Seconds since it began. */\n readonly time: number\n /** Moves the timeline on by `dt` seconds (the host's frame). The first call with 0 starts the first step. */\n advance(dt: number): TakeProgress\n}\n\nexport function createTakeTimeline(sequence: TakeSequence): TakeTimeline {\n let time = 0\n // the steps already begun and already over: each is reported once\n let begun = 0\n let over = 0\n const steps = sequence.steps\n return {\n sequence,\n get time() {\n return time\n },\n advance(dt) {\n time = Math.min(sequence.duration, time + Math.max(0, dt))\n const startedFrom = begun\n while (begun < steps.length && (steps[begun] as TakeStep).start <= time) begun++\n const endedFrom = over\n while (over < begun && (steps[over] as TakeStep).end <= time) over++\n const started = steps.slice(startedFrom, begun)\n const ended = steps.slice(endedFrom, over)\n const step = steps.find((entry) => time < entry.end) ?? null\n const progress = step ? easeInOut((time - step.start) / Math.max(1e-6, step.end - step.start)) : 1\n return { step, progress, started, ended, done: time >= sequence.duration }\n },\n }\n}\n","/**\n * Draws a body that moves in fixed steps between two of them: remember the last two step poses, blend by the scheduler's `alpha` (CLAUDE.md §15).\n * Drawn at the step pose, a body moves 0, 1 or 2 steps per frame at a display that is not the step's rate: it stutters.\n */\n\nexport type StepPosition = { readonly x: number; readonly y: number; readonly z: number }\n\nexport type StepPoseOptions = {\n /** A step longer than this (metres) is a teleport (a respawn, a placed body): drawn at the new pose at once, never swept across. Default 3. */\n readonly teleportDistance?: number\n}\n\nexport type StepPose = {\n /** The body's pose after a fixed step. */\n record(position: StepPosition): void\n /** Puts both poses on `position`: nothing is blended from where the body was. */\n reset(position: StepPosition): void\n /** The pose to draw: `alpha` in [0, 1] is how far the frame is into the next step. */\n blend(alpha: number): StepPosition\n}\n\nexport const STEP_POSE_DEFAULTS = { teleportDistance: 3 } as const\n\nexport function createStepPose(start: StepPosition, options: StepPoseOptions = {}): StepPose {\n const teleportDistance = options.teleportDistance ?? STEP_POSE_DEFAULTS.teleportDistance\n let previous = { x: start.x, y: start.y, z: start.z }\n let current = { x: start.x, y: start.y, z: start.z }\n return {\n record(position) {\n previous = current\n current = { x: position.x, y: position.y, z: position.z }\n if (Math.hypot(current.x - previous.x, current.y - previous.y, current.z - previous.z) > teleportDistance) previous = current\n },\n reset(position) {\n previous = { x: position.x, y: position.y, z: position.z }\n current = previous\n },\n blend(alpha) {\n const k = Math.min(1, Math.max(0, alpha))\n return { x: previous.x + (current.x - previous.x) * k, y: previous.y + (current.y - previous.y) * k, z: previous.z + (current.z - previous.z) * k }\n },\n }\n}\n","/**\n * The body works a control with one hand (CLAUDE.md §18, owner 2026-11-30: every action has a body animation): the free hand `reach`es the point, does the `act` of the gesture\n * (presses a button, turns a knob, flips a rocker, strikes a match, pours, lets go inside, tips over, closes on the thing to stow it, holds the paper up to read) and goes `back`.\n * The thing reacts at the act's moment (`GestureProgress.acted`), so the TV goes on when the finger is on the button. One gesture serves every control of its kind: a press is\n * the TV, the microwave and the radio alike. Pure and clock-free: the host advances it by its own frame's `dt`, says where the shoulder, the hand at rest and the point are,\n * and puts the hand where `gestureHandPose` says.\n */\nimport type { BodyGesture } from '@adatechnology/game-contracts'\n\nimport type { BodyHand } from './hands'\nimport { blendPoses, easeInOut, multiplyQuaternions, quaternionOfBasis } from './hand-math'\nimport type { Pose, QuatTuple, Vec3Tuple } from './hand-math'\n\nexport type GesturePhase = 'reach' | 'act' | 'back'\n\nexport interface GestureTiming {\n readonly reach: number\n readonly back: number\n /** Seconds the act of each gesture takes. */\n readonly act: Readonly<Record<BodyGesture, number>>\n}\n\nexport const GESTURE_TIMING: GestureTiming = {\n reach: 0.32,\n back: 0.3,\n act: { press: 0.22, turn: 0.4, flip: 0.2, strike: 0.35, pour: 0.7, put_in: 0.3, tip: 0.7, stow: 0.25, read: 1.2, pull: 0.45 },\n}\n\n/** The gestures whose thing reacts as the act begins (the words of a paper are read while it is held up); the others react once the act is done. */\nconst ACTS_AT_START: ReadonlySet<BodyGesture> = new Set<BodyGesture>(['read'])\n\n/** How far a hand reaches from its shoulder, metres: a point farther than that is touched at the end of the arm, never with the arm stretched past it. */\nexport const GESTURE_ARM_REACH = 0.62\n\nexport interface GestureProgress {\n readonly phase: GesturePhase\n /** How far into the phase, 0..1, eased. */\n readonly progress: number\n /** True on the advance during which the hand got to the act's moment: the host works the thing now. */\n readonly acted: boolean\n readonly done: boolean\n}\n\nexport interface GestureTimeline {\n readonly gesture: BodyGesture\n readonly duration: number\n /** Moves it on by `dt` seconds (the host's frame). */\n advance(dt: number): GestureProgress\n}\n\nexport function createGestureTimeline(gesture: BodyGesture, timing: GestureTiming = GESTURE_TIMING): GestureTimeline {\n const reach = timing.reach\n const act = timing.act[gesture]\n const duration = reach + act + timing.back\n const actsAt = ACTS_AT_START.has(gesture) ? reach : reach + act\n let time = 0\n let fired = false\n return {\n gesture,\n duration,\n advance(dt) {\n time = Math.min(duration, time + Math.max(0, dt))\n const acted = !fired && time >= actsAt\n if (acted) fired = true\n const phase: GesturePhase = time < reach ? 'reach' : time < reach + act ? 'act' : 'back'\n const start = phase === 'reach' ? 0 : phase === 'act' ? reach : reach + act\n const length = phase === 'reach' ? reach : phase === 'act' ? act : timing.back\n return { phase, progress: easeInOut((time - start) / Math.max(1e-6, length)), acted, done: time >= duration }\n },\n }\n}\n\n/** The gestures done with what the hand holds (the thing put in a bin, the jug poured into a bowl): the hand that carries it does them, never the free one. */\nconst WITH_THE_HELD_THING: ReadonlySet<BodyGesture> = new Set<BodyGesture>(['put_in', 'pour'])\n\n/** The free hand: the weapon hand only when it holds nothing, else the off hand; null when both hold something (a pistol in one, a torch in the other). */\nexport function freeHandOf(busy: { readonly R: boolean; readonly L: boolean }): BodyHand | null {\n if (!busy.R) return 'R'\n return busy.L ? null : 'L'\n}\n\nexport interface GestureHandChoice {\n /** Whether each hand holds something (a weapon, a carried thing). */\n readonly busy: { readonly R: boolean; readonly L: boolean }\n readonly gesture: BodyGesture\n /** The hand that carries the thing a `put_in` or a `pour` is done with, null when none does. */\n readonly carrying?: BodyHand | null\n}\n\n/** The hand that works a control: the one that carries the thing for a gesture done with it, the free one for the rest; null when no hand can (the hands are full). */\nexport function gestureHandOf(choice: GestureHandChoice): BodyHand | null {\n if (WITH_THE_HELD_THING.has(choice.gesture)) return choice.carrying ?? null\n return freeHandOf(choice.busy)\n}\n\nexport interface GestureHandParams {\n readonly gesture: BodyGesture\n readonly phase: GesturePhase\n readonly progress: number\n /** The hand that works (`gestureHandOf`): a left hand is turned the other way round, its thumb on the other side. */\n readonly hand: BodyHand\n /** The shoulder of the hand that works, world space. */\n readonly shoulder: Vec3Tuple\n /** Where the hand is when it does nothing of this (by the chest, or on the weapon's forend). */\n readonly rest: Pose\n /** The point the hand works, world space. */\n readonly at: Vec3Tuple\n /** The body's facing about the vertical (radians, 0 looks down -z): the way the hand goes when the point is right over the shoulder. */\n readonly yaw: number\n}\n\nexport interface GestureHand {\n readonly pose: Pose\n /** How closed the fingers are, 0 open to 1 closed. */\n readonly grip: number\n /** The index finger alone, 0 straight (a finger that presses) to 1 curled. */\n readonly index: number\n}\n\nconst add = (a: Vec3Tuple, b: Vec3Tuple, k = 1): [number, number, number] => [a[0] + b[0] * k, a[1] + b[1] * k, a[2] + b[2] * k]\nconst cross = (a: Vec3Tuple, b: Vec3Tuple): [number, number, number] => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]\nconst axisTurn = (axis: Vec3Tuple, angle: number): QuatTuple => {\n const s = Math.sin(angle / 2)\n return [axis[0] * s, axis[1] * s, axis[2] * s, Math.cos(angle / 2)]\n}\nconst UP: Vec3Tuple = [0, 1, 0]\n\ntype Frame = { readonly at: Vec3Tuple; readonly way: Vec3Tuple; readonly side: Vec3Tuple; readonly q: QuatTuple }\n\n/** Where the hand is and how it is turned `k` (0..1) into the act, from the point it works (`at`), the way to it (`way`), the side (`side`) and the hand's turn there (`q`). */\nconst actPose = (gesture: BodyGesture, frame: Frame, k: number): Pose => {\n const { at, way, side, q } = frame\n switch (gesture) {\n case 'press':\n // the finger goes in onto the button and comes off it\n return { position: add(at, way, -0.06 + 0.05 * Math.sin(Math.PI * k)), quaternion: q }\n case 'turn':\n // the hand round the knob turns a quarter about the way it came\n return { position: add(at, way, -0.02), quaternion: multiplyQuaternions(axisTurn(way, -k * Math.PI * 0.5), q) }\n case 'flip':\n // the fingers on the rocker push it down\n return { position: add(add(at, way, -0.02), UP, -0.03 * k), quaternion: q }\n case 'strike':\n // the match is struck across the side of the box, by the burner\n return { position: add(add(at, way, -0.04), side, 0.08 * (k - 0.5)), quaternion: q }\n case 'pour':\n // over the bowl, the hand tips what it holds forward\n return { position: add(at, UP, 0.15), quaternion: multiplyQuaternions(axisTurn(side, -k * Math.PI * 0.4), q) }\n case 'tip':\n // the hand on the rim turns the container over\n return { position: add(at, UP, 0.05 * k), quaternion: multiplyQuaternions(axisTurn(side, -k * Math.PI * 0.55), q) }\n case 'pull':\n // the fingers closed on the pull bring it toward the body\n return { position: add(at, way, -0.02 - 0.15 * k), quaternion: q }\n case 'put_in':\n case 'stow':\n return { position: [at[0], at[1], at[2]], quaternion: q }\n case 'read':\n // the paper held up, the palm toward the eyes\n return { position: [at[0], at[1], at[2]], quaternion: multiplyQuaternions(axisTurn(way, Math.PI * 0.5), q) }\n }\n}\n\n/** The fingers as the act begins and as it ends: a hand that lets go inside opens, one that stows closes on the thing. */\nconst GRIP: Readonly<Record<BodyGesture, readonly [number, number]>> = {\n press: [0.85, 0.85],\n turn: [0.9, 0.9],\n flip: [0.55, 0.55],\n strike: [0.95, 0.95],\n pour: [1, 1],\n tip: [1, 1],\n put_in: [1, 0.15],\n stow: [0.2, 0.95],\n read: [0.7, 0.7],\n pull: [0.9, 0.9],\n}\nconst OPEN_HAND = 0.2\n\n/** The frame of the act: the point (at the end of the arm when it is out of reach), the way to it on the ground, the side, and a hand turned to it with the thumb up. */\nfunction frameOf(params: GestureHandParams): Frame {\n const { shoulder } = params\n const flatX = params.at[0] - shoulder[0]\n const flatZ = params.at[2] - shoulder[2]\n const flat = Math.hypot(flatX, flatZ)\n const way: Vec3Tuple = flat < 1e-4 ? [-Math.sin(params.yaw), 0, -Math.cos(params.yaw)] : [flatX / flat, 0, flatZ / flat]\n // the thumb up on either hand: the little finger (+z) down for a right hand, up for a left one, whose thumb is at +z\n const little: Vec3Tuple = params.hand === 'R' ? [0, -1, 0] : [0, 1, 0]\n const side = cross(little, way)\n const toward: Vec3Tuple = [params.at[0] - shoulder[0], params.at[1] - shoulder[1], params.at[2] - shoulder[2]]\n const reach = Math.hypot(toward[0], toward[1], toward[2])\n const at = reach > GESTURE_ARM_REACH ? add(shoulder, toward, GESTURE_ARM_REACH / reach) : params.at\n return { at, way, side, q: quaternionOfBasis(way, side, little) }\n}\n\n/** The hand of a gesture now: its pose (world space, HandPose of game-contracts: +x to the knuckles, +z to the little finger) and its fingers. */\nexport function gestureHandPose(params: GestureHandParams): GestureHand {\n const { rest, phase, progress, gesture } = params\n const frame = frameOf(params)\n const [gripIn, gripOut] = GRIP[gesture]\n const index = gesture === 'press' ? 0 : gesture === 'flip' ? 0.2 : 1\n if (phase === 'reach') return { pose: blendPoses(rest, actPose(gesture, frame, 0), progress), grip: OPEN_HAND + (gripIn - OPEN_HAND) * progress, index: 1 + (index - 1) * progress }\n if (phase === 'act') return { pose: actPose(gesture, frame, progress), grip: gripIn + (gripOut - gripIn) * progress, index }\n // a thing stowed goes down to the bag at the hip, closed in the hand, not back to the chest\n const stowed = gesture === 'stow'\n const home: Pose = stowed ? { position: add(rest.position, UP, -0.3), quaternion: rest.quaternion } : rest\n const grip = stowed ? gripOut : gripOut + (OPEN_HAND - gripOut) * progress\n return { pose: blendPoses(actPose(gesture, frame, 1), home, progress), grip, index: index + (1 - index) * progress }\n}\n","/**\n * The body working a control (CLAUDE.md §18): one gesture at a time, by the hand the gesture calls for (`gestureHandOf`: the free one for a button, the one that holds the\n * thing to put in or pour), played over whatever the hands do already (the weapon's targets, a carried thing); the body steps up to the point, stoops for a low one, and the\n * thing is worked when the hand gets there. Any host with a body plays it (the test room, a game): it says where the shoulders, the hands at rest and the feet are, and puts\n * the hands where `targets` says. The timing and the pose are `createGestureTimeline` and `gestureHandPose`.\n */\nimport type { BodyGesture, HandPose, HandTargets, Vec3 } from '@adatechnology/game-contracts'\n\nimport { createGestureTimeline, gestureHandOf, gestureHandPose } from './gesture'\nimport type { GestureProgress, GestureTimeline } from './gesture'\nimport type { Pose } from './hand-math'\nimport type { BodyHand } from './hands'\n\nexport interface GestureBody {\n /** Where the body's middle stands, metres on the floor (x, z). */\n at(): readonly [number, number]\n /** Steps by (dx, dz) metres, stopped by what is in the way. */\n moveBy(dx: number, dz: number): void\n /** Turns the head and the body a share `k` (0..1) of the way toward the point. */\n face(point: Vec3, k: number): void\n /** Stoops while `on`: the hand reaches something lower than the arm reaches standing (a stove's knob). */\n stoop?(on: boolean): void\n /** The body is on its feet and can work a thing (false once it is knocked down or falls): a gesture going on stops without working the thing. */\n able?(): boolean\n}\n\nexport interface GestureHandDeps {\n /** The shoulder of a hand, world space; null for a body without one. */\n shoulder(hand: BodyHand): Vec3 | null\n /** Where a hand rests when the frame's targets have nothing for it (by the chest), world space. */\n restOf(hand: BodyHand): Pose\n /** Whether each hand holds something (a weapon, a carried thing). */\n holding(): { readonly R: boolean; readonly L: boolean }\n /** The hand that carries the thing a `put_in` puts in or a `pour` pours (not a weapon), or null when no hand carries one. */\n carrying?(): BodyHand | null\n /** The body's facing about the vertical, radians. */\n yaw(): number\n /** The body on the floor, for the steps up to a point out of the arm's reach; without it the hand goes from where the body stands. */\n readonly body?: GestureBody\n}\n\n/** How far from the point the body's middle stands to work it with a bent arm, metres on the floor; how fast it steps up, m/s; the longest walk, seconds. */\nconst STAND_OFF = 0.5\nconst STEP_SPEED = 2.5\nconst MAX_WALK_SECONDS = 1.5\nconst TURN_RATE = 8\n/** How far under the shoulder a point is before the body stoops to reach it, metres (an arm hanging down and a little forward reaches about this low). */\nconst STOOP_BELOW = 0.5\n\nexport interface GestureStart {\n readonly gesture: BodyGesture\n /** The point the hand works, world space, asked every frame (a thing that moves is followed). */\n at(): Vec3\n /** The hand got there: the thing is worked now. */\n onAct(): void\n}\n\n/** Why a gesture did not start: another one goes on, no hand can do it (both hold something, or none holds the thing to put in), or the body has no arm for it. */\nexport type GestureRefusal = 'busy' | 'hands_full' | 'no_body'\nexport type GestureStartResult = { readonly ok: true; readonly hand: BodyHand } | { readonly ok: false; readonly reason: GestureRefusal }\n\nexport interface GestureHands {\n /** A gesture is going on. */\n readonly busy: boolean\n /** The hand of the gesture going on. */\n readonly hand: BodyHand | null\n /** Starts a gesture; nothing is done when it is refused (the reason says why). */\n start(start: GestureStart): GestureStartResult\n step(dt: number): void\n /** The frame's targets with the working hand put on the gesture; the other hand keeps what it had. */\n targets(base: HandTargets | null): HandTargets | null\n /** Stops the gesture going on, without working the thing. */\n cancel(): void\n}\n\ntype Going = { readonly start: GestureStart; readonly hand: BodyHand; readonly timeline: GestureTimeline; progress: GestureProgress; walked: number; there: boolean }\n\n/** The body steps up to the point until the arm reaches it (true once there, in the way, or walked too long). */\nfunction stepUp(body: GestureBody | undefined, now: Going, dt: number): boolean {\n if (!body) return true\n const point = now.start.at()\n body.face(point, Math.min(1, dt * TURN_RATE))\n const [x, z] = body.at()\n const dx = point[0] - x\n const dz = point[2] - z\n const d = Math.hypot(dx, dz)\n if (d <= STAND_OFF + 0.03 || now.walked > MAX_WALK_SECONDS) return true\n const go = Math.min(d - STAND_OFF, STEP_SPEED * dt)\n if (go < 1e-4) return false\n body.moveBy((dx / d) * go, (dz / d) * go)\n const [x1, z1] = body.at()\n now.walked += dt\n // something in the way: the hand goes from here\n return Math.hypot(x1 - x, z1 - z) < go * 0.2\n}\n\nexport function createGestureHands(deps: GestureHandDeps): GestureHands {\n let going: Going | null = null\n const stop = (): void => {\n going = null\n deps.body?.stoop?.(false)\n }\n\n return {\n get busy() {\n return going !== null\n },\n get hand() {\n return going?.hand ?? null\n },\n start(start) {\n if (going) return { ok: false, reason: 'busy' }\n const hand = gestureHandOf({ busy: deps.holding(), gesture: start.gesture, carrying: deps.carrying?.() ?? null })\n if (!hand) return { ok: false, reason: 'hands_full' }\n const shoulder = deps.shoulder(hand)\n if (!shoulder || deps.body?.able?.() === false) return { ok: false, reason: 'no_body' }\n const timeline = createGestureTimeline(start.gesture)\n going = { start, hand, timeline, progress: timeline.advance(0), walked: 0, there: false }\n // a point under the reach of the arm hanging from the shoulder standing: the body stoops for it\n if (shoulder[1] - start.at()[1] > STOOP_BELOW) deps.body?.stoop?.(true)\n return { ok: true, hand }\n },\n step(dt) {\n if (!going) return\n const now = going\n // the body knocked down or fallen in the middle: the hand never gets there, nothing is worked\n if (deps.body?.able?.() === false) return stop()\n if (!now.there) {\n now.there = stepUp(deps.body, now, dt)\n if (!now.there) return\n }\n now.progress = now.timeline.advance(dt)\n if (now.progress.acted) now.start.onAct()\n if (now.progress.done && going === now) stop()\n },\n targets(base) {\n if (!going) return base\n const { hand, start, progress } = going\n const shoulder = deps.shoulder(hand)\n if (!shoulder) return base\n const rest = base?.[hand] ?? deps.restOf(hand)\n const worked = gestureHandPose({ gesture: start.gesture, hand, phase: progress.phase, progress: progress.progress, shoulder, rest, at: start.at(), yaw: deps.yaw() })\n const [x, y, z] = worked.pose.position\n const [qx, qy, qz, qw] = worked.pose.quaternion\n const pose: HandPose = { position: [x, y, z], quaternion: [qx, qy, qz, qw] }\n return hand === 'R'\n ? { ...(base ?? {}), R: pose, grip: worked.grip, fingers: { index: worked.index } }\n : { ...(base ?? {}), L: pose, gripL: worked.grip, fingersL: { index: worked.index }, slideL: null }\n },\n cancel: stop,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BO,IAAM,iBAAiB;AACvB,IAAM,+BAA+B;AAErC,IAAM,2BAA2B;AAMjC,IAAM,0BAA0B,CAAC,OAA2B,YAA+D;AAChI,QAAM,EAAE,cAAc,aAAa,IAAI,QAAQ;AAC/C,QAAM,KAAK,MAAM,gBAAgB;AAAA,IAC/B,UAAU,QAAQ;AAAA,IAClB,QAAQ;AAAA,IACR,YAAY,KAAK,IAAI,IAAI,eAAe,IAAI,gBAAgB,CAAC;AAAA,IAC7D,MAAM,QAAQ,QAAQ;AAAA,IACtB,UAAU,QAAQ,YAAY;AAAA,EAChC,CAAC;AACD,SAAO;AAAA,IACL;AAAA,IACA,MAAM,CAAC,WAAW,WAAW,OAAO,MAAM,cAAc,IAAI,WAAW,WAAW,EAAE;AAAA,IACpF,MAAM,CAAC,QAAQ,MAAM,cAAc,IAAI,KA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,EAAE,GAAI,QAAQ,CAAC,GAAI,GAAG,MAAM,MAAM,OAAO,MAAM,SAAS,EAAE,OAAO,OAAO,MAAM,EAAE,IAChF,EAAE,GAAI,QAAQ,CAAC,GAAI,GAAG,MAAM,OAAO,OAAO,MAAM,UAAU,EAAE,OAAO,OAAO,MAAM,GAAG,QAAQ,KAAK;AAAA,IACtG;AAAA,IACA,QAAQ;AAAA,EACV;AACF;","names":["s","cross"]}
1
+ {"version":3,"sources":["../src/physics-controller.ts","../src/foot-rest.ts","../src/walker.ts","../src/furniture-push.ts","../src/door-use.ts","../src/hands.ts","../src/lift.ts","../src/hand-math.ts","../src/item-grip.ts","../src/take-sequence.ts","../src/step-pose.ts","../src/vehicle-boarding.ts","../src/driving-hands.ts","../src/gesture.ts","../src/gesture-hands.ts"],"sourcesContent":["import type { CharacterId, PhysicsWorld, Vec3 } from '@adatechnology/game-physics'\n\nimport type { PlayerCollider } from './player'\nimport type { PlayerController } from './types'\n\n/** The part of the physics contract the player's body uses: any `PhysicsWorld` (or the loop's `SeamWorld`) has it. */\nexport type PlayerPhysicsWorld = Pick<PhysicsWorld, 'createCharacter' | 'moveCharacter' | 'pushCharacter' | 'readCharacter' | 'teleportCharacter' | 'removeCharacter' | 'characterSupported'>\n\nexport type PhysicsControllerOptions = {\n /** Where the feet are. */\n readonly position: Vec3\n /** What `player.collider()` says: the capsule is made as tall and as wide as the standing body. */\n readonly collider: PlayerCollider\n /** Kilograms, default 75. */\n readonly mass?: number\n /** Most force (N) it pushes a prop with, default 400: a 30 kg crate over wood, not a wardrobe. */\n readonly strength?: number\n}\n\nexport type PhysicsPlayerController = PlayerController & {\n readonly id: CharacterId\n /** Shoves the body: `impulse` in N s (a blow, a blast, a car's bumper); the controller feels it as impulse / mass, fading in a quarter of a second. */\n push(impulse: Vec3): void\n supported(): boolean\n dispose(): void\n}\n\nexport const PLAYER_MASS_KG = 75\nexport const PLAYER_PUSH_STRENGTH_NEWTONS = 400\n/** The most a person puts into what is in the way just by walking into it, without leaning on it on purpose: about the sustained push force of ISO 11228-2 for a man (100 N), the order of what a walk can keep up. A thing whose floor grip is above it (a 28 kg sofa on wood: 115 N) stops the walk; a lighter one is shoved along. */\nexport const PLAYER_WALK_PUSH_NEWTONS = 100\n\n/**\n * The player's controller in a physics world: a capsule as tall as the standing body (a crouch does not shrink it) that steps up, climbs, pushes props and is\n * pushed. Put it in `PlayerWorld.controller` and call `player.update(h, input)` from a `beforeStep(h)` of the loop's `actors` phase, never with the frame's `dt`.\n */\nexport const createPhysicsController = (world: PlayerPhysicsWorld, options: PhysicsControllerOptions): PhysicsPlayerController => {\n const { radiusMetres, heightMetres } = options.collider\n const id = world.createCharacter({\n position: options.position,\n radius: radiusMetres,\n halfHeight: Math.max(0, (heightMetres - 2 * radiusMetres) / 2),\n mass: options.mass ?? PLAYER_MASS_KG,\n strength: options.strength ?? PLAYER_PUSH_STRENGTH_NEWTONS,\n })\n return {\n id,\n move: (velocityX, velocityZ, dt) => world.moveCharacter(id, velocityX, velocityZ, dt),\n read: (out) => world.readCharacter(id, out, 0),\n teleport: (x, y, z) => world.teleportCharacter(id, [x, y, z]),\n push: (impulse) => world.pushCharacter(id, impulse),\n supported: () => world.characterSupported(id),\n dispose: () => world.removeCharacter(id),\n }\n}\n","/** Samples of the ground across the foot's disc, per radius: the disc is walked in rings of this many steps. */\nconst RINGS = 32\nconst SAMPLES_PER_RING = 48\n\n/**\n * The height a round foot of `radius` comes to rest at over ground `heightAt` (the lower sphere of the capsule): the highest, over the points of the disc under it, of\n * the ground there less how far the sphere's underside rises above its lowest point at that distance. Flat ground gives its own height; a bowl holds the foot above its middle.\n */\nexport const footRestHeight = (heightAt: (x: number, z: number) => number, x: number, z: number, radius: number): number => {\n let rest = heightAt(x, z)\n for (let ring = 1; ring <= RINGS; ring++) {\n const distance = (radius * ring) / RINGS\n const lift = radius - Math.sqrt(radius * radius - distance * distance)\n for (let sample = 0; sample < SAMPLES_PER_RING; sample++) {\n const angle = (2 * Math.PI * sample) / SAMPLES_PER_RING\n rest = Math.max(rest, heightAt(x + distance * Math.cos(angle), z + distance * Math.sin(angle)) - lift)\n }\n }\n return rest\n}\n","import type { BodyId, CharacterId, CharacterShape, Layer, PhysicsServices, Quat, Vec3 } from '@adatechnology/game-physics'\n\nimport { PLAYER_MASS_KG, PLAYER_PUSH_STRENGTH_NEWTONS } from './physics-controller'\nimport type { PlayerCollider } from './player'\n\n/** The vertical speed (m/s) of a jump under the world's 9.81: it rises 0.81 m, as high as the walker's own jump always did. */\nexport const WALKER_JUMP_SPEED = 3.99\n\nexport type WalkerStance = 'standing' | 'crouched' | 'prone'\n\n/** A stance is this fraction of the standing height: 1.80, 1.20 and 0.60 m for a person 1.80 m tall. */\nconst STANCE_HEIGHT_RATIO: Readonly<Record<WalkerStance, number>> = { standing: 1, crouched: 2 / 3, prone: 1 / 3 }\nconst NO_ROTATION: Quat = [0, 0, 0, 1]\n/** The probe sits this much (m) above the feet: the floor it will stand on touches the capsule and is not an overlap. */\nconst PROBE_LIFT = 0.03\nconst SOLID_LAYERS: readonly Layer[] = ['static', 'debris', 'prop', 'vehicle', 'character']\n\nexport type WalkerOptions = {\n /** Where the feet are. */\n readonly position: Vec3\n /** The standing body: `player.collider()` while standing. */\n readonly collider: PlayerCollider\n /** Kilograms, default 75. */\n readonly mass?: number\n /** Most force (N) it pushes a prop with, default 400. */\n readonly strength?: number\n /** Default 0.4 m. */\n readonly stepHeight?: number\n readonly maxSlopeDegrees?: number\n /** Default 9.81. */\n readonly gravity?: number\n /** The layer of the body the world sees of the walker (`agent`: a vehicle does not stop on it). */\n readonly shadow?: Layer\n /** The shadow's `user`. */\n readonly user?: number\n /** What `unpark` may not stand in (default static, debris, prop, vehicle and character). */\n readonly solidLayers?: readonly Layer[]\n}\n\nexport type Walker = {\n /** The character in the world: another one after `unpark`. */\n readonly id: CharacterId\n readonly stance: WalkerStance\n readonly parked: boolean\n /** The wanted horizontal velocity (m/s, world x and z), kept until it is changed: the key of the frame, not of the step. */\n setIntent(velocityX: number, velocityZ: number): void\n /** A jump when the feet stand on something; false in the air or parked. */\n jump(): boolean\n /** Changes the stance; false (the stance stays) when the new capsule would penetrate something. */\n setStance(stance: WalkerStance): boolean\n /** Shoves the body: `impulse` in N s. */\n push(impulse: Vec3): void\n supported(): boolean\n /** The feet of the last fixed step into `out` (x, y, z). */\n read(out: Float32Array | Float64Array): void\n /** The feet between the last two fixed steps, `alpha` (0 to 1) of the way: the scheduler's alpha, not the loop's (`stepFixed` zeroes that one). */\n drawn(alpha: number, out: Float32Array | Float64Array): void\n /** Puts the feet here at once, with no sweep and no speed carried over, and the drawn feet with them (a respawn, a scripted step). Nothing happens while parked. */\n teleport(feet: Vec3): void\n /** Takes the body out of the world (a seat, an aircraft, a vehicle): it no longer moves or blocks. */\n park(): void\n /** Puts the body back at the first of `candidates` (feet) where the capsule overlaps nothing solid, in this order (the door, the far side, the roof); false, still parked, when none fits. */\n unpark(candidates: readonly Vec3[]): boolean\n /** Leaves the loop and the world. */\n dispose(): void\n}\n\nexport type WalkerServices = Pick<PhysicsServices, 'loop' | 'world'>\n\nconst shapeOf = (collider: PlayerCollider, stance: WalkerStance): CharacterShape => {\n const height = collider.heightMetres * STANCE_HEIGHT_RATIO[stance]\n const radius = Math.min(collider.radiusMetres, height / 3)\n return { radius, halfHeight: (height - 2 * radius) / 2 }\n}\n\n/**\n * The player's body in the physics world, walking in the loop's `actors` phase: the intent is set when the key changes, every fixed step walks it with the step's\n * `h`, and the feet of the last two steps are kept for drawing between them. No allocation after the first call.\n */\nexport const createWalker = (services: WalkerServices, options: WalkerOptions): Walker => {\n const { loop, world } = services\n const mass = options.mass ?? PLAYER_MASS_KG\n const shapes: Readonly<Record<WalkerStance, CharacterShape>> = { standing: shapeOf(options.collider, 'standing'), crouched: shapeOf(options.collider, 'crouched'), prone: shapeOf(options.collider, 'prone') }\n const solid = options.solidLayers ?? SOLID_LAYERS\n const found: BodyId[] = []\n const previous = new Float64Array(3)\n const current = new Float64Array(3)\n let intentX = 0\n let intentZ = 0\n let stance: WalkerStance = 'standing'\n let parked = false\n\n const create = (feet: Vec3): CharacterId =>\n world.createCharacter({\n position: feet,\n radius: shapes[stance].radius,\n halfHeight: shapes[stance].halfHeight,\n mass,\n strength: options.strength ?? PLAYER_PUSH_STRENGTH_NEWTONS,\n ...(options.stepHeight !== undefined ? { stepHeight: options.stepHeight } : {}),\n ...(options.maxSlopeDegrees !== undefined ? { maxSlopeDegrees: options.maxSlopeDegrees } : {}),\n ...(options.gravity !== undefined ? { gravity: options.gravity } : {}),\n ...(options.shadow !== undefined ? { shadow: options.shadow } : {}),\n ...(options.user !== undefined ? { user: options.user } : {}),\n })\n\n let id = create(options.position)\n world.readCharacter(id, current, 0)\n previous.set(current)\n\n const stopLoop = loop.add(\n {\n beforeStep: (h) => {\n if (parked) return\n previous.set(current)\n world.moveCharacter(id, intentX, intentZ, h)\n world.readCharacter(id, current, 0)\n },\n },\n 'actors',\n )\n\n const fitsAt = (feet: Vec3): boolean => {\n const shape = shapes[stance]\n const centre: Vec3 = [feet[0], feet[1] + PROBE_LIFT + shape.halfHeight + shape.radius, feet[2]]\n return world.overlapShape({ kind: 'capsule', halfHeight: shape.halfHeight, radius: shape.radius }, centre, NO_ROTATION, found, { layers: solid }) === 0\n }\n\n return {\n get id() {\n return id\n },\n get stance() {\n return stance\n },\n get parked() {\n return parked\n },\n setIntent: (velocityX, velocityZ) => {\n intentX = velocityX\n intentZ = velocityZ\n },\n jump: () => {\n if (parked || !world.characterSupported(id)) return false\n world.pushCharacter(id, [0, mass * WALKER_JUMP_SPEED, 0])\n return true\n },\n setStance: (next) => {\n if (parked) return false\n if (!world.setCharacterShape(id, shapes[next])) return false\n stance = next\n return true\n },\n push: (impulse) => world.pushCharacter(id, impulse),\n supported: () => world.characterSupported(id),\n read: (out) => {\n out[0] = current[0] as number\n out[1] = current[1] as number\n out[2] = current[2] as number\n },\n drawn: (alpha, out) => {\n const t = alpha < 0 ? 0 : alpha > 1 ? 1 : alpha\n for (let axis = 0; axis < 3; axis++) out[axis] = (previous[axis] as number) + ((current[axis] as number) - (previous[axis] as number)) * t\n },\n teleport: (feet) => {\n if (parked) return\n world.teleportCharacter(id, feet)\n world.readCharacter(id, current, 0)\n previous.set(current)\n },\n park: () => {\n if (parked) return\n parked = true\n world.removeCharacter(id)\n },\n unpark: (candidates) => {\n if (!parked) return true\n for (const feet of candidates) {\n if (!fitsAt(feet)) continue\n id = create(feet)\n parked = false\n world.readCharacter(id, current, 0)\n previous.set(current)\n return true\n }\n return false\n },\n dispose: () => {\n stopLoop()\n if (!parked) world.removeCharacter(id)\n parked = true\n },\n }\n}\n","/**\n * Pushing furniture on foot: hold the interaction button against a piece, a timer that grows with its mass fills, and the player then walks with it.\n * Engine-agnostic: the host says where the player wants to go and answers whether the volume of the piece can go there; this says how fast, and when it locks.\n */\n\nimport type { SurfaceId } from '@adatechnology/game-contracts'\n\n/** What dragging a piece leaves on a floor: a strip of this colour and width (metres) under each side of its base. */\nexport type DragMark = { readonly color: number; readonly width: number }\n\nexport type FurniturePushPhase = 'idle' | 'grip' | 'push' | 'strain'\nexport type FurniturePushBlock = 'too_heavy' | 'obstacle' | null\n\n/** Every number of the push; a game overrides what it wants (`createFurniturePush(rules)`). */\nexport interface FurniturePushRules {\n /** The most the player's legs put on the floor, newtons: with the friction it says the heaviest thing that moves. */\n readonly forceN: number\n readonly gravity: number\n /** Static friction of a base on a floor, by the material of the piece. */\n readonly frictionByMaterial: Readonly<Record<string, number>>\n readonly defaultFriction: number\n /** The hold before the push: `base + perKg * mass`, at most `max` seconds. */\n readonly gripSeconds: { readonly base: number; readonly perKg: number; readonly max: number }\n /** Metres per second: `max` with nothing on the hands, `min` at the limit of the force. */\n readonly speed: { readonly max: number; readonly min: number }\n /**\n * How fast the walk with the piece changes, m/s²: `max` the most a person speeds it up (the force left over the friction, over the mass, may give less), `brake` the\n * most it slows it (stopping, turning back). Below what holds a thing on top (friction × g, about 3.4 m/s² for the softest), so a cup on a pushed table rides along.\n */\n readonly accel: { readonly max: number; readonly brake: number; readonly min: number }\n /** A press shorter than this is not a push (the host keeps it for a tap, such as grabbing). */\n readonly tapSeconds: number\n /** How long the effort stays after the last step that was refused, so that it does not flicker. */\n readonly strainHoldSeconds: number\n /**\n * The scratch a dragged piece leaves, by the floor it is dragged on (`SurfaceId` of game-contracts): wood and tile scratch lighter, concrete scuffs darker,\n * dirt and sand take a furrow; a floor left out (carpet, grass, gravel, asphalt, water) keeps no mark.\n */\n readonly dragMarks: Readonly<Partial<Record<SurfaceId, DragMark>>>\n}\n\nexport const FURNITURE_PUSH_DEFAULTS: FurniturePushRules = {\n forceN: 500,\n gravity: 9.81,\n frictionByMaterial: { wood_soft: 0.4, wood_hard: 0.4, mdf: 0.4, plywood: 0.4, steel: 0.35, aluminium: 0.35, cast_iron: 0.4, copper: 0.35, plastic: 0.35, rubber: 0.8, fabric: 0.45, foam: 0.5, ceramic: 0.5, glass: 0.3, tempered_glass: 0.3, brick: 0.6, concrete: 0.65 },\n defaultFriction: 0.45,\n gripSeconds: { base: 0.4, perKg: 0.015, max: 2.5 },\n speed: { max: 1.8, min: 0.35 },\n accel: { max: 1.5, brake: 3, min: 0.2 },\n tapSeconds: 0.2,\n strainHoldSeconds: 0.25,\n dragMarks: {\n wood: { color: 0xd8c4a0, width: 0.012 },\n tile: { color: 0x9a9a96, width: 0.01 },\n concrete: { color: 0x45433f, width: 0.02 },\n metal: { color: 0xd0d4d8, width: 0.008 },\n glass: { color: 0xf2f2f2, width: 0.006 },\n dirt: { color: 0x4a3524, width: 0.04 },\n sand: { color: 0x8d7a5c, width: 0.05 },\n },\n}\n\nexport type FurniturePushTarget = { readonly massKg: number; readonly material?: string }\n\n/** Static friction of a thing of `material` on what it stands on (the floor, a table top). */\nexport const frictionFor = (material: string | undefined, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => (material !== undefined ? rules.frictionByMaterial[material] : undefined) ?? rules.defaultFriction\n\nconst frictionOf = (target: FurniturePushTarget, rules: FurniturePushRules): number => frictionFor(target.material, rules)\n\n/** A piece, or a row of pieces pushed one against the next (a sofa shoving a chair): their frictions on the floor add up against the legs. */\nexport type FurniturePushLoad = FurniturePushTarget | readonly FurniturePushTarget[]\n\nconst piecesOf = (load: FurniturePushLoad): readonly FurniturePushTarget[] => (Array.isArray(load) ? load : [load as FurniturePushTarget])\nconst frictionForceOf = (load: FurniturePushLoad, rules: FurniturePushRules): number => piecesOf(load).reduce((sum, t) => sum + frictionOf(t, rules) * t.massKg * rules.gravity, 0)\nconst massOf = (load: FurniturePushLoad): number => piecesOf(load).reduce((sum, t) => sum + t.massKg, 0)\nconst loadShare = (load: FurniturePushLoad, rules: FurniturePushRules): number => frictionForceOf(load, rules) / rules.forceN\n\nexport const gripSecondsFor = (massKg: number, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => Math.min(rules.gripSeconds.max, rules.gripSeconds.base + rules.gripSeconds.perKg * Math.max(0, massKg))\n\n/** Whether the legs overcome the friction of the piece (or of the row of pieces) on the floor. */\nexport const canPush = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): boolean => loadShare(target, rules) <= 1\n\n/** Metres per second with the piece on the hands: slower the closer it is to the limit of the force, 0 past it. */\nexport const pushSpeedFor = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => {\n const share = loadShare(target, rules)\n return share > 1 ? 0 : rules.speed.max + (rules.speed.min - rules.speed.max) * share\n}\n\n/** How fast the walk with the piece speeds up, m/s²: the force left over its friction, over its mass, at most what a person does (`accel.max`). */\nexport const pushAccelerationFor = (target: FurniturePushLoad, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): number => {\n const spare = (rules.forceN - frictionForceOf(target, rules)) / Math.max(1e-3, massOf(target))\n return Math.max(rules.accel.min, Math.min(rules.accel.max, spare))\n}\n\n/** The scratch dragging leaves on `surface`, or null where the floor keeps none (carpet, grass). */\nexport const dragMarkFor = (surface: SurfaceId, rules: FurniturePushRules = FURNITURE_PUSH_DEFAULTS): DragMark | null => rules.dragMarks[surface] ?? null\n\n/** Whether a thing resting on a moving piece slides on it: the piece changes speed faster than the friction under the thing can follow (`accelMps2` > friction × g). */\nexport const slipsOnTop = (accelMps2: number, friction: number, gravity = FURNITURE_PUSH_DEFAULTS.gravity): boolean => accelMps2 > friction * gravity\n\nexport type FurniturePushInput = {\n /** Where the player wants to go on the floor: a unit vector, or `[0, 0]` standing. */\n readonly walk: readonly [number, number]\n /** Whether the volume of the piece (and the player behind it) can move by this offset. */\n readonly isFree: (dx: number, dz: number) => boolean\n}\n\nexport type FurniturePushStep = {\n readonly dx: number\n readonly dz: number\n /** The grip closed on this update. */\n readonly engaged: boolean\n /** A step was refused now and the one before was not: the moment the piece hits something. */\n readonly hitObstacle: boolean\n /** The velocity of the piece after this update, m/s on the floor. */\n readonly velocity: readonly [number, number]\n /** How fast its velocity changed in this update, m/s²: what a thing on top feels. */\n readonly acceleration: number\n /** The velocity it had when it hit something and stopped at once (what rests on it keeps it and slides on), or null. */\n readonly stoppedFrom: readonly [number, number] | null\n}\n\nexport interface FurniturePush {\n readonly phase: FurniturePushPhase\n /** How far the hold timer is, 0 to 1. */\n readonly progress: number\n readonly block: FurniturePushBlock\n readonly heldSeconds: number\n /** Whether the hold is still short enough to be a tap. */\n readonly isTap: boolean\n /** The velocity of the piece now, m/s on the floor. */\n readonly velocity: readonly [number, number]\n begin(target: FurniturePushTarget): void\n /** The load changed while pushing (the piece met another and shoves it along): the speed and the speeding up follow the whole row. */\n setLoad(load: FurniturePushLoad): void\n release(): void\n update(dt: number, input: FurniturePushInput): FurniturePushStep\n}\n\nconst STILL: FurniturePushStep = { dx: 0, dz: 0, engaged: false, hitObstacle: false, velocity: [0, 0], acceleration: 0, stoppedFrom: null }\n\nexport function createFurniturePush(overrides: Partial<FurniturePushRules> = {}): FurniturePush {\n const rules: FurniturePushRules = { ...FURNITURE_PUSH_DEFAULTS, ...overrides }\n let phase: FurniturePushPhase = 'idle'\n let target: FurniturePushTarget = { massKg: 0 }\n let held = 0\n let gripSeconds = 1\n let speed = 0\n let accel = rules.accel.max\n let vx = 0\n let vz = 0\n let block: FurniturePushBlock = null\n let refused = 0\n let wasRefused = false\n\n /** The velocity goes toward the walk, no faster than the push speeds it up (or the legs brake it). Answers the change, m/s². */\n const steer = (dt: number, walk: readonly [number, number]): number => {\n const wantX = walk[0] * speed\n const wantZ = walk[1] * speed\n const braking = wantX * vx + wantZ * vz < vx * vx + vz * vz\n let dvx = wantX - vx\n let dvz = wantZ - vz\n const change = Math.hypot(dvx, dvz)\n const most = (braking ? rules.accel.brake : accel) * dt\n if (change > most) {\n dvx *= most / change\n dvz *= most / change\n }\n vx += dvx\n vz += dvz\n return Math.min(change, most) / dt\n }\n\n const walkWith = (dt: number, input: FurniturePushInput): FurniturePushStep => {\n refused = Math.max(0, refused - dt)\n if (block === 'too_heavy' || dt <= 0) return STILL\n const acceleration = steer(dt, input.walk)\n if (Math.hypot(vx, vz) < 1e-4) {\n vx = vz = 0\n if (refused === 0) {\n phase = 'push'\n block = null\n wasRefused = false\n }\n return { ...STILL, acceleration }\n }\n const dx = vx * dt\n const dz = vz * dt\n if (input.isFree(dx, dz)) {\n if (refused === 0) {\n phase = 'push'\n block = null\n }\n wasRefused = false\n return { dx, dz, engaged: false, hitObstacle: false, velocity: [vx, vz], acceleration, stoppedFrom: null }\n }\n const from: readonly [number, number] = [vx, vz]\n vx = vz = 0\n const hitObstacle = !wasRefused\n wasRefused = true\n refused = rules.strainHoldSeconds\n phase = 'strain'\n block = 'obstacle'\n return { ...STILL, hitObstacle, acceleration: Math.hypot(from[0], from[1]) / dt, stoppedFrom: hitObstacle ? from : null }\n }\n\n return {\n get phase() {\n return phase\n },\n get progress() {\n return phase === 'idle' ? 0 : Math.min(1, held / gripSeconds)\n },\n get block() {\n return block\n },\n get heldSeconds() {\n return held\n },\n get velocity(): readonly [number, number] {\n return [vx, vz]\n },\n get isTap() {\n return phase === 'grip' && held < rules.tapSeconds\n },\n begin(next) {\n target = next\n phase = 'grip'\n held = 0\n block = null\n refused = 0\n wasRefused = false\n gripSeconds = gripSecondsFor(next.massKg, rules)\n speed = pushSpeedFor(next, rules)\n accel = pushAccelerationFor(next, rules)\n vx = vz = 0\n },\n setLoad(load) {\n speed = pushSpeedFor(load, rules)\n accel = pushAccelerationFor(load, rules)\n },\n release() {\n phase = 'idle'\n vx = vz = 0\n held = 0\n block = null\n },\n update(dt, input) {\n if (phase === 'idle') return STILL\n held += dt\n if (phase !== 'grip') return walkWith(dt, input)\n if (held < gripSeconds) return STILL\n if (canPush(target, rules)) phase = 'push'\n else {\n phase = 'strain'\n block = 'too_heavy'\n }\n return { ...STILL, engaged: true }\n },\n }\n}\n","/**\n * Opening and closing a hinged or sliding leaf by hand (a house door, a wardrobe or fridge door, a drawer, a car door, a hood): the hand reaches the handle, the leaf\n * follows the hand at a speed set by its mass, stops where something is in its way, and a locked leaf only rattles.\n * The player does not follow the leaf: when the handle leaves arm reach a leaf that goes away is shoved on (`push`) and one that comes toward the body is let go (`release`),\n * and either one finishes its swing on its own.\n * Engine-agnostic: the host says how open the leaf is (0 closed, 1 open) and answers whether it can go to a new opening; this says how far it goes each step.\n */\n\nexport type DoorUsePhase = 'idle' | 'reach' | 'swing' | 'push' | 'release' | 'rattle'\nexport type DoorUseBlock = 'locked' | 'obstacle' | null\n\n/** Every number of the use; a game overrides what it wants (`createDoorUse(rules)`). */\nexport interface DoorUseRules {\n /** The hand going to the handle before the leaf moves, seconds. */\n readonly reachSeconds: number\n /** A full swing: `base + perKg * mass` of the leaf, between `min` and `max` seconds (a fridge door is quick, a car door slower, a steel door slower still). */\n readonly swingSeconds: { readonly base: number; readonly perKg: number; readonly min: number; readonly max: number }\n /** The shove of a leaf that goes away once the handle is out of reach, seconds. */\n readonly pushSeconds: number\n /** The hand letting go and coming back, seconds. */\n readonly releaseSeconds: number\n /** How long a locked leaf is shaken before the hand gives up, seconds. */\n readonly rattleSeconds: number\n /** The part of the swing tested at a time against what is around (smaller is finer and costs more). */\n readonly stepFraction: number\n /** Within this of closed or open a leaf counts as there: the last use's way no longer turns it round. */\n readonly endTolerance: number\n}\n\nexport const DOOR_USE_DEFAULTS: DoorUseRules = {\n reachSeconds: 0.3,\n swingSeconds: { base: 0.45, perKg: 0.02, min: 0.45, max: 1.6 },\n pushSeconds: 0.18,\n releaseSeconds: 0.22,\n // the length of the recorded handle shaken (game-audio door_locked_rattle, 0.6 to 0.83 s): the hand lets go as the sound ends\n rattleSeconds: 0.75,\n stepFraction: 0.04,\n endTolerance: 0.02,\n}\n\n/** The body's shoulder, metres over the feet (the avatar's door pose is drawn for it). */\nexport const DOOR_SHOULDER_HEIGHT = 1.42\n/** The farthest a handle is from the shoulder joint for the palm to stay on it (measured on the body in both views: the palm is 0.06 m off up to 0.5, 0.11 at 0.55, 0.24 at 0.65). */\nexport const DOOR_ARM_REACH = 0.55\n\nexport type DoorUseTarget = {\n /** How open the leaf is now, 0 closed to 1 open. */\n readonly opening: number\n readonly massKg: number\n readonly locked?: boolean\n /** Where the last use sent this leaf: a leaf stopped between closed and open goes the other way (a door blocked half open closes). */\n readonly lastGoal?: 0 | 1\n}\n\nexport type DoorUseStep = {\n readonly phase: DoorUsePhase\n /** How open the leaf is after the step. */\n readonly opening: number\n /** The phase's own progress, 0 to 1 (how far the hand is to the handle, how far the swing went, how much of the rattle is left). */\n readonly progress: number\n /** Set on the step the leaf stopped short or would not move. */\n readonly block: DoorUseBlock\n /** The leaf got where it was going on this step (fully open or fully closed). */\n readonly arrived: boolean\n}\n\n/** Seconds of a full swing for a leaf of this mass. */\nexport const swingSecondsFor = (massKg: number, rules: DoorUseRules = DOOR_USE_DEFAULTS): number =>\n Math.min(rules.swingSeconds.max, Math.max(rules.swingSeconds.min, rules.swingSeconds.base + rules.swingSeconds.perKg * Math.max(0, massKg)))\n\nexport type DoorUseHand = { readonly reaches: () => boolean; readonly pull: boolean }\n\nexport interface DoorUse {\n readonly phase: DoorUsePhase\n /** Where the leaf is going: 1 opening, 0 closing. */\n readonly goal: 0 | 1\n readonly opening: number\n /**\n * Starts using a leaf: the other way from where the last use sent it (`lastGoal`), else a closed or half-open leaf opens and an open\n * one closes. A use in the middle of a swing turns it round.\n * Answers the goal (1 open, 0 closed), or null when the leaf is locked (it rattles instead).\n */\n begin(target: DoorUseTarget): 0 | 1 | null\n /**\n * Advances the use; `isFree(from, to)` answers whether the leaf can go from one opening to the other (nothing in the way of its sweep). `hand` says whether the handle is still\n * within arm reach after the step and whether the leaf comes toward the body (`pull`): once the handle is out of reach the swing hands over to `push` (a leaf going away is shoved\n * on) or `release` (a leaf coming toward the body is let go) and the leaf finishes on its own. Without `hand` the hand never lets go.\n */\n step(dt: number, isFree: (from: number, to: number) => boolean, hand?: DoorUseHand): DoorUseStep\n /** Lets go at once. */\n cancel(): void\n}\n\nexport function createDoorUse(rules: Partial<DoorUseRules> = {}): DoorUse {\n const r: DoorUseRules = { ...DOOR_USE_DEFAULTS, ...rules, swingSeconds: { ...DOOR_USE_DEFAULTS.swingSeconds, ...rules.swingSeconds } }\n let phase: DoorUsePhase = 'idle'\n let goal: 0 | 1 = 1\n let opening = 0\n let time = 0\n let swing = 1\n let start = 0\n /** The hand let go and the leaf is still going to its goal on its own. */\n let coasting = false\n\n const out = (progress: number, arrived = false, b: DoorUseBlock = null): DoorUseStep => ({ phase, opening, progress: Math.max(0, Math.min(1, progress)), block: b, arrived })\n\n /** Moves the leaf toward its goal for `dt` seconds, a little at a time so it stops at the first thing in its way and not past it. */\n const advance = (dt: number, isFree: (from: number, to: number) => boolean): 'moving' | 'stopped' | 'arrived' => {\n const want = goal - opening\n const reach = Math.min(Math.abs(want), dt / swing)\n let moved = 0\n while (moved < reach - 1e-9) {\n const inc = Math.min(r.stepFraction, reach - moved)\n const next = opening + Math.sign(want) * inc\n if (!isFree(opening, next)) return 'stopped'\n opening = next\n moved += inc\n }\n return Math.abs(goal - opening) < 1e-6 ? 'arrived' : 'moving'\n }\n\n /** The hand coming back to rest; it waits there (progress 1) while the leaf still goes on its own. */\n const releaseOut = (arrived: boolean, b: DoorUseBlock = null): DoorUseStep => {\n const p = time / r.releaseSeconds\n if (p >= 1 && !coasting) phase = 'idle'\n return out(p, arrived, b)\n }\n\n return {\n get phase() {\n return phase\n },\n get goal() {\n return goal\n },\n get opening() {\n return opening\n },\n begin(target) {\n opening = Math.max(0, Math.min(1, target.opening))\n time = 0\n coasting = false\n if (target.locked) {\n phase = 'rattle'\n return null\n }\n // in the middle of a swing the hand is already on the handle: the leaf turns round at once\n if (phase === 'swing' || phase === 'reach') goal = goal === 1 ? 0 : 1\n else if (target.lastGoal !== undefined && opening > r.endTolerance && opening < 1 - r.endTolerance) goal = target.lastGoal === 1 ? 0 : 1\n else goal = opening > 0.5 ? 0 : 1\n swing = swingSecondsFor(target.massKg, r)\n start = opening\n phase = phase === 'swing' ? 'swing' : 'reach'\n return goal\n },\n step(dt, isFree, hand) {\n if (phase === 'idle') return out(0)\n time += dt\n if (phase === 'rattle') {\n const p = time / r.rattleSeconds\n if (p >= 1) {\n phase = 'idle'\n return out(1, false, 'locked')\n }\n return out(p, false, time === dt ? 'locked' : null)\n }\n if (phase === 'reach') {\n const p = time / r.reachSeconds\n if (p < 1) return out(p)\n phase = 'swing'\n time = 0\n start = opening\n }\n if (phase === 'swing' || phase === 'push' || coasting) {\n const result = advance(dt, isFree)\n const travel = Math.abs(goal - start) || 1\n const progress = 1 - Math.abs(goal - opening) / travel\n const inHand = phase !== 'release'\n if (result === 'stopped' || result === 'arrived') {\n if (result === 'arrived') opening = goal\n coasting = false\n if (inHand) {\n phase = 'release'\n time = 0\n }\n if (result === 'arrived') return inHand ? out(1, true) : releaseOut(true)\n return inHand ? out(progress, false, 'obstacle') : releaseOut(false, 'obstacle')\n }\n if (inHand && hand && !hand.reaches()) {\n time = 0\n if (hand.pull) {\n phase = 'release'\n coasting = true\n } else phase = 'push'\n return out(0)\n }\n if (phase === 'push') {\n if (time >= r.pushSeconds) {\n phase = 'release'\n time = 0\n coasting = true\n return out(0)\n }\n return out(time / r.pushSeconds)\n }\n if (phase === 'swing') return out(progress)\n }\n return releaseOut(false)\n },\n cancel() {\n phase = 'idle'\n time = 0\n },\n }\n}\n","/**\n * The hands and the weapon (decision of the owner, 2026-11-24): an interaction of one hand (a small thing picked up, a door, a switch) takes the free hand, the one that does not\n * hold the weapon, and the weapon stays in its hand; one of both hands (a big thing carried, a push, a climb) first puts the weapon away in a slot of the body that takes it\n * (a holster at the hip, a sling or back slot for a long gun) and, with none, lets it fall to the ground. A two-handed weapon (a rifle, a shotgun) leaves no hand free, so any\n * interaction puts it away or drops it. When the interaction ends, what was put away comes back to its hand; what fell stays on the ground.\n * A long gun on its sling (decision of the owner, 2026-11-25) is not put away: it swings onto the sling and hangs on the body (`sling`), and stays there after the interaction until\n * the player brings it back to the hands; with no sling worn it goes to the next slot that takes it (`SLOT_FALLBACKS`: the back).\n * A second weapon of the belt (a pistol or a knife in the other hand, decision of the owner 2026-11-27) is not thrown away when the holster is taken: it is tucked in the\n * belt (`SLOT_FALLBACKS`: hip, then belt) and comes back after, as the holstered one does. Picking something up never drops a weapon the body has a place for.\n * Engine-agnostic: the host says what is in each hand and which slots the body wears; this says which hand acts and what happens to each weapon.\n */\n\n/** `R` the weapon hand, `L` the other one. */\nexport type BodyHand = 'R' | 'L'\n\n/** A weapon in a hand: `hands` it takes (0 the bare hand, 1, 2) and the slot of the body that takes it (`hip`, `back`...), null when none does. */\nexport interface HandWeapon {\n readonly id: string\n readonly hands: 0 | 1 | 2\n readonly slot: string | null\n}\n\nexport interface HandsRules {\n /** A thing up to `maxKg` whose longest side is up to `maxLength` metres goes in one hand; anything bigger or heavier takes both. */\n readonly oneHand: { readonly maxKg: number; readonly maxLength: number }\n /**\n * A thing with a carry handle (a bucket of water, a jerrycan, a toolbox) hangs from one hand by it up to `maxKg`, whatever its size. Optional, so rules written\n * before it keep working: without it the default (`HANDS_BY_HANDLE`) holds.\n */\n readonly byHandle?: { readonly maxKg: number }\n}\n\n/** How much a hand carries by a handle when the rules say nothing of it: a 20 L jerrycan full, a bucket of water. */\nexport const HANDS_BY_HANDLE = { maxKg: 25 } as const\n\nexport const HANDS_DEFAULTS: HandsRules = { oneHand: { maxKg: 4, maxLength: 0.7 }, byHandle: HANDS_BY_HANDLE }\n\n/** The slot a weapon goes to when the body wears none of its own (or it is taken): a long gun with no sling goes across the back, a second handgun or knife into the belt. */\nexport const SLOT_FALLBACKS: Readonly<Record<string, readonly string[]>> = { sling: ['back'], hip: ['belt'] }\n\n/** The belt: where a one-handed weapon is tucked when its own place on the body is taken. */\nexport const BELT_SLOT = 'belt'\n\n/** The slot of a long gun that hangs on its sling. */\nexport const SLING_SLOT = 'sling'\n\n/**\n * What a weapon does when the hands are wanted: `holster` goes to `slot` and comes back after; `sling` hangs on the body by its sling and stays there until it is brought back;\n * `drop` falls to the ground and stays there.\n */\nexport type HandsMoveKind = 'holster' | 'sling' | 'drop'\n\nexport interface HandsMove {\n readonly hand: BodyHand\n readonly weapon: string\n readonly move: HandsMoveKind\n readonly slot?: string\n}\n\nexport interface HandsPlan {\n /** The hand the interaction takes, or `both`. */\n readonly hand: BodyHand | 'both'\n /** What happens to each weapon that is in the way, the weapon hand first. */\n readonly moves: readonly HandsMove[]\n}\n\nexport interface PlanHandsParams {\n /** The hands the interaction takes (`interactionHandsFor` for a thing picked up). */\n readonly hands: 1 | 2\n /** What each hand holds; absent or null is an empty hand. */\n readonly weapons: { readonly R?: HandWeapon | null; readonly L?: HandWeapon | null }\n /** The slots the body wears and that are empty (a holster, a sling); one weapon each. */\n readonly slots: readonly string[]\n /** The slots tried when a weapon's own is not worn; default `SLOT_FALLBACKS`. */\n readonly fallbacks?: Readonly<Record<string, readonly string[]>>\n}\n\n/** How many hands it takes to carry a thing of `massKg` and `size` (metres, any order); by its carry handle (`handle`), one up to `byHandle.maxKg`. */\nexport function interactionHandsFor(thing: { readonly massKg: number; readonly size?: readonly number[]; readonly handle?: boolean }, rules: HandsRules = HANDS_DEFAULTS): 1 | 2 {\n if (thing.handle) return thing.massKg > (rules.byHandle ?? HANDS_BY_HANDLE).maxKg ? 2 : 1\n const longest = Math.max(0, ...(thing.size ?? []))\n return thing.massKg > rules.oneHand.maxKg || longest > rules.oneHand.maxLength ? 2 : 1\n}\n\nconst holds = (weapon: HandWeapon | null | undefined): weapon is HandWeapon => !!weapon && weapon.hands > 0\n\n/** Which hand acts and what happens to each weapon in the way. */\nexport function planHands(params: PlanHandsParams): HandsPlan {\n const { R, L } = params.weapons\n const free = [...params.slots]\n const fallbacks = params.fallbacks ?? SLOT_FALLBACKS\n const stow = (hand: BodyHand, weapon: HandWeapon): HandsMove => {\n const own = weapon.slot === null ? [] : [weapon.slot, ...(fallbacks[weapon.slot] ?? [])]\n // a one-handed weapon (a second handgun, a compact SMG, a hatchet) is tucked in the belt when its own places are taken, never thrown away\n const tried = weapon.hands === 1 && !own.includes(BELT_SLOT) ? [...own, BELT_SLOT] : own\n const slot = tried.find((name) => free.includes(name))\n if (slot === undefined) return { hand, weapon: weapon.id, move: 'drop' }\n free.splice(free.indexOf(slot), 1)\n return { hand, weapon: weapon.id, move: slot === SLING_SLOT ? 'sling' : 'holster', slot }\n }\n if (params.hands === 2) {\n const moves = [...(holds(R) ? [stow('R', R)] : []), ...(holds(L) ? [stow('L', L)] : [])]\n return { hand: 'both', moves }\n }\n if (holds(L)) return { hand: 'L', moves: [stow('L', L)] }\n if (!holds(R)) return { hand: 'R', moves: [] }\n return { hand: 'L', moves: R.hands === 2 ? [stow('R', R)] : [] }\n}\n\n/** What comes back to the hands once the interaction ends: the weapons that were put away, each to its hand; the slung ones stay on the sling and the dropped ones on the ground. */\nexport function drawBackOf(plan: HandsPlan): readonly { readonly hand: BodyHand; readonly weapon: string }[] {\n return plan.moves.filter((move) => move.move === 'holster').map((move) => ({ hand: move.hand, weapon: move.weapon }))\n}\n","/**\n * Whether one person lifts a thing off the floor with the hands, from its mass and its size (the mass comes from the material of the SDK: density times volume, or\n * the real mass of the catalogue). The strength is the most a person lifts held against the body; a bulky thing is held away from it, and the back takes the load\n * times its lever (the horizontal multiplier of the NIOSH lifting equation: what is held at `H` metres from the spine is `closeReach / H` of what is held against\n * it). The thing is held the easiest way: its thinnest side away from the body, the hands around the middle one. A sofa (45 kg, 2 x 0.9 x 0.85 m) is held at\n * 0.58 m and weighs more than the 26 kg a person lifts that far out: it is pushed or dragged, not picked up. A gas bottle (16 kg, 0.36 m across) goes up.\n * Engine-agnostic: the host passes the mass and the box of the thing.\n */\n\nexport interface LiftRules {\n /** The most a person lifts held against the body, kg. */\n readonly maxKg: number\n /** Distance (m) from the spine to a load held against the body: NIOSH's 25 cm, where the lever costs nothing. */\n readonly closeReach: number\n /** Distance (m) from the spine to the near face of what is held: the front of the trunk. */\n readonly bodyDepth: number\n /** The widest a person holds between the hands around a thing, metres: the arms hugging it. */\n readonly maxSpan: number\n}\n\nexport const LIFT_DEFAULTS: LiftRules = { maxKg: 60, closeReach: 0.25, bodyDepth: 0.15, maxSpan: 1.3 }\n\n/** `ok` it goes up; `too_heavy` heavier than the strength even against the body; `too_bulky` too wide for the arms or too far out for its weight. */\nexport type LiftVerdict = 'ok' | 'too_heavy' | 'too_bulky'\n\nexport interface LiftCheck {\n readonly verdict: LiftVerdict\n /** The most this thing could weigh and still go up, held its easiest way, kg. */\n readonly liftableKg: number\n}\n\n/** Whether a thing of `massKg` and `size` (metres, any order; without it, a thing held against the body) goes up in one person's hands. */\nexport function liftCheckFor(thing: { readonly massKg: number; readonly size?: readonly number[] }, rules: Partial<LiftRules> = {}): LiftCheck {\n const r = { ...LIFT_DEFAULTS, ...rules }\n const [, middle = 0, thinnest = 0] = [...(thing.size ?? [])].sort((a, b) => b - a)\n const reach = r.bodyDepth + Math.max(0, thinnest) / 2\n const liftableKg = r.maxKg * Math.min(1, r.closeReach / Math.max(reach, 1e-6))\n if (thing.massKg > r.maxKg) return { verdict: 'too_heavy', liftableKg }\n if (middle > r.maxSpan || thing.massKg > liftableKg) return { verdict: 'too_bulky', liftableKg }\n return { verdict: 'ok', liftableKg }\n}\n","/**\n * The little pose algebra the hands need, engine-agnostic: a pose is a position and a unit quaternion `[x, y, z, w]` (local to world), as `HandPose` of game-contracts.\n */\n\nexport type Vec3Tuple = readonly [number, number, number]\nexport type QuatTuple = readonly [number, number, number, number]\n\nexport interface Pose {\n readonly position: Vec3Tuple\n readonly quaternion: QuatTuple\n}\n\n/** The rotation whose local x, y and z go to `x`, `y` and `z` (an orthonormal, right-handed basis). */\nexport function quaternionOfBasis(x: readonly number[], y: readonly number[], z: readonly number[]): [number, number, number, number] {\n const [m00, m10, m20] = [x[0] ?? 0, x[1] ?? 0, x[2] ?? 0]\n const [m01, m11, m21] = [y[0] ?? 0, y[1] ?? 0, y[2] ?? 0]\n const [m02, m12, m22] = [z[0] ?? 0, z[1] ?? 0, z[2] ?? 0]\n const trace = m00 + m11 + m22\n if (trace > 0) {\n const s = 0.5 / Math.sqrt(trace + 1)\n return [(m21 - m12) * s, (m02 - m20) * s, (m10 - m01) * s, 0.25 / s]\n }\n if (m00 > m11 && m00 > m22) {\n const s = 2 * Math.sqrt(1 + m00 - m11 - m22)\n return [0.25 * s, (m01 + m10) / s, (m02 + m20) / s, (m21 - m12) / s]\n }\n if (m11 > m22) {\n const s = 2 * Math.sqrt(1 + m11 - m00 - m22)\n return [(m01 + m10) / s, 0.25 * s, (m12 + m21) / s, (m02 - m20) / s]\n }\n const s = 2 * Math.sqrt(1 + m22 - m00 - m11)\n return [(m02 + m20) / s, (m12 + m21) / s, 0.25 * s, (m10 - m01) / s]\n}\n\nexport function multiplyQuaternions(a: QuatTuple, b: QuatTuple): [number, number, number, number] {\n const [ax, ay, az, aw] = a\n const [bx, by, bz, bw] = b\n return [ax * bw + aw * bx + ay * bz - az * by, ay * bw + aw * by + az * bx - ax * bz, az * bw + aw * bz + ax * by - ay * bx, aw * bw - ax * bx - ay * by - az * bz]\n}\n\nexport function conjugateQuaternion(q: QuatTuple): [number, number, number, number] {\n return [-q[0], -q[1], -q[2], q[3]]\n}\n\nexport function rotateVector(q: QuatTuple, v: Vec3Tuple): [number, number, number] {\n const [x, y, z, w] = q\n const tx = 2 * (y * v[2] - z * v[1])\n const ty = 2 * (z * v[0] - x * v[2])\n const tz = 2 * (x * v[1] - y * v[0])\n return [v[0] + w * tx + (y * tz - z * ty), v[1] + w * ty + (z * tx - x * tz), v[2] + w * tz + (x * ty - y * tx)]\n}\n\n/** `parent` then `local`: the pose of a thing given in the frame of `parent`. */\nexport function composePose(parent: Pose, local: Pose): Pose {\n const offset = rotateVector(parent.quaternion, local.position)\n return {\n position: [parent.position[0] + offset[0], parent.position[1] + offset[1], parent.position[2] + offset[2]],\n quaternion: multiplyQuaternions(parent.quaternion, local.quaternion),\n }\n}\n\n/** The pose whose frame puts `local` at `world`: `composePose(result, local)` is `world`. */\nexport function poseHolding(world: Pose, local: Pose): Pose {\n const quaternion = multiplyQuaternions(world.quaternion, conjugateQuaternion(local.quaternion))\n const offset = rotateVector(quaternion, local.position)\n return { position: [world.position[0] - offset[0], world.position[1] - offset[1], world.position[2] - offset[2]], quaternion }\n}\n\n/** Between `a` (k 0) and `b` (k 1): the position on the line, the turn the short way round. */\nexport function blendPoses(a: Pose, b: Pose, k: number): Pose {\n const lerp = (i: 0 | 1 | 2): number => a.position[i] + (b.position[i] - a.position[i]) * k\n const dot = a.quaternion[0] * b.quaternion[0] + a.quaternion[1] * b.quaternion[1] + a.quaternion[2] * b.quaternion[2] + a.quaternion[3] * b.quaternion[3]\n const sign = dot < 0 ? -1 : 1\n const mixed = [0, 1, 2, 3].map((i) => (a.quaternion[i] ?? 0) * (1 - k) + (b.quaternion[i] ?? 0) * sign * k)\n const length = Math.hypot(...mixed) || 1\n return { position: [lerp(0), lerp(1), lerp(2)], quaternion: [(mixed[0] ?? 0) / length, (mixed[1] ?? 0) / length, (mixed[2] ?? 0) / length, (mixed[3] ?? 1) / length] }\n}\n\n/** Slow in, slow out: a hand speeds up off its start and settles on its target. */\nexport function easeInOut(t: number): number {\n const k = Math.min(1, Math.max(0, t))\n return k * k * (3 - 2 * k)\n}\n","/**\n * How a hand closes on a thing it picks up (decision of the owner, 2026-11-25: the hand on the thing's real grip, the fingers closed around it, the thing in the palm, aligned with\n * the hand in both views). Engine-agnostic: the thing is its box (`size`, metres, in its own frame), the hand frame is the one of `HandTargets`: +x along the fingers, +y the back\n * of the hand, the thumb at -z for a right hand and +z for a left one. The thing's longest side runs through the fist along the thumb (a bottle stands up in a hand held thumb up),\n * its thinnest side across the palm (the palm lies on its broad face), and its middle sits a palm's thickness plus half that side under the middle of the palm.\n */\nimport type { BodyHand } from './hands'\nimport { composePose, poseHolding, quaternionOfBasis } from './hand-math'\nimport type { Pose, Vec3Tuple } from './hand-math'\n\nexport const ITEM_GRIP = {\n /** Half the thickness of a palm (m): what lies between the middle of the palm and the thing. */\n palm: 0.011,\n /** The closure of the fingers (0 open, 1 a fist) on a thing this thick (m) or thinner. */\n fistAt: 0.03,\n closed: 0.95,\n /** How much the closure opens per metre the thing is thicker than `fistAt`, and the most it opens to. */\n openPerMetre: 4,\n open: 0.35,\n /** The fingers before they close on it, as the hand comes to the thing. */\n reaching: 0.15,\n} as const\n\nexport interface ItemGrip {\n /** The thing's middle and turn in the frame of the hand. */\n readonly local: Pose\n /** How closed the fingers are on it (`HandTargets.grip`). */\n readonly grip: number\n /** The hand holds it by a carry handle (a bucket's bail) and it hangs under the hand, upright: carried with the arm down at the side, not in front of the chest. */\n readonly hanging?: boolean\n}\n\nconst AXES: readonly Vec3Tuple[] = [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n]\n\nconst cross = (a: Vec3Tuple, b: Vec3Tuple): Vec3Tuple => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]\nconst scaled = (v: Vec3Tuple, k: number): Vec3Tuple => [v[0] * k, v[1] * k, v[2] * k]\n\n/**\n * The grip of a hand on the carry handle of a thing (a bucket's bail, a jerrycan's or a toolbox's handle), `handle` the middle of the handle in the thing's own frame (metres from its\n * middle): the fist closes round the handle, the thing upright (its +y up, along the thumb) and hanging under the hand, its handle along the fingers.\n */\nexport function gripOnHandle(handle: readonly number[], hand: BodyHand): ItemGrip {\n // the thing's +y goes up the hand (-z of a right hand, the thumb side; +z of a left one), its +x along the fingers, +z the third axis of a right-handed frame\n const up: Vec3Tuple = hand === 'R' ? [0, 0, -1] : [0, 0, 1]\n const along: Vec3Tuple = [1, 0, 0]\n const quaternion = quaternionOfBasis(along, up, cross(along, up))\n const local: Pose = { position: [0, 0, 0], quaternion }\n // the middle of the thing sits so that its handle is in the palm\n const handleInHand = composePose(local, { position: [handle[0] ?? 0, handle[1] ?? 0, handle[2] ?? 0], quaternion: [0, 0, 0, 1] }).position\n return { local: { position: [-handleInHand[0], -handleInHand[1] - ITEM_GRIP.palm, -handleInHand[2]], quaternion }, grip: ITEM_GRIP.closed, hanging: true }\n}\n\n/** The grip of a hand on a thing of box `size` (its own frame, metres); by its carry handle when it has one (`gripOnHandle`). */\nexport function gripOfItem(size: readonly number[], hand: BodyHand, handle?: readonly number[] | null): ItemGrip {\n if (handle) return gripOnHandle(handle, hand)\n const sides = [0, 1, 2].map((axis) => ({ axis, length: Math.max(0, size[axis] ?? 0) })).sort((a, b) => b.length - a.length)\n const [long, mid, thin] = sides as [(typeof sides)[0], (typeof sides)[0], (typeof sides)[0]]\n const thumb: Vec3Tuple = hand === 'R' ? [0, 0, -1] : [0, 0, 1]\n // where each of the thing's own axes goes in the hand: the long one along the thumb, the thin one across the palm, the last one keeps the frame right-handed\n const columns: Vec3Tuple[] = [AXES[0] as Vec3Tuple, AXES[1] as Vec3Tuple, AXES[2] as Vec3Tuple]\n columns[long.axis] = thumb\n columns[thin.axis] = [0, 1, 0]\n const next = (axis: number): number => (axis + 1) % 3\n // x × y = z for the thing's frame: the column after `mid` crossed with the one after that names it\n const before = columns[next(next(mid.axis))] as Vec3Tuple\n const after = columns[next(mid.axis)] as Vec3Tuple\n columns[mid.axis] = cross(after, before)\n const quaternion = quaternionOfBasis(columns[0] as Vec3Tuple, columns[1] as Vec3Tuple, columns[2] as Vec3Tuple)\n const depth = ITEM_GRIP.palm + thin.length / 2\n const across = (mid.length + thin.length) / 2\n const grip = Math.max(ITEM_GRIP.open, Math.min(ITEM_GRIP.closed, ITEM_GRIP.closed - ITEM_GRIP.openPerMetre * Math.max(0, across - ITEM_GRIP.fistAt)))\n return { local: { position: scaled([0, -1, 0], depth), quaternion }, grip }\n}\n\n/** Where the thing is with the hand at `hand` holding it by `grip`. */\nexport function itemPoseInHand(hand: Pose, grip: ItemGrip): Pose {\n return composePose(hand, grip.local)\n}\n\n/** Where the hand goes to take the thing where it lies (`item`, its middle and turn) by `grip`. */\nexport function handPoseOnItem(item: Pose, grip: ItemGrip): Pose {\n return poseHolding(item, grip.local)\n}\n","/**\n * The hands take a thing in steps one can see (decision of the owner, 2026-11-25): first each weapon in the way goes off the hands (`stow` to its holster, `sling` onto its sling, or\n * `drop`: tossed to the ground), then the hand `reach`es the thing's grip, the fingers `close` on it, and it is `lift`ed to where it is carried. A weapon comes back to the hands the\n * same way round (`draw`). Engine-agnostic and clock-free: the host advances it by its own frame's `dt` and does what each step says.\n */\nimport type { HandsMove, HandsPlan } from './hands'\nimport { easeInOut } from './hand-math'\n\n/** Seconds each step takes. */\nexport interface HandsTiming {\n readonly stow: number\n readonly sling: number\n readonly drop: number\n readonly reach: number\n readonly close: number\n readonly lift: number\n readonly draw: number\n}\n\nexport const HANDS_TIMING: HandsTiming = { stow: 0.5, sling: 0.45, drop: 0.4, reach: 0.38, close: 0.16, lift: 0.3, draw: 0.5 }\n\nexport type TakeStepKind = 'stow' | 'sling' | 'drop' | 'reach' | 'close' | 'lift' | 'draw'\n\nexport interface TakeStep {\n readonly kind: TakeStepKind\n /** The weapon the step moves (`stow`, `sling`, `drop`, `draw`). */\n readonly move?: HandsMove\n readonly start: number\n readonly end: number\n}\n\nexport interface TakeSequence {\n readonly steps: readonly TakeStep[]\n readonly duration: number\n}\n\nconst KIND_OF_MOVE: Readonly<Record<HandsMove['move'], 'stow' | 'sling' | 'drop'>> = { holster: 'stow', sling: 'sling', drop: 'drop' }\n\nconst lay = (parts: readonly { readonly kind: TakeStepKind; readonly seconds: number; readonly move?: HandsMove }[]): TakeSequence => {\n let at = 0\n const steps = parts.map((part) => {\n const step: TakeStep = { kind: part.kind, start: at, end: at + part.seconds, ...(part.move ? { move: part.move } : {}) }\n at = step.end\n return step\n })\n return { steps, duration: at }\n}\n\n/** The steps of taking a thing with `plan`: the weapons off the hands (the off hand first), then reach, close and lift. `take` false leaves the thing out (a push). */\nexport function planTakeSequence(plan: HandsPlan, options: { readonly timing?: HandsTiming; readonly take?: boolean } = {}): TakeSequence {\n const timing = options.timing ?? HANDS_TIMING\n const moves = [...plan.moves].reverse().map((move) => ({ kind: KIND_OF_MOVE[move.move], seconds: timing[KIND_OF_MOVE[move.move]], move }))\n const take = options.take === false ? [] : [\n { kind: 'reach' as const, seconds: timing.reach },\n { kind: 'close' as const, seconds: timing.close },\n { kind: 'lift' as const, seconds: timing.lift },\n ]\n return lay([...moves, ...take])\n}\n\n/** The steps of bringing weapons back to the hands, one after the other. */\nexport function planDrawSequence(moves: readonly HandsMove[], timing: HandsTiming = HANDS_TIMING): TakeSequence {\n return lay(moves.map((move) => ({ kind: 'draw' as const, seconds: timing.draw, move })))\n}\n\nexport interface TakeProgress {\n /** The step going on now, null once the sequence is over. */\n readonly step: TakeStep | null\n /** How far into it, 0..1, eased (slow in, slow out). */\n readonly progress: number\n /** The steps that began during this advance, in order. */\n readonly started: readonly TakeStep[]\n /** The steps that ended during this advance, in order. */\n readonly ended: readonly TakeStep[]\n readonly done: boolean\n}\n\nexport interface TakeTimeline {\n readonly sequence: TakeSequence\n /** Seconds since it began. */\n readonly time: number\n /** Moves the timeline on by `dt` seconds (the host's frame). The first call with 0 starts the first step. */\n advance(dt: number): TakeProgress\n}\n\nexport function createTakeTimeline(sequence: TakeSequence): TakeTimeline {\n let time = 0\n // the steps already begun and already over: each is reported once\n let begun = 0\n let over = 0\n const steps = sequence.steps\n return {\n sequence,\n get time() {\n return time\n },\n advance(dt) {\n time = Math.min(sequence.duration, time + Math.max(0, dt))\n const startedFrom = begun\n while (begun < steps.length && (steps[begun] as TakeStep).start <= time) begun++\n const endedFrom = over\n while (over < begun && (steps[over] as TakeStep).end <= time) over++\n const started = steps.slice(startedFrom, begun)\n const ended = steps.slice(endedFrom, over)\n const step = steps.find((entry) => time < entry.end) ?? null\n const progress = step ? easeInOut((time - step.start) / Math.max(1e-6, step.end - step.start)) : 1\n return { step, progress, started, ended, done: time >= sequence.duration }\n },\n }\n}\n","/**\n * Draws a body that moves in fixed steps between two of them: remember the last two step poses, blend by the scheduler's `alpha` (CLAUDE.md §15).\n * Drawn at the step pose, a body moves 0, 1 or 2 steps per frame at a display that is not the step's rate: it stutters.\n */\n\nexport type StepPosition = { readonly x: number; readonly y: number; readonly z: number }\n\nexport type StepPoseOptions = {\n /** A step longer than this (metres) is a teleport (a respawn, a placed body): drawn at the new pose at once, never swept across. Default 3. */\n readonly teleportDistance?: number\n}\n\nexport type StepPose = {\n /** The body's pose after a fixed step. */\n record(position: StepPosition): void\n /** Puts both poses on `position`: nothing is blended from where the body was. */\n reset(position: StepPosition): void\n /** The pose to draw: `alpha` in [0, 1] is how far the frame is into the next step. */\n blend(alpha: number): StepPosition\n}\n\nexport const STEP_POSE_DEFAULTS = { teleportDistance: 3 } as const\n\nexport function createStepPose(start: StepPosition, options: StepPoseOptions = {}): StepPose {\n const teleportDistance = options.teleportDistance ?? STEP_POSE_DEFAULTS.teleportDistance\n let previous = { x: start.x, y: start.y, z: start.z }\n let current = { x: start.x, y: start.y, z: start.z }\n return {\n record(position) {\n previous = current\n current = { x: position.x, y: position.y, z: position.z }\n if (Math.hypot(current.x - previous.x, current.y - previous.y, current.z - previous.z) > teleportDistance) previous = current\n },\n reset(position) {\n previous = { x: position.x, y: position.y, z: position.z }\n current = previous\n },\n blend(alpha) {\n const k = Math.min(1, Math.max(0, alpha))\n return { x: previous.x + (current.x - previous.x) * k, y: previous.y + (current.y - previous.y) * k, z: previous.z + (current.z - previous.z) * k }\n },\n }\n}\n","/**\n * Getting into a vehicle and out of it, as a body does it: the hand goes to the door's handle, the door opens, the body sits, the hand on the door's side\n * pulls the door shut; out, the same backwards (the door opened from inside, the body up at the sill, the door pushed shut). A locked door is only shaken.\n * A vehicle without a door (a motorcycle, an open tractor) is sat on and got off. Engine-agnostic: the host owns the door, the seat and the hand\n * (`VehicleBoardingPorts`); this says what happens next and when the driver is in.\n */\n\n/**\n * `out` on its feet; `reach` the hand going to the handle; `refused` shaking a locked door; `open` the door swinging open; `sit` the body going to the seat;\n * `shut` seated, pulling the door shut; `in` seated with the door shut (the driver drives); `unlatch` seated, pushing the door open; `stand` getting up at the\n * sill; `close` on its feet, the hand shutting the door.\n */\nexport type VehicleBoardingPhase = 'out' | 'reach' | 'refused' | 'open' | 'sit' | 'shut' | 'in' | 'unlatch' | 'stand' | 'close'\n\nexport type VehicleBoardingEvent = { readonly type: 'in' } | { readonly type: 'out' } | { readonly type: 'refused'; readonly reason: 'locked' | 'no_seat' | 'blocked' }\n\n/** What the hand asks of the host at a door's outer handle: `pull` the door comes to the body (opening) or goes away (shutting); `onGrip` once the hand is on it. */\nexport interface VehicleHandleReach {\n readonly pull: boolean\n readonly locked: boolean\n onGrip(): void\n /** The body could not get to the handle: nothing was gripped. */\n onMiss(): void\n}\n\nexport interface VehicleBoardingPorts {\n /** The seat is entered by a door (false: sat on from outside, as a motorcycle). */\n readonly hasDoor: boolean\n doorLocked(): boolean\n /** 0 shut to 1 open. */\n doorOpenness(): number\n /** Starts the door swinging to open (true) or shut (false). */\n swingDoor(open: boolean): void\n /** Sends the hand to the outer handle; a host without a hand calls `onGrip` at once. */\n reachHandle(reach: VehicleHandleReach): void\n /** Starts the body sitting down on the seat; false when it cannot. */\n sit(): boolean\n /** Starts the body getting up at the seat's exit; false when the exit is blocked. */\n stand(): boolean\n /** How far into the seat the body is: 0 on its feet, 1 seated. */\n seated(): number\n}\n\nexport interface VehicleBoardingRules {\n /** How long a locked door is shaken before the hand gives up, seconds. */\n readonly rattleSeconds: number\n /** Within this of shut or open the door counts as there. */\n readonly endTolerance: number\n}\n\nexport const VEHICLE_BOARDING_DEFAULTS: VehicleBoardingRules = { rattleSeconds: 0.75, endTolerance: 0.02 }\n\nexport interface VehicleBoarding {\n readonly phase: VehicleBoardingPhase\n /** The driver is seated with the door shut: the controls are the driver's. */\n readonly driving: boolean\n /** The hand on the door's side is on the door's inner pull (shutting it from the seat, or opening it to get out). */\n readonly handOnDoor: boolean\n /** Starts getting in; false when not on its feet outside. */\n enter(): boolean\n /**\n * Sits without going to the door: the body is put at the seat (a bench's shortcut, a driver who starts inside, a door the body has no clear way to).\n * False when not on its feet outside or the seat refuses.\n */\n takeSeat(): boolean\n /** Starts getting out; false when not driving. */\n leave(): boolean\n /** The body left the seat by another way (the host got it up, the seat is gone): on its feet, the door as it is. */\n dropped(): void\n update(dt: number): VehicleBoardingEvent[]\n}\n\nexport function createVehicleBoarding(ports: VehicleBoardingPorts, rules: Partial<VehicleBoardingRules> = {}): VehicleBoarding {\n const r = { ...VEHICLE_BOARDING_DEFAULTS, ...rules }\n let phase: VehicleBoardingPhase = 'out'\n let clock = 0\n const isOpen = (): boolean => ports.doorOpenness() >= 1 - r.endTolerance\n const isShut = (): boolean => ports.doorOpenness() <= r.endTolerance\n const sitDown = (events: VehicleBoardingEvent[]): void => {\n if (ports.sit()) phase = 'sit'\n else {\n phase = 'out'\n events.push({ type: 'refused', reason: 'no_seat' })\n }\n }\n const pending: VehicleBoardingEvent[] = []\n return {\n get phase() {\n return phase\n },\n get driving() {\n return phase === 'in'\n },\n get handOnDoor() {\n return phase === 'shut' || phase === 'unlatch'\n },\n enter() {\n if (phase !== 'out') return false\n if (!ports.hasDoor) {\n if (!ports.sit()) return false\n phase = 'sit'\n return true\n }\n if (isOpen()) {\n phase = 'open'\n return true\n }\n phase = 'reach'\n const locked = ports.doorLocked()\n ports.reachHandle({\n pull: true,\n locked,\n onGrip: () => {\n if (phase !== 'reach') return\n if (locked) {\n phase = 'refused'\n clock = 0\n return\n }\n ports.swingDoor(true)\n phase = 'open'\n },\n onMiss: () => {\n if (phase !== 'reach') return\n phase = 'out'\n pending.push({ type: 'refused', reason: 'blocked' })\n },\n })\n return true\n },\n takeSeat() {\n if (phase !== 'out' || !ports.sit()) return false\n phase = 'sit'\n return true\n },\n leave() {\n if (phase !== 'in') return false\n if (!ports.hasDoor) {\n if (!ports.stand()) {\n pending.push({ type: 'refused', reason: 'blocked' })\n return false\n }\n phase = 'stand'\n return true\n }\n ports.swingDoor(true)\n phase = 'unlatch'\n return true\n },\n dropped() {\n if (phase === 'out') return\n phase = 'out'\n pending.push({ type: 'out' })\n },\n update(dt) {\n const events = pending.splice(0)\n switch (phase) {\n case 'refused':\n clock += dt\n if (clock >= r.rattleSeconds) {\n phase = 'out'\n events.push({ type: 'refused', reason: 'locked' })\n }\n break\n case 'open':\n if (isOpen()) sitDown(events)\n break\n case 'sit':\n if (ports.seated() >= 1) {\n if (ports.hasDoor && !isShut()) {\n ports.swingDoor(false)\n phase = 'shut'\n } else {\n phase = 'in'\n events.push({ type: 'in' })\n }\n }\n break\n case 'shut':\n if (isShut()) {\n phase = 'in'\n events.push({ type: 'in' })\n }\n break\n case 'unlatch':\n if (!isOpen()) break\n if (ports.stand()) phase = 'stand'\n else {\n // nowhere to stand at the sill: the door comes back shut and the driver stays\n ports.swingDoor(false)\n phase = 'shut'\n events.push({ type: 'refused', reason: 'blocked' })\n }\n break\n case 'stand':\n if (ports.seated() > 0) break\n if (!ports.hasDoor) {\n phase = 'out'\n events.push({ type: 'out' })\n break\n }\n phase = 'close'\n ports.reachHandle({\n pull: false,\n locked: false,\n onGrip: () => {\n if (phase === 'close') ports.swingDoor(false)\n },\n // the door out of reach stays open: the driver is out all the same\n onMiss: () => {\n if (phase !== 'close') return\n phase = 'out'\n pending.push({ type: 'out' })\n },\n })\n break\n case 'close':\n if (isShut()) {\n phase = 'out'\n events.push({ type: 'out' })\n }\n break\n default:\n break\n }\n return events\n },\n }\n}\n","/**\n * The hands of a driver: both on the rim of the steering wheel, turning with it; a hand carried too far round lets go, comes back to its own side and holds\n * again (one hand at a time, the other keeps the wheel); to change gear the hand on the lever's side leaves the rim, takes the knob, moves it and comes back.\n * Engine-agnostic: the host gives the wheel's turn and says when a gear changes; this says where each hand is, as angles on the rim and shares of the way to\n * the lever, and the host turns that into places in its world.\n */\n\nexport interface DrivingHandsRules {\n /** A hand carried this far round from its own place lets go to hold again, radians (a quarter turn and a little). */\n readonly regripAt: number\n /** The hand on the side the wheel turns to goes down the rim and lets go sooner, radians: it is the one that reaches back up for more wheel. */\n readonly firstAt: number\n /** While the wheel keeps turning, a hand takes the rim again this far before its own place, radians, so it has wheel to pull. */\n readonly lead: number\n /** Under this the wheel is held still, radians a second: a hand left off its own place goes back to it. */\n readonly stillRate: number\n /** A hand at rest this far from its own place goes back to it, radians. */\n readonly settleAt: number\n /** Past this a hand cannot stay on the rim whatever the other one does, radians. */\n readonly reachLimit: number\n /** Letting go, coming back and holding again, seconds. */\n readonly regripSeconds: number\n /** The hand from the rim to the knob, and back, seconds each way. */\n readonly leverReachSeconds: number\n /** The hand on the knob while the lever moves, seconds. */\n readonly leverHoldSeconds: number\n}\n\nexport const DRIVING_HANDS_DEFAULTS: DrivingHandsRules = { regripAt: 1.75, firstAt: 0.7, lead: 0.9, stillRate: 0.3, settleAt: 0.25, reachLimit: 2.3, regripSeconds: 0.24, leverReachSeconds: 0.22, leverHoldSeconds: 0.26 }\n\nexport interface DrivingHand {\n /** Where on the rim the hand is, radians from its own place at rest, the way the wheel turns (positive to the left). */\n readonly at: number\n /** 1 holding the rim, down to 0 off it (coming back to hold again, or gone to the lever). */\n readonly hold: number\n /** Share of the way from the rim to the gear lever's knob, 0 on the rim to 1 on the knob. */\n readonly toLever: number\n}\n\nexport interface DrivingHands {\n readonly left: DrivingHand\n readonly right: DrivingHand\n /** Share of the lever's throw done in the gear change going on, 0 before the hand moves it to 1 moved; 1 when no change is going on. */\n readonly leverThrow: number\n /** A gear change starts: `hand` the hand on the lever's side. Ignored while one is going on. */\n shift(hand: 'left' | 'right'): void\n /** `wheel`: the steering wheel's turn now, radians, positive to the left. */\n update(dt: number, wheel: number): void\n /** Both hands back on the rim at rest (the driver got in). */\n reset(wheel: number): void\n}\n\ntype Hand = { at: number; hold: number; toLever: number; regrip: number; from: number; to: number }\n\nconst smooth = (k: number): number => k * k * (3 - 2 * k)\n\nexport function createDrivingHands(rules: Partial<DrivingHandsRules> = {}): DrivingHands {\n const r = { ...DRIVING_HANDS_DEFAULTS, ...rules }\n const hands: Record<'left' | 'right', Hand> = { left: { at: 0, hold: 1, toLever: 0, regrip: -1, from: 0, to: 0 }, right: { at: 0, hold: 1, toLever: 0, regrip: -1, from: 0, to: 0 } }\n let last = 0\n let shifting: { hand: 'left' | 'right'; clock: number } | null = null\n const busy = (h: Hand): boolean => h.regrip >= 0 || h.toLever > 0\n const total = r.leverReachSeconds * 2 + r.leverHoldSeconds\n return {\n left: hands.left,\n right: hands.right,\n get leverThrow() {\n if (!shifting) return 1\n return smooth(Math.max(0, Math.min(1, (shifting.clock - r.leverReachSeconds) / r.leverHoldSeconds)))\n },\n shift(hand) {\n if (shifting) return\n shifting = { hand, clock: 0 }\n hands[hand].regrip = -1\n },\n reset(wheel) {\n last = wheel\n shifting = null\n for (const h of [hands.left, hands.right]) Object.assign(h, { at: 0, hold: 1, toLever: 0, regrip: -1, from: 0, to: 0 })\n },\n update(dt, wheel) {\n const turned = wheel - last\n last = wheel\n if (shifting) {\n shifting.clock += dt\n const h = hands[shifting.hand]\n const c = shifting.clock\n const out = smooth(Math.min(1, c / r.leverReachSeconds))\n const back = smooth(Math.max(0, Math.min(1, (c - r.leverReachSeconds - r.leverHoldSeconds) / r.leverReachSeconds)))\n h.toLever = out * (1 - back)\n h.hold = 1 - h.toLever\n // back on the rim at its own place, wherever the wheel went meanwhile\n h.at = 0\n if (c >= total) {\n h.toLever = 0\n h.hold = 1\n shifting = null\n }\n }\n for (const side of ['left', 'right'] as const) {\n const h = hands[side]\n const other = hands[side === 'left' ? 'right' : 'left']\n if (h.toLever > 0) continue\n if (h.regrip >= 0) {\n h.regrip += dt\n const k = Math.min(1, h.regrip / r.regripSeconds)\n h.at = h.from + (h.to - h.from) * smooth(k)\n h.hold = Math.abs(2 * k - 1)\n if (k >= 1) {\n h.regrip = -1\n h.at = h.to\n h.hold = 1\n }\n continue\n }\n h.at += turned\n const far = Math.abs(h.at)\n const rate = dt > 0 ? turned / dt : 0\n const turning = Math.abs(rate) > r.stillRate\n // turning to the left the left hand goes down the rim (to the right, the right one): that hand lets go first and reaches back for more wheel\n const goesDown = turning && (side === 'left') === rate > 0 && Math.sign(h.at) === Math.sign(rate)\n const wants = far > (goesDown ? r.firstAt : r.regripAt) || (!turning && far > r.settleAt)\n if ((wants && !busy(other)) || far > r.reachLimit) {\n h.regrip = 0\n h.from = h.at\n h.to = turning ? -Math.sign(rate) * r.lead : 0\n }\n }\n },\n }\n}\n","/**\n * The body works a control with one hand (CLAUDE.md §18, owner 2026-11-30: every action has a body animation): the free hand `reach`es the point, does the `act` of the gesture\n * (presses a button, turns a knob, flips a rocker, strikes a match, pours, lets go inside, tips over, closes on the thing to stow it, holds the paper up to read) and goes `back`.\n * The thing reacts at the act's moment (`GestureProgress.acted`), so the TV goes on when the finger is on the button. One gesture serves every control of its kind: a press is\n * the TV, the microwave and the radio alike. Pure and clock-free: the host advances it by its own frame's `dt`, says where the shoulder, the hand at rest and the point are,\n * and puts the hand where `gestureHandPose` says.\n */\nimport type { BodyGesture } from '@adatechnology/game-contracts'\n\nimport type { BodyHand } from './hands'\nimport { blendPoses, easeInOut, multiplyQuaternions, quaternionOfBasis } from './hand-math'\nimport type { Pose, QuatTuple, Vec3Tuple } from './hand-math'\n\nexport type GesturePhase = 'reach' | 'act' | 'back'\n\nexport interface GestureTiming {\n readonly reach: number\n readonly back: number\n /** Seconds the act of each gesture takes. */\n readonly act: Readonly<Record<BodyGesture, number>>\n}\n\nexport const GESTURE_TIMING: GestureTiming = {\n reach: 0.32,\n back: 0.3,\n act: { press: 0.22, turn: 0.4, flip: 0.2, strike: 0.35, pour: 0.7, put_in: 0.3, tip: 0.7, stow: 0.25, read: 1.2, pull: 0.45 },\n}\n\n/** The gestures whose thing reacts as the act begins (the words of a paper are read while it is held up); the others react once the act is done. */\nconst ACTS_AT_START: ReadonlySet<BodyGesture> = new Set<BodyGesture>(['read'])\n\n/** How far a hand reaches from its shoulder, metres: a point farther than that is touched at the end of the arm, never with the arm stretched past it. */\nexport const GESTURE_ARM_REACH = 0.62\n\nexport interface GestureProgress {\n readonly phase: GesturePhase\n /** How far into the phase, 0..1, eased. */\n readonly progress: number\n /** True on the advance during which the hand got to the act's moment: the host works the thing now. */\n readonly acted: boolean\n readonly done: boolean\n}\n\nexport interface GestureTimeline {\n readonly gesture: BodyGesture\n readonly duration: number\n /** Moves it on by `dt` seconds (the host's frame). */\n advance(dt: number): GestureProgress\n}\n\nexport function createGestureTimeline(gesture: BodyGesture, timing: GestureTiming = GESTURE_TIMING): GestureTimeline {\n const reach = timing.reach\n const act = timing.act[gesture]\n const duration = reach + act + timing.back\n const actsAt = ACTS_AT_START.has(gesture) ? reach : reach + act\n let time = 0\n let fired = false\n return {\n gesture,\n duration,\n advance(dt) {\n time = Math.min(duration, time + Math.max(0, dt))\n const acted = !fired && time >= actsAt\n if (acted) fired = true\n const phase: GesturePhase = time < reach ? 'reach' : time < reach + act ? 'act' : 'back'\n const start = phase === 'reach' ? 0 : phase === 'act' ? reach : reach + act\n const length = phase === 'reach' ? reach : phase === 'act' ? act : timing.back\n return { phase, progress: easeInOut((time - start) / Math.max(1e-6, length)), acted, done: time >= duration }\n },\n }\n}\n\n/** The gestures done with what the hand holds (the thing put in a bin, the jug poured into a bowl): the hand that carries it does them, never the free one. */\nconst WITH_THE_HELD_THING: ReadonlySet<BodyGesture> = new Set<BodyGesture>(['put_in', 'pour'])\n\n/** The free hand: the weapon hand only when it holds nothing, else the off hand; null when both hold something (a pistol in one, a torch in the other). */\nexport function freeHandOf(busy: { readonly R: boolean; readonly L: boolean }): BodyHand | null {\n if (!busy.R) return 'R'\n return busy.L ? null : 'L'\n}\n\nexport interface GestureHandChoice {\n /** Whether each hand holds something (a weapon, a carried thing). */\n readonly busy: { readonly R: boolean; readonly L: boolean }\n readonly gesture: BodyGesture\n /** The hand that carries the thing a `put_in` or a `pour` is done with, null when none does. */\n readonly carrying?: BodyHand | null\n}\n\n/** The hand that works a control: the one that carries the thing for a gesture done with it, the free one for the rest; null when no hand can (the hands are full). */\nexport function gestureHandOf(choice: GestureHandChoice): BodyHand | null {\n if (WITH_THE_HELD_THING.has(choice.gesture)) return choice.carrying ?? null\n return freeHandOf(choice.busy)\n}\n\nexport interface GestureHandParams {\n readonly gesture: BodyGesture\n readonly phase: GesturePhase\n readonly progress: number\n /** The hand that works (`gestureHandOf`): a left hand is turned the other way round, its thumb on the other side. */\n readonly hand: BodyHand\n /** The shoulder of the hand that works, world space. */\n readonly shoulder: Vec3Tuple\n /** Where the hand is when it does nothing of this (by the chest, or on the weapon's forend). */\n readonly rest: Pose\n /** The point the hand works, world space. */\n readonly at: Vec3Tuple\n /** The body's facing about the vertical (radians, 0 looks down -z): the way the hand goes when the point is right over the shoulder. */\n readonly yaw: number\n}\n\nexport interface GestureHand {\n readonly pose: Pose\n /** How closed the fingers are, 0 open to 1 closed. */\n readonly grip: number\n /** The index finger alone, 0 straight (a finger that presses) to 1 curled. */\n readonly index: number\n}\n\nconst add = (a: Vec3Tuple, b: Vec3Tuple, k = 1): [number, number, number] => [a[0] + b[0] * k, a[1] + b[1] * k, a[2] + b[2] * k]\nconst cross = (a: Vec3Tuple, b: Vec3Tuple): [number, number, number] => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]\nconst axisTurn = (axis: Vec3Tuple, angle: number): QuatTuple => {\n const s = Math.sin(angle / 2)\n return [axis[0] * s, axis[1] * s, axis[2] * s, Math.cos(angle / 2)]\n}\nconst UP: Vec3Tuple = [0, 1, 0]\n\ntype Frame = { readonly at: Vec3Tuple; readonly way: Vec3Tuple; readonly side: Vec3Tuple; readonly q: QuatTuple }\n\n/** Where the hand is and how it is turned `k` (0..1) into the act, from the point it works (`at`), the way to it (`way`), the side (`side`) and the hand's turn there (`q`). */\nconst actPose = (gesture: BodyGesture, frame: Frame, k: number): Pose => {\n const { at, way, side, q } = frame\n switch (gesture) {\n case 'press':\n // the finger goes in onto the button and comes off it\n return { position: add(at, way, -0.06 + 0.05 * Math.sin(Math.PI * k)), quaternion: q }\n case 'turn':\n // the hand round the knob turns a quarter about the way it came\n return { position: add(at, way, -0.02), quaternion: multiplyQuaternions(axisTurn(way, -k * Math.PI * 0.5), q) }\n case 'flip':\n // the fingers on the rocker push it down\n return { position: add(add(at, way, -0.02), UP, -0.03 * k), quaternion: q }\n case 'strike':\n // the match is struck across the side of the box, by the burner\n return { position: add(add(at, way, -0.04), side, 0.08 * (k - 0.5)), quaternion: q }\n case 'pour':\n // over the bowl, the hand tips what it holds forward\n return { position: add(at, UP, 0.15), quaternion: multiplyQuaternions(axisTurn(side, -k * Math.PI * 0.4), q) }\n case 'tip':\n // the hand on the rim turns the container over\n return { position: add(at, UP, 0.05 * k), quaternion: multiplyQuaternions(axisTurn(side, -k * Math.PI * 0.55), q) }\n case 'pull':\n // the fingers closed on the pull bring it toward the body\n return { position: add(at, way, -0.02 - 0.15 * k), quaternion: q }\n case 'put_in':\n case 'stow':\n return { position: [at[0], at[1], at[2]], quaternion: q }\n case 'read':\n // the paper held up, the palm toward the eyes\n return { position: [at[0], at[1], at[2]], quaternion: multiplyQuaternions(axisTurn(way, Math.PI * 0.5), q) }\n }\n}\n\n/** The fingers as the act begins and as it ends: a hand that lets go inside opens, one that stows closes on the thing. */\nconst GRIP: Readonly<Record<BodyGesture, readonly [number, number]>> = {\n press: [0.85, 0.85],\n turn: [0.9, 0.9],\n flip: [0.55, 0.55],\n strike: [0.95, 0.95],\n pour: [1, 1],\n tip: [1, 1],\n put_in: [1, 0.15],\n stow: [0.2, 0.95],\n read: [0.7, 0.7],\n pull: [0.9, 0.9],\n}\nconst OPEN_HAND = 0.2\n\n/** The frame of the act: the point (at the end of the arm when it is out of reach), the way to it on the ground, the side, and a hand turned to it with the thumb up. */\nfunction frameOf(params: GestureHandParams): Frame {\n const { shoulder } = params\n const flatX = params.at[0] - shoulder[0]\n const flatZ = params.at[2] - shoulder[2]\n const flat = Math.hypot(flatX, flatZ)\n const way: Vec3Tuple = flat < 1e-4 ? [-Math.sin(params.yaw), 0, -Math.cos(params.yaw)] : [flatX / flat, 0, flatZ / flat]\n // the thumb up on either hand: the little finger (+z) down for a right hand, up for a left one, whose thumb is at +z\n const little: Vec3Tuple = params.hand === 'R' ? [0, -1, 0] : [0, 1, 0]\n const side = cross(little, way)\n const toward: Vec3Tuple = [params.at[0] - shoulder[0], params.at[1] - shoulder[1], params.at[2] - shoulder[2]]\n const reach = Math.hypot(toward[0], toward[1], toward[2])\n const at = reach > GESTURE_ARM_REACH ? add(shoulder, toward, GESTURE_ARM_REACH / reach) : params.at\n return { at, way, side, q: quaternionOfBasis(way, side, little) }\n}\n\n/** The hand of a gesture now: its pose (world space, HandPose of game-contracts: +x to the knuckles, +z to the little finger) and its fingers. */\nexport function gestureHandPose(params: GestureHandParams): GestureHand {\n const { rest, phase, progress, gesture } = params\n const frame = frameOf(params)\n const [gripIn, gripOut] = GRIP[gesture]\n const index = gesture === 'press' ? 0 : gesture === 'flip' ? 0.2 : 1\n if (phase === 'reach') return { pose: blendPoses(rest, actPose(gesture, frame, 0), progress), grip: OPEN_HAND + (gripIn - OPEN_HAND) * progress, index: 1 + (index - 1) * progress }\n if (phase === 'act') return { pose: actPose(gesture, frame, progress), grip: gripIn + (gripOut - gripIn) * progress, index }\n // a thing stowed goes down to the bag at the hip, closed in the hand, not back to the chest\n const stowed = gesture === 'stow'\n const home: Pose = stowed ? { position: add(rest.position, UP, -0.3), quaternion: rest.quaternion } : rest\n const grip = stowed ? gripOut : gripOut + (OPEN_HAND - gripOut) * progress\n return { pose: blendPoses(actPose(gesture, frame, 1), home, progress), grip, index: index + (1 - index) * progress }\n}\n","/**\n * The body working a control (CLAUDE.md §18): one gesture at a time, by the hand the gesture calls for (`gestureHandOf`: the free one for a button, the one that holds the\n * thing to put in or pour), played over whatever the hands do already (the weapon's targets, a carried thing); the body steps up to the point, stoops for a low one, and the\n * thing is worked when the hand gets there. Any host with a body plays it (the test room, a game): it says where the shoulders, the hands at rest and the feet are, and puts\n * the hands where `targets` says. The timing and the pose are `createGestureTimeline` and `gestureHandPose`.\n */\nimport type { BodyGesture, HandPose, HandTargets, Vec3 } from '@adatechnology/game-contracts'\n\nimport { createGestureTimeline, gestureHandOf, gestureHandPose } from './gesture'\nimport type { GestureProgress, GestureTimeline } from './gesture'\nimport type { Pose } from './hand-math'\nimport type { BodyHand } from './hands'\n\nexport interface GestureBody {\n /** Where the body's middle stands, metres on the floor (x, z). */\n at(): readonly [number, number]\n /** Steps by (dx, dz) metres, stopped by what is in the way. */\n moveBy(dx: number, dz: number): void\n /** Turns the head and the body a share `k` (0..1) of the way toward the point. */\n face(point: Vec3, k: number): void\n /** Stoops while `on`: the hand reaches something lower than the arm reaches standing (a stove's knob). */\n stoop?(on: boolean): void\n /** The body is on its feet and can work a thing (false once it is knocked down or falls): a gesture going on stops without working the thing. */\n able?(): boolean\n}\n\nexport interface GestureHandDeps {\n /** The shoulder of a hand, world space; null for a body without one. */\n shoulder(hand: BodyHand): Vec3 | null\n /** Where a hand rests when the frame's targets have nothing for it (by the chest), world space. */\n restOf(hand: BodyHand): Pose\n /** Whether each hand holds something (a weapon, a carried thing). */\n holding(): { readonly R: boolean; readonly L: boolean }\n /** The hand that carries the thing a `put_in` puts in or a `pour` pours (not a weapon), or null when no hand carries one. */\n carrying?(): BodyHand | null\n /** The body's facing about the vertical, radians. */\n yaw(): number\n /** The body on the floor, for the steps up to a point out of the arm's reach; without it the hand goes from where the body stands. */\n readonly body?: GestureBody\n}\n\n/** How far from the point the body's middle stands to work it with a bent arm, metres on the floor; how fast it steps up, m/s; the longest walk, seconds. */\nconst STAND_OFF = 0.5\nconst STEP_SPEED = 2.5\nconst MAX_WALK_SECONDS = 1.5\nconst TURN_RATE = 8\n/** How far under the shoulder a point is before the body stoops to reach it, metres (an arm hanging down and a little forward reaches about this low). */\nconst STOOP_BELOW = 0.5\n\nexport interface GestureStart {\n readonly gesture: BodyGesture\n /** The point the hand works, world space, asked every frame (a thing that moves is followed). */\n at(): Vec3\n /** The hand got there: the thing is worked now. */\n onAct(): void\n}\n\n/** Why a gesture did not start: another one goes on, no hand can do it (both hold something, or none holds the thing to put in), or the body has no arm for it. */\nexport type GestureRefusal = 'busy' | 'hands_full' | 'no_body'\nexport type GestureStartResult = { readonly ok: true; readonly hand: BodyHand } | { readonly ok: false; readonly reason: GestureRefusal }\n\nexport interface GestureHands {\n /** A gesture is going on. */\n readonly busy: boolean\n /** The hand of the gesture going on. */\n readonly hand: BodyHand | null\n /** Starts a gesture; nothing is done when it is refused (the reason says why). */\n start(start: GestureStart): GestureStartResult\n step(dt: number): void\n /** The frame's targets with the working hand put on the gesture; the other hand keeps what it had. */\n targets(base: HandTargets | null): HandTargets | null\n /** Stops the gesture going on, without working the thing. */\n cancel(): void\n}\n\ntype Going = { readonly start: GestureStart; readonly hand: BodyHand; readonly timeline: GestureTimeline; progress: GestureProgress; walked: number; there: boolean }\n\n/** The body steps up to the point until the arm reaches it (true once there, in the way, or walked too long). */\nfunction stepUp(body: GestureBody | undefined, now: Going, dt: number): boolean {\n if (!body) return true\n const point = now.start.at()\n body.face(point, Math.min(1, dt * TURN_RATE))\n const [x, z] = body.at()\n const dx = point[0] - x\n const dz = point[2] - z\n const d = Math.hypot(dx, dz)\n if (d <= STAND_OFF + 0.03 || now.walked > MAX_WALK_SECONDS) return true\n const go = Math.min(d - STAND_OFF, STEP_SPEED * dt)\n if (go < 1e-4) return false\n body.moveBy((dx / d) * go, (dz / d) * go)\n const [x1, z1] = body.at()\n now.walked += dt\n // something in the way: the hand goes from here\n return Math.hypot(x1 - x, z1 - z) < go * 0.2\n}\n\nexport function createGestureHands(deps: GestureHandDeps): GestureHands {\n let going: Going | null = null\n const stop = (): void => {\n going = null\n deps.body?.stoop?.(false)\n }\n\n return {\n get busy() {\n return going !== null\n },\n get hand() {\n return going?.hand ?? null\n },\n start(start) {\n if (going) return { ok: false, reason: 'busy' }\n const hand = gestureHandOf({ busy: deps.holding(), gesture: start.gesture, carrying: deps.carrying?.() ?? null })\n if (!hand) return { ok: false, reason: 'hands_full' }\n const shoulder = deps.shoulder(hand)\n if (!shoulder || deps.body?.able?.() === false) return { ok: false, reason: 'no_body' }\n const timeline = createGestureTimeline(start.gesture)\n going = { start, hand, timeline, progress: timeline.advance(0), walked: 0, there: false }\n // a point under the reach of the arm hanging from the shoulder standing: the body stoops for it\n if (shoulder[1] - start.at()[1] > STOOP_BELOW) deps.body?.stoop?.(true)\n return { ok: true, hand }\n },\n step(dt) {\n if (!going) return\n const now = going\n // the body knocked down or fallen in the middle: the hand never gets there, nothing is worked\n if (deps.body?.able?.() === false) return stop()\n if (!now.there) {\n now.there = stepUp(deps.body, now, dt)\n if (!now.there) return\n }\n now.progress = now.timeline.advance(dt)\n if (now.progress.acted) now.start.onAct()\n if (now.progress.done && going === now) stop()\n },\n targets(base) {\n if (!going) return base\n const { hand, start, progress } = going\n const shoulder = deps.shoulder(hand)\n if (!shoulder) return base\n const rest = base?.[hand] ?? deps.restOf(hand)\n const worked = gestureHandPose({ gesture: start.gesture, hand, phase: progress.phase, progress: progress.progress, shoulder, rest, at: start.at(), yaw: deps.yaw() })\n const [x, y, z] = worked.pose.position\n const [qx, qy, qz, qw] = worked.pose.quaternion\n const pose: HandPose = { position: [x, y, z], quaternion: [qx, qy, qz, qw] }\n return hand === 'R'\n ? { ...(base ?? {}), R: pose, grip: worked.grip, fingers: { index: worked.index } }\n : { ...(base ?? {}), L: pose, gripL: worked.grip, fingersL: { index: worked.index }, slideL: null }\n },\n cancel: stop,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BO,IAAM,iBAAiB;AACvB,IAAM,+BAA+B;AAErC,IAAM,2BAA2B;AAMjC,IAAM,0BAA0B,CAAC,OAA2B,YAA+D;AAChI,QAAM,EAAE,cAAc,aAAa,IAAI,QAAQ;AAC/C,QAAM,KAAK,MAAM,gBAAgB;AAAA,IAC/B,UAAU,QAAQ;AAAA,IAClB,QAAQ;AAAA,IACR,YAAY,KAAK,IAAI,IAAI,eAAe,IAAI,gBAAgB,CAAC;AAAA,IAC7D,MAAM,QAAQ,QAAQ;AAAA,IACtB,UAAU,QAAQ,YAAY;AAAA,EAChC,CAAC;AACD,SAAO;AAAA,IACL;AAAA,IACA,MAAM,CAAC,WAAW,WAAW,OAAO,MAAM,cAAc,IAAI,WAAW,WAAW,EAAE;AAAA,IACpF,MAAM,CAAC,QAAQ,MAAM,cAAc,IAAI,KAAK,CAAC;AAAA,IAC7C,UAAU,CAAC,GAAG,GAAG,MAAM,MAAM,kBAAkB,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;AAAA,IAC5D,MAAM,CAAC,YAAY,MAAM,cAAc,IAAI,OAAO;AAAA,IAClD,WAAW,MAAM,MAAM,mBAAmB,EAAE;AAAA,IAC5C,SAAS,MAAM,MAAM,gBAAgB,EAAE;AAAA,EACzC;AACF;;;ACrDA,IAAM,QAAQ;AACd,IAAM,mBAAmB;AAMlB,IAAM,iBAAiB,CAAC,UAA4C,GAAW,GAAW,WAA2B;AAC1H,MAAI,OAAO,SAAS,GAAG,CAAC;AACxB,WAAS,OAAO,GAAG,QAAQ,OAAO,QAAQ;AACxC,UAAM,WAAY,SAAS,OAAQ;AACnC,UAAM,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,IAC/C;AAAA,IACA,QAAQ,MAAM;AACZ,UAAI,CAAC,MAAO,QAAO;AACnB,YAAM,EAAE,MAAM,OAAO,SAAS,IAAI;AAClC,YAAM,WAAW,KAAK,SAAS,IAAI;AACnC,UAAI,CAAC,SAAU,QAAO;AACtB,YAAM,OAAO,OAAO,IAAI,KAAK,KAAK,OAAO,IAAI;AAC7C,YAAM,SAAS,gBAAgB,EAAE,SAAS,MAAM,SAAS,MAAM,OAAO,SAAS,OAAO,UAAU,SAAS,UAAU,UAAU,MAAM,IAAI,MAAM,GAAG,GAAG,KAAK,KAAK,IAAI,EAAE,CAAC;AACpK,YAAM,CAAC,GAAG,GAAG,CAAC,IAAI,OAAO,KAAK;AAC9B,YAAM,CAAC,IAAI,IAAI,IAAI,EAAE,IAAI,OAAO,KAAK;AACrC,YAAM,OAAiB,EAAE,UAAU,CAAC,GAAG,GAAG,CAAC,GAAG,YAAY,CAAC,IAAI,IAAI,IAAI,EAAE,EAAE;AAC3E,aAAO,SAAS,MACZ,EAAE,GAAI,QAAQ,CAAC,GAAI,GAAG,MAAM,MAAM,OAAO,MAAM,SAAS,EAAE,OAAO,OAAO,MAAM,EAAE,IAChF,EAAE,GAAI,QAAQ,CAAC,GAAI,GAAG,MAAM,OAAO,OAAO,MAAM,UAAU,EAAE,OAAO,OAAO,MAAM,GAAG,QAAQ,KAAK;AAAA,IACtG;AAAA,IACA,QAAQ;AAAA,EACV;AACF;","names":["s","cross"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adatechnology/game-player",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "license": "MIT",
5
5
  "description": "Pure, seeded player body for games: vitals from an attribute sheet, stamina, wounds and bleeding, an optional individual infection, being grabbed and breaking free, knock-downs, low-wall vaults, footstep noise, panic, shove and melee against any crowd. A literal port of the team game's player. Knows nothing about any game.",
6
6
  "keywords": [
@@ -46,7 +46,7 @@
46
46
  "dist"
47
47
  ],
48
48
  "dependencies": {
49
- "@adatechnology/game-contracts": "^0.49.0",
49
+ "@adatechnology/game-contracts": "^0.50.0",
50
50
  "@adatechnology/game-physics": "^0.11.2"
51
51
  },
52
52
  "devDependencies": {