@adatechnology/game-interactables 0.6.10 → 0.7.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/README.md +10 -0
- package/dist/index.d.ts +126 -3
- package/dist/index.global.js +283 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +283 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fixture-emitters.ts","../src/colliders.ts","../src/rng.ts","../src/loot.ts","../src/locale.ts","../src/math.ts","../src/world.ts","../src/engine-chain.ts","../src/engine-soft.ts","../src/engine-leaf.ts","../src/engine-parts.ts"],"sourcesContent":["// The water a piece runs while its handle is worked, for a host that moves the parts itself (a test room plays the part's clip, a game its own animation) and has\n// no interactables world: from the piece's spec and how open each part is now, which of its water emitters run and how hard. A tap runs as far as its handle\n// is turned; a flush runs for its seconds once its button goes down, whatever the button does next. Pure: no three.js, object-local, no allocation per call once\n// warmed up but the answer list.\nimport type { EmitterSpec, FixtureSpec, ObjectSpec } from './types'\n\n/** Seconds a flush runs once its button goes down (the interactables world's own flush time). */\nexport const FLUSH_RUN_SECONDS = 2\n/** How open a handle has to be before the water starts, 0..1: a tap barely touched drips nothing. */\nconst START_OPENING = 0.05\n/** A flush button counts as pressed past this far down. */\nconst PRESSED = 0.5\n/** Seconds the end of a flush takes to die down. */\nconst FLUSH_FADE = 0.4\n\n/** One emitter running now, object-local, with its strength 0..1. */\nexport interface RunningEmitter {\n readonly emitter: EmitterSpec\n readonly intensity: number\n}\n\nexport interface FixtureEmitters {\n /** The water emitters of the piece that run now: `opening(part)` is how open that part is, 0 closed to 1 open. Advances the flushes by `dt` seconds. */\n update(dt: number, opening: (part: string) => number): RunningEmitter[]\n /** Whether the piece has any emitter a handle runs (a sink, a shower, a toilet): a host can skip the others. */\n readonly runs: boolean\n}\n\ninterface Driven {\n readonly emitter: EmitterSpec\n readonly fixture: FixtureSpec & { part: string }\n /** Flush only: seconds of run left, and whether the button was down the last time. */\n left: number\n down: boolean\n}\n\n/** The driver of one piece's water emitters by its handles. */\nexport function createFixtureEmitters(spec: Pick<ObjectSpec, 'emitters' | 'fixtures'>): FixtureEmitters {\n const fixtures = new Map((spec.fixtures ?? []).map((fixture) => [fixture.id, fixture]))\n const driven: Driven[] = []\n for (const emitter of spec.emitters ?? []) {\n if (emitter.kind !== 'water') continue\n const fixture = fixtures.get(emitter.source)\n if (!fixture?.part) continue\n driven.push({ emitter, fixture: { ...fixture, part: fixture.part }, left: 0, down: false })\n }\n return {\n runs: driven.length > 0,\n update(dt, opening) {\n const out: RunningEmitter[] = []\n for (const d of driven) {\n const open = Math.min(1, Math.max(0, opening(d.fixture.part)))\n if (d.fixture.kind === 'flush') {\n const down = open >= PRESSED\n if (down && !d.down) d.left = FLUSH_RUN_SECONDS\n d.down = down\n if (d.left <= 0) continue\n d.left = Math.max(0, d.left - dt)\n out.push({ emitter: d.emitter, intensity: Math.min(1, (d.left + 1e-6) / FLUSH_FADE) })\n continue\n }\n if (open > START_OPENING) out.push({ emitter: d.emitter, intensity: open })\n }\n return out\n },\n }\n}\n","import type { ColliderOptions, WorldCollider } from './types'\n\ninterface Box {\n ids: string[]\n object: string\n u0: number\n u1: number\n v0: number\n v1: number\n y0: number\n y1: number\n}\n\nconst volume = (b: Box): number => (b.u1 - b.u0) * (b.v1 - b.v0) * (b.y1 - b.y0)\nconst overlap = (a0: number, a1: number, b0: number, b1: number): number => Math.max(0, Math.min(a1, b1) - Math.max(a0, b0))\n\nfunction tryMerge(a: Box, b: Box, gap: number, slack: number): Box | null {\n if (a.u0 - gap > b.u1 || b.u0 - gap > a.u1) return null\n if (a.v0 - gap > b.v1 || b.v0 - gap > a.v1) return null\n if (a.y0 - gap > b.y1 || b.y0 - gap > a.y1) return null\n const u0 = Math.min(a.u0, b.u0)\n const u1 = Math.max(a.u1, b.u1)\n const v0 = Math.min(a.v0, b.v0)\n const v1 = Math.max(a.v1, b.v1)\n const y0 = Math.min(a.y0, b.y0)\n const y1 = Math.max(a.y1, b.y1)\n const hull = (u1 - u0) * (v1 - v0) * (y1 - y0)\n const common = overlap(a.u0, a.u1, b.u0, b.u1) * overlap(a.v0, a.v1, b.v0, b.v1) * overlap(a.y0, a.y1, b.y0, b.y1)\n const real = volume(a) + volume(b) - common\n if (hull > real * (1 + slack) + 1e-9) return null\n return { ids: [...a.ids, ...b.ids], object: a.object, u0, u1, v0, v1, y0, y1 }\n}\n\n/**\n * Union overlapping or adjacent colliders of the same object (same rotation) into fewer OBBs.\n * A merge happens only when the merged box adds at most `slack` extra volume over the real union, so coverage is never lost\n * and never grows noticeably. Colliders of different objects or rotations are left alone.\n */\nexport function mergeColliders(list: WorldCollider[], options: Pick<ColliderOptions, 'gap' | 'slack'> = {}): WorldCollider[] {\n const gap = options.gap ?? 0.02\n const slack = options.slack ?? 0.1\n const groups = new Map<string, WorldCollider[]>()\n for (const c of list) {\n const key = `${c.object}|${Math.round(c.ry * 1000)}`\n const g = groups.get(key)\n if (g) g.push(c)\n else groups.set(key, [c])\n }\n const out: WorldCollider[] = []\n for (const g of groups.values()) {\n const ry = g[0]?.ry ?? 0\n const cs = Math.cos(ry)\n const sn = Math.sin(ry)\n let boxes: Box[] = g.map((c) => {\n const u = c.cx * cs - c.cz * sn\n const v = c.cx * sn + c.cz * cs\n return { ids: [c.id], object: c.object, u0: u - c.hw, u1: u + c.hw, v0: v - c.hd, v1: v + c.hd, y0: c.y0, y1: c.y1 }\n })\n let changed = boxes.length > 1\n while (changed) {\n changed = false\n outer: for (let i = 0; i < boxes.length; i++) {\n for (let j = i + 1; j < boxes.length; j++) {\n const m = tryMerge(boxes[i] as Box, boxes[j] as Box, gap, slack)\n if (!m) continue\n boxes = boxes.filter((_, k) => k !== i && k !== j)\n boxes.push(m)\n changed = true\n break outer\n }\n }\n }\n for (const b of boxes) {\n const u = (b.u0 + b.u1) / 2\n const v = (b.v0 + b.v1) / 2\n out.push({\n id: b.ids.length === 1 ? (b.ids[0] as string) : `${b.ids[0]}+${b.ids.length - 1}`,\n object: b.object,\n cx: u * cs + v * sn,\n cz: -u * sn + v * cs,\n hw: (b.u1 - b.u0) / 2,\n hd: (b.v1 - b.v0) / 2,\n ry,\n y0: b.y0,\n y1: b.y1,\n })\n }\n }\n return out\n}\n","/** FNV-1a hash of a string to a 32-bit unsigned integer. */\nexport function hashString(text: string): number {\n let h = 2166136261\n for (let i = 0; i < text.length; i++) {\n h ^= text.charCodeAt(i)\n h = Math.imul(h, 16777619)\n }\n return h >>> 0\n}\n\n/** Deterministic random generator (mulberry32). Returns a function producing floats in [0, 1). Numbers and strings are accepted as seeds. */\nexport function rng(seed: number | string = 1): () => number {\n let a = (typeof seed === 'number' ? Math.floor(seed) >>> 0 : hashString(seed)) || 0x9e3779b9\n return () => {\n a = (a + 0x6d2b79f5) >>> 0\n let t = a\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n","import { rng } from './rng'\nimport type { ItemCatalog, ItemStack, LootTables, SlotSpec, Vec3 } from './types'\n\n/** True when an item of `size` [w, h, d] fits in a slot of `max`; width and depth may be swapped (the item is turned). */\nexport function fitsSize(size: Vec3, max: Vec3): boolean {\n const eps = 1e-9\n if (size[1] > max[1] + eps) return false\n return (size[0] <= max[0] + eps && size[2] <= max[2] + eps) || (size[2] <= max[0] + eps && size[0] <= max[2] + eps)\n}\n\n/** Does the item type fit the slot. Types missing from the catalog are accepted (the host owns unknown items). */\nexport function fitsSlot(type: string, slot: SlotSpec, items?: ItemCatalog): boolean {\n const def = items?.[type]\n return def ? fitsSize(def.size, slot.max) : true\n}\n\n/**\n * Deterministic contents for a container: one entry per slot. A slot is filled with probability `fill`; the entry is a weighted pick\n * among the table entries whose item fits the slot. Same seed, same table and same slots always give the same result.\n */\nexport function generateLoot(\n tables: LootTables | undefined,\n tableId: string,\n slots: SlotSpec[],\n seed: number | string,\n items?: ItemCatalog,\n): Array<ItemStack | null> {\n const table = tables?.[tableId]\n const out: Array<ItemStack | null> = slots.map(() => null)\n if (!table) return out\n const rand = rng(seed)\n slots.forEach((slot, i) => {\n // Always draw the same number of random values per slot so a change in one slot does not shift the others.\n const roll = rand()\n const pick = rand()\n const q = rand()\n if (roll >= table.fill) return\n const candidates = table.entries.filter((e) => e.weight > 0 && fitsSlot(e.type, slot, items))\n const total = candidates.reduce((s, e) => s + e.weight, 0)\n if (total <= 0) return\n let r = pick * total\n let chosen = candidates[candidates.length - 1]\n for (const e of candidates) {\n r -= e.weight\n if (r < 0) {\n chosen = e\n break\n }\n }\n const [lo, hi] = chosen.qty ?? [1, 1]\n const def = items?.[chosen.type]\n const stackMax = def ? (def.stack ?? 1) : Number.POSITIVE_INFINITY\n const qty = Math.max(1, Math.min(stackMax, lo + Math.floor(q * (hi - lo + 1))))\n out[i] = { type: chosen.type, qty }\n })\n return out\n}\n","import type { InteractablesLocale, Strings } from './types'\n\n/** Engine-level prompts and messages. Content packs add their own keys through `WorldOptions.strings`. */\nexport const locales: Record<InteractablesLocale, Strings> = {\n en: {\n 'prompt.open': 'Open {name}',\n 'prompt.close': 'Close {name}',\n 'prompt.turn_on': 'Turn on {name}',\n 'prompt.turn_off': 'Turn off {name}',\n 'prompt.take': 'Take',\n 'prompt.sit': 'Sit',\n 'prompt.lie_down': 'Lie down',\n 'prompt.get_up': 'Get up',\n 'prompt.light': 'Light',\n 'prompt.change_channel': 'Change channel',\n 'prompt.read': 'Read',\n 'prompt.breaker_on': 'Switch on {circuit}',\n 'prompt.breaker_off': 'Switch off {circuit}',\n 'prompt.open_valve': 'Open valve',\n 'prompt.close_valve': 'Close valve',\n no_power: 'No power',\n no_gas: 'No gas',\n no_water: 'No water',\n locked: 'Locked',\n requires_open: 'Open it first',\n already_lit: 'Already lit',\n needs_ignition: 'Light it first',\n turn_on_first: 'Turn it on first',\n empty: 'Empty',\n full: 'Full',\n },\n 'pt-BR': {\n 'prompt.open': 'Abrir {name}',\n 'prompt.close': 'Fechar {name}',\n 'prompt.turn_on': 'Ligar {name}',\n 'prompt.turn_off': 'Desligar {name}',\n 'prompt.take': 'Pegar',\n 'prompt.sit': 'Sentar',\n 'prompt.lie_down': 'Deitar',\n 'prompt.get_up': 'Levantar',\n 'prompt.light': 'Acender',\n 'prompt.change_channel': 'Trocar de canal',\n 'prompt.read': 'Ler',\n 'prompt.breaker_on': 'Ligar {circuit}',\n 'prompt.breaker_off': 'Desligar {circuit}',\n 'prompt.open_valve': 'Abrir registro',\n 'prompt.close_valve': 'Fechar registro',\n no_power: 'Sem energia',\n no_gas: 'Sem gás',\n no_water: 'Sem água',\n locked: 'Trancado',\n requires_open: 'Abra primeiro',\n already_lit: 'Já está aceso',\n needs_ignition: 'Acenda primeiro',\n turn_on_first: 'Ligue primeiro',\n empty: 'Vazio',\n full: 'Cheio',\n },\n}\n\n/** Pick a built-in locale for an arbitrary tag (`pt`, `pt-br`, `en-GB`...). Unknown tags give `en`. */\nexport function pickLocale(locale: string | undefined): InteractablesLocale {\n if (!locale) return 'en'\n const l = locale.toLowerCase()\n if (l === 'pt-br' || l === 'pt') return 'pt-BR'\n return 'en'\n}\n\n/**\n * Merged table for a locale: built-in `en`, then the built-in table of `locale`, then the extra strings for `en` and for `locale`.\n * Lookup therefore falls back to English, and the caller never gets undefined for engine keys.\n */\nexport function resolveStrings(locale?: string, extra?: Partial<Record<InteractablesLocale, Strings>>): Strings {\n const loc = pickLocale(locale)\n return { ...locales.en, ...locales[loc], ...(extra?.en ?? {}), ...(loc === 'en' ? {} : (extra?.[loc] ?? {})) }\n}\n\n/** Replace `{name}` placeholders. Unknown placeholders are left untouched. */\nexport function format(text: string, vars?: Record<string, string | number>): string {\n if (!vars) return text\n return text.replace(/\\{(\\w+)\\}/g, (m, k: string) => (k in vars ? String(vars[k]) : m))\n}\n","import type { Motion, Transform, Vec3 } from './types'\n\nexport interface Pose {\n /** Translation relative to the pivot. */\n position: Vec3\n /** Rotation around `axis` (in the part frame) by `angle` radians. */\n rotation: { axis: Vec3; angle: number }\n scale: Vec3\n}\n\nconst DEFAULT_AXIS: Vec3 = [0, 1, 0]\n\n/**\n * Pose of a part at animation value `t` (0..1), relative to its pivot, so any renderer can apply it:\n * `position`, then `rotation` around the pivot, then `scale` along the axis.\n */\nexport function poseOf(motion: Motion, t: number): Pose {\n const tt = Math.max(0, Math.min(1, t))\n const axis = motion.axis ?? DEFAULT_AXIS\n const pose: Pose = { position: [0, 0, 0], rotation: { axis: [axis[0], axis[1], axis[2]], angle: 0 }, scale: [1, 1, 1] }\n switch (motion.kind) {\n case 'hinge':\n case 'rocker':\n case 'knob':\n pose.rotation.angle = (motion.angle ?? Math.PI / 2) * tt\n break\n case 'slide': {\n const d = (motion.distance ?? 0.4) * tt\n pose.position = [axis[0] * d, axis[1] * d, axis[2] * d]\n break\n }\n case 'scale': {\n const k = 1 + ((motion.scale ?? 0.2) - 1) * tt\n pose.scale = [axis[0] !== 0 ? k : 1, axis[1] !== 0 ? k : 1, axis[2] !== 0 ? k : 1]\n break\n }\n }\n return pose\n}\n\n/** Rotate a vector around +y by `ry` radians (same convention as three.js `rotation.y`). */\nexport function rotY(v: Vec3, ry: number): Vec3 {\n const c = Math.cos(ry)\n const s = Math.sin(ry)\n return [c * v[0] + s * v[2], v[1], -s * v[0] + c * v[2]]\n}\n\n/** Object-local point to world space. */\nexport function localToWorld(transform: Transform, v: Vec3): Vec3 {\n const r = rotY(v, transform.ry)\n return [transform.x + r[0], transform.y + r[1], transform.z + r[2]]\n}\n\n/** World point to object-local space. */\nexport function worldToLocal(transform: Transform, v: Vec3): Vec3 {\n return rotY([v[0] - transform.x, v[1] - transform.y, v[2] - transform.z], -transform.ry)\n}\n\n/** Rodrigues rotation of `v` around a unit-length-normalised `axis` by `angle`. */\nexport function rotateAxis(v: Vec3, axis: Vec3, angle: number): Vec3 {\n const len = Math.hypot(axis[0], axis[1], axis[2]) || 1\n const k: Vec3 = [axis[0] / len, axis[1] / len, axis[2] / len]\n const c = Math.cos(angle)\n const s = Math.sin(angle)\n const dot = k[0] * v[0] + k[1] * v[1] + k[2] * v[2]\n const cross: Vec3 = [k[1] * v[2] - k[2] * v[1], k[2] * v[0] - k[0] * v[2], k[0] * v[1] - k[1] * v[0]]\n return [v[0] * c + cross[0] * s + k[0] * dot * (1 - c), v[1] * c + cross[1] * s + k[1] * dot * (1 - c), v[2] * c + cross[2] * s + k[2] * dot * (1 - c)]\n}\n\nexport function clamp(v: number, lo: number, hi: number): number {\n return v < lo ? lo : v > hi ? hi : v\n}\n\nexport function dist3(a: Vec3, b: Vec3): number {\n return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2])\n}\n","import { FLUSH_RUN_SECONDS } from './fixture-emitters'\nimport { mergeColliders } from './colliders'\nimport { fitsSlot, generateLoot } from './loot'\nimport { format, resolveStrings } from './locale'\nimport type { PartDriver, SoftDriver } from './part-physics'\nimport { clamp, dist3, localToWorld, rotateAxis, rotY, worldToLocal } from './math'\nimport type {\n ActiveEmitter,\n BurnerSpec,\n ColliderOptions,\n DeviceSpec,\n FixtureSpec,\n FuelSourceSpec,\n Interactable,\n InteractionSpec,\n ItemStack,\n ObjectSpec,\n PartSpec,\n SeatResult,\n SoftSpec,\n TankSpec,\n TargetOptions,\n Transform,\n Vec3,\n World,\n WorldCollider,\n WorldEvent,\n WorldObject,\n WorldOptions,\n WorldState,\n} from './types'\n\n// ---------------------------------------------------------------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------------------------------------------------------------\n\nconst DEFAULT_ACTOR = 'player'\nconst DEFAULT_RADIUS = 1.2\n/** Local id prefix of the `take` a stack in an open container offers (`<object>:take.<container>.<slot>`). */\nconst TAKE_PREFIX = 'take.'\n/** Reach radius of one contained item, metres. */\nconst TAKE_RADIUS = 0.6\nconst AUTO_RANGE = 2\n/** How far behind a socket's face (m) a plug may be and still take it: a plug on the wall's other side is a wall's thickness (10 cm or more) behind it. */\nconst SOCKET_BEHIND = 0.05\nconst SMOKE_TAIL = 20\nconst FLUSH_SECONDS = FLUSH_RUN_SECONDS\nconst ACTOR_HEIGHT = 1.7\nconst PUSH_GAIN = 1.2\nconst SWEEP_STEPS = 24\nconst FLOW_DEFAULTS: Record<string, number> = { tap: 6, shower: 8, utility_sink: 6, flush: 0, hose: 10, filter: 1 }\n\n// ---------------------------------------------------------------------------------------------------------------------------------\n// Internal state\n// ---------------------------------------------------------------------------------------------------------------------------------\n\ninterface PartState {\n spec: PartSpec\n t: number\n target: number\n maxT: number\n /** With `WorldOptions.partPhysics`: the engine moves the part, and `t` is read from it. */\n driver?: PartDriver\n /** The target the driver was last told (`aim`). */\n commanded?: number\n /** The driver is going to a target: arriving reports the part event. */\n moving?: boolean\n broken?: boolean\n}\n\ninterface DeviceState {\n spec: DeviceSpec\n on: boolean\n channel: number\n}\n\ninterface FuelState {\n spec: FuelSourceSpec\n level: number\n}\n\ninterface BurnerState {\n spec: BurnerSpec\n on: boolean\n lit: boolean\n /** Seconds of smoke left after a solid-fuel fire went out. */\n smoke: number\n}\n\ninterface TankState {\n spec: TankSpec\n level: number\n}\n\ninterface FixtureState {\n spec: FixtureSpec\n on: boolean\n flowing: boolean\n /** Delivered / wanted in the last step, 0..1. */\n frac: number\n /** Seconds left of a flush. */\n timer: number\n}\n\ninterface SoftState {\n spec: SoftSpec\n ax: number\n az: number\n vax: number\n vaz: number\n phase: number\n /** With `WorldOptions.partPhysics`: the engine swings the volume (the spring is not used). */\n driver?: SoftDriver\n}\n\ninterface DamageState {\n max: number\n hp: number\n}\n\ninterface ObjState {\n id: string\n public: WorldObject\n spec: ObjectSpec\n parts: Map<string, PartState>\n contents: Map<string, Array<ItemStack | null>>\n devices: Map<string, DeviceState>\n fuels: Map<string, FuelState>\n burners: Map<string, BurnerState>\n tanks: Map<string, TankState>\n fixtures: Map<string, FixtureState>\n soft: Map<string, SoftState>\n hp: Map<string, DamageState>\n interactions: InteractionSpec[]\n}\n\nfunction cloneStack(s: ItemStack | null): ItemStack | null {\n return s ? { type: s.type, qty: s.qty, ...(s.data ? { data: JSON.parse(JSON.stringify(s.data)) as Record<string, unknown> } : {}) } : null\n}\n\nfunction humanize(id: string): string {\n const s = id.replace(/[_-]+/g, ' ').trim()\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\n// ---------------------------------------------------------------------------------------------------------------------------------\n// World\n// ---------------------------------------------------------------------------------------------------------------------------------\n\nexport function createWorld(options: WorldOptions = {}): World {\n const seed = options.seed ?? 1\n const objs = new Map<string, ObjState>()\n const breakers = new Map<string, boolean>()\n const seats = new Map<string, { object: string; seat: string }>()\n const plugs = new Map<string, string | null>()\n let locale = options.locale ?? 'en'\n let table = resolveStrings(locale, options.strings)\n let grid = options.grid ?? true\n let rain = options.rain ?? 0\n let wind: [number, number] = options.wind ? [options.wind[0], options.wind[1]] : [0, 0]\n let defaultTank: string | null = null\n let defaultTankExplicit = false\n let time = 0\n\n // ------------------------------------------------------------------ text & events\n function t(key: string, vars?: Record<string, string | number>): string {\n return format(table[key] ?? key, vars)\n }\n\n function emit(e: WorldEvent): void {\n options.onEvent?.(e)\n }\n\n function message(key: string): void {\n emit({ type: 'message', key, text: t(key) })\n }\n\n // ------------------------------------------------------------------ lookup helpers\n function gid(o: ObjState, local: string): string {\n return `${o.id}:${local}`\n }\n\n /** Find the first entity matching a world-wide id `objectId:localId`. */\n function findGlobal<T>(id: string, pick: (o: ObjState, local: string) => T | undefined): { o: ObjState; value: T; local: string } | null {\n for (const o of objs.values()) {\n if (!id.startsWith(o.id + ':')) continue\n const local = id.slice(o.id.length + 1)\n const value = pick(o, local)\n if (value !== undefined) return { o, value, local }\n }\n return null\n }\n\n function objectOrThrow(id: string): ObjState {\n const o = objs.get(id)\n if (!o) throw new Error(`Unknown object \"${id}\"`)\n return o\n }\n\n function originOf(o: ObjState): Vec3 {\n const tr = o.public.transform\n return [tr.x, tr.y, tr.z]\n }\n\n function toWorld(o: ObjState, v: Vec3): Vec3 {\n return localToWorld(o.public.transform, v)\n }\n\n // ------------------------------------------------------------------ parts\n function openThreshold(p: PartState): number {\n return Math.min(0.5, p.maxT * 0.9)\n }\n\n function isOpen(o: ObjState, partId: string | undefined): boolean {\n if (!partId) return true\n const p = o.parts.get(partId)\n if (!p) return true\n return p.maxT >= 0.1 && p.t >= openThreshold(p)\n }\n\n function targetIsOpen(p: PartState): boolean {\n return p.maxT >= 0.1 && p.target >= openThreshold(p)\n }\n\n function writeT(o: ObjState, p: PartState, v: number): void {\n p.t = v\n o.public.parts[p.spec.id] = v\n }\n\n function gated(o: ObjState, p: PartState): boolean {\n return !!p.spec.requires && o.parts.has(p.spec.requires) && !isOpen(o, p.spec.requires)\n }\n\n function setOnePart(o: ObjState, p: PartState, target: number, instant: boolean): void {\n const next = clamp(target, 0, p.maxT)\n const changed = next !== p.target\n p.target = next\n if (instant) {\n p.driver?.snap(next)\n p.commanded = next\n writeT(o, p, next)\n }\n if (changed || instant) emit({ type: 'part', object: o.id, part: p.spec.id, t: p.t, target: p.target })\n }\n\n function setPartTarget(o: ObjState, partId: string, target: number, instant = false): void {\n const p = o.parts.get(partId)\n if (!p) return\n const group = p.spec.group\n const members = group ? [...o.parts.values()].filter((q) => q.spec.group === group) : [p]\n for (const q of members) {\n setOne(o, q, target, instant)\n }\n }\n\n function setOne(o: ObjState, p: PartState, target: number, instant: boolean): void {\n setOnePart(o, p, target, instant)\n // a part that other parts require closes them with it (the drawer behind a door closes with the door)\n if (!targetIsOpen(p)) {\n for (const q of o.parts.values()) {\n if (q.spec.requires === p.spec.id && q.target > 0) setPartTarget(o, q.spec.id, 0, instant)\n }\n }\n }\n\n /** Frame of a part right now: rotation (axis in object-local, angle) and translation, both about its pivot. */\n function partFrame(o: ObjState, partId: string | undefined): { pivot: Vec3; axis: Vec3; angle: number; offset: Vec3 } | null {\n if (!partId) return null\n const p = o.parts.get(partId)\n if (!p) return null\n const m = p.spec.motion\n const axis = rotY(m.axis ?? [0, 1, 0], p.spec.ry ?? 0)\n const frame = { pivot: p.spec.pivot, axis, angle: 0, offset: [0, 0, 0] as Vec3 }\n if (m.kind === 'slide') {\n const d = (m.distance ?? 0.4) * p.t\n frame.offset = [axis[0] * d, axis[1] * d, axis[2] * d]\n } else if (m.kind !== 'scale') {\n frame.angle = (m.angle ?? Math.PI / 2) * p.t\n }\n return frame\n }\n\n function applyPart(o: ObjState, partId: string | undefined, local: Vec3): Vec3 {\n const f = partFrame(o, partId)\n if (!f) return local\n const rel: Vec3 = [local[0] - f.pivot[0], local[1] - f.pivot[1], local[2] - f.pivot[2]]\n const r = f.angle !== 0 ? rotateAxis(rel, f.axis, f.angle) : rel\n return [f.pivot[0] + r[0] + f.offset[0], f.pivot[1] + r[1] + f.offset[1], f.pivot[2] + r[2] + f.offset[2]]\n }\n\n /** Moves the full closed-pose slab of a part and returns the largest t whose pose keeps every sampled point clear. */\n function fitBounds(o: ObjState, p: PartState, b: NonNullable<PartSpec['bounds']>, blockedAt: (x: number, z: number) => boolean): number {\n const STEP = 0.05\n const ANGLES = 48\n const m = p.spec.motion\n const axis = rotY(m.axis ?? [0, 1, 0], p.spec.ry ?? 0)\n const lo: Vec3 = [Math.min(b[0], b[3]), Math.min(b[1], b[4]), Math.min(b[2], b[5])]\n const hi: Vec3 = [Math.max(b[0], b[3]), Math.max(b[1], b[4]), Math.max(b[2], b[5])]\n const axisPoints = (i: number): number[] => {\n const n = Math.max(1, Math.ceil((hi[i] - lo[i]) / STEP))\n return Array.from({ length: n + 1 }, (_, k) => lo[i] + ((hi[i] - lo[i]) * k) / n)\n }\n const xs = axisPoints(0)\n const ys = axisPoints(1)\n const zs = axisPoints(2)\n // `blocked` only sees x/z, so only the floor footprint matters. About a vertical axis (and for slides) y never changes\n // the footprint, so the x/z outline is enough; otherwise the footprint boundary is the projection of the box edges.\n const flat = m.kind === 'slide' || Math.abs(axis[1]) > 0.999\n const seen = new Set<string>()\n const pts: Vec3[] = []\n const add = (x: number, y: number, z: number): void => {\n const key = `${x.toFixed(5)},${y.toFixed(5)},${z.toFixed(5)}`\n if (seen.has(key)) return\n seen.add(key)\n pts.push([x, y, z])\n }\n if (flat) {\n for (const x of xs) for (const z of [lo[2], hi[2]]) add(x, lo[1], z)\n for (const z of zs) for (const x of [lo[0], hi[0]]) add(x, lo[1], z)\n } else {\n for (const x of xs) for (const y of [lo[1], hi[1]]) for (const z of [lo[2], hi[2]]) add(x, y, z)\n for (const y of ys) for (const x of [lo[0], hi[0]]) for (const z of [lo[2], hi[2]]) add(x, y, z)\n for (const z of zs) for (const x of [lo[0], hi[0]]) for (const y of [lo[1], hi[1]]) add(x, y, z)\n }\n const tr = o.public.transform\n const pivot = p.spec.pivot\n for (let i = 1; i <= ANGLES; i++) {\n const tt = i / ANGLES\n const angle = m.kind === 'slide' ? 0 : (m.angle ?? Math.PI / 2) * tt\n const d = m.kind === 'slide' ? (m.distance ?? 0.4) * tt : 0\n for (const [x, y, z] of pts) {\n let q: Vec3 = [x, y, z]\n if (angle !== 0) {\n const r = rotateAxis([x - pivot[0], y - pivot[1], z - pivot[2]], axis, angle)\n q = [pivot[0] + r[0], pivot[1] + r[1], pivot[2] + r[2]]\n }\n const w = localToWorld(tr, [q[0] + axis[0] * d, 0, q[2] + axis[2] * d])\n if (blockedAt(w[0], w[2])) return (i - 1) / ANGLES\n }\n }\n return 1\n }\n\n function fitSweep(objectId: string, partId: string, blocked: (x: number, z: number) => boolean): number {\n const o = objectOrThrow(objectId)\n const p = o.parts.get(partId)\n if (!p) throw new Error(`Unknown part \"${partId}\" on \"${objectId}\"`)\n const sweep = p.spec.sweep\n let result = 1\n const bounds = p.spec.bounds\n const mk = p.spec.motion.kind\n if (bounds && (mk === 'hinge' || mk === 'rocker' || mk === 'knob' || mk === 'slide')) {\n result = fitBounds(o, p, bounds, blocked)\n } else if (sweep) {\n const x0 = Math.min(sweep[0], sweep[2])\n const x1 = Math.max(sweep[0], sweep[2])\n const z0 = Math.min(sweep[1], sweep[3])\n const z1 = Math.max(sweep[1], sweep[3])\n const tr = o.public.transform\n const hit = (lx: number, lz: number): boolean => {\n const w = localToWorld(tr, [lx, 0, lz])\n return blocked(w[0], w[2])\n }\n const m = p.spec.motion\n const axis = rotY(m.axis ?? [0, 1, 0], p.spec.ry ?? 0)\n if (m.kind === 'hinge' || m.kind === 'rocker' || m.kind === 'knob') {\n if (Math.abs(axis[1]) >= 0.5) {\n const angle = m.angle ?? Math.PI / 2\n const total = -angle * Math.sign(axis[1])\n const [px, , pz] = p.spec.pivot\n const cx = (x0 + x1) / 2\n const cz = (z0 + z1) / 2\n const w = x1 - x0\n const d = z1 - z0\n const radius = Math.abs(angle) > 1.7 ? Math.min(w, d) : Math.max(w, d)\n const tol = 0.05\n const inRect = (x: number, z: number) => x >= x0 - tol && x <= x1 + tol && z >= z0 - tol && z <= z1 + tol\n const centered = Math.hypot(cx - px, cz - pz) < 1e-6\n const mid = Math.atan2(cz - pz, cx - px)\n for (let i = 1; i <= SWEEP_STEPS && result === 1; i++) {\n const tt = i / SWEEP_STEPS\n let isHit = false\n if (centered) {\n for (let x = x0; x <= x1 + 1e-9 && !isHit; x += 0.1) for (let z = z0; z <= z1 + 1e-9 && !isHit; z += 0.1) isHit = hit(x, z)\n } else {\n const phi = mid - total / 2 + total * tt\n const steps = Math.max(2, Math.ceil(radius / 0.1))\n for (let k = 1; k <= steps && !isHit; k++) {\n const r = (radius * k) / steps\n const x = px + Math.cos(phi) * r\n const z = pz + Math.sin(phi) * r\n if (inRect(x, z)) isHit = hit(x, z)\n }\n }\n if (isHit) result = (i - 1) / SWEEP_STEPS\n }\n }\n } else if (m.kind === 'slide') {\n const len = Math.hypot(axis[0], axis[2])\n if (len > 1e-6) {\n const dx = axis[0] / len\n const dz = axis[2] / len\n const proj = [x0 * dx + z0 * dz, x1 * dx + z0 * dz, x0 * dx + z1 * dz, x1 * dx + z1 * dz]\n const pmin = Math.min(...proj)\n const pmax = Math.max(...proj)\n const nx = Math.max(1, Math.ceil((x1 - x0) / 0.1))\n const nz = Math.max(1, Math.ceil((z1 - z0) / 0.1))\n for (let i = 1; i <= SWEEP_STEPS && result === 1; i++) {\n const limit = pmin + (pmax - pmin) * (i / SWEEP_STEPS)\n let isHit = false\n for (let a = 0; a <= nx && !isHit; a++) {\n for (let b = 0; b <= nz && !isHit; b++) {\n const x = x0 + ((x1 - x0) * a) / nx\n const z = z0 + ((z1 - z0) * b) / nz\n if (x * dx + z * dz <= limit + 1e-9 && hit(x, z)) isHit = true\n }\n }\n if (isHit) result = (i - 1) / SWEEP_STEPS\n }\n }\n }\n }\n p.maxT = result\n if (p.target > result) p.target = result\n if (p.t > result) writeT(o, p, result)\n return result\n }\n\n // ------------------------------------------------------------------ containers\n function containerOf(o: ObjState, id: string) {\n return o.spec.containers?.find((c) => c.id === id)\n }\n\n function accessible(objectId: string, containerId: string): boolean {\n const o = objs.get(objectId)\n if (!o) return false\n const c = containerOf(o, containerId)\n if (!c) return false\n return isOpen(o, c.access)\n }\n\n function contents(objectId: string, containerId: string): Array<ItemStack | null> {\n return (objs.get(objectId)?.contents.get(containerId) ?? []).map(cloneStack)\n }\n\n function take(objectId: string, containerId: string, slot: number, actor: string = DEFAULT_ACTOR): ItemStack | null {\n const o = objs.get(objectId)\n if (!o) return null\n const list = o.contents.get(containerId)\n if (!list || !accessible(objectId, containerId)) return null\n const stack = list[slot]\n if (!stack) return null\n const def = options.items?.[stack.type]\n if (def && def.pickable === false) return null\n list[slot] = null\n emit({ type: 'pickup', object: objectId, container: containerId, slot, stack: cloneStack(stack) as ItemStack, actor })\n return stack\n }\n\n function put(objectId: string, containerId: string, stack: ItemStack): number | null {\n const o = objs.get(objectId)\n if (!o) return null\n const c = containerOf(o, containerId)\n const list = o.contents.get(containerId)\n if (!c || !list || !accessible(objectId, containerId)) return null\n const maxStack = options.items?.[stack.type]?.stack ?? 1\n for (let i = 0; i < list.length; i++) {\n const cur = list[i]\n if (cur && cur.type === stack.type && !cur.data && !stack.data && cur.qty + stack.qty <= maxStack) {\n cur.qty += stack.qty\n return i\n }\n }\n for (let i = 0; i < list.length; i++) {\n if (!list[i] && fitsSlot(stack.type, c.slots[i], options.items)) {\n list[i] = cloneStack(stack)\n return i\n }\n }\n message('full')\n return null\n }\n\n function slotPosition(objectId: string, containerId: string, slot: number): Vec3 {\n const o = objectOrThrow(objectId)\n const c = containerOf(o, containerId)\n const s = c?.slots[slot]\n if (!c || !s) throw new Error(`Unknown slot ${slot} of \"${containerId}\" on \"${objectId}\"`)\n return toWorld(o, applyPart(o, s.part, s.pos))\n }\n\n // ------------------------------------------------------------------ power\n function rebuildPlugs(): void {\n plugs.clear()\n const sockets: Array<{ id: string; pos: Vec3; circuit?: string; local: string; facing: Vec3 }> = []\n for (const o of objs.values()) {\n for (const s of o.spec.sockets ?? []) {\n const pos = toWorld(o, s.pos)\n const ahead = toWorld(o, [s.pos[0], s.pos[1], s.pos[2] + 1])\n sockets.push({ id: gid(o, s.id), local: s.id, pos, circuit: s.circuit, facing: [ahead[0] - pos[0], ahead[1] - pos[1], ahead[2] - pos[2]] })\n }\n }\n const used = new Set<string>()\n const autos: Array<{ o: ObjState; d: DeviceState }> = []\n for (const o of objs.values()) {\n for (const d of o.devices.values()) {\n const key = gid(o, d.spec.id)\n const want = d.spec.socket\n if (want === undefined || d.spec.circuit) {\n plugs.set(key, null)\n } else if (want === 'auto') {\n plugs.set(key, null)\n autos.push({ o, d })\n } else {\n const s = sockets.find((x) => x.id === want) ?? sockets.find((x) => x.id === gid(o, want)) ?? sockets.find((x) => x.local === want)\n plugs.set(key, s ? s.id : null)\n if (s) used.add(s.id)\n }\n }\n }\n for (const { o, d } of autos) {\n const from = d.spec.plug ? toWorld(o, d.spec.plug) : originOf(o)\n let best: (typeof sockets)[number] | null = null\n let bestD = AUTO_RANGE\n for (const s of sockets) {\n if (used.has(s.id)) continue\n // a socket faces out of its wall (+z): a plug behind its face is on the wall's other side, in the next room, and its cord would cross the wall\n if ((from[0] - s.pos[0]) * s.facing[0] + (from[1] - s.pos[1]) * s.facing[1] + (from[2] - s.pos[2]) * s.facing[2] < -SOCKET_BEHIND) continue\n const dd = dist3(from, s.pos)\n if (dd <= bestD) {\n best = s\n bestD = dd\n }\n }\n if (best) {\n used.add(best.id)\n plugs.set(gid(o, d.spec.id), best.id)\n }\n }\n }\n\n function breaker(circuit: string): boolean {\n return breakers.get(circuit) ?? true\n }\n\n function devicePowered(o: ObjState, d: DeviceState): boolean {\n if (d.spec.electric === false) return true\n if (!grid) return false\n if (d.spec.circuit) return breaker(d.spec.circuit)\n if (d.spec.socket === undefined) return false\n const sid = plugs.get(gid(o, d.spec.id))\n if (!sid) return false\n const found = findGlobal(sid, (oo, local) => oo.spec.sockets?.find((s) => s.id === local))\n if (!found) return false\n return found.value.circuit ? breaker(found.value.circuit) : true\n }\n\n function getDevice(objectId: string, deviceId: string): { o: ObjState; d: DeviceState } | null {\n const o = objs.get(objectId)\n const d = o?.devices.get(deviceId)\n return o && d ? { o, d } : null\n }\n\n function powerSnapshot(): Map<string, boolean> {\n const m = new Map<string, boolean>()\n for (const o of objs.values()) for (const d of o.devices.values()) m.set(gid(o, d.spec.id), d.on && devicePowered(o, d))\n return m\n }\n\n function emitPowerChanges(before: Map<string, boolean>): void {\n for (const o of objs.values()) {\n for (const d of o.devices.values()) {\n const key = gid(o, d.spec.id)\n const now = d.on && devicePowered(o, d)\n if (before.get(key) !== now && d.on) emit({ type: 'device', object: o.id, device: d.spec.id, on: d.on, powered: devicePowered(o, d), channel: d.spec.kind === 'screen' ? d.channel : undefined })\n }\n }\n }\n\n function setDeviceOn(o: ObjState, d: DeviceState, on: boolean): void {\n d.on = on\n if (d.spec.part) setPartTarget(o, d.spec.part, on ? 1 : 0)\n const powered = devicePowered(o, d)\n emit({ type: 'device', object: o.id, device: d.spec.id, on, powered, channel: d.spec.kind === 'screen' ? d.channel : undefined })\n if (on && !powered) message('no_power')\n }\n\n function setDevice(objectId: string, deviceId: string, on: boolean): boolean {\n const f = getDevice(objectId, deviceId)\n if (!f) return false\n if (f.d.on !== on) setDeviceOn(f.o, f.d, on)\n return true\n }\n\n function setFixture(objectId: string, fixtureId: string, on: boolean): boolean {\n const fx = objs.get(objectId)?.fixtures.get(fixtureId)\n if (!fx) return false\n if (fx.on !== on) toggleFixture(objs.get(objectId) as ObjState, fixtureId)\n return fx.on === on\n }\n\n function setBurner(objectId: string, burnerId: string, on: boolean): boolean {\n const o = objs.get(objectId)\n const b = o?.burners.get(burnerId)\n if (!o || !b) return false\n const isOn = b.on || b.lit\n if (on === isOn) return true\n if (!on) return toggleBurner(o, burnerId)\n return b.spec.needsIgnition ? ignite(o, burnerId) : toggleBurner(o, burnerId)\n }\n\n function resolveDevice(o: ObjState, id: string): { o: ObjState; d: DeviceState } | null {\n if (id.includes(':')) {\n const f = findGlobal(id, (oo, local) => oo.devices.get(local))\n return f ? { o: f.o, d: f.value } : null\n }\n const local = o.devices.get(id)\n if (local) return { o, d: local }\n for (const oo of objs.values()) {\n const d = oo.devices.get(id)\n if (d) return { o: oo, d }\n }\n return null\n }\n\n function switchIsOn(o: ObjState, spec: { part?: string; controls: string[] }): boolean {\n if (spec.part && o.parts.has(spec.part)) return targetIsOpen(o.parts.get(spec.part) as PartState)\n return spec.controls.some((id) => resolveDevice(o, id)?.d.on)\n }\n\n function toggleSwitch(o: ObjState, id: string): boolean {\n const sw = o.spec.switches?.find((s) => s.id === id)\n if (!sw) return false\n const on = !switchIsOn(o, sw)\n if (sw.part) setPartTarget(o, sw.part, on ? 1 : 0)\n let unpowered = false\n for (const ref of sw.controls) {\n const r = resolveDevice(o, ref)\n if (!r) continue\n r.d.on = on\n if (r.d.spec.part) setPartTarget(r.o, r.d.spec.part, on ? 1 : 0)\n const powered = devicePowered(r.o, r.d)\n if (on && !powered) unpowered = true\n emit({ type: 'device', object: r.o.id, device: r.d.spec.id, on, powered })\n }\n emit({ type: 'switch', object: o.id, switch: sw.id, on })\n if (unpowered) message('no_power')\n return true\n }\n\n // ------------------------------------------------------------------ fuel\n function resolveFuel(o: ObjState, b: BurnerState): { o: ObjState; f: FuelState } | null {\n const want = b.spec.fuel\n if (want === 'auto') {\n const from = toWorld(o, b.spec.pos)\n let best: { o: ObjState; f: FuelState } | null = null\n let bestD = AUTO_RANGE\n for (const oo of objs.values()) {\n for (const f of oo.fuels.values()) {\n if (f.spec.kind !== 'gas') continue\n const d = dist3(from, originOf(oo))\n if (d <= bestD) {\n best = { o: oo, f }\n bestD = d\n }\n }\n }\n return best\n }\n if (want.includes(':')) {\n const f = findGlobal(want, (oo, local) => oo.fuels.get(local))\n return f ? { o: f.o, f: f.value } : null\n }\n const local = o.fuels.get(want)\n return local ? { o, f: local } : null\n }\n\n function valveOpen(o: ObjState, f: FuelState): boolean {\n const v = f.spec.valve\n if (!v || !o.parts.has(v)) return true\n return targetIsOpen(o.parts.get(v) as PartState)\n }\n\n function canBurn(b: BurnerState, ref: { o: ObjState; f: FuelState } | null): boolean {\n return !!ref && ref.f.level > 0 && valveOpen(ref.o, ref.f)\n }\n\n function isSolid(ref: { f: FuelState } | null): boolean {\n return !!ref && ref.f.spec.kind !== 'gas'\n }\n\n function emitBurner(o: ObjState, b: BurnerState): void {\n emit({ type: 'burner', object: o.id, burner: b.spec.id, on: b.on, lit: b.lit })\n }\n\n function extinguish(o: ObjState, b: BurnerState, turnOff: boolean): void {\n const ref = resolveFuel(o, b)\n const wasLit = b.lit\n b.lit = false\n if (turnOff) b.on = false\n if (b.spec.part) setPartTarget(o, b.spec.part, b.on ? 1 : 0)\n if (wasLit && isSolid(ref)) b.smoke = SMOKE_TAIL\n emitBurner(o, b)\n }\n\n function toggleBurner(o: ObjState, id: string): boolean {\n const b = o.burners.get(id)\n if (!b) return false\n if (b.on || b.lit) {\n extinguish(o, b, true)\n return true\n }\n if (b.spec.needsIgnition) return false\n const ref = resolveFuel(o, b)\n b.on = true\n b.lit = canBurn(b, ref)\n if (b.lit) b.smoke = 0\n if (b.spec.part) setPartTarget(o, b.spec.part, 1)\n emitBurner(o, b)\n if (!b.lit) message(ref && ref.f.level <= 0 ? 'empty' : 'no_gas')\n return true\n }\n\n function ignite(o: ObjState, id: string): boolean {\n const b = o.burners.get(id)\n if (!b || b.lit) return false\n const ref = resolveFuel(o, b)\n if (!canBurn(b, ref)) {\n message(ref && ref.f.level <= 0 ? 'empty' : 'no_gas')\n return false\n }\n b.on = true\n b.lit = true\n b.smoke = 0\n if (b.spec.part) setPartTarget(o, b.spec.part, 1)\n emitBurner(o, b)\n return true\n }\n\n function toggleFuel(o: ObjState, id: string): boolean {\n const f = o.fuels.get(id)\n if (!f || !f.spec.valve || !o.parts.has(f.spec.valve)) return false\n const p = o.parts.get(f.spec.valve) as PartState\n setPartTarget(o, f.spec.valve, targetIsOpen(p) ? 0 : 1)\n return true\n }\n\n // ------------------------------------------------------------------ water\n function resolveTank(o: ObjState, id: string | undefined): { o: ObjState; t: TankState } | null {\n const want = id === undefined || id === 'auto' ? defaultTank : id\n if (!want) return null\n const f = findGlobal(want, (oo, local) => oo.tanks.get(local))\n if (f) return { o: f.o, t: f.value }\n const local = o.tanks.get(want)\n return local ? { o, t: local } : null\n }\n\n function drawWater(o: ObjState, fx: FixtureState, liters: number): number {\n if (liters <= 0) return 0\n if (options.waterSupply) return Math.max(0, Math.min(liters, options.waterSupply.draw(gid(o, fx.spec.id), liters)))\n const tank = resolveTank(o, fx.spec.tank)\n if (!tank) return 0\n const got = Math.min(liters, tank.t.level)\n tank.t.level -= got\n return got\n }\n\n function emitFixture(o: ObjState, fx: FixtureState): void {\n emit({ type: 'fixture', object: o.id, fixture: fx.spec.id, on: fx.on, flowing: fx.flowing })\n }\n\n function flowOf(fx: FixtureState): number {\n return fx.spec.flow ?? FLOW_DEFAULTS[fx.spec.kind] ?? 6\n }\n\n function stepFixture(o: ObjState, fx: FixtureState, dt: number): void {\n if (!fx.on) return\n if (fx.spec.kind === 'flush') {\n fx.timer -= dt\n if (fx.timer <= 0) {\n fx.on = false\n fx.flowing = false\n fx.frac = 0\n if (fx.spec.part) setPartTarget(o, fx.spec.part, 0)\n emitFixture(o, fx)\n }\n return\n }\n if (dt <= 0) return\n const wanted = (flowOf(fx) / 60) * dt\n const got = drawWater(o, fx, wanted)\n const flowing = got > 1e-9\n fx.frac = wanted > 0 ? Math.min(1, got / wanted) : 0\n if (flowing !== fx.flowing) {\n fx.flowing = flowing\n emitFixture(o, fx)\n }\n }\n\n function toggleFixture(o: ObjState, id: string): boolean {\n const fx = o.fixtures.get(id)\n if (!fx) return false\n if (fx.on) {\n fx.on = false\n fx.flowing = false\n fx.frac = 0\n if (fx.spec.part) setPartTarget(o, fx.spec.part, 0)\n emitFixture(o, fx)\n return true\n }\n fx.on = true\n if (fx.spec.part) setPartTarget(o, fx.spec.part, 1)\n if (fx.spec.kind === 'flush') {\n const volume = fx.spec.volume ?? 6\n const got = drawWater(o, fx, volume)\n fx.flowing = got > 1e-9\n fx.frac = fx.flowing ? 1 : 0\n fx.timer = FLUSH_SECONDS\n if (!fx.flowing) {\n fx.on = false\n if (fx.spec.part) setPartTarget(o, fx.spec.part, 0)\n }\n } else {\n fx.flowing = false\n fx.frac = 0\n stepFixture(o, fx, 1 / 60)\n }\n emitFixture(o, fx)\n if (!fx.flowing) message('no_water')\n return true\n }\n\n // ------------------------------------------------------------------ seats\n function seatTaken(objectId: string, seatId: string): string | null {\n for (const [actor, s] of seats) if (s.object === objectId && s.seat === seatId) return actor\n return null\n }\n\n function stand(actor: string = DEFAULT_ACTOR): Vec3 | null {\n const s = seats.get(actor)\n if (!s) return null\n seats.delete(actor)\n const o = objs.get(s.object)\n const spec = o?.spec.seats?.find((x) => x.id === s.seat)\n emit({ type: 'seat', object: s.object, seat: s.seat, actor, seated: false })\n if (!o || !spec) return null\n return toWorld(o, spec.exit)\n }\n\n function sit(objectId: string, seatId: string, actor: string = DEFAULT_ACTOR): SeatResult | null {\n const o = objs.get(objectId)\n const seat = o?.spec.seats?.find((s) => s.id === seatId)\n if (!o || !seat) return null\n const holder = seatTaken(objectId, seatId)\n if (holder && holder !== actor) return null\n if (seats.has(actor) && !holder) stand(actor)\n seats.set(actor, { object: objectId, seat: seatId })\n const eye = seat.eye ?? (seat.pose === 'lie' ? 0.18 : 0.62)\n emit({ type: 'seat', object: objectId, seat: seatId, actor, seated: true })\n return { eye: toWorld(o, [seat.pos[0], seat.pos[1] + eye, seat.pos[2]]), yaw: o.public.transform.ry + seat.ry + Math.PI, pose: seat.pose }\n }\n\n // ------------------------------------------------------------------ soft volumes\n function push(pos: Vec3, radius: number, vel: Vec3): void {\n for (const o of objs.values()) {\n if (!o.soft.size) continue\n const tr = o.public.transform\n const lp = worldToLocal(tr, pos)\n const lv = rotY(vel, -tr.ry)\n for (const s of o.soft.values()) {\n const [w, h, d] = s.spec.size\n const hx = w / 2\n const hz = Math.max(d, 0.1) / 2\n const dx = Math.max(Math.abs(lp[0] - s.spec.anchor[0]) - hx, 0)\n const dz = Math.max(Math.abs(lp[2] - s.spec.anchor[2]) - hz, 0)\n if (Math.hypot(dx, dz) > radius) continue\n const top = tr.y + s.spec.anchor[1]\n if (pos[1] + ACTOR_HEIGHT < top - h || pos[1] > top) continue\n if (s.driver) {\n s.driver.push(lv)\n if (s.spec.kind === 'panel' && s.spec.part && lv[2] < -0.05 && lp[2] > s.spec.anchor[2]) setPartTarget(o, s.spec.part, 1)\n continue\n }\n const cap = 8\n s.vax = clamp(s.vax - lv[2] * PUSH_GAIN, -cap, cap)\n s.vaz = clamp(s.vaz + lv[0] * PUSH_GAIN, -cap, cap)\n if (s.spec.kind === 'panel' && s.spec.part && lv[2] < -0.05 && lp[2] > s.spec.anchor[2]) setPartTarget(o, s.spec.part, 1)\n }\n }\n }\n\n const swingOut: [number, number] = [0, 0]\n function stepSoft(dt: number): void {\n const sub = Math.max(1, Math.ceil(dt / (1 / 120)))\n const h = dt / sub\n for (const o of objs.values()) {\n if (!o.soft.size) continue\n const wl = rotY([wind[0], 0, wind[1]], -o.public.transform.ry)\n for (const s of o.soft.values()) {\n const k = s.spec.stiffness ?? 30\n const c = s.spec.damping ?? 4\n const max = s.spec.maxAngle ?? 0.7\n if (s.driver) {\n s.driver.swing(swingOut)\n s.ax = swingOut[0]\n s.az = swingOut[1]\n continue\n }\n const gain = s.spec.wind ?? (s.spec.kind === 'panel' ? 0 : 1)\n const gust = gain * (0.6 + 0.4 * Math.sin(time * 1.7 + s.phase)) * 0.1\n const fx = -wl[2] * gust\n const fz = wl[0] * gust\n for (let i = 0; i < sub; i++) {\n s.vax += (-k * s.ax - c * s.vax + fx) * h\n s.vaz += (-k * s.az - c * s.vaz + fz) * h\n s.ax += s.vax * h\n s.az += s.vaz * h\n }\n if (Math.abs(s.ax) > max) {\n s.ax = Math.sign(s.ax) * max\n s.vax = 0\n }\n if (Math.abs(s.az) > max) {\n s.az = Math.sign(s.az) * max\n s.vaz = 0\n }\n }\n }\n }\n\n // ------------------------------------------------------------------ damage\n function damage(objectId: string, target: string, amount: number, _kind?: string): { hp: number; destroyed: boolean } | null {\n const o = objs.get(objectId)\n if (o && options.destruction) {\n const pos = toWorld(o, [0, 0.5, 0])\n const type = _kind === 'gas' ? 'explosive' : _kind === 'fabric' ? 'slash' : 'blunt'\n const result = options.destruction.hitPart(objectId, target, { type, point: pos, energy: Math.max(0, amount), source: 'interactables' }) as { events?: Array<{ type?: string; part?: string }> } | null | undefined\n const destroyed = !!result?.events?.some((e) => e.type === 'fracture' && e.part === target)\n emit({ type: 'damage', object: objectId, target, hp: -1, destroyed })\n return { hp: -1, destroyed }\n }\n const st = o?.hp.get(target)\n if (!o || !st) return null\n if (st.hp <= 0) return { hp: 0, destroyed: true }\n const before = st.hp\n st.hp = Math.max(0, st.hp - Math.max(0, amount))\n const destroyed = st.hp <= 0\n emit({ type: 'damage', object: objectId, target, hp: st.hp, destroyed })\n const pos = toWorld(o, [0, 0.5, 0])\n const fuel = o.fuels.get(target)\n if (fuel && destroyed && fuel.spec.kind === 'gas' && fuel.level > 0) {\n emit({ type: 'explosion', object: objectId, pos, radius: 2 + fuel.level / 5 })\n fuel.level = 0\n }\n const tank = o.tanks.get(target)\n if (tank && before === st.max && st.hp < before) emit({ type: 'leak', object: objectId, target, pos })\n return { hp: st.hp, destroyed }\n }\n\n // ------------------------------------------------------------------ interactions\n function deriveInteractions(spec: ObjectSpec): InteractionSpec[] {\n const out: InteractionSpec[] = []\n const used = new Set<string>()\n const partPos = (id: string | undefined, fallback: Vec3): Vec3 => spec.parts?.find((p) => p.id === id)?.pivot ?? fallback\n const partLabel = (id: string | undefined): string => spec.parts?.find((p) => p.id === id)?.label ?? ''\n const claim = (id: string | undefined) => {\n if (id) used.add(id)\n }\n for (const d of spec.devices ?? []) {\n claim(d.part)\n const pos = d.part ? partPos(d.part, [0, 1, 0]) : (d.plug ?? [0, 1, 0])\n // a hard-wired lamp (circuit, no plug, no part to press) is driven by switches and `setDevice`: it never steals the interact key\n if (d.kind === 'lamp' && !d.part && !d.plug && d.electric !== false) continue\n out.push({ id: `device.${d.id}`, pos, action: { do: 'toggle_device', device: d.id }, label: partLabel(d.part) })\n if (d.kind === 'screen' && (d.channels ?? 1) > 1) out.push({ id: `channel.${d.id}`, pos, action: { do: 'cycle_device', device: d.id }, label: '' })\n }\n for (const s of spec.switches ?? []) {\n claim(s.part)\n out.push({ id: `switch.${s.id}`, pos: partPos(s.part, [0, 1.2, 0]), action: { do: 'toggle_switch', switch: s.id }, label: partLabel(s.part) })\n }\n const driven = new Set((spec.devices ?? []).map((d) => d.fixture))\n for (const f of spec.fixtures ?? []) {\n claim(f.part)\n if (driven.has(f.id)) continue\n out.push({ id: `fixture.${f.id}`, pos: f.part ? partPos(f.part, f.outlet) : f.outlet, action: { do: 'toggle_fixture', fixture: f.id }, label: partLabel(f.part) })\n }\n for (const b of spec.burners ?? []) {\n claim(b.part)\n const pos = b.part ? partPos(b.part, b.pos) : b.pos\n if (b.needsIgnition) out.push({ id: `ignite.${b.id}`, pos, action: { do: 'ignite', burner: b.id }, label: '' })\n out.push({ id: `burner.${b.id}`, pos, action: { do: 'toggle_burner', burner: b.id }, label: partLabel(b.part) })\n }\n for (const f of spec.fuels ?? []) {\n if (!f.valve) continue\n claim(f.valve)\n out.push({ id: `fuel.${f.id}`, pos: partPos(f.valve, [0, 0.5, 0]), action: { do: 'toggle_fuel', fuel: f.id }, label: partLabel(f.valve) })\n }\n for (const c of spec.containers ?? []) {\n if (!c.access) out.push({ id: `open.${c.id}`, pos: c.volume.center, action: { do: 'open_container', container: c.id }, label: '' })\n }\n for (const p of spec.parts ?? []) {\n if (used.has(p.id)) continue\n if (p.label) out.push({ id: `part.${p.id}`, pos: p.pivot, action: { do: 'toggle_part', part: p.id }, label: p.label })\n }\n for (const c of spec.containers ?? []) {\n if (c.access && !spec.parts?.find((p) => p.id === c.access)?.label) {\n out.push({ id: `open.${c.id}`, pos: partPos(c.access, c.volume.center), action: { do: 'open_container', container: c.id }, label: '' })\n }\n }\n for (const s of spec.seats ?? []) out.push({ id: `seat.${s.id}`, pos: s.pos, action: { do: 'sit', seat: s.id }, label: '' })\n return out\n }\n\n function typeName(o: ObjState): string {\n return table[`type.${o.spec.type}`] ?? humanize(o.spec.type)\n }\n\n function promptOf(o: ObjState, i: InteractionSpec): { label: string; verb: string; object: string } {\n const a = i.action\n let state: string | null = null\n let def = ''\n switch (a.do) {\n case 'toggle_part': {\n const p = o.parts.get(a.part)\n const open = !!p && targetIsOpen(p)\n state = open ? 'open' : 'closed'\n def = open ? 'prompt.close' : 'prompt.open'\n break\n }\n case 'open_container': {\n const c = containerOf(o, a.container)\n const p = c?.access ? o.parts.get(c.access) : undefined\n const open = p ? targetIsOpen(p) : false\n state = p ? (open ? 'open' : 'closed') : null\n def = open ? 'prompt.close' : 'prompt.open'\n break\n }\n case 'toggle_device': {\n const on = !!o.devices.get(a.device)?.on\n state = on ? 'on' : 'off'\n def = on ? 'prompt.turn_off' : 'prompt.turn_on'\n break\n }\n case 'toggle_switch': {\n const sw = o.spec.switches?.find((s) => s.id === a.switch)\n const on = !!sw && switchIsOn(o, sw)\n state = on ? 'on' : 'off'\n def = on ? 'prompt.turn_off' : 'prompt.turn_on'\n break\n }\n case 'toggle_breaker': {\n const on = breaker(a.circuit)\n state = on ? 'on' : 'off'\n def = on ? 'prompt.breaker_off' : 'prompt.breaker_on'\n break\n }\n case 'toggle_fixture': {\n const on = !!o.fixtures.get(a.fixture)?.on\n state = on ? 'on' : 'off'\n def = on ? 'prompt.turn_off' : 'prompt.turn_on'\n break\n }\n case 'toggle_burner': {\n const b = o.burners.get(a.burner)\n const on = !!b && (b.on || b.lit)\n state = on ? 'on' : 'off'\n def = on ? 'prompt.turn_off' : 'prompt.turn_on'\n break\n }\n case 'toggle_fuel': {\n const f = o.fuels.get(a.fuel)\n const open = !!f && valveOpen(o, f)\n state = open ? 'open' : 'closed'\n def = open ? 'prompt.close_valve' : 'prompt.open_valve'\n break\n }\n case 'take':\n def = 'prompt.take'\n break\n case 'read':\n def = 'prompt.read'\n break\n case 'ignite':\n def = 'prompt.light'\n break\n case 'cycle_device':\n def = 'prompt.change_channel'\n break\n case 'sit': {\n const seat = o.spec.seats?.find((s) => s.id === a.seat)\n const mine = seats.get(DEFAULT_ACTOR)\n def = mine && mine.object === o.id && mine.seat === a.seat ? 'prompt.get_up' : seat?.pose === 'lie' ? 'prompt.lie_down' : 'prompt.sit'\n break\n }\n }\n let key = def\n if (i.label) {\n if (state && table[`${i.label}.${state}`] !== undefined) key = `${i.label}.${state}`\n else if (table[i.label] !== undefined) key = i.label\n }\n const vars = { name: typeName(o), circuit: a.do === 'toggle_breaker' ? (a.name ?? a.circuit) : '' }\n const label = t(key, vars)\n // structured prompt: explicit `<key>.verb` / `<key>.object` entries win; otherwise the first word is the verb and the rest the object\n let verb: string\n let object: string\n if (table[`${key}.verb`] !== undefined) {\n verb = t(`${key}.verb`, vars)\n object = table[`${key}.object`] ? t(`${key}.object`, vars) : vars.name\n } else {\n const sp = label.indexOf(' ')\n verb = sp < 0 ? label : label.slice(0, sp)\n object = sp < 0 ? vars.name : label.slice(sp + 1)\n }\n return { label, verb, object }\n }\n\n /** Locale key of the reason an interaction cannot be used right now, or null when it can. */\n function unavailableReason(o: ObjState, i: InteractionSpec): string | null {\n const a = i.action\n if (!requirementMet(i)) return 'requires_open'\n switch (a.do) {\n case 'toggle_part': {\n const p = o.parts.get(a.part)\n return p && gated(o, p) ? 'requires_open' : null\n }\n case 'open_container': {\n const c = containerOf(o, a.container)\n const p = c?.access ? o.parts.get(c.access) : undefined\n return p && gated(o, p) ? 'requires_open' : null\n }\n case 'toggle_breaker': {\n const rocker = a.part ? o.parts.get(a.part) : undefined\n return rocker && gated(o, rocker) ? 'requires_open' : null\n }\n case 'take':\n case 'read':\n return accessible(o.id, a.container) ? null : 'requires_open'\n case 'ignite':\n return o.burners.get(a.burner)?.lit ? 'already_lit' : null\n case 'toggle_burner': {\n const b = o.burners.get(a.burner)\n return !b?.spec.needsIgnition || b.lit ? null : 'needs_ignition'\n }\n case 'cycle_device': {\n const d = o.devices.get(a.device)\n if (!d || !d.on) return 'turn_on_first'\n return devicePowered(o, d) ? null : 'no_power'\n }\n default:\n return null\n }\n }\n\n function requirementMet(i: InteractionSpec): boolean {\n if (!i.requires) return true\n const p = objs.get(i.requires.object)?.parts.get(i.requires.part)\n return !!p && targetIsOpen(p)\n }\n\n function interactablesOf(o: ObjState): Array<{ item: Interactable; spec: InteractionSpec; o: ObjState }> {\n return o.interactions.map((i) => {\n const id = gid(o, i.id)\n const p = promptOf(o, i)\n const item: Interactable = {\n id,\n object: o.id,\n kind: i.action.do,\n pos: toWorld(o, i.pos),\n radius: i.radius ?? DEFAULT_RADIUS,\n label: p.label,\n verb: p.verb,\n noun: p.object,\n available: true,\n act: (actor) => act(id, actor),\n }\n const reason = unavailableReason(o, i) ?? (options.canInteract?.(item, DEFAULT_ACTOR) === false ? 'locked' : null)\n if (reason) {\n item.available = false\n item.reason = reason\n }\n return { item, spec: i, o }\n })\n }\n\n /**\n * One `take` per stack an open container shows, at its slot (it rides the drawer or door shelf with it): each item inside a piece of furniture is picked up\n * on its own, with one hand. Items the catalogue marks `pickable: false`, and stacks whose data says so, are left out.\n */\n function contentTakes(o: ObjState): Interactable[] {\n if (options.takeContents === false) return []\n const out: Interactable[] = []\n for (const c of o.spec.containers ?? []) {\n const list = o.contents.get(c.id)\n if (!list || !list.some((st) => st !== null) || !accessible(o.id, c.id)) continue\n list.forEach((stack, slot) => {\n if (!stack || options.items?.[stack.type]?.pickable === false || stack.data?.pickable === false) return\n const verb = t('prompt.take')\n const noun = table[`item.${stack.type}`] ?? humanize(stack.type)\n const item: Interactable = {\n id: `${o.id}:${TAKE_PREFIX}${c.id}.${slot}`,\n object: o.id,\n kind: 'take',\n pos: slotPosition(o.id, c.id, slot),\n radius: TAKE_RADIUS,\n label: `${verb} ${noun}`,\n verb,\n noun,\n hands: 1,\n itemType: stack.type,\n available: true,\n act: (actor) => takeAt(o.id, c.id, slot, actor ?? DEFAULT_ACTOR),\n }\n if (options.canInteract?.(item, DEFAULT_ACTOR) === false) {\n item.available = false\n item.reason = 'locked'\n }\n out.push(item)\n })\n }\n return out\n }\n\n function takeAt(objectId: string, containerId: string, slot: number, actor: string): boolean {\n const o = objs.get(objectId)\n if (!o) return false\n const probe = contentTakes(o).find((k) => k.id === `${objectId}:${TAKE_PREFIX}${containerId}.${slot}`)\n if (!probe || options.canInteract?.(probe, actor) === false) return false\n return take(objectId, containerId, slot, actor) !== null\n }\n\n function interactables(): Interactable[] {\n const out: Interactable[] = []\n for (const o of objs.values()) {\n for (const e of interactablesOf(o)) out.push(e.item)\n out.push(...contentTakes(o))\n }\n return out\n }\n\n function target(eye: { x: number; y: number; z: number; yaw: number; pitch: number }, opts: TargetOptions = {}): Interactable | null {\n const reach = opts.reach ?? 1.8\n const cone = opts.cone ?? 0.45\n const dir: Vec3 = [-Math.sin(eye.yaw) * Math.cos(eye.pitch), Math.sin(eye.pitch), -Math.cos(eye.yaw) * Math.cos(eye.pitch)]\n let best: Interactable | null = null\n let bestScore = Infinity\n for (const o of objs.values()) {\n for (const item of [...interactablesOf(o).map((e) => e.item), ...contentTakes(o)]) {\n if (!item.available && !opts.includeUnavailable) continue\n if (opts.kinds && !opts.kinds.includes(item.kind)) continue\n if (opts.filter && !opts.filter(item)) continue\n const v: Vec3 = [item.pos[0] - eye.x, item.pos[1] - eye.y, item.pos[2] - eye.z]\n const d = Math.hypot(v[0], v[1], v[2])\n if (d > reach) continue\n const cos = d < 1e-6 ? 1 : clamp((v[0] * dir[0] + v[1] * dir[1] + v[2] * dir[2]) / d, -1, 1)\n const angle = Math.acos(cos)\n if (angle > cone) continue\n const score = (angle / cone) * 0.6 + (d / reach) * 0.4\n if (score < bestScore) {\n bestScore = score\n best = item\n }\n }\n }\n return best\n }\n\n function act(interactableId: string, actor: string = DEFAULT_ACTOR): boolean {\n let found: { item: Interactable; spec: InteractionSpec; o: ObjState } | null = null\n for (const o of objs.values()) {\n if (!interactableId.startsWith(o.id + ':')) continue\n const local = interactableId.slice(o.id.length + 1)\n if (local.startsWith(TAKE_PREFIX)) {\n const at = contentTakes(o).find((k) => k.id === interactableId)\n if (at) return at.act(actor)\n }\n if (!o.interactions.some((i) => i.id === local)) continue\n found = interactablesOf(o).find((e) => e.spec.id === local) ?? null\n if (found) break\n }\n if (!found) return false\n if (!requirementMet(found.spec)) return false\n if (options.canInteract?.(found.item, actor) === false) return false\n return execute(found.o, found.spec.action, actor)\n }\n\n function execute(o: ObjState, a: InteractionSpec['action'], actor: string): boolean {\n switch (a.do) {\n case 'toggle_part': {\n const p = o.parts.get(a.part)\n if (!p || gated(o, p)) return false\n setPartTarget(o, a.part, targetIsOpen(p) ? 0 : 1)\n return true\n }\n case 'open_container': {\n const c = containerOf(o, a.container)\n if (!c) return false\n if (c.access) return execute(o, { do: 'toggle_part', part: c.access }, actor)\n emit({ type: 'container', object: o.id, container: c.id, open: true })\n return true\n }\n case 'take': {\n if (!accessible(o.id, a.container)) return false\n const list = o.contents.get(a.container)\n if (!list) return false\n const slot = a.slot ?? list.findIndex((s) => s !== null)\n if (slot < 0 || !list[slot]) {\n message('empty')\n return false\n }\n return take(o.id, a.container, slot, actor) !== null\n }\n case 'read': {\n if (!accessible(o.id, a.container)) return false\n const stack = o.contents.get(a.container)?.[a.slot]\n if (!stack) {\n message('empty')\n return false\n }\n const key = typeof stack.data?.text === 'string' ? stack.data.text : null\n if (!key) return false\n message(key)\n return true\n }\n case 'toggle_device': {\n const d = o.devices.get(a.device)\n if (!d) return false\n setDeviceOn(o, d, !d.on)\n return true\n }\n case 'cycle_device': {\n const d = o.devices.get(a.device)\n if (!d || !d.on) return false\n if (!devicePowered(o, d)) {\n message('no_power')\n return false\n }\n d.channel = (d.channel + 1) % Math.max(1, d.spec.channels ?? 1)\n emit({ type: 'device', object: o.id, device: d.spec.id, on: true, powered: true, channel: d.channel })\n return true\n }\n case 'toggle_switch':\n return toggleSwitch(o, a.switch)\n case 'toggle_breaker': {\n const rocker = a.part ? o.parts.get(a.part) : undefined\n if (rocker && gated(o, rocker)) return false\n const on = !breaker(a.circuit)\n if (a.part) setPartTarget(o, a.part, on ? 1 : 0)\n world.power.setBreaker(a.circuit, on)\n return true\n }\n case 'toggle_fixture':\n return toggleFixture(o, a.fixture)\n case 'toggle_burner':\n return toggleBurner(o, a.burner)\n case 'ignite':\n return ignite(o, a.burner)\n case 'toggle_fuel':\n return toggleFuel(o, a.fuel)\n case 'sit': {\n const mine = seats.get(actor)\n if (mine && mine.object === o.id && mine.seat === a.seat) {\n stand(actor)\n return true\n }\n return sit(o.id, a.seat, actor) !== null\n }\n }\n }\n\n // ------------------------------------------------------------------ emitters, mirrors, colliders\n function emitters(): ActiveEmitter[] {\n const out: ActiveEmitter[] = []\n for (const o of objs.values()) {\n for (const e of o.spec.emitters ?? []) {\n let intensity = 0\n const b = o.burners.get(e.source)\n const fx = o.fixtures.get(e.source)\n const dev = o.devices.get(e.source)\n const fuel = o.fuels.get(e.source)\n if (b) {\n const ref = resolveFuel(o, b)\n const frac = ref ? clamp(ref.f.level / ref.f.spec.capacity, 0, 1) : 0\n if (b.lit) intensity = 0.35 + 0.65 * frac\n else if (e.kind === 'smoke' && b.smoke > 0) intensity = 0.6 * (b.smoke / SMOKE_TAIL)\n } else if (fx) {\n if (fx.on && fx.flowing) intensity = fx.frac\n } else if (dev) {\n if (dev.on && devicePowered(o, dev)) intensity = 1\n } else if (fuel) {\n const lit = [...o.burners.values()].some((bb) => bb.lit && resolveFuel(o, bb)?.f === fuel)\n if (lit) intensity = 0.35 + 0.65 * clamp(fuel.level / fuel.spec.capacity, 0, 1)\n }\n if (intensity <= 0) continue\n const dir = rotY(e.dir ?? [0, 1, 0], o.public.transform.ry)\n out.push({ id: gid(o, e.id), object: o.id, kind: e.kind, pos: toWorld(o, e.pos), dir, size: e.size ?? 0.3, ...(e.reach !== undefined ? { reach: e.reach } : {}), ...(e.bowl ? { bowl: e.bowl } : {}), intensity: clamp(intensity, 0, 1) })\n }\n }\n return out\n }\n\n function mirrors(eye: Vec3, maxDistance = 10, count = 4) {\n const out: Array<{ id: string; center: Vec3; normal: Vec3; w: number; h: number; distance: number }> = []\n for (const o of objs.values()) {\n for (const m of o.spec.mirrors ?? []) {\n const center = toWorld(o, applyPart(o, m.part, m.center))\n const f = partFrame(o, m.part)\n const ln = f && f.angle !== 0 ? rotateAxis(m.normal, f.axis, f.angle) : m.normal\n const normal = rotY(ln, o.public.transform.ry)\n const len = Math.hypot(normal[0], normal[1], normal[2]) || 1\n const n: Vec3 = [normal[0] / len, normal[1] / len, normal[2] / len]\n const to: Vec3 = [eye[0] - center[0], eye[1] - center[1], eye[2] - center[2]]\n if (n[0] * to[0] + n[1] * to[1] + n[2] * to[2] <= 0) continue\n const distance = Math.hypot(to[0], to[1], to[2])\n if (distance > maxDistance) continue\n out.push({ id: gid(o, m.id), center, normal: n, w: m.w, h: m.h, distance })\n }\n }\n return out.sort((a, b) => a.distance - b.distance).slice(0, count)\n }\n\n function colliders(opts: ColliderOptions = {}): WorldCollider[] {\n const out: WorldCollider[] = []\n const fixed: WorldCollider[] = []\n for (const o of objs.values()) {\n const tr = o.public.transform\n for (const c of o.spec.colliders ?? []) {\n if (c.part && c.offWhenOpen && (o.parts.get(c.part)?.t ?? 0) > 0.5) continue\n let extra = 0\n if (c.part) {\n const f = partFrame(o, c.part)\n if (f && f.angle !== 0 && Math.abs(f.axis[1]) >= 0.5) extra = f.angle * Math.sign(f.axis[1])\n }\n const center = toWorld(o, applyPart(o, c.part, c.center))\n ;(c.part ? out : fixed).push({\n id: gid(o, c.id),\n object: o.id,\n cx: center[0],\n cz: center[2],\n hw: c.half[0],\n hd: c.half[2],\n ry: tr.ry + (c.ry ?? 0) + extra,\n y0: center[1] - c.half[1],\n y1: center[1] + c.half[1],\n })\n }\n }\n if (opts.merge) return [...mergeColliders(fixed, { gap: opts.gap, slack: opts.slack }), ...out]\n return [...fixed, ...out]\n }\n\n // ------------------------------------------------------------------ update\n /** A part the engine moves: it aims at the target when that changed, then `t` is what the joint says; a broken one stays where it broke. */\n function updateDriven(o: ObjState, p: PartState, dt: number): void {\n const driver = p.driver as PartDriver\n if (p.broken) return\n if (p.commanded !== p.target && !(gated(o, p) && p.target > p.t)) {\n driver.aim(p.target)\n p.commanded = p.target\n p.moving = true\n }\n driver.update(dt)\n if (driver.broken) {\n p.broken = true\n emit({ type: 'broke', object: o.id, part: p.spec.id })\n return\n }\n const next = clamp(driver.read(), 0, p.maxT)\n if (next !== p.t) writeT(o, p, next)\n if (!driver.settled) return\n // let go (or pushed by hand): what the joint holds is the target, so the next interaction toggles from there\n p.target = next\n p.commanded = next\n if (p.moving) emit({ type: 'part', object: o.id, part: p.spec.id, t: next, target: next })\n p.moving = false\n }\n\n function update(dt: number): void {\n if (!(dt > 0)) return\n time += dt\n for (const o of objs.values()) {\n for (const p of o.parts.values()) {\n if (p.driver) {\n updateDriven(o, p, dt)\n continue\n }\n if (p.t === p.target) continue\n if (gated(o, p) && p.target > p.t) continue // a gated part may still close\n const step = (p.spec.motion.speed ?? 2.5) * dt\n const next = p.t < p.target ? Math.min(p.target, p.t + step) : Math.max(p.target, p.t - step)\n writeT(o, p, next)\n if (next === p.target) emit({ type: 'part', object: o.id, part: p.spec.id, t: next, target: p.target })\n }\n }\n stepSoft(dt)\n for (const o of objs.values()) {\n for (const b of o.burners.values()) {\n if (b.lit) {\n const ref = resolveFuel(o, b)\n if (!ref || !valveOpen(ref.o, ref.f)) {\n extinguish(o, b, !!b.spec.needsIgnition)\n } else {\n ref.f.level = Math.max(0, ref.f.level - b.spec.rate * dt)\n if (ref.f.level <= 0) extinguish(o, b, !!b.spec.needsIgnition)\n }\n } else if (b.on && !b.spec.needsIgnition && canBurn(b, resolveFuel(o, b))) {\n // a gas knob left open without gas lights as soon as the bottle valve opens\n b.lit = true\n b.smoke = 0\n emitBurner(o, b)\n } else if (b.smoke > 0) {\n b.smoke = Math.max(0, b.smoke - dt)\n }\n }\n if (rain > 0) {\n for (const tk of o.tanks.values()) {\n if (tk.spec.rainArea) tk.level = Math.min(tk.spec.capacity, tk.level + ((rain * tk.spec.rainArea) / 3600) * dt)\n }\n }\n for (const tk of o.tanks.values()) {\n const st = o.hp.get(tk.spec.id)\n if (st && st.hp < st.max && tk.level > 0) {\n const rate = 0.5 + 2.5 * (1 - st.hp / st.max)\n tk.level = Math.max(0, tk.level - rate * dt)\n }\n }\n }\n for (const o of objs.values()) {\n for (const d of o.devices.values()) {\n const fx = d.spec.fixture ? o.fixtures.get(d.spec.fixture) : undefined\n if (!fx) continue\n const run = d.on && devicePowered(o, d)\n if (fx.on === run) continue\n fx.on = run\n if (!run) {\n fx.flowing = false\n fx.frac = 0\n emitFixture(o, fx)\n }\n }\n for (const fx of o.fixtures.values()) stepFixture(o, fx, dt)\n }\n }\n\n // ------------------------------------------------------------------ add / remove\n function add(id: string, spec: ObjectSpec, transform: Transform): WorldObject {\n if (objs.has(id)) throw new Error(`Object \"${id}\" already exists`)\n const pub: WorldObject = { id, spec, transform: { ...transform }, parts: {} }\n const o: ObjState = {\n id,\n public: pub,\n spec,\n parts: new Map(),\n contents: new Map(),\n devices: new Map(),\n fuels: new Map(),\n burners: new Map(),\n tanks: new Map(),\n fixtures: new Map(),\n soft: new Map(),\n hp: new Map(),\n interactions: spec.interactions ?? deriveInteractions(spec),\n }\n for (const p of spec.parts ?? []) {\n const t0 = clamp(p.t0 ?? 0, 0, 1)\n const driver = options.partPhysics?.attachPart(id, p, pub.transform)\n o.parts.set(p.id, { spec: p, t: t0, target: t0, maxT: 1, ...(driver ? { driver, commanded: t0 } : {}) })\n driver?.snap(t0)\n pub.parts[p.id] = t0\n }\n for (const c of spec.containers ?? []) {\n let list: Array<ItemStack | null>\n if (c.contents) list = c.slots.map((_, i) => cloneStack(c.contents?.[i] ?? null))\n else if (c.loot) list = generateLoot(options.loot, c.loot, c.slots, `${seed}|${id}|${c.id}`, options.items)\n else list = c.slots.map(() => null)\n o.contents.set(c.id, list)\n }\n for (const d of spec.devices ?? []) {\n o.devices.set(d.id, { spec: d, on: !!d.on, channel: 0 })\n if (d.on && d.part) {\n const p = o.parts.get(d.part)\n if (p) {\n p.target = p.maxT\n writeT(o, p, p.maxT)\n }\n }\n }\n for (const f of spec.fuels ?? []) o.fuels.set(f.id, { spec: f, level: clamp(f.level ?? f.capacity, 0, f.capacity) })\n for (const b of spec.burners ?? []) o.burners.set(b.id, { spec: b, on: false, lit: false, smoke: 0 })\n for (const tk of spec.tanks ?? []) o.tanks.set(tk.id, { spec: tk, level: clamp(tk.level ?? tk.capacity, 0, tk.capacity) })\n for (const f of spec.fixtures ?? []) o.fixtures.set(f.id, { spec: f, on: false, flowing: false, frac: 0, timer: 0 })\n let n = 0\n for (const s of spec.soft ?? []) {\n const driver = options.partPhysics?.attachSoft?.(id, s, pub.transform)\n o.soft.set(s.id, { spec: s, ax: 0, az: 0, vax: 0, vaz: 0, phase: (n++ * 2.399963) % (Math.PI * 2), ...(driver ? { driver } : {}) })\n }\n for (const d of spec.damage ?? []) o.hp.set(d.target, { max: d.hp, hp: d.hp })\n objs.set(id, o)\n if (!defaultTankExplicit && defaultTank === null && o.tanks.size) defaultTank = gid(o, [...o.tanks.keys()][0])\n rebuildPlugs()\n return pub\n }\n\n function remove(id: string): void {\n const o = objs.get(id)\n if (!o) return\n for (const [actor, s] of [...seats]) if (s.object === id) seats.delete(actor)\n for (const p of o.parts.values()) p.driver?.dispose()\n for (const s of o.soft.values()) s.driver?.dispose()\n objs.delete(id)\n if (defaultTank && defaultTank.startsWith(id + ':')) defaultTank = null\n rebuildPlugs()\n }\n\n // ------------------------------------------------------------------ save / load\n function serialize(): WorldState {\n const objects: WorldState['objects'] = {}\n for (const o of objs.values()) {\n objects[o.id] = {\n parts: Object.fromEntries([...o.parts].map(([k, p]) => [k, p.t])),\n contents: Object.fromEntries([...o.contents].map(([k, v]) => [k, v.map(cloneStack)])),\n devices: Object.fromEntries([...o.devices].map(([k, d]) => [k, { on: d.on, channel: d.channel }])),\n fuels: Object.fromEntries([...o.fuels].map(([k, f]) => [k, { level: f.level, open: valveOpen(o, f) }])),\n burners: Object.fromEntries([...o.burners].map(([k, b]) => [k, { on: b.on, lit: b.lit }])),\n tanks: Object.fromEntries([...o.tanks].map(([k, tk]) => [k, tk.level])),\n fixtures: Object.fromEntries([...o.fixtures].map(([k, f]) => [k, f.on])),\n hp: Object.fromEntries([...o.hp].map(([k, h]) => [k, h.hp])),\n }\n }\n return {\n version: 1,\n objects,\n grid,\n breakers: Object.fromEntries(breakers),\n seats: Object.fromEntries([...seats].map(([a, s]) => [a, { object: s.object, seat: s.seat }])),\n defaultTank,\n }\n }\n\n function load(state: WorldState): void {\n for (const [id, st] of Object.entries(state.objects)) {\n const o = objs.get(id)\n if (!o) continue\n for (const [k, v] of Object.entries(st.parts)) {\n const p = o.parts.get(k)\n if (p) {\n // keep the limit found by fitSweep: a loaded save must not let a door open through a wall again\n p.target = clamp(v, 0, p.maxT)\n p.driver?.snap(p.target)\n p.commanded = p.target\n writeT(o, p, p.target)\n }\n }\n for (const [k, v] of Object.entries(st.contents)) {\n const c = containerOf(o, k)\n if (c) o.contents.set(k, c.slots.map((_, i) => cloneStack(v[i] ?? null)))\n }\n for (const [k, v] of Object.entries(st.devices)) {\n const d = o.devices.get(k)\n if (d) {\n d.on = v.on\n d.channel = v.channel\n }\n }\n for (const [k, v] of Object.entries(st.fuels)) {\n const f = o.fuels.get(k)\n if (f) f.level = v.level\n }\n for (const [k, v] of Object.entries(st.burners)) {\n const b = o.burners.get(k)\n if (b) {\n b.on = v.on\n b.lit = v.lit\n b.smoke = 0\n }\n }\n for (const [k, v] of Object.entries(st.tanks)) {\n const tk = o.tanks.get(k)\n if (tk) tk.level = v\n }\n for (const [k, v] of Object.entries(st.fixtures)) {\n const f = o.fixtures.get(k)\n if (f) {\n f.on = v\n f.flowing = false\n f.frac = 0\n f.timer = v && f.spec.kind === 'flush' ? FLUSH_SECONDS : 0\n }\n }\n for (const [k, v] of Object.entries(st.hp)) {\n const h = o.hp.get(k)\n if (h) h.hp = v\n }\n }\n grid = state.grid\n breakers.clear()\n for (const [k, v] of Object.entries(state.breakers)) breakers.set(k, v)\n seats.clear()\n for (const [a, s] of Object.entries(state.seats)) if (objs.has(s.object)) seats.set(a, { object: s.object, seat: s.seat })\n defaultTank = state.defaultTank\n defaultTankExplicit = true\n }\n\n // ------------------------------------------------------------------ public surface\n const world: World = {\n add,\n remove,\n get: (id) => objs.get(id)?.public,\n objects: () => [...objs.values()].map((o) => o.public),\n update,\n interactables,\n target,\n act,\n partT: (objectId, partId) => objs.get(objectId)?.parts.get(partId)?.t ?? 0,\n setDevice,\n setFixture,\n setBurner,\n setPart: (objectId, partId, targetT, instant) => {\n const o = objs.get(objectId)\n if (o) setPartTarget(o, partId, targetT, instant)\n },\n fitSweep,\n contents,\n accessible,\n take,\n put,\n slotPosition,\n power: {\n get grid() {\n return grid\n },\n set grid(on: boolean) {\n world.power.setGrid(on)\n },\n setGrid(on) {\n if (on === grid) return\n const before = powerSnapshot()\n grid = on\n emit({ type: 'power', grid })\n emitPowerChanges(before)\n },\n setBreaker(circuit, on) {\n if (breaker(circuit) === on) {\n breakers.set(circuit, on)\n return\n }\n const before = powerSnapshot()\n breakers.set(circuit, on)\n emitPowerChanges(before)\n },\n breaker,\n isPowered: (objectId, deviceId) => {\n const r = getDevice(objectId, deviceId)\n return r ? devicePowered(r.o, r.d) : false\n },\n isOn: (objectId, deviceId) => getDevice(objectId, deviceId)?.d.on ?? false,\n pluggedInto: (objectId, deviceId) => plugs.get(`${objectId}:${deviceId}`) ?? null,\n channel: (objectId, deviceId) => getDevice(objectId, deviceId)?.d.channel ?? 0,\n },\n fuelLevel: (objectId, fuelId) => objs.get(objectId)?.fuels.get(fuelId)?.level ?? 0,\n isLit: (objectId, burnerId) => objs.get(objectId)?.burners.get(burnerId)?.lit ?? false,\n water: {\n setDefaultTank(tankId) {\n defaultTank = tankId\n defaultTankExplicit = true\n },\n level(tankId) {\n return findGlobal(tankId, (oo, local) => oo.tanks.get(local))?.value.level ?? 0\n },\n refill(tankId, liters) {\n const f = findGlobal(tankId, (oo, local) => oo.tanks.get(local))\n if (!f) return 0\n const added = Math.max(0, Math.min(liters, f.value.spec.capacity - f.value.level))\n f.value.level += added\n return added\n },\n setRain(mm) {\n rain = Math.max(0, mm)\n },\n isFlowing: (objectId, fixtureId) => {\n const fx = objs.get(objectId)?.fixtures.get(fixtureId)\n return !!fx && fx.on && fx.flowing\n },\n },\n sit,\n stand,\n seatOf: (actor = DEFAULT_ACTOR) => {\n const s = seats.get(actor)\n return s ? { object: s.object, seat: s.seat } : null\n },\n push,\n sway: (objectId, softId) => {\n const s = objs.get(objectId)?.soft.get(softId)\n return s ? { ax: s.ax, az: s.az } : { ax: 0, az: 0 }\n },\n setWind: (x, z) => {\n wind = [x, z]\n },\n emitters,\n mirrors,\n colliders,\n damage,\n hp: (objectId, target) => (options.destruction ? null : (objs.get(objectId)?.hp.get(target)?.hp ?? null)),\n t,\n setLocale: (l) => {\n locale = l\n table = resolveStrings(locale, options.strings)\n },\n serialize,\n load,\n }\n return world\n}\n","import type { BodyId, JointId, Quat, SeamWorld, Vec3 } from '@adatechnology/game-physics'\n\n/** A chain of boxes along a polyline, each joined to the one before by a swing-twist joint: a cord, a cable, a strip of a curtain. */\nexport interface ChainSpec {\n /** From the start to the end of the chain; one link between each two points. */\n readonly points: readonly Vec3[]\n /** Half the width and the depth of a link (m); its length is the segment's. */\n readonly halfWidth: number\n readonly halfDepth: number\n readonly totalMass: number\n /** What the first link hangs from (a static body, or a kinematic one a host moves). */\n readonly startBody: BodyId\n /** What the last link is tied to; undefined: it hangs free. */\n readonly endBody?: BodyId\n /** Half cone of every joint (radians) and the most it twists either way. */\n readonly halfCone: number\n readonly twist: number\n /** Torque (N m) that holds a joint still against the swing: the chain's stiffness at rest. */\n readonly jointFriction: number\n /** Share of velocity lost per second by every link (the air, the cloth). */\n readonly damping: number\n}\n\nexport interface Chain {\n readonly bodies: readonly BodyId[]\n readonly joints: readonly JointId[]\n /** Half the length of each link, for reading its ends. */\n readonly halfLengths: readonly number[]\n /** The collision group the links share (released with the chain). */\n readonly group: number\n}\n\nconst UP: Vec3 = [0, 1, 0]\n\nconst sub = (a: Vec3, b: Vec3): Vec3 => [a[0] - b[0], a[1] - b[1], a[2] - b[2]]\nconst length = (v: Vec3): number => Math.hypot(v[0], v[1], v[2])\nconst cross = (a: Vec3, b: Vec3): Vec3 => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]\n\n/** The turn that takes +y (a link's length) onto `direction` (unit). */\nexport function alignY(direction: Vec3): Quat {\n const axis = cross(UP, direction)\n const sine = length(axis)\n if (sine < 1e-9) return direction[1] >= 0 ? [0, 0, 0, 1] : [1, 0, 0, 0]\n const angle = Math.atan2(sine, direction[1])\n const half = Math.sin(angle / 2) / sine\n return [axis[0] * half, axis[1] * half, axis[2] * half, Math.cos(angle / 2)]\n}\n\n/** A vector turned by a unit quaternion. */\nexport function rotateByQuat(v: Vec3, q: Quat): Vec3 {\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\nconst perpendicular = (direction: Vec3): Vec3 => {\n const side = Math.abs(direction[0]) < 0.9 ? cross(direction, [1, 0, 0]) : cross(direction, [0, 0, 1])\n const size = length(side)\n return [side[0] / size, side[1] / size, side[2] / size]\n}\n\n/** Builds the links and joints of a chain in the world, in the pose its points give (so a cord starts already sagging). */\nexport function buildChain(world: SeamWorld, spec: ChainSpec): Chain {\n const count = spec.points.length - 1\n const lengths = Array.from({ length: count }, (_, i) => length(sub(spec.points[i + 1] as Vec3, spec.points[i] as Vec3)))\n const total = lengths.reduce((sum, each) => sum + each, 0)\n const pairs: Array<readonly [number, number]> = []\n for (let a = 0; a < count; a++) for (let b = a + 1; b < count; b++) pairs.push([a, b])\n const group = world.createGroup(count, pairs)\n const bodies: BodyId[] = []\n const joints: JointId[] = []\n for (let i = 0; i < count; i++) {\n const from = spec.points[i] as Vec3\n const to = spec.points[i + 1] as Vec3\n const span = lengths[i] as number\n const direction: Vec3 = [(to[0] - from[0]) / span, (to[1] - from[1]) / span, (to[2] - from[2]) / span]\n const link = world.createBody({\n shape: { kind: 'box', half: [spec.halfWidth, span / 2, spec.halfDepth] },\n motion: 'dynamic',\n mass: spec.totalMass * (span / total),\n position: [(from[0] + to[0]) / 2, (from[1] + to[1]) / 2, (from[2] + to[2]) / 2],\n rotation: alignY(direction),\n layer: 'debris',\n group: { id: group, sub: i },\n linearDamping: spec.damping,\n angularDamping: spec.damping,\n user: -4,\n })\n const previous = i === 0 ? spec.startBody : (bodies[i - 1] as BodyId)\n if (i === 0) world.ignorePair(spec.startBody, link, true)\n joints.push(world.createJoint(swingTwist(spec, previous, link, from, direction)))\n bodies.push(link)\n }\n if (spec.endBody !== undefined) {\n const last = spec.points[count] as Vec3\n const direction = sub(last, spec.points[count - 1] as Vec3)\n const size = length(direction)\n world.ignorePair(spec.endBody, bodies[count - 1] as BodyId, true)\n joints.push(world.createJoint(swingTwist(spec, bodies[count - 1] as BodyId, spec.endBody, last, [direction[0] / size, direction[1] / size, direction[2] / size])))\n }\n return { bodies, joints, halfLengths: lengths.map((each) => each / 2), group }\n}\n\n/** Takes a chain out of the world: its joints, its links, then the group the links shared. */\nexport function disposeChain(world: SeamWorld, chain: Chain): void {\n for (const joint of chain.joints) world.removeJoint(joint)\n for (const body of chain.bodies) world.removeBody(body)\n world.releaseGroup(chain.group)\n}\n\nconst swingTwist = (spec: ChainSpec, a: BodyId, b: BodyId, point: Vec3, direction: Vec3) => ({\n kind: 'swingTwist' as const,\n a,\n b,\n point,\n twistAxis: direction,\n planeAxis: perpendicular(direction),\n normalHalfCone: spec.halfCone,\n planeHalfCone: spec.halfCone,\n twistMin: -spec.twist,\n twistMax: spec.twist,\n friction: spec.jointFriction,\n})\n\nconst pose = new Float64Array(7)\n\n/** The end of link `index` now (x, y, z into `out` at `offset`): the body's centre moved half the link's length along its own +y (the unit quaternion's y axis, unrolled). */\nconst writeLinkEnd = (world: SeamWorld, chain: Chain, index: number, sign: 1 | -1, out: Float64Array, offset: number): void => {\n world.readPose(chain.bodies[index] as BodyId, pose, 0)\n const x = pose[3] as number\n const y = pose[4] as number\n const z = pose[5] as number\n const w = pose[6] as number\n const half = (chain.halfLengths[index] as number) * sign\n out[offset] = (pose[0] as number) + half * 2 * (x * y - w * z)\n out[offset + 1] = (pose[1] as number) + half * (1 - 2 * (x * x + z * z))\n out[offset + 2] = (pose[2] as number) + half * 2 * (y * z + w * x)\n}\n\n/** The two ends of every link now, as a polyline (x, y, z per point) for a host that draws the cord: the points a chain was built from, moved. */\nexport function chainPoints(world: SeamWorld, chain: Chain, out: Float64Array): void {\n const count = chain.bodies.length\n writeLinkEnd(world, chain, 0, -1, out, 0)\n for (let i = 0; i < count; i++) writeLinkEnd(world, chain, i, 1, out, (i + 1) * 3)\n}\n\n/** Only the free end of the chain (x, y, z into `out`): one pose read, for a host that wants where the tip is and not the whole line. */\nexport function chainEnd(world: SeamWorld, chain: Chain, out: Float64Array): void {\n writeLinkEnd(world, chain, chain.bodies.length - 1, 1, out, 0)\n}\n","import type { BodyId, SeamWorld } from '@adatechnology/game-physics'\n\nimport { buildChain, chainEnd, disposeChain } from './engine-chain'\nimport type { Chain } from './engine-chain'\nimport { localToWorld, rotY } from './math'\nimport type { SoftDriver } from './part-physics'\nimport type { SoftSpec, Transform, Vec3 } from './types'\n\nconst STRIP_WIDTH = 0.12\nconst LINK_LENGTH = 0.15\nconst MAX_LINKS = 8\nconst FABRIC_KG_PER_M2 = 0.3\nconst FABRIC_HALF_DEPTH = 0.01\nconst TWIST_RANGE = 0.3\nconst DEFAULT_MAX_ANGLE = 0.7\nconst DEFAULT_DAMPING = 4\nconst JOINT_HOLD_NM = 0.002\n/** An actor's velocity (m/s) to the speed it gives a strip (the body only brushes the cloth). */\nconst PUSH_GAIN = 0.4\n\n/**\n * A curtain, cloth or strip as hanging chains from a rail along its anchor line, one chain per `STRIP_WIDTH` of width: they swing when an actor pushes through and\n * settle by the damping (the world's spring is not used). The world's `sway` reads back the mean tip offset of the chains as the two swing angles.\n */\nexport function attachStrips(world: SeamWorld, soft: SoftSpec, transform: Transform): SoftDriver {\n const [width, height, depth] = soft.size\n const strips = Math.max(1, Math.round(width / STRIP_WIDTH))\n const links = Math.min(MAX_LINKS, Math.max(2, Math.round(height / LINK_LENGTH)))\n const rail: BodyId = world.createBody({ shape: { kind: 'box', half: [width / 2, 0.01, Math.max(depth, 0.02) / 2] }, motion: 'static', position: localToWorld(transform, soft.anchor), layer: 'static', user: -3 })\n const damping = soft.damping ?? DEFAULT_DAMPING\n const chains: Chain[] = []\n const tops: Vec3[] = []\n for (let i = 0; i < strips; i++) {\n const x = soft.anchor[0] - width / 2 + (width * (i + 0.5)) / strips\n const top = localToWorld(transform, [x, soft.anchor[1], soft.anchor[2]])\n tops.push(top)\n chains.push(\n buildChain(world, {\n points: Array.from({ length: links + 1 }, (_, k): Vec3 => [top[0], top[1] - (height * k) / links, top[2]]),\n halfWidth: (width / strips) * 0.45,\n halfDepth: FABRIC_HALF_DEPTH,\n totalMass: (width / strips) * height * FABRIC_KG_PER_M2,\n startBody: rail,\n halfCone: soft.maxAngle ?? DEFAULT_MAX_ANGLE,\n twist: TWIST_RANGE,\n jointFriction: JOINT_HOLD_NM,\n damping: damping / 4,\n }),\n )\n }\n const tip = new Float64Array(3)\n const lastLinks = chains.map((chain) => chain.bodies[chain.bodies.length - 1] as BodyId)\n const cosYaw = Math.cos(-transform.ry)\n const sinYaw = Math.sin(-transform.ry)\n let restedAx = 0\n let restedAz = 0\n let isRested = false\n let disposed = false\n const everyLinkAsleep = (): boolean => {\n for (let i = 0; i < lastLinks.length; i++) if (!world.isSleeping(lastLinks[i] as BodyId)) return false\n return true\n }\n return {\n swing(out) {\n const asleep = everyLinkAsleep()\n if (asleep && isRested) {\n out[0] = restedAx\n out[1] = restedAz\n return\n }\n let dx = 0\n let dz = 0\n for (let i = 0; i < chains.length; i++) {\n chainEnd(world, chains[i] as Chain, tip)\n const top = tops[i] as Vec3\n const offsetX = (tip[0] as number) - top[0]\n const offsetZ = (tip[2] as number) - top[2]\n // the object's yaw undone (the same turn about y as `worldToLocal`)\n dx += offsetX * cosYaw + offsetZ * sinYaw\n dz += -offsetX * sinYaw + offsetZ * cosYaw\n }\n // rotation about x turns the tip toward -z for a positive angle (and about z toward +x), as the world's spring has it\n out[0] = -Math.asin(Math.max(-1, Math.min(1, dz / strips / height)))\n out[1] = Math.asin(Math.max(-1, Math.min(1, dx / strips / height)))\n restedAx = out[0]\n restedAz = out[1]\n isRested = asleep\n },\n push(velocity) {\n const world3 = rotY(velocity, transform.ry)\n for (const chain of chains) {\n for (const body of chain.bodies) world.addImpulse(body, [world3[0] * PUSH_GAIN * linkMass(soft, strips, links), world3[1] * PUSH_GAIN * linkMass(soft, strips, links), world3[2] * PUSH_GAIN * linkMass(soft, strips, links)])\n }\n },\n dispose() {\n if (disposed) return\n disposed = true\n for (const chain of chains) disposeChain(world, chain)\n world.removeBody(rail)\n },\n }\n}\n\nconst linkMass = (soft: SoftSpec, strips: number, links: number): number => (soft.size[0] / strips) * (soft.size[1] / links) * FABRIC_KG_PER_M2\n","import type { BodyId, JointId, Quat, SeamWorld } from '@adatechnology/game-physics'\n\nimport { clamp, rotateAxis } from './math'\nimport type { PartDriver } from './part-physics'\nimport type { Vec3 } from './types'\n\n/** A part driver whose leaf is a body of the engine: the host draws the part where the body is, and after a break the body is all that is left. */\nexport interface EnginePartDriver extends PartDriver {\n readonly leaf: BodyId\n}\n\n/** Units of t per second that close a gap of one t: the leaf slows as it arrives. */\nconst AIM_GAIN = 8\nconst ARRIVED_AT = 0.004\n\nconst axisAngle = (axis: Vec3, angle: number): Quat => {\n const size = Math.hypot(axis[0], axis[1], axis[2]) || 1\n const k = Math.sin(angle / 2) / size\n return [axis[0] * k, axis[1] * k, axis[2] * k, Math.cos(angle / 2)]\n}\nconst multiply = (a: Quat, b: Quat): Quat => [\n a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],\n a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],\n a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],\n a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2],\n]\n\n\nexport interface LeafDriverSpec {\n readonly world: SeamWorld\n readonly leaf: BodyId\n readonly frame: BodyId\n readonly ownsFrame: boolean\n readonly joint: JointId\n readonly onDispose: () => void\n readonly drive: { readonly isHinge: boolean; readonly axis: Vec3; readonly pivot: Vec3; readonly centre: Vec3; readonly range: number; readonly speed: number; readonly base: Quat }\n}\n\n\n/** Scratch of every leaf: a driver reads and writes a pose, a velocity pair at a time, so no pose or vector is made per frame. */\nconst pose = new Float64Array(7)\nconst linearScratch: Vec3 = [0, 0, 0]\nconst angularScratch: Vec3 = [0, 0, 0]\nconst NO_SPIN: Vec3 = [0, 0, 0]\n\nexport function createLeafDriver(spec: LeafDriverSpec): EnginePartDriver {\n const { world, leaf, frame, joint, drive } = spec\n const { axis, pivot, centre, range } = drive\n let target = 0\n let settled = true\n let broken = false\n let disposed = false\n let lastT = 0\n /** t of the leaf at rest, kept while it sleeps: nothing moves it, so the joint is not asked again. */\n let restedT: number | undefined\n const measure = (): number => {\n if (drive.isHinge) return world.jointAngles(joint).hinge / range\n world.readPose(leaf, pose, 0)\n return (((pose[0] as number) - centre[0]) * axis[0] + ((pose[1] as number) - centre[1]) * axis[1] + ((pose[2] as number) - centre[2]) * axis[2]) / range\n }\n const read = (): number => {\n if (broken) return lastT\n if (settled && world.isSleeping(leaf)) {\n restedT ??= measure()\n lastT = restedT\n return lastT\n }\n restedT = undefined\n lastT = measure()\n return lastT\n }\n const stop = (): void => {\n world.setVelocity(leaf, NO_SPIN, NO_SPIN)\n settled = true\n }\n // t per second to the leaf's own velocity: a turn about the hinge carries the centre round, a slide is a line\n const move = (rate: number): void => {\n world.wake(leaf)\n const speed = rate * range\n angularScratch[0] = axis[0] * speed\n angularScratch[1] = axis[1] * speed\n angularScratch[2] = axis[2] * speed\n if (!drive.isHinge) return world.setVelocity(leaf, angularScratch, NO_SPIN)\n world.readPose(leaf, pose, 0)\n const armX = (pose[0] as number) - pivot[0]\n const armY = (pose[1] as number) - pivot[1]\n const armZ = (pose[2] as number) - pivot[2]\n linearScratch[0] = angularScratch[1] * armZ - angularScratch[2] * armY\n linearScratch[1] = angularScratch[2] * armX - angularScratch[0] * armZ\n linearScratch[2] = angularScratch[0] * armY - angularScratch[1] * armX\n world.setVelocity(leaf, linearScratch, angularScratch)\n }\n const place = (t: number): void => {\n const amount = t * drive.range\n if (drive.isHinge) {\n const centre = rotateAxis([drive.centre[0] - drive.pivot[0], drive.centre[1] - drive.pivot[1], drive.centre[2] - drive.pivot[2]], drive.axis, amount)\n world.setPose(leaf, [drive.pivot[0] + centre[0], drive.pivot[1] + centre[1], drive.pivot[2] + centre[2]], multiply(axisAngle(drive.axis, amount), drive.base), true)\n } else {\n world.setPose(leaf, [drive.centre[0] + drive.axis[0] * amount, drive.centre[1] + drive.axis[1] * amount, drive.centre[2] + drive.axis[2] * amount], drive.base, true)\n }\n world.setVelocity(leaf, [0, 0, 0], [0, 0, 0])\n }\n return {\n leaf,\n aim(next) {\n if (broken) return\n target = next\n settled = false\n restedT = undefined\n },\n snap(t) {\n target = t\n settled = true\n restedT = undefined\n if (!broken) place(t)\n },\n update() {\n if (broken) return\n if (!world.jointExists(joint)) {\n broken = true\n settled = true\n return\n }\n if (settled) return\n const error = target - read()\n if (Math.abs(error) < ARRIVED_AT) return stop()\n move(clamp(error * AIM_GAIN, -drive.speed, drive.speed))\n },\n read,\n get settled() {\n return settled\n },\n get broken() {\n return broken\n },\n dispose() {\n if (disposed) return\n disposed = true\n spec.onDispose()\n if (!broken) world.removeJoint(joint)\n world.removeBody(leaf)\n if (spec.ownsFrame) world.removeBody(frame)\n },\n }\n}\n","import type { BodyId, Quat, SeamWorld } from '@adatechnology/game-physics'\n\nimport { attachStrips } from './engine-soft'\nimport { createLeafDriver } from './engine-leaf'\nimport type { EnginePartDriver } from './engine-leaf'\nimport { localToWorld, rotY } from './math'\nimport type { PartPhysics } from './part-physics'\nimport type { PartSpec, SoftSpec, Transform, Vec3 } from './types'\n\n/** What a host tells the engine about its objects. */\nexport interface EnginePartOptions {\n /** The object's own static body when the host has one: a leaf does not collide with it. Without it each part gets a hidden anchor at its pivot. */\n readonly frameOf?: (object: string) => BodyId | undefined\n /** The impulse (N s) over which a part's joint breaks, or undefined for a part that never breaks. */\n readonly breakImpulse?: (object: string, part: PartSpec) => number | undefined\n /** Mass of a leaf (kg); default its volume at the density of a hollow door. */\n readonly leafMass?: (object: string, part: PartSpec) => number\n}\n\nexport interface EnginePartPhysics extends PartPhysics {\n /** The leaf body of a part the engine took (also after it broke: then it is a loose body the host draws where it is), or undefined. */\n leafOf(object: string, part: string): BodyId | undefined\n dispose(): void\n}\n\nconst HOLLOW_DOOR_DENSITY = 150\nconst MIN_LEAF_MASS = 1\n/** Newtons that hold a drawer still against its slide, and N m a hinge, so a part stays where it is left. */\nconst SLIDE_HOLD_N = 4\nconst HINGE_HOLD_NM = 0.4\nconst SOFT_KINDS: ReadonlySet<SoftSpec['kind']> = new Set(['cloth', 'curtain', 'strip'])\n\nexport const quatY = (ry: number): Quat => [0, Math.sin(ry / 2), 0, Math.cos(ry / 2)]\nconst cross = (a: Vec3, b: Vec3): Vec3 => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]\n\nconst perpendicularTo = (axis: Vec3): Vec3 => {\n const side = Math.abs(axis[0]) < 0.9 ? cross(axis, [1, 0, 0]) : cross(axis, [0, 0, 1])\n const size = Math.hypot(side[0], side[1], side[2])\n return [side[0] / size, side[1] / size, side[2] / size]\n}\n\n/** The engine under the movable parts and soft volumes of an interactables world (`WorldOptions.partPhysics`), made of the contract's bodies and joints only. */\nexport function createEnginePartPhysics(world: SeamWorld, options: EnginePartOptions = {}): EnginePartPhysics {\n const disposers = new Set<() => void>()\n const leaves = new Map<string, BodyId>()\n return {\n attachPart(object, part, transform) {\n const key = `${object}:${part.id}`\n const retire = (): void => {\n leaves.delete(key)\n disposers.delete(dispose)\n }\n const dispose = (): void => driver?.dispose()\n const driver = attachLeaf(world, options, { object, part, transform, onDispose: retire })\n if (!driver) return undefined\n leaves.set(key, driver.leaf)\n disposers.add(dispose)\n return driver\n },\n leafOf: (object, part) => leaves.get(`${object}:${part}`),\n attachSoft(_object, soft, transform) {\n const driver = SOFT_KINDS.has(soft.kind) ? attachStrips(world, soft, transform) : undefined\n if (!driver) return undefined\n const dispose = (): void => driver.dispose()\n disposers.add(dispose)\n return { swing: driver.swing, push: driver.push, dispose: () => { disposers.delete(dispose); driver.dispose() } }\n },\n dispose() {\n for (const dispose of [...disposers]) dispose()\n disposers.clear()\n },\n }\n}\n\ninterface LeafRequest {\n readonly object: string\n readonly part: PartSpec\n readonly transform: Transform\n readonly onDispose: () => void\n}\n\n/** A door, lid or drawer: a leaf box on a hinge or a slider, driven toward its target and free once it gets there. Undefined without `bounds` or for another motion. */\nfunction attachLeaf(world: SeamWorld, options: EnginePartOptions, request: LeafRequest): EnginePartDriver | undefined {\n const { object, part, transform } = request\n const motion = part.motion\n const bounds = part.bounds\n if (!bounds || (motion.kind !== 'hinge' && motion.kind !== 'slide')) return undefined\n const isHinge = motion.kind === 'hinge'\n const axisLocal = rotY(motion.axis ?? [0, 1, 0], part.ry ?? 0)\n const axis = rotY(axisLocal, transform.ry)\n const pivot = localToWorld(transform, part.pivot)\n const half: Vec3 = [(bounds[3] - bounds[0]) / 2, (bounds[4] - bounds[1]) / 2, (bounds[5] - bounds[2]) / 2]\n const centre = localToWorld(transform, [(bounds[0] + bounds[3]) / 2, (bounds[1] + bounds[4]) / 2, (bounds[2] + bounds[5]) / 2])\n const rotation = quatY(transform.ry)\n const range = isHinge ? (motion.angle ?? Math.PI / 2) : (motion.distance ?? 0.4)\n const speed = motion.speed ?? 2.5\n const frame = options.frameOf?.(object) ?? world.createBody({ shape: { kind: 'box', half: [0.01, 0.01, 0.01] }, motion: 'static', position: pivot, layer: 'static', user: -3 })\n const ownsFrame = options.frameOf?.(object) === undefined\n const mass = options.leafMass?.(object, part) ?? Math.max(MIN_LEAF_MASS, 8 * half[0] * half[1] * half[2] * HOLLOW_DOOR_DENSITY)\n const leaf = world.createBody({ shape: { kind: 'box', half }, motion: 'dynamic', mass, position: centre, rotation, layer: 'prop', allowSleep: true, user: -3 })\n world.ignorePair(frame, leaf, true)\n const limits = { min: Math.min(0, range), max: Math.max(0, range) }\n const breakImpulse = options.breakImpulse?.(object, part)\n const joint = world.createJoint(\n isHinge\n ? { kind: 'hinge', a: frame, b: leaf, point: pivot, axis, normal: perpendicularTo(axis), ...limits, friction: HINGE_HOLD_NM, ...(breakImpulse === undefined ? {} : { breakImpulse }) }\n : { kind: 'slider', a: frame, b: leaf, point: pivot, axis, ...limits, friction: SLIDE_HOLD_N, ...(breakImpulse === undefined ? {} : { breakImpulse }) },\n )\n return createLeafDriver({ world, leaf, frame, ownsFrame, joint, onDispose: request.onDispose, drive: { isHinge, axis, pivot, centre, range, speed, base: rotation } })\n}\n\n"],"mappings":";AAOO,IAAM,oBAAoB;AAEjC,IAAM,gBAAgB;AAEtB,IAAM,UAAU;AAEhB,IAAM,aAAa;AAwBZ,SAAS,sBAAsB,MAAkE;AACtG,QAAM,WAAW,IAAI,KAAK,KAAK,YAAY,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC;AACtF,QAAM,SAAmB,CAAC;AAC1B,aAAW,WAAW,KAAK,YAAY,CAAC,GAAG;AACzC,QAAI,QAAQ,SAAS,QAAS;AAC9B,UAAM,UAAU,SAAS,IAAI,QAAQ,MAAM;AAC3C,QAAI,CAAC,SAAS,KAAM;AACpB,WAAO,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,MAAM,QAAQ,KAAK,GAAG,MAAM,GAAG,MAAM,MAAM,CAAC;AAAA,EAC5F;AACA,SAAO;AAAA,IACL,MAAM,OAAO,SAAS;AAAA,IACtB,OAAO,IAAI,SAAS;AAClB,YAAM,MAAwB,CAAC;AAC/B,iBAAW,KAAK,QAAQ;AACtB,cAAM,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,QAAQ,EAAE,QAAQ,IAAI,CAAC,CAAC;AAC7D,YAAI,EAAE,QAAQ,SAAS,SAAS;AAC9B,gBAAM,OAAO,QAAQ;AACrB,cAAI,QAAQ,CAAC,EAAE,KAAM,GAAE,OAAO;AAC9B,YAAE,OAAO;AACT,cAAI,EAAE,QAAQ,EAAG;AACjB,YAAE,OAAO,KAAK,IAAI,GAAG,EAAE,OAAO,EAAE;AAChC,cAAI,KAAK,EAAE,SAAS,EAAE,SAAS,WAAW,KAAK,IA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Aa,EAAG;AAAA,EAC1J;AACA,SAAO,iBAAiB,EAAE,OAAO,MAAM,OAAO,WAAW,OAAO,WAAW,QAAQ,WAAW,OAAO,EAAE,SAAS,MAAM,OAAO,QAAQ,OAAO,OAAO,MAAM,SAAS,EAAE,CAAC;AACvK;","names":["pose","cross","target","add","local","volume","sub","pos","destroyed","PUSH_GAIN","pose","centre","cross"]}
|
|
1
|
+
{"version":3,"sources":["../src/fixture-emitters.ts","../src/colliders.ts","../src/rng.ts","../src/loot.ts","../src/locale.ts","../src/math.ts","../src/world.ts","../src/engine-chain.ts","../src/engine-soft.ts","../src/engine-leaf.ts","../src/engine-parts.ts","../src/fits-volume.ts","../src/object-uses.ts","../src/object-controls.ts"],"sourcesContent":["// The water a piece runs while its handle is worked, for a host that moves the parts itself (a test room plays the part's clip, a game its own animation) and has\n// no interactables world: from the piece's spec and how open each part is now, which of its water emitters run and how hard. A tap runs as far as its handle\n// is turned; a flush runs for its seconds once its button goes down, whatever the button does next. Pure: no three.js, object-local, no allocation per call once\n// warmed up but the answer list.\nimport type { EmitterSpec, FixtureSpec, ObjectSpec } from './types'\n\n/** Seconds a flush runs once its button goes down (the interactables world's own flush time). */\nexport const FLUSH_RUN_SECONDS = 2\n/** How open a handle has to be before the water starts, 0..1: a tap barely touched drips nothing. */\nconst START_OPENING = 0.05\n/** A flush button counts as pressed past this far down. */\nconst PRESSED = 0.5\n/** Seconds the end of a flush takes to die down. */\nconst FLUSH_FADE = 0.4\n\n/** One emitter running now, object-local, with its strength 0..1. */\nexport interface RunningEmitter {\n readonly emitter: EmitterSpec\n readonly intensity: number\n}\n\nexport interface FixtureEmitters {\n /** The water emitters of the piece that run now: `opening(part)` is how open that part is, 0 closed to 1 open. Advances the flushes by `dt` seconds. */\n update(dt: number, opening: (part: string) => number): RunningEmitter[]\n /** Whether the piece has any emitter a handle runs (a sink, a shower, a toilet): a host can skip the others. */\n readonly runs: boolean\n}\n\ninterface Driven {\n readonly emitter: EmitterSpec\n readonly fixture: FixtureSpec & { part: string }\n /** Flush only: seconds of run left, and whether the button was down the last time. */\n left: number\n down: boolean\n}\n\n/** The driver of one piece's water emitters by its handles. */\nexport function createFixtureEmitters(spec: Pick<ObjectSpec, 'emitters' | 'fixtures'>): FixtureEmitters {\n const fixtures = new Map((spec.fixtures ?? []).map((fixture) => [fixture.id, fixture]))\n const driven: Driven[] = []\n for (const emitter of spec.emitters ?? []) {\n if (emitter.kind !== 'water') continue\n const fixture = fixtures.get(emitter.source)\n if (!fixture?.part) continue\n driven.push({ emitter, fixture: { ...fixture, part: fixture.part }, left: 0, down: false })\n }\n return {\n runs: driven.length > 0,\n update(dt, opening) {\n const out: RunningEmitter[] = []\n for (const d of driven) {\n const open = Math.min(1, Math.max(0, opening(d.fixture.part)))\n if (d.fixture.kind === 'flush') {\n const down = open >= PRESSED\n if (down && !d.down) d.left = FLUSH_RUN_SECONDS\n d.down = down\n if (d.left <= 0) continue\n d.left = Math.max(0, d.left - dt)\n out.push({ emitter: d.emitter, intensity: Math.min(1, (d.left + 1e-6) / FLUSH_FADE) })\n continue\n }\n if (open > START_OPENING) out.push({ emitter: d.emitter, intensity: open })\n }\n return out\n },\n }\n}\n","import type { ColliderOptions, WorldCollider } from './types'\n\ninterface Box {\n ids: string[]\n object: string\n u0: number\n u1: number\n v0: number\n v1: number\n y0: number\n y1: number\n}\n\nconst volume = (b: Box): number => (b.u1 - b.u0) * (b.v1 - b.v0) * (b.y1 - b.y0)\nconst overlap = (a0: number, a1: number, b0: number, b1: number): number => Math.max(0, Math.min(a1, b1) - Math.max(a0, b0))\n\nfunction tryMerge(a: Box, b: Box, gap: number, slack: number): Box | null {\n if (a.u0 - gap > b.u1 || b.u0 - gap > a.u1) return null\n if (a.v0 - gap > b.v1 || b.v0 - gap > a.v1) return null\n if (a.y0 - gap > b.y1 || b.y0 - gap > a.y1) return null\n const u0 = Math.min(a.u0, b.u0)\n const u1 = Math.max(a.u1, b.u1)\n const v0 = Math.min(a.v0, b.v0)\n const v1 = Math.max(a.v1, b.v1)\n const y0 = Math.min(a.y0, b.y0)\n const y1 = Math.max(a.y1, b.y1)\n const hull = (u1 - u0) * (v1 - v0) * (y1 - y0)\n const common = overlap(a.u0, a.u1, b.u0, b.u1) * overlap(a.v0, a.v1, b.v0, b.v1) * overlap(a.y0, a.y1, b.y0, b.y1)\n const real = volume(a) + volume(b) - common\n if (hull > real * (1 + slack) + 1e-9) return null\n return { ids: [...a.ids, ...b.ids], object: a.object, u0, u1, v0, v1, y0, y1 }\n}\n\n/**\n * Union overlapping or adjacent colliders of the same object (same rotation) into fewer OBBs.\n * A merge happens only when the merged box adds at most `slack` extra volume over the real union, so coverage is never lost\n * and never grows noticeably. Colliders of different objects or rotations are left alone.\n */\nexport function mergeColliders(list: WorldCollider[], options: Pick<ColliderOptions, 'gap' | 'slack'> = {}): WorldCollider[] {\n const gap = options.gap ?? 0.02\n const slack = options.slack ?? 0.1\n const groups = new Map<string, WorldCollider[]>()\n for (const c of list) {\n const key = `${c.object}|${Math.round(c.ry * 1000)}`\n const g = groups.get(key)\n if (g) g.push(c)\n else groups.set(key, [c])\n }\n const out: WorldCollider[] = []\n for (const g of groups.values()) {\n const ry = g[0]?.ry ?? 0\n const cs = Math.cos(ry)\n const sn = Math.sin(ry)\n let boxes: Box[] = g.map((c) => {\n const u = c.cx * cs - c.cz * sn\n const v = c.cx * sn + c.cz * cs\n return { ids: [c.id], object: c.object, u0: u - c.hw, u1: u + c.hw, v0: v - c.hd, v1: v + c.hd, y0: c.y0, y1: c.y1 }\n })\n let changed = boxes.length > 1\n while (changed) {\n changed = false\n outer: for (let i = 0; i < boxes.length; i++) {\n for (let j = i + 1; j < boxes.length; j++) {\n const m = tryMerge(boxes[i] as Box, boxes[j] as Box, gap, slack)\n if (!m) continue\n boxes = boxes.filter((_, k) => k !== i && k !== j)\n boxes.push(m)\n changed = true\n break outer\n }\n }\n }\n for (const b of boxes) {\n const u = (b.u0 + b.u1) / 2\n const v = (b.v0 + b.v1) / 2\n out.push({\n id: b.ids.length === 1 ? (b.ids[0] as string) : `${b.ids[0]}+${b.ids.length - 1}`,\n object: b.object,\n cx: u * cs + v * sn,\n cz: -u * sn + v * cs,\n hw: (b.u1 - b.u0) / 2,\n hd: (b.v1 - b.v0) / 2,\n ry,\n y0: b.y0,\n y1: b.y1,\n })\n }\n }\n return out\n}\n","/** FNV-1a hash of a string to a 32-bit unsigned integer. */\nexport function hashString(text: string): number {\n let h = 2166136261\n for (let i = 0; i < text.length; i++) {\n h ^= text.charCodeAt(i)\n h = Math.imul(h, 16777619)\n }\n return h >>> 0\n}\n\n/** Deterministic random generator (mulberry32). Returns a function producing floats in [0, 1). Numbers and strings are accepted as seeds. */\nexport function rng(seed: number | string = 1): () => number {\n let a = (typeof seed === 'number' ? Math.floor(seed) >>> 0 : hashString(seed)) || 0x9e3779b9\n return () => {\n a = (a + 0x6d2b79f5) >>> 0\n let t = a\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n","import { rng } from './rng'\nimport type { ItemCatalog, ItemStack, LootTables, SlotSpec, Vec3 } from './types'\n\n/** True when an item of `size` [w, h, d] fits in a slot of `max`; width and depth may be swapped (the item is turned). */\nexport function fitsSize(size: Vec3, max: Vec3): boolean {\n const eps = 1e-9\n if (size[1] > max[1] + eps) return false\n return (size[0] <= max[0] + eps && size[2] <= max[2] + eps) || (size[2] <= max[0] + eps && size[0] <= max[2] + eps)\n}\n\n/** Does the item type fit the slot. Types missing from the catalog are accepted (the host owns unknown items). */\nexport function fitsSlot(type: string, slot: SlotSpec, items?: ItemCatalog): boolean {\n const def = items?.[type]\n return def ? fitsSize(def.size, slot.max) : true\n}\n\n/**\n * Deterministic contents for a container: one entry per slot. A slot is filled with probability `fill`; the entry is a weighted pick\n * among the table entries whose item fits the slot. Same seed, same table and same slots always give the same result.\n */\nexport function generateLoot(\n tables: LootTables | undefined,\n tableId: string,\n slots: SlotSpec[],\n seed: number | string,\n items?: ItemCatalog,\n): Array<ItemStack | null> {\n const table = tables?.[tableId]\n const out: Array<ItemStack | null> = slots.map(() => null)\n if (!table) return out\n const rand = rng(seed)\n slots.forEach((slot, i) => {\n // Always draw the same number of random values per slot so a change in one slot does not shift the others.\n const roll = rand()\n const pick = rand()\n const q = rand()\n if (roll >= table.fill) return\n const candidates = table.entries.filter((e) => e.weight > 0 && fitsSlot(e.type, slot, items))\n const total = candidates.reduce((s, e) => s + e.weight, 0)\n if (total <= 0) return\n let r = pick * total\n let chosen = candidates[candidates.length - 1]\n for (const e of candidates) {\n r -= e.weight\n if (r < 0) {\n chosen = e\n break\n }\n }\n const [lo, hi] = chosen.qty ?? [1, 1]\n const def = items?.[chosen.type]\n const stackMax = def ? (def.stack ?? 1) : Number.POSITIVE_INFINITY\n const qty = Math.max(1, Math.min(stackMax, lo + Math.floor(q * (hi - lo + 1))))\n out[i] = { type: chosen.type, qty }\n })\n return out\n}\n","import type { InteractablesLocale, Strings } from './types'\n\n/** Engine-level prompts and messages. Content packs add their own keys through `WorldOptions.strings`. */\nexport const locales: Record<InteractablesLocale, Strings> = {\n en: {\n 'prompt.open': 'Open {name}',\n 'prompt.close': 'Close {name}',\n 'prompt.turn_on': 'Turn on {name}',\n 'prompt.turn_off': 'Turn off {name}',\n 'prompt.take': 'Take',\n 'prompt.sit': 'Sit',\n 'prompt.lie_down': 'Lie down',\n 'prompt.get_up': 'Get up',\n 'prompt.light': 'Light',\n 'prompt.change_channel': 'Change channel',\n 'prompt.read': 'Read',\n 'prompt.breaker_on': 'Switch on {circuit}',\n 'prompt.breaker_off': 'Switch off {circuit}',\n 'prompt.open_valve': 'Open valve',\n 'prompt.close_valve': 'Close valve',\n no_power: 'No power',\n no_gas: 'No gas',\n no_water: 'No water',\n locked: 'Locked',\n requires_open: 'Open it first',\n already_lit: 'Already lit',\n needs_ignition: 'Light it first',\n turn_on_first: 'Turn it on first',\n empty: 'Empty',\n full: 'Full',\n 'use.put_in': 'Put {item} in {name}',\n 'use.put_in.none': 'Put what you hold in {name}',\n 'use.empty': 'Empty {name}',\n 'use.fill': 'Fill the {bowl} bowl',\n 'use.program.stop': 'Stop {name} ({left} left)',\n 'use.relieve.urine': 'Pee',\n 'use.relieve.feces': 'Poo',\n 'bowl.food': 'food',\n 'bowl.water': 'water',\n hand_empty: 'Your hand is empty',\n not_fit: '{item} does not fit in {name}',\n not_accepted: '{item} does not go in the {bowl} bowl',\n bowl_full: 'The {bowl} bowl is already full',\n needs_closed: 'Close it first',\n already_soiled: 'Flush first',\n done_put_in: '{item} went into {name}',\n done_empty: '{name} emptied ({n} things)',\n done_fill: 'The {bowl} bowl is full',\n done_program: '{name}: {program} started ({time})',\n done_program_end: '{name}: {program} finished',\n done_program_stop: '{name} stopped',\n done_relieve_urine: 'You peed in {name}',\n done_relieve_feces: 'You pooed in {name}',\n done_clean: '{name} flushed clean',\n },\n 'pt-BR': {\n 'prompt.open': 'Abrir {name}',\n 'prompt.close': 'Fechar {name}',\n 'prompt.turn_on': 'Ligar {name}',\n 'prompt.turn_off': 'Desligar {name}',\n 'prompt.take': 'Pegar',\n 'prompt.sit': 'Sentar',\n 'prompt.lie_down': 'Deitar',\n 'prompt.get_up': 'Levantar',\n 'prompt.light': 'Acender',\n 'prompt.change_channel': 'Trocar de canal',\n 'prompt.read': 'Ler',\n 'prompt.breaker_on': 'Ligar {circuit}',\n 'prompt.breaker_off': 'Desligar {circuit}',\n 'prompt.open_valve': 'Abrir registro',\n 'prompt.close_valve': 'Fechar registro',\n no_power: 'Sem energia',\n no_gas: 'Sem gás',\n no_water: 'Sem água',\n locked: 'Trancado',\n requires_open: 'Abra primeiro',\n already_lit: 'Já está aceso',\n needs_ignition: 'Acenda primeiro',\n turn_on_first: 'Ligue primeiro',\n empty: 'Vazio',\n full: 'Cheio',\n 'use.put_in': 'Pôr {item} em {name}',\n 'use.put_in.none': 'Pôr o que está na mão em {name}',\n 'use.empty': 'Esvaziar {name}',\n 'use.fill': 'Encher o pote de {bowl}',\n 'use.program.stop': 'Parar {name} (faltam {left})',\n 'use.relieve.urine': 'Fazer xixi (1)',\n 'use.relieve.feces': 'Fazer cocô (2)',\n 'bowl.food': 'ração',\n 'bowl.water': 'água',\n hand_empty: 'A mão está vazia',\n not_fit: '{item} não cabe em {name}',\n not_accepted: '{item} não vai no pote de {bowl}',\n bowl_full: 'O pote de {bowl} já está cheio',\n needs_closed: 'Feche primeiro',\n already_soiled: 'Dê a descarga primeiro',\n done_put_in: '{item} foi para dentro de {name}',\n done_empty: '{name} esvaziado ({n} coisas)',\n done_fill: 'O pote de {bowl} está cheio',\n done_program: '{name}: {program} começou ({time})',\n done_program_end: '{name}: {program} terminou',\n done_program_stop: '{name} parou',\n done_relieve_urine: 'Você fez xixi em {name}',\n done_relieve_feces: 'Você fez cocô em {name}',\n done_clean: 'Descarga dada: {name} limpo',\n },\n}\n\n/** Pick a built-in locale for an arbitrary tag (`pt`, `pt-br`, `en-GB`...). Unknown tags give `en`. */\nexport function pickLocale(locale: string | undefined): InteractablesLocale {\n if (!locale) return 'en'\n const l = locale.toLowerCase()\n if (l === 'pt-br' || l === 'pt') return 'pt-BR'\n return 'en'\n}\n\n/**\n * Merged table for a locale: built-in `en`, then the built-in table of `locale`, then the extra strings for `en` and for `locale`.\n * Lookup therefore falls back to English, and the caller never gets undefined for engine keys.\n */\nexport function resolveStrings(locale?: string, extra?: Partial<Record<InteractablesLocale, Strings>>): Strings {\n const loc = pickLocale(locale)\n return { ...locales.en, ...locales[loc], ...(extra?.en ?? {}), ...(loc === 'en' ? {} : (extra?.[loc] ?? {})) }\n}\n\n/** Replace `{name}` placeholders. Unknown placeholders are left untouched. */\nexport function format(text: string, vars?: Record<string, string | number>): string {\n if (!vars) return text\n return text.replace(/\\{(\\w+)\\}/g, (m, k: string) => (k in vars ? String(vars[k]) : m))\n}\n","import type { Motion, Transform, Vec3 } from './types'\n\nexport interface Pose {\n /** Translation relative to the pivot. */\n position: Vec3\n /** Rotation around `axis` (in the part frame) by `angle` radians. */\n rotation: { axis: Vec3; angle: number }\n scale: Vec3\n}\n\nconst DEFAULT_AXIS: Vec3 = [0, 1, 0]\n\n/**\n * Pose of a part at animation value `t` (0..1), relative to its pivot, so any renderer can apply it:\n * `position`, then `rotation` around the pivot, then `scale` along the axis.\n */\nexport function poseOf(motion: Motion, t: number): Pose {\n const tt = Math.max(0, Math.min(1, t))\n const axis = motion.axis ?? DEFAULT_AXIS\n const pose: Pose = { position: [0, 0, 0], rotation: { axis: [axis[0], axis[1], axis[2]], angle: 0 }, scale: [1, 1, 1] }\n switch (motion.kind) {\n case 'hinge':\n case 'rocker':\n case 'knob':\n pose.rotation.angle = (motion.angle ?? Math.PI / 2) * tt\n break\n case 'slide': {\n const d = (motion.distance ?? 0.4) * tt\n pose.position = [axis[0] * d, axis[1] * d, axis[2] * d]\n break\n }\n case 'scale': {\n const k = 1 + ((motion.scale ?? 0.2) - 1) * tt\n pose.scale = [axis[0] !== 0 ? k : 1, axis[1] !== 0 ? k : 1, axis[2] !== 0 ? k : 1]\n break\n }\n }\n return pose\n}\n\n/** Rotate a vector around +y by `ry` radians (same convention as three.js `rotation.y`). */\nexport function rotY(v: Vec3, ry: number): Vec3 {\n const c = Math.cos(ry)\n const s = Math.sin(ry)\n return [c * v[0] + s * v[2], v[1], -s * v[0] + c * v[2]]\n}\n\n/** Object-local point to world space. */\nexport function localToWorld(transform: Transform, v: Vec3): Vec3 {\n const r = rotY(v, transform.ry)\n return [transform.x + r[0], transform.y + r[1], transform.z + r[2]]\n}\n\n/** World point to object-local space. */\nexport function worldToLocal(transform: Transform, v: Vec3): Vec3 {\n return rotY([v[0] - transform.x, v[1] - transform.y, v[2] - transform.z], -transform.ry)\n}\n\n/** Rodrigues rotation of `v` around a unit-length-normalised `axis` by `angle`. */\nexport function rotateAxis(v: Vec3, axis: Vec3, angle: number): Vec3 {\n const len = Math.hypot(axis[0], axis[1], axis[2]) || 1\n const k: Vec3 = [axis[0] / len, axis[1] / len, axis[2] / len]\n const c = Math.cos(angle)\n const s = Math.sin(angle)\n const dot = k[0] * v[0] + k[1] * v[1] + k[2] * v[2]\n const cross: Vec3 = [k[1] * v[2] - k[2] * v[1], k[2] * v[0] - k[0] * v[2], k[0] * v[1] - k[1] * v[0]]\n return [v[0] * c + cross[0] * s + k[0] * dot * (1 - c), v[1] * c + cross[1] * s + k[1] * dot * (1 - c), v[2] * c + cross[2] * s + k[2] * dot * (1 - c)]\n}\n\nexport function clamp(v: number, lo: number, hi: number): number {\n return v < lo ? lo : v > hi ? hi : v\n}\n\nexport function dist3(a: Vec3, b: Vec3): number {\n return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2])\n}\n","import { FLUSH_RUN_SECONDS } from './fixture-emitters'\nimport { mergeColliders } from './colliders'\nimport { fitsSlot, generateLoot } from './loot'\nimport { format, resolveStrings } from './locale'\nimport type { PartDriver, SoftDriver } from './part-physics'\nimport { clamp, dist3, localToWorld, rotateAxis, rotY, worldToLocal } from './math'\nimport type {\n ActiveEmitter,\n BurnerSpec,\n ColliderOptions,\n DeviceSpec,\n FixtureSpec,\n FuelSourceSpec,\n Interactable,\n InteractionSpec,\n ItemStack,\n ObjectSpec,\n PartSpec,\n SeatResult,\n SoftSpec,\n TankSpec,\n TargetOptions,\n Transform,\n Vec3,\n World,\n WorldCollider,\n WorldEvent,\n WorldObject,\n WorldOptions,\n WorldState,\n} from './types'\n\n// ---------------------------------------------------------------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------------------------------------------------------------\n\nconst DEFAULT_ACTOR = 'player'\nconst DEFAULT_RADIUS = 1.2\n/** Local id prefix of the `take` a stack in an open container offers (`<object>:take.<container>.<slot>`). */\nconst TAKE_PREFIX = 'take.'\n/** Reach radius of one contained item, metres. */\nconst TAKE_RADIUS = 0.6\nconst AUTO_RANGE = 2\n/** How far behind a socket's face (m) a plug may be and still take it: a plug on the wall's other side is a wall's thickness (10 cm or more) behind it. */\nconst SOCKET_BEHIND = 0.05\nconst SMOKE_TAIL = 20\nconst FLUSH_SECONDS = FLUSH_RUN_SECONDS\nconst ACTOR_HEIGHT = 1.7\nconst PUSH_GAIN = 1.2\nconst SWEEP_STEPS = 24\nconst FLOW_DEFAULTS: Record<string, number> = { tap: 6, shower: 8, utility_sink: 6, flush: 0, hose: 10, filter: 1 }\n\n// ---------------------------------------------------------------------------------------------------------------------------------\n// Internal state\n// ---------------------------------------------------------------------------------------------------------------------------------\n\ninterface PartState {\n spec: PartSpec\n t: number\n target: number\n maxT: number\n /** With `WorldOptions.partPhysics`: the engine moves the part, and `t` is read from it. */\n driver?: PartDriver\n /** The target the driver was last told (`aim`). */\n commanded?: number\n /** The driver is going to a target: arriving reports the part event. */\n moving?: boolean\n broken?: boolean\n}\n\ninterface DeviceState {\n spec: DeviceSpec\n on: boolean\n channel: number\n}\n\ninterface FuelState {\n spec: FuelSourceSpec\n level: number\n}\n\ninterface BurnerState {\n spec: BurnerSpec\n on: boolean\n lit: boolean\n /** Seconds of smoke left after a solid-fuel fire went out. */\n smoke: number\n}\n\ninterface TankState {\n spec: TankSpec\n level: number\n}\n\ninterface FixtureState {\n spec: FixtureSpec\n on: boolean\n flowing: boolean\n /** Delivered / wanted in the last step, 0..1. */\n frac: number\n /** Seconds left of a flush. */\n timer: number\n}\n\ninterface SoftState {\n spec: SoftSpec\n ax: number\n az: number\n vax: number\n vaz: number\n phase: number\n /** With `WorldOptions.partPhysics`: the engine swings the volume (the spring is not used). */\n driver?: SoftDriver\n}\n\ninterface DamageState {\n max: number\n hp: number\n}\n\ninterface ObjState {\n id: string\n public: WorldObject\n spec: ObjectSpec\n parts: Map<string, PartState>\n contents: Map<string, Array<ItemStack | null>>\n devices: Map<string, DeviceState>\n fuels: Map<string, FuelState>\n burners: Map<string, BurnerState>\n tanks: Map<string, TankState>\n fixtures: Map<string, FixtureState>\n soft: Map<string, SoftState>\n hp: Map<string, DamageState>\n interactions: InteractionSpec[]\n}\n\nfunction cloneStack(s: ItemStack | null): ItemStack | null {\n return s ? { type: s.type, qty: s.qty, ...(s.data ? { data: JSON.parse(JSON.stringify(s.data)) as Record<string, unknown> } : {}) } : null\n}\n\nfunction humanize(id: string): string {\n const s = id.replace(/[_-]+/g, ' ').trim()\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\n// ---------------------------------------------------------------------------------------------------------------------------------\n// World\n// ---------------------------------------------------------------------------------------------------------------------------------\n\nexport function createWorld(options: WorldOptions = {}): World {\n const seed = options.seed ?? 1\n const objs = new Map<string, ObjState>()\n const breakers = new Map<string, boolean>()\n const seats = new Map<string, { object: string; seat: string }>()\n const plugs = new Map<string, string | null>()\n let locale = options.locale ?? 'en'\n let table = resolveStrings(locale, options.strings)\n let grid = options.grid ?? true\n let rain = options.rain ?? 0\n let wind: [number, number] = options.wind ? [options.wind[0], options.wind[1]] : [0, 0]\n let defaultTank: string | null = null\n let defaultTankExplicit = false\n let time = 0\n\n // ------------------------------------------------------------------ text & events\n function t(key: string, vars?: Record<string, string | number>): string {\n return format(table[key] ?? key, vars)\n }\n\n function emit(e: WorldEvent): void {\n options.onEvent?.(e)\n }\n\n function message(key: string): void {\n emit({ type: 'message', key, text: t(key) })\n }\n\n // ------------------------------------------------------------------ lookup helpers\n function gid(o: ObjState, local: string): string {\n return `${o.id}:${local}`\n }\n\n /** Find the first entity matching a world-wide id `objectId:localId`. */\n function findGlobal<T>(id: string, pick: (o: ObjState, local: string) => T | undefined): { o: ObjState; value: T; local: string } | null {\n for (const o of objs.values()) {\n if (!id.startsWith(o.id + ':')) continue\n const local = id.slice(o.id.length + 1)\n const value = pick(o, local)\n if (value !== undefined) return { o, value, local }\n }\n return null\n }\n\n function objectOrThrow(id: string): ObjState {\n const o = objs.get(id)\n if (!o) throw new Error(`Unknown object \"${id}\"`)\n return o\n }\n\n function originOf(o: ObjState): Vec3 {\n const tr = o.public.transform\n return [tr.x, tr.y, tr.z]\n }\n\n function toWorld(o: ObjState, v: Vec3): Vec3 {\n return localToWorld(o.public.transform, v)\n }\n\n // ------------------------------------------------------------------ parts\n function openThreshold(p: PartState): number {\n return Math.min(0.5, p.maxT * 0.9)\n }\n\n function isOpen(o: ObjState, partId: string | undefined): boolean {\n if (!partId) return true\n const p = o.parts.get(partId)\n if (!p) return true\n return p.maxT >= 0.1 && p.t >= openThreshold(p)\n }\n\n function targetIsOpen(p: PartState): boolean {\n return p.maxT >= 0.1 && p.target >= openThreshold(p)\n }\n\n function writeT(o: ObjState, p: PartState, v: number): void {\n p.t = v\n o.public.parts[p.spec.id] = v\n }\n\n function gated(o: ObjState, p: PartState): boolean {\n return !!p.spec.requires && o.parts.has(p.spec.requires) && !isOpen(o, p.spec.requires)\n }\n\n function setOnePart(o: ObjState, p: PartState, target: number, instant: boolean): void {\n const next = clamp(target, 0, p.maxT)\n const changed = next !== p.target\n p.target = next\n if (instant) {\n p.driver?.snap(next)\n p.commanded = next\n writeT(o, p, next)\n }\n if (changed || instant) emit({ type: 'part', object: o.id, part: p.spec.id, t: p.t, target: p.target })\n }\n\n function setPartTarget(o: ObjState, partId: string, target: number, instant = false): void {\n const p = o.parts.get(partId)\n if (!p) return\n const group = p.spec.group\n const members = group ? [...o.parts.values()].filter((q) => q.spec.group === group) : [p]\n for (const q of members) {\n setOne(o, q, target, instant)\n }\n }\n\n function setOne(o: ObjState, p: PartState, target: number, instant: boolean): void {\n setOnePart(o, p, target, instant)\n // a part that other parts require closes them with it (the drawer behind a door closes with the door)\n if (!targetIsOpen(p)) {\n for (const q of o.parts.values()) {\n if (q.spec.requires === p.spec.id && q.target > 0) setPartTarget(o, q.spec.id, 0, instant)\n }\n }\n }\n\n /** Frame of a part right now: rotation (axis in object-local, angle) and translation, both about its pivot. */\n function partFrame(o: ObjState, partId: string | undefined): { pivot: Vec3; axis: Vec3; angle: number; offset: Vec3 } | null {\n if (!partId) return null\n const p = o.parts.get(partId)\n if (!p) return null\n const m = p.spec.motion\n const axis = rotY(m.axis ?? [0, 1, 0], p.spec.ry ?? 0)\n const frame = { pivot: p.spec.pivot, axis, angle: 0, offset: [0, 0, 0] as Vec3 }\n if (m.kind === 'slide') {\n const d = (m.distance ?? 0.4) * p.t\n frame.offset = [axis[0] * d, axis[1] * d, axis[2] * d]\n } else if (m.kind !== 'scale') {\n frame.angle = (m.angle ?? Math.PI / 2) * p.t\n }\n return frame\n }\n\n function applyPart(o: ObjState, partId: string | undefined, local: Vec3): Vec3 {\n const f = partFrame(o, partId)\n if (!f) return local\n const rel: Vec3 = [local[0] - f.pivot[0], local[1] - f.pivot[1], local[2] - f.pivot[2]]\n const r = f.angle !== 0 ? rotateAxis(rel, f.axis, f.angle) : rel\n return [f.pivot[0] + r[0] + f.offset[0], f.pivot[1] + r[1] + f.offset[1], f.pivot[2] + r[2] + f.offset[2]]\n }\n\n /** Moves the full closed-pose slab of a part and returns the largest t whose pose keeps every sampled point clear. */\n function fitBounds(o: ObjState, p: PartState, b: NonNullable<PartSpec['bounds']>, blockedAt: (x: number, z: number) => boolean): number {\n const STEP = 0.05\n const ANGLES = 48\n const m = p.spec.motion\n const axis = rotY(m.axis ?? [0, 1, 0], p.spec.ry ?? 0)\n const lo: Vec3 = [Math.min(b[0], b[3]), Math.min(b[1], b[4]), Math.min(b[2], b[5])]\n const hi: Vec3 = [Math.max(b[0], b[3]), Math.max(b[1], b[4]), Math.max(b[2], b[5])]\n const axisPoints = (i: number): number[] => {\n const n = Math.max(1, Math.ceil((hi[i] - lo[i]) / STEP))\n return Array.from({ length: n + 1 }, (_, k) => lo[i] + ((hi[i] - lo[i]) * k) / n)\n }\n const xs = axisPoints(0)\n const ys = axisPoints(1)\n const zs = axisPoints(2)\n // `blocked` only sees x/z, so only the floor footprint matters. About a vertical axis (and for slides) y never changes\n // the footprint, so the x/z outline is enough; otherwise the footprint boundary is the projection of the box edges.\n const flat = m.kind === 'slide' || Math.abs(axis[1]) > 0.999\n const seen = new Set<string>()\n const pts: Vec3[] = []\n const add = (x: number, y: number, z: number): void => {\n const key = `${x.toFixed(5)},${y.toFixed(5)},${z.toFixed(5)}`\n if (seen.has(key)) return\n seen.add(key)\n pts.push([x, y, z])\n }\n if (flat) {\n for (const x of xs) for (const z of [lo[2], hi[2]]) add(x, lo[1], z)\n for (const z of zs) for (const x of [lo[0], hi[0]]) add(x, lo[1], z)\n } else {\n for (const x of xs) for (const y of [lo[1], hi[1]]) for (const z of [lo[2], hi[2]]) add(x, y, z)\n for (const y of ys) for (const x of [lo[0], hi[0]]) for (const z of [lo[2], hi[2]]) add(x, y, z)\n for (const z of zs) for (const x of [lo[0], hi[0]]) for (const y of [lo[1], hi[1]]) add(x, y, z)\n }\n const tr = o.public.transform\n const pivot = p.spec.pivot\n for (let i = 1; i <= ANGLES; i++) {\n const tt = i / ANGLES\n const angle = m.kind === 'slide' ? 0 : (m.angle ?? Math.PI / 2) * tt\n const d = m.kind === 'slide' ? (m.distance ?? 0.4) * tt : 0\n for (const [x, y, z] of pts) {\n let q: Vec3 = [x, y, z]\n if (angle !== 0) {\n const r = rotateAxis([x - pivot[0], y - pivot[1], z - pivot[2]], axis, angle)\n q = [pivot[0] + r[0], pivot[1] + r[1], pivot[2] + r[2]]\n }\n const w = localToWorld(tr, [q[0] + axis[0] * d, 0, q[2] + axis[2] * d])\n if (blockedAt(w[0], w[2])) return (i - 1) / ANGLES\n }\n }\n return 1\n }\n\n function fitSweep(objectId: string, partId: string, blocked: (x: number, z: number) => boolean): number {\n const o = objectOrThrow(objectId)\n const p = o.parts.get(partId)\n if (!p) throw new Error(`Unknown part \"${partId}\" on \"${objectId}\"`)\n const sweep = p.spec.sweep\n let result = 1\n const bounds = p.spec.bounds\n const mk = p.spec.motion.kind\n if (bounds && (mk === 'hinge' || mk === 'rocker' || mk === 'knob' || mk === 'slide')) {\n result = fitBounds(o, p, bounds, blocked)\n } else if (sweep) {\n const x0 = Math.min(sweep[0], sweep[2])\n const x1 = Math.max(sweep[0], sweep[2])\n const z0 = Math.min(sweep[1], sweep[3])\n const z1 = Math.max(sweep[1], sweep[3])\n const tr = o.public.transform\n const hit = (lx: number, lz: number): boolean => {\n const w = localToWorld(tr, [lx, 0, lz])\n return blocked(w[0], w[2])\n }\n const m = p.spec.motion\n const axis = rotY(m.axis ?? [0, 1, 0], p.spec.ry ?? 0)\n if (m.kind === 'hinge' || m.kind === 'rocker' || m.kind === 'knob') {\n if (Math.abs(axis[1]) >= 0.5) {\n const angle = m.angle ?? Math.PI / 2\n const total = -angle * Math.sign(axis[1])\n const [px, , pz] = p.spec.pivot\n const cx = (x0 + x1) / 2\n const cz = (z0 + z1) / 2\n const w = x1 - x0\n const d = z1 - z0\n const radius = Math.abs(angle) > 1.7 ? Math.min(w, d) : Math.max(w, d)\n const tol = 0.05\n const inRect = (x: number, z: number) => x >= x0 - tol && x <= x1 + tol && z >= z0 - tol && z <= z1 + tol\n const centered = Math.hypot(cx - px, cz - pz) < 1e-6\n const mid = Math.atan2(cz - pz, cx - px)\n for (let i = 1; i <= SWEEP_STEPS && result === 1; i++) {\n const tt = i / SWEEP_STEPS\n let isHit = false\n if (centered) {\n for (let x = x0; x <= x1 + 1e-9 && !isHit; x += 0.1) for (let z = z0; z <= z1 + 1e-9 && !isHit; z += 0.1) isHit = hit(x, z)\n } else {\n const phi = mid - total / 2 + total * tt\n const steps = Math.max(2, Math.ceil(radius / 0.1))\n for (let k = 1; k <= steps && !isHit; k++) {\n const r = (radius * k) / steps\n const x = px + Math.cos(phi) * r\n const z = pz + Math.sin(phi) * r\n if (inRect(x, z)) isHit = hit(x, z)\n }\n }\n if (isHit) result = (i - 1) / SWEEP_STEPS\n }\n }\n } else if (m.kind === 'slide') {\n const len = Math.hypot(axis[0], axis[2])\n if (len > 1e-6) {\n const dx = axis[0] / len\n const dz = axis[2] / len\n const proj = [x0 * dx + z0 * dz, x1 * dx + z0 * dz, x0 * dx + z1 * dz, x1 * dx + z1 * dz]\n const pmin = Math.min(...proj)\n const pmax = Math.max(...proj)\n const nx = Math.max(1, Math.ceil((x1 - x0) / 0.1))\n const nz = Math.max(1, Math.ceil((z1 - z0) / 0.1))\n for (let i = 1; i <= SWEEP_STEPS && result === 1; i++) {\n const limit = pmin + (pmax - pmin) * (i / SWEEP_STEPS)\n let isHit = false\n for (let a = 0; a <= nx && !isHit; a++) {\n for (let b = 0; b <= nz && !isHit; b++) {\n const x = x0 + ((x1 - x0) * a) / nx\n const z = z0 + ((z1 - z0) * b) / nz\n if (x * dx + z * dz <= limit + 1e-9 && hit(x, z)) isHit = true\n }\n }\n if (isHit) result = (i - 1) / SWEEP_STEPS\n }\n }\n }\n }\n p.maxT = result\n if (p.target > result) p.target = result\n if (p.t > result) writeT(o, p, result)\n return result\n }\n\n // ------------------------------------------------------------------ containers\n function containerOf(o: ObjState, id: string) {\n return o.spec.containers?.find((c) => c.id === id)\n }\n\n function accessible(objectId: string, containerId: string): boolean {\n const o = objs.get(objectId)\n if (!o) return false\n const c = containerOf(o, containerId)\n if (!c) return false\n return isOpen(o, c.access)\n }\n\n function contents(objectId: string, containerId: string): Array<ItemStack | null> {\n return (objs.get(objectId)?.contents.get(containerId) ?? []).map(cloneStack)\n }\n\n function take(objectId: string, containerId: string, slot: number, actor: string = DEFAULT_ACTOR): ItemStack | null {\n const o = objs.get(objectId)\n if (!o) return null\n const list = o.contents.get(containerId)\n if (!list || !accessible(objectId, containerId)) return null\n const stack = list[slot]\n if (!stack) return null\n const def = options.items?.[stack.type]\n if (def && def.pickable === false) return null\n list[slot] = null\n emit({ type: 'pickup', object: objectId, container: containerId, slot, stack: cloneStack(stack) as ItemStack, actor })\n return stack\n }\n\n function put(objectId: string, containerId: string, stack: ItemStack): number | null {\n const o = objs.get(objectId)\n if (!o) return null\n const c = containerOf(o, containerId)\n const list = o.contents.get(containerId)\n if (!c || !list || !accessible(objectId, containerId)) return null\n const maxStack = options.items?.[stack.type]?.stack ?? 1\n for (let i = 0; i < list.length; i++) {\n const cur = list[i]\n if (cur && cur.type === stack.type && !cur.data && !stack.data && cur.qty + stack.qty <= maxStack) {\n cur.qty += stack.qty\n return i\n }\n }\n for (let i = 0; i < list.length; i++) {\n if (!list[i] && fitsSlot(stack.type, c.slots[i], options.items)) {\n list[i] = cloneStack(stack)\n return i\n }\n }\n message('full')\n return null\n }\n\n function slotPosition(objectId: string, containerId: string, slot: number): Vec3 {\n const o = objectOrThrow(objectId)\n const c = containerOf(o, containerId)\n const s = c?.slots[slot]\n if (!c || !s) throw new Error(`Unknown slot ${slot} of \"${containerId}\" on \"${objectId}\"`)\n return toWorld(o, applyPart(o, s.part, s.pos))\n }\n\n // ------------------------------------------------------------------ power\n function rebuildPlugs(): void {\n plugs.clear()\n const sockets: Array<{ id: string; pos: Vec3; circuit?: string; local: string; facing: Vec3 }> = []\n for (const o of objs.values()) {\n for (const s of o.spec.sockets ?? []) {\n const pos = toWorld(o, s.pos)\n const ahead = toWorld(o, [s.pos[0], s.pos[1], s.pos[2] + 1])\n sockets.push({ id: gid(o, s.id), local: s.id, pos, circuit: s.circuit, facing: [ahead[0] - pos[0], ahead[1] - pos[1], ahead[2] - pos[2]] })\n }\n }\n const used = new Set<string>()\n const autos: Array<{ o: ObjState; d: DeviceState }> = []\n for (const o of objs.values()) {\n for (const d of o.devices.values()) {\n const key = gid(o, d.spec.id)\n const want = d.spec.socket\n if (want === undefined || d.spec.circuit) {\n plugs.set(key, null)\n } else if (want === 'auto') {\n plugs.set(key, null)\n autos.push({ o, d })\n } else {\n const s = sockets.find((x) => x.id === want) ?? sockets.find((x) => x.id === gid(o, want)) ?? sockets.find((x) => x.local === want)\n plugs.set(key, s ? s.id : null)\n if (s) used.add(s.id)\n }\n }\n }\n for (const { o, d } of autos) {\n const from = d.spec.plug ? toWorld(o, d.spec.plug) : originOf(o)\n let best: (typeof sockets)[number] | null = null\n let bestD = AUTO_RANGE\n for (const s of sockets) {\n if (used.has(s.id)) continue\n // a socket faces out of its wall (+z): a plug behind its face is on the wall's other side, in the next room, and its cord would cross the wall\n if ((from[0] - s.pos[0]) * s.facing[0] + (from[1] - s.pos[1]) * s.facing[1] + (from[2] - s.pos[2]) * s.facing[2] < -SOCKET_BEHIND) continue\n const dd = dist3(from, s.pos)\n if (dd <= bestD) {\n best = s\n bestD = dd\n }\n }\n if (best) {\n used.add(best.id)\n plugs.set(gid(o, d.spec.id), best.id)\n }\n }\n }\n\n function breaker(circuit: string): boolean {\n return breakers.get(circuit) ?? true\n }\n\n function devicePowered(o: ObjState, d: DeviceState): boolean {\n if (d.spec.electric === false) return true\n if (!grid) return false\n if (d.spec.circuit) return breaker(d.spec.circuit)\n if (d.spec.socket === undefined) return false\n const sid = plugs.get(gid(o, d.spec.id))\n if (!sid) return false\n const found = findGlobal(sid, (oo, local) => oo.spec.sockets?.find((s) => s.id === local))\n if (!found) return false\n return found.value.circuit ? breaker(found.value.circuit) : true\n }\n\n function getDevice(objectId: string, deviceId: string): { o: ObjState; d: DeviceState } | null {\n const o = objs.get(objectId)\n const d = o?.devices.get(deviceId)\n return o && d ? { o, d } : null\n }\n\n function powerSnapshot(): Map<string, boolean> {\n const m = new Map<string, boolean>()\n for (const o of objs.values()) for (const d of o.devices.values()) m.set(gid(o, d.spec.id), d.on && devicePowered(o, d))\n return m\n }\n\n function emitPowerChanges(before: Map<string, boolean>): void {\n for (const o of objs.values()) {\n for (const d of o.devices.values()) {\n const key = gid(o, d.spec.id)\n const now = d.on && devicePowered(o, d)\n if (before.get(key) !== now && d.on) emit({ type: 'device', object: o.id, device: d.spec.id, on: d.on, powered: devicePowered(o, d), channel: d.spec.kind === 'screen' ? d.channel : undefined })\n }\n }\n }\n\n function setDeviceOn(o: ObjState, d: DeviceState, on: boolean): void {\n d.on = on\n if (d.spec.part) setPartTarget(o, d.spec.part, on ? 1 : 0)\n const powered = devicePowered(o, d)\n emit({ type: 'device', object: o.id, device: d.spec.id, on, powered, channel: d.spec.kind === 'screen' ? d.channel : undefined })\n if (on && !powered) message('no_power')\n }\n\n function setDevice(objectId: string, deviceId: string, on: boolean): boolean {\n const f = getDevice(objectId, deviceId)\n if (!f) return false\n if (f.d.on !== on) setDeviceOn(f.o, f.d, on)\n return true\n }\n\n function setFixture(objectId: string, fixtureId: string, on: boolean): boolean {\n const fx = objs.get(objectId)?.fixtures.get(fixtureId)\n if (!fx) return false\n if (fx.on !== on) toggleFixture(objs.get(objectId) as ObjState, fixtureId)\n return fx.on === on\n }\n\n function setBurner(objectId: string, burnerId: string, on: boolean): boolean {\n const o = objs.get(objectId)\n const b = o?.burners.get(burnerId)\n if (!o || !b) return false\n const isOn = b.on || b.lit\n if (on === isOn) return true\n if (!on) return toggleBurner(o, burnerId)\n return b.spec.needsIgnition ? ignite(o, burnerId) : toggleBurner(o, burnerId)\n }\n\n function resolveDevice(o: ObjState, id: string): { o: ObjState; d: DeviceState } | null {\n if (id.includes(':')) {\n const f = findGlobal(id, (oo, local) => oo.devices.get(local))\n return f ? { o: f.o, d: f.value } : null\n }\n const local = o.devices.get(id)\n if (local) return { o, d: local }\n for (const oo of objs.values()) {\n const d = oo.devices.get(id)\n if (d) return { o: oo, d }\n }\n return null\n }\n\n function switchIsOn(o: ObjState, spec: { part?: string; controls: string[] }): boolean {\n if (spec.part && o.parts.has(spec.part)) return targetIsOpen(o.parts.get(spec.part) as PartState)\n return spec.controls.some((id) => resolveDevice(o, id)?.d.on)\n }\n\n function toggleSwitch(o: ObjState, id: string): boolean {\n const sw = o.spec.switches?.find((s) => s.id === id)\n if (!sw) return false\n const on = !switchIsOn(o, sw)\n if (sw.part) setPartTarget(o, sw.part, on ? 1 : 0)\n let unpowered = false\n for (const ref of sw.controls) {\n const r = resolveDevice(o, ref)\n if (!r) continue\n r.d.on = on\n if (r.d.spec.part) setPartTarget(r.o, r.d.spec.part, on ? 1 : 0)\n const powered = devicePowered(r.o, r.d)\n if (on && !powered) unpowered = true\n emit({ type: 'device', object: r.o.id, device: r.d.spec.id, on, powered })\n }\n emit({ type: 'switch', object: o.id, switch: sw.id, on })\n if (unpowered) message('no_power')\n return true\n }\n\n // ------------------------------------------------------------------ fuel\n function resolveFuel(o: ObjState, b: BurnerState): { o: ObjState; f: FuelState } | null {\n const want = b.spec.fuel\n if (want === 'auto') {\n const from = toWorld(o, b.spec.pos)\n let best: { o: ObjState; f: FuelState } | null = null\n let bestD = AUTO_RANGE\n for (const oo of objs.values()) {\n for (const f of oo.fuels.values()) {\n if (f.spec.kind !== 'gas') continue\n const d = dist3(from, originOf(oo))\n if (d <= bestD) {\n best = { o: oo, f }\n bestD = d\n }\n }\n }\n return best\n }\n if (want.includes(':')) {\n const f = findGlobal(want, (oo, local) => oo.fuels.get(local))\n return f ? { o: f.o, f: f.value } : null\n }\n const local = o.fuels.get(want)\n return local ? { o, f: local } : null\n }\n\n function valveOpen(o: ObjState, f: FuelState): boolean {\n const v = f.spec.valve\n if (!v || !o.parts.has(v)) return true\n return targetIsOpen(o.parts.get(v) as PartState)\n }\n\n function canBurn(b: BurnerState, ref: { o: ObjState; f: FuelState } | null): boolean {\n return !!ref && ref.f.level > 0 && valveOpen(ref.o, ref.f)\n }\n\n function isSolid(ref: { f: FuelState } | null): boolean {\n return !!ref && ref.f.spec.kind !== 'gas'\n }\n\n function emitBurner(o: ObjState, b: BurnerState): void {\n emit({ type: 'burner', object: o.id, burner: b.spec.id, on: b.on, lit: b.lit })\n }\n\n function extinguish(o: ObjState, b: BurnerState, turnOff: boolean): void {\n const ref = resolveFuel(o, b)\n const wasLit = b.lit\n b.lit = false\n if (turnOff) b.on = false\n if (b.spec.part) setPartTarget(o, b.spec.part, b.on ? 1 : 0)\n if (wasLit && isSolid(ref)) b.smoke = SMOKE_TAIL\n emitBurner(o, b)\n }\n\n function toggleBurner(o: ObjState, id: string): boolean {\n const b = o.burners.get(id)\n if (!b) return false\n if (b.on || b.lit) {\n extinguish(o, b, true)\n return true\n }\n if (b.spec.needsIgnition) return false\n const ref = resolveFuel(o, b)\n b.on = true\n b.lit = canBurn(b, ref)\n if (b.lit) b.smoke = 0\n if (b.spec.part) setPartTarget(o, b.spec.part, 1)\n emitBurner(o, b)\n if (!b.lit) message(ref && ref.f.level <= 0 ? 'empty' : 'no_gas')\n return true\n }\n\n function ignite(o: ObjState, id: string): boolean {\n const b = o.burners.get(id)\n if (!b || b.lit) return false\n const ref = resolveFuel(o, b)\n if (!canBurn(b, ref)) {\n message(ref && ref.f.level <= 0 ? 'empty' : 'no_gas')\n return false\n }\n b.on = true\n b.lit = true\n b.smoke = 0\n if (b.spec.part) setPartTarget(o, b.spec.part, 1)\n emitBurner(o, b)\n return true\n }\n\n function toggleFuel(o: ObjState, id: string): boolean {\n const f = o.fuels.get(id)\n if (!f || !f.spec.valve || !o.parts.has(f.spec.valve)) return false\n const p = o.parts.get(f.spec.valve) as PartState\n setPartTarget(o, f.spec.valve, targetIsOpen(p) ? 0 : 1)\n return true\n }\n\n // ------------------------------------------------------------------ water\n function resolveTank(o: ObjState, id: string | undefined): { o: ObjState; t: TankState } | null {\n const want = id === undefined || id === 'auto' ? defaultTank : id\n if (!want) return null\n const f = findGlobal(want, (oo, local) => oo.tanks.get(local))\n if (f) return { o: f.o, t: f.value }\n const local = o.tanks.get(want)\n return local ? { o, t: local } : null\n }\n\n function drawWater(o: ObjState, fx: FixtureState, liters: number): number {\n if (liters <= 0) return 0\n if (options.waterSupply) return Math.max(0, Math.min(liters, options.waterSupply.draw(gid(o, fx.spec.id), liters)))\n const tank = resolveTank(o, fx.spec.tank)\n if (!tank) return 0\n const got = Math.min(liters, tank.t.level)\n tank.t.level -= got\n return got\n }\n\n function emitFixture(o: ObjState, fx: FixtureState): void {\n emit({ type: 'fixture', object: o.id, fixture: fx.spec.id, on: fx.on, flowing: fx.flowing })\n }\n\n function flowOf(fx: FixtureState): number {\n return fx.spec.flow ?? FLOW_DEFAULTS[fx.spec.kind] ?? 6\n }\n\n function stepFixture(o: ObjState, fx: FixtureState, dt: number): void {\n if (!fx.on) return\n if (fx.spec.kind === 'flush') {\n fx.timer -= dt\n if (fx.timer <= 0) {\n fx.on = false\n fx.flowing = false\n fx.frac = 0\n if (fx.spec.part) setPartTarget(o, fx.spec.part, 0)\n emitFixture(o, fx)\n }\n return\n }\n if (dt <= 0) return\n const wanted = (flowOf(fx) / 60) * dt\n const got = drawWater(o, fx, wanted)\n const flowing = got > 1e-9\n fx.frac = wanted > 0 ? Math.min(1, got / wanted) : 0\n if (flowing !== fx.flowing) {\n fx.flowing = flowing\n emitFixture(o, fx)\n }\n }\n\n function toggleFixture(o: ObjState, id: string): boolean {\n const fx = o.fixtures.get(id)\n if (!fx) return false\n if (fx.on) {\n fx.on = false\n fx.flowing = false\n fx.frac = 0\n if (fx.spec.part) setPartTarget(o, fx.spec.part, 0)\n emitFixture(o, fx)\n return true\n }\n fx.on = true\n if (fx.spec.part) setPartTarget(o, fx.spec.part, 1)\n if (fx.spec.kind === 'flush') {\n const volume = fx.spec.volume ?? 6\n const got = drawWater(o, fx, volume)\n fx.flowing = got > 1e-9\n fx.frac = fx.flowing ? 1 : 0\n fx.timer = FLUSH_SECONDS\n if (!fx.flowing) {\n fx.on = false\n if (fx.spec.part) setPartTarget(o, fx.spec.part, 0)\n }\n } else {\n fx.flowing = false\n fx.frac = 0\n stepFixture(o, fx, 1 / 60)\n }\n emitFixture(o, fx)\n if (!fx.flowing) message('no_water')\n return true\n }\n\n // ------------------------------------------------------------------ seats\n function seatTaken(objectId: string, seatId: string): string | null {\n for (const [actor, s] of seats) if (s.object === objectId && s.seat === seatId) return actor\n return null\n }\n\n function stand(actor: string = DEFAULT_ACTOR): Vec3 | null {\n const s = seats.get(actor)\n if (!s) return null\n seats.delete(actor)\n const o = objs.get(s.object)\n const spec = o?.spec.seats?.find((x) => x.id === s.seat)\n emit({ type: 'seat', object: s.object, seat: s.seat, actor, seated: false })\n if (!o || !spec) return null\n return toWorld(o, spec.exit)\n }\n\n function sit(objectId: string, seatId: string, actor: string = DEFAULT_ACTOR): SeatResult | null {\n const o = objs.get(objectId)\n const seat = o?.spec.seats?.find((s) => s.id === seatId)\n if (!o || !seat) return null\n const holder = seatTaken(objectId, seatId)\n if (holder && holder !== actor) return null\n if (seats.has(actor) && !holder) stand(actor)\n seats.set(actor, { object: objectId, seat: seatId })\n const eye = seat.eye ?? (seat.pose === 'lie' ? 0.18 : 0.62)\n emit({ type: 'seat', object: objectId, seat: seatId, actor, seated: true })\n return { eye: toWorld(o, [seat.pos[0], seat.pos[1] + eye, seat.pos[2]]), yaw: o.public.transform.ry + seat.ry + Math.PI, pose: seat.pose }\n }\n\n // ------------------------------------------------------------------ soft volumes\n function push(pos: Vec3, radius: number, vel: Vec3): void {\n for (const o of objs.values()) {\n if (!o.soft.size) continue\n const tr = o.public.transform\n const lp = worldToLocal(tr, pos)\n const lv = rotY(vel, -tr.ry)\n for (const s of o.soft.values()) {\n const [w, h, d] = s.spec.size\n const hx = w / 2\n const hz = Math.max(d, 0.1) / 2\n const dx = Math.max(Math.abs(lp[0] - s.spec.anchor[0]) - hx, 0)\n const dz = Math.max(Math.abs(lp[2] - s.spec.anchor[2]) - hz, 0)\n if (Math.hypot(dx, dz) > radius) continue\n const top = tr.y + s.spec.anchor[1]\n if (pos[1] + ACTOR_HEIGHT < top - h || pos[1] > top) continue\n if (s.driver) {\n s.driver.push(lv)\n if (s.spec.kind === 'panel' && s.spec.part && lv[2] < -0.05 && lp[2] > s.spec.anchor[2]) setPartTarget(o, s.spec.part, 1)\n continue\n }\n const cap = 8\n s.vax = clamp(s.vax - lv[2] * PUSH_GAIN, -cap, cap)\n s.vaz = clamp(s.vaz + lv[0] * PUSH_GAIN, -cap, cap)\n if (s.spec.kind === 'panel' && s.spec.part && lv[2] < -0.05 && lp[2] > s.spec.anchor[2]) setPartTarget(o, s.spec.part, 1)\n }\n }\n }\n\n const swingOut: [number, number] = [0, 0]\n function stepSoft(dt: number): void {\n const sub = Math.max(1, Math.ceil(dt / (1 / 120)))\n const h = dt / sub\n for (const o of objs.values()) {\n if (!o.soft.size) continue\n const wl = rotY([wind[0], 0, wind[1]], -o.public.transform.ry)\n for (const s of o.soft.values()) {\n const k = s.spec.stiffness ?? 30\n const c = s.spec.damping ?? 4\n const max = s.spec.maxAngle ?? 0.7\n if (s.driver) {\n s.driver.swing(swingOut)\n s.ax = swingOut[0]\n s.az = swingOut[1]\n continue\n }\n const gain = s.spec.wind ?? (s.spec.kind === 'panel' ? 0 : 1)\n const gust = gain * (0.6 + 0.4 * Math.sin(time * 1.7 + s.phase)) * 0.1\n const fx = -wl[2] * gust\n const fz = wl[0] * gust\n for (let i = 0; i < sub; i++) {\n s.vax += (-k * s.ax - c * s.vax + fx) * h\n s.vaz += (-k * s.az - c * s.vaz + fz) * h\n s.ax += s.vax * h\n s.az += s.vaz * h\n }\n if (Math.abs(s.ax) > max) {\n s.ax = Math.sign(s.ax) * max\n s.vax = 0\n }\n if (Math.abs(s.az) > max) {\n s.az = Math.sign(s.az) * max\n s.vaz = 0\n }\n }\n }\n }\n\n // ------------------------------------------------------------------ damage\n function damage(objectId: string, target: string, amount: number, _kind?: string): { hp: number; destroyed: boolean } | null {\n const o = objs.get(objectId)\n if (o && options.destruction) {\n const pos = toWorld(o, [0, 0.5, 0])\n const type = _kind === 'gas' ? 'explosive' : _kind === 'fabric' ? 'slash' : 'blunt'\n const result = options.destruction.hitPart(objectId, target, { type, point: pos, energy: Math.max(0, amount), source: 'interactables' }) as { events?: Array<{ type?: string; part?: string }> } | null | undefined\n const destroyed = !!result?.events?.some((e) => e.type === 'fracture' && e.part === target)\n emit({ type: 'damage', object: objectId, target, hp: -1, destroyed })\n return { hp: -1, destroyed }\n }\n const st = o?.hp.get(target)\n if (!o || !st) return null\n if (st.hp <= 0) return { hp: 0, destroyed: true }\n const before = st.hp\n st.hp = Math.max(0, st.hp - Math.max(0, amount))\n const destroyed = st.hp <= 0\n emit({ type: 'damage', object: objectId, target, hp: st.hp, destroyed })\n const pos = toWorld(o, [0, 0.5, 0])\n const fuel = o.fuels.get(target)\n if (fuel && destroyed && fuel.spec.kind === 'gas' && fuel.level > 0) {\n emit({ type: 'explosion', object: objectId, pos, radius: 2 + fuel.level / 5 })\n fuel.level = 0\n }\n const tank = o.tanks.get(target)\n if (tank && before === st.max && st.hp < before) emit({ type: 'leak', object: objectId, target, pos })\n return { hp: st.hp, destroyed }\n }\n\n // ------------------------------------------------------------------ interactions\n function deriveInteractions(spec: ObjectSpec): InteractionSpec[] {\n const out: InteractionSpec[] = []\n const used = new Set<string>()\n const partPos = (id: string | undefined, fallback: Vec3): Vec3 => spec.parts?.find((p) => p.id === id)?.pivot ?? fallback\n const partLabel = (id: string | undefined): string => spec.parts?.find((p) => p.id === id)?.label ?? ''\n const claim = (id: string | undefined) => {\n if (id) used.add(id)\n }\n for (const d of spec.devices ?? []) {\n claim(d.part)\n const pos = d.part ? partPos(d.part, [0, 1, 0]) : (d.plug ?? [0, 1, 0])\n // a hard-wired lamp (circuit, no plug, no part to press) is driven by switches and `setDevice`: it never steals the interact key\n if (d.kind === 'lamp' && !d.part && !d.plug && d.electric !== false) continue\n out.push({ id: `device.${d.id}`, pos, action: { do: 'toggle_device', device: d.id }, label: partLabel(d.part) })\n if (d.kind === 'screen' && (d.channels ?? 1) > 1) out.push({ id: `channel.${d.id}`, pos, action: { do: 'cycle_device', device: d.id }, label: '' })\n }\n for (const s of spec.switches ?? []) {\n claim(s.part)\n out.push({ id: `switch.${s.id}`, pos: partPos(s.part, [0, 1.2, 0]), action: { do: 'toggle_switch', switch: s.id }, label: partLabel(s.part) })\n }\n const driven = new Set((spec.devices ?? []).map((d) => d.fixture))\n for (const f of spec.fixtures ?? []) {\n claim(f.part)\n if (driven.has(f.id)) continue\n out.push({ id: `fixture.${f.id}`, pos: f.part ? partPos(f.part, f.outlet) : f.outlet, action: { do: 'toggle_fixture', fixture: f.id }, label: partLabel(f.part) })\n }\n for (const b of spec.burners ?? []) {\n claim(b.part)\n const pos = b.part ? partPos(b.part, b.pos) : b.pos\n if (b.needsIgnition) out.push({ id: `ignite.${b.id}`, pos, action: { do: 'ignite', burner: b.id }, label: '' })\n out.push({ id: `burner.${b.id}`, pos, action: { do: 'toggle_burner', burner: b.id }, label: partLabel(b.part) })\n }\n for (const f of spec.fuels ?? []) {\n if (!f.valve) continue\n claim(f.valve)\n out.push({ id: `fuel.${f.id}`, pos: partPos(f.valve, [0, 0.5, 0]), action: { do: 'toggle_fuel', fuel: f.id }, label: partLabel(f.valve) })\n }\n for (const c of spec.containers ?? []) {\n if (!c.access) out.push({ id: `open.${c.id}`, pos: c.volume.center, action: { do: 'open_container', container: c.id }, label: '' })\n }\n for (const p of spec.parts ?? []) {\n if (used.has(p.id)) continue\n if (p.label) out.push({ id: `part.${p.id}`, pos: p.pivot, action: { do: 'toggle_part', part: p.id }, label: p.label })\n }\n for (const c of spec.containers ?? []) {\n if (c.access && !spec.parts?.find((p) => p.id === c.access)?.label) {\n out.push({ id: `open.${c.id}`, pos: partPos(c.access, c.volume.center), action: { do: 'open_container', container: c.id }, label: '' })\n }\n }\n for (const s of spec.seats ?? []) out.push({ id: `seat.${s.id}`, pos: s.pos, action: { do: 'sit', seat: s.id }, label: '' })\n return out\n }\n\n function typeName(o: ObjState): string {\n return table[`type.${o.spec.type}`] ?? humanize(o.spec.type)\n }\n\n function promptOf(o: ObjState, i: InteractionSpec): { label: string; verb: string; object: string } {\n const a = i.action\n let state: string | null = null\n let def = ''\n switch (a.do) {\n case 'toggle_part': {\n const p = o.parts.get(a.part)\n const open = !!p && targetIsOpen(p)\n state = open ? 'open' : 'closed'\n def = open ? 'prompt.close' : 'prompt.open'\n break\n }\n case 'open_container': {\n const c = containerOf(o, a.container)\n const p = c?.access ? o.parts.get(c.access) : undefined\n const open = p ? targetIsOpen(p) : false\n state = p ? (open ? 'open' : 'closed') : null\n def = open ? 'prompt.close' : 'prompt.open'\n break\n }\n case 'toggle_device': {\n const on = !!o.devices.get(a.device)?.on\n state = on ? 'on' : 'off'\n def = on ? 'prompt.turn_off' : 'prompt.turn_on'\n break\n }\n case 'toggle_switch': {\n const sw = o.spec.switches?.find((s) => s.id === a.switch)\n const on = !!sw && switchIsOn(o, sw)\n state = on ? 'on' : 'off'\n def = on ? 'prompt.turn_off' : 'prompt.turn_on'\n break\n }\n case 'toggle_breaker': {\n const on = breaker(a.circuit)\n state = on ? 'on' : 'off'\n def = on ? 'prompt.breaker_off' : 'prompt.breaker_on'\n break\n }\n case 'toggle_fixture': {\n const on = !!o.fixtures.get(a.fixture)?.on\n state = on ? 'on' : 'off'\n def = on ? 'prompt.turn_off' : 'prompt.turn_on'\n break\n }\n case 'toggle_burner': {\n const b = o.burners.get(a.burner)\n const on = !!b && (b.on || b.lit)\n state = on ? 'on' : 'off'\n def = on ? 'prompt.turn_off' : 'prompt.turn_on'\n break\n }\n case 'toggle_fuel': {\n const f = o.fuels.get(a.fuel)\n const open = !!f && valveOpen(o, f)\n state = open ? 'open' : 'closed'\n def = open ? 'prompt.close_valve' : 'prompt.open_valve'\n break\n }\n case 'take':\n def = 'prompt.take'\n break\n case 'read':\n def = 'prompt.read'\n break\n case 'ignite':\n def = 'prompt.light'\n break\n case 'cycle_device':\n def = 'prompt.change_channel'\n break\n case 'sit': {\n const seat = o.spec.seats?.find((s) => s.id === a.seat)\n const mine = seats.get(DEFAULT_ACTOR)\n def = mine && mine.object === o.id && mine.seat === a.seat ? 'prompt.get_up' : seat?.pose === 'lie' ? 'prompt.lie_down' : 'prompt.sit'\n break\n }\n }\n let key = def\n if (i.label) {\n if (state && table[`${i.label}.${state}`] !== undefined) key = `${i.label}.${state}`\n else if (table[i.label] !== undefined) key = i.label\n }\n const vars = { name: typeName(o), circuit: a.do === 'toggle_breaker' ? (a.name ?? a.circuit) : '' }\n const label = t(key, vars)\n // structured prompt: explicit `<key>.verb` / `<key>.object` entries win; otherwise the first word is the verb and the rest the object\n let verb: string\n let object: string\n if (table[`${key}.verb`] !== undefined) {\n verb = t(`${key}.verb`, vars)\n object = table[`${key}.object`] ? t(`${key}.object`, vars) : vars.name\n } else {\n const sp = label.indexOf(' ')\n verb = sp < 0 ? label : label.slice(0, sp)\n object = sp < 0 ? vars.name : label.slice(sp + 1)\n }\n return { label, verb, object }\n }\n\n /** Locale key of the reason an interaction cannot be used right now, or null when it can. */\n function unavailableReason(o: ObjState, i: InteractionSpec): string | null {\n const a = i.action\n if (!requirementMet(i)) return 'requires_open'\n switch (a.do) {\n case 'toggle_part': {\n const p = o.parts.get(a.part)\n return p && gated(o, p) ? 'requires_open' : null\n }\n case 'open_container': {\n const c = containerOf(o, a.container)\n const p = c?.access ? o.parts.get(c.access) : undefined\n return p && gated(o, p) ? 'requires_open' : null\n }\n case 'toggle_breaker': {\n const rocker = a.part ? o.parts.get(a.part) : undefined\n return rocker && gated(o, rocker) ? 'requires_open' : null\n }\n case 'take':\n case 'read':\n return accessible(o.id, a.container) ? null : 'requires_open'\n case 'ignite':\n return o.burners.get(a.burner)?.lit ? 'already_lit' : null\n case 'toggle_burner': {\n const b = o.burners.get(a.burner)\n return !b?.spec.needsIgnition || b.lit ? null : 'needs_ignition'\n }\n case 'cycle_device': {\n const d = o.devices.get(a.device)\n if (!d || !d.on) return 'turn_on_first'\n return devicePowered(o, d) ? null : 'no_power'\n }\n default:\n return null\n }\n }\n\n function requirementMet(i: InteractionSpec): boolean {\n if (!i.requires) return true\n const p = objs.get(i.requires.object)?.parts.get(i.requires.part)\n return !!p && targetIsOpen(p)\n }\n\n function interactablesOf(o: ObjState): Array<{ item: Interactable; spec: InteractionSpec; o: ObjState }> {\n return o.interactions.map((i) => {\n const id = gid(o, i.id)\n const p = promptOf(o, i)\n const item: Interactable = {\n id,\n object: o.id,\n kind: i.action.do,\n pos: toWorld(o, i.pos),\n radius: i.radius ?? DEFAULT_RADIUS,\n label: p.label,\n verb: p.verb,\n noun: p.object,\n available: true,\n act: (actor) => act(id, actor),\n }\n const reason = unavailableReason(o, i) ?? (options.canInteract?.(item, DEFAULT_ACTOR) === false ? 'locked' : null)\n if (reason) {\n item.available = false\n item.reason = reason\n }\n return { item, spec: i, o }\n })\n }\n\n /**\n * One `take` per stack an open container shows, at its slot (it rides the drawer or door shelf with it): each item inside a piece of furniture is picked up\n * on its own, with one hand. Items the catalogue marks `pickable: false`, and stacks whose data says so, are left out.\n */\n function contentTakes(o: ObjState): Interactable[] {\n if (options.takeContents === false) return []\n const out: Interactable[] = []\n for (const c of o.spec.containers ?? []) {\n const list = o.contents.get(c.id)\n if (!list || !list.some((st) => st !== null) || !accessible(o.id, c.id)) continue\n list.forEach((stack, slot) => {\n if (!stack || options.items?.[stack.type]?.pickable === false || stack.data?.pickable === false) return\n const verb = t('prompt.take')\n const noun = table[`item.${stack.type}`] ?? humanize(stack.type)\n const item: Interactable = {\n id: `${o.id}:${TAKE_PREFIX}${c.id}.${slot}`,\n object: o.id,\n kind: 'take',\n pos: slotPosition(o.id, c.id, slot),\n radius: TAKE_RADIUS,\n label: `${verb} ${noun}`,\n verb,\n noun,\n hands: 1,\n itemType: stack.type,\n available: true,\n act: (actor) => takeAt(o.id, c.id, slot, actor ?? DEFAULT_ACTOR),\n }\n if (options.canInteract?.(item, DEFAULT_ACTOR) === false) {\n item.available = false\n item.reason = 'locked'\n }\n out.push(item)\n })\n }\n return out\n }\n\n function takeAt(objectId: string, containerId: string, slot: number, actor: string): boolean {\n const o = objs.get(objectId)\n if (!o) return false\n const probe = contentTakes(o).find((k) => k.id === `${objectId}:${TAKE_PREFIX}${containerId}.${slot}`)\n if (!probe || options.canInteract?.(probe, actor) === false) return false\n return take(objectId, containerId, slot, actor) !== null\n }\n\n function interactables(): Interactable[] {\n const out: Interactable[] = []\n for (const o of objs.values()) {\n for (const e of interactablesOf(o)) out.push(e.item)\n out.push(...contentTakes(o))\n }\n return out\n }\n\n function target(eye: { x: number; y: number; z: number; yaw: number; pitch: number }, opts: TargetOptions = {}): Interactable | null {\n const reach = opts.reach ?? 1.8\n const cone = opts.cone ?? 0.45\n const dir: Vec3 = [-Math.sin(eye.yaw) * Math.cos(eye.pitch), Math.sin(eye.pitch), -Math.cos(eye.yaw) * Math.cos(eye.pitch)]\n let best: Interactable | null = null\n let bestScore = Infinity\n for (const o of objs.values()) {\n for (const item of [...interactablesOf(o).map((e) => e.item), ...contentTakes(o)]) {\n if (!item.available && !opts.includeUnavailable) continue\n if (opts.kinds && !opts.kinds.includes(item.kind)) continue\n if (opts.filter && !opts.filter(item)) continue\n const v: Vec3 = [item.pos[0] - eye.x, item.pos[1] - eye.y, item.pos[2] - eye.z]\n const d = Math.hypot(v[0], v[1], v[2])\n if (d > reach) continue\n const cos = d < 1e-6 ? 1 : clamp((v[0] * dir[0] + v[1] * dir[1] + v[2] * dir[2]) / d, -1, 1)\n const angle = Math.acos(cos)\n if (angle > cone) continue\n const score = (angle / cone) * 0.6 + (d / reach) * 0.4\n if (score < bestScore) {\n bestScore = score\n best = item\n }\n }\n }\n return best\n }\n\n function act(interactableId: string, actor: string = DEFAULT_ACTOR): boolean {\n let found: { item: Interactable; spec: InteractionSpec; o: ObjState } | null = null\n for (const o of objs.values()) {\n if (!interactableId.startsWith(o.id + ':')) continue\n const local = interactableId.slice(o.id.length + 1)\n if (local.startsWith(TAKE_PREFIX)) {\n const at = contentTakes(o).find((k) => k.id === interactableId)\n if (at) return at.act(actor)\n }\n if (!o.interactions.some((i) => i.id === local)) continue\n found = interactablesOf(o).find((e) => e.spec.id === local) ?? null\n if (found) break\n }\n if (!found) return false\n if (!requirementMet(found.spec)) return false\n if (options.canInteract?.(found.item, actor) === false) return false\n return execute(found.o, found.spec.action, actor)\n }\n\n function execute(o: ObjState, a: InteractionSpec['action'], actor: string): boolean {\n switch (a.do) {\n case 'toggle_part': {\n const p = o.parts.get(a.part)\n if (!p || gated(o, p)) return false\n setPartTarget(o, a.part, targetIsOpen(p) ? 0 : 1)\n return true\n }\n case 'open_container': {\n const c = containerOf(o, a.container)\n if (!c) return false\n if (c.access) return execute(o, { do: 'toggle_part', part: c.access }, actor)\n emit({ type: 'container', object: o.id, container: c.id, open: true })\n return true\n }\n case 'take': {\n if (!accessible(o.id, a.container)) return false\n const list = o.contents.get(a.container)\n if (!list) return false\n const slot = a.slot ?? list.findIndex((s) => s !== null)\n if (slot < 0 || !list[slot]) {\n message('empty')\n return false\n }\n return take(o.id, a.container, slot, actor) !== null\n }\n case 'read': {\n if (!accessible(o.id, a.container)) return false\n const stack = o.contents.get(a.container)?.[a.slot]\n if (!stack) {\n message('empty')\n return false\n }\n const key = typeof stack.data?.text === 'string' ? stack.data.text : null\n if (!key) return false\n message(key)\n return true\n }\n case 'toggle_device': {\n const d = o.devices.get(a.device)\n if (!d) return false\n setDeviceOn(o, d, !d.on)\n return true\n }\n case 'cycle_device': {\n const d = o.devices.get(a.device)\n if (!d || !d.on) return false\n if (!devicePowered(o, d)) {\n message('no_power')\n return false\n }\n d.channel = (d.channel + 1) % Math.max(1, d.spec.channels ?? 1)\n emit({ type: 'device', object: o.id, device: d.spec.id, on: true, powered: true, channel: d.channel })\n return true\n }\n case 'toggle_switch':\n return toggleSwitch(o, a.switch)\n case 'toggle_breaker': {\n const rocker = a.part ? o.parts.get(a.part) : undefined\n if (rocker && gated(o, rocker)) return false\n const on = !breaker(a.circuit)\n if (a.part) setPartTarget(o, a.part, on ? 1 : 0)\n world.power.setBreaker(a.circuit, on)\n return true\n }\n case 'toggle_fixture':\n return toggleFixture(o, a.fixture)\n case 'toggle_burner':\n return toggleBurner(o, a.burner)\n case 'ignite':\n return ignite(o, a.burner)\n case 'toggle_fuel':\n return toggleFuel(o, a.fuel)\n case 'sit': {\n const mine = seats.get(actor)\n if (mine && mine.object === o.id && mine.seat === a.seat) {\n stand(actor)\n return true\n }\n return sit(o.id, a.seat, actor) !== null\n }\n }\n }\n\n // ------------------------------------------------------------------ emitters, mirrors, colliders\n function emitters(): ActiveEmitter[] {\n const out: ActiveEmitter[] = []\n for (const o of objs.values()) {\n for (const e of o.spec.emitters ?? []) {\n let intensity = 0\n const b = o.burners.get(e.source)\n const fx = o.fixtures.get(e.source)\n const dev = o.devices.get(e.source)\n const fuel = o.fuels.get(e.source)\n if (b) {\n const ref = resolveFuel(o, b)\n const frac = ref ? clamp(ref.f.level / ref.f.spec.capacity, 0, 1) : 0\n if (b.lit) intensity = 0.35 + 0.65 * frac\n else if (e.kind === 'smoke' && b.smoke > 0) intensity = 0.6 * (b.smoke / SMOKE_TAIL)\n } else if (fx) {\n if (fx.on && fx.flowing) intensity = fx.frac\n } else if (dev) {\n if (dev.on && devicePowered(o, dev)) intensity = 1\n } else if (fuel) {\n const lit = [...o.burners.values()].some((bb) => bb.lit && resolveFuel(o, bb)?.f === fuel)\n if (lit) intensity = 0.35 + 0.65 * clamp(fuel.level / fuel.spec.capacity, 0, 1)\n }\n if (intensity <= 0) continue\n const dir = rotY(e.dir ?? [0, 1, 0], o.public.transform.ry)\n out.push({ id: gid(o, e.id), object: o.id, kind: e.kind, pos: toWorld(o, e.pos), dir, size: e.size ?? 0.3, ...(e.reach !== undefined ? { reach: e.reach } : {}), ...(e.bowl ? { bowl: e.bowl } : {}), intensity: clamp(intensity, 0, 1) })\n }\n }\n return out\n }\n\n function mirrors(eye: Vec3, maxDistance = 10, count = 4) {\n const out: Array<{ id: string; center: Vec3; normal: Vec3; w: number; h: number; distance: number }> = []\n for (const o of objs.values()) {\n for (const m of o.spec.mirrors ?? []) {\n const center = toWorld(o, applyPart(o, m.part, m.center))\n const f = partFrame(o, m.part)\n const ln = f && f.angle !== 0 ? rotateAxis(m.normal, f.axis, f.angle) : m.normal\n const normal = rotY(ln, o.public.transform.ry)\n const len = Math.hypot(normal[0], normal[1], normal[2]) || 1\n const n: Vec3 = [normal[0] / len, normal[1] / len, normal[2] / len]\n const to: Vec3 = [eye[0] - center[0], eye[1] - center[1], eye[2] - center[2]]\n if (n[0] * to[0] + n[1] * to[1] + n[2] * to[2] <= 0) continue\n const distance = Math.hypot(to[0], to[1], to[2])\n if (distance > maxDistance) continue\n out.push({ id: gid(o, m.id), center, normal: n, w: m.w, h: m.h, distance })\n }\n }\n return out.sort((a, b) => a.distance - b.distance).slice(0, count)\n }\n\n function colliders(opts: ColliderOptions = {}): WorldCollider[] {\n const out: WorldCollider[] = []\n const fixed: WorldCollider[] = []\n for (const o of objs.values()) {\n const tr = o.public.transform\n for (const c of o.spec.colliders ?? []) {\n if (c.part && c.offWhenOpen && (o.parts.get(c.part)?.t ?? 0) > 0.5) continue\n let extra = 0\n if (c.part) {\n const f = partFrame(o, c.part)\n if (f && f.angle !== 0 && Math.abs(f.axis[1]) >= 0.5) extra = f.angle * Math.sign(f.axis[1])\n }\n const center = toWorld(o, applyPart(o, c.part, c.center))\n ;(c.part ? out : fixed).push({\n id: gid(o, c.id),\n object: o.id,\n cx: center[0],\n cz: center[2],\n hw: c.half[0],\n hd: c.half[2],\n ry: tr.ry + (c.ry ?? 0) + extra,\n y0: center[1] - c.half[1],\n y1: center[1] + c.half[1],\n })\n }\n }\n if (opts.merge) return [...mergeColliders(fixed, { gap: opts.gap, slack: opts.slack }), ...out]\n return [...fixed, ...out]\n }\n\n // ------------------------------------------------------------------ update\n /** A part the engine moves: it aims at the target when that changed, then `t` is what the joint says; a broken one stays where it broke. */\n function updateDriven(o: ObjState, p: PartState, dt: number): void {\n const driver = p.driver as PartDriver\n if (p.broken) return\n if (p.commanded !== p.target && !(gated(o, p) && p.target > p.t)) {\n driver.aim(p.target)\n p.commanded = p.target\n p.moving = true\n }\n driver.update(dt)\n if (driver.broken) {\n p.broken = true\n emit({ type: 'broke', object: o.id, part: p.spec.id })\n return\n }\n const next = clamp(driver.read(), 0, p.maxT)\n if (next !== p.t) writeT(o, p, next)\n if (!driver.settled) return\n // let go (or pushed by hand): what the joint holds is the target, so the next interaction toggles from there\n p.target = next\n p.commanded = next\n if (p.moving) emit({ type: 'part', object: o.id, part: p.spec.id, t: next, target: next })\n p.moving = false\n }\n\n function update(dt: number): void {\n if (!(dt > 0)) return\n time += dt\n for (const o of objs.values()) {\n for (const p of o.parts.values()) {\n if (p.driver) {\n updateDriven(o, p, dt)\n continue\n }\n if (p.t === p.target) continue\n if (gated(o, p) && p.target > p.t) continue // a gated part may still close\n const step = (p.spec.motion.speed ?? 2.5) * dt\n const next = p.t < p.target ? Math.min(p.target, p.t + step) : Math.max(p.target, p.t - step)\n writeT(o, p, next)\n if (next === p.target) emit({ type: 'part', object: o.id, part: p.spec.id, t: next, target: p.target })\n }\n }\n stepSoft(dt)\n for (const o of objs.values()) {\n for (const b of o.burners.values()) {\n if (b.lit) {\n const ref = resolveFuel(o, b)\n if (!ref || !valveOpen(ref.o, ref.f)) {\n extinguish(o, b, !!b.spec.needsIgnition)\n } else {\n ref.f.level = Math.max(0, ref.f.level - b.spec.rate * dt)\n if (ref.f.level <= 0) extinguish(o, b, !!b.spec.needsIgnition)\n }\n } else if (b.on && !b.spec.needsIgnition && canBurn(b, resolveFuel(o, b))) {\n // a gas knob left open without gas lights as soon as the bottle valve opens\n b.lit = true\n b.smoke = 0\n emitBurner(o, b)\n } else if (b.smoke > 0) {\n b.smoke = Math.max(0, b.smoke - dt)\n }\n }\n if (rain > 0) {\n for (const tk of o.tanks.values()) {\n if (tk.spec.rainArea) tk.level = Math.min(tk.spec.capacity, tk.level + ((rain * tk.spec.rainArea) / 3600) * dt)\n }\n }\n for (const tk of o.tanks.values()) {\n const st = o.hp.get(tk.spec.id)\n if (st && st.hp < st.max && tk.level > 0) {\n const rate = 0.5 + 2.5 * (1 - st.hp / st.max)\n tk.level = Math.max(0, tk.level - rate * dt)\n }\n }\n }\n for (const o of objs.values()) {\n for (const d of o.devices.values()) {\n const fx = d.spec.fixture ? o.fixtures.get(d.spec.fixture) : undefined\n if (!fx) continue\n const run = d.on && devicePowered(o, d)\n if (fx.on === run) continue\n fx.on = run\n if (!run) {\n fx.flowing = false\n fx.frac = 0\n emitFixture(o, fx)\n }\n }\n for (const fx of o.fixtures.values()) stepFixture(o, fx, dt)\n }\n }\n\n // ------------------------------------------------------------------ add / remove\n function add(id: string, spec: ObjectSpec, transform: Transform): WorldObject {\n if (objs.has(id)) throw new Error(`Object \"${id}\" already exists`)\n const pub: WorldObject = { id, spec, transform: { ...transform }, parts: {} }\n const o: ObjState = {\n id,\n public: pub,\n spec,\n parts: new Map(),\n contents: new Map(),\n devices: new Map(),\n fuels: new Map(),\n burners: new Map(),\n tanks: new Map(),\n fixtures: new Map(),\n soft: new Map(),\n hp: new Map(),\n interactions: spec.interactions ?? deriveInteractions(spec),\n }\n for (const p of spec.parts ?? []) {\n const t0 = clamp(p.t0 ?? 0, 0, 1)\n const driver = options.partPhysics?.attachPart(id, p, pub.transform)\n o.parts.set(p.id, { spec: p, t: t0, target: t0, maxT: 1, ...(driver ? { driver, commanded: t0 } : {}) })\n driver?.snap(t0)\n pub.parts[p.id] = t0\n }\n for (const c of spec.containers ?? []) {\n let list: Array<ItemStack | null>\n if (c.contents) list = c.slots.map((_, i) => cloneStack(c.contents?.[i] ?? null))\n else if (c.loot) list = generateLoot(options.loot, c.loot, c.slots, `${seed}|${id}|${c.id}`, options.items)\n else list = c.slots.map(() => null)\n o.contents.set(c.id, list)\n }\n for (const d of spec.devices ?? []) {\n o.devices.set(d.id, { spec: d, on: !!d.on, channel: 0 })\n if (d.on && d.part) {\n const p = o.parts.get(d.part)\n if (p) {\n p.target = p.maxT\n writeT(o, p, p.maxT)\n }\n }\n }\n for (const f of spec.fuels ?? []) o.fuels.set(f.id, { spec: f, level: clamp(f.level ?? f.capacity, 0, f.capacity) })\n for (const b of spec.burners ?? []) o.burners.set(b.id, { spec: b, on: false, lit: false, smoke: 0 })\n for (const tk of spec.tanks ?? []) o.tanks.set(tk.id, { spec: tk, level: clamp(tk.level ?? tk.capacity, 0, tk.capacity) })\n for (const f of spec.fixtures ?? []) o.fixtures.set(f.id, { spec: f, on: false, flowing: false, frac: 0, timer: 0 })\n let n = 0\n for (const s of spec.soft ?? []) {\n const driver = options.partPhysics?.attachSoft?.(id, s, pub.transform)\n o.soft.set(s.id, { spec: s, ax: 0, az: 0, vax: 0, vaz: 0, phase: (n++ * 2.399963) % (Math.PI * 2), ...(driver ? { driver } : {}) })\n }\n for (const d of spec.damage ?? []) o.hp.set(d.target, { max: d.hp, hp: d.hp })\n objs.set(id, o)\n if (!defaultTankExplicit && defaultTank === null && o.tanks.size) defaultTank = gid(o, [...o.tanks.keys()][0])\n rebuildPlugs()\n return pub\n }\n\n function remove(id: string): void {\n const o = objs.get(id)\n if (!o) return\n for (const [actor, s] of [...seats]) if (s.object === id) seats.delete(actor)\n for (const p of o.parts.values()) p.driver?.dispose()\n for (const s of o.soft.values()) s.driver?.dispose()\n objs.delete(id)\n if (defaultTank && defaultTank.startsWith(id + ':')) defaultTank = null\n rebuildPlugs()\n }\n\n // ------------------------------------------------------------------ save / load\n function serialize(): WorldState {\n const objects: WorldState['objects'] = {}\n for (const o of objs.values()) {\n objects[o.id] = {\n parts: Object.fromEntries([...o.parts].map(([k, p]) => [k, p.t])),\n contents: Object.fromEntries([...o.contents].map(([k, v]) => [k, v.map(cloneStack)])),\n devices: Object.fromEntries([...o.devices].map(([k, d]) => [k, { on: d.on, channel: d.channel }])),\n fuels: Object.fromEntries([...o.fuels].map(([k, f]) => [k, { level: f.level, open: valveOpen(o, f) }])),\n burners: Object.fromEntries([...o.burners].map(([k, b]) => [k, { on: b.on, lit: b.lit }])),\n tanks: Object.fromEntries([...o.tanks].map(([k, tk]) => [k, tk.level])),\n fixtures: Object.fromEntries([...o.fixtures].map(([k, f]) => [k, f.on])),\n hp: Object.fromEntries([...o.hp].map(([k, h]) => [k, h.hp])),\n }\n }\n return {\n version: 1,\n objects,\n grid,\n breakers: Object.fromEntries(breakers),\n seats: Object.fromEntries([...seats].map(([a, s]) => [a, { object: s.object, seat: s.seat }])),\n defaultTank,\n }\n }\n\n function load(state: WorldState): void {\n for (const [id, st] of Object.entries(state.objects)) {\n const o = objs.get(id)\n if (!o) continue\n for (const [k, v] of Object.entries(st.parts)) {\n const p = o.parts.get(k)\n if (p) {\n // keep the limit found by fitSweep: a loaded save must not let a door open through a wall again\n p.target = clamp(v, 0, p.maxT)\n p.driver?.snap(p.target)\n p.commanded = p.target\n writeT(o, p, p.target)\n }\n }\n for (const [k, v] of Object.entries(st.contents)) {\n const c = containerOf(o, k)\n if (c) o.contents.set(k, c.slots.map((_, i) => cloneStack(v[i] ?? null)))\n }\n for (const [k, v] of Object.entries(st.devices)) {\n const d = o.devices.get(k)\n if (d) {\n d.on = v.on\n d.channel = v.channel\n }\n }\n for (const [k, v] of Object.entries(st.fuels)) {\n const f = o.fuels.get(k)\n if (f) f.level = v.level\n }\n for (const [k, v] of Object.entries(st.burners)) {\n const b = o.burners.get(k)\n if (b) {\n b.on = v.on\n b.lit = v.lit\n b.smoke = 0\n }\n }\n for (const [k, v] of Object.entries(st.tanks)) {\n const tk = o.tanks.get(k)\n if (tk) tk.level = v\n }\n for (const [k, v] of Object.entries(st.fixtures)) {\n const f = o.fixtures.get(k)\n if (f) {\n f.on = v\n f.flowing = false\n f.frac = 0\n f.timer = v && f.spec.kind === 'flush' ? FLUSH_SECONDS : 0\n }\n }\n for (const [k, v] of Object.entries(st.hp)) {\n const h = o.hp.get(k)\n if (h) h.hp = v\n }\n }\n grid = state.grid\n breakers.clear()\n for (const [k, v] of Object.entries(state.breakers)) breakers.set(k, v)\n seats.clear()\n for (const [a, s] of Object.entries(state.seats)) if (objs.has(s.object)) seats.set(a, { object: s.object, seat: s.seat })\n defaultTank = state.defaultTank\n defaultTankExplicit = true\n }\n\n // ------------------------------------------------------------------ public surface\n const world: World = {\n add,\n remove,\n get: (id) => objs.get(id)?.public,\n objects: () => [...objs.values()].map((o) => o.public),\n update,\n interactables,\n target,\n act,\n partT: (objectId, partId) => objs.get(objectId)?.parts.get(partId)?.t ?? 0,\n setDevice,\n setFixture,\n setBurner,\n setPart: (objectId, partId, targetT, instant) => {\n const o = objs.get(objectId)\n if (o) setPartTarget(o, partId, targetT, instant)\n },\n fitSweep,\n contents,\n accessible,\n take,\n put,\n slotPosition,\n power: {\n get grid() {\n return grid\n },\n set grid(on: boolean) {\n world.power.setGrid(on)\n },\n setGrid(on) {\n if (on === grid) return\n const before = powerSnapshot()\n grid = on\n emit({ type: 'power', grid })\n emitPowerChanges(before)\n },\n setBreaker(circuit, on) {\n if (breaker(circuit) === on) {\n breakers.set(circuit, on)\n return\n }\n const before = powerSnapshot()\n breakers.set(circuit, on)\n emitPowerChanges(before)\n },\n breaker,\n isPowered: (objectId, deviceId) => {\n const r = getDevice(objectId, deviceId)\n return r ? devicePowered(r.o, r.d) : false\n },\n isOn: (objectId, deviceId) => getDevice(objectId, deviceId)?.d.on ?? false,\n pluggedInto: (objectId, deviceId) => plugs.get(`${objectId}:${deviceId}`) ?? null,\n channel: (objectId, deviceId) => getDevice(objectId, deviceId)?.d.channel ?? 0,\n },\n fuelLevel: (objectId, fuelId) => objs.get(objectId)?.fuels.get(fuelId)?.level ?? 0,\n isLit: (objectId, burnerId) => objs.get(objectId)?.burners.get(burnerId)?.lit ?? false,\n water: {\n setDefaultTank(tankId) {\n defaultTank = tankId\n defaultTankExplicit = true\n },\n level(tankId) {\n return findGlobal(tankId, (oo, local) => oo.tanks.get(local))?.value.level ?? 0\n },\n refill(tankId, liters) {\n const f = findGlobal(tankId, (oo, local) => oo.tanks.get(local))\n if (!f) return 0\n const added = Math.max(0, Math.min(liters, f.value.spec.capacity - f.value.level))\n f.value.level += added\n return added\n },\n setRain(mm) {\n rain = Math.max(0, mm)\n },\n isFlowing: (objectId, fixtureId) => {\n const fx = objs.get(objectId)?.fixtures.get(fixtureId)\n return !!fx && fx.on && fx.flowing\n },\n },\n sit,\n stand,\n seatOf: (actor = DEFAULT_ACTOR) => {\n const s = seats.get(actor)\n return s ? { object: s.object, seat: s.seat } : null\n },\n push,\n sway: (objectId, softId) => {\n const s = objs.get(objectId)?.soft.get(softId)\n return s ? { ax: s.ax, az: s.az } : { ax: 0, az: 0 }\n },\n setWind: (x, z) => {\n wind = [x, z]\n },\n emitters,\n mirrors,\n colliders,\n damage,\n hp: (objectId, target) => (options.destruction ? null : (objs.get(objectId)?.hp.get(target)?.hp ?? null)),\n t,\n setLocale: (l) => {\n locale = l\n table = resolveStrings(locale, options.strings)\n },\n serialize,\n load,\n }\n return world\n}\n","import type { BodyId, JointId, Quat, SeamWorld, Vec3 } from '@adatechnology/game-physics'\n\n/** A chain of boxes along a polyline, each joined to the one before by a swing-twist joint: a cord, a cable, a strip of a curtain. */\nexport interface ChainSpec {\n /** From the start to the end of the chain; one link between each two points. */\n readonly points: readonly Vec3[]\n /** Half the width and the depth of a link (m); its length is the segment's. */\n readonly halfWidth: number\n readonly halfDepth: number\n readonly totalMass: number\n /** What the first link hangs from (a static body, or a kinematic one a host moves). */\n readonly startBody: BodyId\n /** What the last link is tied to; undefined: it hangs free. */\n readonly endBody?: BodyId\n /** Half cone of every joint (radians) and the most it twists either way. */\n readonly halfCone: number\n readonly twist: number\n /** Torque (N m) that holds a joint still against the swing: the chain's stiffness at rest. */\n readonly jointFriction: number\n /** Share of velocity lost per second by every link (the air, the cloth). */\n readonly damping: number\n}\n\nexport interface Chain {\n readonly bodies: readonly BodyId[]\n readonly joints: readonly JointId[]\n /** Half the length of each link, for reading its ends. */\n readonly halfLengths: readonly number[]\n /** The collision group the links share (released with the chain). */\n readonly group: number\n}\n\nconst UP: Vec3 = [0, 1, 0]\n\nconst sub = (a: Vec3, b: Vec3): Vec3 => [a[0] - b[0], a[1] - b[1], a[2] - b[2]]\nconst length = (v: Vec3): number => Math.hypot(v[0], v[1], v[2])\nconst cross = (a: Vec3, b: Vec3): Vec3 => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]\n\n/** The turn that takes +y (a link's length) onto `direction` (unit). */\nexport function alignY(direction: Vec3): Quat {\n const axis = cross(UP, direction)\n const sine = length(axis)\n if (sine < 1e-9) return direction[1] >= 0 ? [0, 0, 0, 1] : [1, 0, 0, 0]\n const angle = Math.atan2(sine, direction[1])\n const half = Math.sin(angle / 2) / sine\n return [axis[0] * half, axis[1] * half, axis[2] * half, Math.cos(angle / 2)]\n}\n\n/** A vector turned by a unit quaternion. */\nexport function rotateByQuat(v: Vec3, q: Quat): Vec3 {\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\nconst perpendicular = (direction: Vec3): Vec3 => {\n const side = Math.abs(direction[0]) < 0.9 ? cross(direction, [1, 0, 0]) : cross(direction, [0, 0, 1])\n const size = length(side)\n return [side[0] / size, side[1] / size, side[2] / size]\n}\n\n/** Builds the links and joints of a chain in the world, in the pose its points give (so a cord starts already sagging). */\nexport function buildChain(world: SeamWorld, spec: ChainSpec): Chain {\n const count = spec.points.length - 1\n const lengths = Array.from({ length: count }, (_, i) => length(sub(spec.points[i + 1] as Vec3, spec.points[i] as Vec3)))\n const total = lengths.reduce((sum, each) => sum + each, 0)\n const pairs: Array<readonly [number, number]> = []\n for (let a = 0; a < count; a++) for (let b = a + 1; b < count; b++) pairs.push([a, b])\n const group = world.createGroup(count, pairs)\n const bodies: BodyId[] = []\n const joints: JointId[] = []\n for (let i = 0; i < count; i++) {\n const from = spec.points[i] as Vec3\n const to = spec.points[i + 1] as Vec3\n const span = lengths[i] as number\n const direction: Vec3 = [(to[0] - from[0]) / span, (to[1] - from[1]) / span, (to[2] - from[2]) / span]\n const link = world.createBody({\n shape: { kind: 'box', half: [spec.halfWidth, span / 2, spec.halfDepth] },\n motion: 'dynamic',\n mass: spec.totalMass * (span / total),\n position: [(from[0] + to[0]) / 2, (from[1] + to[1]) / 2, (from[2] + to[2]) / 2],\n rotation: alignY(direction),\n layer: 'debris',\n group: { id: group, sub: i },\n linearDamping: spec.damping,\n angularDamping: spec.damping,\n user: -4,\n })\n const previous = i === 0 ? spec.startBody : (bodies[i - 1] as BodyId)\n if (i === 0) world.ignorePair(spec.startBody, link, true)\n joints.push(world.createJoint(swingTwist(spec, previous, link, from, direction)))\n bodies.push(link)\n }\n if (spec.endBody !== undefined) {\n const last = spec.points[count] as Vec3\n const direction = sub(last, spec.points[count - 1] as Vec3)\n const size = length(direction)\n world.ignorePair(spec.endBody, bodies[count - 1] as BodyId, true)\n joints.push(world.createJoint(swingTwist(spec, bodies[count - 1] as BodyId, spec.endBody, last, [direction[0] / size, direction[1] / size, direction[2] / size])))\n }\n return { bodies, joints, halfLengths: lengths.map((each) => each / 2), group }\n}\n\n/** Takes a chain out of the world: its joints, its links, then the group the links shared. */\nexport function disposeChain(world: SeamWorld, chain: Chain): void {\n for (const joint of chain.joints) world.removeJoint(joint)\n for (const body of chain.bodies) world.removeBody(body)\n world.releaseGroup(chain.group)\n}\n\nconst swingTwist = (spec: ChainSpec, a: BodyId, b: BodyId, point: Vec3, direction: Vec3) => ({\n kind: 'swingTwist' as const,\n a,\n b,\n point,\n twistAxis: direction,\n planeAxis: perpendicular(direction),\n normalHalfCone: spec.halfCone,\n planeHalfCone: spec.halfCone,\n twistMin: -spec.twist,\n twistMax: spec.twist,\n friction: spec.jointFriction,\n})\n\nconst pose = new Float64Array(7)\n\n/** The end of link `index` now (x, y, z into `out` at `offset`): the body's centre moved half the link's length along its own +y (the unit quaternion's y axis, unrolled). */\nconst writeLinkEnd = (world: SeamWorld, chain: Chain, index: number, sign: 1 | -1, out: Float64Array, offset: number): void => {\n world.readPose(chain.bodies[index] as BodyId, pose, 0)\n const x = pose[3] as number\n const y = pose[4] as number\n const z = pose[5] as number\n const w = pose[6] as number\n const half = (chain.halfLengths[index] as number) * sign\n out[offset] = (pose[0] as number) + half * 2 * (x * y - w * z)\n out[offset + 1] = (pose[1] as number) + half * (1 - 2 * (x * x + z * z))\n out[offset + 2] = (pose[2] as number) + half * 2 * (y * z + w * x)\n}\n\n/** The two ends of every link now, as a polyline (x, y, z per point) for a host that draws the cord: the points a chain was built from, moved. */\nexport function chainPoints(world: SeamWorld, chain: Chain, out: Float64Array): void {\n const count = chain.bodies.length\n writeLinkEnd(world, chain, 0, -1, out, 0)\n for (let i = 0; i < count; i++) writeLinkEnd(world, chain, i, 1, out, (i + 1) * 3)\n}\n\n/** Only the free end of the chain (x, y, z into `out`): one pose read, for a host that wants where the tip is and not the whole line. */\nexport function chainEnd(world: SeamWorld, chain: Chain, out: Float64Array): void {\n writeLinkEnd(world, chain, chain.bodies.length - 1, 1, out, 0)\n}\n","import type { BodyId, SeamWorld } from '@adatechnology/game-physics'\n\nimport { buildChain, chainEnd, disposeChain } from './engine-chain'\nimport type { Chain } from './engine-chain'\nimport { localToWorld, rotY } from './math'\nimport type { SoftDriver } from './part-physics'\nimport type { SoftSpec, Transform, Vec3 } from './types'\n\nconst STRIP_WIDTH = 0.12\nconst LINK_LENGTH = 0.15\nconst MAX_LINKS = 8\nconst FABRIC_KG_PER_M2 = 0.3\nconst FABRIC_HALF_DEPTH = 0.01\nconst TWIST_RANGE = 0.3\nconst DEFAULT_MAX_ANGLE = 0.7\nconst DEFAULT_DAMPING = 4\nconst JOINT_HOLD_NM = 0.002\n/** An actor's velocity (m/s) to the speed it gives a strip (the body only brushes the cloth). */\nconst PUSH_GAIN = 0.4\n\n/**\n * A curtain, cloth or strip as hanging chains from a rail along its anchor line, one chain per `STRIP_WIDTH` of width: they swing when an actor pushes through and\n * settle by the damping (the world's spring is not used). The world's `sway` reads back the mean tip offset of the chains as the two swing angles.\n */\nexport function attachStrips(world: SeamWorld, soft: SoftSpec, transform: Transform): SoftDriver {\n const [width, height, depth] = soft.size\n const strips = Math.max(1, Math.round(width / STRIP_WIDTH))\n const links = Math.min(MAX_LINKS, Math.max(2, Math.round(height / LINK_LENGTH)))\n const rail: BodyId = world.createBody({ shape: { kind: 'box', half: [width / 2, 0.01, Math.max(depth, 0.02) / 2] }, motion: 'static', position: localToWorld(transform, soft.anchor), layer: 'static', user: -3 })\n const damping = soft.damping ?? DEFAULT_DAMPING\n const chains: Chain[] = []\n const tops: Vec3[] = []\n for (let i = 0; i < strips; i++) {\n const x = soft.anchor[0] - width / 2 + (width * (i + 0.5)) / strips\n const top = localToWorld(transform, [x, soft.anchor[1], soft.anchor[2]])\n tops.push(top)\n chains.push(\n buildChain(world, {\n points: Array.from({ length: links + 1 }, (_, k): Vec3 => [top[0], top[1] - (height * k) / links, top[2]]),\n halfWidth: (width / strips) * 0.45,\n halfDepth: FABRIC_HALF_DEPTH,\n totalMass: (width / strips) * height * FABRIC_KG_PER_M2,\n startBody: rail,\n halfCone: soft.maxAngle ?? DEFAULT_MAX_ANGLE,\n twist: TWIST_RANGE,\n jointFriction: JOINT_HOLD_NM,\n damping: damping / 4,\n }),\n )\n }\n const tip = new Float64Array(3)\n const lastLinks = chains.map((chain) => chain.bodies[chain.bodies.length - 1] as BodyId)\n const cosYaw = Math.cos(-transform.ry)\n const sinYaw = Math.sin(-transform.ry)\n let restedAx = 0\n let restedAz = 0\n let isRested = false\n let disposed = false\n const everyLinkAsleep = (): boolean => {\n for (let i = 0; i < lastLinks.length; i++) if (!world.isSleeping(lastLinks[i] as BodyId)) return false\n return true\n }\n return {\n swing(out) {\n const asleep = everyLinkAsleep()\n if (asleep && isRested) {\n out[0] = restedAx\n out[1] = restedAz\n return\n }\n let dx = 0\n let dz = 0\n for (let i = 0; i < chains.length; i++) {\n chainEnd(world, chains[i] as Chain, tip)\n const top = tops[i] as Vec3\n const offsetX = (tip[0] as number) - top[0]\n const offsetZ = (tip[2] as number) - top[2]\n // the object's yaw undone (the same turn about y as `worldToLocal`)\n dx += offsetX * cosYaw + offsetZ * sinYaw\n dz += -offsetX * sinYaw + offsetZ * cosYaw\n }\n // rotation about x turns the tip toward -z for a positive angle (and about z toward +x), as the world's spring has it\n out[0] = -Math.asin(Math.max(-1, Math.min(1, dz / strips / height)))\n out[1] = Math.asin(Math.max(-1, Math.min(1, dx / strips / height)))\n restedAx = out[0]\n restedAz = out[1]\n isRested = asleep\n },\n push(velocity) {\n const world3 = rotY(velocity, transform.ry)\n for (const chain of chains) {\n for (const body of chain.bodies) world.addImpulse(body, [world3[0] * PUSH_GAIN * linkMass(soft, strips, links), world3[1] * PUSH_GAIN * linkMass(soft, strips, links), world3[2] * PUSH_GAIN * linkMass(soft, strips, links)])\n }\n },\n dispose() {\n if (disposed) return\n disposed = true\n for (const chain of chains) disposeChain(world, chain)\n world.removeBody(rail)\n },\n }\n}\n\nconst linkMass = (soft: SoftSpec, strips: number, links: number): number => (soft.size[0] / strips) * (soft.size[1] / links) * FABRIC_KG_PER_M2\n","import type { BodyId, JointId, Quat, SeamWorld } from '@adatechnology/game-physics'\n\nimport { clamp, rotateAxis } from './math'\nimport type { PartDriver } from './part-physics'\nimport type { Vec3 } from './types'\n\n/** A part driver whose leaf is a body of the engine: the host draws the part where the body is, and after a break the body is all that is left. */\nexport interface EnginePartDriver extends PartDriver {\n readonly leaf: BodyId\n}\n\n/** Units of t per second that close a gap of one t: the leaf slows as it arrives. */\nconst AIM_GAIN = 8\nconst ARRIVED_AT = 0.004\n\nconst axisAngle = (axis: Vec3, angle: number): Quat => {\n const size = Math.hypot(axis[0], axis[1], axis[2]) || 1\n const k = Math.sin(angle / 2) / size\n return [axis[0] * k, axis[1] * k, axis[2] * k, Math.cos(angle / 2)]\n}\nconst multiply = (a: Quat, b: Quat): Quat => [\n a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],\n a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],\n a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],\n a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2],\n]\n\n\nexport interface LeafDriverSpec {\n readonly world: SeamWorld\n readonly leaf: BodyId\n readonly frame: BodyId\n readonly ownsFrame: boolean\n readonly joint: JointId\n readonly onDispose: () => void\n readonly drive: { readonly isHinge: boolean; readonly axis: Vec3; readonly pivot: Vec3; readonly centre: Vec3; readonly range: number; readonly speed: number; readonly base: Quat }\n}\n\n\n/** Scratch of every leaf: a driver reads and writes a pose, a velocity pair at a time, so no pose or vector is made per frame. */\nconst pose = new Float64Array(7)\nconst linearScratch: Vec3 = [0, 0, 0]\nconst angularScratch: Vec3 = [0, 0, 0]\nconst NO_SPIN: Vec3 = [0, 0, 0]\n\nexport function createLeafDriver(spec: LeafDriverSpec): EnginePartDriver {\n const { world, leaf, frame, joint, drive } = spec\n const { axis, pivot, centre, range } = drive\n let target = 0\n let settled = true\n let broken = false\n let disposed = false\n let lastT = 0\n /** t of the leaf at rest, kept while it sleeps: nothing moves it, so the joint is not asked again. */\n let restedT: number | undefined\n const measure = (): number => {\n if (drive.isHinge) return world.jointAngles(joint).hinge / range\n world.readPose(leaf, pose, 0)\n return (((pose[0] as number) - centre[0]) * axis[0] + ((pose[1] as number) - centre[1]) * axis[1] + ((pose[2] as number) - centre[2]) * axis[2]) / range\n }\n const read = (): number => {\n if (broken) return lastT\n if (settled && world.isSleeping(leaf)) {\n restedT ??= measure()\n lastT = restedT\n return lastT\n }\n restedT = undefined\n lastT = measure()\n return lastT\n }\n const stop = (): void => {\n world.setVelocity(leaf, NO_SPIN, NO_SPIN)\n settled = true\n }\n // t per second to the leaf's own velocity: a turn about the hinge carries the centre round, a slide is a line\n const move = (rate: number): void => {\n world.wake(leaf)\n const speed = rate * range\n angularScratch[0] = axis[0] * speed\n angularScratch[1] = axis[1] * speed\n angularScratch[2] = axis[2] * speed\n if (!drive.isHinge) return world.setVelocity(leaf, angularScratch, NO_SPIN)\n world.readPose(leaf, pose, 0)\n const armX = (pose[0] as number) - pivot[0]\n const armY = (pose[1] as number) - pivot[1]\n const armZ = (pose[2] as number) - pivot[2]\n linearScratch[0] = angularScratch[1] * armZ - angularScratch[2] * armY\n linearScratch[1] = angularScratch[2] * armX - angularScratch[0] * armZ\n linearScratch[2] = angularScratch[0] * armY - angularScratch[1] * armX\n world.setVelocity(leaf, linearScratch, angularScratch)\n }\n const place = (t: number): void => {\n const amount = t * drive.range\n if (drive.isHinge) {\n const centre = rotateAxis([drive.centre[0] - drive.pivot[0], drive.centre[1] - drive.pivot[1], drive.centre[2] - drive.pivot[2]], drive.axis, amount)\n world.setPose(leaf, [drive.pivot[0] + centre[0], drive.pivot[1] + centre[1], drive.pivot[2] + centre[2]], multiply(axisAngle(drive.axis, amount), drive.base), true)\n } else {\n world.setPose(leaf, [drive.centre[0] + drive.axis[0] * amount, drive.centre[1] + drive.axis[1] * amount, drive.centre[2] + drive.axis[2] * amount], drive.base, true)\n }\n world.setVelocity(leaf, [0, 0, 0], [0, 0, 0])\n }\n return {\n leaf,\n aim(next) {\n if (broken) return\n target = next\n settled = false\n restedT = undefined\n },\n snap(t) {\n target = t\n settled = true\n restedT = undefined\n if (!broken) place(t)\n },\n update() {\n if (broken) return\n if (!world.jointExists(joint)) {\n broken = true\n settled = true\n return\n }\n if (settled) return\n const error = target - read()\n if (Math.abs(error) < ARRIVED_AT) return stop()\n move(clamp(error * AIM_GAIN, -drive.speed, drive.speed))\n },\n read,\n get settled() {\n return settled\n },\n get broken() {\n return broken\n },\n dispose() {\n if (disposed) return\n disposed = true\n spec.onDispose()\n if (!broken) world.removeJoint(joint)\n world.removeBody(leaf)\n if (spec.ownsFrame) world.removeBody(frame)\n },\n }\n}\n","import type { BodyId, Quat, SeamWorld } from '@adatechnology/game-physics'\n\nimport { attachStrips } from './engine-soft'\nimport { createLeafDriver } from './engine-leaf'\nimport type { EnginePartDriver } from './engine-leaf'\nimport { localToWorld, rotY } from './math'\nimport type { PartPhysics } from './part-physics'\nimport type { PartSpec, SoftSpec, Transform, Vec3 } from './types'\n\n/** What a host tells the engine about its objects. */\nexport interface EnginePartOptions {\n /** The object's own static body when the host has one: a leaf does not collide with it. Without it each part gets a hidden anchor at its pivot. */\n readonly frameOf?: (object: string) => BodyId | undefined\n /** The impulse (N s) over which a part's joint breaks, or undefined for a part that never breaks. */\n readonly breakImpulse?: (object: string, part: PartSpec) => number | undefined\n /** Mass of a leaf (kg); default its volume at the density of a hollow door. */\n readonly leafMass?: (object: string, part: PartSpec) => number\n}\n\nexport interface EnginePartPhysics extends PartPhysics {\n /** The leaf body of a part the engine took (also after it broke: then it is a loose body the host draws where it is), or undefined. */\n leafOf(object: string, part: string): BodyId | undefined\n dispose(): void\n}\n\nconst HOLLOW_DOOR_DENSITY = 150\nconst MIN_LEAF_MASS = 1\n/** Newtons that hold a drawer still against its slide, and N m a hinge, so a part stays where it is left. */\nconst SLIDE_HOLD_N = 4\nconst HINGE_HOLD_NM = 0.4\nconst SOFT_KINDS: ReadonlySet<SoftSpec['kind']> = new Set(['cloth', 'curtain', 'strip'])\n\nexport const quatY = (ry: number): Quat => [0, Math.sin(ry / 2), 0, Math.cos(ry / 2)]\nconst cross = (a: Vec3, b: Vec3): Vec3 => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]\n\nconst perpendicularTo = (axis: Vec3): Vec3 => {\n const side = Math.abs(axis[0]) < 0.9 ? cross(axis, [1, 0, 0]) : cross(axis, [0, 0, 1])\n const size = Math.hypot(side[0], side[1], side[2])\n return [side[0] / size, side[1] / size, side[2] / size]\n}\n\n/** The engine under the movable parts and soft volumes of an interactables world (`WorldOptions.partPhysics`), made of the contract's bodies and joints only. */\nexport function createEnginePartPhysics(world: SeamWorld, options: EnginePartOptions = {}): EnginePartPhysics {\n const disposers = new Set<() => void>()\n const leaves = new Map<string, BodyId>()\n return {\n attachPart(object, part, transform) {\n const key = `${object}:${part.id}`\n const retire = (): void => {\n leaves.delete(key)\n disposers.delete(dispose)\n }\n const dispose = (): void => driver?.dispose()\n const driver = attachLeaf(world, options, { object, part, transform, onDispose: retire })\n if (!driver) return undefined\n leaves.set(key, driver.leaf)\n disposers.add(dispose)\n return driver\n },\n leafOf: (object, part) => leaves.get(`${object}:${part}`),\n attachSoft(_object, soft, transform) {\n const driver = SOFT_KINDS.has(soft.kind) ? attachStrips(world, soft, transform) : undefined\n if (!driver) return undefined\n const dispose = (): void => driver.dispose()\n disposers.add(dispose)\n return { swing: driver.swing, push: driver.push, dispose: () => { disposers.delete(dispose); driver.dispose() } }\n },\n dispose() {\n for (const dispose of [...disposers]) dispose()\n disposers.clear()\n },\n }\n}\n\ninterface LeafRequest {\n readonly object: string\n readonly part: PartSpec\n readonly transform: Transform\n readonly onDispose: () => void\n}\n\n/** A door, lid or drawer: a leaf box on a hinge or a slider, driven toward its target and free once it gets there. Undefined without `bounds` or for another motion. */\nfunction attachLeaf(world: SeamWorld, options: EnginePartOptions, request: LeafRequest): EnginePartDriver | undefined {\n const { object, part, transform } = request\n const motion = part.motion\n const bounds = part.bounds\n if (!bounds || (motion.kind !== 'hinge' && motion.kind !== 'slide')) return undefined\n const isHinge = motion.kind === 'hinge'\n const axisLocal = rotY(motion.axis ?? [0, 1, 0], part.ry ?? 0)\n const axis = rotY(axisLocal, transform.ry)\n const pivot = localToWorld(transform, part.pivot)\n const half: Vec3 = [(bounds[3] - bounds[0]) / 2, (bounds[4] - bounds[1]) / 2, (bounds[5] - bounds[2]) / 2]\n const centre = localToWorld(transform, [(bounds[0] + bounds[3]) / 2, (bounds[1] + bounds[4]) / 2, (bounds[2] + bounds[5]) / 2])\n const rotation = quatY(transform.ry)\n const range = isHinge ? (motion.angle ?? Math.PI / 2) : (motion.distance ?? 0.4)\n const speed = motion.speed ?? 2.5\n const frame = options.frameOf?.(object) ?? world.createBody({ shape: { kind: 'box', half: [0.01, 0.01, 0.01] }, motion: 'static', position: pivot, layer: 'static', user: -3 })\n const ownsFrame = options.frameOf?.(object) === undefined\n const mass = options.leafMass?.(object, part) ?? Math.max(MIN_LEAF_MASS, 8 * half[0] * half[1] * half[2] * HOLLOW_DOOR_DENSITY)\n const leaf = world.createBody({ shape: { kind: 'box', half }, motion: 'dynamic', mass, position: centre, rotation, layer: 'prop', allowSleep: true, user: -3 })\n world.ignorePair(frame, leaf, true)\n const limits = { min: Math.min(0, range), max: Math.max(0, range) }\n const breakImpulse = options.breakImpulse?.(object, part)\n const joint = world.createJoint(\n isHinge\n ? { kind: 'hinge', a: frame, b: leaf, point: pivot, axis, normal: perpendicularTo(axis), ...limits, friction: HINGE_HOLD_NM, ...(breakImpulse === undefined ? {} : { breakImpulse }) }\n : { kind: 'slider', a: frame, b: leaf, point: pivot, axis, ...limits, friction: SLIDE_HOLD_N, ...(breakImpulse === undefined ? {} : { breakImpulse }) },\n )\n return createLeafDriver({ world, leaf, frame, ownsFrame, joint, onDispose: request.onDispose, drive: { isHinge, axis, pivot, centre, range, speed, base: rotation } })\n}\n\n","import type { Vec3 } from './types'\n\n/** Whether a thing of `size` (any turn of it) goes into a box of `half` sizes: each of its sides, longest first, against the box's, longest first. */\nexport function fitsInVolume(size: readonly [number, number, number], half: Vec3): boolean {\n const thing = [...size].sort((a, b) => b - a)\n const room = half.map((h) => h * 2).sort((a, b) => b - a)\n return thing.every((side, i) => side <= (room[i] ?? 0))\n}\n","/**\n * What an object does with the player's hand or on its own time (`ObjectSpec.uses`), for `createObjectControls`: a device's program that runs for its seconds, what\n * the hand holds put inside when it fits, a container emptied, a bowl filled from the hand, a basin soiled and washed by its flush. The rules are the data's: the\n * container's inside, the bowl's capacity and what it accepts, the access part that must be open (or closed, for a program).\n */\nimport type { ControlledHand, ItemControl, ItemControlResult, ItemControlsHost } from '@adatechnology/game-contracts'\n\nimport { fitsInVolume } from './fits-volume'\nimport type { BowlSpec, ContainerSpec, ObjectSpec, UseSpec, World } from './types'\n\n/** What a basin holds, worst last: a flush washes it back to clean. */\nexport type Soil = 'clean' | 'urine' | 'feces'\n\nexport interface UsesState {\n /** kg of food or litres of water in each bowl. */\n readonly bowls: Readonly<Record<string, number>>\n readonly soil: Readonly<Record<string, Soil>>\n /** The program running, with its seconds left. */\n readonly program: { readonly use: string; readonly device: string; readonly left: number } | null\n}\n\nexport interface Uses {\n has(id: string): boolean\n list(host: ItemControlsHost): ItemControl[]\n run(id: string, host: ItemControlsHost): ItemControlResult\n update(dt: number): void\n /** A fixture of the object ran its water: the basin it cleans is clean again. */\n flushed(fixture: string): void\n state(): UsesState\n}\n\nexport interface UsesOptions {\n readonly spec: ObjectSpec\n readonly world: World\n readonly objectId: string\n}\n\nconst OPEN = 0.5\nconst PREFIX = 'use.'\nconst SOIL_RANK: Record<Soil, number> = { clean: 0, urine: 1, feces: 2 }\n\nconst clock = (seconds: number): string => {\n const s = Math.max(0, Math.ceil(seconds))\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`\n}\n\n/** Whether the hand's item is one the bowl accepts: its id, or a room id that ends with it (`item_dog_food` for `dog_food`). */\nconst accepts = (bowl: BowlSpec, hand: ControlledHand): boolean => (bowl.accepts ?? []).some((id) => hand.itemId === id || hand.itemId.endsWith(`_${id}`))\n\ntype Verdict = { readonly available: true } | { readonly available: false; readonly reason: string }\nconst YES: Verdict = { available: true }\nconst no = (reason: string): Verdict => ({ available: false, reason })\n\nexport function createUses(options: UsesOptions): Uses {\n const { spec, world, objectId } = options\n const all = spec.uses ?? []\n const containers = new Map<string, ContainerSpec>((spec.containers ?? []).map((c) => [c.id, c]))\n const bowls = new Map<string, BowlSpec>((spec.bowls ?? []).map((b) => [b.id, b]))\n const level = new Map<string, number>((spec.bowls ?? []).map((b) => [b.id, Math.min(b.capacity, b.level ?? 0)]))\n const soil = new Map<string, Soil>((spec.basins ?? []).filter((b) => b.soils).map((b) => [b.id, 'clean']))\n const cleans = new Map<string, string>((spec.fixtures ?? []).flatMap((f) => (f.cleans ? [[f.id, f.cleans] as const] : [])))\n let program: { use: Extract<UseSpec, { do: 'program' }>; left: number } | null = null\n let lastHost: ItemControlsHost | null = null\n\n const typeKey = `type.${spec.type}`\n const name = (): string => {\n const text = world.t(typeKey)\n return text === typeKey ? spec.type.replace(/_/g, ' ') : text.charAt(0).toLowerCase() + text.slice(1)\n }\n const accessOpen = (host: ItemControlsHost, part: string | undefined): boolean => !part || host.partOpening(part) >= OPEN\n\n const verdict = (use: UseSpec, host: ItemControlsHost): Verdict => {\n const hand = host.hand()\n switch (use.do) {\n case 'program':\n if (!world.power.isPowered(objectId, use.device)) return no('no_power')\n return use.access && host.partOpening(use.access) >= OPEN ? no('needs_closed') : YES\n case 'put_in': {\n const c = containers.get(use.container)\n if (!hand) return no('hand_empty')\n if (!c || !accessOpen(host, c.access)) return no('requires_open')\n return fitsInVolume(hand.size, c.volume.half) ? YES : no('not_fit')\n }\n case 'empty':\n return accessOpen(host, containers.get(use.container)?.access) ? YES : no('requires_open')\n case 'fill': {\n const bowl = bowls.get(use.bowl)\n if (!bowl) return no('empty')\n if ((level.get(bowl.id) ?? 0) >= bowl.capacity - 1e-6) return no('bowl_full')\n if (!hand) return no('hand_empty')\n if (bowl.holds === 'water' && hand.liquid?.kind === 'water' && hand.liquid.closed) return no('requires_open')\n const fits = bowl.holds === 'water' ? hand.liquid?.kind === 'water' && hand.liquid.litres > 0 : accepts(bowl, hand)\n return fits ? YES : no('not_accepted')\n }\n case 'relieve':\n return YES\n }\n }\n\n const textVars = (use: UseSpec, host: ItemControlsHost): Record<string, string> => ({\n name: name(),\n item: host.hand()?.name ?? '',\n bowl: world.t(`bowl.${use.do === 'fill' ? (bowls.get(use.bowl)?.holds ?? 'food') : 'food'}`),\n })\n\n const labelOf = (use: UseSpec, host: ItemControlsHost): string => world.t(use.do === 'put_in' && !host.hand() ? 'use.put_in.none' : use.label, textVars(use, host))\n\n const runUse = (use: UseSpec, host: ItemControlsHost): ItemControlResult => {\n const vars = textVars(use, host)\n switch (use.do) {\n case 'program': {\n world.setDevice(objectId, use.device, true)\n program = { use, left: use.seconds }\n return { ok: true, text: world.t('done_program', { ...vars, program: world.t(use.label), time: clock(use.seconds) }) }\n }\n case 'put_in': {\n const c = containers.get(use.container) as ContainerSpec\n return host.placeHand(c.volume.center) ? { ok: true, text: world.t('done_put_in', vars) } : { ok: false, text: world.t('not_fit', vars) }\n }\n case 'empty': {\n const c = containers.get(use.container) as ContainerSpec\n const [cx, cy, cz] = c.volume.center\n const [hx, hy, hz] = c.volume.half\n const n = host.emptyInside([cx - hx, cy - hy, cz - hz], [cx + hx, cy + hy, cz + hz])\n return { ok: n > 0, text: world.t(n > 0 ? 'done_empty' : 'empty', { ...vars, n }) }\n }\n case 'fill':\n return fill(bowls.get(use.bowl) as BowlSpec, host, vars)\n case 'relieve': {\n const now = soil.get(use.basin) ?? 'clean'\n soil.set(use.basin, SOIL_RANK[use.kind] > SOIL_RANK[now] ? use.kind : now)\n return { ok: true, text: world.t(`done_relieve_${use.kind}`, vars) }\n }\n }\n }\n\n const fill = (bowl: BowlSpec, host: ItemControlsHost, vars: Record<string, string>): ItemControlResult => {\n const now = level.get(bowl.id) ?? 0\n const added = bowl.holds === 'water' ? host.pourHand(bowl.capacity - now) : bowl.capacity - now\n level.set(bowl.id, Math.min(bowl.capacity, now + added))\n return { ok: added > 0, text: world.t(added > 0 ? 'done_fill' : 'not_accepted', vars) }\n }\n\n const stopProgram = (): string => {\n if (!program) return ''\n world.setDevice(objectId, program.use.device, false)\n program = null\n return world.t('done_program_stop', { name: name() })\n }\n\n const visible = (use: UseSpec): boolean => use.do !== 'program' || program === null\n\n return {\n has: (id) => id.startsWith(PREFIX),\n list(host) {\n lastHost = host\n const entries: ItemControl[] = []\n if (program) entries.push({ id: `${PREFIX}stop`, label: world.t('use.program.stop', { name: name(), left: clock(program.left) }), available: true })\n for (const use of all.filter(visible)) {\n const v = verdict(use, host)\n entries.push({ id: `${PREFIX}${use.id}`, label: labelOf(use, host), available: v.available, ...(v.available ? {} : { reason: world.t(v.reason, textVars(use, host)) }) })\n }\n return entries\n },\n run(id, host) {\n lastHost = host\n if (id === `${PREFIX}stop`) return { ok: program !== null, text: stopProgram() }\n const use = all.find((u) => `${PREFIX}${u.id}` === id)\n if (!use || !visible(use)) return { ok: false, text: '' }\n const v = verdict(use, host)\n return v.available ? runUse(use, host) : { ok: false, text: world.t(v.reason, textVars(use, host)) }\n },\n update(dt) {\n if (!program) return\n program.left -= dt\n if (program.left > 0) return\n const done = world.t('done_program_end', { name: name(), program: world.t(program.use.label) })\n world.setDevice(objectId, program.use.device, false)\n program = null\n lastHost?.say(done)\n },\n flushed(fixture) {\n const basin = cleans.get(fixture)\n if (!basin || soil.get(basin) === 'clean') return\n soil.set(basin, 'clean')\n lastHost?.say(world.t('done_clean', { name: name() }))\n },\n state: () => ({\n bowls: Object.fromEntries(level),\n soil: Object.fromEntries(soil),\n program: program ? { use: program.use.id, device: program.use.device, left: program.left } : null,\n }),\n }\n}\n","/**\n * The controls of one object for a host that moves the object's parts itself (a test room plays the parts' clips, a game its own animation): what the object's spec\n * says it does (its devices, fixtures, burners and fuel, run by an interactables world of its own fed by the mains), plus what it does with the player's hand or on\n * its own time (`ObjectSpec.uses`: a program, putting in, emptying, filling a bowl, relieving oneself). Data-driven: nothing here knows a TV from a toilet. Pure: no\n * three.js; the drawing of what the state shows (a screen's picture, a bowl's level, a fire) reads `state()`.\n */\nimport type { ItemControl, ItemControlResult, ItemControls, ItemControlsHost } from '@adatechnology/game-contracts'\n\nimport { createUses } from './object-uses'\nimport type { UsesState } from './object-uses'\nimport type { Action, ActiveEmitter, Interactable, InteractablesLocale, ObjectSpec, Strings, Vec3 } from './types'\nimport { createWorld } from './world'\n\n/** The id the object has in its own world. */\nexport const CONTROLLED_OBJECT = 'object'\nconst MAINS = 'mains'\nconst MAINS_TANK = 'water'\n\n/** World interactions a host that moves the parts itself does on its own (opening, taking, reading, sitting) or that belong to a building (a breaker). */\nconst HOST_KINDS: ReadonlySet<Action['do']> = new Set(['toggle_part', 'open_container', 'take', 'read', 'sit', 'toggle_breaker'])\n\nexport interface ObjectControlsOptions {\n readonly spec: ObjectSpec\n readonly locale?: string\n /** The content pack's strings (`Household.strings`). */\n readonly strings?: Partial<Record<InteractablesLocale, Strings>>\n /** Whether the mains give power and water. Default both: a piece standing on its own in a test room is plugged in and piped. */\n readonly mains?: { readonly power?: boolean; readonly water?: boolean }\n}\n\n/** What the object shows now, for its drawing. */\nexport interface ObjectControlsState extends UsesState {\n /** Screens on and powered, with their channel. */\n readonly screens: ReadonlyArray<{ readonly device: string; readonly channel: number }>\n /** Fires and smoke of its burners, object-local (the water runs from the parts the host moves). */\n readonly emitters: readonly ActiveEmitter[]\n}\n\nexport interface ObjectControls extends ItemControls {\n state(): ObjectControlsState\n}\n\nconst PLUG_FALLBACK: Vec3 = [0, 0.3, 0]\n\n/** A wall socket at each plugged device's plug and one tank behind every fixture: the mains of a piece standing on its own. */\nfunction mainsSpec(spec: ObjectSpec): ObjectSpec {\n const plugged = (spec.devices ?? []).filter((d) => d.socket !== undefined && !d.circuit)\n return { type: MAINS, sockets: plugged.map((d, i) => ({ id: `socket_${i}`, pos: d.plug ?? PLUG_FALLBACK })), tanks: [{ id: MAINS_TANK, capacity: 1e9 }] }\n}\n\nexport function createObjectControls(options: ObjectControlsOptions): ObjectControls {\n const { spec } = options\n const forwarded = new Map<string, boolean>()\n const said: string[] = []\n let host: ItemControlsHost | null = null\n const world = createWorld({\n locale: options.locale ?? 'en',\n ...(options.strings ? { strings: options.strings } : {}),\n grid: options.mains?.power ?? true,\n takeContents: false,\n onEvent: (event) => {\n if (event.type === 'message') said.push(event.text)\n if (event.type === 'part' && event.object === CONTROLLED_OBJECT) forwardPart(event.part, event.target >= 0.5)\n if (event.type === 'fixture' && event.object === CONTROLLED_OBJECT && event.flowing) uses.flushed(event.fixture)\n },\n })\n /** A part the world moved goes to the host, once per change of where it is headed. */\n const forwardPart = (part: string, open: boolean): void => {\n if (forwarded.get(part) === open) return\n forwarded.set(part, open)\n host?.setPart(part, open)\n }\n world.add(MAINS, mainsSpec(spec), { x: 0, y: 0, z: 0, ry: 0 })\n if (options.mains?.water ?? true) world.water.setDefaultTank(`${MAINS}:${MAINS_TANK}`)\n world.add(CONTROLLED_OBJECT, spec, { x: 0, y: 0, z: 0, ry: 0 })\n const uses = createUses({ spec, world, objectId: CONTROLLED_OBJECT })\n // a device a program runs (a washing machine) is started by its programs, not switched on bare\n const programmedDevices = new Set((spec.uses ?? []).flatMap((u) => (u.do === 'program' ? [u.device] : [])))\n const switchesOf = (device: string): string[] => [\n `device.${device}`,\n ...(spec.interactions ?? []).flatMap((i) => (i.action.do === 'toggle_device' && i.action.device === device ? [i.id] : [])),\n ]\n const programmed = new Set([...programmedDevices].flatMap(switchesOf).map((id) => `${CONTROLLED_OBJECT}:${id}`))\n const own = (i: Interactable): boolean => i.object === CONTROLLED_OBJECT && !HOST_KINDS.has(i.kind) && !programmed.has(i.id)\n const interactions = (): Interactable[] => world.interactables().filter(own)\n const lend = (lent: ItemControlsHost): void => {\n host = lent\n }\n\n return {\n list(lent) {\n lend(lent)\n const fromWorld: ItemControl[] = interactions().map((i) => ({ id: i.id, label: i.label, available: i.available, ...(i.reason ? { reason: world.t(i.reason) } : {}) }))\n return [...fromWorld, ...uses.list(lent)]\n },\n run(id, lent): ItemControlResult {\n lend(lent)\n if (uses.has(id)) return uses.run(id, lent)\n const found = interactions().find((i) => i.id === id)\n if (!found) return { ok: false, text: '' }\n said.length = 0\n const ok = world.act(id)\n return { ok, text: said.length > 0 ? said.join(' · ') : found.label }\n },\n update(dt, lent) {\n lend(lent)\n world.update(dt)\n uses.update(dt)\n },\n state() {\n const screens = (spec.devices ?? [])\n .filter((d) => d.kind === 'screen' && world.power.isOn(CONTROLLED_OBJECT, d.id) && world.power.isPowered(CONTROLLED_OBJECT, d.id))\n .map((d) => ({ device: d.id, channel: world.power.channel(CONTROLLED_OBJECT, d.id) }))\n const emitters = world.emitters().filter((e) => e.object === CONTROLLED_OBJECT && e.kind !== 'water')\n return { ...uses.state(), screens, emitters }\n },\n dispose() {\n host = null\n world.remove(CONTROLLED_OBJECT)\n world.remove(MAINS)\n },\n }\n}\n"],"mappings":";AAOO,IAAM,oBAAoB;AAEjC,IAAM,gBAAgB;AAEtB,IAAM,UAAU;AAEhB,IAAM,aAAa;AAwBZ,SAAS,sBAAsB,MAAkE;AACtG,QAAM,WAAW,IAAI,KAAK,KAAK,YAAY,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC;AACtF,QAAM,SAAmB,CAAC;AAC1B,aAAW,WAAW,KAAK,YAAY,CAAC,GAAG;AACzC,QAAI,QAAQ,SAAS,QAAS;AAC9B,UAAM,UAA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