@adatechnology/game-destruction-three 0.24.4 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/audio/impact-keys.ts","../src/renderer.ts","../src/fragments.ts","../src/fitted-boxes.ts","../src/math.ts","../src/fragment-shapes.ts","../src/ground.ts","../src/piece-contacts.ts","../src/pieces.ts","../src/rebar.ts","../src/spec.ts","../src/friction.ts","../src/debris-events.ts","../src/heat.ts","../src/skin-dent.ts","../src/stair-crack.ts","../src/visual.ts","../src/settlement.ts","../src/emitter-anchor.ts","../src/audio/recipes.ts","../src/audio/blast-fire.ts","../src/audio/sound.ts","../src/audio/samples.ts"],"sourcesContent":["import type { DamageType, MaterialDef } from '@adatechnology/game-destruction'\n\nimport type { SoundDetail } from '../types'\n\n/**\n * The sound family of a material, from its tags: what it sounds like when something meets it. Finer than the five keys of `impactKey` (which stay the\n * last fallback): ceramic is not glass, the ground is not concrete, plastic and wax are not wood, leaves are not a sofa.\n */\nexport type ImpactFamily = 'metal' | 'glass' | 'ceramic' | 'soil' | 'masonry' | 'wood' | 'plant' | 'plastic' | 'rubber' | 'wax' | 'soft'\n\n/** Tag → family, in the order they are tried (`green_wood` is `plant` and `wood`: wood wins; `gravel` is `soil` and `masonry`: soil wins). */\nexport const IMPACT_FAMILY_TAGS: readonly (readonly [tag: string, family: ImpactFamily])[] = [\n ['metal', 'metal'],\n ['glass', 'glass'],\n ['ceramic', 'ceramic'],\n ['soil', 'soil'],\n ['masonry', 'masonry'],\n ['wood', 'wood'],\n ['plant', 'plant'],\n ['plastic', 'plastic'],\n ['rubber', 'rubber'],\n ['wax', 'wax'],\n ['fabric', 'soft'],\n]\n\n/** The family of a material, or `undefined` when none of its tags names one (the five legacy keys of `impactKey` then answer). */\nexport function impactFamily(def: MaterialDef | undefined): ImpactFamily | undefined {\n const tags = def?.tags ?? []\n for (const [tag, family] of IMPACT_FAMILY_TAGS) if (tags.includes(tag)) return family\n return undefined\n}\n\n/** What an impact or a break sends with its key: the keys to try before it, most specific first (material and blow, material, family and blow, family). */\nexport type ImpactKeys = SoundDetail & { readonly keys: readonly string[] }\n\nconst ordered = (prefix: string, material: string, family: ImpactFamily | undefined, blow: DamageType | undefined): string[] => {\n const keys: string[] = []\n if (material && blow) keys.push(`${prefix}_${material}_${blow}`)\n if (material) keys.push(`${prefix}_${material}`)\n if (family && blow) keys.push(`${prefix}_${family}_${blow}`)\n if (family) keys.push(`${prefix}_${family}`)\n return keys\n}\n\n/**\n * The impact keys for a blow on a material, most specific first: `impact_<material>_<blow>`, `impact_<material>`, `impact_<family>_<blow>`,\n * `impact_<family>` (blow is the `DamageType`: `ballistic`, `blunt`, `slash`, `explosive`...). The legacy `impactKey` is the last fallback the caller sends as the key.\n */\nexport function impactSoundKeys(material: string, def: MaterialDef | undefined, blow?: DamageType): ImpactKeys {\n return { keys: ordered('impact', material, impactFamily(def), blow) }\n}\n\n/** The keys for a part of this material breaking, most specific first: `break_<material>_<blow>`, `break_<material>`, `break_<family>_<blow>`, `break_<family>`. */\nexport function breakSoundKeys(material: string, def: MaterialDef | undefined, blow?: DamageType): ImpactKeys {\n return { keys: ordered('break', material, impactFamily(def), blow) }\n}\n\n/** The keys for a round glancing off a part of this material: `ricochet_<material>`, `ricochet_<family>` (then the plain `ricochet`). */\nexport function ricochetSoundKeys(material: string, def: MaterialDef | undefined): ImpactKeys {\n return { keys: ordered('ricochet', material, impactFamily(def), undefined) }\n}\n","import type * as THREE_NS from 'three'\nimport type { DamageType, DebrisKind, DestructionEvent, DestructionEventType, Fragment, MaterialDef, PartSettlement, PartSpec, Vec3 } from '@adatechnology/game-destruction'\nimport { breakSoundKeys, impactSoundKeys, ricochetSoundKeys } from './audio/impact-keys'\nimport { DEFERRED_QUEUE_ID, blastShove, warnOnce } from '@adatechnology/game-contracts'\nimport { createVfx, effectForEvent, EVENT_EFFECTS_MAP } from '@adatechnology/game-vfx'\nimport type { GameEvent } from '@adatechnology/game-vfx'\nimport type { VfxWorld } from '@adatechnology/game-vfx'\nimport { createVfxRenderer } from '@adatechnology/game-vfx-three'\nimport type { VfxRenderer } from '@adatechnology/game-vfx-three'\nimport { FragmentSystem } from './fragments'\nimport { GroundSpots } from './ground'\nimport type { Bound, HostVis, MeshVis, PartVis, PieceBody, PieceRound } from './internal'\nimport { clamp, createRng, hashNumbers, hashString } from './math'\nimport { PieceSystem } from './pieces'\nimport type { PieceSweepHit } from './pieces'\nimport { RebarCages } from './rebar'\nimport { partHintOf, specFrameInverse } from './spec'\nimport { surfaceOf } from './friction'\nimport { kitOriginOf } from '@adatechnology/game-contracts'\nimport { debrisColor, debrisLook, fragmentTone } from '@adatechnology/game-destruction'\nimport { familyPlay, HitPoints } from './debris-events'\nimport type { FamilyPlay } from './debris-events'\nimport type { DeferredQueue, WarmUpProbes } from '@adatechnology/game-contracts'\nimport type { DestructionRenderer, BindOptions, MakePieceOptions, ExplodeOptions, Mesh, MeshRange, Object3D, Piece, RendererOptions, SolidBox, SoundDetail, ThreeNamespace } from './types'\nimport { showCollapsedRanges, Visuals } from './visual'\nimport { SettlementView } from './settlement'\nimport { anchorOnMesh, anchorWorld } from './emitter-anchor'\nimport type { EmitterAnchor } from './emitter-anchor'\n\nlet rendererCount = 0\n/** Mass (kg) a collapse of furniture must bring down to raise the collapse effect's cloud; less (a shelf with its books) raises a puff of dust. */\nconst COLLAPSE_CLOUD_KG = 1000\n/** Colour of bare rebar (the cages' material) and of a bar that came down; the steel of a bar weighs this much per cubic metre when the catalogue has no steel. */\nconst REBAR_COLOR = 0x74665c\nconst STEEL_DENSITY = 7850\n/** Metres around a unit that came out within which its decals go too: the plaster over it and the ragged edge that breaks with it. */\nconst CHIP_DECAL_EDGE = 0.05\n/** Radius of the rim of torn fibres around a hole in wood, in hole diameters. */\nconst WOOD_RIM = 1.5\n\ntype Ev<T extends DestructionEvent['type']> = Extract<DestructionEvent, { type: T }>\n\nconst GLOW_FROM_C = 430\n/** A settlement crack is drawn at least this wide (m), so that a hairline still shows a few metres away; and in the colour of the open joint. */\nconst MIN_DRAWN_CRACK_WIDTH = 0.004\nconst SETTLEMENT_CRACK_COLOR = 0x2b2420\nconst QUEUE_CAP = 4000\n/** Seconds the grit of a broken hard face keeps falling (least, most), how often a pinch of it at first, and how many places at once. */\nconst TRICKLE_SECONDS: readonly [number, number] = [2, 5]\nconst TRICKLE_EVERY = 0.25\nconst TRICKLE_MAX = 24\n/**\n * Events the queue takes past `QUEUE_CAP`: what changes what is drawn (a part breaking off, a storey coming down, a fire starting or going out). A blast\n * floods the queue with damage, melt and drip events; dropping a collapse behind them leaves a fallen wall drawn standing.\n */\nconst STRUCTURAL_EVENTS: ReadonlySet<DestructionEventType> = new Set<DestructionEventType>([\n 'fracture', 'detach', 'collapse', 'settle', 'destroyed', 'expose', 'stage', 'hole', 'ignite', 'primed', 'extinguish', 'burnout', 'leak', 'explode',\n])\n/** Fragments of a fracture spawned in one go before the frame budget is looked at, so a small break is never split over frames. */\nconst MIN_FRAGMENTS_PER_SLICE = 8\n/** Seconds the boxes of the fixed objects the pieces land on are kept without an event (a host may move a root). */\nconst STATIC_REFRESH = 0.5\n/**\n * Milliseconds of the periodic re-measure per call: the refresh walks the objects a slice at a time (the dirty ones are measured at once).\n * Measuring every object in one call cost up to 88 ms in a frame of the horde chain (perf.mjs, software GL, 2026-11-03).\n */\nconst STATIC_REFRESH_SLICE_MS = 1\n/** Widest mesh (m, along x or z) a piece lands on by its box: furniture and things; a wider one (a roof, a merged room) would hold it on air. */\n/** Rays down `surfaceAt` casts at most, the distance under which a hit is the part it starts inside, and how far below such a hit it looks again (m). */\nconst SURFACE_RAYS = 4\nconst SURFACE_INSIDE = 0.005\nconst SURFACE_STEP = 0.15\nconst STATIC_SPAN = 3\n/** What counts as a foot of a piece (m above its lowest point); from what height (m) it can fall over and how close its feet are for that (share of the height). */\nconst FEET_BAND = 0.03\nconst TIP_MIN_HEIGHT = 0.3\nconst TIP_NARROW = 0.3\n/** Most meshes a loose piece of furniture touches the ground by, each by its own corners (`setContacts`); one with more stands on its box. */\nconst CONTACT_MESHES = 12\n/** Most meshes of a loose piece other pieces land on one by one (`partBoxes`: a shelf's boards, not the box around the shelf); one with more is landed on by its box. */\nconst PART_BOX_MESHES = 64\n/** Points of the drawing looked at to tell a round piece (per mesh), how alike its two other sides must be (share of the larger) and how far past their circle a point may be. */\nconst ROUND_SAMPLES = 400\nconst ROUND_SIDES = 0.12\nconst ROUND_SLACK = 1.12\n/** Points around each rim of a round piece (and around a ball's three great circles). */\nconst RIM_POINTS = 12\n\n/** The contacts of a round piece: two rims of `RIM_POINTS` at its ends (a cylinder), or three great circles (a ball), in its frame from the centre. */\nconst rimPoints = (round: PieceRound, half: Vec3): Vec3[] => {\n const out: Vec3[] = []\n const circle = (axis: 0 | 1 | 2, at: number, radius: number): void => {\n const [i, j] = axis === 0 ? [1, 2] : axis === 1 ? [0, 2] : [0, 1]\n for (let k = 0; k < RIM_POINTS; k++) {\n const a = (k / RIM_POINTS) * Math.PI * 2\n const p: Vec3 = [0, 0, 0]\n p[axis] = at\n p[i] = Math.cos(a) * radius\n p[j] = Math.sin(a) * radius\n out.push(p)\n }\n }\n if (round.kind === 'sphere') for (const axis of [0, 1, 2] as const) circle(axis, 0, round.radius)\n else {\n // each end by its own rim: a bottle stands on its base, and on its cap only as narrow as the cap is\n const ends = round.profile ?? []\n circle(round.axis, -half[round.axis], ends[0]?.[1] ?? round.radius)\n circle(round.axis, half[round.axis], ends[ends.length - 1]?.[1] ?? round.radius)\n }\n return out\n}\n/** Rings the profile of a round piece is measured in along its axis (`PieceRound.profile`): enough to tell a bottle's shoulder and neck from its body. */\nconst PROFILE_RINGS = 8\n/** k of I = k m r^2 about the axis: a thin cylindrical shell, a solid cylinder, a thin spherical shell and a solid ball. */\nconst SHELL_CYLINDER = 1\nconst SOLID_CYLINDER = 0.5\nconst SHELL_SPHERE = 2 / 3\nconst SOLID_SPHERE = 0.4\n/** Kg per litre of the liquid inside a round piece when its walls are weighed by what is left (water, soda, juice: about 1). */\nconst LIQUID_KG_PER_L = 1\n\n/**\n * The radius of a round piece along its axis, from the points of its drawing (its frame, from the centre of mass): the widest point of each of `PROFILE_RINGS` rings, the end rings\n * at the ends. Its lower hull (what a flat floor can touch it by) is kept: a ring under the line between its neighbours never touches (the neck of a bottle whose cap is as wide).\n */\nconst profileOf = (points: readonly Vec3[], axis: 0 | 1 | 2, half: number, radius: number): Array<readonly [number, number]> => {\n const [i, j] = axis === 0 ? [1, 2] : axis === 1 ? [0, 2] : [0, 1]\n const widest = new Array<number>(PROFILE_RINGS).fill(0)\n for (const p of points) {\n const ring = Math.min(PROFILE_RINGS - 1, Math.max(0, Math.floor(((p[axis] + half) / (2 * half)) * PROFILE_RINGS)))\n widest[ring] = Math.max(widest[ring], Math.hypot(p[i], p[j]))\n }\n const rings: Array<readonly [number, number]> = []\n for (let k = 0; k < PROFILE_RINGS; k++) {\n if (widest[k] <= 0) continue\n const at = k === 0 ? -half : k === PROFILE_RINGS - 1 ? half : -half + ((k + 0.5) / PROFILE_RINGS) * 2 * half\n rings.push([at, Math.min(radius, widest[k])])\n }\n // the outer hull of (at, radius): a ring inside the line from the one before it to the one after it is not touched\n const hull: Array<readonly [number, number]> = []\n for (const ring of rings) {\n while (hull.length >= 2) {\n const [a0, r0] = hull[hull.length - 2]\n const [a1, r1] = hull[hull.length - 1]\n // the middle one is under the line from the first to this ring: it never reaches the floor\n if ((r1 - r0) * (ring[0] - a0) <= (ring[1] - r0) * (a1 - a0)) hull.pop()\n else break\n }\n hull.push(ring)\n }\n return hull\n}\n\n/** How far (m) over its support what is left of a broken object may be and still stand; where under its lowest boxes the support is looked for (shares of the box). */\nconst BROKEN_GAP = 0.03\nconst BROKEN_SAMPLES: ReadonlyArray<readonly [number, number]> = [[0.5, 0.5], [0.1, 0.1], [0.9, 0.1], [0.1, 0.9], [0.9, 0.9]]\n/** Kinds of object that answer to a load path of their own (a house, a wall, the ground), not to `checkBroken`. */\nconst UNCHECKED_KINDS: ReadonlySet<string> = new Set(['structure', 'room', 'ground'])\n/** A part's fire lasts until the part stops burning (`stopFire`); this is only the ceiling the effects world needs. */\nconst FIRE_CEILING_SECONDS = 3600\n/** The `generic` explosion is the M67's (15 m injury radius): a blast with no effect id of its own scales with its radius. */\nconst GENERIC_REFERENCE_RADIUS = 15\n/** Largest half size (m) of the core of a piece swept for what it runs into: a sofa sweeps a small box at its centre, not the whole of it. */\nconst SWEEP_CORE = 0.15\n/** The small flame of a part that a bullet or fire primed: it burns until the part goes off. */\nconst PRIMED_FIRE_RADIUS = 0.2\n\ninterface FireEmitter {\n object: string\n part: string\n point: Vec3\n /** The burning part's position, moved every frame; the effects world's fire follows it. */\n follow: { x: number; y: number; z: number }\n /** Handle of the fire in the effects world, once the part's box is known. */\n handle?: number\n}\n\ninterface Leak {\n object: string\n part: string\n fluid: string\n point: Vec3\n direction: Vec3\n rate: number\n pressurized: boolean\n acc: number\n /** The part had a through opening when the leak began: the leak ends when it has none (a valve shut with `seal`). */\n opened: boolean\n localPoint?: Vec3\n localDirection?: Vec3\n lastLiters?: number\n idleSeconds?: number\n life?: number\n}\n\nconst FLUID_COLORS: Record<string, number> = {\n water: 0x8cc8ff,\n fuel: 0xd9a032,\n oil: 0x2a2018,\n gas: 0xf2f2f2,\n sap: 0xb89b3a,\n acid: 0x9bd23c,\n blood: 0x8a0a0a,\n soda: 0x3a1e12,\n coffee: 0x3b2414,\n beer: 0xd9953c,\n milk: 0xf4f1ea,\n wine: 0x6b101f,\n juice: 0xe8870b,\n}\nconst SMOKE_TONES: Record<string, number> = { white: 0xe6e6e6, grey: 0x8a8a8a, black: 0x2a2a2a }\n\nconst DEFAULT_SPEED: Record<string, number> = {\n sparks: 3,\n splinters: 2.5,\n dust: 1,\n shards: 2.5,\n fibers: 1.2,\n leaves: 1.2,\n drips: 0.5,\n ash: 0.8,\n chips: 2.5,\n smoke: 0.8,\n steam: 1,\n fire: 1.2,\n flash: 0,\n foam: 2.5,\n}\n\n/** Sound key for an impact on a material. */\nexport function impactKey(def: MaterialDef | undefined): string {\n if (!def) return 'impact_wood'\n const tags = def.tags ?? []\n if (tags.includes('metal')) return 'impact_metal'\n if (def.visual?.transparent || def.fracture === 'shatter') return 'impact_glass'\n if (def.fracture === 'crumble') return 'impact_masonry'\n if (def.fracture === 'tear') return 'impact_soft'\n return def.fracture === 'none' ? 'impact_metal' : 'impact_wood'\n}\n\n/** Sound key (`shot_*`) of a round striking this material: sharper than a blow (a tink on steel, a crack on glass); a host without it plays the `impact_*`. */\nexport const shotKey = (def: MaterialDef | undefined): string => impactKey(def).replace('impact_', 'shot_')\n\n/** Sound key (`drag_*`) of a base of this material dragged on a floor. */\nexport const dragSoundKey = (def: MaterialDef | undefined): string => impactKey(def).replace('impact_', 'drag_')\n\nfunction fractureKey(def: MaterialDef | undefined, style: string): string {\n switch (style) {\n case 'shatter':\n return 'shatter_glass'\n case 'crumble':\n return 'crumble'\n case 'splinter':\n return 'splinter'\n default:\n return impactKey(def)\n }\n}\n\n/** Colour of a material when the part gives none: its inside, a unit of it, or its family's (never wood brown on stone). */\nfunction fallbackColor(def: MaterialDef | undefined): number {\n return debrisColor(def)\n}\n\nfunction materialsOf(m: THREE_NS.Material | THREE_NS.Material[]): THREE_NS.Material[] {\n return Array.isArray(m) ? m : [m]\n}\n\nfunction isMeshRange(v: Object3D | MeshRange): v is MeshRange {\n const r = v as Partial<MeshRange>\n return !!r.mesh && Array.isArray(r.range)\n}\n\n/** Create the renderer. See `DestructionRenderer`. */\n/** The seed of the renderer's random stream; `reset` takes it back here. */\nconst RNG_SEED = 0xc0ffee\n\n/** The renderer this package makes always has its `deferredQueue`; a third-party `DestructionRenderer` may leave it out. */\nexport function createDestructionRenderer(THREE: ThreeNamespace, options: RendererOptions): DestructionRenderer & { deferredQueue(): DeferredQueue } {\n return new Renderer(THREE, options)\n}\n\nclass Renderer implements DestructionRenderer {\n private readonly world: RendererOptions['world']\n private readonly scene: THREE_NS.Scene\n private readonly quality: 'low' | 'medium' | 'high'\n private readonly low: boolean\n private readonly groundAt: (x: number, z: number) => number\n private readonly gravity: number\n private readonly autoSplit: boolean\n private readonly maxFragments: number\n private readonly eventBudgetMs: number\n private readonly bounds = new Map<string, Bound>()\n /** World boxes (min xyz, max xyz) of the drawn meshes of the bound objects that are not pieces, for the pieces to land on. */\n private readonly staticBoxes = new Map<string, number[]>()\n /** Objects to measure again; `staticAll` measures every one. */\n private readonly staticDirty = new Set<string>()\n private staticAll = true\n /** The periodic refresh: the objects still to measure again in this round, a slice per call. */\n private staticRound: string[] = []\n /** Boxes of the pieces' meshes (as `staticBoxes`), with the time they were measured. */\n private readonly pieceBoxes = new WeakMap<PieceBody, { at: number; boxes: number[] }>()\n /** Objects broken since the last update: `checkBroken` looks at what is left of them. */\n private readonly broken = new Set<string>()\n private staticAt = 0\n private readonly queue: DestructionEvent[] = []\n /** The cover of each body around a part of the world that went off, read as the event is emitted: before the blast tore or moved anything. */\n private readonly coverWhenWentOff = new WeakMap<DestructionEvent, Map<string, number>>()\n /** Places a blow broke a hard face at: grit and dust keep coming off them for a few seconds, less and less (`TRICKLE_SECONDS`). */\n private readonly trickles: Array<{ point: Vec3; normal: Vec3; anchor: EmitterAnchor | null; color: number | undefined; left: number; total: number; next: number }> = []\n /** Presentation work an event left for later frames (fragments still to spawn, loose groups still to split), run in order within the frame budget. */\n private readonly slices: Array<() => void> = []\n /** When the work of this frame must stop; `Infinity` outside a drain, where a call finishes what it started. */\n private sliceDeadline = Infinity\n /** The clock the drain reads; a budget lends its own while it runs the queue. */\n private drainClock: () => number = () => performance.now()\n /** true once a frame budget owns the draining: `update` no longer drains by itself. */\n private attached = false\n private readonly eventQueue: DeferredQueue = {\n id: DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS,\n pending: () => this.queue.length + this.slices.length,\n run: (deadline, clock) => this.runBudgeted(deadline, clock),\n flush: () => {\n for (let guard = 0; guard < 16 && this.queue.length + this.slices.length > 0; guard++) this.runBudgeted(Infinity, () => 0)\n },\n attach: () => {\n this.attached = true\n },\n detach: () => {\n this.attached = false\n },\n }\n private readonly unsubscribe: () => void\n private readonly visuals: Visuals\n /** The parts the ground went down under, drawn going down (`subside`). */\n private readonly settlement: SettlementView\n private readonly fragments: FragmentSystem\n private readonly ground: GroundSpots\n private readonly pieceSys: PieceSystem\n private readonly cages: RebarCages\n private readonly hitPoints = new HitPoints()\n private readonly active = new Map<string, { object: string; part: string }>()\n private readonly fires = new Map<string, FireEmitter>()\n /** Primed parts burning in the effects world until they go off: their burn loop ends when they are put out. */\n private readonly primedBurning = new Set<string>()\n /** The burn loops asked of the host and not yet ended, by part: whatever stops a part's fire ends its loop, once, with what it started with. */\n private readonly burnSounds = new Map<string, { readonly object: string; readonly point: Vec3; readonly detail: SoundDetail | undefined }>()\n private readonly leaks: Leak[] = []\n private readonly homeTags: string[] = []\n private readonly throttles = new Map<string, number>()\n private rng = createRng(RNG_SEED)\n private readonly vfx: VfxWorld\n /** Names this renderer to the world's drips, so a shared world tells each renderer where its own landed. */\n private readonly owner = `destruction-${++rendererCount}`\n private readonly stopLanding: () => void\n /** The effects renderer made here when the host gave no shared world; it is stepped in `update`. */\n private readonly ownVfx: VfxRenderer | undefined\n private time = 0\n private scanTimer = 0\n private disposed = false\n private readonly box: THREE_NS.Box3\n private readonly tmpQ: THREE_NS.Quaternion\n private readonly v1: THREE_NS.Vector3\n private readonly v2: THREE_NS.Vector3\n\n constructor(\n private readonly THREE: ThreeNamespace,\n private readonly o: RendererOptions,\n ) {\n this.world = o.world\n this.scene = o.scene\n this.quality = o.quality ?? 'medium'\n this.low = this.quality === 'low'\n this.groundAt = o.groundAt ?? (() => 0)\n this.gravity = o.gravity ?? 9.81\n this.autoSplit = o.autoSplit !== false\n this.maxFragments = o.maxFragments ?? 160\n this.eventBudgetMs = o.eventBudgetMs ?? Infinity\n this.box = new THREE.Box3()\n this.tmpQ = new THREE.Quaternion()\n this.v1 = new THREE.Vector3()\n this.v2 = new THREE.Vector3()\n const maxParticles = Math.max(8, Math.floor((o.maxParticles ?? 2500) * (this.low ? 0.5 : 1)))\n this.visuals = new Visuals(THREE, this.low, 600)\n this.settlement = new SettlementView(THREE, this.visuals)\n this.ground = new GroundSpots(THREE, o.scene, this.groundAt, 48)\n if (!o.vfx) warnOnce('game-destruction-three.own-effects-world', 'game-destruction-three made an effects world of its own because the host lent none (options.vfx); pass the host effects so the effects share one budget')\n this.vfx = o.vfx ?? createVfx({ profile: this.quality, gravity: this.gravity, groundAt: this.groundAt, sprites: { capacity: maxParticles, density: this.low ? 0.6 : 1 } })\n this.ownVfx = o.vfx ? undefined : createVfxRenderer(THREE, { scene: o.scene, camera: o.camera ?? new THREE.PerspectiveCamera(), vfx: this.vfx, pointScale: o.pointScale ?? 700 })\n this.stopLanding = this.vfx.onLand(this.owner, (x, _y, z, color, tag) => {\n const home = this.homeTags[tag - 1] ?? ''\n this.ground.add('puddle', x, z, 0.05 + this.rng() * 0.04, color, home)\n })\n this.fragments = new FragmentSystem(THREE, {\n scene: o.scene,\n groundAt: this.groundAt,\n gravity: this.gravity,\n max: this.maxFragments,\n life: o.fragmentLife ?? 12,\n formOf: (id) => this.world.materials.get(id)?.splitForm,\n crumbles: (id) => this.world.materials.get(id)?.fracture === 'crumble',\n // rubble lands on what is still built (a slab, a wall's top, a floor), not only on the terrain under it\n surfaceAt: (x, y, z) => this.surfaceAt(x, y, z),\n })\n this.cages = new RebarCages(THREE, o.scene)\n this.pieceSys = new PieceSystem(THREE, {\n groundAt: this.groundAt,\n staticTopAt: (x, z, y, step) => this.staticTopAt(x, z, y, step),\n gravity: this.gravity,\n scene: o.scene,\n onHardLanding: (p, point, speed) => this.hardLanding(p, point, speed),\n sweep: (p, from, to) => this.sweepPiece(p, from, to),\n onSlam: (p, hit, speed) => this.slam(p, hit, speed),\n // two pieces knocked together: each sounds as its material does (a can on a can, a bottle on a table's leg)\n onKnock: (a, b, point, speed) => {\n this.landingSound(a.objectId, point, clamp(speed / 10, 0.2, 1))\n this.landingSound(b.objectId, point, clamp(speed / 10, 0.2, 1))\n },\n })\n this.unsubscribe = this.world.on('*', (ev) => {\n if (ev.type === 'explode') this.coverWhenWentOff.set(ev, this.coverAround(ev))\n if (this.queue.length < QUEUE_CAP || STRUCTURAL_EVENTS.has(ev.type)) this.queue.push(ev)\n })\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Binding\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n bind(objectId: string, root: Object3D, options: BindOptions = {}): void {\n this.staticDirty.add(objectId)\n if (this.bounds.has(objectId)) this.unbind(objectId)\n const state = this.world.state(objectId)\n const partIds = new Set((state?.parts ?? []).map((p) => p.id))\n const byPart = new Map<string, Array<{ mesh: Mesh; range?: [number, number] }>>()\n const taken = new Set<Mesh>()\n const put = (pid: string, e: { mesh: Mesh; range?: [number, number] }): void => {\n const l = byPart.get(pid)\n if (l) l.push(e)\n else byPart.set(pid, [e])\n }\n const add = (pid: string, m: Mesh): void => {\n if (taken.has(m)) return\n taken.add(m)\n put(pid, { mesh: m })\n }\n const addRange = (pid: string, r: MeshRange): void => {\n const n = (r.mesh.geometry.getAttribute('position')?.count ?? 0) as number\n const [v0, v1] = r.range\n if (!Number.isInteger(v0) || !Number.isInteger(v1) || v0 < 0 || v1 <= v0 || v1 > n) {\n throw new Error(`game-destruction-three: invalid vertex range [${v0}, ${v1}) for part \"${pid}\" (the mesh has ${n} vertices)`)\n }\n put(pid, { mesh: r.mesh, range: [v0, v1] })\n }\n const meshesIn = (o: Object3D): Mesh[] => {\n const out: Mesh[] = []\n o.traverse((c) => {\n if ((c as Mesh).isMesh) out.push(c as Mesh)\n })\n return out\n }\n if (options.parts) {\n for (const [pid, v] of Object.entries(options.parts)) {\n for (const o of Array.isArray(v) ? v : [v]) {\n if (isMeshRange(o)) addRange(pid, o)\n else for (const m of meshesIn(o)) add(pid, m)\n }\n }\n } else {\n const leftovers: Mesh[] = []\n for (const m of meshesIn(root)) {\n const ud = partHintOf(m.userData?.destructionPart)?.id\n if (ud !== undefined && partIds.has(ud)) add(ud, m)\n else if (partIds.has(m.name)) add(m.name, m)\n else leftovers.push(m)\n }\n if (leftovers.length) this.matchByBox(objectId, root, leftovers, add)\n }\n const bound: Bound = { id: objectId, root, sync: options.syncTransform !== false, parts: new Map(), lastPos: null, lastQuat: null, piece: null, isSplit: false }\n if (options.onFrame) bound.onFrame = options.onFrame\n const hosts = new Map<Mesh, HostVis>()\n for (const pid of partIds) bound.parts.set(pid, this.makePartVis(objectId, pid, state?.parts.find((p) => p.id === pid)?.material ?? '', byPart.get(pid) ?? [], hosts))\n for (const [pid, meshes] of byPart) {\n if (!bound.parts.has(pid)) bound.parts.set(pid, this.makePartVis(objectId, pid, this.world.part(objectId, pid)?.material ?? '', meshes, hosts))\n }\n this.bounds.set(objectId, bound)\n for (const pv of bound.parts.values()) this.tagPart(pv, objectId)\n }\n\n /**\n * Label the meshes of a part so a host can go from a raycast hit to the world: `userData.destructionPart` (the part id) and\n * `userData.destructionObject` (the id of the world object that part belongs to now; a loose piece has an id of its own). Parts drawn by a range\n * of a merged mesh share that mesh with others and are left alone until they get a mesh of their own. Decals are marked `destructionDebris`.\n */\n private tagPart(pv: PartVis, objectId: string): void {\n for (const mv of pv.meshes) {\n if (mv.merged && !mv.loose) continue\n mv.mesh.traverse((c) => {\n if (!(c as Mesh).isMesh) return\n const ud = c.userData as Record<string, unknown>\n if (ud.destructionDebris) return\n if (partHintOf(ud.destructionPart)?.id !== pv.id) ud.destructionPart = pv.id\n ud.destructionObject = objectId\n })\n }\n }\n\n private makePartVis(home: string, id: string, material: string, meshes: Array<{ mesh: Mesh; range?: [number, number] }>, hosts: Map<Mesh, HostVis>): PartVis {\n return { id, home, material, meshes: meshes.map((m) => this.visuals.makeMeshVis(m.mesh, home, m.range, hosts)), charApplied: 0, glowApplied: 0, meltApplied: 0, gone: 'none' }\n }\n\n /** Match unlabelled meshes to the part whose shape contains the centre of the mesh's bounding box. */\n private matchByBox(objectId: string, root: Object3D, meshes: Mesh[], add: (pid: string, m: Mesh) => void): void {\n let specParts: PartSpec[] | undefined\n try {\n specParts = this.world.serialize?.().objects.find((o) => o.id === objectId)?.spec.parts\n } catch {\n specParts = undefined\n }\n if (!specParts) return\n const frame = specFrameInverse(this.THREE, root)\n const e = new this.THREE.Euler()\n const q = new this.THREE.Quaternion()\n for (const m of meshes) {\n this.box.setFromObject(m)\n if (this.box.isEmpty()) continue\n const c = this.box.getCenter(this.v1).applyMatrix4(frame)\n let best: PartSpec | null = null\n let bestVol = Infinity\n for (const p of specParts) {\n const l = this.v2.set(c.x - p.position[0], c.y - p.position[1], c.z - p.position[2])\n if (p.rotation) l.applyQuaternion(q.setFromEuler(e.set(p.rotation[0], p.rotation[1], p.rotation[2], 'XYZ')).invert())\n let inside = false\n let vol = 0\n const s = p.shape\n if (s.kind === 'box') {\n inside = Math.abs(l.x) <= s.size[0] / 2 && Math.abs(l.y) <= s.size[1] / 2 && Math.abs(l.z) <= s.size[2] / 2\n vol = s.size[0] * s.size[1] * s.size[2]\n } else if (s.kind === 'cylinder') {\n inside = Math.hypot(l.x, l.z) <= s.radius && Math.abs(l.y) <= s.height / 2\n vol = Math.PI * s.radius * s.radius * s.height\n } else {\n inside = l.length() <= s.radius\n vol = (4 / 3) * Math.PI * s.radius ** 3\n }\n if (inside && vol < bestVol) {\n best = p\n bestVol = vol\n }\n }\n if (best) add(best.id, m)\n }\n }\n\n unbind(objectId: string): void {\n this.staticDirty.add(objectId)\n const b = this.bounds.get(objectId)\n if (!b) return\n this.restore(objectId)\n this.pieceSys.remove(objectId)\n this.bounds.delete(objectId)\n this.hitPoints.forget(objectId)\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Pieces\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n /** Half extents and centre of the box around some meshes, in the metric frame of `root` (its pose removed, its scale kept). */\n private measure(root: Object3D, meshes: MeshVis[]): { half: Vec3; center: THREE_NS.Vector3 } {\n const inv = specFrameInverse(this.THREE, root)\n const total = new this.THREE.Box3()\n const m4 = new this.THREE.Matrix4()\n const lb = new this.THREE.Box3()\n for (const mv of meshes) {\n const m = mv.mesh\n m.updateWorldMatrix(true, false)\n this.visuals.localBox(mv, lb)\n if (lb.isEmpty()) continue\n total.union(lb.clone().applyMatrix4(m4.multiplyMatrices(inv, m.matrixWorld)))\n }\n if (total.isEmpty()) return { half: [0.25, 0.25, 0.25], center: new this.THREE.Vector3() }\n const size = total.getSize(new this.THREE.Vector3())\n return { half: [Math.max(0.02, size.x / 2), Math.max(0.02, size.y / 2), Math.max(0.02, size.z / 2)], center: total.getCenter(new this.THREE.Vector3()) }\n }\n\n private meshesOf(b: Bound): MeshVis[] {\n const out: MeshVis[] = []\n for (const pv of b.parts.values()) if (pv.gone === 'none') for (const mv of pv.meshes) out.push(mv)\n return out\n }\n\n private massOf(objectId: string): number {\n const st = this.world.state(objectId)\n if (!st) return 5\n let m = 0\n for (const p of st.parts) if (p.status !== 'broken' && p.status !== 'melted' && p.status !== 'ashes') m += p.mass\n return m > 0 ? m : 5\n }\n\n makePiece(objectId: string, options: MakePieceOptions = {}): Piece {\n this.staticDirty.add(objectId)\n const b = this.bounds.get(objectId)\n if (!b) throw new Error(`game-destruction-three: object \"${objectId}\" is not bound`)\n if (b.root.parent && b.root.parent !== this.scene) this.scene.attach(b.root)\n const { half, center } = this.measure(b.root, this.meshesOf(b))\n const piece = this.pieceSys.create(objectId, b.root, half, center, options.mass ?? this.massOf(objectId), options.velocity)\n b.piece = piece\n this.fitSurface(b, piece, options.inertia)\n this.fitPartBoxes(b, piece)\n return piece\n }\n\n /**\n * What lands on or runs into a piece of several meshes meets its parts as drawn (`partBoxes`: a bench's slats, a table's top and legs), from the moment it is made a piece, not\n * the box around them all: a board laid on a bench rests on its seat, a can rolls under a table between its legs. Its own contacts with the ground are left as they were.\n */\n private fitPartBoxes(b: Bound, body: PieceBody): void {\n if (body.round) return\n const contacts = body.contacts\n this.setContacts(b, body, this.meshesOf(b).filter((mv) => this.visuals.shown(mv)))\n body.contacts = contacts\n }\n\n /** What the piece's surface is (the friction of the material it stands on) and whether it is round (`round`: it rolls on rings of contacts). */\n private fitSurface(b: Bound, body: PieceBody, inertia?: number): void {\n // the surface it stands on is its lowest part (a sofa's feet, a can's steel), whatever most of its weight is\n const box = new this.THREE.Box3()\n let low = Infinity\n let material: string | null = null\n for (const [partId, pv] of b.parts) {\n if (pv.gone !== 'none') continue\n for (const mv of pv.meshes) {\n if (!this.visuals.shown(mv)) continue\n this.visuals.worldBox(mv, box)\n if (box.isEmpty() || box.min.y >= low - 0.005) continue\n low = box.min.y\n material = this.world.part(b.id, partId)?.material ?? pv.material ?? null\n }\n }\n const surface = material ? surfaceOf(material, this.world.materials.get(material)) : undefined\n body.friction = surface && { static: surface.static, dynamic: surface.dynamic, rolling: surface.rolling }\n body.restitution = surface?.restitution\n const wasRound = body.round !== undefined\n if (inertia !== undefined) body.inertiaGiven = inertia\n const round = this.roundOf(b, body)\n body.round = round ?? undefined\n if (round) {\n body.contacts = rimPoints(round, body.halfExtents)\n body.partBoxes = undefined\n } else if (wasRound) body.contacts = undefined\n }\n\n /**\n * k of a round piece's moment of inertia about its axis (I = k m r^2), from where its mass is. A piece that is not hollow is a solid (k 1/2 for a cylinder, 2/5 for a ball).\n * A hollow one (`userData.hollow`) with nothing inside (no `destructionContains` liquid, no `destructionPowder`) is all wall, a thin shell (k 1, 2/3): an empty can. One with\n * contents weighs its walls as their area times their thickness (`destructionThickness`) times density, or, without a thickness, as what is left of its mass besides the liquid\n * (`LIQUID_KG_PER_L`), and the rest as a solid: a full 350 ml can comes to about 0.53 and rolls down a slope at g sin t / 1.53, an empty one at g sin t / 2.\n */\n private inertiaOf(b: Bound, body: PieceBody, kind: PieceRound['kind'], axis: 0 | 1 | 2, radius: number): number {\n const shell = kind === 'sphere' ? SHELL_SPHERE : SHELL_CYLINDER\n const solid = kind === 'sphere' ? SOLID_SPHERE : SOLID_CYLINDER\n let hollow = false\n let filled = false\n let liters = 0\n let thickness = 0\n let material: string | null = null\n for (const [partId, pv] of b.parts) {\n if (pv.gone !== 'none') continue\n for (const mv of pv.meshes) {\n const ud = mv.mesh.userData as { hollow?: unknown; destructionThickness?: unknown; destructionContains?: { liters?: unknown }; destructionPowder?: unknown }\n if (ud.hollow !== true) continue\n hollow = true\n if (ud.destructionPowder) filled = true\n if (ud.destructionContains) {\n filled = true\n // what is left in it now (drunk or leaked), else what it was filled with\n const left = this.world.part(b.id, partId)?.liters\n liters += left ?? (typeof ud.destructionContains.liters === 'number' ? ud.destructionContains.liters : 0)\n }\n const t = typeof ud.destructionThickness === 'number' ? ud.destructionThickness : 0\n if (t > thickness) {\n thickness = t\n material = this.world.part(b.id, partId)?.material ?? pv.material\n }\n }\n }\n if (!hollow) return solid\n if (!filled) return shell\n const density = material ? this.world.materials.get(material)?.density : undefined\n const area = kind === 'sphere' ? 4 * Math.PI * radius * radius : 2 * Math.PI * radius * 2 * body.halfExtents[axis] + 2 * Math.PI * radius * radius\n const walls = density && thickness > 0 ? area * thickness * density : body.mass - liters * LIQUID_KG_PER_L\n const share = clamp(walls / body.mass, 0, 1)\n return share * shell + (1 - share) * solid\n }\n\n /**\n * Whether what is drawn of the piece is round about one of its axes (a can, a bottle, a plate) or all of them (a ball): its points, in its frame from the centre of\n * mass, all lie within the circle the box's two other sides draw (a box's corners would stick out of it by sqrt 2). Null for anything else.\n */\n private roundOf(b: Bound, body: PieceBody): PieceRound | null {\n const half = body.halfExtents\n const inv = specFrameInverse(this.THREE, b.root)\n const m4 = new this.THREE.Matrix4()\n const p = new this.THREE.Vector3()\n const [cx, cy, cz] = body.localCenter\n const points: Vec3[] = []\n for (const mv of this.meshesOf(b)) {\n if (!this.visuals.shown(mv) || mv.host) continue\n const pos = (mv.mesh.geometry as THREE_NS.BufferGeometry).getAttribute('position')\n if (!pos) continue\n mv.mesh.updateWorldMatrix(true, false)\n m4.multiplyMatrices(inv, mv.mesh.matrixWorld)\n const stride = Math.max(1, Math.floor(pos.count / ROUND_SAMPLES))\n for (let i = 0; i < pos.count; i += stride) {\n p.fromBufferAttribute(pos, i).applyMatrix4(m4)\n points.push([p.x - cx, p.y - cy, p.z - cz])\n }\n }\n if (points.length < 12) return null\n const fits = (axis: 0 | 1 | 2): number | null => {\n const [i, j] = axis === 0 ? [1, 2] : axis === 1 ? [0, 2] : [0, 1]\n // the two other sides alike, and no point out past the circle they draw\n if (Math.abs(half[i] - half[j]) > ROUND_SIDES * Math.max(half[i], half[j])) return null\n const radius = (half[i] + half[j]) / 2\n for (const q of points) if (Math.hypot(q[i], q[j]) > radius * ROUND_SLACK) return null\n return radius\n }\n const radii = ([0, 1, 2] as const).map(fits)\n if (radii.every((r) => r !== null)) {\n const radius = (half[0] + half[1] + half[2]) / 3\n return { kind: 'sphere', axis: 1, radius, inertia: body.inertiaGiven ?? this.inertiaOf(b, body, 'sphere', 1, radius) }\n }\n const axis = ([0, 1, 2] as const).find((k) => radii[k] !== null)\n if (axis === undefined) return null\n const radius = radii[axis] ?? 0\n return { kind: 'cylinder', axis, radius, inertia: body.inertiaGiven ?? this.inertiaOf(b, body, 'cylinder', axis, radius), profile: profileOf(points, axis, half[axis], radius) }\n }\n\n pieces(): Piece[] {\n return [...this.pieceSys.list]\n }\n\n piece(objectId: string): Piece | null {\n return this.pieceSys.get(objectId)\n }\n\n impulse(objectId: string, impulse: Vec3, point?: Vec3): void {\n const p = this.pieceSys.get(objectId)\n if (p) this.pieceSys.impulse(p, impulse, point)\n }\n\n /**\n * What a piece moving from `from` to `to` runs into: the core of its box (its thinnest half each way, at most `SWEEP_CORE`) swept through the world, the piece itself left out,\n * so a crate thrown by a blast stops at the wall instead of passing through it. Null for a world that cannot sweep.\n */\n private sweepPiece(p: PieceBody, from: Vec3, to: Vec3): PieceSweepHit | null {\n if (typeof this.world.sweepBox !== 'function') return null\n const d: Vec3 = [to[0] - from[0], to[1] - from[1], to[2] - from[2]]\n const travel = Math.hypot(d[0], d[1], d[2])\n if (travel < 1e-4) return null\n const core = Math.min(SWEEP_CORE, ...p.halfExtents)\n const box = { min: [from[0] - core, from[1] - core, from[2] - core] as Vec3, max: [from[0] + core, from[1] + core, from[2] + core] as Vec3 }\n const hit = this.world.sweepBox(box, d, travel, { ignore: p.objectId, spacing: Math.max(0.05, core) })\n if (!hit) return null\n // a round piece and another piece meet by their shapes and trade momentum (`PieceSystem.knock`), not as a piece against a wall\n const other = this.pieceSys.get(hit.object)\n if (other && (p.round || other.round)) return null\n const material = this.world.part(hit.object, hit.part)?.material\n const restitution = material === undefined ? undefined : surfaceOf(material, this.world.materials.get(material))?.restitution\n return { object: hit.object, part: hit.part, distance: hit.distance, point: hit.point, normal: hit.normal, ...(restitution === undefined ? {} : { restitution }) }\n }\n\n /** A piece thrown into a wall: the wall takes the blow of its weight where it met it, the piece takes it too, and each sounds as its material does. */\n private slam(p: PieceBody, hit: PieceSweepHit, speed: number): void {\n const energy = 0.5 * p.mass * speed * speed\n const direction: Vec3 = [-hit.normal[0], -hit.normal[1], -hit.normal[2]]\n this.landingSound(hit.object, hit.point, clamp(speed / 10, 0.2, 1))\n this.syncBound(p.objectId)\n try {\n this.world.hitPart(hit.object, hit.part, { type: 'blunt', point: hit.point, energy, radius: 0.1, direction, normal: hit.normal, source: p.objectId })\n this.world.hit(p.objectId, { type: 'blunt', point: hit.point, energy, radius: 0.08, direction: hit.normal, source: 'slam' })\n } catch {\n // either may have left the world\n }\n }\n\n private hardLanding(p: PieceBody, point: Vec3, speed: number): void {\n this.landingSound(p.objectId, point, clamp(speed / 10, 0.2, 1))\n // the piece just moved this frame: the world must know where it is before the hit is resolved against its parts\n this.syncBound(p.objectId)\n try {\n this.world.hit(p.objectId, { type: 'blunt', point, energy: 0.5 * p.mass * speed * speed, radius: 0.08, direction: [0, -1, 0], source: 'fall' })\n } catch {\n // the object may have been removed from the world\n }\n }\n\n /** The impact of the heaviest part of an object (a piece landing): its material and the blunt blow of the fall. */\n private landingSound(objectId: string, point: Vec3, volume: number): void {\n const st = this.world.state(objectId)\n let best = ''\n let mass = -1\n for (const p of st?.parts ?? []) {\n if (p.mass > mass) {\n mass = p.mass\n best = p.material\n }\n }\n this.impactSound(best, point, volume, 'blunt')\n }\n\n /** The impact on a material by a blow: the legacy family key (`impactKey`) with the more specific keys to try first (`impactSoundKeys`). */\n private impactSound(material: string, point: Vec3, volume: number, blow?: DamageType): void {\n const def = this.world.materials.get(material)\n this.sound(impactKey(def), point, volume, impactSoundKeys(material, def, blow))\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Update\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n update(dt: number): void {\n if (this.disposed) return\n dt = clamp(dt, 0, 0.1)\n this.time += dt\n if (!this.attached) this.drainQueue()\n this.checkBroken()\n for (const b of this.bounds.values()) b.onFrame?.(dt)\n // a settling object keeps moving between its (throttled) `settle` events\n for (const b of this.bounds.values()) if (b.soilNode && this.world.state(b.id)?.soil?.status === 'yielding') this.onSettle(b.id)\n this.settlement.update(dt)\n this.pieceSys.update(dt)\n this.fragments.update(dt)\n // what goes on at a part (fire, leaks, trickling grit) reads where the part is after the bodies moved this frame, not a frame behind\n this.updateActive(dt)\n this.updateLeaks(dt)\n this.updateTrickles(dt)\n this.ground.update(dt)\n this.ownVfx?.update(dt)\n this.syncTransforms()\n }\n\n deferredQueue(): DeferredQueue {\n return this.eventQueue\n }\n\n private drainQueue(): void {\n this.runBudgeted(performance.now() + this.eventBudgetMs, () => performance.now())\n }\n\n /** Applies the waiting events in order until the deadline, after the slices earlier events left; always at least one unit when something waits. Returns the units run. */\n private runBudgeted(deadline: number, clock: () => number): number {\n // events produced while applying (a hard landing calls `hit`) wait for the next frame\n const batch = this.queue.splice(0, this.queue.length)\n const outerClock = this.drainClock\n this.drainClock = clock\n this.sliceDeadline = deadline\n let ran = 0\n try {\n ran = this.runSlices(deadline)\n for (let i = 0; i < batch.length; i++) {\n if ((i > 0 || (ran > 0 && this.attached)) && clock() >= deadline) {\n this.queue.unshift(...batch.slice(i))\n return ran\n }\n try {\n this.apply(batch[i]!)\n } catch (err) {\n if (typeof console !== 'undefined') console.error('game-destruction-three: failed to apply', batch[i]!.type, err)\n }\n ran++\n }\n } finally {\n this.sliceDeadline = Infinity\n this.drainClock = outerClock\n }\n return ran\n }\n\n /** Runs the work left by earlier frames until the deadline; at least one piece per frame, so it always finishes. */\n private runSlices(deadline: number): number {\n let ran = 0\n for (; this.slices.length > 0 && (ran === 0 || this.drainClock() < deadline); ran++) {\n try {\n this.slices.shift()!()\n } catch (err) {\n if (typeof console !== 'undefined') console.error('game-destruction-three: failed to run deferred work', err)\n }\n }\n return ran\n }\n\n /**\n * The ground under an object settled or tilted: its parts are drawn under a node with the soil's offset (`ObjectState.soil.offset`), so the host's\n * root keeps the pose the host gave and the world keeps getting it from `syncTransform`.\n */\n private onSettle(objectId: string): void {\n const b = this.bounds.get(objectId)\n const soil = this.world.state(objectId)?.soil\n if (!b || !soil) return\n let node = b.soilNode\n if (!node) {\n node = new this.THREE.Group()\n node.name = 'destruction-soil'\n for (const c of [...b.root.children]) node.add(c)\n b.root.add(node)\n b.soilNode = node\n }\n const { position: p, rotation: q } = soil.offset\n node.position.set(p[0], p[1], p[2])\n node.quaternion.set(q[0], q[1], q[2], q[3])\n node.updateMatrixWorld(true)\n }\n\n /** The ground went down under some parts of an object: each part with a settlement (`PartState.settlement`) starts going down to it. */\n private onSubside(objectId: string): void {\n const b = this.bounds.get(objectId)\n const state = this.world.state(objectId)\n if (!b || !state) return\n const parts: Array<readonly [PartVis, PartSettlement | undefined]> = []\n for (const ps of state.parts) {\n const pv = b.parts.get(ps.id)\n if (pv && ps.settlement) parts.push([pv, ps.settlement])\n }\n this.settlement.follow(b.soilNode ?? b.root, parts)\n }\n\n private syncTransforms(): void {\n for (const b of this.bounds.values()) this.syncOne(b)\n }\n\n /** Push the current transform of one bound object to the world right now (used before a landing hit). */\n private syncBound(objectId: string): void {\n const b = this.bounds.get(objectId)\n if (b) this.syncOne(b)\n }\n\n private syncOne(b: Bound): void {\n if (!b.sync) return\n const p = this.v1\n const q = this.tmpQ\n b.root.updateWorldMatrix(true, false)\n b.root.matrixWorld.decompose(p, q, this.v2)\n const last = b.lastPos\n const lq = b.lastQuat\n const moved = !last || !lq || Math.abs(p.x - last[0]) + Math.abs(p.y - last[1]) + Math.abs(p.z - last[2]) > 1e-5 || Math.abs(q.x - lq[0]) + Math.abs(q.y - lq[1]) + Math.abs(q.z - lq[2]) + Math.abs(q.w - lq[3]) > 1e-6\n if (!moved) return\n b.lastPos = [p.x, p.y, p.z]\n b.lastQuat = [q.x, q.y, q.z, q.w]\n if (this.world.has(b.id)) this.world.setTransform(b.id, [p.x, p.y, p.z], [q.x, q.y, q.z, q.w])\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Events\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n /**\n * The highest top of a bound object that is not a piece under (x, z) a corner at height `y` can land on (at most `step` above it). The world boxes\n * of their drawn meshes are kept until an event or a moved root changes them; parts drawn inside a merged mesh and meshes wider than `STATIC_SPAN`\n * are left out (walls, floors, roofs: the terrain under them is the host's `groundAt`).\n */\n private staticTopAt(x: number, z: number, y: number, step: number): number {\n let top = -Infinity\n for (const a of this.staticNow().values()) {\n // the first six numbers are the box around all of the object's boxes\n if (a.length === 0 || x < a[0] || x > a[3] || z < a[2] || z > a[5]) continue\n for (let i = 6; i < a.length; i += 6) {\n if (x < a[i] || x > a[i + 3] || z < a[i + 2] || z > a[i + 5]) continue\n const t = a[i + 4]\n if (t > top && t <= y + step) top = t\n }\n }\n return top\n }\n\n /** The boxes of the fixed objects (per object: the box around them all, then each one), each object measured again when an event touched it (all of them every `STATIC_REFRESH` s). */\n private staticNow(): Map<string, number[]> {\n if (this.time - this.staticAt > STATIC_REFRESH) {\n this.staticAt = this.time\n if (this.staticRound.length === 0) this.staticRound = [...this.bounds.keys()].reverse()\n }\n if (!this.staticAll && this.staticDirty.size === 0 && this.staticRound.length === 0) return this.staticBoxes\n const box = new this.THREE.Box3()\n const measure = (b: Bound): void => {\n if (b.piece || this.pieceSys.get(b.id)) {\n this.staticBoxes.delete(b.id)\n return\n }\n const out: number[] = [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity]\n for (const mv of this.meshesOf(b)) {\n if (mv.host || mv.loose || !this.visuals.shown(mv)) continue\n this.visuals.worldBox(mv, box)\n if (box.isEmpty() || box.max.x - box.min.x > STATIC_SPAN || box.max.z - box.min.z > STATIC_SPAN) continue\n this.visuals.fittedBoxes(mv, out)\n for (let k = 0; k < 3; k++) {\n out[k] = Math.min(out[k], box.min.getComponent(k))\n out[k + 3] = Math.max(out[k + 3], box.max.getComponent(k))\n }\n }\n this.staticBoxes.set(b.id, out.length > 6 ? out : [])\n }\n const measureId = (id: string): void => {\n const b = this.bounds.get(id)\n if (b) measure(b)\n else this.staticBoxes.delete(id)\n }\n if (this.staticAll) {\n this.staticBoxes.clear()\n for (const b of this.bounds.values()) measure(b)\n this.staticRound = []\n } else {\n for (const id of this.staticDirty) measureId(id)\n const until = performance.now() + STATIC_REFRESH_SLICE_MS\n while (this.staticRound.length > 0) {\n measureId(this.staticRound.pop() as string)\n if (performance.now() >= until) break\n }\n }\n this.staticAll = false\n this.staticDirty.clear()\n return this.staticBoxes\n }\n\n /** The boxes of a piece's drawn meshes, measured once per frame. */\n private pieceBoxesOf(pc: PieceBody): number[] {\n const cached = this.pieceBoxes.get(pc)\n if (cached && cached.at === this.time) return cached.boxes\n const boxes: number[] = []\n const b = this.bounds.get(pc.objectId)\n if (b) {\n for (const mv of this.meshesOf(b)) {\n if (this.visuals.shown(mv)) this.visuals.fittedBoxes(mv, boxes)\n }\n }\n this.pieceBoxes.set(pc, { at: this.time, boxes })\n return boxes\n }\n\n solidsNear(x: number, z: number, radius: number): SolidBox[] {\n const found: SolidBox[] = []\n const scan = (a: number[], id: string, piece: Piece | null, from: number): void => {\n if (from > 0 && (a.length === 0 || x < a[0] - radius || x > a[3] + radius || z < a[2] - radius || z > a[5] + radius)) return\n for (let i = from; i < a.length; i += 6) {\n if (x < a[i] - radius || x > a[i + 3] + radius || z < a[i + 2] - radius || z > a[i + 5] + radius) continue\n found.push({ objectId: id, min: [a[i], a[i + 1], a[i + 2]], max: [a[i + 3], a[i + 4], a[i + 5]], piece })\n }\n }\n for (const [id, a] of this.staticNow()) scan(a, id, null, 6)\n const c = this.v1\n for (const pc of this.pieceSys.list) {\n if (pc.held) continue\n // only the pieces whose box can reach the point are measured\n this.pieceSys.centerOf(pc, c)\n const reach = Math.hypot(pc.halfExtents[0], pc.halfExtents[1], pc.halfExtents[2]) + radius\n if (Math.abs(c.x - x) > reach || Math.abs(c.z - z) > reach) continue\n scan(this.pieceBoxesOf(pc), pc.objectId, pc, 0)\n }\n this.fragments.solidsNear(x, z, radius, (home, min, max, loose) => found.push({ objectId: home, min, max, piece: null, loose }))\n return found\n }\n\n private apply(ev: DestructionEvent): void {\n this.staticDirty.add(ev.object)\n this.hitPoints.note(ev, this.time)\n if (ev.type === 'fracture' || ev.type === 'detach' || ev.type === 'collapse' || ev.type === 'burnout' || ev.type === 'destroyed') this.broken.add(ev.object)\n switch (ev.type) {\n case 'damage':\n if (ev.damageType === 'heat' || ev.damageType === 'fire' || ev.damageType === 'explosive') this.activate(ev.object, ev.part)\n break\n case 'dent':\n this.onDent(ev)\n break\n case 'hole':\n this.onHole(ev)\n break\n case 'crack':\n this.onCrack(ev)\n break\n case 'ricochet': {\n const d = ev.direction\n this.vfx.burst('sparks', ev.point, d, 4 + Math.min(10, ev.energy / 150), 4)\n // the whine of a round off steel, the short crack off stone: by what the part it glanced off is made of\n const glanced = this.partVis(ev.object, ev.part)?.material ?? ''\n this.sound('ricochet', ev.point, 0.7, ricochetSoundKeys(glanced, this.world.materials.get(glanced)))\n break\n }\n case 'debris':\n this.vfx.burst(ev.kind, ev.point, ev.normal, ev.count, ev.speed > 0 ? ev.speed : DEFAULT_SPEED[ev.kind] ?? 1, this.debrisOptions(ev.kind, ev.object, ev.part, ev.material))\n break\n case 'fracture': {\n const pv = this.partVis(ev.object, ev.part)\n if (pv) this.settlement.forget(pv)\n this.onFracture(ev)\n break\n }\n case 'subside':\n this.onSubside(ev.object)\n break\n case 'detach':\n this.onDetach(ev)\n break\n case 'settle':\n this.onSettle(ev.object)\n break\n case 'collapse': {\n // a storey coming down raises the cloud of the collapse effect; a piece of furniture (a shelf and its books) only a puff\n const root = this.bounds.get(ev.object)?.root\n const furniture = !!root && kitOriginOf(root)?.kind === 'furniture'\n // what was still going down goes the rest of the way before it falls on its own\n for (const part of ev.parts) {\n const pv = this.partVis(ev.object, part)\n if (pv) this.settlement.finish(pv)\n }\n this.splitLoose(ev.object)\n if (!furniture || ev.mass >= COLLAPSE_CLOUD_KG) this.playEvent({ kind: 'collapse' }, this.rootPoint(ev.object), this.partPlay(ev.object, ev.parts[0] ?? ''))\n else this.vfx.burst('dust', this.rootPoint(ev.object), [0, 1, 0], clamp(Math.round(ev.mass / 4), 4, 24), 0.8)\n break\n }\n case 'disassemble_progress': {\n const k = `unscrew:${ev.joint}`\n if (this.time - (this.throttles.get(k) ?? -1) > 0.25) {\n this.throttles.set(k, this.time)\n this.sound('unscrew', this.rootPoint(ev.object), clamp(0.3 + ev.progress * 0.5, 0, 1))\n }\n break\n }\n case 'ignite':\n this.startFire(ev)\n this.activate(ev.object, ev.part)\n this.sound('ignite', ev.point, 0.7)\n this.startBurnSound(ev.object, ev.part, ev.point, this.burning(ev.object, ev.part))\n break\n case 'primed':\n // a bullet or fire sets the part burning until its delay runs out; a blast nearby only waits for the explosion\n if (ev.trigger !== 'explosion') {\n this.vfx.fire({ point: ev.point, radius: PRIMED_FIRE_RADIUS, life: ev.delay })\n this.primedBurning.add(`${ev.object}|${ev.part}`)\n this.activate(ev.object, ev.part)\n // the vessel is venting until it bursts: the gas leak for as long as the delay, and the flame it feeds\n this.sound('primed', ev.point, 0.7, { seconds: ev.delay })\n if (!this.burnSounds.has(`${ev.object}|${ev.part}`)) this.startBurnSound(ev.object, ev.part, ev.point, { fuel: 'gas' })\n }\n break\n case 'spall':\n this.onSpall(ev)\n break\n case 'stage':\n this.onStage(ev)\n break\n case 'chip':\n this.onChip(ev)\n break\n case 'expose':\n if (ev.bars.length > 0) this.cages.set(`${ev.object}|${ev.part}`, ev.bars, this.bounds.get(ev.object)?.root)\n else this.dropCage(ev.object, ev.part)\n if (ev.bars.length > 0) {\n const [a, b] = ev.bars[0] as [Vec3, Vec3]\n this.playEvent({ kind: 'expose' }, [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2], this.partPlay(ev.object, ev.part))\n }\n break\n case 'extinguish': {\n const f = this.fires.get(`${ev.object}|${ev.part}`)\n this.primedBurning.delete(`${ev.object}|${ev.part}`)\n if (f) {\n this.stopFire(`${ev.object}|${ev.part}`)\n this.vfx.burst('steam', f.point, [0, 1, 0], 14, 1.2)\n }\n this.endBurnSound(`${ev.object}|${ev.part}`)\n this.activate(ev.object, ev.part)\n this.sound('extinguish', f?.point ?? this.rootPoint(ev.object), 0.6)\n break\n }\n case 'burnout': {\n this.stopFire(`${ev.object}|${ev.part}`)\n this.primedBurning.delete(`${ev.object}|${ev.part}`)\n this.endBurnSound(`${ev.object}|${ev.part}`)\n this.vfx.burst('ash', ev.point, [0, 1, 0], 16, 1)\n this.vfx.burst('smoke', ev.point, [0, 1, 0], 6, 0.8, { color: SMOKE_TONES.grey })\n const pv = this.partVis(ev.object, ev.part)\n if (pv) {\n const def = this.world.materials.get(pv.material)\n this.visuals.setChar(pv, 1, def?.visual?.charColor ?? 0x1a1410)\n }\n this.activate(ev.object, ev.part)\n break\n }\n case 'melt':\n this.activate(ev.object, ev.part)\n // one sizzle per melting object every 1.5 s, not one per part (a plastic bin has dozens)\n if (this.time - (this.throttles.get(`melt:${ev.object}`) ?? -9) > 1.5) {\n this.throttles.set(`melt:${ev.object}`, this.time)\n this.sound('melt_sizzle', this.rootPoint(ev.object), 0.4)\n }\n break\n case 'drip': {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n const def = this.world.materials.get(ev.material)\n const color = (pv && this.partColor(pv, def)) ?? fallbackColor(def)\n let tag = this.homeTags.indexOf(ev.object) + 1\n if (tag === 0) tag = this.homeTags.push(ev.object)\n this.vfx.spawn('drips', ev.point, [(this.rng() - 0.5) * 0.1, -0.1, (this.rng() - 0.5) * 0.1], { color, tag, owner: this.owner })\n break\n }\n case 'leak': {\n const key = `${ev.object}|${ev.part}`\n const b = this.bounds.get(ev.object)\n let localPoint: Vec3 | undefined\n let localDirection: Vec3 | undefined\n if (b) {\n b.root.updateWorldMatrix(true, false)\n const inv = new this.THREE.Matrix4().copy(b.root.matrixWorld).invert()\n const lp = this.v1.set(ev.point[0], ev.point[1], ev.point[2]).applyMatrix4(inv)\n const ld = this.v2.set(ev.direction[0], ev.direction[1], ev.direction[2]).transformDirection(inv).normalize()\n localPoint = [lp.x, lp.y, lp.z]\n localDirection = [ld.x, ld.y, ld.z]\n }\n const same = this.leaks.find((l) => l.object === ev.object && l.part === ev.part && Math.hypot(l.point[0] - ev.point[0], l.point[1] - ev.point[1], l.point[2] - ev.point[2]) < 0.03)\n if (same) {\n same.rate = ev.rate\n same.direction = ev.direction\n if (localPoint) same.localPoint = localPoint\n if (localDirection) same.localDirection = localDirection\n } else {\n if (this.leaks.length >= 24) this.leaks.shift()\n this.leaks.push({\n object: ev.object,\n part: ev.part,\n fluid: ev.fluid,\n point: ev.point,\n direction: ev.direction,\n rate: ev.rate,\n pressurized: ev.pressurized,\n acc: 0,\n opened: this.world.part(ev.object, ev.part)?.holes.some((h) => h.through) ?? false,\n localPoint,\n localDirection,\n life: 0,\n })\n }\n void key\n break\n }\n case 'explode':\n // the vessel that vented into its flame bursts: the gas jet ends with it\n this.primedBurning.delete(`${ev.object}|${ev.part}`)\n this.endBurnSound(`${ev.object}|${ev.part}`)\n this.onExplode(ev)\n break\n case 'destroyed':\n break\n }\n }\n\n /** Where the object's root is now, in the world: a body that tipped or fell is there, not where it was bound. */\n private rootPoint(objectId: string): Vec3 {\n const b = this.bounds.get(objectId)\n if (!b) return [0, 0, 0]\n const p = b.root.getWorldPosition(new this.THREE.Vector3())\n return [p.x, p.y, p.z]\n }\n\n private sound(key: string, point: Vec3, volume: number, detail?: SoundDetail): void {\n if (detail) this.o.onSound?.(key, point, volume, detail)\n else this.o.onSound?.(key, point, volume)\n }\n\n /** What a burning part is made of, for the fire's sound. */\n private burning(objectId: string, partId: string): SoundDetail | undefined {\n const material = this.partVis(objectId, partId)?.material || this.world.part(objectId, partId)?.material\n return material ? { material } : undefined\n }\n\n private partVis(objectId: string, partId: string): PartVis | null {\n return this.bounds.get(objectId)?.parts.get(partId) ?? null\n }\n\n private activate(objectId: string, partId: string): void {\n this.active.set(`${objectId}|${partId}`, { object: objectId, part: partId })\n }\n\n /** Current colour of the part's first mesh (char included), or null. */\n private partColor(pv: PartVis, def: MaterialDef | undefined): number | null {\n // the colour of what most of the part is drawn with (a roof's tiles, not the strip of plaster drawn with it first)\n const size = (m: MeshVis): number => (m.range ? m.range[1] - m.range[0] : (m.mesh.geometry.getAttribute('position')?.count ?? 0))\n const mv = pv.meshes.reduce<MeshVis | undefined>((best, m) => (!best || size(m) > size(best) ? m : best), undefined)\n if (!mv) return null\n const mat = materialsOf(mv.mesh.material)[0] as THREE_NS.MeshStandardMaterial | undefined\n const c = mat?.color\n if (c && (c as THREE_NS.Color).isColor) {\n const tint = this.visuals.vertexTint(mv)\n return tint ? c.clone().multiply(tint).getHex() : c.getHex()\n }\n return def ? fallbackColor(def) : null\n }\n\n private debrisOptions(kind: DebrisKind, objectId: string, partId: string, material?: string): { color?: number } | undefined {\n const pv = this.partVis(objectId, partId)\n const def = this.world.materials.get(material ?? pv?.material ?? '')\n if (kind === 'smoke') return { color: SMOKE_TONES[def?.thermal.smoke ?? 'grey'] }\n // crushed masonry is the colour of its inside (brick orange, plaster light, concrete grey), not of the paint over it\n if ((kind === 'dust' || kind === 'chips') && def?.visual?.innerColor !== undefined) return { color: def.visual.innerColor }\n if (kind === 'fibers' || kind === 'leaves') {\n if (def?.visual?.innerColor !== undefined) return { color: def.visual.innerColor }\n // a part drawn by its host (a house piece) has no mesh of its own here: the burst keeps its default colour\n const c = pv && pv.meshes[0] ? this.visuals.baseColorHex(pv.meshes[0]) : -1\n return c >= 0 ? { color: c } : undefined\n }\n if (kind === 'dust' || kind === 'chips') {\n const c = pv && pv.meshes[0] ? this.visuals.baseColorHex(pv.meshes[0]) : -1\n return c >= 0 && kind === 'chips' ? { color: c } : undefined\n }\n return undefined\n }\n\n /** Mesh of the part closest to a world point. */\n private nearestMesh(pv: PartVis, p: THREE_NS.Vector3): PartVis['meshes'][number] | null {\n let best: PartVis['meshes'][number] | null = null\n let bd = Infinity\n for (const mv of pv.meshes) {\n if (!this.visuals.shown(mv)) continue\n const d = this.visuals.worldBox(mv, this.box).distanceToPoint(p)\n if (d < bd) {\n bd = d\n best = mv\n }\n }\n return best\n }\n\n private worldDir(b: Bound, v: Vec3): THREE_NS.Vector3 {\n b.root.updateWorldMatrix(true, false)\n return new this.THREE.Vector3(v[0], v[1], v[2]).applyQuaternion(b.root.getWorldQuaternion(this.tmpQ)).normalize()\n }\n\n private onDent(ev: Ev<'dent'>): void {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n if (!b || !pv) return\n const def = this.world.materials.get(pv.material)\n const wp = new this.THREE.Vector3(ev.worldPoint[0], ev.worldPoint[1], ev.worldPoint[2])\n const wn = this.worldDir(b, ev.dent.normal)\n const shown = pv.meshes.filter((mv) => this.visuals.shown(mv))\n const reach = shown.reduce((widest, mv) => Math.max(widest, this.visuals.dentReach(mv, wp, ev.dent)), ev.dent.radius)\n this.visuals.applyPartDent(shown, wp, wn, ev.dent, reach)\n if (def?.tags?.includes('metal')) this.vfx.burst('sparks', ev.worldPoint, [wn.x, wn.y, wn.z], 4 + Math.min(8, ev.dent.depth * 150), 3.2)\n this.impactSound(pv.material, ev.worldPoint, clamp(0.3 + ev.dent.depth * 12, 0.3, 1), ev.blow)\n }\n\n private onHole(ev: Ev<'hole'>): void {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n if (!b || !pv) return\n const def = this.world.materials.get(pv.material)\n const n = this.worldDir(b, ev.hole.normal)\n const look = debrisLook(def, 'shot')\n const draw = (point: Vec3, normal: THREE_NS.Vector3): void => {\n const wp = new this.THREE.Vector3(point[0], point[1], point[2])\n const mv = this.nearestMesh(pv, wp)\n if (!mv) return\n if (look.mark === 'star_crack') {\n const seed = hashNumbers(ev.time, point[0], point[1], point[2])\n this.visuals.addCrack(mv, wp, normal, 7, Math.max(0.05, ev.hole.diameter * 5), 0xe8f4ff, seed)\n } else {\n // wood tears its fibres around the hole: a ragged rim of fresh wood under it\n const fresh = look.mark === 'splintered_hole' ? def?.visual?.innerColor : undefined\n if (fresh !== undefined) this.visuals.addSpall(mv, wp, normal, Math.max(0.006, ev.hole.diameter * WOOD_RIM), fresh)\n this.visuals.addHole(mv, wp, normal, ev.hole.diameter)\n }\n }\n draw(ev.worldPoint, n)\n if (ev.hole.through && ev.exitPoint) draw(ev.exitPoint, n.clone().negate())\n if (look.sparks) this.vfx.burst('sparks', ev.worldPoint, [n.x, n.y, n.z], 6, 3.5)\n if (ev.powder) {\n // what the part holds loose (flakes, flour) puffs out: a little back out of the entry, most out of the exit along the shot\n const puff = { color: ev.powder.color, size: 0.6, life: 1.6, alpha: 1.3 }\n this.vfx.burst('dust', ev.worldPoint, [n.x, n.y, n.z], this.low ? 5 : 10, 0.7, puff)\n if (ev.hole.through && ev.exitPoint) this.vfx.burst('dust', ev.exitPoint, [-n.x, -n.y, -n.z], this.low ? 10 : 20, 1.3, puff)\n }\n // the blow's own keys first (`impact_steel_ballistic`...), then the round's per-family key (`shot_metal`), which falls back to the plain impact\n this.sound(shotKey(def), ev.worldPoint, 0.6, impactSoundKeys(pv.material, def, ev.blow))\n }\n\n private onCrack(ev: Ev<'crack'>): void {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n if (!b || !pv) return\n const def = this.world.materials.get(pv.material)\n const stair = ev.crack.stair\n // a stair-step crack of settlement opens the mortar joints of the wall: a dark gap drawn on its face, as wide as it opened (and wide enough to be seen)\n if (stair && !def?.visual?.transparent) {\n const wp = new this.THREE.Vector3(ev.worldPoint[0], ev.worldPoint[1], ev.worldPoint[2])\n const seed = hashNumbers(ev.time, ev.worldPoint[0], ev.worldPoint[1], ev.worldPoint[2])\n const width = Math.max(stair.width, MIN_DRAWN_CRACK_WIDTH)\n const normal = this.worldDir(b, ev.crack.normal)\n const toward = this.worldDir(b, stair.along)\n const look = { length: ev.crack.length, step: stair.step, width, color: SETTLEMENT_CRACK_COLOR, seed }\n // the same crack on both faces of the wall (the far one seen from behind: its side runs the other way round, its path the same)\n for (const face of [wp, wp.clone().addScaledVector(normal, -stair.through)]) {\n const out = face === wp ? normal : normal.clone().negate()\n const mv = this.nearestMesh(pv, face)\n if (mv) this.visuals.addStairCrack(mv, face, out, toward, look)\n }\n }\n // only glass shows a crack as lines (the break runs inside a clear body); an opaque body shows its damage as chips, holes and dents, never lines drawn over it\n else if (def?.visual?.transparent) {\n const wp = new this.THREE.Vector3(ev.worldPoint[0], ev.worldPoint[1], ev.worldPoint[2])\n const mv = this.nearestMesh(pv, wp)\n const seed = hashNumbers(ev.time, ev.worldPoint[0], ev.worldPoint[1], ev.worldPoint[2])\n if (mv) this.visuals.addCrack(mv, wp, this.worldDir(b, ev.crack.normal), ev.crack.rays, ev.crack.length, 0xe8f4ff, seed)\n }\n this.impactSound(pv.material, ev.worldPoint, 0.5, ev.blow)\n }\n\n /** Outward normal of the face of `mv` nearest to a world point: the thin axis of its world box (right for a wall; a sloped face is left to the vertex-range binding). */\n private faceNormal(mv: PartVis['meshes'][number], point: THREE_NS.Vector3): THREE_NS.Vector3 {\n const box = this.visuals.worldBox(mv, this.box)\n const size = box.getSize(this.v1)\n const axis = size.x <= size.y && size.x <= size.z ? 'x' : size.y <= size.z ? 'y' : 'z'\n const side = point[axis] >= (box.min[axis] + box.max[axis]) / 2 ? 1 : -1\n return new this.THREE.Vector3(axis === 'x' ? side : 0, axis === 'y' ? side : 0, axis === 'z' ? side : 0)\n }\n\n /**\n * Plays the effect the event map names for a destruction event (`data/event-effects.json` of `game-vfx`, or `RendererOptions.eventEffects`) at a point.\n * `play` gives the family of the material (the map's `{material}`) and the colours of its debris and dust. Answers whether one played, so the caller can\n * leave out the burst it replaces.\n */\n private playEvent(event: GameEvent, point: Vec3, play?: FamilyPlay): boolean {\n const id = effectForEvent(play && event.material === undefined ? { ...event, material: play.material } : event, this.o.eventEffects ?? EVENT_EFFECTS_MAP)\n if (!id) return false\n return this.vfx.play(id, point, { seed: hashNumbers(point[0], point[1], point[2], this.time), ...(play ? { values: play.values } : {}) }) !== null\n }\n\n /** The family and colours of a part's material, for the effects of the event map. */\n private partPlay(objectId: string, partId: string): FamilyPlay {\n const pv = this.partVis(objectId, partId)\n const def = pv ? this.world.materials.get(pv.material) : undefined\n return familyPlay(def, pv ? (this.partColor(pv, def) ?? undefined) : undefined)\n }\n\n /** A coat came off: a patch in the colour of the core under it, below the bullet holes and cracks. */\n private onSpall(ev: Ev<'spall'>): void {\n const pv = this.partVis(ev.object, ev.part)\n if (!pv) return\n const wp = new this.THREE.Vector3(ev.point[0], ev.point[1], ev.point[2])\n const mv = this.nearestMesh(pv, wp)\n if (!mv) return\n const def = this.world.materials.get(pv.material)\n const normal = this.faceNormal(mv, wp)\n const core = def?.visual?.innerColor\n const look = debrisLook(def, 'spall', { partColor: this.partColor(pv, def) ?? undefined })\n // masonry crumbles in the colour of what is under the coat (brick orange, concrete grey); the generic impact would throw dark grey chips, and a\n // material with no impact recipe of its own (plastic, fabric, soil) throws its own debris in its colour, not the concrete impact\n if (core !== undefined || look.impact === undefined) this.vfx.burst(look.debris, ev.point, [normal.x, normal.y, normal.z], 5, 2.5, { color: look.color })\n else this.playEvent({ kind: 'spall', material: look.impact }, ev.point)\n if (core !== undefined) this.trickleFrom(ev.point, [normal.x, normal.y, normal.z], core, mv)\n // a drawing that shows the coat coming off itself (the house renderer cuts its plaster and draws the bricks under it) takes no flat patch\n if ((mv.mesh.userData.drawnSpalls as string[] | undefined)?.includes(ev.part)) return\n this.visuals.addSpall(mv, wp, normal, Math.sqrt(ev.area / Math.PI), core ?? fallbackColor(def))\n }\n\n /**\n * Grit and dust go on falling from where a blow broke a hard face (masonry, concrete, wood) for `TRICKLE_SECONDS`, a pinch at a time and less and\n * less. The place is held on the mesh it broke on (`mv`), so it falls with the object when it tips or a piece of it comes away.\n */\n private trickleFrom(point: Vec3, normal: Vec3, color: number | undefined, mv: MeshVis | null): void {\n if (this.trickles.length >= TRICKLE_MAX) this.trickles.shift()\n const total = TRICKLE_SECONDS[0] + (TRICKLE_SECONDS[1] - TRICKLE_SECONDS[0]) * this.rng()\n const anchor = mv ? anchorOnMesh(this.THREE, mv, point, normal) : null\n this.trickles.push({ point: [point[0], point[1], point[2]], normal, anchor, color, left: total, total, next: TRICKLE_EVERY })\n }\n\n private updateTrickles(dt: number): void {\n for (let i = this.trickles.length - 1; i >= 0; i--) {\n const t = this.trickles[i]!\n t.left -= dt\n t.next -= dt\n if (t.left <= 0) {\n this.trickles.splice(i, 1)\n continue\n }\n if (t.next > 0) continue\n if (t.anchor) {\n // nothing left to crumble from: the part broke into fragments or is gone\n if (!anchorWorld(t.anchor, this.visuals.shown(t.anchor.mv), this.v1, this.v2)) {\n this.trickles.splice(i, 1)\n continue\n }\n t.point = [this.v1.x, this.v1.y, this.v1.z]\n t.normal = [this.v2.x, this.v2.y, this.v2.z]\n }\n // falling off the face, slower as the loose grit runs out\n const share = t.left / t.total\n t.next = TRICKLE_EVERY / Math.max(share, 0.25)\n const out: Vec3 = [t.normal[0] * 0.2, -1, t.normal[2] * 0.2]\n const options = t.color !== undefined ? { color: t.color } : undefined\n this.vfx.burst('chips', t.point, out, this.low ? 1 : 2, 0.3, options)\n if (this.rng() < 0.5) this.vfx.burst('dust', t.point, out, 1, 0.2, options)\n }\n }\n\n /**\n * Stage 2 of a staged part: the unit-sized fragments come out and the part stays drawn (hiding it is what `fracture` does). The opening itself\n * (cutting the wall's faces) is not drawn yet: it needs the per-vertex binding of the house renderer.\n */\n private onStage(ev: Ev<'stage'>): void {\n const pv = this.partVis(ev.object, ev.part)\n const def = pv ? this.world.materials.get(pv.material) : undefined\n const at = ev.opening?.center ?? this.hitPoints.of(ev.object, ev.part, this.time) ?? this.rootPoint(ev.object)\n const played = this.playEvent({ kind: 'stage', stage: ev.stage }, at, this.partPlay(ev.object, ev.part))\n if (!ev.fragments || !ev.opening) return\n const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(def)\n const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments\n const step = this.low ? 2 : 1\n for (let i = 0; i < ev.fragments.length; i += step) {\n const fr = ev.fragments[i] as Fragment\n const fdef = this.world.materials.get(fr.material)\n this.fragments.spawn(fr, this.fragments.materialFor(fr.material, fdef === def || !fdef ? color : fallbackColor(fdef), false), ev.object, maxAlive)\n }\n if (!played) this.vfx.burst('dust', ev.opening.center, [0, 1, 0], 14, 1.2, { color })\n this.impactSound(pv?.material ?? '', ev.opening.center, 0.8, ev.blow)\n }\n\n /**\n * A unit came out of a wall of units: the unit flies as a fragment with a puff of its dust, and the marks drawn on it (bullet holes, spalls, the impact\n * marks of the effects) go with it. The gap itself is the drawing's (the house renderer cuts the wall where the unit was); a part drawn as one box\n * keeps its box.\n */\n private onChip(ev: Ev<'chip'>): void {\n const pv = this.partVis(ev.object, ev.part)\n const def = pv ? this.world.materials.get(pv.material) : undefined\n const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(def)\n const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments\n for (const fr of ev.fragments) {\n const fdef = this.world.materials.get(fr.material)\n // the inside of the material (fresh wood) when the piece came from it, else the part's colour\n const tone = fragmentTone(fdef, fr, fdef === def ? color : fallbackColor(fdef))\n this.fragments.spawn(fr as Fragment, this.fragments.materialFor(fr.material, tone, false), ev.object, maxAlive)\n }\n // a unit knocked out of masonry or concrete leaves a broken edge that goes on crumbling\n if (def?.visual?.innerColor !== undefined || pv?.material === 'concrete' || pv?.material === 'brick') {\n this.trickleFrom(ev.center, [0, 0, 0], color, pv ? this.nearestMesh(pv, new this.THREE.Vector3(ev.center[0], ev.center[1], ev.center[2])) : null)\n }\n // what a blow tore off a face leaves the hole it made where it is\n if (ev.torn) {\n this.impactSound(pv?.material ?? '', ev.center, 0.5, ev.blow)\n return\n }\n // the holes and spalls drawn on the unit leave with it (also those on the wall a beam is drawn inside), and on the ragged edge of plaster around it\n const T = this.THREE\n const center = new T.Vector3(ev.center[0], ev.center[1], ev.center[2])\n const half = new T.Vector3(ev.size[0] / 2 + CHIP_DECAL_EDGE, ev.size[1] / 2 + CHIP_DECAL_EDGE, ev.size[2] / 2 + CHIP_DECAL_EDGE)\n const rotation = new T.Quaternion(ev.rotation[0], ev.rotation[1], ev.rotation[2], ev.rotation[3])\n for (const part of this.bounds.get(ev.object)?.parts.values() ?? []) for (const mv of part.meshes) this.visuals.clearDecals(mv, center, half, rotation)\n this.vfx.peekWorkshop()?.decals.clearInside(ev.center, [half.x, half.y, half.z], ev.rotation)\n // a puff of the unit's own dust; not the bullet impact effect, which would leave its black mark on the hole the unit left\n this.vfx.burst('dust', ev.center, [0, 1, 0], ev.units ? Math.min(40, 8 + ev.units.length) : 8, ev.units ? 1.6 : 0.8, { color })\n this.impactSound(pv?.material ?? '', ev.center, 0.7, ev.blow)\n }\n\n private onFracture(ev: Ev<'fracture'>): void {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n const matId = pv?.material || (ev.fragments[0]?.material ?? '')\n const def = this.world.materials.get(matId)\n let color = fallbackColor(def)\n let opacity = 0.5\n const transparent = def?.visual?.transparent === true\n if (pv) {\n const c = this.partColor(pv, def)\n if (c !== null) color = c\n const m = pv.meshes[0] ? (materialsOf(pv.meshes[0].origMaterial)[0] as THREE_NS.Material | undefined) : undefined\n if (m && m.transparent) opacity = clamp(m.opacity, 0.2, 0.8)\n this.visuals.hide(pv, 'broken')\n }\n this.spawnFragments(ev, 0, { def, color, opacity, transparent })\n this.loosenIfFootless(ev.object)\n const up: Vec3 = [0, 1, 0]\n const sizeK = clamp(ev.fragments.length / 10, 0.5, 2)\n // what flies off is of the material that broke, in its colour: grey chips of concrete, orange of brick, splinters and pale dust of wood\n const look = debrisLook(def, 'fracture', { style: ev.style, partColor: color })\n const dust = look.dust !== undefined ? { color: look.dust } : undefined\n switch (ev.style) {\n case 'shatter':\n this.vfx.burst('shards', ev.point, up, 18 * sizeK, 3)\n break\n case 'crumble':\n this.vfx.burst('dust', ev.point, up, 16 * sizeK, 1.2, dust)\n this.vfx.burst(look.family === 'glass' ? 'shards' : 'chips', ev.point, up, 6, 3, { color: look.color })\n break\n case 'splinter':\n this.vfx.burst('splinters', ev.point, up, 14 * sizeK, 3, { color: look.color })\n this.vfx.burst('dust', ev.point, up, 5, 0.8, dust)\n break\n case 'tear':\n this.vfx.burst('fibers', ev.point, up, 12 * sizeK, 1.6, { color: look.color })\n break\n case 'snap':\n this.vfx.burst('chips', ev.point, up, 8 * sizeK, 3, { color: look.color })\n break\n default:\n this.vfx.burst('sparks', ev.point, up, 10, 4)\n }\n this.sound(fractureKey(def, ev.style), ev.point, clamp(0.4 + ev.fragments.length * 0.03, 0.4, 1), breakSoundKeys(matId, def, ev.blow))\n }\n\n /** Spawns the fragments of a fracture from index `from`; what does not fit in this frame's budget is spawned by the next frames. */\n private spawnFragments(ev: Ev<'fracture'>, from: number, look: { def: MaterialDef | undefined; color: number; opacity: number; transparent: boolean }): void {\n const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments\n const step = this.low ? 2 : 1\n for (let i = from; i < ev.fragments.length; i += step) {\n if (i - from >= MIN_FRAGMENTS_PER_SLICE * step && this.drainClock() >= this.sliceDeadline) {\n this.slices.push(() => this.spawnFragments(ev, i, look))\n return\n }\n const fr = ev.fragments[i]\n const fdef = this.world.materials.get(fr.material)\n const tone = fragmentTone(fdef, fr, fdef === look.def || !fdef ? look.color : fallbackColor(fdef))\n const mat = this.fragments.materialFor(fr.material, tone, look.transparent || fdef?.visual?.transparent === true, look.opacity)\n this.fragments.spawn(fr, mat, ev.object, maxAlive)\n }\n }\n\n private onDetach(ev: Ev<'detach'>): void {\n this.sound('detach', this.rootPoint(ev.object), 0.5)\n this.splitLoose(ev.object)\n }\n\n /**\n * The cage of a part gave way (`expose` with no bars): nothing holds its bars any more, so each comes down where it is, as steel debris that stays on the\n * ground with a body (`FragmentSystem.spawn` with `lasting`), not as bars left standing in the air.\n */\n private dropCage(objectId: string, partId: string): void {\n const bars = this.cages.take(`${objectId}|${partId}`)\n if (bars.length === 0) return\n const radius = this.cages.barRadius\n const density = this.world.materials.get('steel')?.density ?? STEEL_DENSITY\n const material = this.fragments.materialFor('steel', REBAR_COLOR, false)\n const rnd = createRng(hashString(`${objectId}|${partId}`))\n bars.forEach((bar, i) => {\n const fragment: Fragment = {\n id: `${partId}#bar${i}`, part: partId, material: 'steel', shape: 'chunk', center: bar.center, size: [2 * radius, bar.length, 2 * radius], rotation: bar.rotation,\n velocity: [(rnd() - 0.5) * 0.4, 0, (rnd() - 0.5) * 0.4], angularVelocity: [(rnd() - 0.5) * 1.5, (rnd() - 0.5) * 0.5, (rnd() - 0.5) * 1.5],\n mass: density * Math.PI * radius * radius * bar.length,\n }\n this.fragments.spawn(fragment, material, objectId, this.maxFragments, true)\n })\n }\n\n /**\n * What goes on at a part (its fire, its leak, its burn sound, its heat) moves with the part to the object a split made of it: it goes on where the\n * part is, as it falls, not where the object stood, and does not end because the part has a new id.\n */\n private followSplit(from: Bound, to: Bound): void {\n for (const part of to.parts.keys()) {\n const was = `${from.id}|${part}`\n const now = `${to.id}|${part}`\n const fire = this.fires.get(was)\n if (fire) {\n this.fires.delete(was)\n fire.object = to.id\n this.fires.set(now, fire)\n }\n const sound = this.burnSounds.get(was)\n if (sound) {\n this.burnSounds.delete(was)\n this.burnSounds.set(now, { ...sound, object: to.id })\n }\n if (this.active.delete(was)) this.active.set(now, { object: to.id, part })\n }\n from.root.updateWorldMatrix(true, false)\n to.root.updateWorldMatrix(true, false)\n const into = new this.THREE.Matrix4().copy(to.root.matrixWorld).invert()\n for (const leak of this.leaks) {\n if (leak.object !== from.id || !to.parts.has(leak.part)) continue\n leak.object = to.id\n const point = leak.localPoint ? this.v1.set(...leak.localPoint).applyMatrix4(from.root.matrixWorld) : this.v1.set(...leak.point)\n const direction = leak.localDirection ? this.v2.set(...leak.localDirection).transformDirection(from.root.matrixWorld) : this.v2.set(...leak.direction)\n point.applyMatrix4(into)\n direction.transformDirection(into)\n leak.localPoint = [point.x, point.y, point.z]\n leak.localDirection = [direction.x, direction.y, direction.z]\n }\n }\n\n /** Turn every loose group of the object (a detach, a collapse) into a piece of its own. */\n private splitLoose(objectId: string): void {\n if (!this.autoSplit) return\n const b = this.bounds.get(objectId)\n if (!b) return\n const st = this.world.state(objectId)\n if (!st || st.groups.length < 2) return\n const loose = st.groups.length - 1\n for (let i = 0; i < loose; i++) {\n if (i > 0 && this.drainClock() >= this.sliceDeadline) {\n this.slices.push(() => {\n this.staticDirty.add(objectId)\n this.splitLoose(objectId)\n })\n return\n }\n // the loose groups are always read from index 1: each split renumbers the rest\n let newId: string\n try {\n newId = this.world.splitGroup(objectId, 1)\n } catch {\n break\n }\n this.adoptSplit(b, newId)\n }\n const old = b.piece\n if (old) {\n const { half, center } = this.measure(b.root, this.meshesOf(b))\n old.halfExtents = half\n this.pieceSys.setCenter(old, center)\n old.mass = Math.max(0.05, this.massOf(objectId))\n // what came off no longer touches the ground for it: its contacts are those of what is left\n // and what others meet it by are the boxes of what is left (`partBoxes`): nothing invisible collides\n if (old.contacts || old.round) {\n this.fitSurface(b, old)\n if (!old.round) this.setContacts(b, old, this.meshesOf(b).filter((mv) => this.visuals.shown(mv)))\n } else if (old.partBoxes) this.fitPartBoxes(b, old)\n old.sleeping = false\n } else if (kitOriginOf(b.root)?.kind === 'furniture') {\n // furniture only stands on the floor: what stayed (a leg, two legs and a board) is loose too, and what cannot stand on its own topples\n const piece = this.makePiece(objectId)\n this.tipIfTopHeavy(b)\n // the host stops keeping the footprint it had where it stood: it is a body that moves now\n this.o.onLoosened?.(objectId, piece, 'apart')\n }\n }\n\n /** The renderer side of `splitGroup`: a new group holding the meshes of the new object, made a piece. */\n private adoptSplit(from: Bound, newId: string): void {\n const state = this.world.state(newId)\n const root = from.root\n root.updateWorldMatrix(true, false)\n const group = new this.THREE.Group()\n group.name = `destruction-piece-${newId}`\n root.getWorldPosition(group.position)\n root.getWorldQuaternion(group.quaternion)\n this.scene.add(group)\n group.updateMatrixWorld(true)\n const nb: Bound = { id: newId, root: group, sync: true, parts: new Map(), lastPos: null, lastQuat: null, piece: null, isSplit: true }\n for (const p of state?.parts ?? []) {\n const pv = from.parts.get(p.id)\n if (!pv) continue\n from.parts.delete(p.id)\n nb.parts.set(p.id, pv)\n // its bare bars go with it\n this.cages.move(`${from.id}|${p.id}`, `${newId}|${p.id}`, group)\n for (const mv of pv.meshes) {\n // a part drawn by a range of a merged mesh leaves its faces behind: it gets a mesh of its own\n if (mv.host && !mv.loose) this.visuals.extract(mv, group)\n else {\n group.attach(mv.mesh)\n showCollapsedRanges(mv.mesh)\n mv.moved = true\n }\n }\n }\n this.bounds.set(newId, nb)\n for (const pv of nb.parts.values()) this.tagPart(pv, newId)\n this.followSplit(from, nb)\n const meshes = this.meshesOf(nb)\n if (meshes.length === 0) return\n const { half, center } = this.measure(group, meshes)\n let vel: Vec3 = [0, 0, 0]\n let ang: Vec3 = [0, 0, 0]\n const op = from.piece\n if (op) {\n vel = [...op.velocity]\n ang = [...op.angularVelocity]\n // linear velocity at the loose piece's centre\n const c = this.pieceSys.centerOf(op, new this.THREE.Vector3())\n const nc = center.clone().applyQuaternion(group.quaternion).add(group.position)\n vel[0] += ang[1] * (nc.z - c.z) - ang[2] * (nc.y - c.y)\n vel[1] += ang[2] * (nc.x - c.x) - ang[0] * (nc.z - c.z)\n vel[2] += ang[0] * (nc.y - c.y) - ang[1] * (nc.x - c.x)\n }\n const piece = this.pieceSys.create(newId, group, half, center, this.massOf(newId), vel, ang)\n nb.piece = piece\n this.fitSurface(nb, piece)\n if (kitOriginOf(from.root)?.kind === 'furniture') this.tipIfTopHeavy(nb)\n this.o.onPiece?.(piece)\n }\n\n /**\n * What lost what it stood on falls (furniture, a stand, a crate, a car; not a structure): with every leg of a table broken the top is loose, and with the legs of one side\n * gone what is left topples. Feet are the meshes at the bottom of the object as it was whole; while the ones left still span the same floor (a cupboard with a broken door,\n * a table missing one leg) it stands. A piece that lost a part is the box of what is left, touching the ground by the corners of each part (`setContacts`).\n */\n private loosenIfFootless(objectId: string): void {\n const b = this.bounds.get(objectId)\n if (!b || !this.autoSplit) return\n const left = this.meshesOf(b).filter((mv) => this.visuals.shown(mv))\n if (left.length === 0) return\n // a house, a wall, the ground answer to their own load path: their pieces only take the box of what is left\n const structural = UNCHECKED_KINDS.has(this.kindOf(b))\n const body = b.piece ?? this.pieceSys.get(objectId)\n if (body) {\n // a piece is the box of what is left of it: the legs that broke off no longer hold it up\n const { half, center } = this.measure(b.root, left)\n body.halfExtents = half\n this.pieceSys.setCenter(body, center)\n body.mass = Math.max(0.05, this.massOf(objectId))\n if (!structural) {\n // what is left may be round (a can's label torn off) or not any more (a stool that lost its legs): its contacts follow\n this.fitSurface(b, body)\n if (!body.round) this.setContacts(b, body, left)\n }\n body.sleeping = false\n return\n }\n if (structural) return\n const boxOf = (mv: MeshVis): THREE_NS.Box3 => this.visuals.worldBox(mv, new this.THREE.Box3())\n const whole = [...b.parts.values()].flatMap((pv) => pv.meshes).map(boxOf).filter((one) => !one.isEmpty())\n // what hangs (a wall cabinet, a lamp) is held by what it hangs on: only what stood on something can lose its footing\n if (!this.standsOn(objectId, whole.map((one): [number, number, number, number, number, number] => [one.min.x, one.min.y, one.min.z, one.max.x, one.max.y, one.max.z]))) return\n const floor = Math.min(...whole.map((one) => one.min.y))\n const feetOf = (boxes: THREE_NS.Box3[]): THREE_NS.Box3 => boxes.filter((one) => one.min.y < floor + FEET_BAND).reduce((feet, one) => feet.union(one), new this.THREE.Box3())\n const was = feetOf(whole)\n const now = feetOf(left.map(boxOf).filter((one) => !one.isEmpty()))\n const same = !now.isEmpty() && now.min.x <= was.min.x + FEET_BAND && now.max.x >= was.max.x - FEET_BAND && now.min.z <= was.min.z + FEET_BAND && now.max.z >= was.max.z - FEET_BAND\n if (same) return\n if (!now.isEmpty()) {\n const box = left.map(boxOf).reduce((all, one) => all.union(one), new this.THREE.Box3())\n const centreX = (box.min.x + box.max.x) / 2\n const centreZ = (box.min.z + box.max.z) / 2\n const height = box.max.y - box.min.y\n const narrow = height >= TIP_MIN_HEIGHT && Math.min(now.max.x - now.min.x, now.max.z - now.min.z) < TIP_NARROW * height\n if (!narrow && centreX > now.min.x && centreX < now.max.x && centreZ > now.min.z && centreZ < now.max.z) return\n }\n const piece = this.makePiece(objectId)\n this.setContacts(b, b.piece ?? (piece as PieceBody), left)\n this.tipIfTopHeavy(b)\n // the host stops keeping the footprint it had where it stood: it is a body that moves now\n this.o.onLoosened?.(objectId, piece, 'apart')\n }\n\n shownBoxes(objectId: string, partId?: string): Array<[number, number, number, number, number, number]> {\n const b = this.bounds.get(objectId)\n if (!b) return []\n const box = new this.THREE.Box3()\n const out: Array<[number, number, number, number, number, number]> = []\n const pv = partId === undefined ? null : b.parts.get(partId)\n if (partId !== undefined && (!pv || pv.gone !== 'none')) return out\n for (const mv of pv ? pv.meshes : this.meshesOf(b)) {\n if (!this.visuals.shown(mv)) continue\n this.visuals.worldBox(mv, box)\n if (!box.isEmpty()) out.push([box.min.x, box.min.y, box.min.z, box.max.x, box.max.y, box.max.z])\n }\n return out\n }\n\n /**\n * What is left of each object broken since the last update stands on something, or falls: an object that is not a piece whose lowest drawn box has neither the ground, a\n * fixed top nor a piece within `BROKEN_GAP` under it is made a piece on the spot (see `onBrokenChecked`).\n */\n private checkBroken(): void {\n if (this.broken.size === 0) return\n const ids = [...this.broken]\n this.broken.clear()\n for (const id of ids) {\n const released = this.releaseIfFloating(id)\n this.o.onBrokenChecked?.(id, released)\n }\n }\n\n private releaseIfFloating(objectId: string): boolean {\n const b = this.bounds.get(objectId)\n if (!b || b.piece || this.pieceSys.get(objectId) || !this.autoSplit || UNCHECKED_KINDS.has(this.kindOf(b))) return false\n const boxes = this.shownBoxes(objectId)\n if (boxes.length === 0) return false\n // the object as it was whole (it has not moved: it is no piece): one that hung (a wall cabinet, a lamp) is held by what it hangs on, not checked here\n const whole = new this.THREE.Box3()\n const wholeBoxes: Array<[number, number, number, number, number, number]> = []\n for (const pv of b.parts.values()) {\n for (const mv of pv.meshes) {\n this.visuals.worldBox(mv, whole)\n if (!whole.isEmpty()) wholeBoxes.push([whole.min.x, whole.min.y, whole.min.z, whole.max.x, whole.max.y, whole.max.z])\n }\n }\n if (!this.standsOn(objectId, wholeBoxes) || this.standsOn(objectId, boxes)) return false\n const piece = this.makePiece(objectId)\n this.setContacts(b, b.piece ?? (piece as PieceBody), this.meshesOf(b).filter((mv) => this.visuals.shown(mv)))\n this.tipIfTopHeavy(b)\n this.o.onLoosened?.(objectId, piece, 'apart')\n return true\n }\n\n /** Whether the lowest of `boxes` (world boxes of the object `objectId`) has the ground, a fixed top or a piece within `BROKEN_GAP` under it. */\n private standsOn(objectId: string, boxes: ReadonlyArray<readonly [number, number, number, number, number, number]>): boolean {\n if (boxes.length === 0) return false\n const low = Math.min(...boxes.map((one) => one[1]))\n for (const [x0, y0, z0, x1, , z1] of boxes) {\n if (y0 > low + FEET_BAND) continue\n for (const [fx, fz] of BROKEN_SAMPLES) {\n const x = x0 + (x1 - x0) * fx\n const z = z0 + (z1 - z0) * fz\n const under = Math.max(this.groundAt(x, z), this.staticTopAtBut(objectId, x, z, y0, BROKEN_GAP), this.pieceSys.topAt(x, z, y0, BROKEN_GAP, objectId))\n if (under >= y0 - BROKEN_GAP) return true\n }\n }\n return false\n }\n\n /** The kind of kit piece a bound object is, by the mark on its root or the nearest one above it (a house binds a group inside its marked root); '' when unmarked. */\n private kindOf(b: Bound): string {\n for (let o: THREE_NS.Object3D | null = b.root; o; o = o.parent) {\n const kind = kitOriginOf(o)?.kind\n if (kind) return kind\n }\n return ''\n }\n\n /** The top of the ground or of a standing part of the world under (x, z), below height y: a ray straight down through the destruction world. */\n private surfaceAt(x: number, y: number, z: number): number {\n const ground = this.groundAt(x, z)\n // a world that casts no rays (a stand-in in a test) has only the ground to land on\n if (y <= ground || typeof this.world.raycast !== 'function') return ground\n // a piece of rubble spawned inside a part (the top course of a wall under its bond beam) sees that part first, at no distance: look under it\n let from = y\n for (let k = 0; k < SURFACE_RAYS && from > ground; k++) {\n const hit = this.world.raycast([x, from, z], [0, -1, 0], from - ground)\n if (!hit) return ground\n if (hit.distance > SURFACE_INSIDE) return Math.max(ground, hit.point[1])\n from -= SURFACE_STEP\n }\n return ground\n }\n\n /** `staticTopAt` without the boxes of `objectId` itself. */\n private staticTopAtBut(objectId: string, x: number, z: number, y: number, step: number): number {\n let top = -Infinity\n for (const [id, a] of this.staticNow()) {\n if (id === objectId || a.length === 0 || x < a[0] || x > a[3] || z < a[2] || z > a[5]) continue\n for (let i = 6; i < a.length; i += 6) {\n if (x < a[i] || x > a[i + 3] || z < a[i + 2] || z > a[i + 5]) continue\n const t = a[i + 4]\n if (t > top && t <= y + step) top = t\n }\n }\n return top\n }\n\n /**\n * The piece touches the ground by the corners of each part left of it, not by the box around them all: on one leg, or on the legs of one side, its centre of mass is off\n * what holds it and it goes over until the top meets the floor. Past `CONTACT_MESHES` meshes it keeps the corners of its box; up to `PART_BOX_MESHES`, what lands on it lands\n * on its parts.\n */\n private setContacts(b: Bound, body: PieceBody, meshes: MeshVis[]): void {\n if (meshes.length > PART_BOX_MESHES) {\n body.contacts = undefined\n body.partBoxes = undefined\n return\n }\n const inv = specFrameInverse(this.THREE, b.root)\n const m4 = new this.THREE.Matrix4()\n const lb = new this.THREE.Box3()\n const [cx, cy, cz] = body.localCenter\n const points: Vec3[] = []\n const boxes: Array<{ center: Vec3; half: Vec3 }> = []\n for (const mv of meshes) {\n mv.mesh.updateWorldMatrix(true, false)\n this.visuals.localBox(mv, lb)\n if (lb.isEmpty()) continue\n lb.applyMatrix4(m4.multiplyMatrices(inv, mv.mesh.matrixWorld))\n for (let i = 0; i < 8; i++) points.push([(i & 1 ? lb.max.x : lb.min.x) - cx, (i & 2 ? lb.max.y : lb.min.y) - cy, (i & 4 ? lb.max.z : lb.min.z) - cz])\n boxes.push({\n center: [(lb.min.x + lb.max.x) / 2 - cx, (lb.min.y + lb.max.y) / 2 - cy, (lb.min.z + lb.max.z) / 2 - cz],\n half: [Math.max(0.005, (lb.max.x - lb.min.x) / 2), Math.max(0.005, (lb.max.y - lb.min.y) / 2), Math.max(0.005, (lb.max.z - lb.min.z) / 2)],\n })\n }\n body.contacts = points.length > 0 && meshes.length <= CONTACT_MESHES ? points : undefined\n body.partBoxes = boxes.length > 1 ? boxes : undefined\n }\n\n /**\n * A piece of furniture standing on feet too close for its height (a board on two legs in a line, a lone leg) does not stay up: the box of a piece hides that its weight is up\n * high and its feet are thin, so it gets the start of the fall, across the line of its feet.\n */\n private tipIfTopHeavy(b: Bound): void {\n const piece = b.piece\n if (!piece) return\n const box = new this.THREE.Box3()\n const boxes = this.meshesOf(b).filter((mv) => this.visuals.shown(mv)).map((mv) => this.visuals.worldBox(mv, new this.THREE.Box3()))\n if (boxes.length === 0) return\n for (const one of boxes) box.union(one)\n const height = box.max.y - box.min.y\n const feet = new this.THREE.Box3()\n for (const one of boxes) if (one.min.y < box.min.y + FEET_BAND) feet.union(one)\n const spanX = feet.max.x - feet.min.x\n const spanZ = feet.max.z - feet.min.z\n if (height < TIP_MIN_HEIGHT || Math.min(spanX, spanZ) >= TIP_NARROW * height) return\n const across = spanX <= spanZ ? 0 : 2\n const lean = across === 0 ? box.min.x + box.max.x - feet.min.x - feet.max.x : box.min.z + box.max.z - feet.min.z - feet.max.z\n const away = lean < 0 ? -1 : 1\n // rotating about -z moves the top toward +x; rotating about +x moves it toward +z\n if (across === 0) this.pieceSys.tip(piece, 0, -away)\n else this.pieceSys.tip(piece, away, 0)\n }\n\n private onExplode(ev: Ev<'explode'>, options: ExplodeOptions = {}): void {\n const p = ev.point\n if (options.visual !== false) this.playExplosion(ev, options)\n this.vfx.push(p, ev.radius, 4)\n // shove pieces and fragments\n const c = this.v1\n const report = options.report\n const confinement = report?.find((r) => r.blast !== undefined)?.blast?.confinement ?? 1\n const energy = ev.energy * confinement\n // the energy that got to an object after what stood in the way: the world's shelter of this blast when it carries one, else the cover between the centre and the\n // object's centre (`blastReach`, always on: a wall, a car or a cupboard between them takes the push), as it stood when the part went off: the cupboard the wave\n // tears apart still met it, and the stove it throws was not in the way yet\n const wentOff = this.coverWhenWentOff.get(ev)\n const reachOf = (objectId: string, at: Vec3): number =>\n report?.find((r) => r.object === objectId)?.blast?.shelter ??\n wentOff?.get(objectId) ??\n this.world.blastReach?.(p, at, { ignore: ev.object ? [ev.object, objectId] : [objectId] }) ??\n 1\n const shove = (pc: PieceBody): void => {\n this.pieceSys.centerOf(pc, c)\n if (c.distanceTo(this.v2.set(p[0], p[1], p[2])) > ev.radius) return\n const hit = blastShove({ point: p, energy, radius: ev.radius, reach: reachOf(pc.objectId, [c.x, c.y, c.z]) }, { position: [c.x, c.y, c.z], mass: pc.mass }, this.o.blastShove)\n if (!hit) return\n const spread = pc.halfExtents[0]\n const momentum = hit.speed * pc.mass\n this.pieceSys.impulse(pc, [hit.direction[0] * momentum, hit.direction[1] * momentum, hit.direction[2] * momentum], [c.x + (this.rng() - 0.5) * spread, c.y + spread * 0.5, c.z + (this.rng() - 0.5) * spread])\n }\n for (const pc of [...this.pieceSys.list]) shove(pc)\n if (this.o.shoveable) this.loosen(p, ev.radius, energy, reachOf)\n this.fragments.blast(p, ev.radius, Math.min(20, Math.sqrt(energy) * 0.08))\n this.sound('explode', p, clamp(0.5 + ev.radius / 10, 0.5, 1), {\n radius: ev.radius,\n ...(ev.effect !== undefined ? { effect: ev.effect } : {}),\n ...(options.effect !== undefined ? { effect: options.effect } : {}),\n ...(report ? { confinement } : {}),\n })\n }\n\n /** The cover between a part of the world that goes off and the centre of each piece and each shoveable body within its radius, as the world stands at that moment. */\n private coverAround(ev: Ev<'explode'>): Map<string, number> {\n const cover = new Map<string, number>()\n const reach = this.world.blastReach\n if (!reach) return cover\n const point = new this.THREE.Vector3(ev.point[0], ev.point[1], ev.point[2])\n const centre = new this.THREE.Vector3()\n const read = (objectId: string): void => {\n if (centre.distanceTo(point) <= ev.radius) cover.set(objectId, reach.call(this.world, ev.point, [centre.x, centre.y, centre.z], { ignore: [ev.object, objectId] }))\n }\n for (const pc of this.pieceSys.list) {\n this.pieceSys.centerOf(pc, centre)\n read(pc.objectId)\n }\n const shoveable = this.o.shoveable\n if (!shoveable) return cover\n for (const b of this.bounds.values()) {\n if (b.piece || cover.has(b.id) || !shoveable(b.id) || !this.world.has(b.id)) continue\n centre.copy(this.measure(b.root, this.meshesOf(b)).center).applyQuaternion(b.root.quaternion).add(b.root.position)\n read(b.id)\n }\n return cover\n }\n\n /** The bound objects without a piece that the host lets a blast move (`shoveable`): the ones it reaches with enough speed become pieces and get the shove. */\n private loosen(point: Vec3, radius: number, energy: number, reachOf: (objectId: string, at: Vec3) => number): void {\n const shoveable = this.o.shoveable\n if (!shoveable) return\n for (const b of [...this.bounds.values()]) {\n if (b.piece || this.pieceSys.get(b.id) || !shoveable(b.id) || !this.world.has(b.id)) continue\n const { half, center } = this.measure(b.root, this.meshesOf(b))\n const world = center.clone().applyQuaternion(b.root.quaternion).add(b.root.position)\n const mass = this.massOf(b.id)\n if (world.distanceTo(this.v2.set(point[0], point[1], point[2])) > radius) continue\n const hit = blastShove({ point, energy, radius, reach: reachOf(b.id, [world.x, world.y, world.z]) }, { position: [world.x, world.y, world.z], mass }, this.o.blastShove)\n if (!hit) continue\n const piece = this.makePiece(b.id, { mass })\n const body = this.pieceSys.get(b.id)\n if (!body) continue\n this.o.onLoosened?.(b.id, piece, 'blast')\n const spread = half[0]\n const momentum = hit.speed * mass\n this.pieceSys.impulse(body, [hit.direction[0] * momentum, hit.direction[1] * momentum, hit.direction[2] * momentum], [world.x + (this.rng() - 0.5) * spread, world.y + spread * 0.5, world.z + (this.rng() - 0.5) * spread])\n }\n }\n\n private playExplosion(ev: Ev<'explode'>, options: ExplodeOptions): void {\n const named = options.effect ?? ev.effect\n const direction = options.direction\n const scale = clamp(ev.radius / GENERIC_REFERENCE_RADIUS, 0.2, 3)\n if (named !== undefined && this.vfx.explosion(named, ev.point, direction ? { direction } : {}) !== null) return\n this.vfx.explosion('generic', ev.point, { scale, ...(direction ? { direction } : {}) })\n }\n\n private startFire(ev: { object: string; part: string; point: Vec3 }): void {\n const key = `${ev.object}|${ev.part}`\n this.stopFire(key)\n this.fires.set(key, { object: ev.object, part: ev.part, point: ev.point, follow: { x: ev.point[0], y: ev.point[1], z: ev.point[2] } })\n }\n\n private stopFire(key: string): void {\n const fire = this.fires.get(key)\n if (fire) {\n if (fire.handle !== undefined) this.vfx.stop(fire.handle)\n this.fires.delete(key)\n }\n this.endBurnSound(key)\n }\n\n /** A part's fire loop starts; one already running for the part (it caught again) is ended first, so the host never counts a fire twice. */\n private startBurnSound(object: string, part: string, point: Vec3, detail: SoundDetail | undefined): void {\n const key = `${object}|${part}`\n this.endBurnSound(key)\n this.burnSounds.set(key, { object, point, detail })\n this.sound('burn_loop', point, 0.5, detail)\n }\n\n /** The part's fire loop ends, with the point and the fuel it started with; nothing when it has none running. */\n private endBurnSound(key: string): void {\n const started = this.burnSounds.get(key)\n if (!started) return\n this.burnSounds.delete(key)\n this.sound('burn_end', started.point, 0.5, started.detail)\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Fire, heat, char, melt, leaks\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n private updateActive(dt: number): void {\n this.scanTimer += dt\n if (this.scanTimer >= 0.4) {\n this.scanTimer = 0\n for (const b of this.bounds.values()) {\n for (const pv of b.parts.values()) {\n if (pv.gone !== 'none' && pv.gone !== 'broken') continue\n const ps = this.world.part(b.id, pv.id)\n if (!ps) continue\n const def = this.world.materials.get(pv.material)\n if (\n ps.burning ||\n (def?.visual?.glows && ps.temperature > GLOW_FROM_C) ||\n Math.abs(ps.char - pv.charApplied) > 0.01 ||\n Math.abs(ps.melt - pv.meltApplied) > 0.01 ||\n (pv.gone === 'none' && (ps.status === 'melted' || ps.status === 'ashes'))\n ) {\n this.activate(b.id, pv.id)\n }\n }\n }\n }\n for (const [key, a] of this.active) {\n const pv = this.partVis(a.object, a.part)\n const ps = pv ? this.world.part(a.object, a.part) : null\n if (!pv || !ps) {\n this.active.delete(key)\n this.stopFire(key)\n continue\n }\n const def = this.world.materials.get(pv.material)\n if (pv.gone === 'none') {\n this.visuals.setChar(pv, ps.char, def?.visual?.charColor ?? 0x1a1410)\n if (def?.visual?.glows) this.visuals.setGlow(pv, ps.temperature)\n this.visuals.setMelt(pv, ps.melt)\n if (ps.status === 'melted') this.onGone(a.object, pv, 'melted', def)\n else if (ps.status === 'ashes') this.onGone(a.object, pv, 'ashes', def)\n }\n const fire = this.fires.get(key)\n if (fire) {\n if (ps.burning && ps.status !== 'broken' && ps.status !== 'ashes' && ps.status !== 'melted') this.emitFire(fire, pv, def)\n else this.stopFire(key)\n }\n const hot = def?.visual?.glows === true && ps.temperature > GLOW_FROM_C\n if (!ps.burning && !hot && Math.abs(ps.char - pv.charApplied) < 0.01 && Math.abs(ps.melt - pv.meltApplied) < 0.01) {\n if (def?.visual?.glows && pv.gone === 'none') this.visuals.setGlow(pv, 0)\n this.active.delete(key)\n }\n }\n }\n\n private onGone(objectId: string, pv: PartVis, reason: 'melted' | 'ashes', def: MaterialDef | undefined): void {\n const bb = new this.THREE.Box3()\n for (const mv of pv.meshes) bb.union(this.visuals.worldBox(mv, this.box))\n this.visuals.hide(pv, reason)\n if (bb.isEmpty()) return\n const c = bb.getCenter(new this.THREE.Vector3())\n const s = bb.getSize(new this.THREE.Vector3())\n const footprint = Math.sqrt(Math.max(s.x * s.z, 1e-4))\n if (reason === 'melted') {\n this.ground.add('puddle', c.x, c.z, clamp(footprint * 0.55, 0.05, 1), this.partColor(pv, def) ?? fallbackColor(def), objectId)\n } else {\n this.ground.add('ash', c.x, c.z, clamp(footprint * 0.35, 0.04, 0.5), 0x1d1a18, objectId)\n this.vfx.burst('ash', [c.x, bb.max.y, c.z], [0, 1, 0], 10, 0.8)\n }\n }\n\n private emitFire(f: FireEmitter, pv: PartVis, def: MaterialDef | undefined): void {\n const bb = this.box\n bb.makeEmpty()\n const tmp = new this.THREE.Box3()\n for (const mv of pv.meshes) if (this.visuals.shown(mv)) bb.union(this.visuals.worldBox(mv, tmp))\n if (!bb.isEmpty()) {\n const c = bb.getCenter(this.v1)\n f.follow.x = c.x\n f.follow.y = bb.min.y\n f.follow.z = c.z\n }\n if (f.handle !== undefined) return\n const size = bb.isEmpty() ? this.v2.set(0.2, 0.2, 0.2) : bb.getSize(this.v2)\n const radius = clamp(Math.max(size.x, size.z) * 0.5, 0.12, 1.2)\n const smokeColor = SMOKE_TONES[def?.thermal.smoke ?? 'grey']\n f.handle = this.vfx.fire({ point: [f.follow.x, f.follow.y, f.follow.z], radius, life: FIRE_CEILING_SECONDS, follow: f.follow, ...(smokeColor !== undefined ? { smokeColor } : {}) })\n }\n\n private updateLeaks(dt: number): void {\n for (let i = this.leaks.length - 1; i >= 0; i--) {\n const l = this.leaks[i]\n const b = this.bounds.get(l.object)\n const ps = this.world.part(l.object, l.part)\n // a leak ends when the container is empty or the opening is closed (a valve shut, `seal`)\n if (!b || !ps || ps.liters === undefined || ps.liters <= 1e-4 || (l.opened && !ps.holes.some((h) => h.through))) {\n this.leaks.splice(i, 1)\n continue\n }\n l.life = (l.life ?? 0) + dt\n if (l.pressurized && l.life > 0.8) l.pressurized = false\n\n if (l.lastLiters !== undefined && Math.abs(ps.liters - l.lastLiters) < 1e-5) {\n l.idleSeconds = (l.idleSeconds ?? 0) + dt\n if (l.idleSeconds > 0.4) {\n this.leaks.splice(i, 1)\n continue\n }\n } else {\n l.idleSeconds = 0\n l.lastLiters = ps.liters\n }\n\n let pt = l.point\n let dir = l.direction\n if (l.localPoint && l.localDirection) {\n b.root.updateWorldMatrix(true, false)\n const wp = this.v1.set(l.localPoint[0], l.localPoint[1], l.localPoint[2]).applyMatrix4(b.root.matrixWorld)\n const wd = this.v2.set(l.localDirection[0], l.localDirection[1], l.localDirection[2]).transformDirection(b.root.matrixWorld).normalize()\n pt = [wp.x, wp.y, wp.z]\n dir = [wd.x, wd.y, wd.z]\n l.point = pt\n l.direction = dir\n }\n\n l.acc += clamp(20 + l.rate * 400, 15, 120) * dt\n const color = FLUID_COLORS[l.fluid] ?? 0xaaaaaa\n const dl = Math.hypot(dir[0], dir[1], dir[2]) || 1\n const sp = l.pressurized ? 2.5 + this.rng() * 1.5 : 0.3 + this.rng() * 0.3\n while (l.acc >= 1) {\n l.acc -= 1\n const vel: Vec3 = [(dir[0] / dl) * sp + (this.rng() - 0.5) * 0.25, (dir[1] / dl) * sp + (this.rng() - 0.5) * 0.25, (dir[2] / dl) * sp + (this.rng() - 0.5) * 0.25]\n if (l.fluid === 'gas') this.vfx.spawn('steam', pt, vel, { color, size: 0.5, alpha: 0.5 })\n else this.vfx.spawn('drips', pt, vel, { color, tag: this.rng() < 0.03 ? this.tagOf(l.object) : 0, owner: this.owner })\n }\n }\n }\n\n private tagOf(object: string): number {\n let tag = this.homeTags.indexOf(object) + 1\n if (tag === 0) tag = this.homeTags.push(object)\n return tag\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Emit, clear, restore, stats, dispose\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n emit(kind: DebrisKind | 'fire' | 'flash' | 'foam', point: Vec3, normal: Vec3, count: number, speed?: number): void {\n this.vfx.burst(kind, point, normal, count, speed ?? DEFAULT_SPEED[kind] ?? 1, kind === 'smoke' ? { color: SMOKE_TONES.grey } : undefined)\n }\n\n explode(point: Vec3, energy: number, radius: number, options?: ExplodeOptions): void {\n this.onExplode({ type: 'explode', object: '', part: '', time: this.time, point, energy, radius }, options)\n }\n\n restore(objectId: string): void {\n const homes = new Set<string>([objectId])\n const self = this.bounds.get(objectId)\n if (self?.isSplit) for (const pv of self.parts.values()) homes.add(pv.home)\n for (const home of homes) this.restoreHome(home)\n for (const [key, a] of [...this.active]) if (homes.has(a.object)) this.active.delete(key)\n for (const [key, f] of [...this.fires]) if (homes.has(f.object)) this.stopFire(key)\n for (const [key, started] of [...this.burnSounds]) if (homes.has(started.object)) this.endBurnSound(key)\n for (let i = this.leaks.length - 1; i >= 0; i--) if (homes.has(this.leaks[i].object)) this.leaks.splice(i, 1)\n for (const home of homes) {\n this.fragments.removeHome(home)\n this.ground.removeHome(home)\n this.cages.removeObject(home)\n }\n }\n\n private restoreHome(home: string): void {\n const homeBound = this.bounds.get(home)\n for (const b of [...this.bounds.values()]) {\n for (const [pid, pv] of [...b.parts]) {\n if (pv.home !== home) continue\n this.settlement.forget(pv)\n this.visuals.restorePart(pv)\n this.tagPart(pv, home)\n if (b !== homeBound && homeBound) {\n b.parts.delete(pid)\n homeBound.parts.set(pid, pv)\n }\n }\n if (b.isSplit && b.parts.size === 0) {\n this.scene.remove(b.root)\n this.pieceSys.remove(b.id)\n this.bounds.delete(b.id)\n // its box leaves now: the periodic round only walks the objects still bound\n this.staticDirty.add(b.id)\n }\n }\n }\n\n clear(): void {\n // what was bound is gone: the next read measures what is left, all of it\n this.staticAll = true\n this.queue.length = 0\n this.slices.length = 0\n this.active.clear()\n for (const key of [...this.fires.keys()]) this.stopFire(key)\n for (const key of [...this.burnSounds.keys()]) this.endBurnSound(key)\n this.leaks.length = 0\n this.trickles.length = 0\n this.settlement.clear()\n for (const id of [...this.bounds.keys()]) if (this.bounds.has(id)) this.restore(id)\n // anything left of a split object whose home is gone\n for (const b of [...this.bounds.values()]) {\n if (b.isSplit) {\n for (const pv of b.parts.values()) this.visuals.restorePart(pv)\n this.scene.remove(b.root)\n this.pieceSys.remove(b.id)\n this.bounds.delete(b.id)\n }\n }\n this.fragments.clear()\n this.ground.clear()\n this.cages.clear()\n this.primedBurning.clear()\n this.vfx.sprites().clear()\n this.ownVfx?.world.clear()\n }\n\n reset(): void {\n this.clear()\n this.rng = createRng(RNG_SEED)\n this.time = 0\n this.staticAt = 0\n this.staticRound = []\n this.staticAll = true\n this.throttles.clear()\n this.fragments.reset()\n this.pieceSys.reset()\n }\n\n wakeRegion(x: number, z: number, radius: number): void {\n this.fragments.wakeRegion(x, z, radius)\n this.pieceSys.wakeRegion(x, z, radius)\n }\n\n stats(): { fragments: number; particles: number; pieces: number; decals: number } {\n return { fragments: this.fragments.count, particles: this.vfx.sprites().live + this.ownedVfxParticles(), pieces: this.pieceSys.list.length, decals: this.visuals.decalCount + this.ground.count }\n }\n\n private ownedVfxParticles(): number {\n if (!this.ownVfx) return 0\n const { puffs, sparks, glows, chunks } = this.vfx.stats()\n return puffs + sparks + glows + chunks\n }\n\n // The last warm-up keeps its materials until the next one: a material that does not use lights keeps the program of the lights it was first drawn with, so each warm-up needs materials of its own.\n private warmProbes: { readonly group: THREE_NS.Group; readonly geometry: THREE_NS.BufferGeometry; readonly materials: THREE_NS.Material[] } | undefined\n\n warmUpProbes(): WarmUpProbes {\n this.releaseWarmProbes()\n const { kit } = this.visuals\n const T = this.THREE\n const geometry = new T.BufferGeometry()\n geometry.setAttribute('position', new T.BufferAttribute(new Float32Array(6), 3))\n const materials = [kit.discMaterial().clone(), kit.patchMaterial(0x808080).clone(), kit.lineMaterial(0x000000).clone()]\n const group = new T.Group()\n group.add(new T.Mesh(kit.discGeometry(), materials[0]), new T.Mesh(kit.discGeometry(), materials[1]), new T.LineSegments(geometry, materials[2] as THREE_NS.LineBasicMaterial))\n group.add(...this.fragments.warmMeshes())\n for (const probe of group.children) probe.frustumCulled = false\n this.warmProbes = { group, geometry, materials }\n return { group, dispose: () => {} }\n }\n\n private releaseWarmProbes(): void {\n if (!this.warmProbes) return\n this.warmProbes.geometry.dispose()\n for (const material of this.warmProbes.materials) material.dispose()\n this.warmProbes = undefined\n }\n\n rebarCount(): number {\n return this.cages.count\n }\n\n dispose(): void {\n this.releaseWarmProbes()\n if (this.disposed) return\n this.unsubscribe()\n this.clear()\n for (const id of [...this.bounds.keys()]) this.unbind(id)\n this.fragments.dispose()\n this.ground.dispose()\n this.cages.dispose()\n this.stopLanding()\n this.visuals.dispose()\n this.ownVfx?.dispose()\n this.disposed = true\n }\n}\n","import type * as THREE_NS from 'three'\nimport { markKitOrigin } from '@adatechnology/game-contracts'\nimport type { Fragment, SplitForm } from '@adatechnology/game-destruction'\n\nimport { pushFittedBoxes } from './fitted-boxes'\nimport { FRAGMENT_SHAPE_VARIANTS, buildBrokenBoardGeometry, buildLumpGeometry, buildRubbleGeometry, buildSliverGeometry, buildVeneerGeometry } from './fragment-shapes'\nimport { clamp, createRng, hashString } from './math'\nimport type { LooseBody } from './types'\n\ninterface Live {\n mesh: THREE_NS.Mesh\n /** The surface under the fragment (ground or what is built), and where it was measured: measured again once the fragment moves off that spot. */\n floor: { x: number; z: number; y: number } | null\n home: string\n vel: THREE_NS.Vector3\n ang: THREE_NS.Vector3\n half: THREE_NS.Vector3\n baseScale: THREE_NS.Vector3\n still: number\n asleep: boolean\n /** Seconds at rest. */\n rest: number\n /** 1 while alive; counts down to 0 while shrinking away. */\n fade: number\n dying: boolean\n /** Air drag per second: a loose sheet (a page) glides and flutters down instead of dropping. */\n air: number\n /** A big one (`isBig`): it stays where it lies, and what walks steps on it or kicks it. */\n body: LooseBody | null\n /** The `update` count when it was made. */\n born: number\n /** Seconds it stays at rest before it fades (0 = forever). */\n life: number\n}\n\n/** What a fragment's resting time can depend on: the fragment (its material, size, shape) and the id of the object it came from. */\nexport type FragmentLifeRule = (fragment: Fragment, objectId: string) => number\n\nexport interface FragmentSystemOptions {\n scene: THREE_NS.Scene\n groundAt: (x: number, z: number) => number\n gravity: number\n max: number\n /** Seconds a resting fragment stays before it fades (0 = forever), or a rule that gives it per fragment. */\n life: number | FragmentLifeRule\n /** How a material comes apart (`MaterialDef.splitForm`): MDF lumps and plywood veneer get shapes of their own. Default: none. */\n formOf?: (materialId: string) => SplitForm | undefined\n /**\n * The top of whatever is under (x, z) below height y: the ground, or a slab, a wall, a piece of furniture a piece of rubble lands on. Default: the\n * ground (`groundAt`).\n */\n surfaceAt?: (x: number, y: number, z: number) => number\n /** Whether a material crumbles (`MaterialDef.fracture` 'crumble': brick, block, concrete, plaster): its chunks are drawn broken, not as cut boxes. */\n crumbles?: (materialId: string) => boolean\n}\n\nconst BUILDERS: Record<Exclude<SharedShape, 'shard'>, (THREE: typeof THREE_NS, seed: number) => THREE_NS.BufferGeometry> = {\n sliver: buildSliverGeometry,\n lump: buildLumpGeometry,\n veneer: buildVeneerGeometry,\n board: buildBrokenBoardGeometry,\n rubble: buildRubbleGeometry,\n}\n\n/** The shared shapes a fragment can take besides the box: glass shards, wood splinters, MDF lumps, plywood veneer and the torn stub of a broken board. */\ntype SharedShape = 'shard' | 'sliver' | 'lump' | 'veneer' | 'board' | 'rubble'\n\n/** How far (m) a fragment moves before what is under it is measured again. */\nconst FLOOR_REMEASURE = 0.5\n/** Thickest scrap that flies as a sheet (m), its air drag (1/s) and how hard it sways (m/s²). */\nconst SHEET_MAX = 0.004\nconst SHEET_AIR = 2.5\nconst SHEET_SWAY = 3\n/** A fragment at least this long (m) and this wide is a piece of the thing (half a board), not a splinter; a shard of glass never is. */\nconst BIG_LENGTH = 0.2\nconst BIG_WIDTH = 0.03\n/** The seed of the fragments' random stream (their spin and sway); `reset` takes it back here. */\nconst FRAGMENT_SEED = 0x51ed270b\n\n/** Fragments asleep whose ground is looked at again each update, in turn, and how far (m) over it one may lie before it falls: the table it lay on broke. */\nconst SUPPORT_CHECKS = 32\nconst SUPPORT_GAP = 0.02\n\n/** How many shard shapes there are; a fragment takes one by the hash of its id. */\nconst SHARD_SHAPES = 6\n\nconst isBig = (size: readonly number[]): boolean => {\n const [, middle, longest] = [...size].sort((a, b) => a - b)\n return longest >= BIG_LENGTH && middle >= BIG_WIDTH\n}\n\n/** Light physics for fracture debris: gravity, ground bounce and friction, spin damping, settling flat, sleep, shrink-away and removal. */\nexport class FragmentSystem {\n private readonly list: Live[] = []\n private readonly box: THREE_NS.BoxGeometry\n /** The mesh box of a fragment before its scale. */\n private readonly unitBox = { min: { x: -0.5, y: -0.5, z: -0.5 }, max: { x: 0.5, y: 0.5, z: 0.5 } }\n private shardGeos: THREE_NS.BufferGeometry[] = []\n private readonly shapeGeos = new Map<Exclude<SharedShape, 'shard'>, THREE_NS.BufferGeometry[]>()\n private readonly materials = new Map<string, THREE_NS.Material>()\n private readonly q: THREE_NS.Quaternion\n private readonly dq: THREE_NS.Quaternion\n private readonly m: THREE_NS.Matrix4\n private readonly v: THREE_NS.Vector3\n private readonly w: THREE_NS.Vector3\n private rng = createRng(FRAGMENT_SEED)\n /** Count of `update` calls: what makes the fragments of one burst tell apart from older ones. */\n private tick = 0\n private supportTurn = 0\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly o: FragmentSystemOptions,\n ) {\n this.box = new THREE.BoxGeometry(1, 1, 1)\n this.q = new THREE.Quaternion()\n this.dq = new THREE.Quaternion()\n this.m = new THREE.Matrix4()\n this.v = new THREE.Vector3()\n this.w = new THREE.Vector3()\n }\n\n get count(): number {\n return this.list.length\n }\n\n /** Meshes of every live fragment (tests and picking). */\n meshes(): THREE_NS.Mesh[] {\n return this.list.map((f) => f.mesh)\n }\n\n /** One shared material per source material id + colour (+ transparency). */\n materialFor(materialId: string, color: number, transparent: boolean, opacity = 0.5): THREE_NS.Material {\n const key = `${materialId}:${color}:${transparent ? 1 : 0}`\n let m = this.materials.get(key)\n if (!m) {\n m = transparent\n ? new this.THREE.MeshStandardMaterial({ color, roughness: 0.15, metalness: 0.1, transparent: true, opacity, side: this.THREE.DoubleSide, depthWrite: false })\n : new this.THREE.MeshLambertMaterial({ color })\n this.materials.set(key, m)\n }\n return m\n }\n\n private shardGeometry(seed: number): THREE_NS.BufferGeometry {\n const idx = seed % SHARD_SHAPES\n let g = this.shardGeos[idx]\n if (!g) {\n const r = createRng(1000 + idx)\n const n = 3 + Math.floor(r() * 3) // triangle, quad or pentagon, irregular\n const shape = new this.THREE.Shape()\n const pts: Array<[number, number]> = []\n for (let i = 0; i < n; i++) {\n const a = (i / n) * Math.PI * 2 + (r() - 0.5) * 0.7\n const rad = 0.35 + r() * 0.15\n pts.push([Math.cos(a) * rad, Math.sin(a) * rad])\n }\n shape.moveTo(pts[0][0], pts[0][1])\n for (let i = 1; i < n; i++) shape.lineTo(pts[i][0], pts[i][1])\n shape.closePath()\n g = new this.THREE.ExtrudeGeometry(shape, { depth: 1, bevelEnabled: false })\n g.translate(0, 0, -0.5)\n this.shardGeos[idx] = g\n }\n return g\n }\n\n private sharedGeometry(shape: Exclude<SharedShape, 'shard'>, seed: number): THREE_NS.BufferGeometry {\n const idx = seed % FRAGMENT_SHAPE_VARIANTS\n let variants = this.shapeGeos.get(shape)\n if (!variants) {\n variants = []\n this.shapeGeos.set(shape, variants)\n }\n let g = variants[idx]\n if (!g) {\n g = BUILDERS[shape](this.THREE, idx)\n variants[idx] = g\n }\n return g\n }\n\n /**\n * The geometry a fragment is drawn with: a splinter is a pointed, frayed sliver; MDF breaks in lumps, plywood peels in ragged veneer, the stub of a broken\n * board ends in torn strands at +x; the rest are boxes.\n */\n private geometryOf(f: Fragment): THREE_NS.BufferGeometry {\n const seed = hashString(f.id)\n if (f.shape === 'shard') return this.shardGeometry(seed)\n if (f.shape === 'splinter') return this.sharedGeometry('sliver', seed)\n const form = this.o.formOf?.(f.material)\n if (f.shape === 'chunk' && form === 'granules') return this.sharedGeometry('lump', seed)\n if (f.shape === 'scrap' && form === 'plies') return this.sharedGeometry('veneer', seed)\n if (f.shape === 'slab' && (form === 'slivers' || form === 'plies')) return this.sharedGeometry('board', seed)\n if (f.shape === 'chunk' && this.o.crumbles?.(f.material)) return this.sharedGeometry('rubble', seed)\n return this.box\n }\n\n private markGeometry: THREE_NS.CircleGeometry | null = null\n private markMaterial: THREE_NS.MeshBasicMaterial | null = null\n\n private markParts(): { geometry: THREE_NS.CircleGeometry; material: THREE_NS.MeshBasicMaterial } {\n this.markGeometry ??= new this.THREE.CircleGeometry(1, 10)\n this.markMaterial ??= new this.THREE.MeshBasicMaterial({ color: 0x0b0a09, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -4, polygonOffsetUnits: -4 })\n return { geometry: this.markGeometry, material: this.markMaterial }\n }\n\n /**\n * Meshes, never put in a scene by this class, that draw every shared piece of a fragment once: the box, the six shards, the wood splinters, MDF lumps, plywood veneer, broken masonry, the bullet-hole disc, and the opaque and\n * glass materials. A host draws them at load so the first blast does not upload these buffers in the middle of a frame.\n */\n warmMeshes(): THREE_NS.Mesh[] {\n const opaque = this.materialFor('warm', 0x808080, false)\n const glass = this.materialFor('warm', 0x808080, true)\n const geometries = [this.box, ...Array.from({ length: SHARD_SHAPES }, (_, index) => this.shardGeometry(index))]\n const shaped = (['sliver', 'lump', 'veneer', 'board', 'rubble'] as const).flatMap((shape) => Array.from({ length: FRAGMENT_SHAPE_VARIANTS }, (_, index) => this.sharedGeometry(shape, index)))\n const { geometry, material } = this.markParts()\n return [\n ...geometries.flatMap((shared) => [new this.THREE.Mesh(shared, opaque), new this.THREE.Mesh(shared, glass)]),\n ...shaped.map((shared) => new this.THREE.Mesh(shared, opaque)),\n new this.THREE.Mesh(geometry, material),\n ]\n }\n\n /**\n * Bullet holes that stay on a fragment (`Fragment.marks`): dark discs that are children of its mesh, so they fall, spin and settle with it. The mesh is\n * a unit box scaled to the fragment, so each disc is scaled back; exact for a mark on a face, which is where a bullet hole is.\n */\n addMarks(mesh: THREE_NS.Mesh, f: Fragment): void {\n if (!f.marks?.length) return\n const { geometry, material } = this.markParts()\n const sc = mesh.scale\n for (const mark of f.marks) {\n const disc = new this.THREE.Mesh(geometry, material)\n const radius = Math.max(0.004, mark.diameter) * 0.6\n const n = this.v.set(mark.normal[0], mark.normal[1], mark.normal[2]).normalize()\n disc.position.set(mark.point[0] / sc.x + (n.x * 0.002) / sc.x, mark.point[1] / sc.y + (n.y * 0.002) / sc.y, mark.point[2] / sc.z + (n.z * 0.002) / sc.z)\n disc.quaternion.setFromUnitVectors(this.w.set(0, 0, 1), n)\n disc.scale.set(radius / sc.x, radius / sc.y, radius / sc.z)\n mesh.add(disc)\n }\n }\n\n /**\n * Create the mesh of a fragment and start its motion. `maxAllowed` is the live budget: over it the oldest fragment still showing fades out to make room, and a burst\n * bigger than the budget (every live fragment was made in this same frame) does not make the rest at all, so a blast never builds a thousand meshes only to fade them\n * out. Returns null when the fragment was not made.\n */\n /**\n * Throws `f` into the scene, within `maxAllowed` live fragments (the oldest small ones make room first). A `lasting` fragment (a steel bar) is debris that\n * stays: it has a body the player and the pieces run into, however thin it is, and it never fades.\n */\n spawn(f: Fragment, material: THREE_NS.Material, home: string, maxAllowed: number, lasting = false): THREE_NS.Mesh | null {\n if (this.list.length >= maxAllowed) {\n let alive = 0\n let oldest: Live | undefined\n let oldestSmall: Live | undefined\n for (const l of this.list) {\n if (l.dying) continue\n alive++\n oldest ??= l\n if (!l.body) oldestSmall ??= l\n }\n // the splinters go first; the big ones only when nothing else is left\n oldest = oldestSmall ?? oldest\n if (alive >= maxAllowed) {\n if (!oldest || oldest.born === this.tick) return null\n oldest.dying = true\n }\n }\n const geo = this.geometryOf(f)\n const mesh = new this.THREE.Mesh(geo, material)\n mesh.position.set(f.center[0], f.center[1], f.center[2])\n mesh.quaternion.set(f.rotation[0], f.rotation[1], f.rotation[2], f.rotation[3]).normalize()\n const sz = f.size\n const sc = new this.THREE.Vector3(Math.max(0.005, sz[0]), Math.max(0.005, sz[1]), Math.max(0.003, sz[2]))\n mesh.scale.copy(sc)\n mesh.castShadow = true\n // pure visual debris: a host that picks with a raycast can skip it\n mesh.userData.destructionDebris = true\n mesh.name = 'fragment'\n markKitOrigin(mesh, { owner: 'game-destruction-three', kind: 'fragment', id: f.material })\n this.o.scene.add(mesh)\n const live: Live = {\n mesh,\n floor: null,\n home,\n vel: new this.THREE.Vector3(f.velocity[0], f.velocity[1], f.velocity[2]),\n ang: new this.THREE.Vector3(f.angularVelocity[0], f.angularVelocity[1], f.angularVelocity[2]),\n // shards are thin: the contact extent uses the real (small) thickness, the chunk uses half of each side\n half: sc.clone().multiplyScalar(0.5),\n baseScale: sc,\n still: 0,\n asleep: false,\n rest: 0,\n fade: 1,\n dying: false,\n air: f.shape === 'scrap' && sz[2] <= SHEET_MAX ? SHEET_AIR : 0,\n body: null,\n born: this.tick,\n life: lasting ? 0 : Math.max(0, typeof this.o.life === 'function' ? this.o.life(f, home) : this.o.life),\n }\n // a big piece stays where it fell, whatever its shape: a slab of a roof tile is debris as much as a chunk of brick is\n if (lasting || isBig(f.size)) {\n live.body = {\n mass: f.mass,\n push: (x, z) => {\n live.vel.x = x\n live.vel.z = z\n live.vel.y = Math.max(live.vel.y, 0.3)\n this.rouse(live)\n },\n }\n }\n this.list.push(live)\n this.addMarks(mesh, f)\n return mesh\n }\n\n /** The boxes of the big fragments around (x, z). */\n solidsNear(x: number, z: number, radius: number, found: (home: string, min: [number, number, number], max: [number, number, number], body: LooseBody) => void): void {\n const boxes: number[] = []\n for (const f of this.list) {\n if (!f.body || f.dying) continue\n const reach = f.half.length() + radius\n if (Math.abs(f.mesh.position.x - x) > reach || Math.abs(f.mesh.position.z - z) > reach) continue\n f.mesh.updateMatrixWorld()\n boxes.length = 0\n pushFittedBoxes(this.unitBox, f.mesh.matrixWorld, boxes)\n for (let i = 0; i < boxes.length; i += 6) {\n if (x < boxes[i] - radius || x > boxes[i + 3] + radius || z < boxes[i + 2] - radius || z > boxes[i + 5] + radius) continue\n found(f.home, [boxes[i], boxes[i + 1], boxes[i + 2]], [boxes[i + 3], boxes[i + 4], boxes[i + 5]], f.body)\n }\n }\n }\n\n /** Add velocity to every fragment within `radius` of a point (blasts). */\n blast(point: [number, number, number], radius: number, speed: number): void {\n for (const f of this.list) {\n const d = this.v.copy(f.mesh.position).sub(this.w.set(point[0], point[1], point[2]))\n const dist = d.length()\n if (dist > radius || f.dying) continue\n const k = (1 - dist / radius) ** 2 * speed\n d.normalize().multiplyScalar(k)\n d.y += k * 0.4\n f.vel.add(d)\n f.ang.add(this.w.set(this.rng() - 0.5, this.rng() - 0.5, this.rng() - 0.5).multiplyScalar(k))\n this.rouse(f)\n }\n }\n\n /** A fragment that came to rest stops having its matrix recomputed on every frame; whatever moves it again calls this first. */\n private rouse(f: Live): void {\n f.asleep = false\n f.rest = 0\n // what it lay on may be gone: the floor is measured again where it lies\n f.floor = null\n f.mesh.matrixAutoUpdate = true\n }\n\n /** What lies inside the disc looks at the ground again: it was dug or heaped under it. */\n wakeRegion(x: number, z: number, radius: number): void {\n for (const f of this.list) {\n if (!f.asleep || Math.hypot(f.mesh.position.x - x, f.mesh.position.z - z) > radius) continue\n this.rouse(f)\n }\n }\n\n update(dt: number): void {\n this.tick++\n this.wakeUnsupported()\n const g = this.o.gravity\n for (let i = this.list.length - 1; i >= 0; i--) {\n const f = this.list[i]\n if (f.dying) {\n f.mesh.matrixAutoUpdate = true\n f.fade -= dt / 0.6\n if (f.fade <= 0) {\n this.o.scene.remove(f.mesh)\n this.list.splice(i, 1)\n continue\n }\n f.mesh.scale.copy(f.baseScale).multiplyScalar(f.fade)\n }\n if (f.asleep) {\n f.rest += dt\n if (f.life > 0 && f.rest > f.life && !f.body) {\n f.dying = true\n f.mesh.matrixAutoUpdate = true\n }\n continue\n }\n this.step(f, dt, g)\n }\n }\n\n /** A few fragments asleep each update (`SUPPORT_CHECKS`, in turn) look at the ground under them again: one left over air falls. */\n private wakeUnsupported(): void {\n const n = this.list.length\n for (let k = 0; k < Math.min(SUPPORT_CHECKS, n); k++) {\n this.supportTurn = (this.supportTurn + 1) % n\n const f = this.list[this.supportTurn]\n if (!f.asleep || f.dying) continue\n const e = this.m.makeRotationFromQuaternion(f.mesh.quaternion).elements\n const ext = Math.abs(e[1]) * f.half.x + Math.abs(e[5]) * f.half.y + Math.abs(e[9]) * f.half.z\n // measured afresh: the floor kept from its landing is the top it landed on, which may have broken or been carried off since\n f.floor = null\n if (f.mesh.position.y - ext > this.floorUnder(f) + SUPPORT_GAP) this.rouse(f)\n }\n }\n\n /** What a fragment lands on: measured where it is, and again only once it moved `FLOOR_REMEASURE` m off that spot (a ray down is not free). */\n private floorUnder(f: Live): number {\n const p = f.mesh.position\n if (!this.o.surfaceAt) return this.o.groundAt(p.x, p.z)\n const at = f.floor\n if (!at || Math.abs(at.x - p.x) > FLOOR_REMEASURE || Math.abs(at.z - p.z) > FLOOR_REMEASURE || p.y < at.y - FLOOR_REMEASURE) {\n f.floor = { x: p.x, z: p.z, y: this.o.surfaceAt(p.x, p.y, p.z) }\n }\n return f.floor!.y\n }\n\n private step(f: Live, dt: number, g: number): void {\n const mesh = f.mesh\n f.vel.y -= g * dt\n mesh.position.addScaledVector(f.vel, dt)\n const w = f.ang.length()\n if (w > 1e-5) {\n this.dq.setFromAxisAngle(this.v.copy(f.ang).multiplyScalar(1 / w), w * dt)\n mesh.quaternion.premultiply(this.dq).normalize()\n }\n // ground contact: lowest point of the oriented box\n this.m.makeRotationFromQuaternion(mesh.quaternion)\n const e = this.m.elements\n const h = f.half\n const sc = f.dying ? f.fade : 1\n const ext = (Math.abs(e[1]) * h.x + Math.abs(e[5]) * h.y + Math.abs(e[9]) * h.z) * sc\n const gy = this.floorUnder(f)\n let contact = false\n if (mesh.position.y - ext < gy) {\n contact = true\n mesh.position.y = gy + ext\n if (f.vel.y < -0.6) {\n f.vel.y = -f.vel.y * 0.25\n f.vel.x *= 0.7\n f.vel.z *= 0.7\n f.ang.multiplyScalar(0.55)\n // a hit on a corner makes it tumble a little\n f.ang.x += (this.rng() - 0.5) * 2\n f.ang.z += (this.rng() - 0.5) * 2\n } else {\n f.vel.y = 0\n const fr = Math.exp(-7 * dt)\n f.vel.x *= fr\n f.vel.z *= fr\n f.ang.multiplyScalar(Math.exp(-6 * dt))\n }\n } else {\n f.ang.multiplyScalar(Math.exp(-0.15 * dt))\n if (f.air > 0) this.flutter(f, dt)\n }\n if (contact && f.vel.lengthSq() < 4) this.settle(f, dt)\n const slow = f.vel.lengthSq() < 0.012 && f.ang.lengthSq() < 0.2\n if (contact && slow) {\n f.still += dt\n if (f.still > 0.4) {\n f.asleep = true\n f.mesh.updateMatrix()\n f.mesh.matrixAutoUpdate = false\n f.vel.set(0, 0, 0)\n f.ang.set(0, 0, 0)\n }\n } else {\n f.still = 0\n }\n }\n\n /** A sheet in the air: drag slows it to a slow fall, and it sways and turns over as it goes. */\n private flutter(f: Live, dt: number): void {\n f.vel.multiplyScalar(Math.exp(-f.air * dt))\n f.vel.x += (this.rng() - 0.5) * SHEET_SWAY * dt\n f.vel.z += (this.rng() - 0.5) * SHEET_SWAY * dt\n f.ang.x += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt\n f.ang.z += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt\n }\n\n /** Tip the fragment towards lying on its flattest face. */\n private settle(f: Live, dt: number): void {\n const mesh = f.mesh\n this.m.makeRotationFromQuaternion(mesh.quaternion)\n const e = this.m.elements\n const up = [e[1], e[5], e[9]] // world-y component of each local axis\n const half = [f.half.x, f.half.y, f.half.z]\n let small = 0\n for (let i = 1; i < 3; i++) if (half[i] < half[small]) small = i\n let axis = small\n // a broken board does not stand on its end\n if (Math.abs(up[small]) < 0.35 && !f.body) {\n axis = 0\n for (let i = 1; i < 3; i++) if (Math.abs(up[i]) > Math.abs(up[axis])) axis = i\n }\n const sign = up[axis] >= 0 ? 1 : -1\n this.v.set(e[axis * 4], e[axis * 4 + 1], e[axis * 4 + 2]).multiplyScalar(sign)\n this.w.set(0, 1, 0)\n this.dq.setFromUnitVectors(this.v, this.w)\n this.q.copy(this.dq).multiply(mesh.quaternion)\n mesh.quaternion.slerp(this.q, clamp(dt * 7, 0, 1))\n }\n\n /** Remove the fragments of one object (after `restore`). */\n removeHome(home: string): void {\n for (let i = this.list.length - 1; i >= 0; i--) {\n if (this.list[i].home === home) {\n this.o.scene.remove(this.list[i].mesh)\n this.list.splice(i, 1)\n }\n }\n }\n\n clear(): void {\n for (const f of this.list) this.o.scene.remove(f.mesh)\n this.list.length = 0\n }\n\n /** `clear`, the random stream back to its seed and the tick to 0: what comes next flies as on a new system. */\n reset(): void {\n this.clear()\n this.rng = createRng(FRAGMENT_SEED)\n this.tick = 0\n }\n\n dispose(): void {\n this.clear()\n this.box.dispose()\n this.markGeometry?.dispose()\n this.markMaterial?.dispose()\n for (const g of this.shardGeos) g?.dispose()\n this.shardGeos = []\n for (const variants of this.shapeGeos.values()) for (const g of variants) g?.dispose()\n this.shapeGeos.clear()\n for (const m of this.materials.values()) m.dispose()\n this.materials.clear()\n }\n}\n","import type * as THREE_NS from 'three'\n\n/** Slice length (m) of a turned mesh and the most slices of one mesh. */\nconst SLICE_LENGTH = 0.12\nconst MAX_SLICES = 12\n/** A mesh whose axis box is at most this many times its own volume counts as not turned. */\nconst SNUG_RATIO = 1.1\n\ntype Corner = { readonly x: number; readonly y: number; readonly z: number }\ntype Local = { readonly min: Corner; readonly max: Corner }\n\n/**\n * Appends world axis boxes (min x, y, z, max x, y, z) around the local box of a mesh: one when it lies square, else slices along its longest side. The axis box of a board\n * lying askew is a wide square that holds mostly air, and what walks would hit that air.\n */\nexport function pushFittedBoxes(local: Local, matrix: THREE_NS.Matrix4, out: number[]): void {\n const e = matrix.elements\n const sizes = [0, 1, 2].map((k) => (k === 0 ? local.max.x - local.min.x : k === 1 ? local.max.y - local.min.y : local.max.z - local.min.z))\n const lengths = [0, 1, 2].map((k) => sizes[k] * Math.hypot(e[k * 4], e[k * 4 + 1], e[k * 4 + 2]))\n const longest = lengths.indexOf(Math.max(...lengths))\n const whole = worldBoxOf(local, matrix, longest, 0, 1)\n const span = (whole[3] - whole[0]) * (whole[4] - whole[1]) * (whole[5] - whole[2])\n const volume = lengths[0] * lengths[1] * lengths[2]\n const slices = span <= volume * SNUG_RATIO ? 1 : Math.min(MAX_SLICES, Math.ceil(lengths[longest] / SLICE_LENGTH))\n if (slices <= 1) {\n out.push(...whole)\n return\n }\n for (let i = 0; i < slices; i++) out.push(...worldBoxOf(local, matrix, longest, i / slices, (i + 1) / slices))\n}\n\nfunction worldBoxOf(local: Local, matrix: THREE_NS.Matrix4, axis: number, from: number, to: number): number[] {\n const e = matrix.elements\n const low = [local.min.x, local.min.y, local.min.z]\n const high = [local.max.x, local.max.y, local.max.z]\n const start = low[axis]\n const size = high[axis] - start\n low[axis] = start + size * from\n high[axis] = start + size * to\n const box = [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity]\n for (const x of [low[0], high[0]]) for (const y of [low[1], high[1]]) for (const z of [low[2], high[2]]) {\n for (let k = 0; k < 3; k++) {\n const v = e[k] * x + e[k + 4] * y + e[k + 8] * z + e[k + 12]\n box[k] = Math.min(box[k], v)\n box[k + 3] = Math.max(box[k + 3], v)\n }\n }\n return box\n}\n","import type { Vec3 } from '@adatechnology/game-destruction'\n\n/** Small deterministic PRNG (mulberry32): returns a function giving numbers in [0, 1). */\nexport function createRng(seed: number): () => number {\n let a = seed >>> 0\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\n/** Hash of a few numbers into an unsigned 32-bit seed. */\nexport function hashNumbers(...values: number[]): number {\n let h = 2166136261\n for (const v of values) {\n const n = Math.round(v * 1000) | 0\n h = Math.imul(h ^ n, 16777619)\n h ^= h >>> 13\n }\n return h >>> 0\n}\n\nexport function hashString(s: string): number {\n let h = 2166136261\n for (let i = 0; i < s.length; i++) h = Math.imul(h ^ s.charCodeAt(i), 16777619)\n return h >>> 0\n}\n\nexport const clamp = (v: number, lo: number, hi: number): number => (v < lo ? lo : v > hi ? hi : v)\nexport const lerp = (a: number, b: number, t: number): number => a + (b - a) * t\n\nexport function vec3Length(v: Vec3): number {\n return Math.hypot(v[0], v[1], v[2])\n}\n\nexport function normalize3(v: Vec3): Vec3 {\n const l = Math.hypot(v[0], v[1], v[2])\n return l > 1e-9 ? [v[0] / l, v[1] / l, v[2] / l] : [0, 1, 0]\n}\n\n/** `0xRRGGBB` -> `[r, g, b]` in 0..1. */\nexport function hexToRgb(hex: number): [number, number, number] {\n return [((hex >> 16) & 255) / 255, ((hex >> 8) & 255) / 255, (hex & 255) / 255]\n}\n\nexport function mixHex(a: number, b: number, t: number): number {\n const ar = (a >> 16) & 255\n const ag = (a >> 8) & 255\n const ab = a & 255\n const r = Math.round(ar + (((b >> 16) & 255) - ar) * t)\n const g = Math.round(ag + (((b >> 8) & 255) - ag) * t)\n const bl = Math.round(ab + ((b & 255) - ab) * t)\n return (r << 16) | (g << 8) | bl\n}\n","import type * as THREE_NS from 'three'\n\nimport { createRng } from './math'\n\n/** How many shapes of each kind there are; a fragment takes one by the hash of its id, so a burst shares a handful of buffers. */\nexport const FRAGMENT_SHAPE_VARIANTS = 6\n\n/** Cross-sections along a sliver (the last one is its point) and how much each corner may stray in or out (the torn fibres). */\nconst SLIVER_STATIONS = 6\nconst SLIVER_FRAY = 0.3\n\n/** Corners of a sliver's cross-section in the unit box: the four corners and a ridge on each wide face. */\nconst SLIVER_SECTION: ReadonlyArray<readonly [number, number]> = [[0.5, 0.5], [0, 0.5], [-0.5, 0.5], [-0.5, -0.5], [0, -0.5], [0.5, -0.5]]\n\n/** Width of the section along a sliver (0 at the broken end, 1 at the point): ragged and narrower at the break, full in the middle, tapering to the point. */\nconst sliverWidth = (t: number): number => (t < 0.25 ? 0.6 + 1.6 * t : t > 0.5 ? Math.max(0, (1 - t) / 0.5) ** 0.85 : 1)\n\nconst pushTriangle = (out: number[], a: readonly number[], b: readonly number[], c: readonly number[]): void => {\n out.push(a[0], a[1], a[2], b[0], b[1], b[2], c[0], c[1], c[2])\n}\n\nconst faceted = (THREE: typeof THREE_NS, positions: number[]): THREE_NS.BufferGeometry => {\n const geometry = new THREE.BufferGeometry()\n geometry.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3))\n geometry.computeVertexNormals()\n return geometry\n}\n\n/**\n * A splinter of wood in the unit box, long along x: a ragged broken end, a body whose corners stray in and out from section to section (the torn fibres\n * along its edges), bending a little, and a point at the other end that is off its axis. About 60 triangles, shared by every splinter of the variant.\n */\nexport function buildSliverGeometry(THREE: typeof THREE_NS, seed: number): THREE_NS.BufferGeometry {\n const rnd = createRng(7000 + seed)\n const rings: number[][][] = []\n const bendY = (rnd() - 0.5) * 0.3\n const bendZ = (rnd() - 0.5) * 0.3\n for (let i = 0; i < SLIVER_STATIONS - 1; i++) {\n const t = i / (SLIVER_STATIONS - 1)\n const x = -0.5 + t + (i > 0 ? (rnd() - 0.5) * 0.08 : 0)\n const width = sliverWidth(t)\n const lift = Math.sin(t * Math.PI)\n rings.push(SLIVER_SECTION.map(([y, z]) => {\n const fray = 1 - SLIVER_FRAY + SLIVER_FRAY * 1.4 * rnd()\n return [x, Math.max(-0.5, Math.min(0.5, y * width * fray + bendY * lift)), Math.max(-0.5, Math.min(0.5, z * width * fray + bendZ * lift))]\n }))\n }\n const tip = [0.5, (rnd() - 0.5) * 0.5, (rnd() - 0.5) * 0.3]\n // the broken end is torn, not cut: its centre stands out or sinks in\n const torn = [-0.5 + rnd() * 0.12, (rnd() - 0.5) * 0.2, (rnd() - 0.5) * 0.2]\n const sides = SLIVER_SECTION.length\n const positions: number[] = []\n for (let k = 0; k < sides; k++) {\n const next = (k + 1) % sides\n pushTriangle(positions, torn, rings[0][next], rings[0][k])\n for (let i = 0; i < rings.length - 1; i++) {\n const a = rings[i][k], b = rings[i][next], c = rings[i + 1][next], d = rings[i + 1][k]\n pushTriangle(positions, a, b, c)\n pushTriangle(positions, a, c, d)\n }\n const last = rings[rings.length - 1]\n pushTriangle(positions, last[k], last[next], tip)\n }\n return faceted(THREE, positions)\n}\n\n/**\n * A crumbly lump of pressed fibre (MDF) in the unit box: an icosahedron whose corners are pushed in and out by where they are (so the faces stay\n * closed), squashed to fill the box. 20 triangles.\n */\nexport function buildLumpGeometry(THREE: typeof THREE_NS, seed: number): THREE_NS.BufferGeometry {\n const rnd = createRng(8000 + seed)\n const base = new THREE.IcosahedronGeometry(0.5, 0)\n const source = base.getAttribute('position')\n const pushOf = new Map<string, number>()\n const positions: number[] = []\n for (let i = 0; i < source.count; i++) {\n const x = source.getX(i), y = source.getY(i), z = source.getZ(i)\n const key = `${x.toFixed(3)},${y.toFixed(3)},${z.toFixed(3)}`\n let push = pushOf.get(key)\n if (push === undefined) {\n push = 0.6 + 0.55 * rnd()\n pushOf.set(key, push)\n }\n positions.push(x * push, y * push, z * push)\n }\n base.dispose()\n const extent = [0, 0, 0]\n for (let i = 0; i < positions.length; i++) extent[i % 3] = Math.max(extent[i % 3], Math.abs(positions[i]))\n for (let i = 0; i < positions.length; i++) positions[i] *= 0.5 / Math.max(extent[i % 3], 1e-3)\n return faceted(THREE, positions)\n}\n\n/** Points along each long edge of a peeled sheet of veneer. */\nconst VENEER_EDGE = 11\n\n/**\n * A sheet of veneer peeled off plywood in the unit box (thin along z): long edges torn along the grain in fine teeth (now and then a deeper notch) and\n * the short ends broken across with a sliver standing out, extruded to its thickness.\n */\nexport function buildVeneerGeometry(THREE: typeof THREE_NS, seed: number): THREE_NS.BufferGeometry {\n const rnd = createRng(9000 + seed)\n const shape = new THREE.Shape()\n const outline: Array<[number, number]> = []\n // the long edges tear along the grain in fine teeth; each short end breaks across with one long sliver of veneer standing out\n const edge = (y: number, inward: number): number => y - inward * (rnd() * 0.16 + (rnd() < 0.15 ? 0.12 : 0))\n for (let i = 0; i <= VENEER_EDGE; i++) outline.push([-0.5 + i / VENEER_EDGE, edge(0.5, 1)])\n outline.push([0.5 - rnd() * 0.12, 0.2 * rnd()], [0.5, -0.1 + 0.2 * rnd()], [0.5 - rnd() * 0.12, -0.25 * rnd()])\n for (let i = VENEER_EDGE; i >= 0; i--) outline.push([-0.5 + i / VENEER_EDGE, edge(-0.5, -1)])\n outline.push([-0.5 + rnd() * 0.12, -0.2 * rnd()], [-0.5, 0.1 * rnd()], [-0.5 + rnd() * 0.12, 0.25 * rnd()])\n shape.moveTo(outline[0][0], outline[0][1])\n for (let i = 1; i < outline.length; i++) shape.lineTo(outline[i][0], outline[i][1])\n shape.closePath()\n const geometry = new THREE.ExtrudeGeometry(shape, { depth: 1, bevelEnabled: false })\n geometry.translate(0, 0, -0.5)\n return geometry\n}\n\n/** Share of a broken board's length its torn end takes, and how many strands of fibre (at least, at most) the end splits into across its width. */\nconst TORN_END = 0.24\nconst TORN_STRANDS: readonly [number, number] = [4, 7]\n\n/** Pushes the two triangles of the quad a-b-c-d, wound so that it faces where (b - a) x (c - b) points. */\nconst pushQuad = (out: number[], quad: ReadonlyArray<readonly number[]>): void => {\n pushTriangle(out, quad[0], quad[1], quad[2])\n pushTriangle(out, quad[0], quad[2], quad[3])\n}\n\n/** Uneven cuts of [-0.5, 0.5] into `count` widths, each between a third and twice the mean. */\nconst unevenCuts = (count: number, rnd: () => number): number[] => {\n const shares = Array.from({ length: count }, () => 0.35 + 1.65 * rnd())\n const total = shares.reduce((sum, share) => sum + share, 0)\n const cuts = [-0.5]\n for (const share of shares) cuts.push(cuts[cuts.length - 1] + share / total)\n cuts[cuts.length - 1] = 0.5\n return cuts\n}\n\n/**\n * The stub of a wooden board broken across, in the unit box, long along x: the sound part of the board, and at its +x end the break, torn into strands\n * of fibre of uneven widths and lengths that bend a little and fray before they come to points, not a clean saw cut. 58 to 94 triangles.\n */\nexport function buildBrokenBoardGeometry(THREE: typeof THREE_NS, seed: number): THREE_NS.BufferGeometry {\n const rnd = createRng(10000 + seed)\n const end = 0.5 - TORN_END\n const positions: number[] = []\n const lo = -0.5, hi = 0.5\n // the sound part of the board: a box from the far end to where the break starts (its face at the break is closed by the strands)\n pushQuad(positions, [[lo, lo, hi], [end, lo, hi], [end, hi, hi], [lo, hi, hi]])\n pushQuad(positions, [[lo, hi, lo], [end, hi, lo], [end, lo, lo], [lo, lo, lo]])\n pushQuad(positions, [[lo, hi, hi], [end, hi, hi], [end, hi, lo], [lo, hi, lo]])\n pushQuad(positions, [[lo, lo, lo], [end, lo, lo], [end, lo, hi], [lo, lo, hi]])\n pushQuad(positions, [[lo, lo, lo], [lo, lo, hi], [lo, hi, hi], [lo, hi, lo]])\n const count = TORN_STRANDS[0] + Math.floor(rnd() * (TORN_STRANDS[1] - TORN_STRANDS[0] + 1))\n const cuts = unevenCuts(count, rnd)\n for (let k = 0; k < count; k++) {\n const y0 = cuts[k], y1 = cuts[k + 1]\n const length = TORN_END * (0.15 + 0.85 * rnd())\n // halfway out the strand has narrowed and strays a little sideways and up or down; then it comes to a point off its middle\n const midX = end + length * (0.35 + 0.3 * rnd())\n const narrow = 0.55 + 0.35 * rnd()\n const shiftY = (rnd() - 0.5) * (y1 - y0) * 0.6\n const shiftZ = (rnd() - 0.5) * 0.5\n const cy = (y0 + y1) / 2 + shiftY, hy = ((y1 - y0) / 2) * narrow, hz = 0.5 * (0.4 + 0.5 * rnd())\n const base = [[end, y0, lo], [end, y1, lo], [end, y1, hi], [end, y0, hi]]\n const clampZ = (z: number): number => Math.max(lo, Math.min(hi, z))\n const mid = [[midX, cy - hy, clampZ(shiftZ - hz)], [midX, cy + hy, clampZ(shiftZ - hz)], [midX, cy + hy, clampZ(shiftZ + hz)], [midX, cy - hy, clampZ(shiftZ + hz)]]\n const tip = [end + length, y0 + (y1 - y0) * rnd(), clampZ(shiftZ + (rnd() - 0.5) * 0.4)]\n for (let i = 0; i < 4; i++) {\n const next = (i + 1) % 4\n pushQuad(positions, [base[i], base[next], mid[next], mid[i]])\n pushTriangle(positions, mid[i], mid[next], tip)\n }\n }\n return faceted(THREE, positions)\n}\n\n/**\n * A broken piece of brick, block or concrete in the unit box: a box whose corners are knocked off (each pulled in along its own axes) and whose edges are\n * nicked, so a heap of them reads as broken masonry, not as cut blocks. The faces of the box stay nearly flat (the faces of the brick); 48 triangles.\n */\nexport function buildRubbleGeometry(THREE: typeof THREE_NS, seed: number): THREE_NS.BufferGeometry {\n const rnd = createRng(9000 + seed)\n const base = new THREE.BoxGeometry(1, 1, 1, 2, 2, 2).toNonIndexed()\n const source = base.getAttribute('position')\n const moved = new Map<string, number[]>()\n const positions: number[] = []\n for (let i = 0; i < source.count; i++) {\n const p = [source.getX(i), source.getY(i), source.getZ(i)]\n const key = p.map((x) => x.toFixed(3)).join(',')\n let out = moved.get(key)\n if (!out) {\n // 3 coordinates on the box's surface: a corner; 2: the middle of an edge; 1: the middle of a face, which stays\n const outer = p.filter((x) => Math.abs(x) > 0.49).length\n const bite = outer === 3 ? 0.08 + 0.3 * rnd() : outer === 2 ? 0.1 * rnd() : 0\n out = p.map((x) => (Math.abs(x) > 0.49 ? x - Math.sign(x) * bite * (0.4 + 0.6 * rnd()) : x))\n moved.set(key, out)\n }\n positions.push(out[0]!, out[1]!, out[2]!)\n }\n base.dispose()\n return faceted(THREE, positions)\n}\n","import type * as THREE_NS from 'three'\nimport { lerp } from './math'\n\ninterface Spot {\n mesh: THREE_NS.Mesh\n kind: 'puddle' | 'ash'\n home: string\n x: number\n z: number\n radius: number\n target: number\n}\n\nconst MAX_RADIUS = 1.2\n\n/** Flat discs on the ground: puddles of melted material and piles of ash. Nearby ones merge; the oldest go when the cap is reached. */\nexport class GroundSpots {\n private readonly spots: Spot[] = []\n private readonly geometry: THREE_NS.CircleGeometry\n private readonly materials = new Map<string, THREE_NS.MeshBasicMaterial>()\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly scene: THREE_NS.Scene,\n private readonly groundAt: (x: number, z: number) => number,\n private readonly cap: number,\n ) {\n this.geometry = new THREE.CircleGeometry(1, 20)\n this.geometry.rotateX(-Math.PI / 2)\n }\n\n get count(): number {\n return this.spots.length\n }\n\n private material(kind: 'puddle' | 'ash', color: number): THREE_NS.MeshBasicMaterial {\n const key = `${kind}:${color}`\n let m = this.materials.get(key)\n if (!m) {\n m = new this.THREE.MeshBasicMaterial({\n color,\n transparent: true,\n opacity: kind === 'puddle' ? 0.88 : 0.95,\n depthWrite: false,\n polygonOffset: true,\n polygonOffsetFactor: -2,\n polygonOffsetUnits: -2,\n })\n this.materials.set(key, m)\n }\n return m\n }\n\n /** Add (or grow) a spot at (x, z). `radius` is the radius this addition contributes. */\n add(kind: 'puddle' | 'ash', x: number, z: number, radius: number, color: number, home: string): void {\n for (const s of this.spots) {\n if (s.kind !== kind) continue\n const d = Math.hypot(s.x - x, s.z - z)\n if (d < Math.max(s.target, radius) * 0.9) {\n s.target = Math.min(MAX_RADIUS, Math.sqrt(s.target * s.target + radius * radius * 0.5))\n return\n }\n }\n while (this.spots.length >= this.cap) this.remove(this.spots[0])\n const mesh = new this.THREE.Mesh(this.geometry, this.material(kind, color))\n const y = this.groundAt(x, z) + 0.004 + (this.spots.length % 8) * 0.0004\n mesh.position.set(x, y, z)\n mesh.scale.setScalar(0.001)\n mesh.renderOrder = 1\n mesh.userData.destructionDebris = true\n this.scene.add(mesh)\n this.spots.push({ mesh, kind, home, x, z, radius: 0.001, target: Math.min(MAX_RADIUS, radius) })\n }\n\n private remove(s: Spot): void {\n const i = this.spots.indexOf(s)\n if (i >= 0) this.spots.splice(i, 1)\n this.scene.remove(s.mesh)\n }\n\n update(dt: number): void {\n const k = Math.min(1, dt * 3)\n for (const s of this.spots) {\n if (Math.abs(s.radius - s.target) < 1e-4) continue\n s.radius = lerp(s.radius, s.target, k)\n s.mesh.scale.setScalar(s.radius)\n }\n }\n\n /** Remove the spots made for one object (after its `restore`). */\n removeHome(home: string): void {\n for (const s of [...this.spots]) if (s.home === home) this.remove(s)\n }\n\n clear(): void {\n for (const s of [...this.spots]) this.remove(s)\n }\n\n dispose(): void {\n this.clear()\n this.geometry.dispose()\n for (const m of this.materials.values()) m.dispose()\n this.materials.clear()\n }\n}\n","import type { Vec3 } from '@adatechnology/game-destruction'\n\n/**\n * The shape two pieces meet each other by: a round piece is a capsule round its axis (a can lying on its side, a bottle, a ball when its segment is a point), anything else\n * the boxes of its parts (a table's top and legs, as drawn) or of itself, each a centre, rotation columns (`Matrix4.elements`) and half extents.\n */\nexport type ContactShape =\n | { readonly kind: 'capsule'; readonly from: Vec3; readonly to: Vec3; readonly radius: number }\n | { readonly kind: 'boxes'; readonly boxes: ReadonlyArray<{ readonly c: Vec3; readonly e: ArrayLike<number>; readonly half: Vec3 }> }\n\n/** Where two shapes meet: the point between them, the unit normal from the second to the first, and how deep they overlap (m). */\nexport interface ShapeContact {\n readonly point: Vec3\n readonly normal: Vec3\n readonly depth: number\n}\n\n/** Rounds of the closest-point search between a segment and a box (each a projection onto one, then the other: convex, so it closes in). */\nconst SEGMENT_BOX_ROUNDS = 4\n/** Two segments this near parallel (sin^2 of the angle between them) are side by side. */\nconst PARALLEL = 1e-4\n\nconst sub = (a: Vec3, b: Vec3): Vec3 => [a[0] - b[0], a[1] - b[1], a[2] - b[2]]\nconst dot = (a: Vec3, b: Vec3): number => a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\nconst along = (a: Vec3, d: Vec3, t: number): Vec3 => [a[0] + d[0] * t, a[1] + d[1] * t, a[2] + d[2] * t]\nconst clamp01 = (t: number): number => (t < 0 ? 0 : t > 1 ? 1 : t)\n\n/** The point of the segment `from`-`to` nearest to `p`. */\nconst nearestOnSegment = (from: Vec3, to: Vec3, p: Vec3): Vec3 => {\n const d = sub(to, from)\n const len2 = dot(d, d)\n return len2 < 1e-12 ? from : along(from, d, clamp01(dot(sub(p, from), d) / len2))\n}\n\n/** The nearest points of two segments (Ericson, Real-Time Collision Detection 5.1.9). */\nconst nearestOfSegments = (p1: Vec3, q1: Vec3, p2: Vec3, q2: Vec3): [Vec3, Vec3] => {\n const d1 = sub(q1, p1)\n const d2 = sub(q2, p2)\n const r = sub(p1, p2)\n const a = dot(d1, d1)\n const e = dot(d2, d2)\n const f = dot(d2, r)\n let s = 0\n let t = 0\n if (a < 1e-12 && e < 1e-12) return [p1, p2]\n if (a < 1e-12) t = clamp01(f / e)\n else {\n const c = dot(d1, r)\n if (e < 1e-12) s = clamp01(-c / a)\n else {\n const b = dot(d1, d2)\n const denom = a * e - b * b\n if (denom > PARALLEL * a * e) s = clamp01((b * f - c * e) / denom)\n else {\n // side by side (two cans lying parallel): they touch along the length they share, met at its middle, so the blow turns neither\n const s0 = clamp01(-c / a)\n const s1 = clamp01((b - c) / a)\n s = (s0 + s1) / 2\n }\n t = (b * s + f) / e\n if (t < 0) {\n t = 0\n s = clamp01(-c / a)\n } else if (t > 1) {\n t = 1\n s = clamp01((b - c) / a)\n }\n }\n }\n return [along(p1, d1, s), along(p2, d2, t)]\n}\n\n/** `p` in the frame of the box (its axes, from its centre). */\nconst toBox = (box: { c: Vec3; e: ArrayLike<number> }, p: Vec3): Vec3 => {\n const d = sub(p, box.c)\n const e = box.e\n return [e[0] * d[0] + e[1] * d[1] + e[2] * d[2], e[4] * d[0] + e[5] * d[1] + e[6] * d[2], e[8] * d[0] + e[9] * d[1] + e[10] * d[2]]\n}\n\n/** A point in the frame of the box back in the world. */\nconst fromBox = (box: { c: Vec3; e: ArrayLike<number> }, l: Vec3): Vec3 => {\n const e = box.e\n return [box.c[0] + e[0] * l[0] + e[4] * l[1] + e[8] * l[2], box.c[1] + e[1] * l[0] + e[5] * l[1] + e[9] * l[2], box.c[2] + e[2] * l[0] + e[6] * l[1] + e[10] * l[2]]\n}\n\n/** A capsule against one box: the nearest point of its segment to the box, and how far inside the capsule's radius the box comes. */\nconst capsuleBox = (from: Vec3, to: Vec3, radius: number, box: { c: Vec3; e: ArrayLike<number>; half: Vec3 }): ShapeContact | null => {\n let p = nearestOnSegment(from, to, box.c)\n let l = toBox(box, p)\n for (let round = 0; round < SEGMENT_BOX_ROUNDS; round++) {\n const clamped: Vec3 = [Math.max(-box.half[0], Math.min(box.half[0], l[0])), Math.max(-box.half[1], Math.min(box.half[1], l[1])), Math.max(-box.half[2], Math.min(box.half[2], l[2]))]\n p = nearestOnSegment(from, to, fromBox(box, clamped))\n l = toBox(box, p)\n }\n const q: Vec3 = [Math.max(-box.half[0], Math.min(box.half[0], l[0])), Math.max(-box.half[1], Math.min(box.half[1], l[1])), Math.max(-box.half[2], Math.min(box.half[2], l[2]))]\n const gap: Vec3 = [l[0] - q[0], l[1] - q[1], l[2] - q[2]]\n const distance = Math.hypot(gap[0], gap[1], gap[2])\n if (distance >= radius) return null\n const e = box.e\n if (distance > 1e-6) {\n const n: Vec3 = [gap[0] / distance, gap[1] / distance, gap[2] / distance]\n const normal: Vec3 = [e[0] * n[0] + e[4] * n[1] + e[8] * n[2], e[1] * n[0] + e[5] * n[1] + e[9] * n[2], e[2] * n[0] + e[6] * n[1] + e[10] * n[2]]\n return { point: fromBox(box, q), normal, depth: radius - distance }\n }\n // the segment runs inside the box: out through the nearest face\n let axis = 0\n for (let k = 1; k < 3; k++) if (box.half[k] - Math.abs(l[k]) < box.half[axis] - Math.abs(l[axis])) axis = k\n const sign = l[axis] < 0 ? -1 : 1\n return { point: p, normal: [sign * e[axis * 4], sign * e[axis * 4 + 1], sign * e[axis * 4 + 2]], depth: radius + box.half[axis] - Math.abs(l[axis]) }\n}\n\n/** Where shape `a` meets shape `b` (the normal from `b` to `a`), the deepest of their boxes; null when they do not touch. Two box shapes are not answered here. */\nexport function shapeContact(a: ContactShape, b: ContactShape): ShapeContact | null {\n if (a.kind === 'capsule' && b.kind === 'capsule') {\n const [pa, pb] = nearestOfSegments(a.from, a.to, b.from, b.to)\n const d = sub(pa, pb)\n const distance = Math.hypot(d[0], d[1], d[2])\n const reach = a.radius + b.radius\n if (distance >= reach) return null\n // side by side on one line (a can rolled straight at the end of another): apart sideways on the ground\n const normal: Vec3 = distance > 1e-6 ? [d[0] / distance, d[1] / distance, d[2] / distance] : [1, 0, 0]\n return { point: along(pb, normal, b.radius - (reach - distance) / 2), normal, depth: reach - distance }\n }\n if (a.kind === 'capsule' && b.kind === 'boxes') {\n let best: ShapeContact | null = null\n for (const box of b.boxes) {\n const hit = capsuleBox(a.from, a.to, a.radius, box)\n if (hit && (!best || hit.depth > best.depth)) best = hit\n }\n return best\n }\n if (a.kind === 'boxes' && b.kind === 'capsule') {\n const hit = shapeContact(b, a)\n return hit && { point: hit.point, normal: [-hit.normal[0], -hit.normal[1], -hit.normal[2]], depth: hit.depth }\n }\n return null\n}\n","import type * as THREE_NS from 'three'\nimport type { Vec3 } from '@adatechnology/game-destruction'\nimport type { PieceBody, PieceFriction } from './internal'\nimport { clamp } from './math'\nimport { shapeContact } from './piece-contacts'\nimport type { ContactShape } from './piece-contacts'\n\nexport interface PieceSystemOptions {\n groundAt: (x: number, z: number) => number\n /**\n * The highest top of what does not move (furniture, scenery) under `(x, z)` that a corner at height `y` can land on (at most `step` above it),\n * `-Infinity` when none. The ground and the other pieces are added by the system.\n */\n staticTopAt?: (x: number, z: number, y: number, step: number) => number\n gravity: number\n /** A piece hit the ground faster than 3 m/s (throttled per piece). */\n onHardLanding: (piece: PieceBody, point: Vec3, speed: number) => void\n /** Notified when a piece is about to be removed. */\n scene: THREE_NS.Scene\n /**\n * What a piece moving from `from` to `to` (its centre, world) runs into on the way: a wall, a car, a cupboard (`distance` along the way, the `normal` of what it met).\n * Without it a piece only meets the ground, the tops of fixed things and the other pieces.\n */\n sweep?: (piece: PieceBody, from: Vec3, to: Vec3) => PieceSweepHit | null\n /** A piece ran into something (`sweep`) faster than `SLAM_MIN_SPEED` m/s into it (throttled per piece): for the blow on both and the sound. */\n onSlam?: (piece: PieceBody, hit: PieceSweepHit, speed: number) => void\n /** Two pieces knocked into each other faster than `SLAM_MIN_SPEED` m/s (throttled per pair): for the sound. */\n onKnock?: (a: PieceBody, b: PieceBody, point: Vec3, speed: number) => void\n}\n\n/** What a moving piece ran into (`PieceSystemOptions.sweep`). */\nexport interface PieceSweepHit {\n readonly object: string\n readonly part: string\n /** Metres along the way from the centre where the piece meets it. */\n readonly distance: number\n readonly point: Vec3\n readonly normal: Vec3\n /** Coefficient of restitution of what it met (by its material); mixed with the piece's (geometric mean). */\n readonly restitution?: number\n}\n\n/** Slower than this (m/s) into a wall a piece only stops against it: no blow, no sound. */\nexport const SLAM_MIN_SPEED = 2\n/** Share of the speed into a wall a piece keeps, bouncing back, when neither surface says otherwise (`PieceBody.restitution`, `PieceSweepHit.restitution`). */\nconst SLAM_BOUNCE = 0.2\n/** Normals steeper than this (y) are a floor or a top: the support of the pieces answers those, not the sweep. */\nconst SLAM_FLOOR_NORMAL = 0.7\n\nconst SUB_DT = 1 / 120\n/** Coulomb friction of a piece when no material says otherwise: what holds it still (static) and what drags it while it slides (dynamic). */\nconst MU_STATIC = 0.7\nconst MU_DYNAMIC = 0.6\n/** Sliding faster than this (m/s) along the surface, a contact drags with the dynamic friction; slower, it holds with the static one. */\nconst SLIP_SPEED = 0.02\n/** Rolling resistance coefficient of the ground and of a surface that does not say (`PieceFriction.rolling`): a can or a bottle on a hard floor (0.01-0.02). */\nconst ROLLING_RESISTANCE = 0.015\n/** A round piece whose axis leans more than 45 degrees from upright lies on its side (the share of the world's down across its axis). */\nconst ROUND_LYING = Math.SQRT1_2\nconst SLEEP_AFTER = 0.5\n/**\n * A piece on the ground that neither moves farther than `CALM_DRIFT` (m) nor turns more than `CALM_TURN` (rad) in `CALM_SLEEP_AFTER` seconds sleeps, however\n * its speed flickers: a book propped on another, or trembling where its corners rest on two pieces, stays in place; a fall or a slide leaves the window sooner.\n */\nconst CALM_DRIFT = 0.01\nconst CALM_TURN = 0.05\nconst CALM_SLEEP_AFTER = 1.5\nconst HARD_LANDING = 3\n/** Contact tolerance in metres: corners this close to the ground count as touching, which keeps the contact set (and a resting box) stable. */\nconst SLOP = 0.002\n/** A resting support narrower than this fraction of the centre-of-mass height is a balancing act, not a rest: the piece topples. */\nconst NARROW = 0.3\n/** Angular acceleration (rad/s^2 per metre of height) that pushes a balancing piece off its edge, toward the side its centre of mass leans to. */\nconst TOPPLE = 3\n/** Angular acceleration (rad/s^2) of a piece that falls over (`tip`), beyond what the box of its bounds would allow, and the height of the centre of mass (m) at which it lies. */\nconst TIP_ACCELERATION = 30\nconst TIP_LYING = 0.25\nconst TIP_SECONDS = 3\n/** How far (m) above a corner a top may be and still catch it (on top of what the corner falls in one sub-step): higher is beside it, not under it. */\nconst STEP = 0.03\n/** Slots of the warm start: the 8 corners and the points along the 12 edges. */\nconst WARM_SLOTS = 8 + 12 * 7\n/** Passes of the contact solver over the points that touch the ground, each substep. */\nconst SOLVER_PASSES = 10\n/** Restitution of a piece against the side of a step of the ground. */\nconst SIDE_BOUNCE = 0.1\n/**\n * Points along each edge of the box, between its corners (fractions of the half edge), that also touch the ground when the support under the corners is not level\n * (the piece is over a step): the edge of a table under a box's bottom is a support between its corners. On level ground the corners are enough.\n */\nconst EDGE_POINTS = [-0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75]\n/** Sleeping pieces whose support is looked at again each update, in turn: what held one up may have broken, fallen over or been carried off. */\nconst SUPPORT_CHECKS = 16\n/** A sleeping piece none of whose lowest points has a support within this many metres under it wakes and falls. */\nconst SUPPORT_GAP = 0.02\n/** A piece moving faster than this (m/s) or turning faster than this (rad/s) wakes what lies asleep on it. */\nconst WAKE_ABOVE_SPEED = 0.05\nconst WAKE_ABOVE_SPIN = 0.1\n/** Side (m) of the cells of the grid the surfaces are found by (`surfaceGrid`). */\nconst SURFACE_CELL = 0.5\n/** Most cells across one surface goes into; a wider one is looked at for every point (`wideSurfaces`). */\nconst SURFACE_CELLS_ACROSS = 24\nconst cellKey = (ix: number, iz: number): number => (ix + 32768) * 65536 + (iz + 32768)\n/** Most steps an update is split into while round pieces roll fast (`collisionSteps`). */\nconst MAX_COLLISION_STEPS = 8\n/** Radius (m) a round piece is taken to have at least when the update is split for it (`collisionSteps`): a degenerate one of nothing does not split it without end. */\nconst MIN_ROUND_RADIUS = 0.005\n/** Two pieces closing slower than this (m/s) only stop against each other; faster, they bounce by their restitution. */\nconst BOUNCE_MIN_SPEED = 0.1\n/** A contact normal at least this level (its share along the ground) puts two pieces apart along the ground only. */\nconst KNOCK_FLAT = 0.5\n\n/** Box of a piece in the world: centre, rotation columns (`Matrix4.elements`) and half extents. */\n/** Which pieces a step moves and which pairs it meets (`PieceSystem.update` splits only what closes in on a round piece). */\ninterface StepFilter {\n readonly moves: (b: PieceBody) => boolean\n readonly meets: (a: PieceBody, b: PieceBody) => boolean\n}\n\ninterface Solid {\n body: PieceBody\n c: Vec3\n e: number[]\n half: Vec3\n /** Radius of the box around its centre: a point farther than it on the ground plane misses it. */\n r: number\n}\n\n/** The axis of the box whose face the last `boxTopAt` line left through (its top there): the face a point on that spot stands on. */\nlet topFace = 1\n\n/** Height where the vertical line through `(x, z)` leaves the top of a box, or -Infinity when it misses the box. */\nconst boxTopAt = (s: Solid, x: number, z: number): number => {\n const e = s.e\n const dx = x - s.c[0], dz = z - s.c[2]\n let t0 = -Infinity, t1 = Infinity\n for (let k = 0; k < 3; k++) {\n // the line is c + (dx, t, dz) with t the height over the centre; along axis k: p + t d\n const p = e[k * 4] * dx + e[k * 4 + 2] * dz\n const d = e[k * 4 + 1]\n const h = s.half[k]\n if (Math.abs(d) < 1e-9) {\n if (Math.abs(p) > h) return -Infinity\n continue\n }\n let a = (-h - p) / d, b = (h - p) / d\n if (a > b) [a, b] = [b, a]\n t0 = Math.max(t0, a)\n if (b < t1) {\n t1 = b\n topFace = k\n }\n if (t0 > t1) return -Infinity\n }\n return s.c[1] + t1\n}\n\nconst UP: Vec3 = [0, 1, 0]\n\n/** The outward normal of face `axis` of a box on its upper side: the surface of a tilted table top under a point. */\nconst faceNormal = (s: Solid, axis: number): Vec3 => {\n const e = s.e\n const sign = e[axis * 4 + 1] < 0 ? -1 : 1\n return [sign * e[axis * 4], sign * e[axis * 4 + 1], sign * e[axis * 4 + 2]]\n}\n\n/** The friction of two surfaces against each other: the geometric mean of each one's coefficients. */\nconst pairFriction = (a: PieceFriction | undefined, b: PieceFriction | null): PieceFriction => ({\n static: Math.sqrt((a?.static ?? MU_STATIC) * (b?.static ?? MU_STATIC)),\n dynamic: Math.sqrt((a?.dynamic ?? MU_DYNAMIC) * (b?.dynamic ?? MU_DYNAMIC)),\n // the softer of the two sets how much a round thing rolling on the other sinks in and is held back\n rolling: Math.max(a?.rolling ?? 0, b?.rolling ?? ROLLING_RESISTANCE),\n})\n\n/** The coefficient of restitution of two surfaces against each other: the geometric mean of each one's. */\nconst pairRestitution = (a: number | undefined, b: number | undefined): number => Math.sqrt((a ?? SLAM_BOUNCE) * (b ?? SLAM_BOUNCE))\n\n/**\n * Light rigid-body physics for loose pieces: gravity, the 8 corners of the local box against the ground with an impulse (restitution, friction,\n * angular response), damping, sleeping, and a gentle horizontal separation between pieces side by side. The ground a corner lands on is the\n * highest of the terrain, the top of any other piece under it and what the host reports as fixed (`staticTopAt`): a falling shelf lands on the books\n * below it, a tipping panel on the chair in front of it. Over a step (a table's edge) points along the box's edges touch too, so the edge holds the box between\n * its corners, and the side of a step of the ground is a wall: a corner that comes at it from the side stops there. The contacts are solved together, warm started.\n * Not a general solver: what lies under a corner holds it, what stands beside it does not.\n */\nexport class PieceSystem {\n readonly list: PieceBody[] = []\n private time = 0\n private readonly p: THREE_NS.Vector3\n private readonly q: THREE_NS.Quaternion\n private readonly dq: THREE_NS.Quaternion\n private readonly nextQ: THREE_NS.Quaternion\n private readonly m: THREE_NS.Matrix4\n private readonly ax: THREE_NS.Vector3\n private solids: Solid[] = []\n /** The boxes other pieces land on: a piece's own parts when it has them (`partBoxes`), else its box. */\n private surfaces: Solid[] = []\n /** The surfaces by the cells of a grid on the ground (`SURFACE_CELL`) their bounding circle covers: what is under a point is looked for in its cell only. */\n private readonly surfaceGrid = new Map<number, Solid[]>()\n /** The surfaces wider than `SURFACE_CELLS_ACROSS` cells (a slab come down whole): looked at for every point. */\n private readonly wideSurfaces: Solid[] = []\n /** Each piece's box of the step (`solids`), by its body. */\n private readonly solidOf = new Map<PieceBody, Solid>()\n /** Each piece's surfaces of the step (its parts' boxes, or its box), by its body. */\n private readonly surfacesOf = new Map<PieceBody, Solid[]>()\n private supportTurn = 0\n /** The surface normal and the friction of what the last `supportAt` found under the point (the ground and fixed tops are level: up, and no piece). */\n private supportNormal: Vec3 = UP\n private supportFriction: PieceFriction | null = null\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly o: PieceSystemOptions,\n ) {\n this.p = new THREE.Vector3()\n this.q = new THREE.Quaternion()\n this.dq = new THREE.Quaternion()\n this.nextQ = new THREE.Quaternion()\n this.m = new THREE.Matrix4()\n this.ax = new THREE.Vector3()\n }\n\n get(objectId: string): PieceBody | null {\n return this.list.find((b) => b.objectId === objectId) ?? null\n }\n\n /** Sets a piece falling over, about the world axes x and z (a unit axis): its feet are thinner than the box that stands for it, so the box alone would hold it up. */\n tip(body: PieceBody, x: number, z: number): void {\n body.tipping = { x, z, seconds: TIP_SECONDS }\n body.sleeping = false\n }\n\n create(objectId: string, root: THREE_NS.Object3D, halfExtents: Vec3, localCenter: THREE_NS.Vector3, mass: number, velocity?: Vec3, angular?: Vec3): PieceBody {\n const existing = this.get(objectId)\n if (existing) {\n existing.root = root\n existing.halfExtents = halfExtents\n existing.mass = mass\n this.setCenter(existing, localCenter)\n if (velocity) existing.velocity = [...velocity]\n existing.sleeping = false\n return existing\n }\n const body: PieceBody = {\n objectId,\n tipping: null,\n root,\n velocity: velocity ? [...velocity] : [0, 0, 0],\n angularVelocity: angular ? [...angular] : [0, 0, 0],\n halfExtents: [Math.max(0.01, halfExtents[0]), Math.max(0.01, halfExtents[1]), Math.max(0.01, halfExtents[2])],\n mass: Math.max(0.05, mass),\n sleeping: false,\n held: false,\n localCenter: [localCenter.x, localCenter.y, localCenter.z],\n centerV: localCenter.clone(),\n still: 0,\n calmAt: null,\n calm: 0,\n lastHit: -1,\n onGround: false,\n }\n this.list.push(body)\n return body\n }\n\n /** Move the centre of mass (after a part broke off). */\n setCenter(b: PieceBody, c: THREE_NS.Vector3): void {\n b.centerV.copy(c)\n b.localCenter = [c.x, c.y, c.z]\n }\n\n remove(objectId: string): void {\n const i = this.list.findIndex((b) => b.objectId === objectId)\n if (i < 0) return\n // the boxes of the step forget it too: nothing keeps a removed piece's tree alive\n const [gone] = this.list.splice(i, 1)\n if (gone) this.forgetSolids(gone)\n }\n\n clear(): void {\n this.list.length = 0\n this.solids = []\n this.surfaces = []\n this.solidOf.clear()\n this.surfacesOf.clear()\n this.surfaceGrid.clear()\n this.wideSurfaces.length = 0\n }\n\n /** Drops a piece from the boxes of the step (`solids`, `surfaces` and their grid). */\n private forgetSolids(body: PieceBody): void {\n this.solidOf.delete(body)\n this.surfacesOf.delete(body)\n this.solids = this.solids.filter((s) => s.body !== body)\n this.surfaces = this.surfaces.filter((s) => s.body !== body)\n for (const [key, cell] of this.surfaceGrid) {\n const kept = cell.filter((s) => s.body !== body)\n if (kept.length === 0) this.surfaceGrid.delete(key)\n else if (kept.length !== cell.length) this.surfaceGrid.set(key, kept)\n }\n const wide = this.wideSurfaces.filter((s) => s.body !== body)\n this.wideSurfaces.length = 0\n this.wideSurfaces.push(...wide)\n }\n\n /** `clear` and the clock back to 0. */\n reset(): void {\n this.clear()\n this.time = 0\n }\n\n /** World position of the centre of mass. */\n centerOf(b: PieceBody, out: THREE_NS.Vector3): THREE_NS.Vector3 {\n return out.copy(b.centerV).applyQuaternion(b.root.quaternion).add(b.root.position)\n }\n\n impulse(b: PieceBody, impulse: Vec3, point?: Vec3): void {\n const inv = 1 / b.mass\n b.velocity[0] += impulse[0] * inv\n b.velocity[1] += impulse[1] * inv\n b.velocity[2] += impulse[2] * inv\n if (point) {\n const c = this.centerOf(b, this.p)\n const rx = point[0] - c.x\n const ry = point[1] - c.y\n const rz = point[2] - c.z\n // torque = r x J, angular velocity change = I^-1 torque\n const tx = ry * impulse[2] - rz * impulse[1]\n const ty = rz * impulse[0] - rx * impulse[2]\n const tz = rx * impulse[1] - ry * impulse[0]\n const w = this.mulInvInertia(b, tx, ty, tz)\n b.angularVelocity[0] += w[0]\n b.angularVelocity[1] += w[1]\n b.angularVelocity[2] += w[2]\n }\n b.sleeping = false\n b.still = 0\n b.calmAt = null\n }\n\n /** I^-1 * (x, y, z) in world space for a box with the body's half extents and mass (needs `this.m` to hold the body's rotation). */\n private mulInvInertia(b: PieceBody, x: number, y: number, z: number): Vec3 {\n this.m.makeRotationFromQuaternion(b.root.quaternion)\n return this.mulInvInertiaWith(b, this.m.elements, x, y, z)\n }\n\n private mulInvInertiaWith(b: PieceBody, e: ArrayLike<number>, x: number, y: number, z: number): Vec3 {\n const [hx, hy, hz] = b.halfExtents\n const k = 3 / b.mass\n let ix = k / (hy * hy + hz * hz)\n let iy = k / (hx * hx + hz * hz)\n let iz = k / (hx * hx + hy * hy)\n const round = b.round\n if (round) {\n // about the axis it rolls on, a round piece has I = k m r^2: a full can is a solid cylinder (k 0.5), an empty one a thin shell (k 1)\n const about = 1 / (round.inertia * b.mass * round.radius * round.radius)\n if (round.kind === 'sphere') ix = iy = iz = about\n else if (round.axis === 0) ix = about\n else if (round.axis === 1) iy = about\n else iz = about\n }\n // local = R^T v (columns of R are the local axes in world space)\n const lx = (e[0] * x + e[1] * y + e[2] * z) * ix\n const ly = (e[4] * x + e[5] * y + e[6] * z) * iy\n const lz = (e[8] * x + e[9] * y + e[10] * z) * iz\n return [e[0] * lx + e[4] * ly + e[8] * lz, e[1] * lx + e[5] * ly + e[9] * lz, e[2] * lx + e[6] * ly + e[10] * lz]\n }\n\n /** The points of the box that touch the ground, in its own frame: the 8 corners, then (with `edges`) `EDGE_POINTS` along each of its 12 edges; or the piece's own `contacts`. */\n private samples(b: PieceBody, edges: boolean): Vec3[] {\n if (b.contacts) return b.contacts\n const [hx, hy, hz] = b.halfExtents\n const out: Vec3[] = []\n for (let i = 0; i < 8; i++) out.push([i & 1 ? hx : -hx, i & 2 ? hy : -hy, i & 4 ? hz : -hz])\n if (!edges) return out\n const h = [hx, hy, hz]\n for (let axis = 0; axis < 3; axis++) {\n const a1 = (axis + 1) % 3\n const a2 = (axis + 2) % 3\n for (let k = 0; k < 4; k++) {\n for (const f of EDGE_POINTS) {\n const p: Vec3 = [0, 0, 0]\n p[axis] = f * h[axis]\n p[a1] = k & 1 ? h[a1] : -h[a1]\n p[a2] = k & 2 ? h[a2] : -h[a2]\n out.push(p)\n }\n }\n }\n return out\n }\n\n /**\n * An impulse along the unit normal `n` at `r` (from the centre of mass, world) that stops the point closing in along `n` (with `bounce`); `e` holds the body's rotation.\n */\n private contactImpulse(b: PieceBody, e: ArrayLike<number>, r: Vec3, n: Vec3, bounce: number): void {\n const v = b.velocity\n const w = b.angularVelocity\n const vn = (v[0] + w[1] * r[2] - w[2] * r[1]) * n[0] + (v[1] + w[2] * r[0] - w[0] * r[2]) * n[1] + (v[2] + w[0] * r[1] - w[1] * r[0]) * n[2]\n if (vn >= 0) return\n // I^-1 (r x n), then (I^-1 (r x n) x r) . n\n const a = this.mulInvInertiaWith(b, e, r[1] * n[2] - r[2] * n[1], r[2] * n[0] - r[0] * n[2], r[0] * n[1] - r[1] * n[0])\n const k = (a[1] * r[2] - a[2] * r[1]) * n[0] + (a[2] * r[0] - a[0] * r[2]) * n[1] + (a[0] * r[1] - a[1] * r[0]) * n[2]\n const j = (-(1 + bounce) * vn) / (1 / b.mass + k)\n for (let i = 0; i < 3; i++) {\n v[i] += (j * n[i]) / b.mass\n w[i] += a[i] * j\n }\n }\n\n /** What lies inside the disc looks at the ground again: it was dug or heaped under it. */\n wakeRegion(x: number, z: number, radius: number): void {\n for (const b of this.list) {\n if (!b.sleeping || b.held || Math.hypot(b.root.position.x - x, b.root.position.z - z) > radius) continue\n b.sleeping = false\n b.still = 0\n b.calmAt = null\n }\n }\n\n update(dt: number): void {\n const { steps, near } = this.collisionSteps(dt)\n if (steps === 1) {\n this.time += dt\n this.step(dt)\n return\n }\n // only the round pieces and what closes in on them are split: the rest (a wall's bricks falling far from the can) take the update whole, so their sweep runs once\n const start = this.time\n this.time = start + dt\n const far = (b: PieceBody): boolean => !near.has(b)\n this.step(dt, { moves: far, meets: (a, b) => far(a) && far(b) })\n for (let i = 0; i < steps; i++) {\n this.time = start + (dt * (i + 1)) / steps\n this.step(dt / steps, { moves: (b) => near.has(b), meets: (a, b) => near.has(a) || near.has(b) })\n }\n }\n\n /**\n * Steps of an update: one, or more while a round piece and a piece it could meet within the update close in fast enough to pass through each other between two (closing at\n * their two speeds they cover at most the round one's radius per step: two cans at 3.6 m/s close 12 cm in a frame, a can is 7 cm across; a plank thrown at a can still counts).\n * A round piece with nothing in reach takes one step, so its sweep against the world (the costly part) runs once; `near` holds the pieces of the pairs that need more.\n */\n private collisionSteps(dt: number): { steps: number; near: Set<PieceBody> } {\n let need = 1\n const near = new Set<PieceBody>()\n const p = this.p\n const speedOf = (b: PieceBody): number => (b.held ? 0 : Math.hypot(b.velocity[0], b.velocity[1], b.velocity[2]))\n for (const b of this.list) {\n if (!b.round || b.held) continue\n // a radius of nothing passes through nothing: one step\n const radius = Math.max(MIN_ROUND_RADIUS, b.round.radius)\n const speed = b.sleeping ? 0 : speedOf(b)\n const c = this.centerOf(b, p)\n const cx = c.x, cy = c.y, cz = c.z\n const rb = Math.hypot(b.halfExtents[0], b.halfExtents[1], b.halfExtents[2])\n for (const o of this.list) {\n if (o === b || (b.sleeping && o.sleeping)) continue\n const closing = speed + (o.sleeping ? 0 : speedOf(o))\n if (closing * dt < radius * 0.5) continue\n const reach = closing * dt + rb + Math.hypot(o.halfExtents[0], o.halfExtents[1], o.halfExtents[2])\n const oc = this.centerOf(o, p)\n if (Math.abs(oc.x - cx) > reach || Math.abs(oc.y - cy) > reach || Math.abs(oc.z - cz) > reach) continue\n const pair = Math.ceil((closing * dt) / radius)\n if (pair < 2) continue\n need = Math.max(need, pair)\n near.add(b)\n near.add(o)\n }\n }\n return { steps: Math.max(1, Math.min(MAX_COLLISION_STEPS, need)), near }\n }\n\n /** A step of `dt`: the pieces `only.moves` takes move (all when absent) and the pairs `only.meets` takes meet, so each pair meets in one of the steps of an update. */\n private step(dt: number, only?: StepFilter): void {\n this.solids = this.list.map((body) => {\n const c = this.centerOf(body, new this.THREE.Vector3())\n const h = body.halfExtents\n return { body, c: [c.x, c.y, c.z] as Vec3, e: [...new this.THREE.Matrix4().makeRotationFromQuaternion(body.root.quaternion).elements], half: h, r: Math.hypot(h[0], h[1], h[2]) }\n })\n // what lands on a piece lands on its parts (a shelf's boards, a table's top), not on the box around them all\n this.surfaces = this.solids.flatMap((whole): Solid[] => {\n const parts = whole.body.partBoxes\n if (!parts) return [whole]\n const e = whole.e\n return parts.map(({ center, half }) => ({\n body: whole.body,\n c: [\n whole.c[0] + e[0] * center[0] + e[4] * center[1] + e[8] * center[2],\n whole.c[1] + e[1] * center[0] + e[5] * center[1] + e[9] * center[2],\n whole.c[2] + e[2] * center[0] + e[6] * center[1] + e[10] * center[2],\n ] as Vec3,\n e,\n half,\n r: Math.hypot(half[0], half[1], half[2]),\n }))\n })\n this.solidOf.clear()\n for (const one of this.solids) this.solidOf.set(one.body, one)\n this.surfacesOf.clear()\n for (const one of this.surfaces) {\n const list = this.surfacesOf.get(one.body)\n if (list) list.push(one)\n else this.surfacesOf.set(one.body, [one])\n }\n this.surfaceGrid.clear()\n this.wideSurfaces.length = 0\n for (const one of this.surfaces) {\n const x0 = Math.floor((one.c[0] - one.r) / SURFACE_CELL)\n const x1 = Math.floor((one.c[0] + one.r) / SURFACE_CELL)\n const z0 = Math.floor((one.c[2] - one.r) / SURFACE_CELL)\n const z1 = Math.floor((one.c[2] + one.r) / SURFACE_CELL)\n if (x1 - x0 > SURFACE_CELLS_ACROSS || z1 - z0 > SURFACE_CELLS_ACROSS) {\n this.wideSurfaces.push(one)\n continue\n }\n for (let ix = x0; ix <= x1; ix++) {\n for (let iz = z0; iz <= z1; iz++) {\n const key = cellKey(ix, iz)\n const cell = this.surfaceGrid.get(key)\n if (cell) cell.push(one)\n else this.surfaceGrid.set(key, [one])\n }\n }\n }\n if (this.wideSurfaces.length > 0) for (const cell of this.surfaceGrid.values()) cell.push(...this.wideSurfaces)\n this.wakeUnsupported()\n for (const b of this.list) {\n if (b.held) {\n b.velocity = [0, 0, 0]\n b.angularVelocity = [0, 0, 0]\n b.sleeping = false\n b.still = 0\n b.calmAt = null\n continue\n }\n if (b.sleeping || (only && !only.moves(b))) continue\n this.integrate(b, dt)\n if (b.sleeping) continue\n const v = b.velocity\n const w = b.angularVelocity\n if (Math.hypot(v[0], v[1], v[2]) > WAKE_ABOVE_SPEED || Math.hypot(w[0], w[1], w[2]) > WAKE_ABOVE_SPIN) this.wakeAbove(b)\n }\n this.collide(dt, only?.meets)\n }\n\n /** A few sleeping pieces each update (`SUPPORT_CHECKS`, in turn) look under them again: one whose table broke, or whose shelf fell over, falls. */\n private wakeUnsupported(): void {\n const n = this.list.length\n for (let k = 0; k < Math.min(SUPPORT_CHECKS, n); k++) {\n this.supportTurn = (this.supportTurn + 1) % n\n const b = this.list[this.supportTurn]\n if (!b.sleeping || b.held || this.supported(b, false) || this.supported(b, true)) continue\n b.sleeping = false\n b.still = 0\n b.calmAt = null\n }\n }\n\n /**\n * Whether a point of `b` (its corners, or with `edges` the points along its edges too) has the ground, a piece or a fixed top under it. Any point, not only the lowest:\n * a book propped on a fallen case rests by a corner high on it while its lowest one hangs beside it.\n */\n private supported(b: PieceBody, edges: boolean): boolean {\n const c = this.centerOf(b, this.p)\n const e = this.m.makeRotationFromQuaternion(b.root.quaternion).elements\n for (const [sx, sy, sz] of this.samples(b, edges)) {\n const y = c.y + e[1] * sx + e[5] * sy + e[9] * sz\n const x = c.x + e[0] * sx + e[4] * sy + e[8] * sz\n const z = c.z + e[2] * sx + e[6] * sy + e[10] * sz\n if (this.supportAt(b, x, y, z, STEP) >= y - SUPPORT_GAP) return true\n }\n return false\n }\n\n /** The surfaces whose cell holds `(x, z)`, the wide ones (`wideSurfaces`) among them. */\n private surfacesAt(x: number, z: number): readonly Solid[] {\n return this.surfaceGrid.get(cellKey(Math.floor(x / SURFACE_CELL), Math.floor(z / SURFACE_CELL))) ?? this.wideSurfaces\n }\n\n /** The highest top of a piece (other than `self`) under `(x, z)` that a point at height `y` stands on (at most `step` above it), -Infinity when none; the boxes of the last update. */\n topAt(x: number, z: number, y: number, step: number, self?: string): number {\n let top = -Infinity\n for (const s of this.surfacesAt(x, z)) {\n if (s.body.objectId === self || (s.body.held && !s.body.carrying) || Math.abs(x - s.c[0]) > s.r || Math.abs(z - s.c[2]) > s.r) continue\n const t = boxTopAt(s, x, z)\n if (t > top && t <= y + step) top = t\n }\n return top\n }\n\n /** What lay asleep on `b` (a box over its top) wakes at once when `b` moves: a can on a table that goes over goes with it. */\n private wakeAbove(b: PieceBody): void {\n const below = this.solidOf.get(b)\n if (!below) return\n const top = below.c[1] + below.half[0] * Math.abs(below.e[1]) + below.half[1] * Math.abs(below.e[5]) + below.half[2] * Math.abs(below.e[9])\n // what can lie on it is in the cells its own circle covers\n const x0 = Math.floor((below.c[0] - below.r) / SURFACE_CELL)\n const x1 = Math.floor((below.c[0] + below.r) / SURFACE_CELL)\n const z0 = Math.floor((below.c[2] - below.r) / SURFACE_CELL)\n const z1 = Math.floor((below.c[2] + below.r) / SURFACE_CELL)\n const wide = x1 - x0 > SURFACE_CELLS_ACROSS || z1 - z0 > SURFACE_CELLS_ACROSS\n const look = (part: Solid): void => {\n const o = part.body\n const s = this.solidOf.get(o)\n if (!s || !o.sleeping || o.held || o === b) return\n if (s.c[1] < below.c[1] || s.c[1] - s.r > top + STEP || Math.hypot(s.c[0] - below.c[0], s.c[2] - below.c[2]) > s.r + below.r) return\n // what lies on it is over it: a board leaning over a can rolling by its foot is not on the can\n if (boxTopAt(below, s.c[0], s.c[2]) === -Infinity && !this.restsOn(o, b, true)) return\n o.sleeping = false\n o.still = 0\n o.calmAt = null\n }\n if (wide) for (const s of this.solids) look(s)\n else for (let ix = x0; ix <= x1; ix++) for (let iz = z0; iz <= z1; iz++) for (const part of this.surfaceGrid.get(cellKey(ix, iz)) ?? []) look(part)\n }\n\n /**\n * Whether `o` rests on a top of `below` (its parts, or its box): a corner of `o` (its contacts or its box) is over that top and within `STEP` of it. With `lowest`, only its\n * lowest corners count (within `STEP` of its lowest): a can rolling by another is beside it, not on it; without, a board leaning on a seat by its high end rests on the seat.\n */\n private restsOn(o: PieceBody, below: PieceBody, lowest: boolean): boolean {\n const c = this.centerOf(o, this.p)\n const e = this.m.makeRotationFromQuaternion(o.root.quaternion).elements\n const points = this.samples(o, false).map(([sx, sy, sz]): Vec3 => [c.x + e[0] * sx + e[4] * sy + e[8] * sz, c.y + e[1] * sx + e[5] * sy + e[9] * sz, c.z + e[2] * sx + e[6] * sy + e[10] * sz])\n let low = Infinity\n for (const p of points) low = Math.min(low, p[1])\n for (const [x, y, z] of points) {\n if (lowest && y > low + STEP) continue\n for (const s of this.surfacesAt(x, z)) if (s.body === below && Math.abs(y - boxTopAt(s, x, z)) <= STEP) return true\n }\n return false\n }\n\n /** Where a corner of `self` at `(x, y, z)` lands: the ground, the top of another piece or of something fixed under it. */\n private supportAt(self: PieceBody, x: number, y: number, z: number, step: number): number {\n let top = this.o.groundAt(x, z)\n let on: Solid | null = null\n let face = 1\n for (const s of this.surfacesAt(x, z)) {\n if (s.body === self || (s.body.held && !s.body.carrying) || Math.abs(x - s.c[0]) > s.r || Math.abs(z - s.c[2]) > s.r) continue\n const t = boxTopAt(s, x, z)\n if (t > top && t <= y + step) {\n top = t\n on = s\n face = topFace\n }\n }\n const fixed = this.o.staticTopAt?.(x, z, y, step) ?? -Infinity\n if (fixed >= top) on = null\n this.supportNormal = on ? faceNormal(on, face) : UP\n this.supportFriction = on?.body.friction ?? null\n return Math.max(top, fixed)\n }\n\n /** Stops a piece that ran into something on its way from `start` to `pos` (`sweep`): moves it back to where it met it and takes the speed into it. */\n private sweepOn(b: PieceBody, start: Vec3, pos: Vec3): void {\n const travel = Math.hypot(pos[0] - start[0], pos[1] - start[1], pos[2] - start[2])\n if (travel < 1e-3) return\n const hit = this.o.sweep?.(b, start, pos)\n if (!hit || hit.normal[1] > SLAM_FLOOR_NORMAL) return\n const v = b.velocity\n const n = hit.normal\n const into = -(v[0] * n[0] + v[1] * n[1] + v[2] * n[2])\n if (into <= 0) return\n const k = Math.min(1, hit.distance / travel)\n const bounce = pairRestitution(b.restitution, hit.restitution)\n for (let i = 0; i < 3; i++) {\n pos[i] = start[i] + (pos[i] - start[i]) * k\n v[i] += (1 + bounce) * into * n[i]\n }\n const w = b.angularVelocity\n w[0] *= 0.5\n w[1] *= 0.5\n w[2] *= 0.5\n if (into >= SLAM_MIN_SPEED && this.time - b.lastHit > 0.15) {\n b.lastHit = this.time\n this.o.onSlam?.(b, hit, into)\n }\n }\n\n private integrate(b: PieceBody, dt: number): void {\n const c = this.centerOf(b, this.p)\n const pos: Vec3 = [c.x, c.y, c.z]\n const start: Vec3 = [c.x, c.y, c.z]\n const q = this.q.copy(b.root.quaternion)\n const v = b.velocity\n const w = b.angularVelocity\n const invM = 1 / b.mass\n const steps = clamp(Math.ceil(dt / SUB_DT), 1, 8)\n const h = dt / steps\n let landing = 0\n let landPoint: Vec3 = [pos[0], pos[1], pos[2]]\n let contactedLast = false\n let touched = false\n let unstable = false\n\n // over a step of the ground (the corners find it at different heights: a table's edge under it) the points along the edges touch too\n const corners = this.samples(b, false)\n this.m.makeRotationFromQuaternion(q)\n let gLow = Infinity\n let gHigh = -Infinity\n for (const [sx, sy, sz] of corners) {\n const e0 = this.m.elements\n const y = pos[1] + e0[1] * sx + e0[5] * sy + e0[9] * sz\n const x = pos[0] + e0[0] * sx + e0[4] * sy + e0[8] * sz\n const z = pos[2] + e0[2] * sx + e0[6] * sy + e0[10] * sz\n // only the fixed ground counts here: other pieces touching it (a pile, things spawned together) keep the corners\n const g = Math.max(this.o.groundAt(x, z), this.o.staticTopAt?.(x, z, y, STEP) ?? -Infinity)\n gLow = Math.min(gLow, g)\n gHigh = Math.max(gHigh, g)\n }\n let local = b.round ? this.roundSamples(b, q) : gHigh - gLow > STEP ? this.samples(b, true) : corners\n let prev: Vec3[] = local.map(() => [0, 0, 0])\n\n for (let s = 0; s < steps; s++) {\n if (b.round) {\n // a round piece touches by its lowest points as it will be turned at the end of this substep: they move round it as it rolls\n const wl0 = Math.hypot(w[0], w[1], w[2])\n const next = this.nextQ.copy(q)\n if (wl0 > 1e-6) next.premultiply(this.dq.setFromAxisAngle(this.ax.set(w[0] / wl0, w[1] / wl0, w[2] / wl0), wl0 * h)).normalize()\n local = this.roundSamples(b, next)\n if (prev.length !== local.length) prev = local.map(() => [0, 0, 0])\n }\n // where each point was before this substep: a point that comes at a higher ground from below it hit the side of the step\n this.m.makeRotationFromQuaternion(q)\n const e0 = this.m.elements\n for (let i = 0; i < local.length; i++) {\n const [sx, sy, sz] = local[i]\n prev[i][0] = pos[0] + e0[0] * sx + e0[4] * sy + e0[8] * sz\n prev[i][1] = pos[1] + e0[1] * sx + e0[5] * sy + e0[9] * sz\n prev[i][2] = pos[2] + e0[2] * sx + e0[6] * sy + e0[10] * sz\n }\n v[1] -= this.o.gravity * h\n pos[0] += v[0] * h\n pos[1] += v[1] * h\n pos[2] += v[2] * h\n const wl = Math.hypot(w[0], w[1], w[2])\n if (wl > 1e-6) {\n this.dq.setFromAxisAngle(this.ax.set(w[0] / wl, w[1] / wl, w[2] / wl), wl * h)\n q.premultiply(this.dq).normalize()\n }\n // the air slows a box's spin a little; a round piece keeps rolling, held back only by its rolling resistance on the ground\n const damp = b.round ? 1 : Math.exp(-0.15 * h)\n w[0] *= damp\n w[1] *= damp\n w[2] *= damp\n\n this.m.makeRotationFromQuaternion(q)\n const e = this.m.elements\n const rs: Vec3[] = []\n const ids: number[] = []\n // per contact: the normal of the surface under it and the friction of the two surfaces\n const ns: Vec3[] = []\n const mus: PieceFriction[] = []\n let maxPen = 0\n // the normal of the surface under the deepest point: the piece is pushed out along it (straight up on the floor, across a tilted top)\n let penNormal: Vec3 = UP\n const rise = STEP + Math.max(0, -v[1]) * h * 2\n // the side of a step of the ground: how far back the piece goes (metres along -dir) and the point that hit it\n let side: { back: number; dir: [number, number]; r: Vec3 } | null = null\n let lowest = Infinity\n for (let i = 0; i < local.length; i++) {\n const [sx, sy, sz] = local[i]\n const r: Vec3 = [e[0] * sx + e[4] * sy + e[8] * sz, e[1] * sx + e[5] * sy + e[9] * sz, e[2] * sx + e[6] * sy + e[10] * sz]\n const px = pos[0] + r[0]\n const pz = pos[2] + r[2]\n const cy = pos[1] + r[1]\n // the ground's own step (a table, a counter) that the point was more than a step below before this substep: it came at its side or is\n // under it, and does not stand on it (nor ratchets up onto it as the rest of the piece is lifted)\n const was = prev[i]\n const raw = this.o.groundAt(px, pz)\n if (raw > cy - SLOP && was[1] < raw - STEP) {\n // under a top it was already beneath (put under an overhang), or coming at its side: either way that top does not hold it\n if (this.o.groundAt(was[0], was[2]) >= raw - STEP) {\n // beneath it, the point stands on the floor the piece last stood on (the height field cannot see under a top)\n const floor = b.floor\n if (floor !== undefined && floor - cy > -SLOP && floor < raw - STEP) {\n rs.push(r)\n ids.push(i)\n ns.push(UP)\n mus.push(pairFriction(b.friction, null))\n maxPen = Math.max(maxPen, floor - cy)\n }\n continue\n }\n const dx = px - was[0]\n const dz = pz - was[2]\n const len = Math.hypot(dx, dz)\n if (len > 1e-6) {\n // where along its move the point met the side: the first place the ground is up at this top\n let lo = 0\n let hi = 1\n for (let it = 0; it < 6; it++) {\n const mid = (lo + hi) / 2\n if (this.o.groundAt(was[0] + dx * mid, was[2] + dz * mid) >= raw - STEP) hi = mid\n else lo = mid\n }\n const back = (1 - lo) * len + 0.001\n if (!side || back > side.back) side = { back, dir: [dx / len, dz / len], r }\n }\n continue\n }\n // the points along the edges are there for the step of the ground; on other pieces only the corners stand, as everywhere else\n this.supportNormal = UP\n this.supportFriction = null\n const gy = i < 8 || b.contacts ? this.supportAt(b, px, cy, pz, rise) : Math.max(raw, this.o.staticTopAt?.(px, pz, cy, rise) ?? -Infinity)\n const pen = gy - cy\n if (pen > -SLOP) {\n rs.push(r)\n ids.push(i)\n ns.push(this.supportNormal)\n mus.push(pairFriction(b.friction, this.supportFriction))\n if (pen > maxPen) {\n maxPen = pen\n penNormal = this.supportNormal\n }\n lowest = Math.min(lowest, gy)\n }\n }\n if (lowest < Infinity) b.floor = lowest\n if (b.round && ns.length > 0) {\n const sum: Vec3 = [0, 0, 0]\n for (const one of ns) for (let k = 0; k < 3; k++) sum[k] += one[k]\n const len = Math.hypot(sum[0], sum[1], sum[2])\n b.surfaceNormal = len > 1e-6 ? [sum[0] / len, sum[1] / len, sum[2] / len] : UP\n } else if (b.round && rs.length === 0) b.surfaceNormal = UP\n if (side) {\n // the side of the step stops the piece: back out of it, and the point loses the speed it had into the side\n pos[0] -= side.dir[0] * side.back\n pos[2] -= side.dir[1] * side.back\n this.contactImpulse(b, e, side.r, [-side.dir[0], 0, -side.dir[1]], SIDE_BOUNCE)\n }\n contactedLast = rs.length > 0\n if (contactedLast) touched = true\n if (!contactedLast) continue\n // a point `maxPen` under a surface of normal n is `maxPen * n.y` inside it, along n\n const out = Math.max(0, maxPen - SLOP * 0.5) * penNormal[1]\n pos[0] += penNormal[0] * out\n pos[1] += penNormal[1] * out\n pos[2] += penNormal[2] * out\n let impact = 0\n for (const r of rs) impact = Math.max(impact, -(v[1] + w[2] * r[0] - w[0] * r[2]))\n const restitution = impact > 2 ? 0.25 : 0\n if (impact > landing) {\n landing = impact\n let sx = 0\n let sz = 0\n for (const r of rs) {\n sx += r[0]\n sz += r[2]\n }\n const lx = pos[0] + sx / rs.length\n const lz = pos[2] + sz / rs.length\n landPoint = [lx, pos[1] - Math.max(...rs.map((r) => -r[1])), lz]\n }\n // Contact impulses, solved together: each point keeps the impulse it has given so far (pushing only, never pulling) and the friction it has\n // given (within the paper's grip times that push), and every pass corrects them. Points spread unevenly under the box (a table's edge under\n // half of it) then share the weight as they should, instead of the first ones handled kicking the box into a spin.\n // the velocity of a point of the piece: v + w x r\n const pointV = (r: Vec3): Vec3 => [v[0] + w[1] * r[2] - w[2] * r[1], v[1] + w[2] * r[0] - w[0] * r[2], v[2] + w[0] * r[1] - w[1] * r[0]]\n const dot = (a: Vec3, c: Vec3): number => a[0] * c[0] + a[1] * c[1] + a[2] * c[2]\n const goal = rs.map((r, k) => {\n const vn = dot(pointV(r), ns[k])\n return vn < 0 ? -restitution * vn : 0\n })\n // a point that slides drags with the dynamic friction, one that holds with the static one (Coulomb)\n const slipping = rs.map((r, k) => {\n // as it moved before this substep's gravity: a thing at rest on a slope is held by the static grip, not let go by the pull it is to resist\n const pv = pointV(r)\n pv[1] += this.o.gravity * h\n const vn = dot(pv, ns[k])\n return Math.hypot(pv[0] - vn * ns[k][0], pv[1] - vn * ns[k][1], pv[2] - vn * ns[k][2]) > SLIP_SPEED\n })\n // the step moved the piece at the speed it had before the contacts: what they took from it along the ground is taken from the move too, so\n // a push the floor's grip holds does not creep the piece along\n const vx0 = v[0]\n const vz0 = v[2]\n // warm start: each point starts from what it gave in the last substep (a resting box carries its weight from the first pass)\n if (!b.warm || b.warm.length !== WARM_SLOTS * 4) b.warm = new Float64Array(WARM_SLOTS * 4)\n const warm = b.warm\n const accN = ids.map((id) => (id < WARM_SLOTS ? warm[id * 4] : 0))\n const accT = ids.map((id): Vec3 => (id < WARM_SLOTS ? [warm[id * 4 + 1], warm[id * 4 + 2], warm[id * 4 + 3]] : [0, 0, 0]))\n /** Gives the piece the impulse `j` (world) at `r`. */\n const push = (r: Vec3, j: Vec3): void => {\n v[0] += j[0] * invM\n v[1] += j[1] * invM\n v[2] += j[2] * invM\n const dw = this.mulInvInertiaWith(b, e, r[1] * j[2] - r[2] * j[1], r[2] * j[0] - r[0] * j[2], r[0] * j[1] - r[1] * j[0])\n w[0] += dw[0]\n w[1] += dw[1]\n w[2] += dw[2]\n }\n /** The mass the piece shows to an impulse along the unit `d` at `r`: 1 / (1/m + (I^-1 (r x d) x r) . d). */\n const reach = (r: Vec3, d: Vec3): number => {\n const a = this.mulInvInertiaWith(b, e, r[1] * d[2] - r[2] * d[1], r[2] * d[0] - r[0] * d[2], r[0] * d[1] - r[1] * d[0])\n return invM + (a[1] * r[2] - a[2] * r[1]) * d[0] + (a[2] * r[0] - a[0] * r[2]) * d[1] + (a[0] * r[1] - a[1] * r[0]) * d[2]\n }\n for (let k = 0; k < rs.length; k++) {\n const n = ns[k]\n const t = accT[k]\n if (accN[k] !== 0 || t[0] !== 0 || t[1] !== 0 || t[2] !== 0) push(rs[k], [n[0] * accN[k] + t[0], n[1] * accN[k] + t[1], n[2] * accN[k] + t[2]])\n }\n for (let it = 0; it < SOLVER_PASSES; it++) {\n for (let k = 0; k < rs.length; k++) {\n const r = rs[k]\n const n = ns[k]\n // the push along the normal of the surface (a tilted top pushes across it, not straight up)\n const vn = dot(pointV(r), n)\n const total = Math.max(0, accN[k] + (goal[k] - vn) / reach(r, n))\n const j = total - accN[k]\n accN[k] = total\n if (j !== 0) push(r, [n[0] * j, n[1] * j, n[2] * j])\n // friction in the plane of the surface, up to the static or dynamic coefficient times the push the point gives\n const pv = pointV(r)\n const pn = dot(pv, n)\n const vt: Vec3 = [pv[0] - pn * n[0], pv[1] - pn * n[1], pv[2] - pn * n[2]]\n const speed = Math.hypot(vt[0], vt[1], vt[2])\n const f: Vec3 = [accT[k][0], accT[k][1], accT[k][2]]\n if (speed > 1e-6) {\n const d: Vec3 = [vt[0] / speed, vt[1] / speed, vt[2] / speed]\n const jt = speed / reach(r, d)\n f[0] -= d[0] * jt\n f[1] -= d[1] * jt\n f[2] -= d[2] * jt\n } else if (f[0] === 0 && f[1] === 0 && f[2] === 0) continue\n const most = (slipping[k] ? mus[k].dynamic : mus[k].static) * accN[k]\n const fl = Math.hypot(f[0], f[1], f[2])\n if (fl > most) {\n f[0] *= most / fl\n f[1] *= most / fl\n f[2] *= most / fl\n }\n const dj: Vec3 = [f[0] - accT[k][0], f[1] - accT[k][1], f[2] - accT[k][2]]\n accT[k] = f\n if (dj[0] !== 0 || dj[1] !== 0 || dj[2] !== 0) push(r, dj)\n }\n }\n pos[0] += (v[0] - vx0) * h\n pos[2] += (v[2] - vz0) * h\n warm.fill(0)\n for (let k = 0; k < rs.length; k++) {\n const id = ids[k]\n if (id >= WARM_SLOTS) continue\n warm[id * 4] = accN[k]\n warm[id * 4 + 1] = accT[k][0]\n warm[id * 4 + 2] = accT[k][1]\n warm[id * 4 + 3] = accT[k][2]\n }\n // Support check. The corner contacts above are relative to the centre of mass, so they already give a torque when the centre of mass is\n // outside the support. What they cannot do is end a balancing act: a tall thin piece on its edge (or a single corner) is in equilibrium\n // with the centre of mass above a very small support, so it must not rest there. It gets a gentle topple push toward the side it leans\n // to (or toward the wider side when it leans nowhere), and it may not sleep.\n let x0 = Infinity, x1 = -Infinity, z0 = Infinity, z1 = -Infinity, low = 0\n for (const r of rs) {\n x0 = Math.min(x0, r[0]); x1 = Math.max(x1, r[0])\n z0 = Math.min(z0, r[2]); z1 = Math.max(z1, r[2])\n low = Math.min(low, r[1])\n }\n const height = -low\n const wx = x1 - x0\n const wz = z1 - z0\n // a round piece lying on its side rests on a line: that is its rest, not a balancing act (it rolls if the ground slopes)\n unstable = !b.round && (Math.min(wx, wz) < NARROW * height || x0 > 0 || x1 < 0 || z0 > 0 || z1 < 0)\n if (b.tipping) {\n b.tipping.seconds -= h\n // lying is measured on the box as it is turned: a top corner held from above (a board it was joined to) says nothing of how it stands\n const [hx, hy, hz] = b.halfExtents\n const upHalf = Math.abs(e[1]) * hx + Math.abs(e[5]) * hy + Math.abs(e[9]) * hz\n if (upHalf < TIP_LYING || b.tipping.seconds <= 0) b.tipping = null\n else {\n w[0] += b.tipping.x * TIP_ACCELERATION * h\n w[2] += b.tipping.z * TIP_ACCELERATION * h\n unstable = true\n }\n }\n if (unstable) {\n // the support centre relative to the centre of mass: the piece falls away from it (toward +axis when it is centred)\n const dirX = x0 + x1 > 0 ? -1 : 1\n const dirZ = z0 + z1 > 0 ? -1 : 1\n const k = TOPPLE * Math.min(height, 1) * h\n // rotating about -z moves the top toward +x; rotating about +x moves it toward +z\n if (wx <= wz) w[2] -= dirX * k\n else w[0] += dirZ * k\n }\n // rolling / spinning resistance while touching the ground: a box loses its spin; a round piece rolls on, held back by its rolling resistance\n // (a deceleration of C_RR g / r about the axis it rolls on) and a little spin about the others\n if (b.round) {\n let rolling = 0\n for (const mu of mus) rolling = Math.max(rolling, mu.rolling ?? ROLLING_RESISTANCE)\n this.rollingResistance(b, q, w, h, rolling)\n } else {\n const rd = Math.exp((rs.length >= 3 ? -3 : -1.5) * h)\n w[0] *= rd\n w[1] *= rd\n w[2] *= rd\n const fd = Math.exp(-0.3 * h)\n v[0] *= fd\n v[2] *= fd\n }\n }\n\n // what stands in the way (a wall, a car): the piece stops against it, bounces a little and both take the blow\n if (this.o.sweep && !b.held) this.sweepOn(b, start, pos)\n\n // write back\n b.root.quaternion.copy(q)\n const off = this.ax.copy(b.centerV).applyQuaternion(q)\n b.root.position.set(pos[0] - off.x, pos[1] - off.y, pos[2] - off.z)\n b.root.updateMatrixWorld(true)\n b.onGround = contactedLast\n\n if (landing > HARD_LANDING && this.time - b.lastHit > 0.15) {\n b.lastHit = this.time\n this.o.onHardLanding(b, landPoint, landing)\n }\n\n const still = touched && !unstable && Math.hypot(v[0], v[1], v[2]) < 0.12 && Math.hypot(w[0], w[1], w[2]) < 0.45\n if (still) b.still += dt\n else b.still = 0\n if (b.still >= SLEEP_AFTER || this.staysInPlace(b, touched && !b.tipping, pos, q, dt)) {\n b.sleeping = true\n b.calmAt = null\n v[0] = v[1] = v[2] = 0\n w[0] = w[1] = w[2] = 0\n }\n }\n\n /** Whether the piece has kept to the same spot on the ground for `CALM_SLEEP_AFTER` (see `CALM_DRIFT`). */\n private staysInPlace(b: PieceBody, touched: boolean, center: Vec3, q: THREE_NS.Quaternion, dt: number): boolean {\n const at = b.calmAt\n const turned = at ? 2 * Math.acos(Math.min(1, Math.abs(at.quaternion[0] * q.x + at.quaternion[1] * q.y + at.quaternion[2] * q.z + at.quaternion[3] * q.w))) : Infinity\n if (!touched || !at || Math.hypot(center[0] - at.center[0], center[1] - at.center[1], center[2] - at.center[2]) > CALM_DRIFT || turned > CALM_TURN) {\n b.calmAt = touched ? { center: [center[0], center[1], center[2]], quaternion: [q.x, q.y, q.z, q.w] } : null\n b.calm = 0\n return false\n }\n b.calm += dt\n return b.calm >= CALM_SLEEP_AFTER\n }\n\n /** Whether the centre `c` of `upper` is over the top of `lower`'s box (as it was at the start of the update). */\n private onTopOf(upper: PieceBody, lower: PieceBody, c: THREE_NS.Vector3): boolean {\n const s = this.solidOf.get(lower)\n if (!s) return false\n const top = boxTopAt(s, c.x, c.z)\n return top > -Infinity && c.y >= top - 0.01\n }\n\n /**\n * The points a round piece touches the ground by as it is turned now (`q`): its rims (`contacts`), which hold it standing on an end, and the exact lowest point of each\n * rim (of the ball), so lying on its side it rests on a line and rolls smoothly instead of over the corners of a polygon.\n */\n private roundSamples(b: PieceBody, q: THREE_NS.Quaternion): Vec3[] {\n const round = b.round\n const rims = b.contacts ?? []\n if (!round) return rims\n const e = this.m.makeRotationFromQuaternion(q).elements\n // into the surface it last lay on (the world's down on the floor), in the piece's frame: on a slope it touches below its centre across the slope, not straight down\n const n = b.surfaceNormal ?? UP\n const down: Vec3 = [-(e[0] * n[0] + e[1] * n[1] + e[2] * n[2]), -(e[4] * n[0] + e[5] * n[1] + e[6] * n[2]), -(e[8] * n[0] + e[9] * n[1] + e[10] * n[2])]\n if (round.kind === 'sphere') return [...rims, [down[0] * round.radius, down[1] * round.radius, down[2] * round.radius]]\n const k = round.axis\n const across: Vec3 = [down[0], down[1], down[2]]\n across[k] = 0\n const len = Math.hypot(across[0], across[1], across[2])\n // standing on an end: the rim holds it\n if (len < 1e-3) return rims\n const lowest = (at: number, radius: number): Vec3 => {\n const p: Vec3 = [(across[0] / len) * radius, (across[1] / len) * radius, (across[2] / len) * radius]\n p[k] = at\n return p\n }\n const half = b.halfExtents[k]\n // the lowest point of each ring along it: a straight can touches by both ends, a tapered bottle by its wide end and its narrow one, a bottle's neck not at all\n const low = (round.profile ?? [[-half, round.radius], [half, round.radius]]).map(([at, radius]) => lowest(at, radius))\n // lying (its axis nearer level than upright) it touches by those lowest points only: the points of the rims beside them move as it rolls and would brake it\n return len > ROUND_LYING ? low : [...rims, ...low]\n }\n\n /**\n * Slows the spin of a round piece on the ground by its rolling resistance: a torque C_rr N r about the axis it rolls on (N = m g n_y on a surface of normal n), so with\n * I = k m r^2 the spin loses C_rr g n_y / (k r) per second, and down a slope of angle t it rolls at g (sin t - C_rr cos t) / (1 + k). Standing on its rim, a can's spin\n * about the rest dies down; lying, it keeps turning about the line it touches by (a tapered bottle rounds its narrow end).\n */\n private rollingResistance(b: PieceBody, q: THREE_NS.Quaternion, w: Vec3, h: number, rolling: number): void {\n const round = b.round\n if (!round) return\n const e = this.m.makeRotationFromQuaternion(q).elements\n const cylinder = round.kind === 'cylinder'\n const a: Vec3 = cylinder ? [e[round.axis * 4], e[round.axis * 4 + 1], e[round.axis * 4 + 2]] : [0, 0, 0]\n const along = cylinder ? w[0] * a[0] + w[1] * a[1] + w[2] * a[2] : 0\n const roll: Vec3 = cylinder ? [a[0] * along, a[1] * along, a[2] * along] : [w[0], w[1], w[2]]\n const rest: Vec3 = [w[0] - roll[0], w[1] - roll[1], w[2] - roll[2]]\n const spin = Math.hypot(roll[0], roll[1], roll[2])\n const upright = b.surfaceNormal?.[1] ?? 1\n const slow = spin > 0 ? Math.max(0, spin - (rolling * this.o.gravity * upright * h) / (round.inertia * round.radius)) / spin : 0\n const lying = cylinder && Math.abs(a[1]) < ROUND_LYING\n const damp = lying ? 1 : Math.exp(-3 * h)\n for (let i = 0; i < 3; i++) w[i] = roll[i] * slow + rest[i] * damp\n }\n\n /** Half the height of the box of a piece as it is turned now. */\n private halfHeight(b: PieceBody): number {\n const e = this.m.makeRotationFromQuaternion(b.root.quaternion).elements\n return Math.abs(e[1]) * b.halfExtents[0] + Math.abs(e[5]) * b.halfExtents[1] + Math.abs(e[9]) * b.halfExtents[2]\n }\n\n /**\n * Pieces against each other. Candidates by sweep and prune along x on their bounding spheres (sorted once per step: fifty cans cost a sort and a handful of pairs, not\n * 1225); a pair with a round piece in it meets by its shapes (`shapeContact`) and exchanges an impulse, two boxes are only pushed apart (`separatePair`).\n */\n private collide(dt: number, meets?: StepFilter['meets']): void {\n const n = this.list.length\n if (n < 2) return\n const centers = this.list.map((b) => {\n const c = this.centerOf(b, this.p)\n return [c.x, c.y, c.z] as Vec3\n })\n const radii = this.list.map((b) => Math.hypot(b.halfExtents[0], b.halfExtents[1], b.halfExtents[2]))\n const order = this.list.map((_, i) => i).sort((i, j) => centers[i][0] - radii[i] - (centers[j][0] - radii[j]))\n for (let oi = 0; oi < n; oi++) {\n const i = order[oi]\n const reach = centers[i][0] + radii[i]\n for (let oj = oi + 1; oj < n; oj++) {\n const j = order[oj]\n if (centers[j][0] - radii[j] > reach) break\n const a = this.list[i]\n const b = this.list[j]\n if ((a.held || a.sleeping) && (b.held || b.sleeping)) continue\n if (meets && !meets(a, b)) continue\n const r = radii[i] + radii[j]\n const ca = centers[i]\n const cb = centers[j]\n if (Math.abs(ca[1] - cb[1]) > r || Math.abs(ca[2] - cb[2]) > r) continue\n // one lies on the other (a book on a shelf): the corners hold them apart, a sideways push would slide it off\n // (a round piece meets the other by their shapes, which tell lying on from beside: a can by a tall wardrobe whose middle is far above it still hits it)\n if (!a.round && !b.round && Math.abs(ca[1] - cb[1]) >= (this.halfHeight(a) + this.halfHeight(b)) * 0.9) continue\n // or on a tilted top (a table going over): the one above is over the other's top, whatever their boxes' heights\n if (this.onTopOf(b, a, new this.THREE.Vector3(...cb)) || this.onTopOf(a, b, new this.THREE.Vector3(...ca))) continue\n if (a.round || b.round) this.knock(a, b, ca, cb)\n // two boxes, unless one leans on the other's part (a board on a bench's seat): the support holds them, not a push apart\n // nor when no part of one is in a part of the other (a book lying in the hollow of a case on its back is inside its box, not in its boards)\n else if (this.partsOverlap(a, b) && !this.restsOn(a, b, false) && !this.restsOn(b, a, false)) this.separatePair(a, b, ca, cb, dt)\n }\n }\n }\n\n /** The shape a piece meets others by (`ContactShape`), as it stands now: a round one a capsule round its axis, any other the boxes of its parts or its box. */\n private contactShape(b: PieceBody, c: Vec3): ContactShape {\n const e = [...this.m.makeRotationFromQuaternion(b.root.quaternion).elements]\n const round = b.round\n if (round) {\n if (round.kind === 'sphere') return { kind: 'capsule', from: c, to: c, radius: round.radius }\n // the segment stops a radius short of each end, so end on it is as long as the piece\n const reach = Math.max(0, b.halfExtents[round.axis] - round.radius)\n const k = round.axis * 4\n const d: Vec3 = [e[k] * reach, e[k + 1] * reach, e[k + 2] * reach]\n return { kind: 'capsule', from: [c[0] - d[0], c[1] - d[1], c[2] - d[2]], to: [c[0] + d[0], c[1] + d[1], c[2] + d[2]], radius: round.radius }\n }\n const parts = b.partBoxes ?? [{ center: [0, 0, 0] as Vec3, half: b.halfExtents }]\n return {\n kind: 'boxes',\n boxes: parts.map(({ center, half }) => ({\n c: [c[0] + e[0] * center[0] + e[4] * center[1] + e[8] * center[2], c[1] + e[1] * center[0] + e[5] * center[1] + e[9] * center[2], c[2] + e[2] * center[0] + e[6] * center[1] + e[10] * center[2]] as Vec3,\n e,\n half,\n })),\n }\n }\n\n /**\n * Two pieces that met, one of them round: they are put apart along the normal (by their inverse masses) and, closing in, exchange an impulse\n * j = -(1 + e) v_n / (1/m_a + 1/m_b + the turning of each), with the restitution e of their two materials, and the friction of their surfaces across it. The impulses are\n * equal and opposite, so the momentum of the pair is kept. A held piece is not moved (the hand holds it); a sleeping one wakes when it is knocked.\n */\n private knock(a: PieceBody, b: PieceBody, ca: Vec3, cb: Vec3): void {\n const hit = shapeContact(this.contactShape(a, ca), this.contactShape(b, cb))\n if (!hit) return\n const n = hit.normal\n // one on the other (a can rolling down a board, off its end): the support of the pieces holds it, as it does on the floor\n if (Math.abs(n[1]) > SLAM_FLOOR_NORMAL) return\n const ra: Vec3 = [hit.point[0] - ca[0], hit.point[1] - ca[1], hit.point[2] - ca[2]]\n const rb: Vec3 = [hit.point[0] - cb[0], hit.point[1] - cb[1], hit.point[2] - cb[2]]\n const pointV = (body: PieceBody, r: Vec3): Vec3 => {\n const v = body.velocity\n const w = body.angularVelocity\n return [v[0] + w[1] * r[2] - w[2] * r[1], v[1] + w[2] * r[0] - w[0] * r[2], v[2] + w[0] * r[1] - w[1] * r[0]]\n }\n const relative = (): Vec3 => {\n const va = pointV(a, ra)\n const vb = pointV(b, rb)\n return [va[0] - vb[0], va[1] - vb[1], va[2] - vb[2]]\n }\n const vn0 = relative()\n const closing = vn0[0] * n[0] + vn0[1] * n[1] + vn0[2] * n[2]\n // a sleeping piece stays put for a touch (cans asleep side by side); knocked, it wakes\n const wake = (body: PieceBody): void => {\n body.sleeping = false\n body.still = 0\n body.calmAt = null\n }\n if (closing < -WAKE_ABOVE_SPEED) {\n if (a.sleeping) wake(a)\n if (b.sleeping) wake(b)\n }\n const ima = a.held || a.sleeping ? 0 : 1 / a.mass\n const imb = b.held || b.sleeping ? 0 : 1 / b.mass\n if (ima + imb === 0) return\n const ea = [...this.m.makeRotationFromQuaternion(a.root.quaternion).elements]\n const eb = [...this.m.makeRotationFromQuaternion(b.root.quaternion).elements]\n // apart: along the ground when they meet side by side (a can is not lifted off the floor by its neighbour), else along the normal\n const flat = Math.hypot(n[0], n[2])\n const out: Vec3 = flat > KNOCK_FLAT ? [n[0] / flat, 0, n[2] / flat] : n\n const depth = Math.max(0, hit.depth - SLOP) / (flat > KNOCK_FLAT ? flat : 1)\n for (const [body, share, sign] of [[a, ima, 1], [b, imb, -1]] as const) {\n if (share === 0) continue\n const move = (depth * share * sign) / (ima + imb)\n body.root.position.x += out[0] * move\n body.root.position.y += out[1] * move\n body.root.position.z += out[2] * move\n }\n if (closing >= 0) return\n /** What the pair shows to an impulse along the unit `d`: 1/m_a + 1/m_b + (I_a^-1 (r_a x d) x r_a) . d + (the same for b). */\n const turning = (body: PieceBody, e: number[], r: Vec3, d: Vec3): number => {\n const t = this.mulInvInertiaWith(body, e, r[1] * d[2] - r[2] * d[1], r[2] * d[0] - r[0] * d[2], r[0] * d[1] - r[1] * d[0])\n return (t[1] * r[2] - t[2] * r[1]) * d[0] + (t[2] * r[0] - t[0] * r[2]) * d[1] + (t[0] * r[1] - t[1] * r[0]) * d[2]\n }\n const resist = (d: Vec3): number => ima + imb + (ima > 0 ? turning(a, ea, ra, d) : 0) + (imb > 0 ? turning(b, eb, rb, d) : 0)\n const give = (j: Vec3): void => {\n if (ima > 0) {\n for (let i = 0; i < 3; i++) a.velocity[i] += j[i] * ima\n const dw = this.mulInvInertiaWith(a, ea, ra[1] * j[2] - ra[2] * j[1], ra[2] * j[0] - ra[0] * j[2], ra[0] * j[1] - ra[1] * j[0])\n for (let i = 0; i < 3; i++) a.angularVelocity[i] += dw[i]\n }\n if (imb > 0) {\n for (let i = 0; i < 3; i++) b.velocity[i] -= j[i] * imb\n const dw = this.mulInvInertiaWith(b, eb, rb[1] * j[2] - rb[2] * j[1], rb[2] * j[0] - rb[0] * j[2], rb[0] * j[1] - rb[1] * j[0])\n for (let i = 0; i < 3; i++) b.angularVelocity[i] -= dw[i]\n }\n }\n // a touch slower than `BOUNCE_MIN_SPEED` only stops (two cans resting together do not chatter)\n const bounce = -closing > BOUNCE_MIN_SPEED ? pairRestitution(a.restitution, b.restitution) : 0\n const j = (-(1 + bounce) * closing) / resist(n)\n give([n[0] * j, n[1] * j, n[2] * j])\n // the friction of the two surfaces across the normal, up to mu times the push (Coulomb)\n const v = relative()\n const vn = v[0] * n[0] + v[1] * n[1] + v[2] * n[2]\n const vt: Vec3 = [v[0] - vn * n[0], v[1] - vn * n[1], v[2] - vn * n[2]]\n const slide = Math.hypot(vt[0], vt[1], vt[2])\n if (slide < 1e-6) return\n const t: Vec3 = [vt[0] / slide, vt[1] / slide, vt[2] / slide]\n const jt = Math.min(slide / resist(t), pairFriction(a.friction, b.friction ?? null).dynamic * j)\n give([-t[0] * jt, -t[1] * jt, -t[2] * jt])\n if (-closing >= SLAM_MIN_SPEED && this.time - Math.max(a.lastHit, b.lastHit) > 0.15) {\n a.lastHit = b.lastHit = this.time\n this.o.onKnock?.(a, b, hit.point, -closing)\n }\n }\n\n /** Whether a part of `a` and a part of `b` (their boxes of the step, as world-aligned boxes around them) overlap. */\n private partsOverlap(a: PieceBody, b: PieceBody): boolean {\n const extent = (s: Solid, k: number): number => Math.abs(s.e[k]) * s.half[0] + Math.abs(s.e[k + 4]) * s.half[1] + Math.abs(s.e[k + 8]) * s.half[2]\n for (const pa of this.surfacesOf.get(a) ?? []) {\n for (const pb of this.surfacesOf.get(b) ?? []) {\n let apart = false\n for (let k = 0; k < 3 && !apart; k++) apart = Math.abs(pa.c[k] - pb.c[k]) > extent(pa, k) + extent(pb, k)\n if (!apart) return true\n }\n }\n return false\n }\n\n /** Two boxes overlapping side by side (horizontal bounding circles): pushed apart, gently, so they do not interpenetrate forever. */\n private separatePair(a: PieceBody, b: PieceBody, ca: Vec3, cb: Vec3, dt: number): void {\n const fixedA = a.held || a.sleeping\n const fixedB = b.held || b.sleeping\n const maxMove = 1.5 * dt\n const rh = (Math.max(a.halfExtents[0], a.halfExtents[2]) + Math.max(b.halfExtents[0], b.halfExtents[2])) * 0.8\n let dx = cb[0] - ca[0]\n let dz = cb[2] - ca[2]\n let d = Math.hypot(dx, dz)\n if (d >= rh) return\n if (d < 1e-5) {\n dx = 1\n dz = 0\n d = 1\n }\n const push = Math.min(maxMove, (rh - d) * 0.5)\n const wa = fixedA ? 0 : fixedB ? 1 : b.mass / (a.mass + b.mass)\n const wb = fixedB ? 0 : fixedA ? 1 : a.mass / (a.mass + b.mass)\n const ux = dx / (d || 1)\n const uz = dz / (d || 1)\n if (!fixedA) {\n a.root.position.x -= ux * push * 2 * wa\n a.root.position.z -= uz * push * 2 * wa\n }\n if (!fixedB) {\n b.root.position.x += ux * push * 2 * wb\n b.root.position.z += uz * push * 2 * wb\n }\n }\n}\n","import type * as THREE_NS from 'three'\nimport type { Vec3 } from '@adatechnology/game-destruction'\n\n/** A bar of a cage, in world space. */\nexport interface RebarBar {\n readonly center: Vec3\n readonly rotation: [number, number, number, number]\n readonly length: number\n}\n\n/** Bare rebar of reinforced parts: one instanced cylinder mesh per part, replaced whenever the part exposes more (or less) of its cage. */\nexport class RebarCages {\n private readonly cages = new Map<string, THREE_NS.InstancedMesh>()\n private readonly geometry: THREE_NS.CylinderGeometry\n private readonly material: THREE_NS.MeshStandardMaterial\n private readonly up: THREE_NS.Vector3\n private readonly dir: THREE_NS.Vector3\n private readonly mid: THREE_NS.Vector3\n private readonly q: THREE_NS.Quaternion\n private readonly scale: THREE_NS.Vector3\n private readonly m: THREE_NS.Matrix4\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly scene: THREE_NS.Scene,\n private readonly radius = 0.004,\n ) {\n this.geometry = new THREE.CylinderGeometry(radius, radius, 1, 6)\n this.material = new THREE.MeshStandardMaterial({ color: 0x74665c, roughness: 0.55, metalness: 0.6 })\n this.up = new THREE.Vector3(0, 1, 0)\n this.dir = new THREE.Vector3()\n this.mid = new THREE.Vector3()\n this.q = new THREE.Quaternion()\n this.scale = new THREE.Vector3()\n this.m = new THREE.Matrix4()\n }\n\n /** Bars drawn now, over every part. */\n get count(): number {\n let n = 0\n for (const mesh of this.cages.values()) n += mesh.count\n return n\n }\n\n /** Meshes of the live cages (tests and picking). */\n meshes(): THREE_NS.InstancedMesh[] {\n return [...this.cages.values()]\n }\n\n /**\n * Draw `bars` (world space) as the cage of `key`; an empty list removes it. The cage is a child of `holder` (the drawing of the part's object, the scene\n * by default), so it goes where the part goes: a beam that comes down takes its bare bars with it.\n */\n set(key: string, bars: ReadonlyArray<readonly [Vec3, Vec3]>, holder?: THREE_NS.Object3D): void {\n this.remove(key)\n if (bars.length === 0) return\n const parent = holder ?? this.scene\n parent.updateWorldMatrix(true, false)\n const toParent = new this.THREE.Matrix4().copy(parent.matrixWorld).invert()\n const mesh = new this.THREE.InstancedMesh(this.geometry, this.material, bars.length)\n bars.forEach(([a, b], i) => {\n this.dir.set(b[0] - a[0], b[1] - a[1], b[2] - a[2])\n const length = this.dir.length()\n this.mid.set((a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2)\n this.q.setFromUnitVectors(this.up, length > 1e-9 ? this.dir.divideScalar(length) : this.up)\n this.m.compose(this.mid, this.q, this.scale.set(1, Math.max(length, 1e-4), 1)).premultiply(toParent)\n mesh.setMatrixAt(i, this.m)\n })\n mesh.instanceMatrix.needsUpdate = true\n mesh.castShadow = true\n mesh.name = 'rebar-cage'\n parent.add(mesh)\n this.cages.set(key, mesh)\n }\n\n /** The cage of `from` now belongs to `to` (a part that left its object for one of its own) and hangs from `holder`, where it is in the world now. */\n move(from: string, to: string, holder: THREE_NS.Object3D): void {\n const mesh = this.cages.get(from)\n if (!mesh) return\n this.cages.delete(from)\n this.remove(to)\n holder.attach(mesh)\n this.cages.set(to, mesh)\n }\n\n /** Takes the cage of `key` away and gives its bars, where they are in the world now: centre, turn (the bar along its y) and length. */\n take(key: string): RebarBar[] {\n const mesh = this.cages.get(key)\n if (!mesh) return []\n mesh.updateWorldMatrix(true, false)\n const bars: RebarBar[] = []\n for (let i = 0; i < mesh.count; i++) {\n mesh.getMatrixAt(i, this.m)\n this.m.premultiply(mesh.matrixWorld).decompose(this.mid, this.q, this.scale)\n bars.push({ center: [this.mid.x, this.mid.y, this.mid.z], rotation: [this.q.x, this.q.y, this.q.z, this.q.w], length: this.scale.y })\n }\n this.remove(key)\n return bars\n }\n\n /** Radius of the bars drawn, metres. */\n get barRadius(): number {\n return this.radius\n }\n\n remove(key: string): void {\n const mesh = this.cages.get(key)\n if (!mesh) return\n mesh.removeFromParent()\n mesh.dispose()\n this.cages.delete(key)\n }\n\n /** Remove the cages of every part of `object` (keys are `object|part`). */\n removeObject(object: string): void {\n for (const key of [...this.cages.keys()]) if (key.startsWith(`${object}|`)) this.remove(key)\n }\n\n clear(): void {\n for (const key of [...this.cages.keys()]) this.remove(key)\n }\n\n dispose(): void {\n this.clear()\n this.geometry.dispose()\n this.material.dispose()\n }\n}\n","import type * as THREE_NS from 'three'\nimport { guessMaterial, inferJoints, MATERIALS, partMass } from '@adatechnology/game-destruction'\nimport type { JointKind, JointSpec, MaterialId, PartSpec } from '@adatechnology/game-destruction'\nimport type { Mesh, Object3D, SpecFromObjectOptions, SpecFromObjectResult, ThreeNamespace } from './types'\n\ninterface Entry {\n key: string\n meshes: Mesh[]\n box: THREE_NS.Box3\n material: MaterialId\n explicitId: string | null\n fill?: number\n hollow: boolean\n /** `userData.destructionSkin`: a layer drawn on a part (a label, a coat), never a part of its own. */\n skin: boolean\n tags?: string[]\n /** `userData.destructionContains`: the fluid the part holds (a hole in it makes it leak). */\n contains?: { fluid: string; liters: number }\n /** `userData.destructionPowder`: the loose dry contents the part holds (`PartSpec.powder`). */\n powder?: { color: number }\n /** `userData.destructionThickness`: the real wall thickness in metres (a can is a tenth of a millimetre, far less than its box says). */\n thickness?: number\n /** Part id wished by the host (`userData.destructionPart`). */\n fixedId: boolean\n name: string\n /** `parent` / `kind` of an object-valued `destructionPart`: the part is attached to `parent` by a joint of that kind. */\n parent?: string\n jointKind?: JointKind\n}\n\n/** What `userData.destructionPart` says: a string (the part id) or an object `{ id, material?, parent?, kind? }`. */\nexport interface PartHint {\n id: string\n material?: string\n parent?: string\n kind?: string\n}\n\n/** Read `userData.destructionContains` (`{ fluid, liters }`); undefined when it holds nothing. */\nfunction containsOf(value: unknown): { fluid: string; liters: number } | undefined {\n if (!value || typeof value !== 'object') return undefined\n const v = value as Record<string, unknown>\n return typeof v.fluid === 'string' && typeof v.liters === 'number' && v.liters > 0 ? { fluid: v.fluid, liters: v.liters } : undefined\n}\n\n/** Read `userData.destructionPart` (string or object with an `id`); null when it names no part. */\nexport function partHintOf(value: unknown): PartHint | null {\n if (typeof value === 'string') return value ? { id: value } : null\n if (!value || typeof value !== 'object') return null\n const v = value as Record<string, unknown>\n if (typeof v.id !== 'string' || !v.id) return null\n const str = (x: unknown): string | undefined => (typeof x === 'string' && x ? x : undefined)\n return { id: v.id, material: str(v.material), parent: str(v.parent), kind: str(v.kind) }\n}\n\nconst METAL = /steel|iron|metal|alumin|copper|brass|bronze|tin|titan|chrome|zinc|lead/i\n\nfunction sanitizeId(name: string): string {\n let id = name\n .trim()\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '_')\n .replace(/^_+|_+$/g, '')\n if (id && /^[0-9]/.test(id)) id = `p_${id}`\n return id\n}\n\nfunction isMesh(o: Object3D): o is Mesh {\n return (o as Mesh).isMesh === true\n}\n\nfunction sizeOf(box: THREE_NS.Box3): [number, number, number] {\n return [box.max.x - box.min.x, box.max.y - box.min.y, box.max.z - box.min.z]\n}\n\n/** Inverse of the root's world pose without its scale: world space to the metric frame the spec and the world's `setTransform` use. */\nexport function specFrameInverse(THREE: ThreeNamespace, root: Object3D): THREE_NS.Matrix4 {\n root.updateMatrixWorld(true)\n const position = new THREE.Vector3()\n const quaternion = new THREE.Quaternion()\n root.matrixWorld.decompose(position, quaternion, new THREE.Vector3())\n return new THREE.Matrix4().compose(position, quaternion, new THREE.Vector3(1, 1, 1)).invert()\n}\n\n/**\n * Build a `DestructibleSpec` from a three.js object: one part per mesh (meshes sharing `userData.destructionPart` become one part), each an\n * axis-aligned box in metres in the root's frame (its position and rotation removed, its world scale kept; rotation omitted), with the material taken from `options.materialOf`, `userData.destructionMaterial`\n * or a guess from the names. Tiny meshes are merged into the part they overlap most; joints are inferred from touching parts.\n *\n * `userData.destructionContains` (`{ fluid, liters }`) makes the part a container: a hole through it leaks. `userData.destructionPowder` (`{ color }`) fills it with a dry powder or flakes that puff out of a hole. `root.userData.destructionMass` (kg) fixes the total mass, split between the parts in proportion to their volume, density and fill.\n * A mesh with `userData.destructionSkin` (a label, a coat) joins the part it overlaps most instead of becoming a part: it stays drawn and bound to that part (decals, dents) but never breaks off.\n * Meshes that are invisible or have `userData.destructionIgnore` (or sit under such an object) are skipped. The result also tells which meshes\n * became which part, ready to be passed to `bind`.\n */\nexport function specFromObject3D(THREE: ThreeNamespace, root: Object3D, options: SpecFromObjectOptions = {}): SpecFromObjectResult {\n const fallback = options.fallback ?? 'plastic'\n const minSize = options.minSize ?? 0.015\n const inv = specFrameInverse(THREE, root)\n\n // 1. collect meshes -> entries (grouped by an explicit part name)\n const entries: Entry[] = []\n const byKey = new Map<string, Entry>()\n const visit = (o: Object3D): void => {\n if (!o.visible || o.userData?.destructionIgnore) return\n if (isMesh(o) && o.geometry) {\n const geom = o.geometry\n if (!geom.boundingBox) geom.computeBoundingBox()\n if (geom.boundingBox && !geom.boundingBox.isEmpty()) {\n const box = geom.boundingBox.clone().applyMatrix4(new THREE.Matrix4().multiplyMatrices(inv, o.matrixWorld))\n const mats = Array.isArray(o.material) ? o.material : [o.material]\n const matName = mats[0]?.name ?? ''\n const ud = o.userData ?? {}\n const hint = partHintOf(ud.destructionPart)\n const material =\n options.materialOf?.(o) ??\n (typeof ud.destructionMaterial === 'string' ? (ud.destructionMaterial as string) : undefined) ??\n hint?.material ??\n guessMaterial(`${o.name} ${matName} ${typeof ud.material === 'string' ? ud.material : ''}`) ??\n fallback\n const explicit = hint?.id ?? null\n const hollow = ud.hollow === true || /hollow/i.test(o.name)\n const skin = ud.destructionSkin === true\n const fill = options.fillOf?.(o, material)\n const tags = Array.isArray(ud.destructionTags) ? (ud.destructionTags as string[]) : undefined\n const contains = containsOf(ud.destructionContains)\n const powder = typeof (ud.destructionPowder as { color?: unknown } | undefined)?.color === 'number' ? { color: (ud.destructionPowder as { color: number }).color } : undefined\n const thickness = typeof ud.destructionThickness === 'number' && ud.destructionThickness > 0 ? (ud.destructionThickness as number) : undefined\n const existing = explicit ? byKey.get(explicit) : undefined\n if (existing) {\n const before = sizeOf(existing.box)\n const bv = before[0] * before[1] * before[2]\n const ns = sizeOf(box)\n existing.box.union(box)\n existing.meshes.push(o)\n if (ns[0] * ns[1] * ns[2] > bv) existing.material = material\n existing.hollow = existing.hollow || hollow\n existing.skin = existing.skin && skin\n if (fill !== undefined) existing.fill = fill\n if (contains) existing.contains = contains\n if (powder) existing.powder = powder\n if (thickness !== undefined) existing.thickness = Math.min(existing.thickness ?? thickness, thickness)\n } else {\n const e: Entry = { key: explicit ?? `m${entries.length}`, meshes: [o], box, material, explicitId: explicit, fill, hollow, skin, tags, fixedId: !!explicit, ...(contains ? { contains } : {}), ...(powder ? { powder } : {}), ...(thickness !== undefined ? { thickness } : {}), name: o.name, parent: hint?.parent, jointKind: hint?.kind as JointKind | undefined }\n entries.push(e)\n if (explicit) byKey.set(explicit, e)\n }\n }\n }\n for (const c of o.children) visit(c)\n }\n visit(root)\n\n // 2. merge tiny meshes and skins into the touching part they overlap most\n const eps = 0.005\n const overlapVolume = (a: THREE_NS.Box3, b: THREE_NS.Box3): number => {\n const x = Math.min(a.max.x, b.max.x) - Math.max(a.min.x, b.min.x) + eps\n const y = Math.min(a.max.y, b.max.y) - Math.max(a.min.y, b.min.y) + eps\n const z = Math.min(a.max.z, b.max.z) - Math.max(a.min.z, b.min.z) + eps\n return x > 0 && y > 0 && z > 0 ? x * y * z : 0\n }\n const largest = (e: Entry) => Math.max(...sizeOf(e.box))\n const kept: Entry[] = []\n const tiny: Entry[] = []\n for (const e of entries) (e.skin || (!e.fixedId && largest(e) < minSize) ? tiny : kept).push(e)\n for (const t of tiny) {\n let best: Entry | null = null\n let bestV = 0\n for (const k of kept) {\n const v = overlapVolume(t.box, k.box)\n if (v > bestV) {\n bestV = v\n best = k\n }\n }\n if (!best) {\n // not touching anything: join the nearest part within a small distance\n let bd = 0.05\n for (const k of kept) {\n const d = k.box.distanceToPoint(t.box.getCenter(new THREE.Vector3()))\n if (d < bd) {\n bd = d\n best = k\n }\n }\n }\n if (best) {\n best.meshes.push(...t.meshes) // the box stays: a tiny mesh sits inside or on the surface of its part\n } else {\n kept.push(t) // isolated crumb: keep it as its own part\n }\n }\n\n // 3. ids, parts\n const used = new Set<string>()\n const parts: PartSpec[] = []\n const meshesOf: Record<string, Object3D[]> = {}\n let counter = 0\n for (const e of kept) {\n counter++\n let base = (e.explicitId ? sanitizeId(e.explicitId) : '') || sanitizeId(e.name) || `part_${counter}`\n let id = base\n for (let n = 2; used.has(id); n++) id = `${base}_${n}`\n used.add(id)\n base = id\n const size = sizeOf(e.box)\n const center = e.box.getCenter(new THREE.Vector3())\n const part: PartSpec = {\n id,\n material: e.material,\n shape: { kind: 'box', size: [Math.max(size[0], 0.002), Math.max(size[1], 0.002), Math.max(size[2], 0.002)] },\n position: [center.x, center.y, center.z],\n }\n const minSide = Math.min(...size)\n if (e.fill !== undefined) part.fill = e.fill\n else if (e.hollow) part.fill = 0.05\n if (e.thickness !== undefined) part.thickness = e.thickness\n else if (minSide < 0.01 && METAL.test(e.material)) {\n part.fill = e.fill ?? 1\n part.thickness = Math.max(minSide, 0.0005)\n }\n if (e.tags) part.tags = [...e.tags]\n if (e.contains) part.contains = { ...e.contains }\n if (e.powder) part.powder = { ...e.powder }\n const ao = options.anchorBelow ?? -1\n if (ao >= 0 && e.box.min.y <= ao) part.anchored = true\n parts.push(part)\n meshesOf[id] = e.meshes\n }\n\n const knownMass = root.userData?.destructionMass\n if (typeof knownMass === 'number' && knownMass > 0) {\n const shares = parts.map((p) => {\n const material = MATERIALS.find((m) => m.id === p.material)\n return material ? partMass(p, material) : 0\n })\n const total = shares.reduce((a, b) => a + b, 0)\n if (total > 0) parts.forEach((p, i) => (p.mass = (knownMass * shares[i]) / total))\n }\n\n const spec: SpecFromObjectResult['spec'] = { parts }\n if (options.name !== undefined) spec.name = options.name\n else if (root.name) spec.name = root.name\n if (options.tags) spec.tags = [...options.tags]\n spec.joints = options.joints === false ? [] : inferJoints(parts)\n // explicit attachments from `destructionPart: { parent, kind }` win over the inferred joint between the same two parts\n if (options.joints !== false) {\n const finalId = new Map<Entry, string>()\n kept.forEach((e, i) => finalId.set(e, parts[i].id))\n const idOf = new Map<string, string>()\n for (const e of kept) if (e.explicitId) idOf.set(e.explicitId, finalId.get(e)!)\n const joints: JointSpec[] = spec.joints\n for (const e of kept) {\n if (!e.parent) continue\n const id = finalId.get(e)!\n const parent = idOf.get(e.parent) ?? (used.has(sanitizeId(e.parent)) ? sanitizeId(e.parent) : null)\n if (!parent || parent === id) continue\n const at = joints.findIndex((j) => (j.a === parent && j.b === id) || (j.a === id && j.b === parent))\n const kind = e.jointKind ?? (at >= 0 ? joints[at].kind : 'resting')\n const joint: JointSpec = { id: `${parent}~${id}`, a: parent, b: id, kind }\n if (at >= 0) joints[at] = joint\n else joints.push(joint)\n }\n }\n return { spec, parts: meshesOf }\n}\n","import type { MaterialDef } from '@adatechnology/game-destruction'\nimport type { PieceFriction } from './internal'\n\n/** What a surface is to what touches it: its Coulomb friction and rolling resistance (`PieceFriction`) and its coefficient of restitution. */\nexport interface SurfaceDef extends PieceFriction {\n readonly restitution: number\n}\n\n/**\n * Coulomb friction, rolling resistance and restitution of a surface by its material. Two surfaces against each other mix the friction and the restitution by geometric mean\n * (`pieces.ts`), so each value is the coefficient of the material against itself: wood on wood 0.4 and 0.3, and then steel on wood sqrt(0.6 x 0.4) = 0.49, rubber on concrete\n * sqrt(1.0 x 0.7) = 0.84; the rolling resistance is the softer surface's (the larger).\n * Friction from the engineering tables of dry friction (The Engineering ToolBox, \"Friction and Friction Coefficients\"; Serway, Physics for Scientists and Engineers, table\n * 5.1): wood 0.25-0.5, steel 0.5-0.8 static and 0.4-0.6 sliding, glass 0.4 against other materials, ceramic 0.5, rubber 0.8-1.0, concrete and brick 0.6-0.7, plastic 0.3-0.4,\n * fabric and foam 0.5-0.8, paper 0.4. Rolling resistance (The Engineering ToolBox, \"Rolling Resistance\"): steel on steel 0.001-0.002, a hard wheel on concrete 0.01-0.02, on\n * wood 0.01, a carpet or foam 0.05-0.1. Restitution of a body bouncing on the material (drop tests): rubber 0.8, glass 0.7, steel 0.6, wood and plastic 0.5, concrete 0.4,\n * fabric and paper 0.2.\n */\nconst SURFACE_BY_KEY: ReadonlyArray<readonly [RegExp, SurfaceDef]> = [\n [/rubber|tire|tyre/, { static: 1.0, dynamic: 0.8, rolling: 0.03, restitution: 0.8 }],\n [/foam|sponge|fabric|cloth|leather|textile|carpet/, { static: 0.6, dynamic: 0.5, rolling: 0.08, restitution: 0.2 }],\n [/concrete|brick|stone|masonry|cement|asphalt|plaster/, { static: 0.7, dynamic: 0.6, rolling: 0.012, restitution: 0.4 }],\n [/steel|iron|metal|alumin|copper|brass|tin/, { static: 0.6, dynamic: 0.4, rolling: 0.002, restitution: 0.6 }],\n [/glass/, { static: 0.4, dynamic: 0.35, rolling: 0.002, restitution: 0.7 }],\n [/ceramic|porcelain|tile/, { static: 0.5, dynamic: 0.4, rolling: 0.005, restitution: 0.5 }],\n [/wood|mdf|plywood|board|cork/, { static: 0.4, dynamic: 0.3, rolling: 0.01, restitution: 0.5 }],\n [/plastic|polycarbonate|acrylic|nylon|pvc/, { static: 0.4, dynamic: 0.3, rolling: 0.01, restitution: 0.5 }],\n [/paper|cardboard|carton/, { static: 0.4, dynamic: 0.3, rolling: 0.02, restitution: 0.2 }],\n]\n\n/** The surface of a material by its id and tags (see `SURFACE_BY_KEY`), or undefined when nothing matches (the pieces' defaults then). */\nexport function surfaceOf(materialId: string, def?: MaterialDef): SurfaceDef | undefined {\n const keys = [materialId, ...(def?.tags ?? [])].join(' ').toLowerCase()\n return SURFACE_BY_KEY.find(([key]) => key.test(keys))?.[1]\n}\n\n/** The friction of a material by its id and tags (see `SURFACE_BY_KEY`), or undefined when nothing matches (the pieces' default then). */\nexport function frictionOf(materialId: string, def?: MaterialDef): PieceFriction | undefined {\n const surface = surfaceOf(materialId, def)\n return surface && { static: surface.static, dynamic: surface.dynamic, rolling: surface.rolling }\n}\n","import { debrisColor, debrisFamily, dustColor } from '@adatechnology/game-destruction'\nimport type { DestructionEvent, MaterialDef, Vec3 } from '@adatechnology/game-destruction'\nimport { DEBRIS_COLOR_VARIABLE, DUST_COLOR_VARIABLE } from '@adatechnology/game-vfx'\n\n/** How long a hit point stays the place a stage of the same part happens at (s): the stage comes in the same batch as the hit. */\nconst HIT_POINT_SECONDS = 1\n\n/** The family and the colours an effect of the event map is played with: the `{material}` of the map and the values its recipe reads. */\nexport interface FamilyPlay {\n readonly material: string\n readonly values: Readonly<Record<string, number>>\n}\n\n/** The family of the material and the colours of its debris and dust, for `vfx.play`. */\nexport function familyPlay(def: MaterialDef | undefined, partColor?: number): FamilyPlay {\n const dust = dustColor(def, partColor)\n return {\n material: debrisFamily(def),\n values: { [DEBRIS_COLOR_VARIABLE]: debrisColor(def, partColor), ...(dust !== undefined ? { [DUST_COLOR_VARIABLE]: dust } : {}) },\n }\n}\n\n/** The world point a destruction event happened at, when it carries one. */\nfunction pointOf(ev: DestructionEvent): Vec3 | undefined {\n switch (ev.type) {\n case 'hole':\n case 'crack':\n return ev.worldPoint\n case 'spall':\n case 'debris':\n return ev.point\n case 'chip':\n return ev.center\n default:\n return undefined\n }\n}\n\n/**\n * Where each part was last hit. A stage 1 carries no point of its own (only the stage 2 opening has one), so its splinters, chips or shards are thrown\n * from the hit that set it off, not from the root of the object (the middle of a house).\n */\nexport class HitPoints {\n private readonly points = new Map<string, { point: Vec3; time: number }>()\n\n note(ev: DestructionEvent, time: number): void {\n const point = pointOf(ev)\n if (!point || !('part' in ev)) return\n this.points.set(`${ev.object}|${ev.part}`, { point, time })\n }\n\n /** The last hit on the part, if it was recent. */\n of(objectId: string, partId: string, time: number): Vec3 | undefined {\n const hit = this.points.get(`${objectId}|${partId}`)\n return hit && time - hit.time <= HIT_POINT_SECONDS ? hit.point : undefined\n }\n\n forget(objectId: string): void {\n for (const key of this.points.keys()) if (key.startsWith(`${objectId}|`)) this.points.delete(key)\n }\n}\n","import { mixHex } from './math'\n\n/** Blackbody-ish stops: [temperature °C, colour]. Luminance grows with the temperature. */\nconst STOPS: Array<[number, number]> = [\n [450, 0x000000],\n [500, 0x2a0400],\n [650, 0x8a1500],\n [800, 0xd84a08],\n [950, 0xff8c14],\n [1100, 0xffc23a],\n [1250, 0xffe8a0],\n [1400, 0xffffff],\n]\n\n/**\n * Glow colour of a hot surface as `0xRRGGBB`: black (no glow) below about 450 °C, dark red around 500, orange around 800, yellow around 1100 and\n * white from 1400 °C. Brightness never decreases as the temperature rises. Use it as an emissive colour.\n */\nexport function heatColor(temperatureC: number): number {\n if (!(temperatureC > STOPS[0][0])) return 0\n const last = STOPS[STOPS.length - 1]\n if (temperatureC >= last[0]) return last[1]\n for (let i = 1; i < STOPS.length; i++) {\n const [t1, c1] = STOPS[i]\n if (temperatureC <= t1) {\n const [t0, c0] = STOPS[i - 1]\n return mixHex(c0, c1, (temperatureC - t0) / (t1 - t0))\n }\n }\n return last[1]\n}\n","import type * as THREE_NS from 'three'\n\n/** A shell mesh with its vertex positions before and after a dent, both in its own local space. */\nexport type ShellSnapshot = {\n readonly mesh: THREE_NS.Mesh\n readonly before: ArrayLike<number>\n readonly after: ArrayLike<number>\n}\n\n/**\n * How far the surface of the shells moved where `worldPoint` (a vertex of a skin: a label, a coat) lies on it, as a world vector: the displacement of the\n * nearest shell triangle, interpolated by barycentric weights. A skin that takes it moves with the shell, whatever the two meshes' vertex grids are.\n * Returns the distance (world metres) from the point to that triangle, how high above the shell the skin lies.\n */\nexport function shellDisplacementAt(THREE: typeof THREE_NS, worldPoint: THREE_NS.Vector3, shells: readonly ShellSnapshot[], out: THREE_NS.Vector3): number {\n const triangle = new THREE.Triangle()\n const corners = [new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3()] as const\n const local = new THREE.Vector3()\n const closest = new THREE.Vector3()\n const weights = new THREE.Vector3()\n const moved = new THREE.Vector3()\n let nearest = Infinity\n out.set(0, 0, 0)\n let nearestScale = 1\n for (const shell of shells) {\n shell.mesh.updateWorldMatrix(true, false)\n shell.mesh.worldToLocal(local.copy(worldPoint))\n const index = shell.mesh.geometry.index\n const triangles = index ? index.count / 3 : shell.before.length / 9\n for (let t = 0; t < triangles; t++) {\n const ids = [0, 1, 2].map((corner) => (index ? index.getX(t * 3 + corner) : t * 3 + corner))\n ids.forEach((id, corner) => corners[corner]!.set(shell.before[id * 3]!, shell.before[id * 3 + 1]!, shell.before[id * 3 + 2]!))\n triangle.set(corners[0], corners[1], corners[2])\n // a degenerate triangle (the tip of a lathe on its axis, the doubled rim of a can) has no surface to follow and no closest point (NaN must never win)\n if (triangle.getArea() <= 1e-14) continue\n triangle.closestPointToPoint(local, closest)\n const distance = closest.distanceToSquared(local)\n if (!(distance < nearest)) continue\n nearest = distance\n nearestScale = shell.mesh.matrixWorld.getMaxScaleOnAxis() || 1\n triangle.getBarycoord(closest, weights)\n moved.set(0, 0, 0)\n ids.forEach((id, corner) => {\n const weight = corner === 0 ? weights.x : corner === 1 ? weights.y : weights.z\n moved.x += weight * (shell.after[id * 3]! - shell.before[id * 3]!)\n moved.y += weight * (shell.after[id * 3 + 1]! - shell.before[id * 3 + 1]!)\n moved.z += weight * (shell.after[id * 3 + 2]! - shell.before[id * 3 + 2]!)\n })\n out.copy(moved).transformDirection(shell.mesh.matrixWorld)\n out.multiplyScalar(moved.length() * (shell.mesh.matrixWorld.getMaxScaleOnAxis() || 1))\n }\n }\n return Math.sqrt(nearest) * nearestScale\n}\n","import { createRng } from './math'\n\n/**\n * The path of a stair-step crack in a wall of units, in the wall's plane: `h` metres toward the side that went down, `u` metres up. In running bond a\n * crack through the joints goes half a unit along a bed joint and one course up a head joint, again and again, so it climbs at about 45 degrees for a\n * brick of 19 x 9 cm. `step` is the run of one unit and the rise of one course; `seed` makes the same crack every time.\n */\nexport function stairCrackPath(spec: { readonly length: number; readonly step: readonly [number, number]; readonly seed: number }): Array<[number, number]> {\n const rnd = createRng(spec.seed)\n const run = Math.max(0.02, spec.step[0] / 2)\n const rise = Math.max(0.02, spec.step[1])\n const points: Array<[number, number]> = [[0, 0]]\n let h = 0\n let u = 0\n let walked = 0\n while (walked < spec.length) {\n // a head joint is not always the next one along: now and then the crack runs on a whole unit before it climbs\n const along = run * (rnd() < 0.2 ? 2 : 1)\n h += along\n points.push([h, u])\n u += rise\n points.push([h, u])\n walked += along + rise\n }\n return points\n}\n\n/**\n * The crack as a strip of triangles over the path, `width` metres wide at its start and narrowing to `taper` of that at its end: flat (`h`, `u`)\n * pairs, three points a triangle, wound counter-clockwise seen from +h × +u.\n */\nexport function stairCrackStrip(points: ReadonlyArray<readonly [number, number]>, width: number, taper: number): number[] {\n const out: number[] = []\n const n = points.length - 1\n for (let k = 0; k < n; k++) {\n const [h0, u0] = points[k]!\n const [h1, u1] = points[k + 1]!\n const length = Math.hypot(h1 - h0, u1 - u0) || 1\n const half0 = (width * (1 - ((1 - taper) * k) / n)) / 2\n const half1 = (width * (1 - ((1 - taper) * (k + 1)) / n)) / 2\n // the side of the segment, and a joint's worth past each end so the steps meet without gaps\n const sh = -(u1 - u0) / length\n const su = (h1 - h0) / length\n const eh = ((h1 - h0) / length) * half0\n const eu = ((u1 - u0) / length) * half0\n const a: [number, number] = [h0 - eh - sh * half0, u0 - eu - su * half0]\n const b: [number, number] = [h1 + eh - sh * half1, u1 + eu - su * half1]\n const c: [number, number] = [h1 + eh + sh * half1, u1 + eu + su * half1]\n const d: [number, number] = [h0 - eh + sh * half0, u0 - eu + su * half0]\n out.push(...a, ...b, ...c, ...a, ...c, ...d)\n }\n return out\n}\n","import type * as THREE_NS from 'three'\nimport type { Dent } from '@adatechnology/game-destruction'\nimport { heatColor } from './heat'\nimport type { Decal, HostVis, MeshVis, PartVis } from './internal'\nimport { clamp, createRng, lerp } from './math'\nimport { shellDisplacementAt, type ShellSnapshot } from './skin-dent'\nimport { pushFittedBoxes } from './fitted-boxes'\nimport { stairCrackPath, stairCrackStrip } from './stair-crack'\n\ntype Mesh = THREE_NS.Mesh\n\nconst POS_ATTR = 'position'\n\nfunction positionAttr(geo: THREE_NS.BufferGeometry): THREE_NS.BufferAttribute | null {\n const a = geo.getAttribute(POS_ATTR) as THREE_NS.BufferAttribute | THREE_NS.InterleavedBufferAttribute | undefined\n return a && !(a as THREE_NS.InterleavedBufferAttribute).isInterleavedBufferAttribute ? (a as THREE_NS.BufferAttribute) : null\n}\n\nfunction materialsOf(m: THREE_NS.Material | THREE_NS.Material[]): THREE_NS.Material[] {\n return Array.isArray(m) ? m : [m]\n}\n\nfunction colorOf(m: THREE_NS.Material): THREE_NS.Color | null {\n const c = (m as THREE_NS.MeshStandardMaterial).color\n return c && (c as THREE_NS.Color).isColor ? c : null\n}\n\n/** Shared resources for decals (one geometry, a few materials) created lazily and disposed together. */\nexport class DecalKit {\n private disc: THREE_NS.CircleGeometry | null = null\n private discMat: THREE_NS.MeshBasicMaterial | null = null\n private lineMats = new Map<number, THREE_NS.LineBasicMaterial>()\n private patchMats = new Map<number, THREE_NS.MeshBasicMaterial>()\n constructor(private readonly THREE: typeof THREE_NS) {}\n\n discGeometry(): THREE_NS.CircleGeometry {\n return (this.disc ??= new this.THREE.CircleGeometry(1, 14))\n }\n\n discMaterial(): THREE_NS.MeshBasicMaterial {\n return (this.discMat ??= new this.THREE.MeshBasicMaterial({\n color: 0x050505,\n transparent: true,\n opacity: 0.92,\n depthWrite: false,\n polygonOffset: true,\n polygonOffsetFactor: -4,\n polygonOffsetUnits: -4,\n side: this.THREE.DoubleSide,\n }))\n }\n\n /** Opaque patch in the colour of what shows under a spalled coat. */\n patchMaterial(color: number): THREE_NS.MeshBasicMaterial {\n let m = this.patchMats.get(color)\n if (!m) {\n m = new this.THREE.MeshBasicMaterial({ color, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -3, polygonOffsetUnits: -3 })\n this.patchMats.set(color, m)\n }\n return m\n }\n\n lineMaterial(color: number): THREE_NS.LineBasicMaterial {\n let m = this.lineMats.get(color)\n if (!m) {\n m = new this.THREE.LineBasicMaterial({ color, transparent: true, opacity: 0.9, depthWrite: false })\n this.lineMats.set(color, m)\n }\n return m\n }\n\n dispose(): void {\n this.disc?.dispose()\n this.discMat?.dispose()\n for (const m of this.lineMats.values()) m.dispose()\n for (const m of this.patchMats.values()) m.dispose()\n this.patchMats.clear()\n this.disc = null\n this.discMat = null\n this.lineMats.clear()\n }\n}\n\nconst tmpV = (THREE: typeof THREE_NS) => new THREE.Vector3()\n\n/**\n * The positions a host drew a range with before it took the range out of the merged mesh to draw it another way (the house renderer collapses the range of a\n * wall it draws with holes, `userData.collapsedRanges`, and keeps the first positions in `userData.plainPositions`): a part that leaves the mesh takes those,\n * or it would leave as a collapsed, invisible range that still carries its decals and is still shot at.\n */\nexport function plainPositions(mesh: THREE_NS.Mesh, v0: number, v1: number): Float32Array | null {\n const { collapsedRanges, plainPositions: plain } = mesh.userData as { collapsedRanges?: ReadonlyArray<readonly [number, number]>; plainPositions?: Float32Array }\n if (!plain || !collapsedRanges?.some(([a, b]) => a < v1 && b > v0)) return null\n return plain\n}\n\n/** A whole mesh that leaves with its part draws again the ranges its host collapsed (`plainPositions`): it is the part now, and the part is still there. */\nexport function showCollapsedRanges(mesh: THREE_NS.Mesh): void {\n const data = mesh.userData as { collapsedRanges?: Array<[number, number]>; plainPositions?: Float32Array }\n const plain = data.plainPositions\n const position = mesh.geometry?.getAttribute(POS_ATTR) as THREE_NS.BufferAttribute | undefined\n if (!plain || !data.collapsedRanges?.length || !position) return\n const array = position.array as Float32Array\n for (const [v0, v1] of data.collapsedRanges) array.set(plain.subarray(v0 * 3, v1 * 3), v0 * 3)\n data.collapsedRanges = []\n position.needsUpdate = true\n mesh.geometry.computeBoundingBox()\n mesh.geometry.computeBoundingSphere()\n}\n\n/** Mesh-level visual changes: copy-on-write geometry and materials, dents, decals, char, glow, melt, hiding, restoring. */\n/** A dent reaches at least this many vertices of a mesh: fewer and the mesh cannot show its curve (it would be invisible or a sharp spike). */\nconst MIN_DENT_VERTICES = 10\n/** The reach of a dent that had to widen is this many times the distance to the farthest of those vertices, so they all get a falloff above zero. */\nconst WIDEN_MARGIN = 1.1\n/** A skin follows its shell this share of the way in: the two meshes triangulate the dent differently, and a skin left a bit outside never lets the shell through. */\nconst SKIN_FOLLOW = 0.85\n/** And stays this many metres outside, so the thin gap of a label (a millimetre) survives the two meshes triangulating the rim differently. */\nconst SKIN_SLACK = 0.0005\n/** Extra slack per metre a skin lies above its shell: skins stacked on one another (a label and its band) keep their order while the dent bends them. */\nconst SKIN_LAYER_SLACK = 4\n/** And at least this many times the distance to the nearest vertex, so even the nearest one is pushed visibly. */\nconst NEAREST_MARGIN = 1.5\n/**\n * The first positions of a merged mesh: `userData._p0` when another drawing keeps them there (the house renderer, which collapses the ranges of what it\n * draws itself, `userData.collapsedRanges`), else those of the geometry it was bound with.\n */\nconst basePositions = (host: { mesh: Mesh; origGeometry: THREE_NS.BufferGeometry }): Float32Array | null => {\n const p0 = host.mesh.userData._p0 as Float32Array | undefined\n if (p0) return p0\n const op = positionAttr(host.origGeometry)\n return op ? (op.array as unknown as Float32Array) : null\n}\n\n/** Collapses in `arr` the ranges another drawing hides on the mesh (`userData.collapsedRanges`, each to its first vertex). */\nconst collapseForeign = (mesh: Mesh, arr: Float32Array): void => {\n for (const [v0, v1] of (mesh.userData.collapsedRanges as Array<[number, number]> | undefined) ?? []) {\n for (let k = v0 + 1; k < v1; k++) {\n arr[k * 3] = arr[v0 * 3]!\n arr[k * 3 + 1] = arr[v0 * 3 + 1]!\n arr[k * 3 + 2] = arr[v0 * 3 + 2]!\n }\n }\n}\n\n/** Metres along its normal a mark looks for the drawn face under it (`onFace`). */\nconst DECAL_SNAP = 0.03\n/** Metres a stair-step crack sits off the face, and how narrow its far end is (share of its width). */\nconst STAIR_CRACK_LIFT = 0.002\nconst STAIR_CRACK_TAPER = 0.35\n\nexport class Visuals {\n readonly kit: DecalKit\n private readonly a: THREE_NS.Vector3\n private readonly b: THREE_NS.Vector3\n private readonly m4: THREE_NS.Matrix4\n private readonly ray: THREE_NS.Raycaster\n private readonly box: THREE_NS.Box3\n private readonly t: THREE_NS.Vector3\n private readonly lbox: THREE_NS.Box3\n /** Total live decals across meshes (kept in sync by add/remove). */\n decalCount = 0\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly lowQuality: boolean,\n private readonly decalCap: number,\n ) {\n this.kit = new DecalKit(THREE)\n this.a = tmpV(THREE)\n this.b = tmpV(THREE)\n this.m4 = new THREE.Matrix4()\n this.ray = new THREE.Raycaster()\n // batched meshes leave the camera layer (createStaticBatcher), not the world: rays still find them\n this.ray.layers.enableAll()\n this.box = new THREE.Box3()\n this.t = tmpV(THREE)\n this.lbox = new THREE.Box3()\n }\n\n /**\n * @param range vertex range `[v0, v1)` of a merged mesh this part is drawn by (see `MeshRange`); `hosts` caches the shared state per mesh for one `bind`.\n */\n makeMeshVis(mesh: Mesh, home: string, range?: [number, number], hosts?: Map<Mesh, HostVis>): MeshVis {\n let host: HostVis | null = null\n if (range) {\n host = hosts?.get(mesh) ?? null\n if (!host) {\n host = { mesh, origGeometry: mesh.geometry, origMaterial: mesh.material, ownGeo: false, work: null, ownMat: false, sharers: [] }\n hosts?.set(mesh, host)\n }\n }\n const mv: MeshVis = {\n mesh,\n home,\n origGeometry: mesh.geometry,\n origMaterial: mesh.material,\n origVisible: mesh.visible,\n origParent: mesh.parent,\n origPosition: mesh.position.clone(),\n origQuaternion: mesh.quaternion.clone(),\n origScale: mesh.scale.clone(),\n ownMat: false,\n ownGeo: false,\n work: null,\n baseColors: null,\n decals: [],\n meltApplied: 0,\n bottomY: 0,\n moved: false,\n host,\n range: range ? [range[0], range[1]] : null,\n merged: host && range ? { host, range: [range[0], range[1]] } : null,\n loose: false,\n collapsed: false,\n hidden: false,\n touched: false,\n charK: 0,\n charHex: 0,\n glowHex: 0,\n glowK: 0,\n }\n host?.sharers.push(mv)\n return mv\n }\n\n vertexCount(mv: MeshVis): number {\n if (mv.range) return mv.range[1] - mv.range[0]\n return mv.mesh.geometry.getAttribute(POS_ATTR)?.count ?? 0\n }\n\n /** Is the part drawn? (A ranged part shares its mesh, so `mesh.visible` says nothing about it.) */\n shown(mv: MeshVis): boolean {\n return mv.host ? !mv.hidden : mv.mesh.visible\n }\n\n /** Box of the part's vertices in the space of its mesh (the whole geometry for a plain mesh). */\n localBox(mv: MeshVis, out: THREE_NS.Box3): THREE_NS.Box3 {\n out.makeEmpty()\n if (!mv.host || !mv.range) {\n const geo = mv.mesh.geometry\n if (!geo.boundingBox) geo.computeBoundingBox()\n return geo.boundingBox ? out.copy(geo.boundingBox) : out\n }\n const arr = mv.host.work ?? (positionAttr(mv.mesh.geometry)?.array as unknown as ArrayLike<number> | undefined)\n if (!arr) return out\n for (let i = mv.range[0] * 3; i < mv.range[1] * 3; i += 3) out.expandByPoint(this.t.set(arr[i], arr[i + 1], arr[i + 2]))\n return out\n }\n\n /** Box of the part in world space. */\n /** Appends the boxes that follow the mesh in the world (`pushFittedBoxes`) to `out`. */\n fittedBoxes(mv: MeshVis, out: number[]): void {\n const box = new this.THREE.Box3()\n if (mv.host) this.localBox(mv, box)\n else {\n const geometry = mv.mesh.geometry\n if (!geometry.boundingBox) geometry.computeBoundingBox()\n if (geometry.boundingBox) box.copy(geometry.boundingBox)\n else box.makeEmpty()\n }\n if (box.isEmpty()) return\n mv.mesh.updateWorldMatrix(true, false)\n pushFittedBoxes(box, mv.mesh.matrixWorld, out)\n }\n\n worldBox(mv: MeshVis, out: THREE_NS.Box3): THREE_NS.Box3 {\n if (!mv.host) return out.setFromObject(mv.mesh)\n this.localBox(mv, out)\n mv.mesh.updateWorldMatrix(true, false)\n return out.isEmpty() ? out : out.applyMatrix4(mv.mesh.matrixWorld)\n }\n\n private readonly tints = new WeakMap<MeshVis, THREE_NS.Color | null>()\n\n /**\n * Average vertex colour of a mesh whose material uses `vertexColors` (computed once per mesh, from its original geometry), else null. Fragments\n * and debris of such a mesh multiply it by `material.color`; without it they come out white.\n */\n vertexTint(mv: MeshVis): THREE_NS.Color | null {\n if (this.tints.has(mv)) return this.tints.get(mv) ?? null\n let tint: THREE_NS.Color | null = null\n const used = materialsOf(mv.origMaterial).some((m) => (m as THREE_NS.MeshStandardMaterial).vertexColors === true)\n const attr = used ? (mv.origGeometry.getAttribute('color') as THREE_NS.BufferAttribute | undefined) : undefined\n if (attr && attr.count > 0 && attr.itemSize >= 3) {\n // a ranged part averages its own vertices only\n const from = mv.merged ? mv.merged.range[0] : 0\n const to = mv.merged ? Math.min(attr.count, mv.merged.range[1]) : attr.count\n let r = 0, g = 0, b = 0\n for (let i = from; i < to; i++) {\n r += attr.getX(i)\n g += attr.getY(i)\n b += attr.getZ(i)\n }\n const n = Math.max(1, to - from)\n tint = new this.THREE.Color(r / n, g / n, b / n)\n }\n this.tints.set(mv, tint)\n return tint\n }\n\n /** Colour of the original material (before any char) times the vertex tint, `0xRRGGBB`, or -1. */\n baseColorHex(mv: MeshVis): number {\n const c = mv.baseColors?.[0] ?? colorOf(materialsOf(mv.origMaterial)[0])\n if (!c) return -1\n const tint = this.vertexTint(mv)\n return tint ? c.clone().multiply(tint).getHex() : c.getHex()\n }\n\n /** Is the original material transparent? */\n isTransparent(mv: MeshVis): boolean {\n return materialsOf(mv.origMaterial).some((m) => m.transparent && m.opacity < 1)\n }\n\n ownMaterial(mv: MeshVis): void {\n if (mv.ownMat) return\n mv.ownMat = true\n const src = materialsOf(mv.origMaterial)\n const cloned = src.map((m) => m.clone())\n mv.baseColors = src.map((m) => colorOf(m)?.clone() ?? new this.THREE.Color(0x888888))\n mv.mesh.material = Array.isArray(mv.origMaterial) ? cloned : cloned[0]\n }\n\n /** Clone the geometry (vertex edits); false when its positions cannot be edited. */\n ownGeometry(mv: MeshVis): boolean {\n if (mv.host) return this.ownHostGeometry(mv.host)\n if (mv.ownGeo) return true\n const pos = positionAttr(mv.mesh.geometry)\n if (!pos) return false\n mv.ownGeo = true\n const g = mv.mesh.geometry.clone()\n mv.mesh.geometry = g\n mv.work = new Float32Array((positionAttr(g) as THREE_NS.BufferAttribute).array as ArrayLike<number>)\n return true\n }\n\n private ownHostGeometry(host: HostVis): boolean {\n if (host.ownGeo) return true\n const pos = positionAttr(host.mesh.geometry)\n if (!pos) return false\n host.ownGeo = true\n const g = host.mesh.geometry.clone()\n host.mesh.geometry = g\n host.work = new Float32Array(basePositions(host) ?? ((positionAttr(g) as THREE_NS.BufferAttribute).array as ArrayLike<number>))\n return true\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Dents\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n /**\n * Push the vertices of the mesh within `dent.radius` of `worldPoint` inwards along `worldNormal` by `depth * (1 - (d/r)^2)^2`.\n * Returns false when nothing was changed (too far, low quality on a heavy mesh, or no editable positions).\n */\n applyDent(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, dent: Dent, reachWorld = 0): boolean {\n const mesh = mv.mesh\n if (this.lowQuality && this.vertexCount(mv) > 20000) return false\n mesh.updateWorldMatrix(true, false)\n const s = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n const lp = mesh.worldToLocal(this.a.copy(worldPoint))\n const ln = this.b.copy(worldNormal).transformDirection(this.m4.copy(mesh.matrixWorld).invert()).normalize()\n const r = Math.max(dent.radius, reachWorld) / s\n const depth = dent.depth / s\n // quick reject: the point must be near the mesh bounds\n const geo = mesh.geometry\n let bb: THREE_NS.Box3 | null\n if (mv.host) bb = this.localBox(mv, this.lbox)\n else {\n if (!geo.boundingBox) geo.computeBoundingBox()\n bb = geo.boundingBox\n }\n if (bb && !bb.isEmpty() && bb.distanceToPoint(lp) > r) return false\n if (!this.ownGeometry(mv)) return false\n const work = (mv.host ? mv.host.work : mv.work) as Float32Array\n const pos = positionAttr(mesh.geometry) as THREE_NS.BufferAttribute\n const from = mv.range ? mv.range[0] * 3 : 0\n const to = mv.range ? mv.range[1] * 3 : work.length\n const reach = r\n const reach2 = reach * reach\n for (let i = from; i < to; i += 3) {\n const dx = work[i] - lp.x\n const dy = work[i + 1] - lp.y\n const dz = work[i + 2] - lp.z\n const d2 = dx * dx + dy * dy + dz * dz\n if (d2 >= reach2) continue\n const f = 1 - d2 / reach2\n const k = depth * f * f\n work[i] -= ln.x * k\n work[i + 1] -= ln.y * k\n work[i + 2] -= ln.z * k\n }\n mv.touched = true\n this.writePositions(mv, pos)\n return true\n }\n\n /**\n * World radius a dent needs on this mesh to reach `MIN_DENT_VERTICES` vertices (the dent's own radius when the mesh is fine enough). A part with several meshes\n * (a shell and its label) must dent them all with the largest of these, so the skin and the shell follow the same smooth surface and never cross.\n */\n dentReach(mv: MeshVis, worldPoint: THREE_NS.Vector3, dent: Dent): number {\n const mesh = mv.mesh\n mesh.updateWorldMatrix(true, false)\n const s = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n const lp = mesh.worldToLocal(this.a.copy(worldPoint))\n const source = (mv.host ? mv.host.work : mv.work) ?? ((positionAttr(mesh.geometry) as THREE_NS.BufferAttribute | undefined)?.array as ArrayLike<number> | undefined)\n if (!source) return dent.radius\n // a mesh the dent does not touch (the far cap of a can) must not widen it\n let bounds: THREE_NS.Box3 | null\n if (mv.host) bounds = this.localBox(mv, this.lbox)\n else {\n if (!mesh.geometry.boundingBox) mesh.geometry.computeBoundingBox()\n bounds = mesh.geometry.boundingBox\n }\n if (bounds && !bounds.isEmpty() && bounds.distanceToPoint(lp) > dent.radius / s) return dent.radius\n const from = mv.range ? mv.range[0] * 3 : 0\n const to = mv.range ? mv.range[1] * 3 : source.length\n const r2 = (dent.radius / s) ** 2\n const distances: number[] = []\n let inside = 0\n for (let i = from; i < to; i += 3) {\n const dx = source[i]! - lp.x\n const dy = source[i + 1]! - lp.y\n const dz = source[i + 2]! - lp.z\n const d2 = dx * dx + dy * dy + dz * dz\n if (d2 < r2) inside++\n distances.push(d2)\n }\n if (inside >= MIN_DENT_VERTICES || distances.length < MIN_DENT_VERTICES) return dent.radius\n distances.sort((x, y) => x - y)\n const nearest = Math.sqrt(distances[0]!)\n return Math.max(dent.radius, Math.sqrt(distances[MIN_DENT_VERTICES - 1]!) * s * WIDEN_MARGIN, nearest * s * NEAREST_MARGIN)\n }\n\n /**\n * Dent all the meshes of a part. The shells take the dent as `applyDent` gives it; a skin (label, coat: `userData.destructionSkin`) sits a hair above its shell\n * and moves with the shell's surface instead (see `shellDisplacementAt`), so the shell never shows through it whatever the two meshes' vertex grids are.\n */\n applyPartDent(meshes: readonly MeshVis[], worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, dent: Dent, reachWorld: number): void {\n const isSkin = (mv: MeshVis): boolean => mv.mesh.userData.destructionSkin === true && !mv.host\n const shells = meshes.filter((mv) => !isSkin(mv))\n const snapshots: ShellSnapshot[] = []\n for (const mv of shells) {\n const heavy = this.lowQuality && this.vertexCount(mv) > 20000\n const plain = !mv.host && !heavy && this.ownGeometry(mv) && mv.work\n const before = plain ? new Float32Array(mv.work as Float32Array) : null\n this.applyDent(mv, worldPoint, worldNormal, dent, reachWorld)\n if (before) snapshots.push({ mesh: mv.mesh, before, after: mv.work as Float32Array })\n }\n const displacement = this.t\n const vertex = this.a\n for (const mv of meshes) {\n if (!isSkin(mv)) continue\n if (snapshots.length === 0) {\n this.applyDent(mv, worldPoint, worldNormal, dent, reachWorld)\n continue\n }\n if (!this.ownGeometry(mv)) continue\n const work = mv.work as Float32Array\n const mesh = mv.mesh\n mesh.updateWorldMatrix(true, false)\n const toLocal = this.m4.copy(mesh.matrixWorld).invert()\n const scale = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n let touched = false\n for (let i = 0; i < work.length; i += 3) {\n vertex.set(work[i]!, work[i + 1]!, work[i + 2]!).applyMatrix4(mesh.matrixWorld)\n if (vertex.distanceTo(worldPoint) > reachWorld) continue\n const height = shellDisplacementAt(this.THREE, vertex, snapshots, displacement)\n const length = displacement.length()\n if (length === 0) continue\n // the shell's facets lie outside a dip (deeper than the shell, the skin would sink under it) and inside a rim (the smooth dent is shallower there): take the shallower of the two\n const falloff = 1 - (vertex.distanceTo(worldPoint) / reachWorld) ** 2\n const smooth = dent.depth * falloff * falloff\n const pull = Math.max(0, Math.min(length, smooth) * SKIN_FOLLOW - SKIN_SLACK - height * SKIN_LAYER_SLACK)\n displacement.transformDirection(toLocal).multiplyScalar(pull / scale)\n work[i] += displacement.x\n work[i + 1] += displacement.y\n work[i + 2] += displacement.z\n touched = true\n }\n if (touched) this.writePositions(mv, positionAttr(mesh.geometry) as THREE_NS.BufferAttribute)\n }\n }\n\n /** Copy `work` (dents) into the geometry, adding the melt sag when the mesh is melting. */\n private writePositions(mv: MeshVis, pos: THREE_NS.BufferAttribute): void {\n if (mv.host) {\n this.rebuildHost(mv.host)\n return\n }\n const work = mv.work as Float32Array\n const arr = pos.array as unknown as Float32Array\n const melt = mv.meltApplied\n if (melt <= 0 || (this.lowQuality && work.length / 3 > 20000)) {\n arr.set(work)\n } else {\n const geo = mv.mesh.geometry\n if (!geo.boundingBox) geo.computeBoundingBox()\n const bb = geo.boundingBox as THREE_NS.Box3\n const h = Math.max(1e-4, bb.max.y - bb.min.y)\n const minY = bb.min.y\n for (let i = 0, v = 0; i < work.length; i += 3, v++) {\n const n = ((Math.imul(v + 1, 2654435761) >>> 0) % 1000) / 1000\n const n2 = ((Math.imul(v + 7, 40503) >>> 0) % 1000) / 1000\n const lowness = 1 - (work[i + 1] - minY) / h // 1 at the bottom, 0 at the top\n const spread = 1 + 0.12 * melt * (0.4 + n2) * (0.3 + lowness)\n arr[i] = work[i] * spread\n arr[i + 2] = work[i + 2] * spread\n arr[i + 1] = Math.max(minY, work[i + 1] - n * melt * h * 0.08)\n }\n }\n pos.needsUpdate = true\n const geo = mv.mesh.geometry\n geo.computeVertexNormals()\n geo.boundingBox = null\n geo.boundingSphere = null\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Decals\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n /**\n * The point on the drawn face of `mesh` under a world point, within `DECAL_SNAP` metres along the normal: the world's box of a part and the face\n * the renderer drew (a coat of plaster, a merged house mesh) can be a few millimetres apart, and a mark behind the drawn face does not show.\n */\n private onFace(mesh: Mesh, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3): THREE_NS.Vector3 {\n if (!(mesh as { isMesh?: boolean }).isMesh || !mesh.geometry?.attributes?.position) return worldPoint\n const n = worldNormal.clone().normalize()\n this.ray.set(worldPoint.clone().addScaledVector(n, DECAL_SNAP), n.clone().negate())\n this.ray.near = 0\n this.ray.far = 2 * DECAL_SNAP\n const hits: THREE_NS.Intersection[] = []\n mesh.raycast(this.ray, hits)\n // a wall the house cut where it was shot is drawn by a mesh of its own next to the merged one (`breach-shell` of the house renderer); where it is\n // cut (`userData.cutAt`), the mark goes on what shows through (`userData.behind`: the bricks)\n for (const c of mesh.parent?.children ?? []) {\n if (c === mesh || c.name !== 'breach-shell') continue\n c.raycast(this.ray, hits)\n const behind = (c.userData.behind as (() => THREE_NS.Object3D | null) | undefined)?.()\n if (behind) behind.raycast(this.ray, hits)\n }\n let best: THREE_NS.Intersection | null = null\n for (const h of hits) {\n if ((h.object.userData.cutAt as ((p: THREE_NS.Vector3) => boolean) | undefined)?.(h.point)) continue\n if (h.face && h.face.normal.clone().transformDirection(h.object.matrixWorld).dot(n) <= 0.3) continue\n if (!best || Math.abs(h.distance - DECAL_SNAP) < Math.abs(best.distance - DECAL_SNAP)) best = h\n }\n return best ? best.point : worldPoint\n }\n\n /** Decal pose in mesh space: position and a rotation taking +Z to the surface normal. */\n private decalPose(mesh: Mesh, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, lift: number): { s: number; pos: THREE_NS.Vector3; quat: THREE_NS.Quaternion } {\n mesh.updateWorldMatrix(true, false)\n const s = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n const ln = worldNormal.clone().transformDirection(this.m4.copy(mesh.matrixWorld).invert()).normalize()\n const pos = mesh.worldToLocal(this.onFace(mesh, worldPoint, worldNormal).clone()).addScaledVector(ln, lift / s)\n const quat = new this.THREE.Quaternion().setFromUnitVectors(new this.THREE.Vector3(0, 0, 1), ln)\n return { s, pos, quat }\n }\n\n private addDecal(mv: MeshVis, decal: Decal): void {\n decal.obj.userData.destructionDebris = true\n mv.mesh.add(decal.obj)\n mv.decals.push(decal)\n this.decalCount++\n while (mv.decals.length > 48 || this.decalCount > this.decalCap) {\n const old = mv.decals.shift()\n if (!old) break\n this.disposeDecal(old)\n }\n }\n\n private disposeDecal(d: Decal): void {\n d.obj.parent?.remove(d.obj)\n d.geometry?.dispose()\n this.decalCount = Math.max(0, this.decalCount - 1)\n }\n\n /**\n * Takes away the decals of a mesh that sit inside a box (world `center`, `half` extents along the axes of the world `rotation`): the surface they\n * marked is gone (a unit came out of the wall with its bullet holes and spalls).\n */\n clearDecals(mv: MeshVis, center: THREE_NS.Vector3, half: THREE_NS.Vector3, rotation: THREE_NS.Quaternion): void {\n const inv = rotation.clone().invert()\n const p = new this.THREE.Vector3()\n for (let i = mv.decals.length - 1; i >= 0; i--) {\n const d = mv.decals[i]!\n d.obj.getWorldPosition(p).sub(center).applyQuaternion(inv)\n if (Math.abs(p.x) > half.x || Math.abs(p.y) > half.y || Math.abs(p.z) > half.z) continue\n this.disposeDecal(d)\n mv.decals.splice(i, 1)\n }\n }\n\n addHole(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, diameter: number): void {\n const { s, pos, quat } = this.decalPose(mv.mesh, worldPoint, worldNormal, 0.0025)\n const work = (mv.host ? mv.host.work : mv.work) as Float32Array | undefined\n if (work && mv.touched) {\n const ln = worldNormal.clone().transformDirection(this.m4.copy(mv.mesh.matrixWorld).invert()).normalize()\n let minDistSq = Infinity\n let nearestDisp = 0\n const from = mv.range ? mv.range[0] * 3 : 0\n const to = mv.range ? mv.range[1] * 3 : work.length\n for (let i = from; i < to; i += 3) {\n const dx = work[i]! - pos.x\n const dy = work[i + 1]! - pos.y\n const dz = work[i + 2]! - pos.z\n const d2 = dx * dx + dy * dy + dz * dz\n if (d2 < minDistSq) {\n minDistSq = d2\n nearestDisp = dx * ln.x + dy * ln.y + dz * ln.z\n }\n }\n if (minDistSq < (0.06 / s) ** 2 && nearestDisp < 0) {\n pos.addScaledVector(ln, nearestDisp)\n }\n }\n const disc = new this.THREE.Mesh(this.kit.discGeometry(), this.kit.discMaterial())\n disc.position.copy(pos)\n disc.quaternion.copy(quat)\n disc.scale.setScalar((Math.max(0.004, diameter) * 0.5 * 1.25) / s)\n disc.renderOrder = 2\n this.addDecal(mv, { obj: disc })\n }\n\n /** A patch where a surface coat came off, in the colour of the core under it; drawn under the bullet holes. */\n addSpall(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, radius: number, color: number): void {\n const { s, pos, quat } = this.decalPose(mv.mesh, worldPoint, worldNormal, 0.0015)\n const disc = new this.THREE.Mesh(this.kit.discGeometry(), this.kit.patchMaterial(color))\n disc.position.copy(pos)\n disc.quaternion.copy(quat)\n disc.scale.setScalar(Math.max(0.01, radius) / s)\n disc.renderOrder = 1\n this.addDecal(mv, { obj: disc })\n }\n\n /** A star of jagged lines: `rays` rays up to `length` metres, seeded so the same event always draws the same star. */\n addCrack(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, rays: number, length: number, color: number, seed: number): void {\n const { s, pos, quat } = this.decalPose(mv.mesh, worldPoint, worldNormal, 0.002)\n const rnd = createRng(seed)\n const verts: number[] = []\n const n = clamp(Math.round(rays), 3, 16)\n const L = Math.max(0.02, length) / s\n for (let r = 0; r < n; r++) {\n let ang = (r / n) * Math.PI * 2 + (rnd() - 0.5) * 0.5\n let x = 0\n let y = 0\n const segs = 3\n const total = L * (0.6 + 0.4 * rnd())\n for (let k = 0; k < segs; k++) {\n const step = (total / segs) * (0.7 + 0.6 * rnd())\n ang += (rnd() - 0.5) * 0.45\n const nx = x + Math.cos(ang) * step\n const ny = y + Math.sin(ang) * step\n verts.push(x, y, 0, nx, ny, 0)\n if (k > 0 && rnd() < 0.5) {\n const ba = ang + (rnd() < 0.5 ? -1 : 1) * (0.5 + rnd() * 0.5)\n const bl = step * (0.6 + 0.6 * rnd())\n verts.push(nx, ny, 0, nx + Math.cos(ba) * bl, ny + Math.sin(ba) * bl, 0)\n }\n x = nx\n y = ny\n }\n }\n // a faint ring around the impact\n const ringR = L * 0.12\n for (let k = 0; k < 8; k++) {\n const a0 = (k / 8) * Math.PI * 2\n const a1 = ((k + 1) / 8) * Math.PI * 2\n if (rnd() < 0.75) verts.push(Math.cos(a0) * ringR, Math.sin(a0) * ringR, 0, Math.cos(a1) * ringR, Math.sin(a1) * ringR, 0)\n }\n const geo = new this.THREE.BufferGeometry()\n geo.setAttribute('position', new this.THREE.Float32BufferAttribute(verts, 3))\n const lines = new this.THREE.LineSegments(geo, this.kit.lineMaterial(color))\n lines.position.copy(pos)\n lines.quaternion.copy(quat)\n lines.renderOrder = 2\n this.addDecal(mv, { obj: lines, geometry: geo })\n }\n\n /**\n * A stair-step crack through the joints of a wall (settlement): from `worldPoint` on the face whose outward normal is `worldNormal`, climbing toward\n * `worldToward` (the side that went down) one unit at a time, `width` metres wide at its start. A strip of triangles in the mesh's space, owned by the\n * part's marks: it goes with them (cleared, restored, disposed).\n */\n addStairCrack(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, worldToward: THREE_NS.Vector3, spec: { length: number; step: readonly [number, number]; width: number; color: number; seed: number }): void {\n const mesh = mv.mesh\n mesh.updateWorldMatrix(true, false)\n const n = worldNormal.clone().normalize()\n const up = new this.THREE.Vector3(0, 1, 0).addScaledVector(n, -n.y).normalize()\n const side = worldToward.clone().addScaledVector(n, -worldToward.dot(n)).addScaledVector(up, -worldToward.dot(up))\n if (side.lengthSq() < 1e-8) side.crossVectors(up, n)\n side.normalize()\n const start = this.onFace(mesh, worldPoint, n).clone().addScaledVector(n, STAIR_CRACK_LIFT)\n const flat = stairCrackStrip(stairCrackPath({ length: spec.length, step: spec.step, seed: spec.seed }), spec.width, STAIR_CRACK_TAPER)\n // the strip is wound counter-clockwise from side x up; it has to face out of the wall\n const flip = new this.THREE.Vector3().crossVectors(side, up).dot(n) < 0\n const verts: number[] = []\n const point = this.a\n for (let i = 0; i < flat.length; i += 6) {\n const order = flip ? [0, 2, 1] : [0, 1, 2]\n for (const k of order) {\n point.copy(start).addScaledVector(side, flat[i + k * 2]!).addScaledVector(up, flat[i + k * 2 + 1]!)\n mesh.worldToLocal(point)\n verts.push(point.x, point.y, point.z)\n }\n }\n const geo = new this.THREE.BufferGeometry()\n geo.setAttribute('position', new this.THREE.Float32BufferAttribute(verts, 3))\n const strip = new this.THREE.Mesh(geo, this.kit.patchMaterial(spec.color))\n strip.renderOrder = 2\n this.addDecal(mv, { obj: strip, geometry: geo })\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Settlement\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n /**\n * Moves the part's vertices and its marks down by `dropAt(world point)` metres (negative: up), where each of them is: a part that settled more at\n * one end tilts. Writes the geometry unless `write` is false (several parts of one merged mesh are then written once by `commit`).\n */\n sink(mv: MeshVis, dropAt: (world: THREE_NS.Vector3) => number, write = true): boolean {\n if (!this.ownGeometry(mv)) return false\n const mesh = mv.mesh\n mesh.updateWorldMatrix(true, false)\n const scale = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n const down = this.b.set(0, -1, 0).transformDirection(this.m4.copy(mesh.matrixWorld).invert())\n const work = (mv.host ? mv.host.work : mv.work) as Float32Array\n const from = mv.range ? mv.range[0] * 3 : 0\n const to = mv.range ? mv.range[1] * 3 : work.length\n const point = this.a\n for (let i = from; i < to; i += 3) {\n const d = dropAt(point.set(work[i]!, work[i + 1]!, work[i + 2]!).applyMatrix4(mesh.matrixWorld)) / scale\n work[i] += down.x * d\n work[i + 1] += down.y * d\n work[i + 2] += down.z * d\n }\n for (const decal of mv.decals) decal.obj.position.addScaledVector(down, dropAt(decal.obj.getWorldPosition(point)) / scale)\n mv.touched = true\n if (write) this.commit(mv)\n return true\n }\n\n /** Writes what `sink` moved into the geometry. */\n commit(mv: MeshVis): void {\n const pos = positionAttr(mv.mesh.geometry)\n if (pos) this.writePositions(mv, pos)\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Char and heat glow\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n setChar(pv: PartVis, char: number, charColor: number): void {\n if (Math.abs(char - pv.charApplied) < 0.004) return\n pv.charApplied = char\n const target = new this.THREE.Color(charColor)\n for (const mv of pv.meshes) {\n if (mv.host) {\n mv.charK = clamp(char, 0, 1)\n mv.charHex = charColor\n this.paint(mv)\n continue\n }\n this.ownMaterial(mv)\n const mats = materialsOf(mv.mesh.material)\n mats.forEach((m, i) => {\n const c = colorOf(m)\n const base = mv.baseColors?.[i]\n if (c && base) c.copy(base).lerp(target, clamp(char, 0, 1))\n })\n }\n }\n\n /** Emissive glow of a hot part. `temperature` below the glow threshold switches it off. */\n setGlow(pv: PartVis, temperatureC: number): void {\n const hex = heatColor(temperatureC)\n const key = hex === 0 ? 0 : Math.round(temperatureC / 5) * 5\n if (key === pv.glowApplied) return\n pv.glowApplied = key\n const intensity = hex === 0 ? 0 : clamp(0.35 + (temperatureC - 450) / 900, 0, 1.4)\n for (const mv of pv.meshes) {\n if (mv.host) {\n mv.glowHex = hex\n mv.glowK = intensity\n this.paint(mv)\n continue\n }\n this.ownMaterial(mv)\n for (const m of materialsOf(mv.mesh.material)) {\n const e = (m as THREE_NS.MeshStandardMaterial).emissive\n if (e && (e as THREE_NS.Color).isColor) {\n e.setHex(hex)\n ;(m as THREE_NS.MeshStandardMaterial).emissiveIntensity = intensity\n }\n }\n }\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Melt\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n /** Sag the part: shorter in Y (down to 25 %), a bit wider, vertices pushed down with noise, the bottom stays put. */\n setMelt(pv: PartVis, melt: number): void {\n const m = clamp(melt, 0, 1)\n if (Math.abs(m - pv.meltApplied) < 0.01) return\n pv.meltApplied = m\n for (const mv of pv.meshes) {\n const mesh = mv.mesh\n if (mv.host) {\n // a range of a shared mesh cannot scale the mesh: squash and widen its own vertices\n mv.meltApplied = m\n mv.touched = true\n if (!(this.lowQuality && this.vertexCount(mv) > 20000) && this.ownGeometry(mv)) this.rebuildHost(mv.host)\n continue\n }\n if (mv.meltApplied === 0 && m > 0) {\n mesh.updateWorldMatrix(true, false)\n mv.bottomY = this.box.setFromObject(mesh).min.y\n }\n mv.meltApplied = m\n mv.moved = true\n const sy = lerp(1, 0.25, m)\n const sxz = 1 + 0.18 * m\n mesh.scale.set(mv.origScale.x * sxz, mv.origScale.y * sy, mv.origScale.z * sxz)\n mesh.position.copy(mv.origPosition)\n mesh.updateWorldMatrix(true, false)\n const bottom = this.box.setFromObject(mesh).min.y\n const dy = mv.bottomY - bottom\n if (Math.abs(dy) > 1e-6 && mesh.parent) {\n mesh.parent.updateWorldMatrix(true, false)\n const inv = this.m4.copy(mesh.parent.matrixWorld).invert()\n this.a.set(0, dy, 0).applyMatrix4(inv)\n this.b.set(0, 0, 0).applyMatrix4(inv)\n mesh.position.copy(mv.origPosition).add(this.a.sub(this.b))\n }\n if (!(this.lowQuality && this.vertexCount(mv) > 20000) && this.ownGeometry(mv)) {\n this.writePositions(mv, positionAttr(mesh.geometry) as THREE_NS.BufferAttribute)\n }\n }\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Visibility and restore\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n hide(pv: PartVis, reason: PartVis['gone']): void {\n pv.gone = reason\n for (const mv of pv.meshes) {\n if (!mv.host || mv.loose) {\n mv.mesh.visible = false\n mv.hidden = true\n continue\n }\n // a range of a shared mesh: collapse its vertices to a point and hide what was drawn on it\n mv.hidden = true\n for (const d of mv.decals) d.obj.visible = false\n this.collapse(mv)\n }\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Parts drawn by a vertex range of a merged mesh\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n /** Collapse the part's vertices in the merged mesh to one point (its triangles become degenerate and vanish). */\n private collapse(mv: MeshVis): void {\n if (!mv.merged || !this.ownHostGeometry(mv.merged.host)) return\n mv.collapsed = true\n mv.touched = true\n this.rebuildHost(mv.merged.host)\n }\n\n /** Write `work` into the geometry again with the melt of ranged parts and the collapsed ranges applied. */\n private rebuildHost(host: HostVis): void {\n const geo = host.mesh.geometry\n const pos = positionAttr(geo)\n const work = host.work\n if (!pos || !work) return\n const arr = pos.array as unknown as Float32Array\n arr.set(work)\n collapseForeign(host.mesh, arr)\n for (const s of host.sharers) {\n if (s.merged && s.merged.host === host) {\n if (s.collapsed) this.collapseRange(arr, s.merged.range)\n else if (s.meltApplied > 0 && !s.loose) this.meltRange(arr, work, s.merged.range, s.meltApplied)\n } else if (s.host === host && s.range && s.meltApplied > 0) this.meltRange(arr, work, s.range, s.meltApplied)\n }\n pos.needsUpdate = true\n geo.computeVertexNormals()\n geo.boundingBox = null\n geo.boundingSphere = null\n }\n\n private collapseRange(arr: Float32Array, range: [number, number]): void {\n const x = arr[range[0] * 3]\n const y = arr[range[0] * 3 + 1]\n const z = arr[range[0] * 3 + 2]\n for (let i = range[0] * 3; i < range[1] * 3; i += 3) {\n arr[i] = x\n arr[i + 1] = y\n arr[i + 2] = z\n }\n }\n\n /** Melt of one range: shorter in Y (down to 25 %) with the bottom fixed, a bit wider around its centre, with the same noise as a whole mesh. */\n private meltRange(arr: Float32Array, work: Float32Array, range: [number, number], melt: number): void {\n let minY = Infinity\n let maxY = -Infinity\n let cx = 0\n let cz = 0\n const n = Math.max(1, range[1] - range[0])\n for (let i = range[0] * 3; i < range[1] * 3; i += 3) {\n minY = Math.min(minY, work[i + 1])\n maxY = Math.max(maxY, work[i + 1])\n cx += work[i]\n cz += work[i + 2]\n }\n cx /= n\n cz /= n\n const h = Math.max(1e-4, maxY - minY)\n const sy = lerp(1, 0.25, melt)\n const sxz = 1 + 0.18 * melt\n for (let i = range[0] * 3, v = 0; i < range[1] * 3; i += 3, v++) {\n const noise = ((Math.imul(v + 1, 2654435761) >>> 0) % 1000) / 1000\n arr[i] = cx + (work[i] - cx) * sxz\n arr[i + 2] = cz + (work[i + 2] - cz) * sxz\n arr[i + 1] = Math.max(minY, minY + (work[i + 1] - minY) * sy - noise * melt * h * 0.04)\n }\n }\n\n /** The colour attribute of the host's current geometry (created white when there is none) with vertex colours switched on in its material. */\n private ensureColors(host: HostVis): THREE_NS.BufferAttribute | null {\n if (!this.ownHostGeometry(host)) return null\n const geo = host.mesh.geometry\n let attr = geo.getAttribute('color') as THREE_NS.BufferAttribute | undefined\n if (!attr) {\n const n = geo.getAttribute(POS_ATTR).count\n attr = new this.THREE.BufferAttribute(new Float32Array(n * 3).fill(1), 3)\n geo.setAttribute('color', attr)\n }\n if (!host.ownMat) {\n host.ownMat = true\n const src = materialsOf(host.mesh.material)\n const cloned = src.map((m) => m.clone())\n host.mesh.material = Array.isArray(host.mesh.material) ? cloned : cloned[0]\n }\n for (const m of materialsOf(host.mesh.material)) {\n if ((m as THREE_NS.MeshStandardMaterial).vertexColors !== true) {\n ;(m as THREE_NS.MeshStandardMaterial).vertexColors = true\n m.needsUpdate = true\n }\n }\n return attr\n }\n\n /** Colour of the part's vertices from the original colours, its char and its heat. Only the part's range is written. */\n private paint(mv: MeshVis): void {\n if (!mv.host || !mv.range || !mv.merged) return\n const idle = mv.charK <= 0 && mv.glowK <= 0\n if (idle && !mv.touched) return\n const attr = this.ensureColors(mv.host)\n if (!attr) return\n const size = attr.itemSize\n const arr = attr.array as unknown as Float32Array\n const orig = mv.merged.host.origGeometry.getAttribute('color') as THREE_NS.BufferAttribute | undefined\n const oSize = orig?.itemSize ?? 3\n const oArr = orig?.array as unknown as ArrayLike<number> | undefined\n const shift = mv.merged.range[0] - mv.range[0]\n const ch = new this.THREE.Color(mv.charHex)\n const heat = new this.THREE.Color(mv.glowHex)\n const k = clamp(mv.charK, 0, 1)\n const gk = clamp(mv.glowK, 0, 1)\n const boost = 1 + Math.max(0, mv.glowK - 1)\n for (let i = mv.range[0]; i < mv.range[1]; i++) {\n const o = (i + shift) * oSize\n let r = oArr ? oArr[o] : 1\n let g = oArr ? oArr[o + 1] : 1\n let b = oArr ? oArr[o + 2] : 1\n if (k > 0) {\n r = lerp(r, ch.r, k)\n g = lerp(g, ch.g, k)\n b = lerp(b, ch.b, k)\n }\n if (gk > 0) {\n r = lerp(r, heat.r * boost, gk)\n g = lerp(g, heat.g * boost, gk)\n b = lerp(b, heat.b * boost, gk)\n }\n arr[i * size] = r\n arr[i * size + 1] = g\n arr[i * size + 2] = b\n }\n mv.touched = true\n attr.needsUpdate = true\n }\n\n /**\n * Move a ranged part to a mesh of its own: the faces whose vertices all lie in its range are copied (with the current dents and colours) into a\n * new mesh that takes the merged mesh's transform and material, then attached to `group`; the range is collapsed in the merged mesh. Decals\n * go with it.\n */\n extract(mv: MeshVis, group: THREE_NS.Object3D): void {\n if (!mv.host || !mv.range || !mv.merged || mv.loose) return\n const host = mv.host\n const [v0, v1] = mv.range\n const src = host.mesh.geometry\n const geo = new this.THREE.BufferGeometry()\n const count = v1 - v0\n for (const name of Object.keys(src.attributes)) {\n const a = src.getAttribute(name) as THREE_NS.BufferAttribute\n if ((a as unknown as { isInterleavedBufferAttribute?: boolean }).isInterleavedBufferAttribute) continue\n const size = a.itemSize\n const from = (name === POS_ATTR ? plainPositions(host.mesh, v0, v1) ?? host.work : null) ?? (a.array as unknown as Float32Array)\n const slice = (from as unknown as { slice(a: number, b: number): ArrayLike<number> }).slice(v0 * size, v1 * size)\n const Ctor = (a.array as unknown as { constructor: new (x: ArrayLike<number>) => ArrayLike<number> }).constructor\n geo.setAttribute(name, new this.THREE.BufferAttribute(new Ctor(slice) as never, size, a.normalized))\n }\n const index = src.getIndex()\n if (index) {\n const out: number[] = []\n for (let i = 0; i + 2 < index.count; i += 3) {\n const a = index.getX(i)\n const b = index.getX(i + 1)\n const c = index.getX(i + 2)\n if (a >= v0 && a < v1 && b >= v0 && b < v1 && c >= v0 && c < v1) out.push(a - v0, b - v0, c - v0)\n }\n geo.setIndex(count > 65535 ? new this.THREE.Uint32BufferAttribute(out, 1) : new this.THREE.Uint16BufferAttribute(out, 1))\n }\n const mats = materialsOf(host.mesh.material).map((m) => m.clone())\n const loose = new this.THREE.Mesh(geo, mats[0])\n loose.name = `${host.mesh.name || 'mesh'}:${v0}-${v1}`\n loose.castShadow = host.mesh.castShadow\n loose.receiveShadow = host.mesh.receiveShadow\n loose.renderOrder = host.mesh.renderOrder\n loose.frustumCulled = host.mesh.frustumCulled\n loose.layers.mask = host.mesh.layers.mask\n loose.position.copy(host.mesh.position)\n loose.quaternion.copy(host.mesh.quaternion)\n loose.scale.copy(host.mesh.scale)\n const parent = host.mesh.parent\n if (parent) parent.add(loose)\n loose.updateMatrixWorld(true)\n // the merged mesh loses the range; the decals and the part's state follow the new mesh\n this.collapse(mv)\n for (const d of mv.decals) {\n d.obj.visible = true\n loose.add(d.obj)\n }\n const lp = positionAttr(geo) as THREE_NS.BufferAttribute\n const lh: HostVis = {\n mesh: loose,\n origGeometry: geo,\n origMaterial: loose.material,\n ownGeo: true,\n work: new Float32Array(lp.array as ArrayLike<number>),\n ownMat: true,\n sharers: [mv],\n }\n mv.host = lh\n mv.range = [0, count]\n mv.mesh = loose\n mv.loose = true\n mv.moved = true\n group.attach(loose)\n for (const m of materialsOf(loose.material)) m.needsUpdate = true\n }\n\n private restoreRanged(mv: MeshVis): void {\n const merged = mv.merged as NonNullable<MeshVis['merged']>\n const host = merged.host\n for (const d of mv.decals) this.disposeDecal(d)\n mv.decals.length = 0\n if (mv.loose) {\n const loose = mv.mesh\n loose.parent?.remove(loose)\n loose.geometry.dispose()\n for (const m of materialsOf(loose.material)) m.dispose()\n mv.host = host\n mv.range = [merged.range[0], merged.range[1]]\n mv.mesh = host.mesh\n mv.loose = false\n mv.moved = false\n }\n mv.collapsed = false\n mv.hidden = false\n mv.meltApplied = 0\n mv.charK = 0\n mv.glowK = 0\n mv.touched = false\n if (!host.ownGeo) return\n // positions and colours of the range go back to the original ones\n const work = host.work as Float32Array\n const op = basePositions(host)\n const [v0, v1] = merged.range\n if (op) work.set(op.subarray(v0 * 3, v1 * 3), v0 * 3)\n const attr = host.mesh.geometry.getAttribute('color') as THREE_NS.BufferAttribute | undefined\n if (attr) {\n const orig = host.origGeometry.getAttribute('color') as THREE_NS.BufferAttribute | undefined\n const size = attr.itemSize\n const a = attr.array as unknown as Float32Array\n for (let i = v0; i < v1; i++) {\n for (let c = 0; c < 3; c++) a[i * size + c] = orig ? orig.array[i * orig.itemSize + c] : 1\n }\n attr.needsUpdate = true\n }\n if (host.sharers.every((s) => !s.touched)) {\n host.mesh.geometry.dispose()\n host.mesh.geometry = host.origGeometry\n // the original geometry as it is now: its first positions, with what another drawing keeps collapsed\n const base = basePositions(host), back = positionAttr(host.origGeometry)\n if (base && back) {\n const arr = back.array as unknown as Float32Array\n arr.set(base)\n collapseForeign(host.mesh, arr)\n back.needsUpdate = true\n }\n host.work = null\n host.ownGeo = false\n if (host.ownMat) {\n for (const m of materialsOf(host.mesh.material)) m.dispose()\n host.mesh.material = host.origMaterial\n host.ownMat = false\n }\n } else this.rebuildHost(host)\n }\n\n /** Bring one mesh back to how it was when it was bound. */\n restoreMesh(mv: MeshVis): void {\n if (mv.merged) {\n this.restoreRanged(mv)\n return\n }\n const mesh = mv.mesh\n for (const d of mv.decals) this.disposeDecal(d)\n mv.decals.length = 0\n if (mv.ownGeo) {\n mesh.geometry.dispose()\n mesh.geometry = mv.origGeometry\n mv.ownGeo = false\n mv.work = null\n }\n if (mv.ownMat) {\n for (const m of materialsOf(mesh.material)) m.dispose()\n mesh.material = mv.origMaterial\n mv.ownMat = false\n mv.baseColors = null\n }\n mesh.visible = mv.origVisible\n if (mv.origParent && mesh.parent !== mv.origParent) {\n mv.origParent.add(mesh)\n mv.moved = true\n }\n if (mv.moved) {\n mesh.position.copy(mv.origPosition)\n mesh.quaternion.copy(mv.origQuaternion)\n mesh.scale.copy(mv.origScale)\n mv.moved = false\n }\n mv.meltApplied = 0\n }\n\n restorePart(pv: PartVis): void {\n for (const mv of pv.meshes) this.restoreMesh(mv)\n delete pv.settled\n pv.charApplied = 0\n pv.glowApplied = 0\n pv.meltApplied = 0\n pv.gone = 'none'\n }\n\n dispose(): void {\n this.kit.dispose()\n }\n}\n","import type * as THREE_NS from 'three'\nimport { settlementAt } from '@adatechnology/game-destruction'\nimport type { PartSettlement, Vec3 } from '@adatechnology/game-destruction'\nimport type { HostVis, MeshVis, PartVis } from './internal'\nimport type { Visuals } from './visual'\n\n/** Seconds a settlement takes to show: the ground slumps into the hole over about a second, it does not jump. */\nexport const SETTLE_SECONDS = 1.2\n/** Seconds between two redraws of a settling part (a merged house mesh is written again each time). */\nconst SETTLE_REDRAW = 0.1\n\ninterface Settling {\n pv: PartVis\n root: THREE_NS.Object3D\n /** The settlement drawn when this one started, and where it goes. */\n start: PartSettlement | undefined\n target: PartSettlement\n /** Share of the way already drawn, 0..1, and seconds since it started. */\n shown: number\n elapsed: number\n lastDrawn: number\n}\n\nconst dropOf = (line: PartSettlement | undefined, point: Vec3): number => (line ? settlementAt(line, point) : 0)\nconst sameLine = (a: PartSettlement | undefined, b: PartSettlement): boolean =>\n !!a && a.drop.length === b.drop.length && a.drop.every((v, k) => v === b.drop[k]) && a.from.every((v, k) => v === b.from[k]) && a.to.every((v, k) => v === b.to[k])\n\n/**\n * Draws the settlement of the parts the ground went down under (`PartState.settlement`): each point of a part goes down by the drop at its place along\n * the settlement line (so a part that went down more at one end tilts), smoothly over `SETTLE_SECONDS`, its marks with it.\n */\nexport class SettlementView {\n private readonly moving = new Map<PartVis, Settling>()\n private readonly local: THREE_NS.Vector3\n private readonly inverse: THREE_NS.Matrix4\n\n constructor(THREE: typeof THREE_NS, private readonly visuals: Visuals) {\n this.local = new THREE.Vector3()\n this.inverse = new THREE.Matrix4()\n }\n\n /** The parts of an object (`root` draws it in object space) and their settlement now: those that changed start going to it. */\n follow(root: THREE_NS.Object3D, parts: Iterable<readonly [PartVis, PartSettlement | undefined]>): void {\n for (const [pv, target] of parts) {\n if (!target || pv.gone !== 'none' || sameLine(this.moving.get(pv)?.target ?? pv.settled, target)) continue\n this.finish(pv)\n this.moving.set(pv, { pv, root, start: pv.settled, target, shown: 0, elapsed: 0, lastDrawn: -SETTLE_REDRAW })\n }\n }\n\n get count(): number {\n return this.moving.size\n }\n\n update(dt: number): void {\n for (const s of this.moving.values()) {\n s.elapsed += dt\n const done = s.elapsed >= SETTLE_SECONDS\n if (!done && s.elapsed - s.lastDrawn < SETTLE_REDRAW) continue\n s.lastDrawn = s.elapsed\n const t = Math.min(1, s.elapsed / SETTLE_SECONDS)\n this.draw(s, t * t * (3 - 2 * t))\n if (done) {\n s.pv.settled = s.target\n this.moving.delete(s.pv)\n }\n }\n }\n\n /** Draws the rest of a part's settlement at once (it is about to be split off or put back). */\n finish(pv: PartVis): void {\n const s = this.moving.get(pv)\n if (!s) return\n this.draw(s, 1)\n pv.settled = s.target\n this.moving.delete(pv)\n }\n\n /** Forget a part without drawing (it was put back as it was). */\n forget(pv: PartVis): void {\n this.moving.delete(pv)\n }\n\n clear(): void {\n this.moving.clear()\n }\n\n private draw(s: Settling, shown: number): void {\n const share = shown - s.shown\n if (share <= 0) return\n s.shown = shown\n s.root.updateWorldMatrix(true, false)\n this.inverse.copy(s.root.matrixWorld).invert()\n const dropAt = (world: THREE_NS.Vector3): number => {\n const p = this.local.copy(world).applyMatrix4(this.inverse)\n const at: Vec3 = [p.x, p.y, p.z]\n return (dropOf(s.target, at) - dropOf(s.start, at)) * share\n }\n // the meshes the part shares with others are written once each\n const writes = new Map<HostVis | MeshVis, MeshVis>()\n for (const mv of s.pv.meshes) if (this.visuals.sink(mv, dropAt, false)) writes.set(mv.host ?? mv, mv)\n for (const mv of writes.values()) this.visuals.commit(mv)\n }\n}\n","import type * as THREE_NS from 'three'\nimport type { Vec3 } from '@adatechnology/game-destruction'\nimport type { MeshVis } from './internal'\n\n/**\n * Where a lasting emitter (grit trickling off a broken face) sits on the mesh it came off, in that mesh's own space: it goes wherever the mesh goes\n * (the object tips, a loose group falls as a piece of its own), never left pouring where the object stood. `mv.mesh` is read each time, so a part\n * moved to a mesh of its own (`Visuals.extract`, same space) keeps it.\n */\nexport interface EmitterAnchor {\n readonly mv: MeshVis\n readonly local: Vec3\n readonly localNormal: Vec3\n}\n\ntype ThreeMath = Pick<typeof THREE_NS, 'Vector3' | 'Matrix4'>\n\nexport function anchorOnMesh(THREE: ThreeMath, mv: MeshVis, point: Vec3, normal: Vec3): EmitterAnchor {\n mv.mesh.updateWorldMatrix(true, false)\n const inverse = new THREE.Matrix4().copy(mv.mesh.matrixWorld).invert()\n const local = new THREE.Vector3(point[0], point[1], point[2]).applyMatrix4(inverse)\n const localNormal = new THREE.Vector3(normal[0], normal[1], normal[2]).transformDirection(inverse)\n return { mv, local: [local.x, local.y, local.z], localNormal: [localNormal.x, localNormal.y, localNormal.z] }\n}\n\nfunction inScene(object: THREE_NS.Object3D): boolean {\n let top = object\n while (top.parent) top = top.parent\n return (top as THREE_NS.Scene).isScene === true\n}\n\n/**\n * Writes where the anchor is now (world point, world normal). False when there is nothing left to emit from: the mesh is no longer shown (the part\n * broke into fragments, burnt away) or no longer in a scene (restored away, discarded).\n */\nexport function anchorWorld(anchor: EmitterAnchor, shown: boolean, point: THREE_NS.Vector3, normal: THREE_NS.Vector3): boolean {\n const mesh = anchor.mv.mesh\n if (!shown || !inScene(mesh)) return false\n mesh.updateWorldMatrix(true, false)\n point.set(anchor.local[0], anchor.local[1], anchor.local[2]).applyMatrix4(mesh.matrixWorld)\n normal.set(anchor.localNormal[0], anchor.localNormal[1], anchor.localNormal[2]).transformDirection(mesh.matrixWorld)\n return true\n}\n","// The sounds of materials breaking, as recipes of @adatechnology/game-audio. The art scene's `sfx.*` (cena L1354-L1367) are ported literally: the same\n// filters, frequencies, lengths, volumes and reverb sends, and the same random numbers drawn in the same order, so a recipe leaves the trace of the team\n// code. The game's `boom` (jogo L68278) is here too, as the game's explosion.\nimport { DISTANCE_CURVES, sceneMany as many, sceneNoise as noise, sceneRecipe, sceneTone as tone } from '@adatechnology/game-audio'\nimport type { Layer, LoopRecipe, SoundBank, SoundRecipe } from '@adatechnology/game-audio'\n\nimport { BLAST_SOUNDS, FIRE_FUEL_LOOPS, FIRE_LOOP, FIRE_SOUNDS, GRENADE_PIN_PULL, ROCKET_MOTOR_LOOP, SMOKE_HISS_LOOP } from './blast-fire'\n\nconst scene = (id: string, layers: readonly Layer[], line: string, vars?: SoundRecipe['vars'], group?: string): SoundRecipe =>\n sceneRecipe(id, layers, line, { ...(vars ? { vars } : {}), ...(group ? { group } : {}) })\n\nconst boomLayers = (big: boolean): Layer[] => [\n noise({ f: 1200, f2: 120, d: 1.8, vol: 2, wet: 1.2 }),\n tone({ f: 65, f2: 24, d: 1.0, vol: 1.8 }),\n noise({ type: 'highpass', f: 1500, d: 0.2, vol: 0.8 }),\n ...(big ? [noise({ f: 500, f2: 90, a: 0.2, d: 2.4, vol: 1.2, wet: 1, delay: 0.15 })] : []),\n ...many(8, () => tone({ f: [2600, 5600], d: 0.05, vol: 0.08, delay: [0.4, 1.6] })),\n]\n\n/** The art scene's destruction sounds, each with the team name in its `sources`. */\nexport const SCENE_SOUNDS: readonly SoundRecipe[] = [\n scene(\n 'glass_shatter',\n [noise({ type: 'highpass', f: 2800, d: 0.45, vol: 0.9, wet: 0.5 }), ...many(12, () => tone({ f: [3000, 7500], d: [0.06, 0.14], vol: 0.18, delay: [0, 0.55] }))],\n 'L1359 glass',\n ),\n scene(\n 'wood_hit',\n [noise({ type: 'bandpass', f: 850, q: 1, d: 0.25, vol: 0.9, wet: 0.3 }), tone({ f: 210, f2: 90, d: 0.1, vol: 0.6 }), noise({ type: 'highpass', f: 2000, d: 0.04, vol: 0.5 })],\n 'L1360 wood',\n ),\n // many parts coming loose at once share the `debris_knock` voices (game-audio voice-groups.json)\n scene('thunk', [noise({ type: 'bandpass', f: 700, q: 2, d: 0.07, vol: 0.4 })], 'L1361 thunk', undefined, 'debris_knock'),\n scene('ping', [tone({ f: [2600, 3500], f2: 1400, d: 0.14, vol: 0.18, wet: 0.3 })], 'L1362 ping'),\n scene('clang', [tone({ f: [520, 720], f2: 480, d: 0.5, vol: 0.35, wet: 0.4 }), tone({ f: 1370, f2: 1300, d: 0.3, vol: 0.15 }), noise({ type: 'highpass', f: 2000, d: 0.05, vol: 0.5 })], 'L1363 clang'),\n scene('chip', [noise({ type: 'bandpass', f: 1600, q: 1.2, d: 0.06, vol: 0.5 })], 'L1364 chip'),\n scene(\n 'crumble',\n [noise({ f: 900, f2: 200, d: 0.6, vol: 0.9, wet: 0.3 }), ...many(5, () => noise({ type: 'bandpass', f: [500, 1400], q: 2, d: 0.05, vol: 0.4, delay: [0.1, 0.5] }))],\n 'L1365 crumble',\n ),\n // `thud(x, z, v)`: `v` is the `scale` param (default 1)\n scene('thud', [tone({ f: 75, f2: 38, d: 0.22, vol: { param: 'scale', scale: 0.6 } }), noise({ f: 420, d: 0.16, vol: { param: 'scale', scale: 0.45 } })], 'L1358 thud', { scale: 1 }),\n // `hiss(x, z, d)`: `seconds` is the param `d` (default 1.2)\n // every melting part shares one `sizzle` voice\n scene('hiss', [noise({ type: 'highpass', f: 3500, a: 0.05, d: { param: 'seconds' }, vol: 0.35 })], 'L1366 hiss', { seconds: 1.2 }, 'sizzle'),\n scene('boom', boomLayers(false), 'L1367 boom'),\n scene('boom_big', boomLayers(true), 'L1367 boom (big)'),\n scene('burst', [noise({ f: 700, f2: 120, d: 0.7, vol: 1.4, wet: 0.5 }), noise({ type: 'highpass', f: 3000, a: 0.05, d: 1.2, vol: 0.4, delay: 0.1 })], 'L1357 burst'),\n scene('crack', [noise({ type: 'highpass', f: 1800, d: 0.05, vol: 0.8 }), tone({ f: 420, f2: 180, d: 0.06, vol: 0.4 })], 'L1354 crack'),\n]\n\n/** The game's explosion thump: a sine from 70 to 28 Hz over 1.2 s, `1.4 / (1 + d² × 0.002)` (jogo L68278). */\nexport const EXPLOSION_BOOM: SoundRecipe = {\n id: 'explosion_boom',\n bus: 'world',\n order: 'boom',\n duration: 1.6,\n tail: 0.1,\n layers: [\n {\n source: { kind: 'osc', wave: 'sine', frequency: { from: 70, to: 28, curve: 'exp', over: 1.2 } },\n envelope: [\n [0, 1, 'set'],\n ['1d', 0.001, 'exp', 'fixed'],\n ],\n },\n ],\n falloff: DISTANCE_CURVES.game_boom,\n sources: ['jogo:L68278-68285 boom'],\n}\n\n/**\n * The fire loop of the art scene (cena L1316): noise through a 1800 Hz bandpass (Q 0.6) into a gain that starts at 0. The page never raises it, so it is\n * silent there; here `createDestructionSound` raises it while something burns (the level is the kit's, in `fire`).\n */\nexport const BURN_LOOP: LoopRecipe = {\n id: 'burn_loop',\n bus: 'world',\n order: 'chain_loop',\n source: { kind: 'noise', loop: true },\n filters: { mode: 'serial', bank: [{ type: 'bandpass', frequency: { set: 1800 }, q: 0.6 }] },\n volume: 0,\n sources: ['cena:L1316 fire loop (silent in the page: its gain is never raised)', 'sdk: the level while burning'],\n}\n\nconst drag = (id: string, layers: readonly Layer[]): SoundRecipe => ({ ...sceneRecipe(id, layers, ''), sources: ['sdk: a base dragged on a floor, one grain per stretch'] })\n\n/** Something heavy dragged on a floor, by what its base is made of. */\nexport const DRAG_SOUNDS: readonly SoundRecipe[] = [\n drag('drag_wood', [noise({ type: 'bandpass', f: 380, q: 1.4, d: 0.28, vol: 0.5 }), noise({ type: 'bandpass', f: [900, 1300], q: 3, d: 0.08, vol: 0.14 })]),\n drag('drag_metal', [noise({ type: 'bandpass', f: 1500, q: 4, d: 0.26, vol: 0.32 }), tone({ f: [880, 1240], f2: 760, d: 0.18, vol: 0.05 })]),\n drag('drag_glass', [noise({ type: 'bandpass', f: 2600, q: 5, d: 0.2, vol: 0.22 })]),\n drag('drag_masonry', [noise({ type: 'bandpass', f: 260, q: 0.9, d: 0.3, vol: 0.62 }), ...many(3, () => noise({ type: 'bandpass', f: [600, 1200], q: 2, d: 0.04, vol: 0.14, delay: [0, 0.2] }))]),\n drag('drag_soft', [noise({ type: 'lowpass', f: 420, d: 0.28, vol: 0.3 })]),\n]\n\nconst leaf = (id: string, layers: readonly Layer[]): SoundRecipe => ({ ...sceneRecipe(id, layers, ''), sources: ['sdk: a door, lid or drawer worked by hand'] })\n\n/** A leaf worked by hand: the latch, the hinge as it turns (by what the leaf is made of), the leaf meeting its frame, a locked leaf shaken, a drawer on its runners. */\nexport const LEAF_SOUNDS: readonly SoundRecipe[] = [\n leaf('latch', [noise({ type: 'bandpass', f: 2400, q: 4, d: 0.03, vol: 0.35 }), tone({ f: 1900, f2: 1500, d: 0.025, vol: 0.06, delay: 0.035 })]),\n leaf('creak_wood', [tone({ f: [190, 240], f2: 310, d: 0.5, vol: 0.05 }), noise({ type: 'bandpass', f: 520, q: 6, a: 0.05, d: 0.45, vol: 0.12 })]),\n leaf('creak_metal', [tone({ f: [620, 760], f2: 900, d: 0.35, vol: 0.035 }), noise({ type: 'bandpass', f: 1400, q: 8, a: 0.04, d: 0.3, vol: 0.08 })]),\n leaf('shut_wood', [tone({ f: 120, f2: 60, d: 0.14, vol: 0.5 }), noise({ type: 'bandpass', f: 600, q: 1.2, d: 0.1, vol: 0.55, wet: 0.25 }), noise({ type: 'bandpass', f: 2400, q: 4, d: 0.03, vol: 0.25, delay: 0.02 })]),\n leaf('shut_metal', [tone({ f: 160, f2: 85, d: 0.18, vol: 0.55 }), noise({ type: 'bandpass', f: 900, q: 1.6, d: 0.12, vol: 0.45, wet: 0.3 }), tone({ f: 1250, f2: 1150, d: 0.12, vol: 0.06 })]),\n leaf('shut_soft', [tone({ f: 95, f2: 55, d: 0.12, vol: 0.35 }), noise({ type: 'lowpass', f: 500, d: 0.1, vol: 0.3 })]),\n leaf('rattle', many(5, () => noise({ type: 'bandpass', f: [1600, 2600], q: 3, d: 0.035, vol: 0.32, delay: [0, 0.45] }))),\n leaf('slide', [noise({ type: 'bandpass', f: 700, q: 2, a: 0.04, d: 0.35, vol: 0.22 }), noise({ type: 'bandpass', f: 2200, q: 5, d: 0.3, vol: 0.05 })]),\n // an item taken in the hand: the fingers on a hard surface and the sleeve moving, or a soft thing gathered up (the kit's recordings answer these ids)\n leaf('grab_hard', [noise({ type: 'bandpass', f: 1800, q: 3, d: 0.03, vol: 0.18 }), noise({ type: 'bandpass', f: 900, q: 1.2, a: 0.02, d: 0.14, vol: 0.08 })]),\n leaf('grab_soft', [noise({ type: 'lowpass', f: 1400, a: 0.02, d: 0.16, vol: 0.14 })]),\n]\n\nconst impact = (id: string, layers: readonly Layer[]): SoundRecipe => ({ ...sceneRecipe(id, layers, ''), sources: ['sdk: a blow on a material, by material and kind of blow (synthesised until the recorded samples arrive)'] })\n\n/**\n * A blow on a material, by what it is made of and what met it (`impactSoundKeys`): a bullet, a blunt blow (a punch, a kick, a fall), a blade. Each\n * is drawn from how the real thing sounds (checklist 5.3): a bullet rings steel and goes \"tchak\" on concrete with pebbles after it, a fist on steel is a\n * low \"bong\", a knife scrapes it; the ground is a dull \"tuf\", ceramic a dry \"tic\", plastic a hollow \"toc\", a sofa a \"fump\". Levels are matched so a\n * bullet on concrete is as loud as on wood.\n */\nexport const IMPACT_SOUNDS: readonly SoundRecipe[] = [\n // metal\n impact('metal_bullet', [noise({ type: 'highpass', f: 3000, d: 0.03, vol: 0.8 }), tone({ f: [2600, 3400], f2: 1800, d: 0.14, vol: 0.28, wet: 0.35 }), tone({ f: [520, 720], f2: 480, d: 0.35, vol: 0.22, wet: 0.35 })]),\n impact('metal_blunt', [noise({ type: 'bandpass', f: 800, q: 1, d: 0.05, vol: 0.5 }), tone({ f: [150, 210], f2: 120, d: 0.6, vol: 0.5, wet: 0.4 }), tone({ f: [420, 520], f2: 400, d: 0.4, vol: 0.12 })]),\n impact('metal_blade', [noise({ type: 'bandpass', f: [3500, 4500], q: 6, a: 0.01, d: 0.18, vol: 0.45 }), tone({ f: [2200, 2800], f2: 3000, d: 0.15, vol: 0.06 })]),\n impact('metal_ping', [noise({ type: 'highpass', f: 3500, d: 0.02, vol: 0.5 }), tone({ f: [2600, 3500], f2: 1400, d: 0.14, vol: 0.2, wet: 0.3 })]),\n impact('metal_thin', [noise({ type: 'highpass', f: 2500, d: 0.04, vol: 0.6 }), tone({ f: [900, 1300], f2: 700, d: 0.25, vol: 0.22, wet: 0.3 }), noise({ type: 'bandpass', f: 1200, q: 2, d: 0.08, vol: 0.3 })]),\n // wood (the bullet keeps the art scene's `wood_hit`)\n impact('wood_blunt', [tone({ f: [110, 150], f2: 70, d: 0.14, vol: 0.6 }), noise({ type: 'bandpass', f: 500, q: 1.2, d: 0.12, vol: 0.55, wet: 0.2 })]),\n impact('wood_blade', [noise({ type: 'bandpass', f: [1800, 2400], q: 2, a: 0.01, d: 0.12, vol: 0.5 }), ...many(3, () => noise({ type: 'bandpass', f: [2500, 4000], q: 3, d: 0.02, vol: 0.22, delay: [0.02, 0.1] }))]),\n impact('wood_splinter', [noise({ type: 'highpass', f: 1800, d: 0.05, vol: 0.6 }), tone({ f: [380, 480], f2: 170, d: 0.08, vol: 0.3 }), ...many(4, () => noise({ type: 'bandpass', f: [2500, 4200], q: 3, d: 0.02, vol: 0.2, delay: [0.03, 0.25] }))]),\n impact('mdf_puff', [noise({ type: 'lowpass', f: 900, d: 0.08, vol: 1 }), tone({ f: [180, 230], f2: 110, d: 0.06, vol: 0.3 }), noise({ type: 'highpass', f: 3000, a: 0.01, d: 0.2, vol: 0.1 })]),\n // glass and ceramic\n impact('glass_bullet', [noise({ type: 'highpass', f: 4000, d: 0.05, vol: 0.7 }), tone({ f: [3200, 4200], f2: 2600, d: 0.2, vol: 0.14, wet: 0.3 }), ...many(4, () => tone({ f: [4000, 7000], d: 0.05, vol: 0.07, delay: [0.02, 0.2] }))]),\n impact('glass_blunt', [noise({ type: 'bandpass', f: 2200, q: 3, d: 0.05, vol: 0.8 }), tone({ f: [1400, 1800], f2: 1300, d: 0.2, vol: 0.16, wet: 0.3 })]),\n impact('glass_blade', [noise({ type: 'bandpass', f: 5000, q: 8, a: 0.02, d: 0.25, vol: 0.3 })]),\n impact('ceramic_hit', [noise({ type: 'bandpass', f: 3000, q: 2, d: 0.03, vol: 0.6 }), tone({ f: [1800, 2400], f2: 1600, d: 0.1, vol: 0.2 })]),\n impact('ceramic_bullet', [noise({ type: 'highpass', f: 2500, d: 0.06, vol: 0.85 }), ...many(5, () => tone({ f: [2500, 5000], d: 0.04, vol: 0.09, delay: [0, 0.15] }))]),\n // masonry and the ground\n impact('masonry_bullet', [noise({ type: 'bandpass', f: [1600, 2000], q: 1, d: 0.05, vol: 1.8 }), noise({ type: 'lowpass', f: 600, d: 0.12, vol: 0.9, wet: 0.2 }), ...many(4, () => noise({ type: 'bandpass', f: [2000, 4000], q: 3, d: 0.02, vol: 0.28, delay: [0.03, 0.3] }))]),\n impact('masonry_blunt', [tone({ f: [70, 95], f2: 45, d: 0.12, vol: 0.55 }), noise({ type: 'lowpass', f: 400, d: 0.1, vol: 0.5 })]),\n impact('masonry_blade', [noise({ type: 'bandpass', f: [2500, 3500], q: 4, a: 0.01, d: 0.15, vol: 0.4 })]),\n impact('plaster_puff', [noise({ type: 'lowpass', f: 900, d: 0.09, vol: 0.7 }), noise({ type: 'highpass', f: 3000, a: 0.01, d: 0.2, vol: 0.14 })]),\n impact('soil_bullet', [noise({ type: 'lowpass', f: 700, d: 0.08, vol: 2.2 }), ...many(3, () => noise({ type: 'bandpass', f: [1200, 2200], q: 2, d: 0.03, vol: 0.18, delay: [0.02, 0.2] }))]),\n impact('soil_blunt', [tone({ f: [55, 70], f2: 40, d: 0.1, vol: 0.45 }), noise({ type: 'lowpass', f: 300, d: 0.08, vol: 0.4 })]),\n impact('sand_hit', [noise({ type: 'bandpass', f: 3500, q: 0.8, a: 0.005, d: 0.15, vol: 0.45 }), noise({ type: 'lowpass', f: 500, d: 0.06, vol: 0.45 })]),\n impact('gravel_hit', [noise({ type: 'lowpass', f: 500, d: 0.06, vol: 0.45 }), ...many(6, () => noise({ type: 'bandpass', f: [1500, 3500], q: 3, d: 0.025, vol: 0.28, delay: [0, 0.18] }))]),\n // plastic, rubber, wax\n impact('plastic_hit', [noise({ type: 'bandpass', f: 1600, q: 3, d: 0.04, vol: 0.5 }), tone({ f: [380, 520], f2: 300, d: 0.08, vol: 0.32 })]),\n impact('plastic_bullet', [noise({ type: 'bandpass', f: 2500, q: 2, d: 0.03, vol: 1.3 }), tone({ f: [600, 800], f2: 450, d: 0.06, vol: 0.4 })]),\n impact('rubber_hit', [tone({ f: [90, 130], f2: 60, d: 0.1, vol: 0.45 }), noise({ type: 'lowpass', f: 350, d: 0.06, vol: 0.28 })]),\n impact('wax_hit', [noise({ type: 'lowpass', f: 800, d: 0.05, vol: 0.45 }), tone({ f: [240, 280], f2: 180, d: 0.05, vol: 0.22 })]),\n // soft things, paper, plants\n impact('soft_bullet', [noise({ type: 'lowpass', f: 450, a: 0.003, d: 0.1, vol: 1.8 }), noise({ type: 'bandpass', f: 900, q: 1, d: 0.05, vol: 0.5 })]),\n impact('fabric_hit', [noise({ type: 'lowpass', f: 650, d: 0.14, vol: 0.5 }), tone({ f: [85, 115], f2: 50, d: 0.12, vol: 0.28 })]),\n impact('fabric_rip', [noise({ type: 'bandpass', f: [2000, 2800], q: 1.5, a: 0.02, d: 0.25, vol: 0.4 }), ...many(4, () => noise({ type: 'bandpass', f: [3000, 5000], q: 4, d: 0.02, vol: 0.14, delay: [0, 0.22] }))]),\n impact('paper_hit', [noise({ type: 'bandpass', f: 2200, q: 1, d: 0.05, vol: 0.45 })]),\n impact('paper_tear', [noise({ type: 'highpass', f: 2500, a: 0.02, d: 0.3, vol: 0.15 })]),\n impact('leaf_rustle', many(6, () => noise({ type: 'bandpass', f: [2500, 6000], q: 2, d: 0.05, vol: 0.16, delay: [0, 0.3] }))),\n impact('branch_cut', [noise({ type: 'bandpass', f: 1500, q: 2, d: 0.04, vol: 0.55 }), tone({ f: [260, 340], f2: 150, d: 0.05, vol: 0.22 })]),\n impact('fruit_splat', [noise({ type: 'lowpass', f: 1200, d: 0.12, vol: 0.55 }), noise({ type: 'bandpass', f: 600, q: 0.7, d: 0.2, vol: 0.32 })]),\n // a round glancing off: steel whines down in pitch (\"piiuu\"), stone and concrete give a short crack with grit\n impact('ricochet_metal', [noise({ type: 'highpass', f: 3000, d: 0.02, vol: 0.6 }), tone({ f: [2800, 3600], f2: 900, d: 0.38, vol: 0.2, wet: 0.4 }), tone({ f: [5200, 6400], f2: 2000, d: 0.2, vol: 0.05 })]),\n impact('ricochet_stone', [noise({ type: 'bandpass', f: [2200, 2800], q: 2, d: 0.04, vol: 0.8 }), tone({ f: [1800, 2400], f2: 1200, d: 0.08, vol: 0.1 }), ...many(3, () => noise({ type: 'bandpass', f: [2500, 4500], q: 3, d: 0.015, vol: 0.2, delay: [0.02, 0.12] }))]),\n // breaks a material has of its own (the rest keep the art scene's shatter, crumble and splinter)\n impact('ceramic_break', [noise({ type: 'highpass', f: 1800, d: 0.3, vol: 0.85, wet: 0.4 }), ...many(8, () => tone({ f: [1800, 4500], d: [0.04, 0.1], vol: 0.15, delay: [0, 0.4] }))]),\n impact('tempered_burst', [noise({ type: 'highpass', f: 3500, d: 0.6, vol: 0.9, wet: 0.4 }), ...many(16, () => tone({ f: [4000, 8000], d: 0.04, vol: 0.08, delay: [0, 0.8] }))]),\n impact('plastic_crack', [noise({ type: 'bandpass', f: 1800, q: 2, d: 0.06, vol: 0.75 }), tone({ f: [450, 550], f2: 250, d: 0.05, vol: 0.22 })]),\n impact('mdf_crumble', [noise({ type: 'lowpass', f: 700, d: 0.25, vol: 0.75, wet: 0.2 }), ...many(4, () => noise({ type: 'lowpass', f: 500, d: 0.05, vol: 0.32, delay: [0.05, 0.3] }))]),\n]\n\nexport const DESTRUCTION_SOUND_BANK: SoundBank = { id: 'destruction_three', sounds: [...SCENE_SOUNDS, ...DRAG_SOUNDS, ...LEAF_SOUNDS, ...IMPACT_SOUNDS, EXPLOSION_BOOM, ...BLAST_SOUNDS, ...FIRE_SOUNDS, GRENADE_PIN_PULL], loops: [BURN_LOOP, FIRE_LOOP, ...FIRE_FUEL_LOOPS, SMOKE_HISS_LOOP, ROCKET_MOTOR_LOOP] }\n","// Blasts and fire: the kit's synthesized sounds for each family of explosive (grenade, big charge, fuel, car, pipe bomb, rocket, flashbang, molotov),\n// the far and the indoor versions of a blast, and the fire (ignition, roar, crackle, gas leak, put out). Synthesized until recorded files reach the\n// SDK; each recipe is built so the loudest moment is the first few milliseconds (the crack of the blast lands on the frame of the event), the body\n// and the debris follow, and every frequency and timing is a range so no two plays sound alike.\nimport { sceneMany as many, sceneNoise as noise, sceneRecipe, sceneTone as tone } from '@adatechnology/game-audio'\nimport type { Falloff, FilterSpec, Layer, LoopRecipe, SoundRecipe } from '@adatechnology/game-audio'\n\n/** A blast near the listener: loud for tens of metres; lowpass cutoffs fall with distance. */\nexport const BLAST_FALLOFF: Falloff = { model: 'inverse_square', k: 0.0012, cutoffK: 0.006, minGain: 0.002 }\n/** A blast far away (past `BLAST_FAR_DISTANCE`): heard for hundreds of metres. */\nexport const BLAST_FAR_FALLOFF: Falloff = { model: 'inverse_square', k: 0.00008, scale: 0.3, minGain: 0.001 }\n/** Fire, ignition and crackles: a room-size sound. */\nexport const FIRE_FALLOFF: Falloff = { model: 'inverse_square', k: 0.01, cutoffK: 0.01, minGain: 0.005 }\n/** Metres from the listener past which a blast plays its far version. */\nexport const BLAST_FAR_DISTANCE = 60\n\n/** The explosion families, each with its own sound. */\nexport const BLAST_KINDS = ['grenade', 'big', 'fuel', 'car', 'pipe_bomb', 'rocket', 'flashbang', 'molotov'] as const\nexport type BlastKind = (typeof BLAST_KINDS)[number]\n\n/**\n * Which family each named explosion of `@adatechnology/game-vfx` (`explosions.json`, the `effect` of an explosive part) belongs to. Data: a game adds\n * or changes entries through `DestructionSoundOptions.blastKinds`. An explosion without a known effect is a grenade below `BIG_BLAST_RADIUS` and a big\n * charge above it.\n */\nexport const BLAST_KIND_OF: Readonly<Record<string, BlastKind>> = {\n m67: 'grenade',\n vog_25: 'grenade',\n m79_40mm: 'grenade',\n claymore: 'grenade',\n generic: 'grenade',\n c4: 'big',\n dynamite: 'big',\n fuel_station_tank: 'big',\n propane_p13: 'fuel',\n fuel_barrel: 'fuel',\n fuel_pump: 'fuel',\n car_fuel_tank: 'car',\n pipe_bomb: 'pipe_bomb',\n m72_66mm: 'rocket',\n at4_84mm: 'rocket',\n carl_gustaf_84mm: 'rocket',\n pg7v: 'rocket',\n flashbang: 'flashbang',\n molotov: 'molotov',\n}\n\n/** Blast radius (metres) from which an explosion with no known effect is a big charge. */\nexport const BIG_BLAST_RADIUS = 8\n\nconst blast = (id: string, layers: readonly Layer[], sources: readonly string[], falloff: Falloff = BLAST_FALLOFF): SoundRecipe => ({\n ...sceneRecipe(id, layers, ''),\n falloff,\n sources,\n})\n\n// the instant crack of the shock front: the loudest part, in the first milliseconds\nconst crack = (f: readonly [number, number], d: number, vol: number): Layer => noise({ type: 'highpass', f, a: 0.001, d, vol })\n// stones, wood and metal falling back after the blast, spread over `[from, to]` seconds\nconst debris = (count: number, from: number, to: number, vol: readonly [number, number]): Layer[] => [\n ...many(count, () => noise({ type: 'bandpass', f: [300, 1400], q: 2.5, d: [0.03, 0.09], vol, delay: [from, to] })),\n ...many(Math.ceil(count / 3), () => noise({ type: 'bandpass', f: [1800, 3600], q: 5, d: [0.02, 0.04], vol: [vol[0] * 0.6, vol[1] * 0.6] as const, delay: [from + 0.1, to] })),\n]\n// steel fragments whizzing and striking around the blast\nconst shrapnel = (count: number, to: number): Layer[] => many(count, () => noise({ type: 'bandpass', f: [2500, 6000], q: 6, d: [0.015, 0.045], vol: [0.08, 0.16], delay: [0.02, to] }))\n// glass panes breaking and their shards falling\nconst glass = (count: number, from: number): Layer[] => [\n noise({ type: 'highpass', f: [2600, 3000], d: 0.4, vol: 0.7, wet: 0.5, delay: from }),\n ...many(count, () => tone({ f: [3000, 7500], d: [0.05, 0.13], vol: 0.12, delay: [from, from + 0.7] })),\n]\n\n/** One sound per explosion family, the far and the indoor versions. */\nexport const BLAST_SOUNDS: readonly SoundRecipe[] = [\n blast(\n 'explosion_grenade',\n [\n crack([2300, 2700], 0.06, 2.4),\n noise({ f: [2500, 3000], f2: 160, d: 0.7, vol: 2, wet: 0.35 }),\n tone({ f: [80, 92], f2: 32, d: 0.5, vol: 1.6 }),\n noise({ type: 'bandpass', f: [620, 760], q: 0.8, d: 0.18, vol: 1.1 }),\n ...shrapnel(14, 0.7),\n ...debris(10, 0.35, 1.8, [0.1, 0.2]),\n ],\n ['sdk: frag grenade (M67, VOG-25, 40 mm): sharp crack, short body, fragments striking, a little debris'],\n ),\n blast(\n 'explosion_big',\n [\n crack([1900, 2300], 0.08, 2.4),\n noise({ f: [2200, 2600], f2: 90, d: 1.6, vol: 2.2, wet: 0.45 }),\n tone({ f: [52, 60], f2: 22, d: 1.6, vol: 1.9 }),\n noise({ f: [280, 330], f2: 60, a: 0.25, d: 2.8, vol: 0.8, wet: 0.6, delay: 0.05 }),\n ...debris(24, 0.5, 3.6, [0.12, 0.25]),\n ],\n ['sdk: big charge (C4, dynamite, a fuel station tank): crack, long deep roar, debris falling for 2 to 4 s'],\n ),\n blast(\n 'explosion_fuel',\n [\n noise({ type: 'highpass', f: [1700, 2000], a: 0.001, d: 0.05, vol: 1 }),\n tone({ f: [380, 450], f2: 300, d: 0.4, vol: 0.3 }),\n noise({ f: [1700, 2000], f2: 150, a: 0.03, d: 1.4, vol: 2.1, wet: 0.4 }),\n tone({ f: [48, 56], f2: 25, d: 1.2, vol: 1.7 }),\n noise({ type: 'bandpass', f: [450, 560], q: 0.6, a: 0.15, d: 2.2, vol: 0.85, wet: 0.5, delay: 0.1 }),\n ...debris(10, 0.5, 2.6, [0.08, 0.16]),\n ],\n ['sdk: a fuel vessel bursting (propane P13, fuel barrel, pump): the shell tearing, a fireball \"whoomp\" and its roar'],\n ),\n blast(\n 'explosion_car',\n [\n noise({ type: 'highpass', f: [1700, 2000], a: 0.001, d: 0.06, vol: 1.1 }),\n noise({ f: [1600, 1900], f2: 140, a: 0.03, d: 1.6, vol: 2.1, wet: 0.4 }),\n tone({ f: [44, 52], f2: 24, d: 1.4, vol: 1.8 }),\n noise({ type: 'bandpass', f: [420, 520], q: 0.6, a: 0.15, d: 2.6, vol: 0.9, wet: 0.5, delay: 0.1 }),\n ...glass(10, 0.04),\n tone({ f: [130, 150], f2: 85, d: 1.1, vol: 0.18, delay: [0.3, 0.5] }),\n ...debris(16, 0.6, 3.2, [0.1, 0.2]),\n ],\n ['sdk: a car going up: the fuel tank fireball, every window breaking, the body groaning, parts falling'],\n ),\n blast(\n 'explosion_pipe_bomb',\n [\n crack([2000, 2400], 0.07, 2.2),\n noise({ f: [2000, 2400], f2: 150, d: 0.8, vol: 1.9, wet: 0.35 }),\n tone({ f: [70, 82], f2: 30, d: 0.6, vol: 1.5 }),\n ...many(6, () => tone({ f: [1800, 3200], f2: 1200, d: [0.06, 0.12], vol: 0.06, delay: [0.05, 0.6] })),\n ...shrapnel(18, 0.9),\n ...debris(8, 0.4, 1.8, [0.08, 0.16]),\n ],\n ['sdk: pipe bomb: crack, body, the steel pipe flying apart in ringing pieces'],\n ),\n blast(\n 'explosion_rocket',\n [\n crack([2100, 2500], 0.08, 2.4),\n noise({ f: [2400, 2800], f2: 120, d: 1.1, vol: 2.1, wet: 0.4 }),\n tone({ f: [60, 70], f2: 26, d: 0.9, vol: 1.8 }),\n noise({ f: [350, 420], f2: 80, a: 0.08, d: 1.8, vol: 0.9, wet: 0.6, delay: 0.05 }),\n ...shrapnel(10, 0.8),\n ...debris(16, 0.4, 2.6, [0.1, 0.2]),\n ],\n ['sdk: rocket or anti-tank warhead (M72, AT4, RPG): hard crack, heavy body, debris'],\n ),\n blast(\n 'explosion_flashbang',\n [crack([1400, 1700], 0.12, 2.8), noise({ f: [1900, 2200], f2: 300, d: 0.35, vol: 1.3, wet: 0.3 }), tone({ f: [110, 130], f2: 60, d: 0.2, vol: 0.8 })],\n ['sdk: flashbang: a deafening crack with almost no body and no fragments'],\n ),\n blast(\n 'molotov_break_ignite',\n [\n ...glass(8, 0),\n noise({ f: [280, 340], f2: 2200, a: 0.12, d: 0.9, vol: 1.5, wet: 0.6, delay: 0.05 }),\n tone({ f: [85, 95], f2: 55, d: 0.4, vol: 0.5, delay: 0.08 }),\n ],\n ['sdk: molotov: the bottle breaking and the fuel catching with a \"fuuush\"'],\n FIRE_FALLOFF,\n ),\n blast(\n 'explosion_far',\n [\n noise({ f: [550, 650], f2: 80, a: 0.03, d: 2.5, vol: 2, wet: 1.4 }),\n tone({ f: [42, 48], f2: 25, d: 1.8, vol: 1.2 }),\n noise({ f: [350, 420], f2: 70, a: 0.1, d: 1.6, vol: 0.6, wet: 1.5, delay: [0.6, 1] }),\n ],\n ['sdk: any blast far away: no crack left, a dull thud and the echo rolling back'],\n BLAST_FAR_FALLOFF,\n ),\n blast(\n 'explosion_indoor_tail',\n [\n ...many(3, () => noise({ f: [650, 800], d: 0.12, vol: 0.5, delay: [0.04, 0.2] })),\n noise({ f: [850, 950], f2: 120, a: 0.05, d: 2.6, vol: 0.9, wet: 1.6, delay: 0.08 }),\n ],\n ['sdk: the room answering a blast inside it: slaps off the walls and a boomy tail'],\n ),\n]\n\n/** Fire: ignition, gas leaking from a vessel about to burst, a fire put out, and the crackles that ride on the fire loop. */\nexport const FIRE_SOUNDS: readonly SoundRecipe[] = [\n {\n ...blast(\n 'fire_ignite',\n [noise({ f: [230, 270], f2: 1500, a: 0.07, d: 0.5, vol: 1.6 }), tone({ f: [80, 90], f2: 55, d: 0.3, vol: 0.45 }), noise({ type: 'highpass', f: 3000, d: 0.3, vol: 0.1, delay: 0.1 })],\n ['sdk: fire catching, a soft \"fuuump\"'],\n FIRE_FALLOFF,\n ),\n group: 'fire_ignite',\n },\n {\n ...blast('gas_leak', [noise({ type: 'bandpass', f: [3200, 3800], q: 0.7, a: 0.08, d: { param: 'seconds' }, vol: 0.3 })], ['sdk: gas jetting from a punctured vessel'], FIRE_FALLOFF),\n vars: { seconds: 2 },\n },\n {\n ...blast(\n 'fire_extinguish',\n [noise({ type: 'highpass', f: [2300, 2700], a: 0.03, d: { param: 'seconds' }, vol: 0.3 }), noise({ type: 'bandpass', f: [800, 1000], q: 0.5, d: 0.5, vol: 0.25 })],\n ['sdk: water or foam on a fire: a steam puff and a sizzle'],\n FIRE_FALLOFF,\n ),\n vars: { seconds: 1.2 },\n },\n { ...blast('fire_crackle', [noise({ type: 'highpass', f: [1500, 3000], d: [0.01, 0.025], vol: [1.2, 2.2] })], ['sdk: a crackle of the fire'], FIRE_FALLOFF), group: 'fire_crackle' },\n { ...blast('fire_pop', [noise({ type: 'bandpass', f: [500, 1100], q: 1, d: [0.03, 0.06], vol: [3, 4.5] })], ['sdk: a log or a resin pocket popping'], FIRE_FALLOFF), group: 'fire_crackle' },\n]\n\n/** The roar of the fires: low, soft noise; `createDestructionSound` raises it with every part that burns and sprinkles crackles on it. */\nexport const FIRE_LOOP: LoopRecipe = {\n id: 'fire_loop',\n bus: 'world',\n order: 'chain_loop',\n source: { kind: 'noise', loop: true },\n filters: { mode: 'serial', bank: [{ type: 'lowpass', frequency: { set: 950 }, q: 0.5 }] },\n volume: 0,\n sources: ['sdk: the roar under the crackles of a fire'],\n}\n\n/** A rocket in flight (RPG-7, AT4, M72): the motor's steady roar behind it, dull and wide; the fallback of the recorded loop of the same id. */\nexport const ROCKET_MOTOR_LOOP: LoopRecipe = {\n id: 'rocket_motor_loop',\n bus: 'world',\n order: 'chain_loop',\n source: { kind: 'noise', loop: true },\n filters: { mode: 'serial', bank: [{ type: 'highpass', frequency: { set: 250 }, q: 0.6 }, { type: 'lowpass', frequency: { set: 5200 }, q: 0.5 }] },\n volume: 0,\n sources: ['sdk: the motor of a rocket in flight (a wide hiss with a low body, steady until the warhead goes off)'],\n}\n\n/** A smoke canister burning (an M18 and the like): a steady hiss of gas through the vents, bright and without crackles; the fallback of the recorded loop of the same id. */\nexport const SMOKE_HISS_LOOP: LoopRecipe = {\n id: 'smoke_grenade_hiss',\n bus: 'world',\n order: 'chain_loop',\n source: { kind: 'noise', loop: true },\n filters: { mode: 'serial', bank: [{ type: 'highpass', frequency: { set: 1400 }, q: 0.7 }, { type: 'lowpass', frequency: { set: 7000 }, q: 0.5 }] },\n volume: 0,\n sources: ['sdk: a smoke canister venting (the gas through its holes, steady for its whole burn)'],\n}\n\n/** The pin of a hand grenade pulled and the lever let go: two small metal clicks, heard only near. */\nexport const GRENADE_PIN_PULL: SoundRecipe = blast(\n 'grenade_pin_pull',\n [noise({ type: 'highpass', f: [3200, 4200], d: 0.025, vol: 0.5 }), noise({ type: 'bandpass', f: [2200, 2800], q: 2, d: 0.04, vol: 0.4, delay: 0.18 })],\n ['sdk: the ring pulled from the fuse, then the spoon flying off'],\n FIRE_FALLOFF,\n)\n\n/**\n * What is burning, for the sound: each fuel has its own roar (a gas jet, a fuel pool, wood, plastic) and its own share of crackles. The rules are the\n * same for all (the level grows with how much burns, fades with distance, never clips); only the timbre comes from the fuel.\n */\nexport const FIRE_FUELS = ['wood', 'fabric', 'plastic', 'gas', 'liquid'] as const\nexport type FireFuel = (typeof FIRE_FUELS)[number]\n\n/** The fuel of a burning material (`materials.json` of game-destruction). Data: a game adds its own materials through `DestructionSoundOptions.fuels`. */\nexport const FIRE_FUEL_OF: Readonly<Record<string, FireFuel>> = {\n wood_soft: 'wood',\n wood_hard: 'wood',\n plywood: 'wood',\n mdf: 'wood',\n green_wood: 'wood',\n foliage: 'wood',\n cactus: 'wood',\n paper: 'fabric',\n fabric: 'fabric',\n leather: 'fabric',\n foam: 'plastic',\n plastic: 'plastic',\n rubber: 'plastic',\n wax: 'plastic',\n}\n\n/** The loop each fuel plays. Fabric and paper share the wood roar until they have their own. */\nexport const FIRE_LOOP_OF: Readonly<Record<FireFuel, string>> = {\n wood: 'fire_loop',\n fabric: 'fire_loop',\n plastic: 'fire_loop_plastic',\n gas: 'fire_loop_gas',\n liquid: 'fire_loop_liquid',\n}\n\n/** How much each fuel crackles (0..1): wood snaps and pops, plastic now and then, a gas jet and a fuel pool not at all. */\nexport const FIRE_CRACKLE_OF: Readonly<Record<FireFuel, number>> = { wood: 1, fabric: 0.5, plastic: 0.35, gas: 0, liquid: 0 }\n\nconst roar = (id: string, bank: readonly FilterSpec[], source: string): LoopRecipe => ({\n id,\n bus: 'world',\n order: 'chain_loop',\n source: { kind: 'noise', loop: true },\n filters: { mode: 'serial', bank },\n volume: 0,\n sources: [source],\n})\n\n/** The synthesized roar of each fuel other than wood: the fallback of the recorded loops of the same id. */\nexport const FIRE_FUEL_LOOPS: readonly LoopRecipe[] = [\n // a gas jet: a steady, broad roar, brighter than wood and without crackles\n roar('fire_loop_gas', [{ type: 'highpass', frequency: { set: 220 }, q: 0.7 }, { type: 'lowpass', frequency: { set: 2400 }, q: 0.6 }], 'sdk: a gas jet burning (a vessel venting into the flame)'),\n // a fuel pool: a soft, low, rolling roar\n roar('fire_loop_liquid', [{ type: 'highpass', frequency: { set: 90 }, q: 0.7 }, { type: 'lowpass', frequency: { set: 650 }, q: 0.9 }], 'sdk: a pool of fuel burning'),\n // plastic and rubber: a thin sizzle over a low burn\n roar('fire_loop_plastic', [{ type: 'bandpass', frequency: { set: 1800 }, q: 0.6 }], 'sdk: plastic and rubber melting in the fire'),\n]\n\n/** The sound of a blast family. */\nexport const BLAST_SOUND_OF: Readonly<Record<BlastKind, string>> = {\n grenade: 'explosion_grenade',\n big: 'explosion_big',\n fuel: 'explosion_fuel',\n car: 'explosion_car',\n pipe_bomb: 'explosion_pipe_bomb',\n rocket: 'explosion_rocket',\n flashbang: 'explosion_flashbang',\n molotov: 'molotov_break_ignite',\n}\n","import type { Vec3 } from '@adatechnology/game-contracts'\nimport { FOLEY_BANK, GAME_SFX_BANK } from '@adatechnology/game-audio'\nimport type { AudioEngine, AudioLoopHandle } from '@adatechnology/game-audio'\n\nimport { BIG_BLAST_RADIUS, BLAST_FAR_DISTANCE, BLAST_KIND_OF, BLAST_SOUND_OF, FIRE_CRACKLE_OF, FIRE_FUEL_OF, FIRE_LOOP_OF } from './blast-fire'\nimport type { BlastKind, FireFuel } from './blast-fire'\nimport { DESTRUCTION_SOUND_BANK } from './recipes'\nimport type { SoundDetail } from '../types'\n\n/**\n * What a sound key plays: the recipe, its params, a scale on the volume the renderer gives, and (optionally) a louder recipe above a volume\n * (a big blast gets the long boom).\n */\nexport type SoundKeyRule = {\n readonly sound: string\n readonly params?: Readonly<Record<string, number>>\n readonly volumeScale?: number\n readonly above?: { readonly volume: number; readonly sound: string }\n /** A sound of this bank played when the engine does not know `sound` (a vehicle door without the vehicle bank registered shuts like metal). */\n readonly fallback?: string\n}\n\nexport type DestructionSoundStyle = 'art_scene' | 'game'\n\n/**\n * The keys of a blow on a material (`impactSoundKeys`, `breakSoundKeys`): `impact_<family>_<blow>`, `impact_<material>[_<blow>]`, `break_<...>`. The renderer\n * sends them before its legacy family key, so the first one with a rule plays; a game replaces any of them in `keys`.\n */\nexport const IMPACT_SOUND_KEYS: Readonly<Record<string, SoundKeyRule>> = {\n impact_metal_ballistic: { sound: 'metal_bullet' },\n impact_metal_blunt: { sound: 'metal_blunt' },\n impact_metal_slash: { sound: 'metal_blade' },\n impact_aluminium_ballistic: { sound: 'metal_thin' },\n impact_aluminium_blunt: { sound: 'metal_thin' },\n impact_copper_ballistic: { sound: 'metal_thin' },\n impact_copper_blunt: { sound: 'metal_thin' },\n impact_wood_ballistic: { sound: 'wood_hit' },\n impact_wood_blunt: { sound: 'wood_blunt' },\n impact_wood_slash: { sound: 'wood_blade' },\n break_wood: { sound: 'wood_splinter' },\n // the art scene's key for a part splintering and for a round striking steel or wood: the recordings answer them too\n splinter: { sound: 'wood_splinter' },\n shot_wood: { sound: 'wood_splinter' },\n shot_metal: { sound: 'metal_ping' },\n impact_mdf_ballistic: { sound: 'mdf_puff' },\n impact_mdf_blunt: { sound: 'mdf_puff', volumeScale: 0.8 },\n impact_glass_ballistic: { sound: 'glass_bullet' },\n impact_glass_blunt: { sound: 'glass_blunt' },\n impact_glass_slash: { sound: 'glass_blade' },\n impact_ceramic: { sound: 'ceramic_hit' },\n impact_ceramic_ballistic: { sound: 'ceramic_bullet' },\n impact_masonry_ballistic: { sound: 'masonry_bullet' },\n impact_masonry_blunt: { sound: 'masonry_blunt' },\n impact_masonry_slash: { sound: 'masonry_blade' },\n impact_plaster: { sound: 'plaster_puff' },\n impact_soil: { sound: 'soil_blunt' },\n impact_soil_ballistic: { sound: 'soil_bullet' },\n impact_sand: { sound: 'sand_hit' },\n impact_gravel: { sound: 'gravel_hit' },\n impact_plastic: { sound: 'plastic_hit' },\n impact_plastic_ballistic: { sound: 'plastic_bullet' },\n impact_rubber: { sound: 'rubber_hit' },\n impact_wax: { sound: 'wax_hit' },\n impact_soft_ballistic: { sound: 'soft_bullet' },\n impact_soft_blunt: { sound: 'fabric_hit' },\n impact_soft_slash: { sound: 'fabric_rip' },\n impact_paper: { sound: 'paper_hit' },\n impact_paper_slash: { sound: 'paper_tear' },\n impact_plant: { sound: 'leaf_rustle' },\n impact_plant_slash: { sound: 'branch_cut' },\n impact_flesh_fruit: { sound: 'fruit_splat' },\n ricochet_metal: { sound: 'ricochet_metal' },\n ricochet_masonry: { sound: 'ricochet_stone' },\n ricochet_soil: { sound: 'ricochet_stone' },\n ricochet_ceramic: { sound: 'ricochet_stone' },\n break_ceramic: { sound: 'ceramic_break' },\n break_tempered_glass: { sound: 'tempered_burst' },\n break_plastic: { sound: 'plastic_crack' },\n break_mdf: { sound: 'mdf_crumble' },\n break_soft: { sound: 'fabric_rip' },\n break_fabric: { sound: 'fabric_rip' },\n break_paper: { sound: 'paper_tear' },\n break_plant: { sound: 'branch_cut' },\n}\n\n/**\n * Every sound a blow, ricochet or break on a material can play (`sound`, `above.sound` and `fallback` of each rule of `rules`): a game preloads them on\n * the first input, so even the first ricochet or impact plays the recording instead of the synthesized recipe while the file is still loading.\n */\nexport const impactSoundIds = (rules: Readonly<Record<string, SoundKeyRule>> = IMPACT_SOUND_KEYS): string[] => {\n const ids = new Set<string>()\n for (const rule of Object.values(rules)) {\n ids.add(rule.sound)\n if (rule.above) ids.add(rule.above.sound)\n if (rule.fallback) ids.add(rule.fallback)\n }\n return [...ids]\n}\n\n/**\n * The keys `createDestructionRenderer` sends to `onSound`, mapped to the sounds the teams delivered. The Cena de Arte has a sound for every material\n * (clang, wood, glass, crumble, thud...); the game has four classes (impact, glass, wood, explosion) and its own explosion thump. Which team sound answers\n * which key is the kit's choice (the teams call the sounds, not the renderer's keys), so it is data: `keys` replaces any entry.\n */\nexport const DESTRUCTION_SOUND_KEYS: Readonly<Record<DestructionSoundStyle, Readonly<Record<string, SoundKeyRule>>>> = {\n art_scene: {\n impact_metal: { sound: 'clang' },\n impact_wood: { sound: 'wood_hit' },\n impact_glass: { sound: 'ping' },\n impact_masonry: { sound: 'chip' },\n impact_soft: { sound: 'thud' },\n // a round strikes: the steel rings high, glass cracks, wood and masonry chip, a soft part takes a dull thunk\n shot_metal: { sound: 'ping' },\n shot_wood: { sound: 'chip' },\n shot_glass: { sound: 'crack' },\n shot_masonry: { sound: 'chip' },\n shot_soft: { sound: 'thunk' },\n drag_wood: { sound: 'drag_wood' },\n drag_metal: { sound: 'drag_metal' },\n drag_glass: { sound: 'drag_glass' },\n drag_masonry: { sound: 'drag_masonry' },\n drag_soft: { sound: 'drag_soft' },\n // a leaf worked by hand (doors, lids, drawers): the latch, the hinge turning, the leaf meeting the frame, a locked one shaken\n leaf_latch: { sound: 'latch' },\n leaf_creak_wood: { sound: 'creak_wood' },\n leaf_creak_metal: { sound: 'creak_metal' },\n leaf_shut_wood: { sound: 'shut_wood' },\n leaf_shut_metal: { sound: 'shut_metal' },\n leaf_shut_glass: { sound: 'shut_metal', volumeScale: 0.6 },\n leaf_shut_masonry: { sound: 'shut_wood' },\n leaf_shut_soft: { sound: 'shut_soft' },\n leaf_rattle: { sound: 'rattle' },\n leaf_slide: { sound: 'slide' },\n // the keys of the item clips (furniture and vehicle doors, hoods, trunks, drawers)\n door_latch: { sound: 'latch' },\n hood_latch: { sound: 'latch' },\n trunk_latch: { sound: 'latch' },\n door_open: { sound: 'latch' },\n door_shut: { sound: 'shut_metal' },\n hood_shut: { sound: 'shut_metal' },\n trunk_shut: { sound: 'shut_metal' },\n door_close: { sound: 'shut_wood', volumeScale: 0.7 },\n // a vehicle's leaves (the vehicle bank of game-vehicles-three): a car door shuts with a padded thump and a latch, not like a fridge\n vehicle_door_open: { sound: 'car_door_open', fallback: 'latch' },\n vehicle_door_shut: { sound: 'car_door_close', fallback: 'shut_metal' },\n vehicle_trunk_open: { sound: 'car_door_open', fallback: 'latch' },\n vehicle_trunk_shut: { sound: 'car_trunk_close', fallback: 'shut_metal' },\n vehicle_hood_open: { sound: 'car_hood_open', fallback: 'latch' },\n vehicle_hood_shut: { sound: 'car_hood_close', fallback: 'shut_metal' },\n drawer_open: { sound: 'slide' },\n drawer_close: { sound: 'slide' },\n lid_open: { sound: 'latch' },\n lid_close: { sound: 'shut_soft' },\n flap_open: { sound: 'latch' },\n flap_close: { sound: 'shut_soft' },\n // an item taken in the hand, by what it is made of (game-audio's KIT_SAMPLE_ALIASES puts recordings on these ids)\n grab_metal: { sound: 'grab_hard' },\n grab_wood: { sound: 'grab_hard' },\n grab_glass: { sound: 'grab_hard', volumeScale: 0.7 },\n grab_masonry: { sound: 'grab_hard' },\n grab_soft: { sound: 'grab_soft' },\n shatter_glass: { sound: 'glass_shatter' },\n crumble: { sound: 'crumble' },\n splinter: { sound: 'crack' },\n ricochet: { sound: 'ping' },\n unscrew: { sound: 'chip' },\n detach: { sound: 'thunk' },\n ignite: { sound: 'fire_ignite' },\n primed: { sound: 'gas_leak' },\n extinguish: { sound: 'fire_extinguish' },\n melt_sizzle: { sound: 'hiss', params: { seconds: 0.6 } },\n // the blast family comes from the explosion's effect (`BLAST_KIND_OF`); this rule answers only an explosion the kit cannot place\n explode: { sound: 'explosion_grenade', above: { volume: 0.9, sound: 'explosion_big' } },\n ...IMPACT_SOUND_KEYS,\n },\n game: {\n impact_metal: { sound: 'sfx_impact' },\n impact_wood: { sound: 'sfx_wood' },\n impact_glass: { sound: 'sfx_glass' },\n impact_masonry: { sound: 'sfx_impact' },\n impact_soft: { sound: 'sfx_flesh' },\n shatter_glass: { sound: 'sfx_glass' },\n crumble: { sound: 'sfx_impact' },\n splinter: { sound: 'sfx_wood' },\n explode: { sound: 'explosion_boom' },\n },\n}\n\nexport type DestructionSoundOptions = {\n /** Which team answers the keys (default `art_scene`, the kit mix). `game` falls back to the art scene for the keys the game has no sound for. */\n readonly style?: DestructionSoundStyle\n /** Replaces or adds a key's rule; `null` silences it. A key without a rule that is the id of a registered sound (the foley bank's) plays that sound. */\n readonly keys?: Readonly<Record<string, SoundKeyRule | null>>\n /** The fire loop: the volume each burning part adds and the most it reaches (the page never raises it, so these are the kit's). */\n readonly fire?: { readonly perFire?: number; readonly max?: number }\n /** Burn loop on or off (default on). */\n readonly burnLoop?: boolean\n /** The loop of the wood fire (default `fire_loop`; `burn_loop` is the art scene's bright one). */\n readonly fireLoop?: string\n /** Adds to or changes `FIRE_FUEL_OF`: which fuel a burning material sounds like. */\n readonly fuels?: Readonly<Record<string, FireFuel>>\n /** Adds to or changes `FIRE_LOOP_OF`: the loop of each fuel. */\n readonly fireLoops?: Partial<Readonly<Record<FireFuel, string>>>\n /** The fuel of a fire whose material is not in the table (default `wood`). */\n readonly defaultFuel?: FireFuel\n /** Crackles per second over the fire loop: `base + perSqrtFire × √(parts burning)`, at most `max` (default 2, 3, 14). `false` turns them off. */\n readonly crackles?: false | { readonly base?: number; readonly perSqrtFire?: number; readonly max?: number; readonly volume?: number }\n /** Adds to or changes `BLAST_KIND_OF`: which family a named explosion (`effect`) sounds like. */\n readonly blastKinds?: Readonly<Record<string, BlastKind>>\n /** Metres past which a blast plays `explosion_far` instead of its own sound (default `BLAST_FAR_DISTANCE`). */\n readonly blastFarDistance?: number\n /** `confinement` of a blast (from its report) from which the indoor tail plays too (default 1.3). */\n readonly indoorConfinement?: number\n /** Seed of the crackle timing (default 1). */\n readonly seed?: number\n}\n\nexport type DestructionSound = {\n /** Pass to `createDestructionRenderer({ onSound })`. */\n readonly onSound: (key: string, point: Vec3, volume: number, detail?: SoundDetail) => void\n /** Moves the fire crackles on; call once per frame with the frame time in seconds. */\n update(dt: number): void\n /** The sound an explosion plays (`explode` with its detail), for a listener at the engine's listener position. */\n blastSound(point: Vec3, volume: number, detail?: SoundDetail): string\n /** The rule a key resolves to, if any; with `detail`, the rule `onSound` would play (the first of `detail.keys` that has one, else `key`'s). */\n rule(key: string, detail?: SoundDetail): SoundKeyRule | undefined\n /** Parts burning now. */\n readonly burning: () => number\n /** Parts burning now, by fuel. */\n readonly burningBy: () => Readonly<Partial<Record<FireFuel, number>>>\n /** Puts every fire sound out (the scene was cleared); the engine and the bank stay. */\n reset(): void\n dispose(): void\n}\n\nexport const DEFAULT_FIRE = { perFire: 0.08, max: 0.45 } as const\n/** A fire loop that ends fades out over this many seconds (moved on by `update`) before it is stopped. */\nexport const FIRE_FADE_SECONDS = 0.4\nexport const DEFAULT_CRACKLES = { base: 2, perSqrtFire: 3, max: 14, volume: 0.5 } as const\nexport const DEFAULT_INDOOR_CONFINEMENT = 1.3\n\n/**\n * Plays the renderer's sound keys on a game-audio engine: the bank is registered in the engine, a key becomes a positional sound at the point, and\n * `burn_loop` / `burn_end` (a part starts to burn, a part burns out or is put out) drive one fire loop whose volume follows how many parts burn, with\n * crackles at the burning points (`update`). An explosion plays the sound of its family (`BLAST_KIND_OF` by its effect), the far rumble past\n * `blastFarDistance` and the indoor tail when the blast was confined.\n */\nexport function createDestructionSound(engine: AudioEngine, options: DestructionSoundOptions = {}): DestructionSound {\n engine.register(DESTRUCTION_SOUND_BANK)\n engine.register(GAME_SFX_BANK)\n // the foley of the hand (doors, lids, drawers, items): its ids are keys of their own, played as they are\n engine.register(FOLEY_BANK)\n const fire = { ...DEFAULT_FIRE, ...options.fire }\n const crackles = options.crackles === false ? null : { ...DEFAULT_CRACKLES, ...options.crackles }\n const fireLoop = options.fireLoop ?? 'fire_loop'\n const kinds: Readonly<Record<string, BlastKind>> = { ...BLAST_KIND_OF, ...options.blastKinds }\n const farDistance = options.blastFarDistance ?? BLAST_FAR_DISTANCE\n const indoorFrom = options.indoorConfinement ?? DEFAULT_INDOOR_CONFINEMENT\n const rules: Record<string, SoundKeyRule | null | undefined> = { ...DESTRUCTION_SOUND_KEYS.art_scene, ...(options.style === 'game' ? DESTRUCTION_SOUND_KEYS.game : {}), ...options.keys }\n // a blast takes its family's sound unless the host chose the explode rule itself (a style or a key of its own)\n const blastByKind = options.style !== 'game' && !(options.keys && 'explode' in options.keys)\n const channel = engine.channel({ seed: options.seed ?? 1 })\n const fuelOf: Readonly<Record<string, FireFuel>> = { ...FIRE_FUEL_OF, ...options.fuels }\n const loopOf: Readonly<Record<FireFuel, string>> = { ...FIRE_LOOP_OF, ...(options.fireLoop ? { wood: fireLoop, fabric: fireLoop } : {}), ...options.fireLoops }\n const defaultFuel = options.defaultFuel ?? 'wood'\n // one loop per sound (fuels that share a loop share its level); a loop stops when nothing of its fuels burns\n const loops = new Map<string, AudioLoopHandle>()\n // where the fires are and what burns there: the crackles come from the points whose fuel crackles\n const fires: { readonly point: Vec3; readonly fuel: FireFuel }[] = []\n let nextCrackle = 0\n // loops whose fire ended: silenced now, stopped when their fade is over\n const fading: { readonly handle: AudioLoopHandle; left: number }[] = []\n\n const fadeOut = (handle: AudioLoopHandle): void => {\n handle.set({ volume: 0 })\n fading.push({ handle, left: FIRE_FADE_SECONDS })\n }\n\n const fuelFor = (detail: SoundDetail | undefined): FireFuel => detail?.fuel ?? (detail?.material !== undefined ? fuelOf[detail.material] : undefined) ?? defaultFuel\n\n const setFire = (): void => {\n if (options.burnLoop === false) return\n const count = new Map<string, number>()\n for (const f of fires) {\n const id = loopOf[f.fuel]\n count.set(id, (count.get(id) ?? 0) + 1)\n }\n for (const [id, handle] of loops) {\n if (count.has(id)) continue\n fadeOut(handle)\n loops.delete(id)\n }\n for (const [id, n] of count) {\n let handle = loops.get(id)\n if (!handle) {\n handle = engine.loop(id)\n loops.set(id, handle)\n }\n handle.set({ volume: Math.min(fire.max, fire.perFire * n) })\n }\n }\n\n // the nearest fire of that fuel goes out (any fuel when the end does not say)\n const forget = (point: Vec3, fuel: FireFuel | undefined): void => {\n let best = -1\n let bestD = Infinity\n fires.forEach((f, i) => {\n if (fuel !== undefined && f.fuel !== fuel) return\n const d = (f.point[0] - point[0]) ** 2 + (f.point[1] - point[1]) ** 2 + (f.point[2] - point[2]) ** 2\n if (d < bestD) {\n bestD = d\n best = i\n }\n })\n if (best < 0 && fuel !== undefined) forget(point, undefined)\n else if (best >= 0) fires.splice(best, 1)\n }\n\n const reset = (): void => {\n for (const handle of loops.values()) fadeOut(handle)\n loops.clear()\n fires.length = 0\n }\n const dispose = (): void => {\n for (const handle of loops.values()) handle.stop()\n loops.clear()\n for (const { handle } of fading) handle.stop()\n fading.length = 0\n fires.length = 0\n }\n\n const blastSound = (point: Vec3, volume: number, detail?: SoundDetail): string => {\n const named = detail?.effect === undefined ? undefined : kinds[detail.effect]\n const kind = named ?? ((detail?.radius ?? 0) >= BIG_BLAST_RADIUS || volume >= 0.9 ? 'big' : 'grenade')\n const sound = BLAST_SOUND_OF[kind]\n const distance = engine.plan(sound, { position: point, seed: 1 })?.distance ?? 0\n // a molotov is a fire, not a blast: it never turns into the far rumble\n return kind !== 'molotov' && distance > farDistance ? 'explosion_far' : sound\n }\n\n return {\n onSound(key, point, volume, detail) {\n if (key === 'burn_loop') {\n fires.push({ point, fuel: fuelFor(detail) })\n setFire()\n return\n }\n if (key === 'burn_end') {\n forget(point, detail?.fuel ?? (detail?.material !== undefined ? fuelOf[detail.material] : undefined))\n setFire()\n return\n }\n if (key === 'explode' && blastByKind) {\n const sound = blastSound(point, volume, detail)\n engine.play(sound, { position: point, volume })\n if (sound !== 'explosion_far' && sound !== 'molotov_break_ignite' && (detail?.confinement ?? 1) >= indoorFrom) engine.play('explosion_indoor_tail', { position: point, volume })\n return\n }\n // the most specific key that has a rule (material and blow, material, family and blow, family), else the key itself (a `shot_` key with no rule\n // falls back to its `impact_` one); `null` on a specific key silences it\n let rule: SoundKeyRule | null | undefined\n for (const k of detail?.keys ?? []) {\n if (k in rules) {\n rule = rules[k]\n break\n }\n }\n if (rule === undefined) rule = key in rules ? rules[key] : rules[key.replace(/^shot_/, 'impact_')]\n if (rule === null) return\n if (!rule) {\n // a key with no rule that names a registered sound plays that sound (the foley ids: `door_wood_close`, `item_pickup_metal`...)\n if (engine.registry.sound(key)) engine.play(key, { position: point, volume })\n return\n }\n const wanted = rule.above && volume >= rule.above.volume ? rule.above.sound : rule.sound\n const sound = rule.fallback && !engine.registry.sound(wanted) ? rule.fallback : wanted\n const params = detail?.seconds === undefined ? rule.params : { ...rule.params, seconds: detail.seconds }\n engine.play(sound, { position: point, volume: volume * (rule.volumeScale ?? 1), intensity: Math.min(1, Math.max(0, volume)), ...(params ? { params } : {}) })\n },\n update(dt) {\n for (let i = fading.length - 1; i >= 0; i--) {\n const entry = fading[i] as (typeof fading)[number]\n entry.left -= dt\n if (entry.left > 0) continue\n entry.handle.stop()\n fading.splice(i, 1)\n }\n if (!crackles || fires.length === 0 || options.burnLoop === false) return\n // only the fuels that crackle count: a gas jet or a fuel pool roars without snapping\n const weight = fires.reduce((sum, f) => sum + FIRE_CRACKLE_OF[f.fuel], 0)\n if (weight <= 0) return\n nextCrackle -= dt\n // at most a few crackles per frame, even after a long one\n for (let i = 0; i < 4 && nextCrackle <= 0; i++) {\n const rate = Math.min(crackles.max, crackles.base * Math.min(1, weight) + crackles.perSqrtFire * Math.sqrt(weight))\n nextCrackle += (0.4 + channel.random() * 1.2) / rate\n let pick = channel.random() * weight\n const at = fires.find((f) => (pick -= FIRE_CRACKLE_OF[f.fuel]) <= 0) ?? (fires[fires.length - 1] as (typeof fires)[number])\n engine.play(channel.random() < 0.18 ? 'fire_pop' : 'fire_crackle', { position: at.point, volume: crackles.volume })\n }\n if (nextCrackle < 0) nextCrackle = 0\n },\n blastSound,\n rule(key, detail) {\n for (const k of detail?.keys ?? []) if (k in rules) return rules[k] ?? undefined\n return rules[key] ?? undefined\n },\n burning: () => fires.length,\n burningBy: () => {\n const by: Partial<Record<FireFuel, number>> = {}\n for (const f of fires) by[f.fuel] = (by[f.fuel] ?? 0) + 1\n return by\n },\n reset,\n dispose,\n }\n}\n","// The recorded files of the blasts and the fire (`@adatechnology/game-audio/assets/sfx/explosoes-fogo`, field recordings): the numbers each sound id\n// needs on top of its files. Same ids as the synthesized recipes of `blast-fire.ts`, which stay as the fallback while the files load, when they fail,\n// and for every family that has no recording yet (fuel, pipe bomb, rocket, the indoor tail).\nimport { sampleBankFromManifest } from '@adatechnology/game-audio'\nimport type { SampleDefaults, SampleSound, SfxManifest, SoundBank } from '@adatechnology/game-audio'\nimport { BLAST_FALLOFF, BLAST_FAR_FALLOFF, FIRE_FALLOFF } from './blast-fire'\n\n/** The numbers of one recorded sound, plus whether it loops (the fire's roar). */\nexport type BlastFireSampleDefaults = SampleDefaults & { readonly loop?: boolean | { readonly crossfade?: number } }\n\nconst blast = (gain: number): BlastFireSampleDefaults => ({ bus: 'world', gain, falloff: BLAST_FALLOFF, cutoffK: 0.006, priority: 3 })\nconst fire = (gain: number, group?: string): BlastFireSampleDefaults => ({ bus: 'world', gain, falloff: FIRE_FALLOFF, cutoffK: 0.01, ...(group ? { group } : {}) })\n\n/**\n * The sounds of the blasts and the fire that have recorded takes, with their bus, level and distance curve (the recipes' own curves, so a file and its\n * fallback fade alike with distance). Data: a game passes its own table to `blastFireSampleBank`.\n */\nexport const BLAST_FIRE_SAMPLES: Readonly<Record<string, BlastFireSampleDefaults>> = {\n explosion_grenade: blast(1),\n explosion_big: blast(1),\n explosion_car: blast(1),\n explosion_flashbang: blast(1),\n explosion_rocket: blast(1),\n molotov_break_ignite: blast(0.8),\n // the far takes are already muffled: no extra distance lowpass\n explosion_far: { bus: 'world', gain: 1, falloff: BLAST_FAR_FALLOFF, cutoffK: 0, priority: 2 },\n fire_ignite: fire(0.8, 'fire_ignite'),\n fire_crackle: fire(0.8, 'fire_crackle'),\n fire_pop: fire(0.6, 'fire_crackle'),\n fire_extinguish: fire(0.7),\n gas_leak: fire(0.5),\n // the roar: recorded fires chained with a crossfade (the level comes from `createDestructionSound`, by how much burns)\n fire_loop: { bus: 'world', gain: 4, loop: { crossfade: 1 } },\n // each fuel has its own roar: a gas jet (burners and torches), a pool of fuel, plastic and rubber sizzling under the flames\n fire_loop_gas: { bus: 'world', gain: 6, loop: { crossfade: 1 } },\n fire_loop_liquid: { bus: 'world', gain: 3.5, loop: { crossfade: 1 } },\n fire_loop_plastic: { bus: 'world', gain: 1, loop: { crossfade: 0.6 } },\n // a smoke canister venting: a gas hiss chained like the fire roar (the level comes from the room, by how near the burning canisters are)\n smoke_grenade_hiss: { bus: 'world', gain: 1, loop: { crossfade: 0.8 } },\n // the motor of a rocket in flight, chained like the roar of a fire (the room sets the level by how near the rocket is)\n rocket_motor_loop: { bus: 'world', gain: 1, loop: { crossfade: 0.5 } },\n // the ring and the spoon of a hand grenade: a small metal latch\n grenade_pin_pull: fire(0.5),\n}\n\nexport type BlastFireSampleBankOptions = {\n /** Bank id (default 'destruction-samples'). */\n readonly id?: string\n /** Where the manifest's folder is served (`/sfx/`); default ''. */\n readonly baseUrl?: string\n /** Numbers per id (default `BLAST_FIRE_SAMPLES`). */\n readonly sounds?: Readonly<Record<string, BlastFireSampleDefaults>>\n}\n\n/**\n * A bank of the recorded blasts and fire from the kit's sound manifest. Register it with the engine next to `DESTRUCTION_SOUND_BANK`: each id plays\n * its files once loaded and its synthesized recipe until then.\n */\nexport function blastFireSampleBank(manifest: SfxManifest, options: BlastFireSampleBankOptions = {}): SoundBank {\n const sounds = options.sounds ?? BLAST_FIRE_SAMPLES\n const bank = sampleBankFromManifest(manifest, { id: options.id ?? 'destruction-samples', ...(options.baseUrl === undefined ? {} : { baseUrl: options.baseUrl }), sounds })\n const samples: SampleSound[] = (bank.samples ?? []).map((sample) => {\n const loop = sounds[sample.id]?.loop\n return loop === undefined ? sample : { ...sample, loop }\n })\n return { ...bank, samples }\n}\n"],"mappings":";;;;;AAWO,IAAM,qBAAgF;AAAA,EAC3F,CAAC,SAAS,OAAO;AAAA,EACjB,CAA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C,iBAAiB,KAAK,GAAG;AAAA,EACzB,UAAU,KAAK,GAAG;AAAA;AAAA,EAElB,WAAW,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,EAAE;AAAA;AAAA,EAE3D,eAAe,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,EAAE;AAAA,EAC/D,kBAAkB,EAAE,KAAK,SAAS,MAAM,KAAK,MAAM,EAAE,WAAW,EAAE,EAAE;AAAA,EACpE,mBAAmB,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,WAAW,IAAI,EAAE;AAAA;AAAA,EAErE,oBAAoB,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,WAAW,IAAI,EAAE;AAAA;AAAA,EAEtE,mBAAmB,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,WAAW,IAAI,EAAE;AAAA;AAAA,EAErE,kBAAkB,KAAK,GAAG;AAC5B;AAeO,SAAS,oBAAoB,UAAuB,UAAsC,CAAC,GAAc;AAC9G,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,OAAO,uBAAuB,UAAU,EAAE,IAAI,QAAQ,MAAM,uBAAuB,GAAI,QAAQ,YAAY,SAAY,CAAC,IAAI,EAAE,SAAS,QAAQ,QAAQ,GAAI,OAAO,CAAC;AACzK,QAAM,WAA0B,KAAK,WAAW,CAAC,GAAG,IAAI,CAAC,WAAW;AAClE,UAAM,OAAO,OAAO,OAAO,EAAE,GAAG;AAChC,WAAO,SAAS,SAAY,SAAS,EAAE,GAAG,QAAQ,KAAK;AAAA,EACzD,CAAC;AACD,SAAO,EAAE,GAAG,MAAM,QAAQ;AAC5B;","names":["glass","scene","SUPPORT_CHECKS","SUPPORT_GAP","impact","dot","c","along","v","t","j","scene","debrisColor","along","geo","noise","debrisColor","materialsOf","axis","radius","tone","fire","many","noise","sceneRecipe","tone","sceneRecipe","noise","tone","many","fire","sound","blast"]}
1
+ {"version":3,"sources":["../src/audio/impact-keys.ts","../src/renderer.ts","../src/blast-debris.ts","../src/event-class.ts","../src/event-weight.ts","../src/fragments.ts","../src/fitted-boxes.ts","../src/fragment-instances.ts","../src/math.ts","../src/fragment-shapes.ts","../src/pose-trail.ts","../src/ground.ts","../src/internal.ts","../src/static-part-job.ts","../src/worker-kinds.ts","../src/engine-ground-job.ts","../src/engine-ground-collision.ts","../src/engine-ground-step.ts","../src/engine-ground-ring.ts","../src/engine-ground-reach.ts","../src/engine-ground-solid.ts","../src/engine-ground.ts","../src/drawn-solids.ts","../src/drawn-boxes.ts","../src/rigid-pose.ts","../src/engine-statics.ts","../src/awake-list.ts","../src/friction.ts","../src/piece-contacts.ts","../src/engine-pieces.ts","../src/engine-ground-heights.ts","../src/engine-ground-schedule.ts","../src/physics-option.ts","../src/support-hull.ts","../src/pieces.ts","../src/rebar.ts","../src/spec.ts","../src/debris-events.ts","../src/jit-warmup.ts","../src/visual.ts","../src/bend.ts","../src/heat.ts","../src/mesh-ray-probe.ts","../src/skin-dent.ts","../src/stair-crack.ts","../src/settlement.ts","../src/settled-batches.ts","../src/emitter-anchor.ts","../src/vfx-source.ts","../src/index.ts","../src/blast-pacer.ts","../src/engine-ground-port.ts","../src/audio/recipes.ts","../src/audio/blast-fire.ts","../src/audio/sound.ts","../src/audio/voice-groups.ts","../src/audio/samples.ts"],"sourcesContent":["import type { DamageType, MaterialDef } from '@adatechnology/game-destruction'\n\nimport type { SoundDetail } from '../types'\n\n/**\n * The sound family of a material, from its tags: what it sounds like when something meets it. Finer than the five keys of `impactKey` (which stay the\n * last fallback): ceramic is not glass, the ground is not concrete, plastic and wax are not wood, leaves are not a sofa.\n */\nexport type ImpactFamily = 'metal' | 'glass' | 'ceramic' | 'soil' | 'masonry' | 'wood' | 'plant' | 'plastic' | 'rubber' | 'wax' | 'soft'\n\n/** Tag → family, in the order they are tried (`green_wood` is `plant` and `wood`: wood wins; `gravel` is `soil` and `masonry`: soil wins). */\nexport const IMPACT_FAMILY_TAGS: readonly (readonly [tag: string, family: ImpactFamily])[] = [\n ['metal', 'metal'],\n ['glass', 'glass'],\n ['ceramic', 'ceramic'],\n ['soil', 'soil'],\n ['masonry', 'masonry'],\n ['wood', 'wood'],\n ['plant', 'plant'],\n ['plastic', 'plastic'],\n ['rubber', 'rubber'],\n ['wax', 'wax'],\n ['fabric', 'soft'],\n]\n\n/** The family of a material, or `undefined` when none of its tags names one (the five legacy keys of `impactKey` then answer). */\nexport function impactFamily(def: MaterialDef | undefined): ImpactFamily | undefined {\n const tags = def?.tags ?? []\n for (const [tag, family] of IMPACT_FAMILY_TAGS) if (tags.includes(tag)) return family\n return undefined\n}\n\n/** What an impact or a break sends with its key: the keys to try before it, most specific first (material and blow, material, family and blow, family). */\nexport type ImpactKeys = SoundDetail & { readonly keys: readonly string[] }\n\nconst ordered = (prefix: string, material: string, family: ImpactFamily | undefined, blow: DamageType | undefined): string[] => {\n const keys: string[] = []\n if (material && blow) keys.push(`${prefix}_${material}_${blow}`)\n if (material) keys.push(`${prefix}_${material}`)\n if (family && blow) keys.push(`${prefix}_${family}_${blow}`)\n if (family) keys.push(`${prefix}_${family}`)\n return keys\n}\n\n/**\n * The impact keys for a blow on a material, most specific first: `impact_<material>_<blow>`, `impact_<material>`, `impact_<family>_<blow>`,\n * `impact_<family>` (blow is the `DamageType`: `ballistic`, `blunt`, `slash`, `explosive`...). The legacy `impactKey` is the last fallback the caller sends as the key.\n */\nexport function impactSoundKeys(material: string, def: MaterialDef | undefined, blow?: DamageType): ImpactKeys {\n return { keys: ordered('impact', material, impactFamily(def), blow) }\n}\n\n/** The keys for a part of this material breaking, most specific first: `break_<material>_<blow>`, `break_<material>`, `break_<family>_<blow>`, `break_<family>`. */\nexport function breakSoundKeys(material: string, def: MaterialDef | undefined, blow?: DamageType): ImpactKeys {\n return { keys: ordered('break', material, impactFamily(def), blow) }\n}\n\n/** The keys for a round glancing off a part of this material: `ricochet_<material>`, `ricochet_<family>` (then the plain `ricochet`). */\nexport function ricochetSoundKeys(material: string, def: MaterialDef | undefined): ImpactKeys {\n return { keys: ordered('ricochet', material, impactFamily(def), undefined) }\n}\n","import type * as THREE_NS from 'three'\nimport type { Crack, DamageType, DebrisKind, DestructionEvent, Fragment, MaterialDef, ObjectState, PartSettlement, PartSpec, Vec3 } from '@adatechnology/game-destruction'\nimport { breakSoundKeys, impactSoundKeys, ricochetSoundKeys } from './audio/impact-keys'\nimport { DEFERRED_PRIORITY, DEFERRED_QUEUE_ID, blastShove, drainDetached, warnOnce } from '@adatechnology/game-contracts'\nimport { createVfx, effectForEvent, EVENT_EFFECTS_MAP } from '@adatechnology/game-vfx'\nimport type { GameEvent } from '@adatechnology/game-vfx'\nimport type { VfxWorld } from '@adatechnology/game-vfx'\nimport { createVfxRenderer } from '@adatechnology/game-vfx-three'\nimport type { VfxRenderer } from '@adatechnology/game-vfx-three'\nimport { WorkBudget, WorkQueue } from '@adatechnology/game-physics'\nimport { BlastWakes, PhysicsCostMeter, chooseForPhysics, physicsPieceCount, resolveBlastDebris, resolveWorkUnitCosts, splitWorkUnits } from './blast-debris'\nimport type { BlastWake, DebrisCostSample, ResolvedBlastDebris, WorkUnitCosts } from './blast-debris'\nimport { EventOrder, isStructuralEvent } from './event-class'\nimport { eventApplyWeight } from './event-weight'\nimport { FragmentSystem } from './fragments'\nimport { GroundSpots } from './ground'\nimport type { Bound, HostVis, MeshVis, PartBox, PartVis, PieceBody, PieceRound } from './internal'\nimport { isTurned } from './internal'\nimport { drawnSolidsOf } from './drawn-solids'\nimport { hollowBoxesOf } from './drawn-boxes'\nimport { isRigidPose } from './rigid-pose'\nimport type { MeasureBudget } from './drawn-solids'\nimport { fitOrientedBoxes } from '@adatechnology/game-shapes'\nimport { clamp, createRng, hashNumbers, hashString } from './math'\nimport type { StaticSolid } from './engine-pieces'\nimport { sameSolids } from './engine-statics'\nimport { PieceSystem } from './pieces'\nimport type { PieceSweepHit } from './pieces'\nimport { RebarCages } from './rebar'\nimport { partHintOf, specFrameInverse } from './spec'\nimport { surfaceOf } from './friction'\nimport { kitOriginOf, markKitOrigin } from '@adatechnology/game-contracts'\nimport { debrisColor, debrisLook, fragmentTone } from '@adatechnology/game-destruction'\nimport { familyPlay, HitPoints } from './debris-events'\nimport type { FamilyPlay } from './debris-events'\nimport type { DeferredQueue, WarmUpProbes } from '@adatechnology/game-contracts'\nimport { warmUpDestructionJit } from './jit-warmup'\nimport type { DeferredQueueRegistration, DestructionRenderer, BindOptions, MakePieceOptions, ExplodeOptions, Mesh, MeshRange, Object3D, Piece, RendererOptions, SolidBox, SoundDetail, ThreeNamespace } from './types'\nimport { showCollapsedRanges, Visuals } from './visual'\nimport { SettlementView } from './settlement'\nimport { SettledBatches } from './settled-batches'\nimport type { SettledBatchStats } from './settled-batches'\nimport { anchorOnMesh, anchorWorld } from './emitter-anchor'\nimport { stampSource } from './vfx-source'\nimport type { EmitterAnchor } from './emitter-anchor'\n\nlet rendererCount = 0\n/** Most loose pieces and fragments simulated at once a game loop can start from (`RendererOptions.maxAwakePieces`, `maxAwakeFragments`; the default is no limit). */\nexport const SUGGESTED_MAX_AWAKE_PIECES = 24\nexport const SUGGESTED_MAX_AWAKE_FRAGMENTS = 64\n/** Mass (kg) a collapse of furniture must bring down to raise the collapse effect's cloud; less (a shelf with its books) raises a puff of dust. */\nconst COLLAPSE_CLOUD_KG = 1000\n/** Colour of bare rebar (the cages' material) and of a bar that came down; the steel of a bar weighs this much per cubic metre when the catalogue has no steel. */\nconst REBAR_COLOR = 0x74665c\nconst STEEL_DENSITY = 7850\n/** Metres around a unit that came out within which its decals go too: the plaster over it and the ragged edge that breaks with it. */\nconst CHIP_DECAL_EDGE = 0.05\n/** Radius of the rim of torn fibres around a hole in wood, in hole diameters. */\n/**\n * A round on concrete, stone or brick knocks a cone out of the face around its hole (front-face cratering): about five calibres across (a 7.62 leaves a crater of\n * 3 to 4 cm, a pistol round 2 to 3 cm), fresh broken material a shade lighter than the weathered face. Radius per hole diameter, its least (m) and the lightening.\n */\nconst CRATER_RADIUS = 2.5\nconst CRATER_MIN_RADIUS = 0.012\nconst CRATER_LIGHTEN = 0.12\nconst WOOD_RIM = 1.5\n\ntype Ev<T extends DestructionEvent['type']> = Extract<DestructionEvent, { type: T }>\n\nconst GLOW_FROM_C = 430\n/** A settlement crack is drawn at least this wide (m), so that a hairline still shows a few metres away; and in the colour of the open joint. */\nconst MIN_DRAWN_CRACK_WIDTH = 0.004\nconst SETTLEMENT_CRACK_COLOR = 0x2b2420\nconst QUEUE_CAP = 4000\n/** Seconds the grit of a broken hard face keeps falling (least, most), how often a pinch of it at first, and how many places at once. */\nconst TRICKLE_SECONDS: readonly [number, number] = [2, 5]\nconst TRICKLE_EVERY = 0.25\nconst TRICKLE_MAX = 24\n/** Frames in a row with a structural event waiting and no tick to apply it in, after which a frame drain applies everything (a paused or skipped simulation). */\nconst STALLED_FRAMES = 8\n/** Fragments of a fracture spawned in one go before the frame budget is looked at, so a small break is never split over frames. */\nconst MIN_FRAGMENTS_PER_SLICE = 8\n\n/** A loose group waiting its turn to become a piece (`RendererOptions.workBudget`): data only, so it can be saved. */\ninterface PendingSplit {\n readonly objectId: string\n /** Every part of the group when it came loose, sorted: at its turn the group is the loose one holding any of them still (a part may be shattered meanwhile). */\n readonly parts: readonly string[]\n readonly torn: ReadonlyArray<readonly [string, string]>\n}\n\n/** Fragments of a fracture still to spawn from `from` (`RendererOptions.workBudget`): data, not a closure. */\ninterface FragmentSlice {\n readonly ev: Ev<'fracture'>\n readonly from: number\n readonly look: { def: MaterialDef | undefined; color: number; opacity: number; transparent: boolean }\n}\n/** Seconds the boxes of the fixed objects the pieces land on are kept without an event (a host may move a root). */\nconst STATIC_REFRESH = 0.5\n/**\n * Objects the periodic re-measure takes per call: the refresh walks the objects a slice at a time (the dirty ones are measured at once). A count, not a clock: the boxes feed\n * the physics (`staticSolids`, `staticTopAt`), so what is measured when cannot depend on the machine. Measuring every object in one call cost up to 88 ms in a frame of the\n * horde chain (perf.mjs, software GL, 2026-11-03); a round of 8 a call covers 240 objects in the 0.5 s of `STATIC_REFRESH`.\n */\nconst STATIC_REFRESH_PER_UPDATE = 8\n/** Widest mesh (m, along x or z) a piece lands on by its box: furniture and things; a wider one (a roof, a merged room) would hold it on air. */\n/** Rays down `surfaceAt` casts at most, the distance under which a hit is the part it starts inside, and how far below such a hit it looks again (m). */\nconst SURFACE_RAYS = 4\nconst SURFACE_INSIDE = 0.005\nconst SURFACE_STEP = 0.15\nconst STATIC_SPAN = 3\n/** Vertices of fixed parts measured from scratch per update for an engine (about 2 ms): a house of hundreds of parts is filled in over a few updates, not one frame. */\nconst VERTICES_PER_UPDATE = 3000\n/** What counts as a foot of a piece (m above its lowest point); from what height (m) it can fall over and how close its feet are for that (share of the height). */\nconst FEET_BAND = 0.03\n/**\n * How far the centre of what is left of a piece of furniture must be inside the polygon of its feet to stand (`loosenIfFootless`), per metre of its height: it would have to\n * lean past atan(0.1), 6°, to go over. Less, it is balanced on an edge (a table on three legs, its centre a few centimetres inside the line between two of them) and goes over.\n */\nconst STAND_LEAN = 0.1\n/** The spin (rad/s) a piece of furniture balanced on an edge of its feet is started over it with. */\nconst EDGE_NUDGE = 1\nconst TIP_MIN_HEIGHT = 0.3\nconst TIP_NARROW = 0.3\n/** What a loose group hangs on (`hingeOf`) stands still when its piece is slower than this (m/s) and turns slower than this (rad/s). */\nconst HINGE_STILL_SPEED = 0.2\nconst HINGE_STILL_SPIN = 0.5\n/** Milliseconds the boxes fitted ahead of the blow take per events drain when no budget runs the `destruction.prefit` queue (`fitBoxesAhead`): a house is a few hundred parts, fitted over a few seconds. */\nconst PREFIT_SLICE_MS = 1\n\n/** Most meshes a loose piece of furniture touches the ground by, each by its own corners (`setContacts`); one with more stands on its box. */\nconst CONTACT_MESHES = 12\n/** Most meshes of a loose piece other pieces land on one by one (`partBoxes`: a shelf's boards, not the box around the shelf); one with more is landed on by its box. */\nconst PART_BOX_MESHES = 64\n/** Points of the drawing looked at to tell a round piece (per mesh), how alike its two other sides must be (share of the larger) and how far past their circle a point may be. */\nconst ROUND_SAMPLES = 400\nconst ROUND_SIDES = 0.12\n/** The least half side (m) of a piece's box, however small what is drawn of it. */\nconst MIN_PIECE_HALF = 0.02\nconst ROUND_SLACK = 1.12\n/** Points around each rim of a round piece (and around a ball's three great circles). */\nconst RIM_POINTS = 12\n\n/** The contacts of a round piece: two rims of `RIM_POINTS` at its ends (a cylinder), or three great circles (a ball), in its frame from the centre. */\nconst rimPoints = (round: PieceRound, half: Vec3): Vec3[] => {\n const out: Vec3[] = []\n const circle = (axis: 0 | 1 | 2, at: number, radius: number): void => {\n const [i, j] = axis === 0 ? [1, 2] : axis === 1 ? [0, 2] : [0, 1]\n for (let k = 0; k < RIM_POINTS; k++) {\n const a = (k / RIM_POINTS) * Math.PI * 2\n const p: Vec3 = [0, 0, 0]\n p[axis] = at\n p[i] = Math.cos(a) * radius\n p[j] = Math.sin(a) * radius\n out.push(p)\n }\n }\n if (round.kind === 'sphere') for (const axis of [0, 1, 2] as const) circle(axis, 0, round.radius)\n else {\n // each end by its own rim: a bottle stands on its base, and on its cap only as narrow as the cap is\n const ends = round.profile ?? []\n circle(round.axis, -half[round.axis], ends[0]?.[1] ?? round.radius)\n circle(round.axis, half[round.axis], ends[ends.length - 1]?.[1] ?? round.radius)\n }\n return out\n}\n/** Rings the profile of a round piece is measured in along its axis (`PieceRound.profile`): enough to tell a bottle's shoulder and neck from its body. */\nconst PROFILE_RINGS = 8\n/** k of I = k m r^2 about the axis: a thin cylindrical shell, a solid cylinder, a thin spherical shell and a solid ball. */\nconst SHELL_CYLINDER = 1\nconst SOLID_CYLINDER = 0.5\nconst SHELL_SPHERE = 2 / 3\nconst SOLID_SPHERE = 0.4\n/** Kg per litre of the liquid inside a round piece when its walls are weighed by what is left (water, soda, juice: about 1). */\nconst LIQUID_KG_PER_L = 1\n/** How much of a solid cylinder's moment the liquid in a rolling can adds: a liquid is dragged round by the walls but does not turn as one with them (0 a liquid that never spins, 1 frozen). */\nconst LIQUID_SPIN_COUPLING = 0.5\n/** The lightest a piece weighs in the physics (kg): below it the solver's mass ratios against a floor or a foot go wild. An empty can is 50 g, so it keeps its own mass. */\nexport const MIN_PIECE_MASS_KG = 0.02\n\n/**\n * The radius of a round piece along its axis, from the points of its drawing (its frame, from the centre of mass): the widest point of each of `PROFILE_RINGS` rings, the end rings\n * at the ends. Its lower hull (what a flat floor can touch it by) is kept: a ring under the line between its neighbours never touches (the neck of a bottle whose cap is as wide).\n */\nconst profileOf = (points: readonly Vec3[], axis: 0 | 1 | 2, half: number, radius: number): Array<readonly [number, number]> => {\n const [i, j] = axis === 0 ? [1, 2] : axis === 1 ? [0, 2] : [0, 1]\n const widest = new Array<number>(PROFILE_RINGS).fill(0)\n for (const p of points) {\n const ring = Math.min(PROFILE_RINGS - 1, Math.max(0, Math.floor(((p[axis] + half) / (2 * half)) * PROFILE_RINGS)))\n widest[ring] = Math.max(widest[ring], Math.hypot(p[i], p[j]))\n }\n const rings: Array<readonly [number, number]> = []\n for (let k = 0; k < PROFILE_RINGS; k++) {\n if (widest[k] <= 0) continue\n const at = k === 0 ? -half : k === PROFILE_RINGS - 1 ? half : -half + ((k + 0.5) / PROFILE_RINGS) * 2 * half\n rings.push([at, Math.min(radius, widest[k])])\n }\n // the outer hull of (at, radius): a ring inside the line from the one before it to the one after it is not touched\n const hull: Array<readonly [number, number]> = []\n for (const ring of rings) {\n while (hull.length >= 2) {\n const [a0, r0] = hull[hull.length - 2]\n const [a1, r1] = hull[hull.length - 1]\n // the middle one is under the line from the first to this ring: it never reaches the floor\n if ((r1 - r0) * (ring[0] - a0) <= (ring[1] - r0) * (a1 - a0)) hull.pop()\n else break\n }\n hull.push(ring)\n }\n return hull\n}\n\n/** How far (m) over its support what is left of a broken object may be and still stand; where under its lowest boxes the support is looked for (shares of the box). */\nconst BROKEN_GAP = 0.03\nconst BROKEN_SAMPLES: ReadonlyArray<readonly [number, number]> = [[0.5, 0.5], [0.1, 0.1], [0.9, 0.1], [0.1, 0.9], [0.9, 0.9]]\n/** Kinds of object that answer to a load path of their own (a house, a wall, the ground), not to `checkBroken`. */\nconst UNCHECKED_KINDS: ReadonlySet<string> = new Set(['structure', 'room', 'ground'])\n/** A part's fire lasts until the part stops burning (`stopFire`); this is only the ceiling the effects world needs. */\nconst FIRE_CEILING_SECONDS = 3600\n/** The `generic` explosion is the M67's (15 m injury radius): a blast with no effect id of its own scales with its radius. */\nconst GENERIC_REFERENCE_RADIUS = 15\n/** Largest half size (m) of the core of a piece swept for what it runs into: a sofa sweeps a small box at its centre, not the whole of it. */\nconst SWEEP_CORE = 0.15\n/** The small flame of a part that a bullet or fire primed: it burns until the part goes off. */\nconst PRIMED_FIRE_RADIUS = 0.2\n\n/** The joints that tear and still hold two parts that are in different groups of the object: the pairs of parts that are about to go apart. */\nfunction tornPairsOf(state: ObjectState): Array<readonly [string, string]> {\n const groupOf = new Map<string, number>()\n state.groups.forEach((group, index) => group.forEach((part) => groupOf.set(part, index)))\n return state.joints.filter((joint) => joint.tears === true && !joint.open && groupOf.get(joint.a) !== groupOf.get(joint.b)).map((joint) => [joint.a, joint.b] as const)\n}\n\ninterface FireEmitter {\n object: string\n part: string\n point: Vec3\n /** The burning part's position, moved every frame; the effects world's fire follows it. */\n follow: { x: number; y: number; z: number }\n /** Handle of the fire in the effects world, once the part's box is known. */\n handle?: number\n}\n\ninterface Leak {\n object: string\n part: string\n fluid: string\n point: Vec3\n direction: Vec3\n rate: number\n pressurized: boolean\n acc: number\n /** The part had a through opening when the leak began: the leak ends when it has none (a valve shut with `seal`). */\n opened: boolean\n localPoint?: Vec3\n localDirection?: Vec3\n lastLiters?: number\n idleSeconds?: number\n life?: number\n}\n\nconst FLUID_COLORS: Record<string, number> = {\n water: 0x8cc8ff,\n fuel: 0xd9a032,\n oil: 0x2a2018,\n gas: 0xf2f2f2,\n sap: 0xb89b3a,\n acid: 0x9bd23c,\n blood: 0x8a0a0a,\n soda: 0x3a1e12,\n coffee: 0x3b2414,\n beer: 0xd9953c,\n milk: 0xf4f1ea,\n wine: 0x6b101f,\n juice: 0xe8870b,\n}\nconst SMOKE_TONES: Record<string, number> = { white: 0xe6e6e6, grey: 0x8a8a8a, black: 0x2a2a2a }\n\nconst DEFAULT_SPEED: Record<string, number> = {\n sparks: 3,\n splinters: 2.5,\n dust: 1,\n shards: 2.5,\n fibers: 1.2,\n leaves: 1.2,\n drips: 0.5,\n ash: 0.8,\n chips: 2.5,\n smoke: 0.8,\n steam: 1,\n fire: 1.2,\n flash: 0,\n foam: 2.5,\n}\n\n/** Sound key for an impact on a material. */\nexport function impactKey(def: MaterialDef | undefined): string {\n if (!def) return 'impact_wood'\n const tags = def.tags ?? []\n if (tags.includes('metal')) return 'impact_metal'\n if (def.visual?.transparent || def.fracture === 'shatter') return 'impact_glass'\n if (def.fracture === 'crumble') return 'impact_masonry'\n if (def.fracture === 'tear') return 'impact_soft'\n return def.fracture === 'none' ? 'impact_metal' : 'impact_wood'\n}\n\n/** Sound key (`shot_*`) of a round striking this material: sharper than a blow (a tink on steel, a crack on glass); a host without it plays the `impact_*`. */\nexport const shotKey = (def: MaterialDef | undefined): string => impactKey(def).replace('impact_', 'shot_')\n\n/** Sound key (`drag_*`) of a base of this material dragged on a floor. */\nexport const dragSoundKey = (def: MaterialDef | undefined): string => impactKey(def).replace('impact_', 'drag_')\n\nfunction fractureKey(def: MaterialDef | undefined, style: string): string {\n switch (style) {\n case 'shatter':\n return 'shatter_glass'\n case 'crumble':\n return 'crumble'\n case 'splinter':\n return 'splinter'\n default:\n return impactKey(def)\n }\n}\n\n/** Colour of a material when the part gives none: its inside, a unit of it, or its family's (never wood brown on stone). */\nfunction fallbackColor(def: MaterialDef | undefined): number {\n return debrisColor(def)\n}\n\nfunction materialsOf(m: THREE_NS.Material | THREE_NS.Material[]): THREE_NS.Material[] {\n return Array.isArray(m) ? m : [m]\n}\n\nfunction isMeshRange(v: Object3D | MeshRange): v is MeshRange {\n const r = v as Partial<MeshRange>\n return !!r.mesh && Array.isArray(r.range)\n}\n\n/** Create the renderer. See `DestructionRenderer`. */\n/** The seed of the renderer's random stream; `reset` takes it back here. */\nconst RNG_SEED = 0xc0ffee\n\n/** The renderer this package makes always has its `deferredQueue`; a third-party `DestructionRenderer` may leave it out. */\nexport function createDestructionRenderer(THREE: ThreeNamespace, options: RendererOptions): DestructionRenderer & { deferredQueue(): DeferredQueue; deferredQueues(): readonly DeferredQueueRegistration[] } {\n if (options.jitWarmUp !== false) {\n // the throwaway renderer takes no number of the game's: the first real one is still `destruction-1`\n const before = rendererCount\n try {\n warmUpDestructionJit(THREE, (inner) => new Renderer(THREE, inner), options.jitWarmUp === true ? {} : options.jitWarmUp)\n } catch (error) {\n // the warm-up only saves time: the game starts without it\n warnOnce('game-destruction-three.jit-warm-up-failed', `game-destruction-three skipped the JIT warm-up: ${error instanceof Error ? error.message : String(error)}`)\n } finally {\n rendererCount = before\n }\n }\n return new Renderer(THREE, options)\n}\n\n/** true when both lists hold the very same numbers, in the same order. */\nconst sameNumbers = (a: readonly number[], b: readonly number[]): boolean => {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false\n return true\n}\n\nclass Renderer implements DestructionRenderer {\n private readonly world: RendererOptions['world']\n private readonly scene: THREE_NS.Scene\n private readonly quality: 'low' | 'medium' | 'high'\n private readonly low: boolean\n private readonly groundAt: (x: number, z: number) => number\n private readonly gravity: number\n private readonly autoSplit: boolean\n private readonly maxFragments: number\n /** The debris policy of blasts (`RendererOptions.blastDebris`), or null: a host that sets nothing wakes and loosens everything in the blast's frame, as before. */\n private readonly blastDebris: ResolvedBlastDebris | null\n private readonly blastWakes: BlastWakes | null\n private readonly costMeter: PhysicsCostMeter\n /** The step cost the debris policy reads this frame (`debrisCost`), null when there is none (the kit's own solver, or `fixed`). */\n private cost: DebrisCostSample | null = null\n private costFrame = 0\n /** The pieces faded away (`faded`): their root shrinks, then leaves the scene. */\n private readonly fading = new Map<string, { root: Object3D; age: number }>()\n private readonly eventBudgetMs: number\n private readonly bounds = new Map<string, Bound>()\n /** World boxes (min xyz, max xyz) of the drawn meshes of the bound objects that are not pieces, for the pieces to land on. */\n private readonly staticBoxes = new Map<string, number[]>()\n /** `staticSolids` per object, kept until `staticNow` measures the object again for a reason. */\n private readonly solidCache = new Map<string, { solids: StaticSolid[] }>()\n /** The objects `staticNow` measured again for a reason (an event, a moved root, boxes that changed): their `staticSolids` are measured again too. */\n private readonly solidStale = new Set<string>()\n /** The world matrix of each root when `staticNow` last measured it. */\n private readonly rootMatrices = new Map<string, number[]>()\n /** `clipToDrawn` per hosted body: the boxes it was given, the root's world matrix, and the boxes cut to what it draws. */\n private readonly clipped = new Map<string, { from: readonly StaticSolid[]; matrix: number[]; solids: readonly StaticSolid[] }>()\n /** Each drawn solid with its surface's friction (`withSurface`), by the solid `drawnSolidsOf` gave: weak, so a solid measured anew lets the old one go. */\n private readonly surfaced = new WeakMap<StaticSolid, StaticSolid>()\n /** The meshes whose world matrix one `staticSolids` call brought up to date (`MeasureBudget.updated`), emptied at its end. */\n private readonly measuredMeshes = new Set<object>()\n /** What `staticSolids` hands back, refilled each call. */\n private readonly solidsOut = new Map<string, readonly StaticSolid[]>()\n /** Objects to measure again; `staticAll` measures every one. */\n private readonly staticDirty = new Set<string>()\n private staticAll = true\n /** The periodic refresh: the objects still to measure again in this round, a slice per call. */\n private staticRound: string[] = []\n /** Boxes of the pieces' meshes (as `staticBoxes`), with the time they were measured. */\n private readonly pieceBoxes = new WeakMap<PieceBody, { at: number; boxes: number[] }>()\n /** Objects broken since the last update: `checkBroken` looks at what is left of them. */\n private readonly broken = new Set<string>()\n private staticAt = 0\n private queue: DestructionEvent[] = []\n /** The cover of each body around a part of the world that went off, read as the event is emitted: before the blast tore or moved anything. */\n private readonly coverWhenWentOff = new WeakMap<DestructionEvent, Map<string, number>>()\n /** Places a blow broke a hard face at: grit and dust keep coming off them for a few seconds, less and less (`TRICKLE_SECONDS`). */\n private readonly trickles: Array<{ point: Vec3; normal: Vec3; anchor: EmitterAnchor | null; color: number | undefined; left: number; total: number; next: number; source: string | undefined }> = []\n /** Presentation work an event left for later frames (fragments still to spawn, loose groups still to split), run in order within the frame budget; as data under `workBudget`. */\n private readonly slices: Array<(() => void) | FragmentSlice> = []\n /** The frame budget of work units the explosion's deferred work draws from (`RendererOptions.workBudget`), null when the clock cuts it as before. */\n private readonly work: WorkBudget | null\n private readonly workCosts: Required<WorkUnitCosts>\n /** The loose groups waiting to become pieces under `workBudget`, as data: the object, a part of the group, and the tearing joints read when it came loose. */\n private readonly splitQueue = new WorkQueue<PendingSplit>('split')\n /**\n * Objects bound or drawn again whose loose groups become pieces in the next drain: queued under `workBudget` (a load drops the queue the save was taken with), split without\n * it. The value says whether it came with a fresh `bind` (its pieces start where they stood, `splittingAtLoad`); one drawn again or given its pieces back splits as live.\n */\n private readonly looseToCheck = new Map<string, boolean>()\n /** Where the player was at the start of this frame's work step: read once per frame. */\n private workFocus: Vec3 | undefined\n /** True while the loose groups an object was freshly bound with are split (`splitChecked`): their pieces start where they stood, asleep when balanced on a support. */\n private splittingAtLoad = false\n /** The `WorkBudget` frame an event last split a group in: the first one of a frame goes over the budget, so a blow breaks something at once. */\n private eventSplitFrame = -1\n /** The boxes `fitOrientedBoxes` gave for the points of a part drawn by a range of a merged mesh (in its mesh's own space, unless its pose scales), kept with the points and triangles they came from: the same drawing is not fitted again. Released with the object (`forgetBound`). */\n private readonly fittedBoxes = new Map<MeshVis, { readonly points: readonly number[]; readonly triangles: readonly number[]; readonly boxes: ReturnType<typeof fitOrientedBoxes> }>()\n /** Objects whose ranged parts are still to be fitted ahead of the blow that breaks them, a part per step, only with time left in the frame. */\n private readonly prefitting: Array<{ readonly b: Bound; readonly parts: MeshVis[]; next: number }> = []\n /** When the work of this frame must stop; `Infinity` outside a drain, where a call finishes what it started. */\n private sliceDeadline = Infinity\n /** The clock the drain reads; a budget lends its own while it runs the queue. */\n private drainClock: () => number = () => performance.now()\n /** true once a frame budget owns the draining: `update` no longer drains by itself. */\n private attached = false\n /** true while the host applies the structural events itself, at the end of each tick (`applyStructuralEvents`): a frame drain leaves them, and what waits behind them, for the next tick. */\n private structuralInTick = false\n private readonly eventOrder = new EventOrder()\n /** true while the host holds every event (a blast still being run in slices, `holdEvents`): no drain applies one and no stall is counted. */\n private areEventsHeld = false\n /**\n * The structural events of a spread blast, arranged once as `applyStructuralEvents` arranges them, applied a slice per frame (`applyStructuralEventsSliced`); `tail`\n * is what followed the last structural one, given back to the queue when they are all applied.\n */\n private heldStructural: { readonly events: readonly DestructionEvent[]; readonly tail: readonly DestructionEvent[]; next: number } | undefined\n private stalledFrames = 0\n private watchedFrame = -1\n private readonly eventQueue: DeferredQueue = {\n id: DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS,\n pending: (frame) => this.watchStall(frame) + this.appliableEvents() + this.slices.length + this.splitQueue.size + this.looseLeft(),\n run: (deadline, clock) => this.runBudgeted(deadline, clock),\n flush: () => {\n for (let guard = 0; guard < 16 && this.queue.length + this.slices.length + this.splitQueue.size + this.looseLeft() > 0; guard++) this.runBudgeted(Infinity, () => 0, true)\n if (!this.prefitAttached) this.prefitQueue.flush()\n },\n attach: () => {\n this.attached = true\n },\n detach: () => {\n this.attached = false\n },\n }\n /** true once a frame budget owns the fitting ahead: the events drain no longer does it. */\n private prefitAttached = false\n private readonly prefitQueue: DeferredQueue = {\n id: DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT,\n pending: () => this.prefitLeft(),\n run: (deadline, clock) => this.runPrefit(deadline, clock),\n flush: () => {\n this.runPrefit(Infinity, () => 0)\n },\n attach: () => {\n this.prefitAttached = true\n },\n detach: () => {\n this.prefitAttached = false\n },\n }\n private readonly unsubscribe: () => void\n private readonly visuals: Visuals\n /** The parts the ground went down under, drawn going down (`subside`). */\n private readonly settlement: SettlementView\n private readonly fragments: FragmentSystem\n private readonly ground: GroundSpots\n private readonly pieceSys: PieceSystem\n private readonly cages: RebarCages\n /** The debris at rest drawn in batches. */\n private readonly settledBatches: SettledBatches\n private readonly hitPoints = new HitPoints()\n private readonly active = new Map<string, { object: string; part: string }>()\n private readonly fires = new Map<string, FireEmitter>()\n /** Primed parts burning in the effects world until they go off: their burn loop ends when they are put out. */\n private readonly primedBurning = new Set<string>()\n /** The burn loops asked of the host and not yet ended, by part: whatever stops a part's fire ends its loop, once, with what it started with. */\n private readonly burnSounds = new Map<string, { readonly object: string; readonly point: Vec3; readonly detail: SoundDetail | undefined }>()\n private readonly leaks: Leak[] = []\n private readonly homeTags: string[] = []\n private readonly throttles = new Map<string, number>()\n private rng = createRng(RNG_SEED)\n private readonly vfx: VfxWorld\n /** The object whose event is being applied: what the effects world is given while it is set is that object's (`stampSource`). */\n private emitting: string | undefined\n /** Names this renderer to the world's drips, so a shared world tells each renderer where its own landed. */\n private readonly owner = `destruction-${++rendererCount}`\n private readonly stopLanding: () => void\n /** The effects renderer made here when the host gave no shared world; it is stepped in `update`. */\n private readonly ownVfx: VfxRenderer | undefined\n private time = 0\n private scanTimer = 0\n private disposed = false\n private readonly box: THREE_NS.Box3\n private readonly tmpQ: THREE_NS.Quaternion\n private readonly v1: THREE_NS.Vector3\n private readonly v2: THREE_NS.Vector3\n private readonly v3: THREE_NS.Vector3\n private readonly q1: THREE_NS.Quaternion\n\n constructor(\n private readonly THREE: ThreeNamespace,\n private readonly o: RendererOptions,\n ) {\n this.world = o.world\n this.scene = o.scene\n this.quality = o.quality ?? 'medium'\n this.low = this.quality === 'low'\n this.groundAt = o.groundAt ?? (() => 0)\n this.gravity = o.gravity ?? 9.81\n this.autoSplit = o.autoSplit !== false\n this.maxFragments = o.maxFragments ?? 160\n this.blastDebris = o.blastDebris ? resolveBlastDebris(o.blastDebris) : null\n this.blastWakes = this.blastDebris ? new BlastWakes(this.blastDebris) : null\n const priors = resolveBlastDebris(o.blastDebris)\n this.costMeter = new PhysicsCostMeter(priors.physicsCostPerBodyMs, priors.wakeCostPerBodyMs)\n this.eventBudgetMs = o.eventBudgetMs ?? Infinity\n this.work = o.workBudget ? new WorkBudget(o.workBudget) : null\n this.workCosts = resolveWorkUnitCosts(o.workBudget?.costs)\n this.box = new THREE.Box3()\n this.tmpQ = new THREE.Quaternion()\n this.v1 = new THREE.Vector3()\n this.v2 = new THREE.Vector3()\n this.v3 = new THREE.Vector3()\n this.q1 = new THREE.Quaternion()\n const maxParticles = Math.max(8, Math.floor((o.maxParticles ?? 2500) * (this.low ? 0.5 : 1)))\n this.visuals = new Visuals(THREE, this.low, 600)\n this.settlement = new SettlementView(THREE, this.visuals)\n this.ground = new GroundSpots(THREE, o.scene, this.groundAt, 48)\n if (!o.vfx) warnOnce('game-destruction-three.own-effects-world', 'game-destruction-three made an effects world of its own because the host lent none (options.vfx); pass the host effects so the effects share one budget')\n this.vfx = stampSource(o.vfx ?? createVfx({ profile: this.quality, gravity: this.gravity, groundAt: this.groundAt, sprites: { capacity: maxParticles, density: this.low ? 0.6 : 1 } }), () => this.emitting)\n this.ownVfx = o.vfx ? undefined : createVfxRenderer(THREE, { scene: o.scene, camera: o.camera ?? new THREE.PerspectiveCamera(), vfx: this.vfx, pointScale: o.pointScale ?? 700 })\n this.stopLanding = this.vfx.onLand(this.owner, (x, _y, z, color, tag) => {\n const home = this.homeTags[tag - 1] ?? ''\n this.ground.add('puddle', x, z, 0.05 + this.rng() * 0.04, color, home)\n })\n this.fragments = new FragmentSystem(THREE, {\n scene: o.scene,\n groundAt: this.groundAt,\n gravity: this.gravity,\n max: this.maxFragments,\n life: o.fragmentLife ?? 12,\n formOf: (id) => this.world.materials.get(id)?.splitForm,\n crumbles: (id) => this.world.materials.get(id)?.fracture === 'crumble',\n // rubble lands on what is still built (a slab, a wall's top, a floor), not only on the terrain under it\n surfaceAt: (x, y, z) => this.surfaceAt(x, y, z),\n // and it meets the walls, ceilings and furniture on its way: it stops on their face instead of flying into them\n sweep: (from, direction, distance) => (typeof this.world.raycast === 'function' ? this.world.raycast([from[0], from[1], from[2]], [direction[0], direction[1], direction[2]], distance) : null),\n maxAwake: o.maxAwakeFragments ?? Infinity,\n ...(o.interpolate ? { interpolate: true } : {}),\n })\n this.cages = new RebarCages(THREE, o.scene)\n this.settledBatches = new SettledBatches(THREE, o.scene, o.settledBatches ?? { enabled: false })\n this.pieceSys = new PieceSystem(THREE, {\n physics: o.physics,\n ...(o.interpolate ? { interpolate: true } : {}),\n groundAt: this.groundAt,\n ...(o.terrainAt ? { terrainAt: o.terrainAt } : {}),\n ...(o.terrainRollingAt ? { terrainRollingAt: o.terrainRollingAt } : {}),\n ...(o.terrainRollingDampingAt ? { terrainRollingDampingAt: o.terrainRollingDampingAt } : {}),\n ...(o.terrainRangeAt ? { terrainRangeAt: o.terrainRangeAt } : {}),\n ...(o.terrainGridAt && o.terrainAt ? { terrainGridAt: o.terrainGridAt } : {}),\n ...(o.terrainPatchAt && o.terrainGridAt && o.terrainAt ? { terrainPatchAt: o.terrainPatchAt } : {}),\n ...(o.blastGroundTiles !== undefined ? { blastGroundTiles: o.blastGroundTiles } : {}),\n staticTopAt: (x, z, y, step) => this.staticTopAt(x, z, y, step),\n staticSolids: () => this.staticSolids(),\n gravity: this.gravity,\n scene: o.scene,\n maxAwake: o.maxAwakePieces ?? Infinity,\n ...(o.tilesUnderParts ? { tilesUnderParts: true } : {}),\n ...(o.groundWorker ? { groundWorker: o.groundWorker } : {}),\n ...(o.groundWorkerFrames !== undefined ? { groundWorkerFrames: o.groundWorkerFrames } : {}),\n ...(this.blastDebris\n ? { keep: { maxLive: this.blastDebris.maxLivePieces, far: this.blastDebris.far, ...(o.focus ? { focus: o.focus } : {}), onFade: (b: PieceBody) => this.fadePiece(b) } }\n : {}),\n onHardLanding: (p, point, speed) => this.hardLanding(p, point, speed),\n sweep: (p, from, to) => this.sweepPiece(p, from, to),\n onSlam: (p, hit, speed) => this.slam(p, hit, speed),\n // two pieces knocked together: each sounds as its material does (a can on a can, a bottle on a table's leg)\n onKnock: (a, b, point, speed) => {\n this.landingSound(a.objectId, point, clamp(speed / 10, 0.2, 1))\n this.landingSound(b.objectId, point, clamp(speed / 10, 0.2, 1))\n },\n })\n this.unsubscribe = this.world.on('*', (ev) => {\n if (ev.type === 'explode') this.coverWhenWentOff.set(ev, this.coverAround(ev))\n // past the cap only what changes the simulation is kept: a blast floods the queue with damage and marks, and a dropped collapse leaves a fallen wall drawn standing\n if (this.queue.length < QUEUE_CAP || isStructuralEvent(ev)) this.queue.push(ev)\n })\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Binding\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n bind(objectId: string, root: Object3D, options: BindOptions = {}): void {\n this.staticDirty.add(objectId)\n if (this.bounds.has(objectId)) this.unbind(objectId)\n const state = this.world.state(objectId)\n const partIds = new Set((state?.parts ?? []).map((p) => p.id))\n const byPart = new Map<string, Array<{ mesh: Mesh; range?: [number, number] }>>()\n const taken = new Set<Mesh>()\n const put = (pid: string, e: { mesh: Mesh; range?: [number, number] }): void => {\n const l = byPart.get(pid)\n if (l) l.push(e)\n else byPart.set(pid, [e])\n }\n const add = (pid: string, m: Mesh): void => {\n if (taken.has(m)) return\n taken.add(m)\n put(pid, { mesh: m })\n }\n const addRange = (pid: string, r: MeshRange): void => {\n const n = (r.mesh.geometry.getAttribute('position')?.count ?? 0) as number\n const [v0, v1] = r.range\n if (!Number.isInteger(v0) || !Number.isInteger(v1) || v0 < 0 || v1 <= v0 || v1 > n) {\n throw new Error(`game-destruction-three: invalid vertex range [${v0}, ${v1}) for part \"${pid}\" (the mesh has ${n} vertices)`)\n }\n put(pid, { mesh: r.mesh, range: [v0, v1] })\n }\n const meshesIn = (o: Object3D): Mesh[] => {\n const out: Mesh[] = []\n o.traverse((c) => {\n if ((c as Mesh).isMesh) out.push(c as Mesh)\n })\n return out\n }\n if (options.parts) {\n for (const [pid, v] of Object.entries(options.parts)) {\n for (const o of Array.isArray(v) ? v : [v]) {\n if (isMeshRange(o)) addRange(pid, o)\n else for (const m of meshesIn(o)) add(pid, m)\n }\n }\n } else {\n const leftovers: Mesh[] = []\n for (const m of meshesIn(root)) {\n const ud = partHintOf(m.userData?.destructionPart)?.id\n if (ud !== undefined && partIds.has(ud)) add(ud, m)\n else if (partIds.has(m.name)) add(m.name, m)\n else leftovers.push(m)\n }\n if (leftovers.length) this.matchByBox(objectId, root, leftovers, add)\n }\n const bound: Bound = { id: objectId, root, sync: options.syncTransform !== false, parts: new Map(), lastPos: null, lastQuat: null, piece: null, isSplit: false }\n if (options.onFrame) bound.onFrame = options.onFrame\n const hosts = new Map<Mesh, HostVis>()\n for (const pid of partIds) bound.parts.set(pid, this.makePartVis(objectId, pid, state?.parts.find((p) => p.id === pid)?.material ?? '', byPart.get(pid) ?? [], hosts))\n for (const [pid, meshes] of byPart) {\n if (!bound.parts.has(pid)) bound.parts.set(pid, this.makePartVis(objectId, pid, this.world.part(objectId, pid)?.material ?? '', meshes, hosts))\n }\n for (const [pid, hostIds] of Object.entries(options.marksOn ?? {})) {\n const pv = bound.parts.get(pid)\n const markHosts = hostIds.map((h) => bound.parts.get(h)).filter((h): h is PartVis => !!h && h !== pv)\n if (pv && markHosts.length) pv.markHosts = markHosts\n }\n this.bounds.set(objectId, bound)\n for (const pv of bound.parts.values()) this.tagPart(pv, objectId)\n if (this.o.fitBoxesAhead !== false) this.prefitPartBoxes(bound)\n this.checkLoose(objectId, true)\n }\n\n /**\n * Label the meshes of a part so a host can go from a raycast hit to the world: `userData.destructionPart` (the part id) and\n * `userData.destructionObject` (the id of the world object that part belongs to now; a loose piece has an id of its own). Parts drawn by a range\n * of a merged mesh share that mesh with others and are left alone until they get a mesh of their own. Decals are marked `destructionDebris`.\n */\n private tagPart(pv: PartVis, objectId: string): void {\n for (const mv of pv.meshes) {\n if (mv.merged && !mv.loose) continue\n mv.mesh.traverse((c) => {\n if (!(c as Mesh).isMesh) return\n const ud = c.userData as Record<string, unknown>\n if (ud.destructionDebris) return\n if (partHintOf(ud.destructionPart)?.id !== pv.id) ud.destructionPart = pv.id\n ud.destructionObject = objectId\n })\n }\n }\n\n private makePartVis(home: string, id: string, material: string, meshes: Array<{ mesh: Mesh; range?: [number, number] }>, hosts: Map<Mesh, HostVis>): PartVis {\n return { id, home, material, meshes: meshes.map((m) => this.visuals.makeMeshVis(m.mesh, home, m.range, hosts)), charApplied: 0, glowApplied: 0, meltApplied: 0, gone: 'none' }\n }\n\n /** Match unlabelled meshes to the part whose shape contains the centre of the mesh's bounding box. */\n private matchByBox(objectId: string, root: Object3D, meshes: Mesh[], add: (pid: string, m: Mesh) => void): void {\n let specParts: PartSpec[] | undefined\n try {\n specParts = this.world.serialize?.().objects.find((o) => o.id === objectId)?.spec.parts\n } catch {\n specParts = undefined\n }\n if (!specParts) return\n const frame = specFrameInverse(this.THREE, root)\n const e = new this.THREE.Euler()\n const q = new this.THREE.Quaternion()\n for (const m of meshes) {\n this.box.setFromObject(m)\n if (this.box.isEmpty()) continue\n const c = this.box.getCenter(this.v1).applyMatrix4(frame)\n let best: PartSpec | null = null\n let bestVol = Infinity\n for (const p of specParts) {\n const l = this.v2.set(c.x - p.position[0], c.y - p.position[1], c.z - p.position[2])\n if (p.rotation) l.applyQuaternion(q.setFromEuler(e.set(p.rotation[0], p.rotation[1], p.rotation[2], 'XYZ')).invert())\n let inside = false\n let vol = 0\n const s = p.shape\n if (s.kind === 'box') {\n inside = Math.abs(l.x) <= s.size[0] / 2 && Math.abs(l.y) <= s.size[1] / 2 && Math.abs(l.z) <= s.size[2] / 2\n vol = s.size[0] * s.size[1] * s.size[2]\n } else if (s.kind === 'cylinder') {\n inside = Math.hypot(l.x, l.z) <= s.radius && Math.abs(l.y) <= s.height / 2\n vol = Math.PI * s.radius * s.radius * s.height\n } else {\n inside = l.length() <= s.radius\n vol = (4 / 3) * Math.PI * s.radius ** 3\n }\n if (inside && vol < bestVol) {\n best = p\n bestVol = vol\n }\n }\n if (best) add(best.id, m)\n }\n }\n\n /** Drop an object from the bound ones, with the boxes fitted for its parts. */\n private forgetBound(objectId: string): void {\n const b = this.bounds.get(objectId)\n if (b) {\n for (const pv of b.parts.values()) for (const mv of pv.meshes) this.fittedBoxes.delete(mv)\n if (b.frozen) this.thawRoot(b)\n }\n this.bounds.delete(objectId)\n }\n\n unbind(objectId: string): void {\n this.staticDirty.add(objectId)\n this.clipped.delete(objectId)\n this.looseToCheck.delete(objectId)\n this.splitQueue.remove((entry) => entry.objectId === objectId)\n const b = this.bounds.get(objectId)\n if (!b) return\n this.restore(objectId)\n this.pieceSys.remove(objectId)\n this.forgetBound(objectId)\n this.hitPoints.forget(objectId)\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Pieces\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n /** Half extents and centre of the box around some meshes, in the metric frame of `root` (its pose removed, its scale kept). */\n private measure(root: Object3D, meshes: MeshVis[]): { half: Vec3; center: THREE_NS.Vector3 } {\n const inv = specFrameInverse(this.THREE, root)\n const total = new this.THREE.Box3()\n const m4 = new this.THREE.Matrix4()\n const lb = new this.THREE.Box3()\n for (const mv of meshes) {\n const m = mv.mesh\n m.updateWorldMatrix(true, false)\n this.visuals.localBox(mv, lb)\n if (lb.isEmpty()) continue\n total.union(lb.clone().applyMatrix4(m4.multiplyMatrices(inv, m.matrixWorld)))\n }\n if (total.isEmpty()) return { half: [0.25, 0.25, 0.25], center: new this.THREE.Vector3() }\n const size = total.getSize(new this.THREE.Vector3())\n return { half: [Math.max(MIN_PIECE_HALF, size.x / 2), Math.max(MIN_PIECE_HALF, size.y / 2), Math.max(MIN_PIECE_HALF, size.z / 2)], center: total.getCenter(new this.THREE.Vector3()) }\n }\n\n /**\n * A hosted body's boxes (`hostedSolids`: its damage zones) cut to the box of what its root draws, in the root's frame: the zones reach past the drawn body (17 cm each\n * side and 14 cm over the room's sedan), and a box where nothing is drawn is an invisible collider (§12): doors made by the wall it is parked against were made inside\n * it. A box turned against the root (a door swung open) is kept as it is. The same list back until the boxes or the root's place change.\n */\n private clipToDrawn(id: string, hosted: readonly StaticSolid[]): readonly StaticSolid[] {\n const b = this.bounds.get(id)\n if (!b) return hosted\n // the root's meshes are measured by their bounds: a merged mesh with a write pending in the batch must show them\n this.visuals.flushPendingRebuilds()\n b.root.updateWorldMatrix(true, true)\n const m = b.root.matrixWorld.elements\n const known = this.clipped.get(id)\n if (known && known.from === hosted && known.matrix.every((v, k) => v === m[k])) return known.solids\n const inv = new this.THREE.Matrix4().copy(b.root.matrixWorld).invert()\n const drawn = new this.THREE.Box3()\n const part = new this.THREE.Box3()\n const to = new this.THREE.Matrix4()\n b.root.traverseVisible((o) => {\n const mesh = o as Mesh\n if (!mesh.isMesh || !mesh.geometry) return\n if (!mesh.geometry.boundingBox) mesh.geometry.computeBoundingBox()\n if (!mesh.geometry.boundingBox) return\n drawn.union(part.copy(mesh.geometry.boundingBox).applyMatrix4(to.multiplyMatrices(inv, mesh.matrixWorld)))\n })\n const rootQ = new this.THREE.Quaternion()\n b.root.getWorldQuaternion(rootQ)\n const solids = drawn.isEmpty() ? hosted : this.clipEach(hosted, { drawn, inv, root: b.root, rootQ })\n this.clipped.set(id, { from: hosted, matrix: [...m], solids })\n return solids\n }\n\n private clipEach(hosted: readonly StaticSolid[], frame: { readonly drawn: THREE_NS.Box3; readonly inv: THREE_NS.Matrix4; readonly root: Object3D; readonly rootQ: THREE_NS.Quaternion }): StaticSolid[] {\n const out: StaticSolid[] = []\n const q = new this.THREE.Quaternion()\n const c = new this.THREE.Vector3()\n const box = new this.THREE.Box3()\n for (const s of hosted) {\n q.set(s.rotation[0], s.rotation[1], s.rotation[2], s.rotation[3])\n // turned against the root (a part posed): kept as the world holds it\n if (Math.abs(q.dot(frame.rootQ)) < 1 - 1e-6) {\n out.push(s)\n continue\n }\n c.set(s.center[0], s.center[1], s.center[2]).applyMatrix4(frame.inv)\n box.min.set(c.x - s.half[0], c.y - s.half[1], c.z - s.half[2])\n box.max.set(c.x + s.half[0], c.y + s.half[1], c.z + s.half[2])\n box.intersect(frame.drawn)\n if (box.isEmpty()) continue\n const center = box.getCenter(c).applyMatrix4(frame.root.matrixWorld)\n out.push({ center: [center.x, center.y, center.z], half: [(box.max.x - box.min.x) / 2, (box.max.y - box.min.y) / 2, (box.max.z - box.min.z) / 2], rotation: s.rotation })\n }\n return out\n }\n\n /** Whether a bound object has no mesh here at all (another module draws it), as against one whose meshes all broke or are hidden. */\n private drawsNothingHere(objectId: string): boolean {\n const b = this.bounds.get(objectId)\n if (!b) return false\n for (const pv of b.parts.values()) if (pv.meshes.length > 0) return false\n return true\n }\n\n private meshesOf(b: Bound): MeshVis[] {\n const out: MeshVis[] = []\n for (const pv of b.parts.values()) if (pv.gone === 'none') for (const mv of pv.meshes) out.push(mv)\n return out\n }\n\n private massOf(objectId: string): number {\n const st = this.world.state(objectId)\n if (!st) return 5\n let m = 0\n for (const p of st.parts) if (p.status !== 'broken' && p.status !== 'melted' && p.status !== 'ashes') m += p.mass\n return m > 0 ? m : 5\n }\n\n /** The mass of a piece changed (a liquid drunk or leaked out of it): its mass follows, and a round one turns by the moment of what is left in it. */\n setPieceMass(objectId: string, mass: number): void {\n const b = this.bounds.get(objectId)\n const body = b?.piece ?? this.pieceSys.get(objectId)\n if (!b || !body) return\n // what the world's parts weigh minus what the piece weighs now: the liquid that left, kept over the refits a break makes\n body.massOffset = Math.max(0, this.massOf(objectId) - mass)\n body.mass = Math.max(MIN_PIECE_MASS_KG, mass)\n if (body.round) this.fitSurface(b, body)\n body.sleeping = false\n }\n\n makePiece(objectId: string, options: MakePieceOptions = {}): Piece {\n this.staticDirty.add(objectId)\n const b = this.bounds.get(objectId)\n if (!b) throw new Error(`game-destruction-three: object \"${objectId}\" is not bound`)\n if (b.root.parent && b.root.parent !== this.scene) this.scene.attach(b.root)\n const { half, center } = this.measure(b.root, this.meshesOf(b))\n const piece = this.pieceSys.create(objectId, b.root, half, center, options.mass ?? this.massOf(objectId), options.velocity)\n b.piece = piece\n this.fitSurface(b, piece, options.inertia)\n this.fitPartBoxes(b, piece)\n return piece\n }\n\n /**\n * What lands on or runs into a piece of several meshes meets its parts as drawn (`partBoxes`: a bench's slats, a table's top and legs), from the moment it is made a piece, not\n * the box around them all: a board laid on a bench rests on its seat, a can rolls under a table between its legs. Its own contacts with the ground are left as they were.\n */\n private fitPartBoxes(b: Bound, body: PieceBody): void {\n if (body.round) return\n const contacts = body.contacts\n this.setContacts(b, body, this.meshesOf(b).filter((mv) => this.visuals.shown(mv)))\n body.contacts = contacts\n }\n\n /** What the piece's surface is (the friction of the material it stands on) and whether it is round (`round`: it rolls on rings of contacts). */\n private fitSurface(b: Bound, body: PieceBody, inertia?: number): void {\n // the surface it stands on is its lowest part (a sofa's feet, a can's steel), whatever most of its weight is\n const box = new this.THREE.Box3()\n let low = Infinity\n let material: string | null = null\n for (const [partId, pv] of b.parts) {\n if (pv.gone !== 'none') continue\n for (const mv of pv.meshes) {\n if (!this.visuals.shown(mv)) continue\n this.visuals.worldBox(mv, box)\n if (box.isEmpty() || box.min.y >= low - 0.005) continue\n low = box.min.y\n material = this.world.part(b.id, partId)?.material ?? pv.material ?? null\n }\n }\n const surface = material ? surfaceOf(material, this.world.materials.get(material)) : undefined\n body.friction = surface && { static: surface.static, dynamic: surface.dynamic, rolling: surface.rolling, rollingDamping: surface.rollingDamping }\n body.restitution = surface?.restitution\n const wasRound = body.round !== undefined\n if (inertia !== undefined) body.inertiaGiven = inertia\n const round = this.roundOf(b, body)\n body.round = round ?? undefined\n if (round) {\n body.contacts = rimPoints(round, body.halfExtents)\n body.partBoxes = undefined\n } else if (wasRound) body.contacts = undefined\n }\n\n /**\n * k of a round piece's moment of inertia about its axis (I = k m r^2), from where its mass is. A piece that is not hollow is a solid (k 1/2 for a cylinder, 2/5 for a ball).\n * A hollow one (`userData.hollow`) with nothing inside (no `destructionContains` liquid, no `destructionPowder`) is all wall, a thin shell (k 1, 2/3): an empty can. One with\n * contents weighs its walls as their area times their thickness (`destructionThickness`) times density, or, without a thickness, as what is left of its mass besides the liquid\n * (`LIQUID_KG_PER_L`), and the rest as a solid: a full 350 ml can comes to about 0.53 and rolls down a slope at g sin t / 1.53, an empty one at g sin t / 2.\n */\n private inertiaOf(b: Bound, body: PieceBody, kind: PieceRound['kind'], axis: 0 | 1 | 2, radius: number): number {\n const shell = kind === 'sphere' ? SHELL_SPHERE : SHELL_CYLINDER\n const solid = kind === 'sphere' ? SOLID_SPHERE : SOLID_CYLINDER\n let hollow = false\n let filled = false\n let liters = 0\n let thickness = 0\n let material: string | null = null\n for (const [partId, pv] of b.parts) {\n if (pv.gone !== 'none') continue\n for (const mv of pv.meshes) {\n const ud = mv.mesh.userData as { hollow?: unknown; destructionThickness?: unknown; destructionContains?: { liters?: unknown }; destructionPowder?: unknown }\n if (ud.hollow !== true) continue\n hollow = true\n if (ud.destructionPowder) filled = true\n if (ud.destructionContains) {\n filled = true\n // what is left in it now (drunk or leaked), else what it was filled with\n const left = this.world.part(b.id, partId)?.liters\n liters += left ?? (typeof ud.destructionContains.liters === 'number' ? ud.destructionContains.liters : 0)\n }\n const t = typeof ud.destructionThickness === 'number' ? ud.destructionThickness : 0\n if (t > thickness) {\n thickness = t\n material = this.world.part(b.id, partId)?.material ?? pv.material\n }\n }\n }\n if (!hollow) return solid\n if (!filled) return shell\n const density = material ? this.world.materials.get(material)?.density : undefined\n const area = kind === 'sphere' ? 4 * Math.PI * radius * radius : 2 * Math.PI * radius * 2 * body.halfExtents[axis] + 2 * Math.PI * radius * radius\n const walls = density && thickness > 0 ? area * thickness * density : body.mass - liters * LIQUID_KG_PER_L\n const share = clamp(walls / body.mass, 0, 1)\n // the liquid inside lags the walls: it carries a part of what a solid of its mass would\n const liquidShare = clamp((liters * LIQUID_KG_PER_L) / body.mass, 0, 1 - share)\n return share * shell + (1 - share - liquidShare) * solid + liquidShare * solid * LIQUID_SPIN_COUPLING\n }\n\n /**\n * Whether what is drawn of the piece is round about one of its axes (a can, a bottle, a plate) or all of them (a ball): its points, in its frame from the centre of\n * mass, all lie within the circle the box's two other sides draw (a box's corners would stick out of it by sqrt 2). Null for anything else.\n */\n private roundOf(b: Bound, body: PieceBody): PieceRound | null {\n const half = body.halfExtents\n const inv = specFrameInverse(this.THREE, b.root)\n const m4 = new this.THREE.Matrix4()\n const p = new this.THREE.Vector3()\n const [cx, cy, cz] = body.localCenter\n const points: Vec3[] = []\n for (const mv of this.meshesOf(b)) {\n if (!this.visuals.shown(mv) || mv.host) continue\n const pos = (mv.mesh.geometry as THREE_NS.BufferGeometry).getAttribute('position')\n if (!pos) continue\n mv.mesh.updateWorldMatrix(true, false)\n m4.multiplyMatrices(inv, mv.mesh.matrixWorld)\n const stride = Math.max(1, Math.floor(pos.count / ROUND_SAMPLES))\n for (let i = 0; i < pos.count; i += stride) {\n p.fromBufferAttribute(pos, i).applyMatrix4(m4)\n points.push([p.x - cx, p.y - cy, p.z - cz])\n }\n }\n if (points.length < 12) return null\n // what is drawn reaches this far each way: a chip smaller than the least box a piece gets (`MIN_PIECE_HALF`) sits well inside its box, and inside the circle of it\n // too, square or not (a 1 x 1 cm splinter of a blast rolled like a pencil at 600 rad/s, for good)\n const drawn = new Float64Array(3)\n for (const q of points) for (let k = 0; k < 3; k++) drawn[k] = Math.max(drawn[k], Math.abs(q[k]))\n const fits = (axis: 0 | 1 | 2): number | null => {\n const [i, j] = axis === 0 ? [1, 2] : axis === 1 ? [0, 2] : [0, 1]\n // the two other sides alike, and no point out past the circle they draw, both as drawn\n if (Math.abs(half[i] - half[j]) > ROUND_SIDES * Math.max(half[i], half[j])) return null\n if (Math.abs(drawn[i] - drawn[j]) > ROUND_SIDES * Math.max(drawn[i], drawn[j])) return null\n const reach = (drawn[i] + drawn[j]) / 2\n for (const q of points) if (Math.hypot(q[i], q[j]) > reach * ROUND_SLACK) return null\n return (half[i] + half[j]) / 2\n }\n const radii = ([0, 1, 2] as const).map(fits)\n if (radii.every((r) => r !== null)) {\n const radius = (half[0] + half[1] + half[2]) / 3\n return { kind: 'sphere', axis: 1, radius, inertia: body.inertiaGiven ?? this.inertiaOf(b, body, 'sphere', 1, radius) }\n }\n const axis = ([0, 1, 2] as const).find((k) => radii[k] !== null)\n if (axis === undefined) return null\n const radius = radii[axis] ?? 0\n return { kind: 'cylinder', axis, radius, inertia: body.inertiaGiven ?? this.inertiaOf(b, body, 'cylinder', axis, radius), profile: profileOf(points, axis, half[axis], radius) }\n }\n\n pieces(): Piece[] {\n return [...this.pieceSys.list]\n }\n\n piece(objectId: string): Piece | null {\n return this.pieceSys.get(objectId)\n }\n\n impulse(objectId: string, impulse: Vec3, point?: Vec3): void {\n const p = this.pieceSys.get(objectId)\n if (p) this.pieceSys.impulse(p, impulse, point)\n }\n\n /**\n * What a piece moving from `from` to `to` runs into: the core of its box (its thinnest half each way, at most `SWEEP_CORE`) swept through the world, the piece itself left out,\n * so a crate thrown by a blast stops at the wall instead of passing through it. Null for a world that cannot sweep.\n */\n private sweepPiece(p: PieceBody, from: Vec3, to: Vec3): PieceSweepHit | null {\n if (typeof this.world.sweepBox !== 'function') return null\n const d: Vec3 = [to[0] - from[0], to[1] - from[1], to[2] - from[2]]\n const travel = Math.hypot(d[0], d[1], d[2])\n if (travel < 1e-4) return null\n const core = Math.min(SWEEP_CORE, ...p.halfExtents)\n const box = { min: [from[0] - core, from[1] - core, from[2] - core] as Vec3, max: [from[0] + core, from[1] + core, from[2] + core] as Vec3 }\n const hit = this.world.sweepBox(box, d, travel, { ignore: p.objectId, spacing: Math.max(0.05, core) })\n if (!hit) return null\n // a round piece and another piece meet by their shapes and trade momentum (`PieceSystem.knock`), not as a piece against a wall\n const other = this.pieceSys.get(hit.object)\n if (other && (p.round || other.round)) return null\n const material = this.world.part(hit.object, hit.part)?.material\n const restitution = material === undefined ? undefined : surfaceOf(material, this.world.materials.get(material))?.restitution\n return { object: hit.object, part: hit.part, distance: hit.distance, point: hit.point, normal: hit.normal, ...(restitution === undefined ? {} : { restitution }) }\n }\n\n /** A piece thrown into a wall: the wall takes the blow of its weight where it met it, the piece takes it too, and each sounds as its material does. */\n private slam(p: PieceBody, hit: PieceSweepHit, speed: number): void {\n const energy = 0.5 * p.mass * speed * speed\n const direction: Vec3 = [-hit.normal[0], -hit.normal[1], -hit.normal[2]]\n this.landingSound(hit.object, hit.point, clamp(speed / 10, 0.2, 1))\n this.syncBound(p.objectId)\n try {\n this.world.hitPart(hit.object, hit.part, { type: 'blunt', point: hit.point, energy, radius: 0.1, direction, normal: hit.normal, source: p.objectId })\n this.world.hit(p.objectId, { type: 'blunt', point: hit.point, energy, radius: 0.08, direction: hit.normal, source: 'slam' })\n } catch {\n // either may have left the world\n }\n }\n\n private hardLanding(p: PieceBody, point: Vec3, speed: number): void {\n this.landingSound(p.objectId, point, clamp(speed / 10, 0.2, 1))\n // the piece just moved this frame: the world must know where it is before the hit is resolved against its parts\n this.syncBound(p.objectId)\n try {\n this.world.hit(p.objectId, { type: 'blunt', point, energy: 0.5 * p.mass * speed * speed, radius: 0.08, direction: [0, -1, 0], source: 'fall' })\n } catch {\n // the object may have been removed from the world\n }\n }\n\n /** The impact of the heaviest part of an object (a piece landing): its material and the blunt blow of the fall. */\n private landingSound(objectId: string, point: Vec3, volume: number): void {\n const st = this.world.state(objectId)\n let best = ''\n let mass = -1\n for (const p of st?.parts ?? []) {\n if (p.mass > mass) {\n mass = p.mass\n best = p.material\n }\n }\n this.impactSound(best, point, volume, 'blunt')\n }\n\n /** The impact on a material by a blow: the legacy family key (`impactKey`) with the more specific keys to try first (`impactSoundKeys`). */\n private impactSound(material: string, point: Vec3, volume: number, blow?: DamageType): void {\n const def = this.world.materials.get(material)\n this.sound(impactKey(def), point, volume, impactSoundKeys(material, def, blow))\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Update\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n restoreStepPose(): void {\n this.pieceSys.restoreStepPose()\n this.fragments.restoreStepPose()\n }\n\n present(alpha: number): void {\n if (this.disposed) return\n this.pieceSys.presentPose(alpha)\n this.fragments.presentPose(alpha)\n }\n\n update(dt: number): void {\n if (this.disposed) return\n this.restoreStepPose()\n dt = clamp(dt, 0, 0.1)\n this.time += dt\n this.work?.beginFrame()\n if (!this.attached) this.drainQueue()\n this.checkBroken()\n for (const b of this.bounds.values()) b.onFrame?.(dt)\n // a settling object keeps moving between its (throttled) `settle` events\n for (const b of this.bounds.values()) if (b.soilNode && this.world.state(b.id)?.soil?.status === 'yielding') this.onSettle(b.id)\n this.settlement.update(dt)\n this.cost = this.sampleCost()\n this.advanceWakes(dt)\n this.thawWoken()\n this.pieceSys.update(dt)\n this.measureCost()\n this.updateFading(dt)\n this.fragments.update(dt)\n // what goes on at a part (fire, leaks, trickling grit) reads where the part is after the bodies moved this frame, not a frame behind\n this.updateActive(dt)\n this.updateLeaks(dt)\n this.updateTrickles(dt)\n this.ground.update(dt)\n this.ownVfx?.update(dt)\n this.syncTransforms()\n this.settledBatches.update(dt, () => this.restingDebris())\n }\n\n /** An event of the object (a blow, fire, char): its meshes leave the batches before it is drawn (`SettledBatches.release`). */\n private releaseBatched(objectId: string): void {\n if (!this.settledBatches.hasMembers()) return\n const b = this.bounds.get(objectId)\n if (b) this.settledBatches.release(this.meshesOf(b).map((mv) => mv.mesh))\n }\n\n /**\n * The meshes of the debris at rest: the fragments asleep (without marks on them) and the meshes of their own of the pieces asleep, but for an object with a part burning,\n * hot or still charring (`active`): its colours change in place.\n */\n private restingDebris(): Mesh[] {\n const meshes = new Set(this.fragments.restingMeshes())\n const changing = new Set<string>()\n for (const a of this.active.values()) changing.add(a.object)\n for (const piece of this.pieceSys.list) {\n const b = piece.sleeping && !piece.held && !changing.has(piece.objectId) ? this.bounds.get(piece.objectId) : undefined\n if (!b) continue\n // a part drawn by a range of a mesh it shares with others (a house) is left in that mesh\n for (const mv of this.meshesOf(b)) if ((!mv.host || mv.loose) && !mv.hidden && this.visuals.shown(mv)) meshes.add(mv.mesh)\n }\n return [...meshes]\n }\n\n settledBatchStats(): SettledBatchStats {\n return this.settledBatches.stats()\n }\n\n deferredQueue(): DeferredQueue {\n return this.eventQueue\n }\n\n /** Every queue of the renderer with the options a frame budget registers it with: the blow's own effect drains whole (`mustDrain`), the rest obeys the deadline. */\n deferredQueues(): readonly DeferredQueueRegistration[] {\n return [\n { queue: this.eventQueue, options: { ...DEFERRED_PRIORITY[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS], mustDrain: true } },\n { queue: this.prefitQueue, options: DEFERRED_PRIORITY[DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT] },\n { queue: this.settledBatches.queue, options: DEFERRED_PRIORITY[DEFERRED_QUEUE_ID.SETTLED_BATCH] },\n ]\n }\n\n /** The host applies the structural events itself at the end of each tick (`applyStructuralEvents`) from now on, or no longer; not under `workBudget`, whose events are paced by the frame. */\n setStructuralInTick(isInTick: boolean): void {\n // pending: under `workBudget` the mode stays off, so the events there still read the drawn pose (spec 017, evidence-120hz T2.2)\n this.structuralInTick = isInTick && !this.work\n }\n\n /**\n * At the end of a tick, on the step pose: applies the structural events that wait, with every visual event before the last of them, in the order of emission (a visual event of\n * an object with a structural one goes before it). What follows the last structural event is the frame's.\n */\n applyStructuralEvents(): void {\n if (this.disposed || this.work || this.areEventsHeld) return\n this.stalledFrames = 0\n // a spread blast whose slices are not all applied yet goes first, whole: the tick never runs past events of an earlier blast\n if (this.heldStructural) this.applyHeldStructural(Infinity)\n let last = -1\n for (let i = this.queue.length - 1; i >= 0 && last < 0; i--) if (isStructuralEvent(this.queue[i]!)) last = i\n if (last < 0) return\n const ordered = this.eventOrder.arrange(this.queue.splice(0, this.queue.length))\n let end = ordered.length\n while (end > 0 && !isStructuralEvent(ordered[end - 1]!)) end--\n this.requeue(ordered, end)\n this.visuals.batchRebuilds(() => {\n for (let i = 0; i < end; i++) {\n try {\n this.apply(ordered[i]!)\n } catch (err) {\n if (typeof console !== 'undefined') console.error('game-destruction-three: failed to apply', ordered[i]!.type, err)\n }\n }\n })\n }\n\n /** Holds every event of the queue (no drain applies any, no stall is counted) while the host runs a blast in slices, or lets them go. */\n holdEvents(isHeld: boolean): void {\n this.areEventsHeld = isHeld\n this.stalledFrames = 0\n }\n\n /**\n * `applyStructuralEvents` spread over frames: the first call arranges the waiting events once, exactly as the whole call does, and keeps those up to the last structural\n * one; each call applies the next of them in order until their weights (`EVENT_APPLY_WEIGHT`) reach `units` (at least one event). The same events in the same order as\n * the whole call, so the same world. What followed the last structural event goes back to the queue once they are all applied. Returns the events still held.\n */\n applyStructuralEventsSliced(units: number): number {\n if (this.disposed || this.work) return 0\n this.stalledFrames = 0\n if (!this.heldStructural) {\n let last = -1\n for (let i = this.queue.length - 1; i >= 0 && last < 0; i--) if (isStructuralEvent(this.queue[i]!)) last = i\n if (last < 0) return 0\n const ordered = this.eventOrder.arrange(this.queue.splice(0, this.queue.length))\n let end = ordered.length\n while (end > 0 && !isStructuralEvent(ordered[end - 1]!)) end--\n this.heldStructural = { events: ordered.slice(0, end), tail: ordered.slice(end), next: 0 }\n }\n this.applyHeldStructural(units)\n return this.structuralBacklog()\n }\n\n /** Structural events of a spread blast not applied yet (`applyStructuralEventsSliced`). */\n structuralBacklog(): number {\n return this.heldStructural ? this.heldStructural.events.length - this.heldStructural.next : 0\n }\n\n private applyHeldStructural(units: number): void {\n const held = this.heldStructural\n if (!held) return\n let spent = 0\n let stop = held.next\n while (stop < held.events.length && (stop === held.next || spent + eventApplyWeight(held.events[stop]!) <= units)) spent += eventApplyWeight(held.events[stop++]!)\n this.visuals.batchRebuilds(() => {\n for (let i = held.next; i < stop; i++) {\n try {\n this.apply(held.events[i]!)\n } catch (err) {\n if (typeof console !== 'undefined') console.error('game-destruction-three: failed to apply', held.events[i]!.type, err)\n }\n }\n })\n held.next = stop\n if (held.next < held.events.length) return\n this.heldStructural = undefined\n this.requeue(held.tail, 0)\n }\n\n /** Puts `events` from `from` on, back at the front of the queue, in order (no spread: a blast leaves tens of thousands). */\n private requeue(events: readonly DestructionEvent[], from: number): void {\n if (from >= events.length) return\n this.queue = events.slice(from).concat(this.queue)\n }\n\n /** Counts the frames (once each) a structural event has waited with no tick to apply it; always 0, for `pending`'s sum. */\n private watchStall(frame: number | undefined): number {\n if (!this.structuralInTick || frame === undefined || frame === this.watchedFrame) return 0\n // a held blast is not stalled: the host applies it in slices and lets the ticks go when it is done\n if (this.areEventsHeld || this.heldStructural) {\n this.stalledFrames = 0\n return 0\n }\n this.watchedFrame = frame\n this.stalledFrames = this.queue.some(isStructuralEvent) ? this.stalledFrames + 1 : 0\n return 0\n }\n\n /** How many events a drain may apply now: all, or (the host applies the structural ones in the tick) only those ahead of the first structural one. */\n private appliableEvents(all = false): number {\n if (this.areEventsHeld && !all) return 0\n if (all || !this.structuralInTick || this.stalledFrames >= STALLED_FRAMES) return this.queue.length\n let count = 0\n while (count < this.queue.length && !isStructuralEvent(this.queue[count]!)) count++\n return count\n }\n\n private drainQueue(): void {\n drainDetached(this.eventQueue, this.eventBudgetMs)\n }\n\n /** Applies the waiting events in order until the deadline, after the slices earlier events left; always at least one unit when something waits. Returns the units run. */\n private runBudgeted(deadline: number, clock: () => number, all = false): number {\n if (this.work) return this.runWork(this.work, all)\n // events produced while applying (a hard landing calls `hit`) wait for the next frame\n const batch = this.eventOrder.arrange(this.queue.splice(0, this.appliableEvents(all)))\n if (this.stalledFrames >= STALLED_FRAMES) this.stalledFrames = 0\n const outerClock = this.drainClock\n this.drainClock = clock\n this.sliceDeadline = deadline\n let ran = 0\n try {\n ran = this.runSlices(deadline)\n let isOutOfTime = false\n this.visuals.batchRebuilds(() => {\n for (let i = 0; i < batch.length; i++) {\n if ((i > 0 || (ran > 0 && this.attached)) && clock() >= deadline) {\n this.requeue(batch, i)\n isOutOfTime = true\n return\n }\n try {\n this.apply(batch[i]!)\n } catch (err) {\n if (typeof console !== 'undefined') console.error('game-destruction-three: failed to apply', batch[i]!.type, err)\n }\n ran++\n }\n })\n if (isOutOfTime) return ran\n // after the events, as under the budget: a group a blow of this frame looses keeps the split it gets in the event\n ran += this.splitChecked(deadline, ran)\n if (this.queue.length === 0 && this.slices.length === 0 && this.looseToCheck.size === 0) ran += this.runPrefitDetached(deadline, clock, ran === 0)\n } finally {\n this.sliceDeadline = Infinity\n this.drainClock = outerClock\n }\n return ran\n }\n\n /**\n * One frame under `workBudget`: the work earlier frames left (fragments, then the loose groups whose turn it is), then every waiting event (its effects show in the frame\n * it happened; it only leaves less of the budget; the groups it looses split in it while they fit, `splitWithin`). No clock is read. `all` runs everything (a flush).\n */\n private runWork(work: WorkBudget, all: boolean): number {\n const batch = this.eventOrder.arrange(this.queue.splice(0, this.queue.length))\n this.workFocus = this.o.focus?.()\n const outerDeadline = this.sliceDeadline\n // a finite deadline only says \"in a drain\": under the budget the work stops on units, never on the clock\n this.sliceDeadline = all ? Infinity : 0\n let ran = 0\n try {\n // the work earlier frames left goes first, as without the budget: the fragments, then the loose groups whose turn it is\n ran += this.runSlices(Infinity)\n ran += this.runSplits(work, all)\n for (const ev of batch) {\n work.take('event', this.workCosts.perEvent)\n try {\n this.apply(ev)\n } catch (err) {\n if (typeof console !== 'undefined') console.error('game-destruction-three: failed to apply', ev.type, err)\n }\n ran++\n }\n // after the events, so a group a blow of this frame looses keeps the split it gets in the event\n this.queueChecked()\n if (all) ran += this.runSlices(Infinity) + this.runSplits(work, all)\n // the fits ahead take only what the frame left, after everything else (as without the budget)\n if (this.queue.length === 0 && this.slices.length === 0 && this.splitQueue.size === 0 && !all) ran += this.runPrefitWork(work)\n } finally {\n this.sliceDeadline = outerDeadline\n }\n return ran\n }\n\n /** Runs the work left by earlier frames until the deadline (under `workBudget`, while units are left); at least one piece per frame, so it always finishes. */\n private runSlices(deadline: number): number {\n let ran = 0\n for (; this.slices.length > 0 && (ran === 0 || (this.work ? this.work.remaining > 0 || this.sliceDeadline === Infinity : this.drainClock() < deadline)); ran++) {\n try {\n const slice = this.slices.shift()!\n if (typeof slice === 'function') slice()\n else this.spawnFragments(slice.ev, slice.from, slice.look)\n } catch (err) {\n if (typeof console !== 'undefined') console.error('game-destruction-three: failed to run deferred work', err)\n }\n }\n return ran\n }\n\n /**\n * The ground under an object settled or tilted: its parts are drawn under a node with the soil's offset (`ObjectState.soil.offset`), so the host's\n * root keeps the pose the host gave and the world keeps getting it from `syncTransform`.\n */\n private onSettle(objectId: string): void {\n const b = this.bounds.get(objectId)\n const soil = this.world.state(objectId)?.soil\n if (!b || !soil) return\n let node = b.soilNode\n if (!node) {\n node = new this.THREE.Group()\n node.name = 'destruction-soil'\n for (const c of [...b.root.children]) node.add(c)\n b.root.add(node)\n b.soilNode = node\n }\n const { position: p, rotation: q } = soil.offset\n node.position.set(p[0], p[1], p[2])\n node.quaternion.set(q[0], q[1], q[2], q[3])\n node.updateMatrixWorld(true)\n }\n\n /** The ground went down under some parts of an object: each part with a settlement (`PartState.settlement`) starts going down to it. */\n private onSubside(objectId: string): void {\n const b = this.bounds.get(objectId)\n const state = this.world.state(objectId)\n if (!b || !state) return\n const parts: Array<readonly [PartVis, PartSettlement | undefined]> = []\n for (const ps of state.parts) {\n const pv = b.parts.get(ps.id)\n if (pv && ps.settlement) parts.push([pv, ps.settlement])\n }\n this.settlement.follow(b.soilNode ?? b.root, parts)\n }\n\n /**\n * The roots the world is told about: a piece asleep is not read (its root stops recomputing its matrix) until it wakes or a host calls\n * `markMoved`; every other root is read, and only decomposed when its world matrix changed.\n */\n private syncTransforms(): void {\n for (const b of this.bounds.values()) {\n // a held piece is moved by its host (push, carry) even while the engine still has it asleep\n if (b.piece?.sleeping && !b.piece.held && !b.moved) {\n if (!b.frozen) this.freezeRoot(b)\n continue\n }\n if (b.frozen) this.thawRoot(b)\n b.moved = false\n this.syncOne(b)\n }\n }\n\n private freezeRoot(b: Bound): void {\n this.syncOne(b)\n b.root.updateMatrix()\n b.root.matrixAutoUpdate = false\n b.frozen = true\n }\n\n private thawRoot(b: Bound): void {\n b.root.matrixAutoUpdate = true\n b.frozen = false\n b.root.updateMatrixWorld(true)\n }\n\n /** A piece woken before the step (a blow, the host) has its matrix back before the engine writes its pose to the root. */\n private thawWoken(): void {\n for (const b of this.bounds.values()) if (b.frozen && !b.piece?.sleeping) this.thawRoot(b)\n }\n\n /** The host moved the root of an object by hand (a teleport): its transform goes to the world on the next `update`, even if it is a piece asleep. */\n markMoved(objectId: string): void {\n const b = this.bounds.get(objectId)\n if (!b) return\n b.moved = true\n if (b.frozen) this.thawRoot(b)\n }\n\n /** Push the current transform of one bound object to the world right now (used before a landing hit). */\n private syncBound(objectId: string): void {\n const b = this.bounds.get(objectId)\n if (b) this.syncOne(b)\n }\n\n private syncOne(b: Bound): void {\n if (!b.sync) return\n const p = this.v1\n const q = this.tmpQ\n b.root.updateWorldMatrix(true, false)\n const elements = b.root.matrixWorld.elements\n const world = b.lastWorld\n if (world) {\n let same = true\n for (let i = 0; i < 16; i++) {\n if (world[i] === elements[i]) continue\n same = false\n world[i] = elements[i] as number\n }\n if (same && b.lastPos) return\n } else {\n b.lastWorld = Float64Array.from(elements)\n }\n b.root.matrixWorld.decompose(p, q, this.v2)\n const last = b.lastPos\n const lq = b.lastQuat\n const moved = !last || !lq || Math.abs(p.x - last[0]) + Math.abs(p.y - last[1]) + Math.abs(p.z - last[2]) > 1e-5 || Math.abs(q.x - lq[0]) + Math.abs(q.y - lq[1]) + Math.abs(q.z - lq[2]) + Math.abs(q.w - lq[3]) > 1e-6\n if (!moved) return\n if (last && lq) {\n last[0] = p.x\n last[1] = p.y\n last[2] = p.z\n lq[0] = q.x\n lq[1] = q.y\n lq[2] = q.z\n lq[3] = q.w\n } else {\n b.lastPos = [p.x, p.y, p.z]\n b.lastQuat = [q.x, q.y, q.z, q.w]\n }\n if (this.world.has(b.id)) this.world.setTransform(b.id, [p.x, p.y, p.z], [q.x, q.y, q.z, q.w])\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Events\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n /**\n * The highest top of a bound object that is not a piece under (x, z) a corner at height `y` can land on (at most `step` above it). The world boxes\n * of their drawn meshes are kept until an event or a moved root changes them; parts drawn inside a merged mesh and meshes wider than `STATIC_SPAN`\n * are left out (walls, floors, roofs: the terrain under them is the host's `groundAt`).\n */\n private staticTopAt(x: number, z: number, y: number, step: number): number {\n let top = -Infinity\n for (const a of this.staticNow().values()) {\n // the first six numbers are the box around all of the object's boxes\n if (a.length === 0 || x < a[0] || x > a[3] || z < a[2] || z > a[5]) continue\n for (let i = 6; i < a.length; i += 6) {\n if (x < a[i] || x > a[i + 3] || z < a[i + 2] || z > a[i + 5]) continue\n const t = a[i + 4]\n if (t > top && t <= y + step) top = t\n }\n }\n return top\n }\n\n /**\n * The fixed objects as their drawn boxes turned as drawn (the local box of each mesh in its world matrix), for an engine: one list per object, the same list until\n * `staticNow` measures that object again. The same meshes `staticNow` keeps: no merged host, no loose part, nothing hidden, nothing wider than `STATIC_SPAN`.\n */\n private staticSolids(): Map<string, readonly StaticSolid[]> {\n const now = this.staticNow()\n for (const id of this.solidCache.keys()) if (!now.has(id)) this.solidCache.delete(id)\n // asked every update: the map and the scratch are kept, the lists are the cached ones\n const out = this.solidsOut\n out.clear()\n const budget: MeasureBudget = { left: VERTICES_PER_UPDATE, incomplete: false, updated: this.measuredMeshes, workers: this.o.workers ?? null }\n try {\n this.measureEach(now, budget, out)\n } finally {\n // holds no mesh past the call (a mesh that leaves the scene is not kept here)\n this.measuredMeshes.clear()\n }\n return out\n }\n\n /** `staticSolids` for each fixed object of `now`, into `out`. */\n private measureEach(now: ReadonlyMap<string, unknown>, budget: MeasureBudget, out: Map<string, readonly StaticSolid[]>): void {\n for (const id of now.keys()) {\n // a body drawn by a module of its own (a vehicle: no mesh of it is bound here) is the boxes of its parts still on it, as the world holds them\n const hosted = this.drawsNothingHere(id) ? this.world.hostedSolids?.(id) : null\n if (hosted) {\n // pieces the body's own module measured on what it draws (a part id as key) are the drawn shape already: only the damage-zone boxes are cut to it\n out.set(id, hosted.length > 0 && hosted.every((solid) => solid.key !== undefined) ? hosted : this.clipToDrawn(id, hosted))\n continue\n }\n const cached = this.solidCache.get(id)\n if (cached && !this.solidStale.has(id)) {\n out.set(id, cached.solids)\n continue\n }\n this.solidStale.delete(id)\n budget.incomplete = false\n const solids = this.measureSolids(id, budget)\n // some parts wait for the next update: this object is measured again then, the parts done are kept\n if (budget.incomplete) this.solidStale.add(id)\n // measured again often to the same numbers: the same boxes keep the same list (an engine rebuilds what changed)\n if (cached && sameSolids(cached.solids, solids)) {\n out.set(id, cached.solids)\n continue\n }\n this.solidCache.set(id, { solids })\n out.set(id, solids)\n }\n }\n\n /**\n * Every fixed thing the object draws as what it collides as (`drawnSolidsOf`): a box where one fits the part, the triangles where not, a part of a merged mesh by its own\n * vertices, a mesh of any width. What is hidden, broken or loose is not drawn, so it is not here.\n */\n private measureSolids(id: string, budget: MeasureBudget): StaticSolid[] {\n const solids: StaticSolid[] = []\n const b = this.bounds.get(id)\n if (!b) return solids\n for (const pv of b.parts.values()) {\n if (pv.gone !== 'none') continue\n const material = this.world.part(id, pv.id)?.material ?? pv.material\n const surface = material ? surfaceOf(material, this.world.materials.get(material)) : undefined\n pv.meshes.forEach((mv, k) => {\n if (mv.loose || !this.visuals.shown(mv)) return\n for (const solid of drawnSolidsOf(this.THREE, this.visuals, mv, `${pv.id}:${k}`, budget)) solids.push(surface ? this.withSurface(solid, surface) : solid)\n })\n }\n return solids\n }\n\n /**\n * The solid with the friction of its surface: the same object as last time for the same solid and the same numbers, so the lists after a re-measure hold the very objects the engine\n * holds and compare by identity (`sameSolids`, `EngineStatics.fit`), not number by number through every vertex of a mesh.\n */\n private withSurface(solid: StaticSolid, surface: { readonly static: number; readonly dynamic: number; readonly rolling?: number; readonly rollingDamping?: number }): StaticSolid {\n const rolling = surface.rolling ?? 0\n const rollingDamping = surface.rollingDamping ?? 0\n const kept = this.surfaced.get(solid)\n if (kept?.friction && kept.friction.static === surface.static && kept.friction.dynamic === surface.dynamic && kept.friction.rolling === rolling && kept.friction.rollingDamping === rollingDamping) return kept\n const made: StaticSolid = { ...solid, friction: { static: surface.static, dynamic: surface.dynamic, rolling, rollingDamping } }\n this.surfaced.set(solid, made)\n return made\n }\n\n /** The boxes of the fixed objects (per object: the box around them all, then each one), each object measured again when an event touched it (all of them every `STATIC_REFRESH` s). */\n private staticNow(): Map<string, number[]> {\n if (this.time - this.staticAt > STATIC_REFRESH) {\n this.staticAt = this.time\n if (this.staticRound.length === 0) this.staticRound = [...this.bounds.keys()].reverse()\n }\n if (!this.staticAll && this.staticDirty.size === 0 && this.staticRound.length === 0) return this.staticBoxes\n const box = new this.THREE.Box3()\n const measure = (b: Bound, force: boolean): void => {\n if (b.piece || this.pieceSys.get(b.id)) {\n this.staticBoxes.delete(b.id)\n this.solidStale.delete(b.id)\n this.rootMatrices.delete(b.id)\n return\n }\n const out: number[] = [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity]\n for (const mv of this.meshesOf(b)) {\n if (mv.host || mv.loose || !this.visuals.shown(mv)) continue\n this.visuals.worldBox(mv, box)\n if (box.isEmpty() || box.max.x - box.min.x > STATIC_SPAN || box.max.z - box.min.z > STATIC_SPAN) continue\n this.visuals.fittedBoxes(mv, out)\n for (let k = 0; k < 3; k++) {\n out[k] = Math.min(out[k], box.min.getComponent(k))\n out[k + 3] = Math.max(out[k + 3], box.max.getComponent(k))\n }\n }\n const next = out.length > 6 ? out : []\n const was = this.staticBoxes.get(b.id)\n b.root.updateWorldMatrix(true, false)\n const matrix = b.root.matrixWorld.elements\n const placed = this.rootMatrices.get(b.id)\n if (force || !was || was.length !== next.length || next.some((v, k) => Math.abs(v - was[k]) > 1e-6) || !placed || matrix.some((v, k) => v !== placed[k])) this.solidStale.add(b.id)\n this.rootMatrices.set(b.id, [...matrix])\n this.staticBoxes.set(b.id, next)\n }\n const measureId = (id: string, force: boolean): void => {\n const b = this.bounds.get(id)\n if (b) measure(b, force)\n else {\n this.staticBoxes.delete(id)\n this.solidStale.delete(id)\n this.rootMatrices.delete(id)\n }\n }\n if (this.staticAll) {\n this.staticBoxes.clear()\n for (const b of this.bounds.values()) measure(b, true)\n this.staticRound = []\n } else {\n for (const id of this.staticDirty) measureId(id, true)\n for (let taken = 0; taken < STATIC_REFRESH_PER_UPDATE && this.staticRound.length > 0; taken++) measureId(this.staticRound.pop() as string, false)\n }\n this.staticAll = false\n this.staticDirty.clear()\n return this.staticBoxes\n }\n\n /** The boxes of a piece's drawn meshes, measured once per frame. */\n private pieceBoxesOf(pc: PieceBody): number[] {\n const cached = this.pieceBoxes.get(pc)\n if (cached && cached.at === this.time) return cached.boxes\n const boxes: number[] = []\n const b = this.bounds.get(pc.objectId)\n if (b) {\n for (const mv of this.meshesOf(b)) {\n if (this.visuals.shown(mv)) this.visuals.fittedBoxes(mv, boxes)\n }\n }\n this.pieceBoxes.set(pc, { at: this.time, boxes })\n return boxes\n }\n\n solidsNear(x: number, z: number, radius: number): SolidBox[] {\n const found: SolidBox[] = []\n const scan = (a: number[], id: string, piece: Piece | null, from: number): void => {\n if (from > 0 && (a.length === 0 || x < a[0] - radius || x > a[3] + radius || z < a[2] - radius || z > a[5] + radius)) return\n for (let i = from; i < a.length; i += 6) {\n if (x < a[i] - radius || x > a[i + 3] + radius || z < a[i + 2] - radius || z > a[i + 5] + radius) continue\n found.push({ objectId: id, min: [a[i], a[i + 1], a[i + 2]], max: [a[i + 3], a[i + 4], a[i + 5]], piece })\n }\n }\n for (const [id, a] of this.staticNow()) scan(a, id, null, 6)\n const c = this.v1\n for (const pc of this.pieceSys.list) {\n if (pc.held) continue\n // only the pieces whose box can reach the point are measured\n this.pieceSys.centerOf(pc, c)\n const reach = Math.hypot(pc.halfExtents[0], pc.halfExtents[1], pc.halfExtents[2]) + radius\n if (Math.abs(c.x - x) > reach || Math.abs(c.z - z) > reach) continue\n scan(this.pieceBoxesOf(pc), pc.objectId, pc, 0)\n }\n this.fragments.solidsNear(x, z, radius, (home, min, max, loose) => found.push({ objectId: home, min, max, piece: null, loose }))\n return found\n }\n\n private apply(ev: DestructionEvent): void {\n const outer = this.emitting\n // an event of no object (a blast set off in the air) makes effects of no one\n this.emitting = ev.object || undefined\n try {\n this.applyEvent(ev)\n } finally {\n this.emitting = outer\n }\n }\n\n private applyEvent(ev: DestructionEvent): void {\n this.staticDirty.add(ev.object)\n this.releaseBatched(ev.object)\n this.hitPoints.note(ev, this.time)\n if (ev.type === 'fracture' || ev.type === 'detach' || ev.type === 'collapse' || ev.type === 'burnout' || ev.type === 'destroyed') this.broken.add(ev.object)\n switch (ev.type) {\n case 'damage':\n if (ev.damageType === 'heat' || ev.damageType === 'fire' || ev.damageType === 'explosive') this.activate(ev.object, ev.part)\n break\n case 'dent':\n this.onDent(ev)\n break\n case 'bend':\n this.onBend(ev)\n break\n case 'hole':\n this.onHole(ev)\n break\n case 'crack':\n this.onCrack(ev)\n break\n case 'ricochet': {\n const d = ev.direction\n this.vfx.burst('sparks', ev.point, d, 4 + Math.min(10, ev.energy / 150), 4)\n // the whine of a round off steel, the short crack off stone: by what the part it glanced off is made of\n const glanced = this.partVis(ev.object, ev.part)?.material ?? ''\n this.sound('ricochet', ev.point, 0.7, ricochetSoundKeys(glanced, this.world.materials.get(glanced)))\n break\n }\n case 'debris':\n this.vfx.burst(ev.kind, ev.point, ev.normal, ev.count, ev.speed > 0 ? ev.speed : DEFAULT_SPEED[ev.kind] ?? 1, this.debrisOptions(ev.kind, ev.object, ev.part, ev.material))\n break\n case 'fracture': {\n const pv = this.partVis(ev.object, ev.part)\n if (pv) this.settlement.forget(pv)\n this.onFracture(ev)\n break\n }\n case 'subside':\n this.onSubside(ev.object)\n break\n case 'detach':\n this.onDetach(ev)\n break\n case 'settle':\n this.onSettle(ev.object)\n break\n case 'collapse': {\n // a storey coming down raises the cloud of the collapse effect; a piece of furniture (a shelf and its books) only a puff\n const root = this.bounds.get(ev.object)?.root\n const furniture = !!root && kitOriginOf(root)?.kind === 'furniture'\n // what was still going down goes the rest of the way before it falls on its own\n for (const part of ev.parts) {\n const pv = this.partVis(ev.object, part)\n if (pv) this.settlement.finish(pv)\n }\n this.splitLoose(ev.object)\n if (!furniture || ev.mass >= COLLAPSE_CLOUD_KG) this.playEvent({ kind: 'collapse' }, this.rootPoint(ev.object), this.partPlay(ev.object, ev.parts[0] ?? ''))\n else this.vfx.burst('dust', this.rootPoint(ev.object), [0, 1, 0], clamp(Math.round(ev.mass / 4), 4, 24), 0.8)\n break\n }\n case 'disassemble_progress': {\n const k = `unscrew:${ev.joint}`\n if (this.time - (this.throttles.get(k) ?? -1) > 0.25) {\n this.throttles.set(k, this.time)\n this.sound('unscrew', this.rootPoint(ev.object), clamp(0.3 + ev.progress * 0.5, 0, 1))\n }\n break\n }\n case 'ignite':\n this.startFire(ev)\n this.activate(ev.object, ev.part)\n this.sound('ignite', ev.point, 0.7)\n this.startBurnSound(ev.object, ev.part, ev.point, this.burning(ev.object, ev.part))\n break\n case 'primed':\n // a bullet or fire sets the part burning until its delay runs out; a blast nearby only waits for the explosion\n if (ev.trigger !== 'explosion') {\n this.vfx.fire({ point: ev.point, radius: PRIMED_FIRE_RADIUS, life: ev.delay })\n this.primedBurning.add(`${ev.object}|${ev.part}`)\n this.activate(ev.object, ev.part)\n // the vessel is venting until it bursts: the gas leak for as long as the delay, and the flame it feeds\n this.sound('primed', ev.point, 0.7, { seconds: ev.delay })\n if (!this.burnSounds.has(`${ev.object}|${ev.part}`)) this.startBurnSound(ev.object, ev.part, ev.point, { fuel: 'gas' })\n }\n break\n case 'spall':\n this.onSpall(ev)\n break\n case 'stage':\n this.onStage(ev)\n break\n case 'chip':\n this.onChip(ev)\n break\n case 'expose':\n if (ev.bars.length > 0) this.cages.set(`${ev.object}|${ev.part}`, ev.bars, this.bounds.get(ev.object)?.root)\n else this.dropCage(ev.object, ev.part)\n if (ev.bars.length > 0) {\n const [a, b] = ev.bars[0] as [Vec3, Vec3]\n this.playEvent({ kind: 'expose' }, [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2], this.partPlay(ev.object, ev.part))\n }\n break\n case 'extinguish': {\n const f = this.fires.get(`${ev.object}|${ev.part}`)\n this.primedBurning.delete(`${ev.object}|${ev.part}`)\n if (f) {\n this.stopFire(`${ev.object}|${ev.part}`)\n this.vfx.burst('steam', f.point, [0, 1, 0], 14, 1.2)\n }\n this.endBurnSound(`${ev.object}|${ev.part}`)\n this.activate(ev.object, ev.part)\n this.sound('extinguish', f?.point ?? this.rootPoint(ev.object), 0.6)\n break\n }\n case 'burnout': {\n this.stopFire(`${ev.object}|${ev.part}`)\n this.primedBurning.delete(`${ev.object}|${ev.part}`)\n this.endBurnSound(`${ev.object}|${ev.part}`)\n this.vfx.burst('ash', ev.point, [0, 1, 0], 16, 1)\n this.vfx.burst('smoke', ev.point, [0, 1, 0], 6, 0.8, { color: SMOKE_TONES.grey })\n const pv = this.partVis(ev.object, ev.part)\n if (pv) {\n const def = this.world.materials.get(pv.material)\n this.visuals.setChar(pv, 1, def?.visual?.charColor ?? 0x1a1410)\n }\n this.activate(ev.object, ev.part)\n break\n }\n case 'melt':\n this.activate(ev.object, ev.part)\n // one sizzle per melting object every 1.5 s, not one per part (a plastic bin has dozens)\n if (this.time - (this.throttles.get(`melt:${ev.object}`) ?? -9) > 1.5) {\n this.throttles.set(`melt:${ev.object}`, this.time)\n this.sound('melt_sizzle', this.rootPoint(ev.object), 0.4)\n }\n break\n case 'drip': {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n const def = this.world.materials.get(ev.material)\n const color = (pv && this.partColor(pv, def)) ?? fallbackColor(def)\n let tag = this.homeTags.indexOf(ev.object) + 1\n if (tag === 0) tag = this.homeTags.push(ev.object)\n this.vfx.spawn('drips', ev.point, [(this.rng() - 0.5) * 0.1, -0.1, (this.rng() - 0.5) * 0.1], { color, tag, owner: this.owner })\n break\n }\n case 'leak': {\n const key = `${ev.object}|${ev.part}`\n const b = this.bounds.get(ev.object)\n let localPoint: Vec3 | undefined\n let localDirection: Vec3 | undefined\n if (b) {\n b.root.updateWorldMatrix(true, false)\n const inv = new this.THREE.Matrix4().copy(b.root.matrixWorld).invert()\n const lp = this.v1.set(ev.point[0], ev.point[1], ev.point[2]).applyMatrix4(inv)\n const ld = this.v2.set(ev.direction[0], ev.direction[1], ev.direction[2]).transformDirection(inv).normalize()\n localPoint = [lp.x, lp.y, lp.z]\n localDirection = [ld.x, ld.y, ld.z]\n }\n const same = this.leaks.find((l) => l.object === ev.object && l.part === ev.part && Math.hypot(l.point[0] - ev.point[0], l.point[1] - ev.point[1], l.point[2] - ev.point[2]) < 0.03)\n if (same) {\n same.rate = ev.rate\n same.direction = ev.direction\n if (localPoint) same.localPoint = localPoint\n if (localDirection) same.localDirection = localDirection\n } else {\n if (this.leaks.length >= 24) this.leaks.shift()\n this.leaks.push({\n object: ev.object,\n part: ev.part,\n fluid: ev.fluid,\n point: ev.point,\n direction: ev.direction,\n rate: ev.rate,\n pressurized: ev.pressurized,\n acc: 0,\n opened: this.world.part(ev.object, ev.part)?.holes.some((h) => h.through) ?? false,\n localPoint,\n localDirection,\n life: 0,\n })\n }\n void key\n break\n }\n case 'explode':\n // the vessel that vented into its flame bursts: the gas jet ends with it\n this.primedBurning.delete(`${ev.object}|${ev.part}`)\n this.endBurnSound(`${ev.object}|${ev.part}`)\n this.onExplode(ev)\n break\n case 'destroyed':\n break\n }\n }\n\n /** Where the object's root is now, in the world: a body that tipped or fell is there, not where it was bound. */\n private rootPoint(objectId: string): Vec3 {\n const b = this.bounds.get(objectId)\n if (!b) return [0, 0, 0]\n const p = b.root.getWorldPosition(new this.THREE.Vector3())\n return [p.x, p.y, p.z]\n }\n\n private sound(key: string, point: Vec3, volume: number, detail?: SoundDetail): void {\n if (detail) this.o.onSound?.(key, point, volume, detail)\n else this.o.onSound?.(key, point, volume)\n }\n\n /** What a burning part is made of, for the fire's sound. */\n private burning(objectId: string, partId: string): SoundDetail | undefined {\n const material = this.partVis(objectId, partId)?.material || this.world.part(objectId, partId)?.material\n return material ? { material } : undefined\n }\n\n private partVis(objectId: string, partId: string): PartVis | null {\n return this.bounds.get(objectId)?.parts.get(partId) ?? null\n }\n\n private activate(objectId: string, partId: string): void {\n this.active.set(`${objectId}|${partId}`, { object: objectId, part: partId })\n }\n\n /** Current colour of the part's first mesh (char included), or null. */\n private partColor(pv: PartVis, def: MaterialDef | undefined): number | null {\n // the colour of what most of the part is drawn with (a roof's tiles, not the strip of plaster drawn with it first)\n const size = (m: MeshVis): number => (m.range ? m.range[1] - m.range[0] : (m.mesh.geometry.getAttribute('position')?.count ?? 0))\n const mv = pv.meshes.reduce<MeshVis | undefined>((best, m) => (!best || size(m) > size(best) ? m : best), undefined)\n if (!mv) return null\n const mat = materialsOf(mv.mesh.material)[0] as THREE_NS.MeshStandardMaterial | undefined\n const c = mat?.color\n if (c && (c as THREE_NS.Color).isColor) {\n const tint = this.visuals.vertexTint(mv)\n return tint ? c.clone().multiply(tint).getHex() : c.getHex()\n }\n return def ? fallbackColor(def) : null\n }\n\n private debrisOptions(kind: DebrisKind, objectId: string, partId: string, material?: string): { color?: number } | undefined {\n const pv = this.partVis(objectId, partId)\n const def = this.world.materials.get(material ?? pv?.material ?? '')\n if (kind === 'smoke') return { color: SMOKE_TONES[def?.thermal.smoke ?? 'grey'] }\n // crushed masonry is the colour of its inside (brick orange, plaster light, concrete grey), not of the paint over it\n if ((kind === 'dust' || kind === 'chips') && def?.visual?.innerColor !== undefined) return { color: def.visual.innerColor }\n if (kind === 'fibers' || kind === 'leaves') {\n if (def?.visual?.innerColor !== undefined) return { color: def.visual.innerColor }\n // a part drawn by its host (a house piece) has no mesh of its own here: the burst keeps its default colour\n const c = pv && pv.meshes[0] ? this.visuals.baseColorHex(pv.meshes[0]) : -1\n return c >= 0 ? { color: c } : undefined\n }\n if (kind === 'dust' || kind === 'chips') {\n const c = pv && pv.meshes[0] ? this.visuals.baseColorHex(pv.meshes[0]) : -1\n return c >= 0 && kind === 'chips' ? { color: c } : undefined\n }\n return undefined\n }\n\n /** Mesh of the part closest to a world point. */\n private nearestMesh(pv: PartVis, p: THREE_NS.Vector3): PartVis['meshes'][number] | null {\n let best: PartVis['meshes'][number] | null = null\n let bd = Infinity\n // a part drawn by no mesh of its own takes its marks on the meshes it is drawn inside (`BindOptions.marksOn`)\n const meshes = pv.meshes.length || !pv.markHosts ? pv.meshes : pv.markHosts.flatMap((h) => h.meshes)\n for (const mv of meshes) {\n if (!this.visuals.shown(mv)) continue\n const d = this.visuals.worldBox(mv, this.box).distanceToPoint(p)\n if (d < bd) {\n bd = d\n best = mv\n }\n }\n return best\n }\n\n private worldDir(b: Bound, v: Vec3): THREE_NS.Vector3 {\n b.root.updateWorldMatrix(true, false)\n return new this.THREE.Vector3(v[0], v[1], v[2]).applyQuaternion(b.root.getWorldQuaternion(this.tmpQ)).normalize()\n }\n\n /** A plate bent: every mesh of the part turns about the hinge line together (a shovel's blade pieces), on top of the dents they already have. */\n private onBend(ev: Ev<'bend'>): void {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n if (!b || !pv) return\n // the object's frame is in metres whatever the scale of the model root (a model drawn in centimetres): its pose is the root's position and rotation only\n b.root.updateWorldMatrix(true, false)\n const point = new this.THREE.Vector3(ev.hinge.point[0], ev.hinge.point[1], ev.hinge.point[2])\n const origin = this.v1\n const rotation = this.tmpQ\n b.root.matrixWorld.decompose(origin, rotation, this.v2)\n point.applyQuaternion(rotation).add(origin)\n const axis = this.worldDir(b, ev.hinge.axis)\n const side = this.worldDir(b, ev.hinge.side)\n for (const mv of pv.meshes) if (this.visuals.shown(mv)) this.visuals.applyBend(mv, point, axis, side, ev.angle)\n }\n\n private onDent(ev: Ev<'dent'>): void {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n if (!b || !pv) return\n const def = this.world.materials.get(pv.material)\n const wp = new this.THREE.Vector3(ev.worldPoint[0], ev.worldPoint[1], ev.worldPoint[2])\n const wn = this.worldDir(b, ev.dent.normal)\n const shown = pv.meshes.filter((mv) => this.visuals.shown(mv))\n const reach = shown.reduce((widest, mv) => Math.max(widest, this.visuals.dentReach(mv, wp, ev.dent)), ev.dent.radius)\n this.visuals.applyPartDent(shown, wp, wn, ev.dent, reach)\n if (def?.tags?.includes('metal')) this.vfx.burst('sparks', ev.worldPoint, [wn.x, wn.y, wn.z], 4 + Math.min(8, ev.dent.depth * 150), 3.2)\n this.impactSound(pv.material, ev.worldPoint, clamp(0.3 + ev.dent.depth * 12, 0.3, 1), ev.blow)\n }\n\n private onHole(ev: Ev<'hole'>): void {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n if (!b || !pv) return\n const def = this.world.materials.get(pv.material)\n const n = this.worldDir(b, ev.hole.normal)\n const look = debrisLook(def, 'shot')\n this.drawHoleMark(pv, ev.worldPoint, n, ev.hole.diameter, ev.time)\n if (ev.hole.through && ev.exitPoint) this.drawHoleMark(pv, ev.exitPoint, n.clone().negate(), ev.hole.diameter, ev.time)\n if (look.sparks) this.vfx.burst('sparks', ev.worldPoint, [n.x, n.y, n.z], 6, 3.5)\n if (ev.powder) {\n // what the part holds loose (flakes, flour) puffs out: a little back out of the entry, most out of the exit along the shot\n const puff = { color: ev.powder.color, size: 0.6, life: 1.6, alpha: 1.3 }\n this.vfx.burst('dust', ev.worldPoint, [n.x, n.y, n.z], this.low ? 5 : 10, 0.7, puff)\n if (ev.hole.through && ev.exitPoint) this.vfx.burst('dust', ev.exitPoint, [-n.x, -n.y, -n.z], this.low ? 10 : 20, 1.3, puff)\n }\n // the blow's own keys first (`impact_steel_ballistic`...), then the round's per-family key (`shot_metal`), which falls back to the plain impact\n this.sound(shotKey(def), ev.worldPoint, 0.6, impactSoundKeys(pv.material, def, ev.blow))\n }\n\n /** The mark of one hole on the mesh of `pv` nearest to the world `point`: a star crack in glass, a ragged rim and a dark disc elsewhere. */\n private drawHoleMark(pv: PartVis, point: Vec3, normal: THREE_NS.Vector3, diameter: number, time: number): void {\n const def = this.world.materials.get(pv.material)\n const look = debrisLook(def, 'shot')\n const wp = new this.THREE.Vector3(point[0], point[1], point[2])\n const mv = this.nearestMesh(pv, wp)\n if (!mv) return\n if (look.mark === 'star_crack') {\n const seed = hashNumbers(time, point[0], point[1], point[2])\n this.visuals.addCrack(mv, wp, normal, 7, Math.max(0.05, diameter * 5), 0xe8f4ff, seed)\n return\n }\n // wood tears its fibres around the hole: a ragged rim of fresh wood under it\n const fresh = look.mark === 'splintered_hole' ? def?.visual?.innerColor : undefined\n if (fresh !== undefined) this.visuals.addSpall(mv, wp, normal, Math.max(0.006, diameter * WOOD_RIM), fresh)\n // masonry and concrete crater around the hole: the patch of fresh broken material under the dark hole\n const core = look.mark === 'crater' ? def?.visual?.innerColor : undefined\n if (core !== undefined) this.visuals.addSpall(mv, wp, normal, Math.max(CRATER_MIN_RADIUS, diameter * CRATER_RADIUS), lighten(core, CRATER_LIGHTEN))\n this.visuals.addHole(mv, wp, normal, diameter)\n }\n\n private onCrack(ev: Ev<'crack'>): void {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n if (!b || !pv) return\n this.drawCrackMark(b, pv, ev.crack, ev.worldPoint, ev.time)\n this.impactSound(pv.material, ev.worldPoint, 0.5, ev.blow)\n }\n\n /** The mark of one crack: the mortar gap of a settlement crack on both faces of a wall, or the star lines of glass; an opaque body shows chips, holes and dents instead. */\n private drawCrackMark(b: Bound, pv: PartVis, crack: Crack, worldPoint: Vec3, time: number): void {\n const def = this.world.materials.get(pv.material)\n const stair = crack.stair\n // a stair-step crack of settlement opens the mortar joints of the wall: a dark gap drawn on its face, as wide as it opened (and wide enough to be seen)\n if (stair && !def?.visual?.transparent) {\n const wp = new this.THREE.Vector3(worldPoint[0], worldPoint[1], worldPoint[2])\n const seed = hashNumbers(time, worldPoint[0], worldPoint[1], worldPoint[2])\n const width = Math.max(stair.width, MIN_DRAWN_CRACK_WIDTH)\n const normal = this.worldDir(b, crack.normal)\n const toward = this.worldDir(b, stair.along)\n const look = { length: crack.length, step: stair.step, width, color: SETTLEMENT_CRACK_COLOR, seed }\n // the same crack on both faces of the wall (the far one seen from behind: its side runs the other way round, its path the same)\n for (const face of [wp, wp.clone().addScaledVector(normal, -stair.through)]) {\n const out = face === wp ? normal : normal.clone().negate()\n const mv = this.nearestMesh(pv, face)\n if (mv) this.visuals.addStairCrack(mv, face, out, toward, look)\n }\n }\n // only glass shows a crack as lines (the break runs inside a clear body); an opaque body shows its damage as chips, holes and dents, never lines drawn over it\n else if (def?.visual?.transparent) {\n const wp = new this.THREE.Vector3(worldPoint[0], worldPoint[1], worldPoint[2])\n const mv = this.nearestMesh(pv, wp)\n const seed = hashNumbers(time, worldPoint[0], worldPoint[1], worldPoint[2])\n if (mv) this.visuals.addCrack(mv, wp, this.worldDir(b, crack.normal), crack.rays, crack.length, 0xe8f4ff, seed)\n }\n }\n\n /** Outward normal of the face of `mv` nearest to a world point: the thin axis of its world box (right for a wall; a sloped face is left to the vertex-range binding). */\n private faceNormal(mv: PartVis['meshes'][number], point: THREE_NS.Vector3): THREE_NS.Vector3 {\n const box = this.visuals.worldBox(mv, this.box)\n const size = box.getSize(this.v1)\n const axis = size.x <= size.y && size.x <= size.z ? 'x' : size.y <= size.z ? 'y' : 'z'\n const side = point[axis] >= (box.min[axis] + box.max[axis]) / 2 ? 1 : -1\n return new this.THREE.Vector3(axis === 'x' ? side : 0, axis === 'y' ? side : 0, axis === 'z' ? side : 0)\n }\n\n /**\n * Plays the effect the event map names for a destruction event (`data/event-effects.json` of `game-vfx`, or `RendererOptions.eventEffects`) at a point.\n * `play` gives the family of the material (the map's `{material}`) and the colours of its debris and dust. Answers whether one played, so the caller can\n * leave out the burst it replaces.\n */\n private playEvent(event: GameEvent, point: Vec3, play?: FamilyPlay): boolean {\n const id = effectForEvent(play && event.material === undefined ? { ...event, material: play.material } : event, this.o.eventEffects ?? EVENT_EFFECTS_MAP)\n if (!id) return false\n return this.vfx.play(id, point, { seed: hashNumbers(point[0], point[1], point[2], this.time), ...(play ? { values: play.values } : {}) }) !== null\n }\n\n /** The family and colours of a part's material, for the effects of the event map. */\n private partPlay(objectId: string, partId: string): FamilyPlay {\n const pv = this.partVis(objectId, partId)\n const def = pv ? this.world.materials.get(pv.material) : undefined\n return familyPlay(def, pv ? (this.partColor(pv, def) ?? undefined) : undefined)\n }\n\n /** A coat came off: a patch in the colour of the core under it, below the bullet holes and cracks. */\n private onSpall(ev: Ev<'spall'>): void {\n const pv = this.partVis(ev.object, ev.part)\n if (!pv) return\n const wp = new this.THREE.Vector3(ev.point[0], ev.point[1], ev.point[2])\n const mv = this.nearestMesh(pv, wp)\n if (!mv) return\n const def = this.world.materials.get(pv.material)\n const normal = this.faceNormal(mv, wp)\n const core = def?.visual?.innerColor\n const look = debrisLook(def, 'spall', { partColor: this.partColor(pv, def) ?? undefined })\n // masonry crumbles in the colour of what is under the coat (brick orange, concrete grey); the generic impact would throw dark grey chips, and a\n // material with no impact recipe of its own (plastic, fabric, soil) throws its own debris in its colour, not the concrete impact\n if (core !== undefined || look.impact === undefined) this.vfx.burst(look.debris, ev.point, [normal.x, normal.y, normal.z], 5, 2.5, { color: look.color })\n else this.playEvent({ kind: 'spall', material: look.impact }, ev.point)\n if (core !== undefined) this.trickleFrom(ev.point, [normal.x, normal.y, normal.z], core, mv)\n // a drawing that shows the coat coming off itself (the house renderer cuts its plaster and draws the bricks under it) takes no flat patch\n if ((mv.mesh.userData.drawnSpalls as string[] | undefined)?.includes(ev.part)) return\n this.visuals.addSpall(mv, wp, normal, Math.sqrt(ev.area / Math.PI), core ?? fallbackColor(def))\n }\n\n /**\n * Grit and dust go on falling from where a blow broke a hard face (masonry, concrete, wood) for `TRICKLE_SECONDS`, a pinch at a time and less and\n * less. The place is held on the mesh it broke on (`mv`), so it falls with the object when it tips or a piece of it comes away.\n */\n private trickleFrom(point: Vec3, normal: Vec3, color: number | undefined, mv: MeshVis | null): void {\n if (this.trickles.length >= TRICKLE_MAX) this.trickles.shift()\n const total = TRICKLE_SECONDS[0] + (TRICKLE_SECONDS[1] - TRICKLE_SECONDS[0]) * this.rng()\n const anchor = mv ? anchorOnMesh(this.THREE, mv, point, normal) : null\n this.trickles.push({ point: [point[0], point[1], point[2]], normal, anchor, color, left: total, total, next: TRICKLE_EVERY, source: this.emitting ?? mv?.home })\n }\n\n private updateTrickles(dt: number): void {\n for (let i = this.trickles.length - 1; i >= 0; i--) {\n const t = this.trickles[i]!\n t.left -= dt\n t.next -= dt\n if (t.left <= 0) {\n this.trickles.splice(i, 1)\n continue\n }\n if (t.next > 0) continue\n if (t.anchor) {\n // nothing left to crumble from: the part broke into fragments or is gone\n if (!anchorWorld(t.anchor, this.visuals.shown(t.anchor.mv), this.v1, this.v2)) {\n this.trickles.splice(i, 1)\n continue\n }\n t.point = [this.v1.x, this.v1.y, this.v1.z]\n t.normal = [this.v2.x, this.v2.y, this.v2.z]\n }\n // falling off the face, slower as the loose grit runs out\n const share = t.left / t.total\n t.next = TRICKLE_EVERY / Math.max(share, 0.25)\n const out: Vec3 = [t.normal[0] * 0.2, -1, t.normal[2] * 0.2]\n const options = { ...(t.color !== undefined ? { color: t.color } : {}), ...(t.source !== undefined ? { source: t.source } : {}) }\n this.vfx.burst('chips', t.point, out, this.low ? 1 : 2, 0.3, options)\n if (this.rng() < 0.5) this.vfx.burst('dust', t.point, out, 1, 0.2, options)\n }\n }\n\n /**\n * Stage 2 of a staged part: the unit-sized fragments come out and the part stays drawn (hiding it is what `fracture` does). The opening itself\n * (cutting the wall's faces) is not drawn yet: it needs the per-vertex binding of the house renderer.\n */\n private onStage(ev: Ev<'stage'>): void {\n const pv = this.partVis(ev.object, ev.part)\n const def = pv ? this.world.materials.get(pv.material) : undefined\n const at = ev.opening?.center ?? this.hitPoints.of(ev.object, ev.part, this.time) ?? this.rootPoint(ev.object)\n const played = this.playEvent({ kind: 'stage', stage: ev.stage }, at, this.partPlay(ev.object, ev.part))\n if (!ev.fragments || !ev.opening) return\n const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(def)\n const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments\n const step = this.low ? 2 : 1\n for (let i = 0; i < ev.fragments.length; i += step) {\n const fr = ev.fragments[i] as Fragment\n const fdef = this.world.materials.get(fr.material)\n this.fragments.spawn(fr, this.fragments.materialFor(fr.material, fdef === def || !fdef ? color : fallbackColor(fdef), false), ev.object, maxAlive)\n }\n if (!played) this.vfx.burst('dust', ev.opening.center, [0, 1, 0], 14, 1.2, { color })\n this.impactSound(pv?.material ?? '', ev.opening.center, 0.8, ev.blow)\n }\n\n /**\n * A unit came out of a wall of units: the unit flies as a fragment with a puff of its dust, and the marks drawn on it (bullet holes, spalls, the impact\n * marks of the effects) go with it. The gap itself is the drawing's (the house renderer cuts the wall where the unit was); a part drawn as one box\n * keeps its box.\n */\n private onChip(ev: Ev<'chip'>): void {\n const pv = this.partVis(ev.object, ev.part)\n const def = pv ? this.world.materials.get(pv.material) : undefined\n const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(def)\n const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments\n for (const fr of ev.fragments) {\n const fdef = this.world.materials.get(fr.material)\n // the inside of the material (fresh wood) when the piece came from it, else the part's colour\n const tone = fragmentTone(fdef, fr, fdef === def ? color : fallbackColor(fdef))\n this.fragments.spawn(fr as Fragment, this.fragments.materialFor(fr.material, tone, false), ev.object, maxAlive)\n }\n // a unit knocked out of masonry or concrete leaves a broken edge that goes on crumbling\n if (def?.visual?.innerColor !== undefined || pv?.material === 'concrete' || pv?.material === 'brick') {\n this.trickleFrom(ev.center, [0, 0, 0], color, pv ? this.nearestMesh(pv, new this.THREE.Vector3(ev.center[0], ev.center[1], ev.center[2])) : null)\n }\n // what a blow tore off a face leaves the hole it made where it is\n if (ev.torn) {\n this.impactSound(pv?.material ?? '', ev.center, 0.5, ev.blow)\n return\n }\n // the holes and spalls drawn on the unit leave with it (also those on the wall a beam is drawn inside), and on the ragged edge of plaster around it\n const T = this.THREE\n const center = new T.Vector3(ev.center[0], ev.center[1], ev.center[2])\n const half = new T.Vector3(ev.size[0] / 2 + CHIP_DECAL_EDGE, ev.size[1] / 2 + CHIP_DECAL_EDGE, ev.size[2] / 2 + CHIP_DECAL_EDGE)\n const rotation = new T.Quaternion(ev.rotation[0], ev.rotation[1], ev.rotation[2], ev.rotation[3])\n for (const part of this.bounds.get(ev.object)?.parts.values() ?? []) for (const mv of part.meshes) this.visuals.clearDecals(mv, center, half, rotation)\n this.vfx.peekWorkshop()?.decals.clearInside(ev.center, [half.x, half.y, half.z], ev.rotation)\n // a puff of the unit's own dust; not the bullet impact effect, which would leave its black mark on the hole the unit left\n this.vfx.burst('dust', ev.center, [0, 1, 0], ev.units ? Math.min(40, 8 + ev.units.length) : 8, ev.units ? 1.6 : 0.8, { color })\n this.impactSound(pv?.material ?? '', ev.center, 0.7, ev.blow)\n }\n\n private onFracture(ev: Ev<'fracture'>): void {\n const b = this.bounds.get(ev.object)\n const pv = b?.parts.get(ev.part)\n const matId = pv?.material || (ev.fragments[0]?.material ?? '')\n const def = this.world.materials.get(matId)\n let color = fallbackColor(def)\n let opacity = 0.5\n const transparent = def?.visual?.transparent === true\n if (pv) {\n const c = this.partColor(pv, def)\n if (c !== null) color = c\n const m = pv.meshes[0] ? (materialsOf(pv.meshes[0].origMaterial)[0] as THREE_NS.Material | undefined) : undefined\n if (m && m.transparent) opacity = clamp(m.opacity, 0.2, 0.8)\n this.visuals.hide(pv, 'broken')\n }\n this.spawnFragments(ev, 0, { def, color, opacity, transparent })\n // the groups the operation left loose come off first (the world's state is that of the end of the operation, whatever order its events arrive in): only\n // what is left of the object can have lost its footing\n this.splitLoose(ev.object)\n this.loosenIfFootless(ev.object)\n const up: Vec3 = [0, 1, 0]\n const sizeK = clamp(ev.fragments.length / 10, 0.5, 2)\n // what flies off is of the material that broke, in its colour: grey chips of concrete, orange of brick, splinters and pale dust of wood\n const look = debrisLook(def, 'fracture', { style: ev.style, partColor: color })\n const dust = look.dust !== undefined ? { color: look.dust } : undefined\n switch (ev.style) {\n case 'shatter':\n this.vfx.burst('shards', ev.point, up, 18 * sizeK, 3)\n break\n case 'crumble':\n this.vfx.burst('dust', ev.point, up, 16 * sizeK, 1.2, dust)\n this.vfx.burst(look.family === 'glass' ? 'shards' : 'chips', ev.point, up, 6, 3, { color: look.color })\n break\n case 'splinter':\n this.vfx.burst('splinters', ev.point, up, 14 * sizeK, 3, { color: look.color })\n this.vfx.burst('dust', ev.point, up, 5, 0.8, dust)\n break\n case 'tear':\n this.vfx.burst('fibers', ev.point, up, 12 * sizeK, 1.6, { color: look.color })\n break\n case 'snap':\n this.vfx.burst('chips', ev.point, up, 8 * sizeK, 3, { color: look.color })\n break\n default:\n this.vfx.burst('sparks', ev.point, up, 10, 4)\n }\n this.sound(fractureKey(def, ev.style), ev.point, clamp(0.4 + ev.fragments.length * 0.03, 0.4, 1), breakSoundKeys(matId, def, ev.blow))\n }\n\n /** Spawns the fragments of a fracture from index `from`; what does not fit in this frame's budget is spawned by the next frames. */\n private spawnFragments(ev: Ev<'fracture'>, from: number, look: { def: MaterialDef | undefined; color: number; opacity: number; transparent: boolean }): void {\n const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments\n const step = this.low ? 2 : 1\n for (let i = from; i < ev.fragments.length; i += step) {\n if (this.work && this.sliceDeadline !== Infinity) {\n if (i - from >= MIN_FRAGMENTS_PER_SLICE * step && !this.work.tryTake('fragment', this.workCosts.perFragment)) {\n this.slices.push({ ev, from: i, look })\n return\n }\n if (i - from < MIN_FRAGMENTS_PER_SLICE * step) this.work.take('fragment', this.workCosts.perFragment)\n } else if (i - from >= MIN_FRAGMENTS_PER_SLICE * step && this.drainClock() >= this.sliceDeadline) {\n this.slices.push(() => this.spawnFragments(ev, i, look))\n return\n }\n const fr = ev.fragments[i]\n const fdef = this.world.materials.get(fr.material)\n const tone = fragmentTone(fdef, fr, fdef === look.def || !fdef ? look.color : fallbackColor(fdef))\n const mat = this.fragments.materialFor(fr.material, tone, look.transparent || fdef?.visual?.transparent === true, look.opacity)\n this.fragments.spawn(fr, mat, ev.object, maxAlive)\n }\n }\n\n private onDetach(ev: Ev<'detach'>): void {\n this.sound('detach', this.rootPoint(ev.object), 0.5)\n this.splitLoose(ev.object)\n }\n\n /**\n * The cage of a part gave way (`expose` with no bars): nothing holds its bars any more, so each comes down where it is, as steel debris that stays on the\n * ground with a body (`FragmentSystem.spawn` with `lasting`), not as bars left standing in the air.\n */\n private dropCage(objectId: string, partId: string): void {\n const bars = this.cages.take(`${objectId}|${partId}`)\n if (bars.length === 0) return\n const radius = this.cages.barRadius\n const density = this.world.materials.get('steel')?.density ?? STEEL_DENSITY\n const material = this.fragments.materialFor('steel', REBAR_COLOR, false)\n const rnd = createRng(hashString(`${objectId}|${partId}`))\n bars.forEach((bar, i) => {\n const fragment: Fragment = {\n id: `${partId}#bar${i}`, part: partId, material: 'steel', shape: 'chunk', center: bar.center, size: [2 * radius, bar.length, 2 * radius], rotation: bar.rotation,\n velocity: [(rnd() - 0.5) * 0.4, 0, (rnd() - 0.5) * 0.4], angularVelocity: [(rnd() - 0.5) * 1.5, (rnd() - 0.5) * 0.5, (rnd() - 0.5) * 1.5],\n mass: density * Math.PI * radius * radius * bar.length,\n }\n this.fragments.spawn(fragment, material, objectId, this.maxFragments, true)\n })\n }\n\n /**\n * What goes on at a part (its fire, its leak, its burn sound, its heat) moves with the part to the object a split made of it: it goes on where the\n * part is, as it falls, not where the object stood, and does not end because the part has a new id.\n */\n private followSplit(from: Bound, to: Bound): void {\n for (const part of to.parts.keys()) {\n const was = `${from.id}|${part}`\n const now = `${to.id}|${part}`\n const fire = this.fires.get(was)\n if (fire) {\n this.fires.delete(was)\n fire.object = to.id\n this.fires.set(now, fire)\n }\n const sound = this.burnSounds.get(was)\n if (sound) {\n this.burnSounds.delete(was)\n this.burnSounds.set(now, { ...sound, object: to.id })\n }\n if (this.active.delete(was)) this.active.set(now, { object: to.id, part })\n }\n from.root.updateWorldMatrix(true, false)\n to.root.updateWorldMatrix(true, false)\n const into = new this.THREE.Matrix4().copy(to.root.matrixWorld).invert()\n for (const leak of this.leaks) {\n if (leak.object !== from.id || !to.parts.has(leak.part)) continue\n leak.object = to.id\n const point = leak.localPoint ? this.v1.set(...leak.localPoint).applyMatrix4(from.root.matrixWorld) : this.v1.set(...leak.point)\n const direction = leak.localDirection ? this.v2.set(...leak.localDirection).transformDirection(from.root.matrixWorld) : this.v2.set(...leak.direction)\n point.applyMatrix4(into)\n direction.transformDirection(into)\n leak.localPoint = [point.x, point.y, point.z]\n leak.localDirection = [direction.x, direction.y, direction.z]\n }\n }\n\n /** The pieces that held two parts by a joint that tears leave each other alone for good: a wire does not hit the pole it was clipped to as that pole falls. */\n private tetherTorn(torn: ReadonlyArray<readonly [string, string]>): void {\n const objectOf = (part: string): string | undefined => {\n for (const [id, bound] of this.bounds) if (bound.parts.has(part)) return id\n return undefined\n }\n for (const [first, second] of torn) {\n const a = objectOf(first)\n const c = objectOf(second)\n if (a !== undefined && c !== undefined && a !== c) this.pieceSys.tether(a, c)\n }\n }\n\n /** Turn every loose group of the object (a detach, a collapse) into a piece of its own. */\n private splitLoose(objectId: string, tearing: ReadonlyArray<readonly [string, string]> = []): void {\n if (!this.autoSplit) return\n const b = this.bounds.get(objectId)\n if (!b) return\n const st = this.world.state(objectId)\n if (!st || st.groups.length < 2) return\n const loose = st.groups.length - 1\n const torn = [...tearing, ...tornPairsOf(st)]\n if (this.work) {\n this.splitWithin(this.work, b, st, torn)\n return\n }\n // every loose group at once, whatever the clock says: the world builds what is left once, not once per group (a blast tears several off a house of\n // hundreds of parts), and what comes off in a frame must not depend on how long the frame took\n this.visuals.batchRebuilds(() => {\n // the hinges are read before, while the groups still hang on what stands\n let hinges: (Vec3 | null)[]\n let newIds: string[]\n try {\n hinges = Array.from({ length: loose }, (_, i) => this.hingeOf(objectId, i + 1))\n newIds = this.world.splitGroups(objectId, Array.from({ length: loose }, (_, i) => i + 1))\n } catch {\n return\n }\n newIds.forEach((newId, i) => {\n this.adoptSplit(b, newId)\n this.hangOnHinge(newId, hinges[i] ?? null)\n })\n })\n this.afterSplit(b, torn)\n }\n\n /** What is left of an object after loose groups came off it: its piece takes the box and contacts of what is left, or furniture left without its feet becomes one. */\n private afterSplit(b: Bound, torn: ReadonlyArray<readonly [string, string]>): void {\n const objectId = b.id\n this.tetherTorn(torn)\n const old = b.piece\n if (old) {\n const { half, center } = this.measure(b.root, this.meshesOf(b))\n old.halfExtents = half\n this.pieceSys.setCenter(old, center)\n old.mass = Math.max(MIN_PIECE_MASS_KG, this.massOf(objectId) - (old.massOffset ?? 0))\n // what came off no longer touches the ground for it: its contacts are those of what is left\n // and what others meet it by are the boxes of what is left (`partBoxes`): nothing invisible collides\n if (old.contacts || old.round) {\n this.fitSurface(b, old)\n if (!old.round) this.setContacts(b, old, this.meshesOf(b).filter((mv) => this.visuals.shown(mv)))\n } else if (old.partBoxes) this.fitPartBoxes(b, old)\n // at load what is left stood as it was: it is not woken\n if (!this.splittingAtLoad) old.sleeping = false\n } else if (kitOriginOf(b.root)?.kind === 'furniture' && !this.splittingAtLoad) {\n // furniture only stands on the floor: what stayed (a leg, two legs and a board) is loose too, and what cannot stand on its own topples; at load it stands as it stood\n const piece = this.makePiece(objectId)\n this.tipIfTopHeavy(b)\n // the host stops keeping the footprint it had where it stood: it is a body that moves now\n this.o.onLoosened?.(objectId, piece, 'apart')\n }\n }\n\n /**\n * Under `workBudget`: each loose group of the object none of whose parts is already waiting joins the split queue, ranked by its distance to `focus` (the player at the\n * start of the frame's work step) and its smallest part id, and charged by the size of its work. Until its turn it stays in the object, drawn and solid where it stood.\n */\n private queueLoose(b: Bound, st: ObjectState, torn: ReadonlyArray<readonly [string, string]>, focus: Vec3 | undefined): void {\n const waiting = new Set<string>()\n for (const { item } of this.splitQueue.saveState()) if (item.objectId === b.id) for (const id of item.parts) waiting.add(id)\n for (let g = 1; g < st.groups.length; g++) {\n const group = st.groups[g]!\n const parts = [...group].sort()\n if (parts.length === 0 || parts.some((id) => waiting.has(id))) continue\n const units = this.splitUnitsOf(b, group, st.parts.length)\n const centre = focus ? this.groupCentre(b, group) : null\n const priority = focus && centre ? Math.hypot(centre.x - focus[0], centre.y - focus[1], centre.z - focus[2]) : 0\n this.splitQueue.push({ objectId: b.id, parts, torn: torn.map(([first, second]) => [first, second] as const) }, priority, `${b.id}\\0${parts[0]}`, units)\n }\n }\n\n /**\n * The object's loose groups become pieces in the next drain (after a bind, a redraw, or pieces given back), not inside the call: the world may still be building it. Under\n * `workBudget` they join the split queue (`queueChecked`); without it they split in the drain (`splitChecked`).\n */\n private checkLoose(objectId: string, bound = false): void {\n if (this.autoSplit) this.looseToCheck.set(objectId, bound || (this.looseToCheck.get(objectId) ?? false))\n }\n\n /** The objects `checkLoose` marked that have a loose group now; one without any is no work waiting and is forgotten (a group that comes loose later comes with an event). */\n private looseLeft(): number {\n let left = 0\n for (const objectId of [...this.looseToCheck.keys()]) {\n if ((this.world.state(objectId)?.groups.length ?? 0) > 1) left++\n else this.looseToCheck.delete(objectId)\n }\n return left\n }\n\n /**\n * Without `workBudget`: the objects `checkLoose` marked, in the order they were marked, have their loose groups split (`splitLoose`) while the drain has time (with nothing\n * run before it in the drain, `done`, the first always does); the rest wait for the next drain. One with no loose group costs nothing. Returns how many objects split.\n */\n private splitChecked(deadline: number, done: number): number {\n let ran = 0\n for (const [objectId, bound] of [...this.looseToCheck]) {\n if (done + ran > 0 && this.drainClock() >= deadline) break\n this.looseToCheck.delete(objectId)\n const st = this.world.state(objectId)\n if (!this.bounds.has(objectId) || !st || st.groups.length < 2) continue\n this.staticDirty.add(objectId)\n this.splittingAtLoad = bound\n try {\n this.splitLoose(objectId)\n } finally {\n this.splittingAtLoad = false\n }\n ran++\n }\n return ran\n }\n\n /** The loose groups of the objects `checkLoose` marked join the split queue, unless waiting already: none stays loose in its object for ever. */\n private queueChecked(): void {\n for (const objectId of this.looseToCheck.keys()) {\n const b = this.bounds.get(objectId)\n const st = this.world.state(objectId)\n if (b && st && st.groups.length > 1) this.queueLoose(b, st, tornPairsOf(st), this.workFocus)\n }\n this.looseToCheck.clear()\n }\n\n /**\n * Under `workBudget`, in the event: the loose groups split now, in the world's order, while their units fit (the first of the frame always does, so a blow breaks something\n * at once); the rest wait in the queue. With room for all of them it is the same work in the same order as without the budget. An object with groups already waiting\n * keeps its turn in the queue.\n */\n private splitWithin(work: WorkBudget, b: Bound, st: ObjectState, torn: ReadonlyArray<readonly [string, string]>): void {\n const waiting = this.splitQueue.some((entry) => entry.objectId === b.id)\n let split = 0\n this.visuals.batchRebuilds(() => {\n // the world makes the object anew on each split: its state is read again each time\n for (let now: ObjectState | null = st; !waiting && now && now.groups.length > 1; now = this.world.state(b.id)) {\n const units = this.splitUnitsOf(b, now.groups[1]!, now.parts.length)\n if (!work.tryTake('split', units)) {\n if (this.eventSplitFrame === work.frame) return\n work.take('split', units)\n }\n let newId: string\n const hinge = this.hingeOf(b.id, 1)\n try {\n newId = this.world.splitGroup(b.id, 1)\n } catch {\n return\n }\n if (newId === b.id) return\n this.eventSplitFrame = work.frame\n this.adoptSplit(b, newId)\n this.hangOnHinge(newId, hinge)\n split++\n }\n })\n const left = this.world.state(b.id)\n if (left && left.groups.length > 1) this.queueLoose(b, left, torn, this.workFocus)\n if (split > 0) this.afterSplit(b, torn)\n }\n\n /** The units of cutting `group` off `b` (`splitWorkUnits`): its vertices, the merged meshes it leaves, the parts of the object. */\n private splitUnitsOf(b: Bound, group: readonly string[], objectParts: number): number {\n let vertices = 0\n const hosts = new Set<HostVis>()\n for (const id of group) {\n for (const mv of b.parts.get(id)?.meshes ?? []) {\n vertices += mv.range ? mv.range[1] - mv.range[0] : (mv.mesh.geometry.getAttribute('position')?.count ?? 0)\n if (mv.host && !mv.loose) hosts.add(mv.host)\n }\n }\n let hostVertices = 0\n for (const host of hosts) hostVertices += host.mesh.geometry.getAttribute('position')?.count ?? 0\n return splitWorkUnits(this.workCosts, { vertices, hostVertices, objectParts })\n }\n\n /** The centre of the drawn boxes of a group's meshes, in the world; null when none is drawn. */\n private groupCentre(b: Bound, group: readonly string[]): THREE_NS.Vector3 | null {\n const box = this.box.makeEmpty()\n for (const id of group) for (const mv of b.parts.get(id)?.meshes ?? []) box.union(this.visuals.worldBox(mv, new this.THREE.Box3()))\n return box.isEmpty() ? null : box.getCenter(this.v1)\n }\n\n /** The loose groups whose turn it is this frame become pieces; each object they came off is measured again once after its batch. Returns how many split. */\n private runSplits(work: WorkBudget, all: boolean): number {\n const turn = all ? this.drainSplits() : this.splitQueue.release(work)\n const touched = new Map<string, ReadonlyArray<readonly [string, string]>>()\n const lost = new Map<string, ReadonlyArray<readonly [string, string]>>()\n let ran = 0\n this.visuals.batchRebuilds(() => {\n for (const entry of turn) {\n const b = this.bounds.get(entry.objectId)\n const st = this.world.state(entry.objectId)\n if (!b || !st || !this.world.has(entry.objectId)) continue\n // groups renumber as others split, and may have grown or lost parts since: the group is the loose one holding any of its parts now\n const parts = new Set(entry.parts)\n const index = st.groups.findIndex((group, g) => g > 0 && group.some((id) => parts.has(id)))\n if (index < 1) {\n lost.set(entry.objectId, [...(lost.get(entry.objectId) ?? []), ...entry.torn])\n continue\n }\n let newId: string\n const hinge = this.hingeOf(entry.objectId, index)\n try {\n newId = this.world.splitGroup(entry.objectId, index)\n } catch {\n continue\n }\n this.adoptSplit(b, newId)\n this.hangOnHinge(newId, hinge)\n this.staticDirty.add(entry.objectId)\n touched.set(entry.objectId, [...(touched.get(entry.objectId) ?? []), ...entry.torn])\n ran++\n }\n })\n for (const [objectId, torn] of touched) {\n const b = this.bounds.get(objectId)\n if (b) this.afterSplit(b, torn)\n }\n // a waiting group may have broken in two before its turn, or none of its parts be loose any more: every loose group not waiting now joins the queue\n for (const [objectId, torn] of [...touched, ...lost]) {\n const b = this.bounds.get(objectId)\n const st = this.world.state(objectId)\n if (b && st && st.groups.length > 1) this.queueLoose(b, st, [...torn, ...tornPairsOf(st)], this.workFocus)\n }\n return ran\n }\n\n /** Every waiting split, in queue order (a flush). */\n private drainSplits(): PendingSplit[] {\n const out = this.splitQueue.saveState().map((entry) => entry.item)\n this.splitQueue.clear()\n return out\n }\n\n /** The renderer side of `splitGroup`: a new group holding the meshes of the new object, made a piece. */\n /**\n * Where a loose group still hangs on what stands (a shelf that lost the side at one end, still screwed to the other): the middle of the overlap of the two parts of the\n * one joint that holds and joins it to a structural part of the object's first group, which stands, in the world. Null when it hangs on nothing, or on more than one.\n */\n private hingeOf(objectId: string, group: number): Vec3 | null {\n const st = this.world.state(objectId)\n const loose = st?.groups[group]\n const standing = st?.groups[0]\n if (!st || !loose || !standing || group === 0) return null\n // what stands must stand still: a hinge is a point fixed in the world (a case knocked over carries its shelves with it)\n const piece = this.bounds.get(objectId)?.piece\n if (piece && !piece.sleeping && (Math.hypot(...piece.velocity) > HINGE_STILL_SPEED || Math.hypot(...piece.angularVelocity) > HINGE_STILL_SPIN)) return null\n const inLoose = new Set(loose)\n const inStanding = new Set(standing)\n const structural = new Set(st.parts.filter((p) => p.load !== undefined).map((p) => p.id))\n const holds = st.joints.filter((j) => {\n if (j.open || j.tears || j.kind === 'resting') return false\n const [own, other] = inLoose.has(j.a) ? [j.a, j.b] : [j.b, j.a]\n return inLoose.has(own) && inStanding.has(other) && structural.has(own) && structural.has(other)\n })\n if (holds.length !== 1) return null\n const joint = holds[0]!\n const boxOf = (partId: string): number[] | null =>\n this.shownBoxes(objectId, partId).reduce<number[] | null>((all, one) => (all ? all.map((value, k) => (k < 3 ? Math.min(value, one[k]!) : Math.max(value, one[k]!))) : [...one]), null)\n const a = boxOf(joint.a)\n const c = boxOf(joint.b)\n if (!a || !c) return null\n const point: Vec3 = [0, 0, 0]\n for (let k = 0; k < 3; k++) point[k] = (Math.max(a[k]!, c[k]!) + Math.min(a[k + 3]!, c[k + 3]!)) / 2\n return point\n }\n\n /** The piece of a group split off hangs on its hinge (`hingeOf`), when it had one. */\n private hangOnHinge(newId: string, hinge: Vec3 | null): void {\n const piece = hinge && this.bounds.get(newId)?.piece\n if (piece && hinge) this.pieceSys.hinge(piece, hinge)\n }\n\n private adoptSplit(from: Bound, newId: string): void {\n const state = this.world.state(newId)\n const root = from.root\n root.updateWorldMatrix(true, false)\n const group = new this.THREE.Group()\n group.name = `destruction-piece-${newId}`\n // a piece is drawn by this renderer from the meshes of the object it came off (CLAUDE.md, \"where every drawn piece comes from\"); its kind stays out of the source's checks\n markKitOrigin(group, { owner: 'game-destruction-three', kind: 'piece', id: kitOriginOf(root)?.id ?? from.id })\n root.getWorldPosition(group.position)\n root.getWorldQuaternion(group.quaternion)\n this.scene.add(group)\n group.updateMatrixWorld(true)\n const nb: Bound = { id: newId, root: group, sync: true, parts: new Map(), lastPos: null, lastQuat: null, piece: null, isSplit: true }\n for (const p of state?.parts ?? []) {\n const pv = from.parts.get(p.id)\n if (!pv) continue\n from.parts.delete(p.id)\n nb.parts.set(p.id, pv)\n // its bare bars go with it\n this.cages.move(`${from.id}|${p.id}`, `${newId}|${p.id}`, group)\n for (const mv of pv.meshes) {\n // a part drawn by a range of a merged mesh leaves its faces behind: it gets a mesh of its own\n if (mv.host && !mv.loose) this.visuals.extract(mv, group)\n else {\n group.attach(mv.mesh)\n showCollapsedRanges(mv.mesh)\n mv.moved = true\n }\n }\n }\n this.bounds.set(newId, nb)\n for (const pv of nb.parts.values()) this.tagPart(pv, newId)\n this.followSplit(from, nb)\n const meshes = this.meshesOf(nb)\n if (meshes.length === 0) return\n const { half, center } = this.measure(group, meshes)\n let vel: Vec3 = [0, 0, 0]\n let ang: Vec3 = [0, 0, 0]\n const op = from.piece\n if (op) {\n vel = [...op.velocity]\n ang = [...op.angularVelocity]\n // linear velocity at the loose piece's centre\n const c = this.pieceSys.centerOf(op, new this.THREE.Vector3())\n const nc = center.clone().applyQuaternion(group.quaternion).add(group.position)\n vel[0] += ang[1] * (nc.z - c.z) - ang[2] * (nc.y - c.y)\n vel[1] += ang[2] * (nc.x - c.x) - ang[0] * (nc.z - c.z)\n vel[2] += ang[0] * (nc.y - c.y) - ang[1] * (nc.x - c.x)\n }\n const piece = this.pieceSys.create(newId, group, half, center, this.massOf(newId), vel, ang)\n nb.piece = piece\n this.fitSurface(nb, piece)\n // what lands on it meets its parts as drawn (a board come off with its books), not the box around them all: nothing invisible collides\n this.fitPartBoxes(nb, piece)\n // a group loose at load starts asleep where it stood when something holds it up, so nothing jumps; held by nothing, it falls\n const resting = this.splittingAtLoad && this.pieceSys.restIfSupported(piece)\n // what cannot stand where it stood (at load), and furniture come apart, stands on the corners of its parts as drawn (§12), not on its box: a top on one leg tips over it\n const furniture = kitOriginOf(from.root)?.kind === 'furniture'\n if (!resting && (this.splittingAtLoad || furniture) && !piece.round) this.setContacts(nb, piece, meshes.filter((mv) => this.visuals.shown(mv)))\n if (!resting && furniture) this.tipIfTopHeavy(nb)\n this.o.onPiece?.(piece)\n }\n\n /**\n * What lost what it stood on falls (furniture, a stand, a crate, a car; not a structure): with every leg of a table broken the top is loose, and with the legs of one side\n * gone what is left topples. Feet are the meshes at the bottom of the object as it was whole; while the ones left still span the same floor (a cupboard with a broken door,\n * a table missing one leg) it stands. A piece that lost a part is the box of what is left, touching the ground by the corners of each part (`setContacts`).\n */\n private loosenIfFootless(objectId: string): void {\n const b = this.bounds.get(objectId)\n if (!b || !this.autoSplit) return\n const left = this.meshesOf(b).filter((mv) => this.visuals.shown(mv))\n if (left.length === 0) return\n // a house, a wall, the ground answer to their own load path: their pieces only take the box of what is left\n const structural = UNCHECKED_KINDS.has(this.kindOf(b))\n const body = b.piece ?? this.pieceSys.get(objectId)\n if (body) {\n // a piece is the box of what is left of it: the legs that broke off no longer hold it up\n const { half, center } = this.measure(b.root, left)\n body.halfExtents = half\n this.pieceSys.setCenter(body, center)\n body.mass = Math.max(MIN_PIECE_MASS_KG, this.massOf(objectId) - (body.massOffset ?? 0))\n if (!structural) {\n // what is left may be round (a can's label torn off) or not any more (a stool that lost its legs): its contacts follow\n this.fitSurface(b, body)\n if (!body.round) this.setContacts(b, body, left)\n }\n body.sleeping = false\n return\n }\n if (structural) return\n const boxOf = (mv: MeshVis): THREE_NS.Box3 => this.visuals.worldBox(mv, new this.THREE.Box3())\n const whole = [...b.parts.values()].flatMap((pv) => pv.meshes).map(boxOf).filter((one) => !one.isEmpty())\n // what hangs (a wall cabinet, a lamp) is held by what it hangs on: only what stood on something can lose its footing\n if (!this.standsOn(objectId, whole.map((one): [number, number, number, number, number, number] => [one.min.x, one.min.y, one.min.z, one.max.x, one.max.y, one.max.z]))) return\n const floor = Math.min(...whole.map((one) => one.min.y))\n const feetOf = (boxes: THREE_NS.Box3[]): THREE_NS.Box3 => boxes.filter((one) => one.min.y < floor + FEET_BAND).reduce((feet, one) => feet.union(one), new this.THREE.Box3())\n const leftBoxes = left.map(boxOf).filter((one) => !one.isEmpty())\n const now = feetOf(leftBoxes)\n // it stands while the centre of what is left is inside the polygon of its feet by `STAND_MARGIN` (a cupboard with a broken door); a table that lost a leg has its\n // centre on the line between the two legs beside the gap, balanced on an edge, and goes over toward the gap\n let away: { x: number; z: number } | null = null\n const was = feetOf(whole)\n const same = !now.isEmpty() && now.min.x <= was.min.x + FEET_BAND && now.max.x >= was.max.x - FEET_BAND && now.min.z <= was.min.z + FEET_BAND && now.max.z >= was.max.z - FEET_BAND\n // what is not furniture (a frame, a stand) keeps standing while its feet still span the same floor: its own load path answers for it\n if (same && kitOriginOf(b.root)?.kind !== 'furniture') return\n if (!now.isEmpty()) {\n const feet = leftBoxes.filter((one) => one.min.y < floor + FEET_BAND)\n const hull = convexHull(feet.flatMap((one) => [[one.min.x, one.min.z], [one.max.x, one.min.z], [one.max.x, one.max.z], [one.min.x, one.max.z]] as Array<[number, number]>))\n const centre = centreOfBoxes(leftBoxes)\n const inside = insideBy(hull, [centre[0], centre[2]])\n const box = leftBoxes.reduce((all, one) => all.union(one), new this.THREE.Box3())\n const height = box.max.y - box.min.y\n const narrow = height >= TIP_MIN_HEIGHT && Math.min(now.max.x - now.min.x, now.max.z - now.min.z) < TIP_NARROW * height\n if (!narrow && inside.depth > STAND_LEAN * (centre[1] - floor)) return\n away = hull.length >= 3 ? inside.out : null\n }\n const piece = this.makePiece(objectId)\n this.setContacts(b, b.piece ?? (piece as PieceBody), left)\n // balanced on an edge it is started over it, and gravity does the rest: turning about (z, 0, -x) moves the top toward (x, z)\n const loose = b.piece\n if (away && loose) {\n loose.angularVelocity[0] += away.z * EDGE_NUDGE\n loose.angularVelocity[2] -= away.x * EDGE_NUDGE\n loose.sleeping = false\n } else this.tipIfTopHeavy(b)\n // the host stops keeping the footprint it had where it stood: it is a body that moves now\n this.o.onLoosened?.(objectId, piece, 'apart')\n }\n\n shownBoxes(objectId: string, partId?: string): Array<[number, number, number, number, number, number]> {\n const b = this.bounds.get(objectId)\n if (!b) return []\n const box = new this.THREE.Box3()\n const out: Array<[number, number, number, number, number, number]> = []\n const pv = partId === undefined ? null : b.parts.get(partId)\n if (partId !== undefined && (!pv || pv.gone !== 'none')) return out\n for (const mv of pv ? pv.meshes : this.meshesOf(b)) {\n if (!this.visuals.shown(mv)) continue\n this.visuals.worldBox(mv, box)\n if (!box.isEmpty()) out.push([box.min.x, box.min.y, box.min.z, box.max.x, box.max.y, box.max.z])\n }\n return out\n }\n\n /**\n * What is left of each object broken since the last update stands on something, or falls: an object that is not a piece whose lowest drawn box has neither the ground, a\n * fixed top nor a piece within `BROKEN_GAP` under it is made a piece on the spot (see `onBrokenChecked`).\n */\n private checkBroken(): void {\n if (this.broken.size === 0) return\n const ids = [...this.broken]\n this.broken.clear()\n for (const id of ids) {\n const released = this.releaseIfFloating(id)\n this.o.onBrokenChecked?.(id, released)\n }\n }\n\n private releaseIfFloating(objectId: string): boolean {\n const b = this.bounds.get(objectId)\n if (!b || b.piece || this.pieceSys.get(objectId) || !this.autoSplit || UNCHECKED_KINDS.has(this.kindOf(b))) return false\n const boxes = this.shownBoxes(objectId)\n if (boxes.length === 0) return false\n // the object as it was whole (it has not moved: it is no piece): one that hung (a wall cabinet, a lamp) is held by what it hangs on, not checked here\n const whole = new this.THREE.Box3()\n const wholeBoxes: Array<[number, number, number, number, number, number]> = []\n for (const pv of b.parts.values()) {\n for (const mv of pv.meshes) {\n this.visuals.worldBox(mv, whole)\n if (!whole.isEmpty()) wholeBoxes.push([whole.min.x, whole.min.y, whole.min.z, whole.max.x, whole.max.y, whole.max.z])\n }\n }\n if (!this.standsOn(objectId, wholeBoxes) || this.standsOn(objectId, boxes)) return false\n const piece = this.makePiece(objectId)\n this.setContacts(b, b.piece ?? (piece as PieceBody), this.meshesOf(b).filter((mv) => this.visuals.shown(mv)))\n this.tipIfTopHeavy(b)\n this.o.onLoosened?.(objectId, piece, 'apart')\n return true\n }\n\n /** Whether the lowest of `boxes` (world boxes of the object `objectId`) has the ground, a fixed top or a piece within `BROKEN_GAP` under it. */\n private standsOn(objectId: string, boxes: ReadonlyArray<readonly [number, number, number, number, number, number]>): boolean {\n if (boxes.length === 0) return false\n const low = Math.min(...boxes.map((one) => one[1]))\n for (const [x0, y0, z0, x1, , z1] of boxes) {\n if (y0 > low + FEET_BAND) continue\n for (const [fx, fz] of BROKEN_SAMPLES) {\n const x = x0 + (x1 - x0) * fx\n const z = z0 + (z1 - z0) * fz\n const under = Math.max(this.groundAt(x, z), this.staticTopAtBut(objectId, x, z, y0, BROKEN_GAP), this.pieceSys.topAt(x, z, y0, BROKEN_GAP, objectId))\n if (under >= y0 - BROKEN_GAP) return true\n }\n }\n return false\n }\n\n /** The kind of kit piece a bound object is, by the mark on its root or the nearest one above it (a house binds a group inside its marked root); '' when unmarked. */\n private kindOf(b: Bound): string {\n for (let o: THREE_NS.Object3D | null = b.root; o; o = o.parent) {\n const kind = kitOriginOf(o)?.kind\n if (kind) return kind\n }\n return ''\n }\n\n /** The top of the ground or of a standing part of the world under (x, z), below height y: a ray straight down through the destruction world. */\n private surfaceAt(x: number, y: number, z: number): number {\n const ground = this.groundAt(x, z)\n // a world that casts no rays (a stand-in in a test) has only the ground to land on\n if (y <= ground || typeof this.world.raycast !== 'function') return ground\n // a piece of rubble spawned inside a part (the top course of a wall under its bond beam) sees that part first, at no distance: look under it\n let from = y\n for (let k = 0; k < SURFACE_RAYS && from > ground; k++) {\n const hit = this.world.raycast([x, from, z], [0, -1, 0], from - ground)\n if (!hit) return ground\n if (hit.distance > SURFACE_INSIDE) return Math.max(ground, hit.point[1])\n from -= SURFACE_STEP\n }\n return ground\n }\n\n /** `staticTopAt` without the boxes of `objectId` itself. */\n private staticTopAtBut(objectId: string, x: number, z: number, y: number, step: number): number {\n let top = -Infinity\n for (const [id, a] of this.staticNow()) {\n if (id === objectId || a.length === 0 || x < a[0] || x > a[3] || z < a[2] || z > a[5]) continue\n for (let i = 6; i < a.length; i += 6) {\n if (x < a[i] || x > a[i + 3] || z < a[i + 2] || z > a[i + 5]) continue\n const t = a[i + 4]\n if (t > top && t <= y + step) top = t\n }\n }\n return top\n }\n\n /**\n * The piece touches the ground by the corners of each part left of it, not by the box around them all: on one leg, or on the legs of one side, its centre of mass is off\n * what holds it and it goes over until the top meets the floor. Past `CONTACT_MESHES` meshes it keeps the corners of its box; up to `PART_BOX_MESHES`, what lands on it lands\n * on its parts.\n */\n private setContacts(b: Bound, body: PieceBody, meshes: MeshVis[]): void {\n if (meshes.length > PART_BOX_MESHES) {\n body.contacts = undefined\n body.partBoxes = undefined\n return\n }\n const inv = specFrameInverse(this.THREE, b.root)\n const m4 = new this.THREE.Matrix4()\n const lb = new this.THREE.Box3()\n const [cx, cy, cz] = body.localCenter\n const points: Vec3[] = []\n const boxes: PartBox[] = []\n for (const mv of meshes) {\n mv.mesh.updateWorldMatrix(true, false)\n this.visuals.localBox(mv, lb)\n if (lb.isEmpty()) continue\n m4.multiplyMatrices(inv, mv.mesh.matrixWorld)\n this.partBoxesOf(mv, { lb, m4, from: [cx, cy, cz] }, boxes)\n lb.applyMatrix4(m4)\n for (let i = 0; i < 8; i++) points.push([(i & 1 ? lb.max.x : lb.min.x) - cx, (i & 2 ? lb.max.y : lb.min.y) - cy, (i & 4 ? lb.max.z : lb.min.z) - cz])\n }\n body.contacts = points.length > 0 && meshes.length <= CONTACT_MESHES ? points : undefined\n // one box turned as drawn (a roof sheet lying askew) is kept too: the box of the piece would be the air around it\n body.partBoxes = boxes.length > 1 || (boxes.length === 1 && isTurned(boxes[0])) ? boxes : undefined\n }\n\n /** `fitOrientedBoxes` of a ranged part's points, taken from what it gave before when the points and the triangles are the very same numbers. */\n private fitRanged(mv: MeshVis, points: number[]): ReturnType<typeof fitOrientedBoxes> {\n const triangles = this.trianglesOf(mv)\n const kept = this.fittedBoxes.get(mv)\n if (kept && sameNumbers(kept.points, points) && sameNumbers(kept.triangles, triangles)) return kept.boxes\n const boxes = fitOrientedBoxes(points, triangles)\n this.fittedBoxes.set(mv, { points, triangles, boxes })\n return boxes\n }\n\n /** Queue the ranged parts of a bound object to be fitted while a frame has time to spare, read the way `setContacts` reads them while the object stands where it is. */\n private prefitPartBoxes(b: Bound): void {\n const parts = this.meshesOf(b).filter((mv) => mv.range && mv.host && !mv.loose)\n if (parts.length > 0) this.prefitting.push({ b, parts, next: 0 })\n }\n\n private prefitLeft(): number {\n let left = 0\n for (const job of this.prefitting) left += job.parts.length - job.next\n return left\n }\n\n /** Fit queued parts one at a time until the deadline, one at least. Returns the parts taken off the queue. */\n private runPrefit(deadline: number, clock: () => number): number {\n let ran = 0\n const frames = new Map<Bound, THREE_NS.Matrix4>()\n while (this.prefitting.length > 0 && (ran === 0 || clock() < deadline)) {\n this.prefitOne(frames)\n ran++\n }\n return ran\n }\n\n /** With no budget running the fitting ahead (`prefitQueue`): inside the events drain, for `PREFIT_SLICE_MS` or what is left of `deadline` (one part at least when `force`: nothing else ran). */\n private runPrefitDetached(deadline: number, clock: () => number, force: boolean): number {\n if (this.prefitAttached) return 0\n const left = deadline - clock()\n if (left <= 0 && !force) return 0\n return drainDetached(this.prefitQueue, Math.min(left, PREFIT_SLICE_MS), clock)\n }\n\n /** Under `workBudget`: the queued parts fitted ahead while their units fit in what the frame left (`perVertex` of the part's range), never by the clock. */\n private runPrefitWork(work: WorkBudget): number {\n let ran = 0\n const frames = new Map<Bound, THREE_NS.Matrix4>()\n while (this.prefitting.length > 0) {\n const job = this.prefitting[0]!\n const mv = job.parts[job.next]\n const units = mv?.range ? this.workCosts.perVertex * (mv.range[1] - mv.range[0]) : 0\n if (units > 0 && !work.tryTake('prefit', units)) break\n if (this.prefitOne(frames)) ran++\n }\n return ran\n }\n\n /** The next queued part fitted ahead; false when it was skipped (gone, loose, or its object unbound). */\n private prefitOne(frames: Map<Bound, THREE_NS.Matrix4>): boolean {\n const job = this.prefitting[0]!\n const mv = job.parts[job.next++]\n if (job.next >= job.parts.length) this.prefitting.shift()\n if (!mv || this.bounds.get(job.b.id) !== job.b) {\n if (this.prefitting[0] === job) this.prefitting.shift()\n return false\n }\n if (!mv.range || !mv.host || mv.loose) return false\n let inverse = frames.get(job.b)\n if (!inverse) frames.set(job.b, (inverse = specFrameInverse(this.THREE, job.b.root)))\n mv.mesh.updateWorldMatrix(true, false)\n const m4 = new this.THREE.Matrix4().multiplyMatrices(inverse, mv.mesh.matrixWorld)\n this.partBoxesOf(mv, { lb: new this.THREE.Box3(), m4, from: [0, 0, 0] }, [])\n return true\n }\n\n /** The triangles of a ranged part as vertex numbers of its own range (three each): the surface its vertices are joined by. A loose part is read from the buffer itself, not from what the host keeps for the parts that still hang on it. */\n private trianglesOf(mv: MeshVis): number[] {\n const [from, to] = mv.range ?? [0, 0]\n const index = mv.mesh.geometry.getIndex()?.array\n const count = index ? index.length : (mv.mesh.geometry.getAttribute('position')?.count ?? 0)\n const own: number[] = []\n for (let i = 0; i + 2 < count; i += 3) {\n const a = index ? index[i]! : i\n const b = index ? index[i + 1]! : i + 1\n const c = index ? index[i + 2]! : i + 2\n if (a < from || a >= to || b < from || b >= to || c < from || c >= to) continue\n own.push(a - from, b - from, c - from)\n }\n return own\n }\n\n /**\n * The boxes of one mesh in the piece's frame, from its centre of mass, turned as the mesh is drawn: a plain mesh is its geometry's box in its own space, turned by its\n * place in the piece; a part drawn by a range of a merged mesh (a roof sheet in the house's roof mesh) is fitted to its own vertices (`fitOrientedBoxes`), since the box\n * of those vertices in the merged mesh's space is the box around a tilted sheet, mostly air.\n */\n private partBoxesOf(mv: MeshVis, at: { readonly lb: THREE_NS.Box3; readonly m4: THREE_NS.Matrix4; readonly from: Vec3 }, out: PartBox[]): void {\n const [cx, cy, cz] = at.from\n if (mv.range) {\n const own: number[] = []\n this.visuals.rangePoints(mv, new this.THREE.Matrix4(), own)\n const drawn = hollowBoxesOf(own)\n if (drawn) {\n const pos = new this.THREE.Vector3()\n const quat = new this.THREE.Quaternion()\n const scale = new this.THREE.Vector3()\n at.m4.decompose(pos, quat, scale)\n for (const box of drawn) {\n const c = new this.THREE.Vector3((box.low[0]! + box.high[0]!) / 2, (box.low[1]! + box.high[1]!) / 2, (box.low[2]! + box.high[2]!) / 2).applyMatrix4(at.m4)\n const half: Vec3 = [Math.abs((box.high[0]! - box.low[0]!) * scale.x) / 2, Math.abs((box.high[1]! - box.low[1]!) * scale.y) / 2, Math.abs((box.high[2]! - box.low[2]!) * scale.z) / 2]\n out.push({ center: [c.x - cx, c.y - cy, c.z - cz], half, rotation: [quat.x, quat.y, quat.z, quat.w] })\n }\n return\n }\n // fitted in the mesh's own space, which a split or a move does not change, and carried into the piece by the pose: the same boxes, turned and moved, with no fit\n if (isRigidPose(at.m4.elements)) {\n const turn = new this.THREE.Quaternion().setFromRotationMatrix(at.m4)\n const c = new this.THREE.Vector3()\n const q = new this.THREE.Quaternion()\n for (const box of this.fitRanged(mv, own)) {\n c.set(box.center[0], box.center[1], box.center[2]).applyMatrix4(at.m4)\n q.set(box.rotation[0], box.rotation[1], box.rotation[2], box.rotation[3]).premultiply(turn).normalize()\n out.push({ center: [c.x - cx, c.y - cy, c.z - cz], half: [...box.half], rotation: [q.x, q.y, q.z, q.w] })\n }\n return\n }\n const pts: number[] = []\n this.visuals.rangePoints(mv, at.m4, pts)\n for (const box of this.fitRanged(mv, pts)) out.push({ center: [box.center[0] - cx, box.center[1] - cy, box.center[2] - cz], half: [...box.half], rotation: [...box.rotation] })\n return\n }\n const pos = new this.THREE.Vector3()\n const quat = new this.THREE.Quaternion()\n const scale = new this.THREE.Vector3()\n at.m4.decompose(pos, quat, scale)\n const c = at.lb.getCenter(new this.THREE.Vector3()).applyMatrix4(at.m4)\n const size = at.lb.getSize(new this.THREE.Vector3())\n out.push({\n center: [c.x - cx, c.y - cy, c.z - cz],\n half: [Math.max(0.005, Math.abs(size.x * scale.x) / 2), Math.max(0.005, Math.abs(size.y * scale.y) / 2), Math.max(0.005, Math.abs(size.z * scale.z) / 2)],\n rotation: [quat.x, quat.y, quat.z, quat.w],\n })\n }\n\n /**\n * A piece of furniture standing on feet too close for its height (a board on two legs in a line, a lone leg) does not stay up: the box of a piece hides that its weight is up\n * high and its feet are thin, so it gets the start of the fall, across the line of its feet.\n */\n private tipIfTopHeavy(b: Bound): void {\n const piece = b.piece\n if (!piece) return\n const box = new this.THREE.Box3()\n const boxes = this.meshesOf(b).filter((mv) => this.visuals.shown(mv)).map((mv) => this.visuals.worldBox(mv, new this.THREE.Box3()))\n if (boxes.length === 0) return\n for (const one of boxes) box.union(one)\n const height = box.max.y - box.min.y\n const feet = new this.THREE.Box3()\n for (const one of boxes) if (one.min.y < box.min.y + FEET_BAND) feet.union(one)\n const spanX = feet.max.x - feet.min.x\n const spanZ = feet.max.z - feet.min.z\n if (height < TIP_MIN_HEIGHT || Math.min(spanX, spanZ) >= TIP_NARROW * height) return\n const across = spanX <= spanZ ? 0 : 2\n const lean = across === 0 ? box.min.x + box.max.x - feet.min.x - feet.max.x : box.min.z + box.max.z - feet.min.z - feet.max.z\n const away = lean < 0 ? -1 : 1\n // rotating about -z moves the top toward +x; rotating about +x moves it toward +z\n if (across === 0) this.pieceSys.tip(piece, 0, -away)\n else this.pieceSys.tip(piece, away, 0)\n }\n\n private onExplode(ev: Ev<'explode'>, options: ExplodeOptions = {}): void {\n const p = ev.point\n if (options.visual !== false) this.playExplosion(ev, options)\n this.vfx.push(p, ev.radius, 4)\n this.pieceSys.layGroundAt(p[0], p[2], ev.radius)\n // shove pieces and fragments\n const c = this.v1\n const report = options.report\n const confinement = report?.find((r) => r.blast !== undefined)?.blast?.confinement ?? 1\n const energy = ev.energy * confinement\n // the energy that got to an object after what stood in the way: the world's shelter of this blast when it carries one, else the cover between the centre and the\n // object's centre (`blastReach`, always on: a wall, a car or a cupboard between them takes the push), as it stood when the part went off: the cupboard the wave\n // tears apart still met it, and the stove it throws was not in the way yet\n const wentOff = this.coverWhenWentOff.get(ev)\n const reachOf = (objectId: string, at: Vec3): number =>\n report?.find((r) => r.object === objectId)?.blast?.shelter ??\n wentOff?.get(objectId) ??\n this.world.blastReach?.(p, at, { ignore: ev.object ? [ev.object, objectId] : [objectId] }) ??\n 1\n // with a debris policy the shove waits its turn in the wake queue (nearest the player first, else the centre), sized by the measured step cost: not the whole pile in the blast's frame\n const policy = this.blastDebris ? resolveBlastDebris(this.o.blastDebris, options.debris) : null\n const focus = this.o.focus?.()\n const reach = (distance: number, wake: BlastWake, at: Vec3): void => {\n if (!policy || !this.blastWakes) return this.applyWake(wake)\n const priority = focus ? Math.hypot(at[0] - focus[0], at[1] - focus[1], at[2] - focus[2]) : distance\n this.blastWakes.push(priority, wake, policy.maxWakeDelay)\n }\n // the wave presses on the whole face it meets, so the push has no lever arm beyond the thinnest side of the body: a thin long piece (a shovel) is not spun by it\n const shove = (pc: PieceBody): void => {\n this.pieceSys.centerOf(pc, c)\n const distance = c.distanceTo(this.v2.set(p[0], p[1], p[2]))\n if (distance > ev.radius) return\n const area = this.waveArea(pc.objectId, pc.halfExtents, pc.root.quaternion, c, p)\n const hit = blastShove({ point: p, energy, radius: ev.radius, reach: reachOf(pc.objectId, [c.x, c.y, c.z]) }, { position: [c.x, c.y, c.z], mass: pc.mass, ...(area !== undefined ? { area } : {}) }, this.o.blastShove)\n if (!hit) return\n const spread = Math.min(...pc.halfExtents)\n const momentum = hit.speed * pc.mass\n const impulse: Vec3 = [hit.direction[0] * momentum, hit.direction[1] * momentum, hit.direction[2] * momentum]\n const point: Vec3 = [c.x + (this.rng() - 0.5) * spread, c.y + spread * 0.5, c.z + (this.rng() - 0.5) * spread]\n reach(distance, { objectId: pc.objectId, generation: pc.generation, impulse, point }, [c.x, c.y, c.z])\n }\n for (const pc of [...this.pieceSys.list]) shove(pc)\n if (this.o.shoveable) this.loosen(p, ev.radius, energy, reachOf, policy, reach)\n this.advanceWakes(0)\n this.fragments.blast(p, ev.radius, Math.min(20, Math.sqrt(energy) * 0.08))\n this.sound('explode', p, clamp(0.5 + ev.radius / 10, 0.5, 1), {\n radius: ev.radius,\n ...(ev.effect !== undefined ? { effect: ev.effect } : {}),\n ...(options.effect !== undefined ? { effect: options.effect } : {}),\n ...(report ? { confinement } : {}),\n })\n }\n\n /** The area a body shows the blast, or undefined when the host gave the numbers of the game rule (`blastShove`): then the push is that rule, not the blast wave. */\n private waveArea(objectId: string, half: Vec3, quaternion: THREE_NS.Quaternion, centre: THREE_NS.Vector3, point: Vec3): number | undefined {\n if (this.o.blastShove !== undefined) return undefined\n const box = this.areaFacing(half, quaternion, centre, point)\n const shown = this.shownArea(objectId, point)\n return shown === undefined ? box : Math.min(box, shown)\n }\n\n /**\n * Square metres the drawn parts of an object still standing show a blast at `point`: the box of each mesh, turned as it is, seen from there. The box of the whole piece\n * overstates a slender thing: a shovel lying on its side is a 1.1 x 0.07 m box (0.077 m2) but its handle and blade show 0.9 x 0.035 + 0.3 x 0.012 = 0.035 m2.\n */\n private shownArea(objectId: string, point: Vec3): number | undefined {\n const b = this.bounds.get(objectId)\n if (!b) return undefined\n this.visuals.flushPendingRebuilds()\n const seen = new Set<THREE_NS.Object3D>()\n const size = new this.THREE.Vector3()\n const scale = new this.THREE.Vector3()\n const centre = new this.THREE.Vector3()\n const turn = new this.THREE.Quaternion()\n let area = 0\n for (const pv of b.parts.values()) {\n if (pv.gone !== 'none') continue\n for (const { mesh } of pv.meshes) {\n if (seen.has(mesh) || !mesh.visible) continue\n seen.add(mesh)\n const geometry = mesh.geometry\n if (!geometry.boundingBox) geometry.computeBoundingBox()\n const bounds = geometry.boundingBox\n if (!bounds || bounds.isEmpty()) continue\n mesh.updateWorldMatrix(true, false)\n mesh.matrixWorld.decompose(centre, turn, scale)\n bounds.getSize(size).multiply(scale)\n bounds.getCenter(centre).applyMatrix4(mesh.matrixWorld)\n area += this.areaFacing([Math.abs(size.x) / 2, Math.abs(size.y) / 2, Math.abs(size.z) / 2], turn, centre, point)\n }\n }\n return area > 0 ? area : undefined\n }\n\n /** Square metres a box of half sizes `half` (its own axes, turned by `quaternion`) at `centre` shows a blast at `point`: the sum of its faces seen from there, by the cosine of each. */\n private areaFacing(half: Vec3, quaternion: THREE_NS.Quaternion, centre: THREE_NS.Vector3, point: Vec3): number {\n const toward = this.v3.set(centre.x - point[0], centre.y - point[1], centre.z - point[2])\n if (toward.lengthSq() < 1e-12) return 0\n toward.normalize().applyQuaternion(this.q1.copy(quaternion).invert())\n return 4 * (half[1] * half[2] * Math.abs(toward.x) + half[0] * half[2] * Math.abs(toward.y) + half[0] * half[1] * Math.abs(toward.z))\n }\n\n /** The cover between a part of the world that goes off and the centre of each piece and each shoveable body within its radius, as the world stands at that moment. */\n private coverAround(ev: Ev<'explode'>): Map<string, number> {\n const cover = new Map<string, number>()\n const reach = this.world.blastReach\n if (!reach) return cover\n const point = new this.THREE.Vector3(ev.point[0], ev.point[1], ev.point[2])\n const centre = new this.THREE.Vector3()\n const read = (objectId: string): void => {\n if (centre.distanceTo(point) <= ev.radius) cover.set(objectId, reach.call(this.world, ev.point, [centre.x, centre.y, centre.z], { ignore: [ev.object, objectId] }))\n }\n for (const pc of this.pieceSys.list) {\n this.pieceSys.centerOf(pc, centre)\n read(pc.objectId)\n }\n const shoveable = this.o.shoveable\n if (!shoveable) return cover\n for (const b of this.bounds.values()) {\n if (b.piece || cover.has(b.id) || !shoveable(b.id) || !this.world.has(b.id)) continue\n centre.copy(this.measure(b.root, this.meshesOf(b)).center).applyQuaternion(b.root.quaternion).add(b.root.position)\n read(b.id)\n }\n return cover\n }\n\n /**\n * The bound objects without a piece that the host lets a blast move (`shoveable`): the ones it reaches with enough speed become pieces and get the shove. With a debris\n * policy, how many enter physics is the count the measured cost allows (`physicsPieceCount`): every big one, then the nearest chips while there is room; the chips left\n * over stay where they stand (nothing invisible collides, nothing drawn is taken away) and the blast throws visual chips there instead.\n */\n private loosen(point: Vec3, radius: number, energy: number, reachOf: (objectId: string, at: Vec3) => number, policy: ResolvedBlastDebris | null, reach: (distance: number, wake: BlastWake, at: Vec3) => void): void {\n const shoveable = this.o.shoveable\n if (!shoveable) return\n const candidates: Array<{ b: Bound; world: THREE_NS.Vector3; half: Vec3; mass: number; hit: { direction: Vec3; speed: number }; size: number; distance: number }> = []\n const focus = this.o.focus?.()\n for (const b of [...this.bounds.values()]) {\n if (b.piece || this.pieceSys.get(b.id) || !shoveable(b.id) || !this.world.has(b.id)) continue\n const { half, center } = this.measure(b.root, this.meshesOf(b))\n const world = center.clone().applyQuaternion(b.root.quaternion).add(b.root.position)\n const mass = this.massOf(b.id)\n const distance = world.distanceTo(this.v2.set(point[0], point[1], point[2]))\n if (distance > radius) continue\n const area = this.waveArea(b.id, half, b.root.quaternion, world, point)\n const hit = blastShove({ point, energy, radius, reach: reachOf(b.id, [world.x, world.y, world.z]) }, { position: [world.x, world.y, world.z], mass, ...(area !== undefined ? { area } : {}) }, this.o.blastShove)\n // what orders them is the distance to the player when there is one, else to the blast\n const rank = focus ? Math.hypot(world.x - focus[0], world.y - focus[1], world.z - focus[2]) : distance\n if (hit) candidates.push({ b, world, half, mass, hit, size: 2 * Math.max(...half), distance: rank })\n }\n const count = policy ? physicsPieceCount({ minPieces: policy.minPhysicsPieces, maxPieces: policy.maxPhysicsPieces, costTargetMs: policy.physicsCostTargetMs }, this.costMeter.wakeCostPerBodyMs, this.awakeBodies()) : Infinity\n const { physics, chips } = policy ? chooseForPhysics(candidates, count, policy.chipSize) : { physics: candidates, chips: [] }\n for (const { b, world, half, mass, hit, distance } of physics) {\n const piece = this.makePiece(b.id, { mass })\n const body = this.pieceSys.get(b.id)\n if (!body) continue\n this.o.onLoosened?.(b.id, piece, 'blast')\n const spread = Math.min(...half)\n const momentum = hit.speed * mass\n const impulse: Vec3 = [hit.direction[0] * momentum, hit.direction[1] * momentum, hit.direction[2] * momentum]\n const at: Vec3 = [world.x + (this.rng() - 0.5) * spread, world.y + spread * 0.5, world.z + (this.rng() - 0.5) * spread]\n reach(distance, { objectId: b.id, generation: body.generation, impulse, point: at }, [world.x, world.y, world.z])\n }\n for (const { world, hit } of chips) this.vfx.burst('chips', [world.x, world.y, world.z], hit.direction, 4, Math.min(6, hit.speed))\n }\n\n /** The step cost of this frame by the `debrisCost` source: the loop's clock, nothing (`fixed`), or the recording. */\n private sampleCost(): DebrisCostSample | null {\n const source = this.o.debrisCost\n if (source?.source === 'fixed') return null\n if (source?.source === 'replay') return source.samples[this.costFrame++] ?? null\n const sample = this.pieceSys.stepCost()\n if (sample && source?.record) source.record.push(sample)\n return sample\n }\n\n /** One frame of the wake queue: the step cost of the frames before sizes the batch. */\n private advanceWakes(dt: number): void {\n if (!this.blastWakes) return\n const work = this.work\n // under the work budget the wakes draw what the frame's other work left (the cost still sizes the batch below it)\n const limit = work ? work.fits(this.workCosts.perWake) : Infinity\n const woken = this.blastWakes.advance({ dt, lastStepMs: this.cost?.stepMs ?? 0, costPerBodyMs: this.costMeter.wakeCostPerBodyMs, limit, apply: this.applyWake })\n work?.take('wake', woken * this.workCosts.perWake)\n }\n\n /** A blast's push reaching its piece: the very body it was pushed for (a piece removed or faded since, or made again under the same id, takes nothing). */\n private readonly applyWake = (wake: BlastWake): void => {\n const piece = this.pieceSys.get(wake.objectId)\n if (piece && piece.generation === wake.generation) this.pieceSys.impulse(piece, [wake.impulse[0], wake.impulse[1], wake.impulse[2]], [wake.point[0], wake.point[1], wake.point[2]])\n }\n\n /** Awake bodies in the physics world (what a blast's debris adds to). */\n private awakeBodies(): number {\n return this.pieceSys.activeBodies()\n }\n\n /** The world's cost per awake body, from the loop's last frame. */\n private measureCost(): void {\n if (this.cost) this.costMeter.observe(this.cost.stepMs, this.cost.active)\n }\n\n /** A piece at rest that is far and old, or over the cap (`PieceSystemOptions.keep`): its body and collider go now and its root shrinks away. */\n private fadePiece(b: PieceBody): void {\n const bound = this.bounds.get(b.objectId)\n if (!bound || this.fading.has(b.objectId)) return\n this.staticDirty.add(b.objectId)\n this.pieceSys.remove(b.objectId)\n this.forgetBound(b.objectId)\n this.hitPoints.forget(b.objectId)\n this.fading.set(b.objectId, { root: bound.root, age: 0 })\n }\n\n private updateFading(dt: number): void {\n if (this.fading.size === 0) return\n const seconds = this.blastDebris?.far.fadeSeconds ?? 0\n for (const [id, f] of this.fading) {\n f.age += dt\n const left = seconds > 0 ? 1 - f.age / seconds : 0\n if (left > 0) {\n f.root.scale.setScalar(left)\n continue\n }\n this.fading.delete(id)\n // the host owns the geometry and disposes it in `onDebrisFaded`\n // eslint-disable-next-line kit/no-bare-remove -- the host disposes the root it is handed\n f.root.removeFromParent()\n this.o.onDebrisFaded?.(id, f.root)\n }\n }\n\n private playExplosion(ev: Ev<'explode'>, options: ExplodeOptions): void {\n const named = options.effect ?? ev.effect\n const direction = options.direction\n const scale = clamp(ev.radius / GENERIC_REFERENCE_RADIUS, 0.2, 3)\n if (named !== undefined && this.vfx.explosion(named, ev.point, direction ? { direction } : {}) !== null) return\n this.vfx.explosion('generic', ev.point, { scale, ...(direction ? { direction } : {}) })\n }\n\n private startFire(ev: { object: string; part: string; point: Vec3 }): void {\n const key = `${ev.object}|${ev.part}`\n this.stopFire(key)\n this.fires.set(key, { object: ev.object, part: ev.part, point: ev.point, follow: { x: ev.point[0], y: ev.point[1], z: ev.point[2] } })\n }\n\n private stopFire(key: string): void {\n const fire = this.fires.get(key)\n if (fire) {\n if (fire.handle !== undefined) this.vfx.stop(fire.handle)\n this.fires.delete(key)\n }\n this.endBurnSound(key)\n }\n\n /** A part's fire loop starts; one already running for the part (it caught again) is ended first, so the host never counts a fire twice. */\n private startBurnSound(object: string, part: string, point: Vec3, detail: SoundDetail | undefined): void {\n const key = `${object}|${part}`\n this.endBurnSound(key)\n this.burnSounds.set(key, { object, point, detail })\n this.sound('burn_loop', point, 0.5, detail)\n }\n\n /** The part's fire loop ends, with the point and the fuel it started with; nothing when it has none running. */\n private endBurnSound(key: string): void {\n const started = this.burnSounds.get(key)\n if (!started) return\n this.burnSounds.delete(key)\n this.sound('burn_end', started.point, 0.5, started.detail)\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Fire, heat, char, melt, leaks\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n private updateActive(dt: number): void {\n this.scanTimer += dt\n if (this.scanTimer >= 0.4) {\n this.scanTimer = 0\n for (const b of this.bounds.values()) {\n for (const pv of b.parts.values()) {\n if (pv.gone !== 'none' && pv.gone !== 'broken') continue\n const ps = this.world.part(b.id, pv.id)\n if (!ps) continue\n const def = this.world.materials.get(pv.material)\n if (\n ps.burning ||\n (def?.visual?.glows && ps.temperature > GLOW_FROM_C) ||\n Math.abs(ps.char - pv.charApplied) > 0.01 ||\n Math.abs(ps.melt - pv.meltApplied) > 0.01 ||\n (pv.gone === 'none' && (ps.status === 'melted' || ps.status === 'ashes'))\n ) {\n this.activate(b.id, pv.id)\n }\n }\n }\n }\n for (const [key, a] of this.active) {\n const pv = this.partVis(a.object, a.part)\n const ps = pv ? this.world.part(a.object, a.part) : null\n if (!pv || !ps) {\n this.active.delete(key)\n this.stopFire(key)\n continue\n }\n const def = this.world.materials.get(pv.material)\n if (pv.gone === 'none') {\n this.visuals.setChar(pv, ps.char, def?.visual?.charColor ?? 0x1a1410)\n if (def?.visual?.glows) this.visuals.setGlow(pv, ps.temperature)\n this.visuals.setMelt(pv, ps.melt)\n if (ps.status === 'melted') this.onGone(a.object, pv, 'melted', def)\n else if (ps.status === 'ashes') this.onGone(a.object, pv, 'ashes', def)\n }\n const fire = this.fires.get(key)\n if (fire) {\n if (ps.burning && ps.status !== 'broken' && ps.status !== 'ashes' && ps.status !== 'melted') this.emitFire(fire, pv, def)\n else this.stopFire(key)\n }\n const hot = def?.visual?.glows === true && ps.temperature > GLOW_FROM_C\n if (!ps.burning && !hot && Math.abs(ps.char - pv.charApplied) < 0.01 && Math.abs(ps.melt - pv.meltApplied) < 0.01) {\n if (def?.visual?.glows && pv.gone === 'none') this.visuals.setGlow(pv, 0)\n this.active.delete(key)\n }\n }\n }\n\n private onGone(objectId: string, pv: PartVis, reason: 'melted' | 'ashes', def: MaterialDef | undefined): void {\n const bb = new this.THREE.Box3()\n for (const mv of pv.meshes) bb.union(this.visuals.worldBox(mv, this.box))\n this.visuals.hide(pv, reason)\n if (bb.isEmpty()) return\n const c = bb.getCenter(new this.THREE.Vector3())\n const s = bb.getSize(new this.THREE.Vector3())\n const footprint = Math.sqrt(Math.max(s.x * s.z, 1e-4))\n if (reason === 'melted') {\n this.ground.add('puddle', c.x, c.z, clamp(footprint * 0.55, 0.05, 1), this.partColor(pv, def) ?? fallbackColor(def), objectId)\n } else {\n this.ground.add('ash', c.x, c.z, clamp(footprint * 0.35, 0.04, 0.5), 0x1d1a18, objectId)\n this.vfx.burst('ash', [c.x, bb.max.y, c.z], [0, 1, 0], 10, 0.8, { source: objectId })\n }\n }\n\n private emitFire(f: FireEmitter, pv: PartVis, def: MaterialDef | undefined): void {\n const bb = this.box\n bb.makeEmpty()\n const tmp = new this.THREE.Box3()\n for (const mv of pv.meshes) if (this.visuals.shown(mv)) bb.union(this.visuals.worldBox(mv, tmp))\n if (bb.isEmpty()) {\n // nothing of the part is drawn (a roof rafter has no mesh, or the part broke or burnt away): no flame may hang where it was\n if (f.handle !== undefined) this.vfx.stop(f.handle)\n delete f.handle\n return\n }\n const c = bb.getCenter(this.v1)\n f.follow.x = c.x\n f.follow.y = bb.min.y\n f.follow.z = c.z\n if (f.handle !== undefined) return\n const size = bb.getSize(this.v2)\n const radius = clamp(Math.max(size.x, size.z) * 0.5, 0.12, 1.2)\n const smokeColor = SMOKE_TONES[def?.thermal.smoke ?? 'grey']\n f.handle = this.vfx.fire({ point: [f.follow.x, f.follow.y, f.follow.z], radius, life: FIRE_CEILING_SECONDS, follow: f.follow, source: f.object, ...(smokeColor !== undefined ? { smokeColor } : {}) })\n }\n\n private updateLeaks(dt: number): void {\n for (let i = this.leaks.length - 1; i >= 0; i--) {\n const l = this.leaks[i]\n const b = this.bounds.get(l.object)\n const ps = this.world.part(l.object, l.part)\n // a leak ends when the container is empty or the opening is closed (a valve shut, `seal`)\n if (!b || !ps || ps.liters === undefined || ps.liters <= 1e-4 || (l.opened && !ps.holes.some((h) => h.through))) {\n this.leaks.splice(i, 1)\n continue\n }\n l.life = (l.life ?? 0) + dt\n if (l.pressurized && l.life > 0.8) l.pressurized = false\n\n if (l.lastLiters !== undefined && Math.abs(ps.liters - l.lastLiters) < 1e-5) {\n l.idleSeconds = (l.idleSeconds ?? 0) + dt\n if (l.idleSeconds > 0.4) {\n this.leaks.splice(i, 1)\n continue\n }\n } else {\n l.idleSeconds = 0\n l.lastLiters = ps.liters\n }\n\n let pt = l.point\n let dir = l.direction\n if (l.localPoint && l.localDirection) {\n b.root.updateWorldMatrix(true, false)\n const wp = this.v1.set(l.localPoint[0], l.localPoint[1], l.localPoint[2]).applyMatrix4(b.root.matrixWorld)\n const wd = this.v2.set(l.localDirection[0], l.localDirection[1], l.localDirection[2]).transformDirection(b.root.matrixWorld).normalize()\n pt = [wp.x, wp.y, wp.z]\n dir = [wd.x, wd.y, wd.z]\n l.point = pt\n l.direction = dir\n }\n\n l.acc += clamp(20 + l.rate * 400, 15, 120) * dt\n const color = FLUID_COLORS[l.fluid] ?? 0xaaaaaa\n const dl = Math.hypot(dir[0], dir[1], dir[2]) || 1\n const sp = l.pressurized ? 2.5 + this.rng() * 1.5 : 0.3 + this.rng() * 0.3\n while (l.acc >= 1) {\n l.acc -= 1\n const vel: Vec3 = [(dir[0] / dl) * sp + (this.rng() - 0.5) * 0.25, (dir[1] / dl) * sp + (this.rng() - 0.5) * 0.25, (dir[2] / dl) * sp + (this.rng() - 0.5) * 0.25]\n if (l.fluid === 'gas') this.vfx.spawn('steam', pt, vel, { color, size: 0.5, alpha: 0.5, source: l.object })\n else this.vfx.spawn('drips', pt, vel, { color, tag: this.rng() < 0.03 ? this.tagOf(l.object) : 0, owner: this.owner, source: l.object })\n }\n }\n }\n\n private tagOf(object: string): number {\n let tag = this.homeTags.indexOf(object) + 1\n if (tag === 0) tag = this.homeTags.push(object)\n return tag\n }\n\n // ----------------------------------------------------------------------------------------------------------------------------------\n // Emit, clear, restore, stats, dispose\n // ----------------------------------------------------------------------------------------------------------------------------------\n\n emit(kind: DebrisKind | 'fire' | 'flash' | 'foam', point: Vec3, normal: Vec3, count: number, speed?: number): void {\n this.vfx.burst(kind, point, normal, count, speed ?? DEFAULT_SPEED[kind] ?? 1, kind === 'smoke' ? { color: SMOKE_TONES.grey } : undefined)\n }\n\n explode(point: Vec3, energy: number, radius: number, options?: ExplodeOptions): void {\n this.onExplode({ type: 'explode', object: '', part: '', time: this.time, point, energy, radius }, options)\n }\n\n restore(objectId: string): void {\n const homes = new Set<string>([objectId])\n const self = this.bounds.get(objectId)\n if (self?.isSplit) for (const pv of self.parts.values()) homes.add(pv.home)\n for (const home of homes) this.restoreHome(home)\n for (const [key, a] of [...this.active]) if (homes.has(a.object)) this.active.delete(key)\n for (const [key, f] of [...this.fires]) if (homes.has(f.object)) this.stopFire(key)\n for (const [key, started] of [...this.burnSounds]) if (homes.has(started.object)) this.endBurnSound(key)\n for (let i = this.leaks.length - 1; i >= 0; i--) if (homes.has(this.leaks[i].object)) this.leaks.splice(i, 1)\n for (const home of homes) {\n this.fragments.removeHome(home)\n this.ground.removeHome(home)\n this.cages.removeObject(home)\n }\n }\n\n /**\n * Draws a bound object again from the state its world holds now: the host put it back damaged (`DestructionWorld.loadObject`) and the meshes, still whole, take its dents, holes,\n * cracks, bend and char, with the broken, melted and burned parts hidden, as the live path drew them. Marks the meshes already carry are wiped first.\n */\n redraw(objectId: string): void {\n const b = this.bounds.get(objectId)\n if (!b) return\n this.restoreHome(objectId)\n b.root.updateWorldMatrix(true, false)\n for (const pv of b.parts.values()) this.drawPartState(b, pv)\n this.checkLoose(objectId)\n }\n\n private drawPartState(b: Bound, pv: PartVis): void {\n const ps = this.world.part(b.id, pv.id)\n if (!ps) return\n if (ps.status === 'broken' || ps.status === 'melted' || ps.status === 'ashes') {\n this.visuals.hide(pv, ps.status)\n return\n }\n const toWorld = (local: Vec3): Vec3 => {\n const at = new this.THREE.Vector3(local[0], local[1], local[2]).applyMatrix4(b.root.matrixWorld)\n return [at.x, at.y, at.z]\n }\n const shown = pv.meshes.filter((mv) => this.visuals.shown(mv))\n for (const dent of ps.dents) {\n const at = toWorld(dent.point)\n const wp = new this.THREE.Vector3(at[0], at[1], at[2])\n const reach = shown.reduce((widest, mv) => Math.max(widest, this.visuals.dentReach(mv, wp, dent)), dent.radius)\n this.visuals.applyPartDent(shown, wp, this.worldDir(b, dent.normal), dent, reach)\n }\n for (const hole of ps.holes) this.drawHoleMark(pv, toWorld(hole.point), this.worldDir(b, hole.normal), hole.diameter, 0)\n for (const crack of ps.cracks) this.drawCrackMark(b, pv, crack, toWorld(crack.point), 0)\n if (ps.bend !== undefined && ps.bendHinge) {\n const hinge = new this.THREE.Vector3(...toWorld(ps.bendHinge.point))\n const axis = this.worldDir(b, ps.bendHinge.axis)\n const side = this.worldDir(b, ps.bendHinge.side)\n for (const mv of shown) this.visuals.applyBend(mv, hinge, axis, side, ps.bend)\n }\n if (ps.char > 0 || ps.melt > 0) this.activate(b.id, pv.id)\n }\n\n release(objectId: string): string[] {\n const removed = this.releasePieces(objectId)\n this.unbind(objectId)\n return removed\n }\n\n releasePieces(objectId: string): string[] {\n const family = this.familyOf(objectId)\n const pieces = [...family].filter((id) => id !== objectId)\n const ofFamily = (key: string): boolean => [...family].some((id) => key.startsWith(`${id}|`))\n // an event still waiting would bring an effect of theirs back after they left\n for (let i = this.queue.length - 1; i >= 0; i--) if (family.has(this.queue[i]!.object)) this.queue.splice(i, 1)\n this.splitQueue.remove((entry) => family.has(entry.objectId))\n for (const id of family) this.looseToCheck.delete(id)\n for (const [key, a] of [...this.active]) if (family.has(a.object)) this.active.delete(key)\n for (const [key, f] of [...this.fires]) if (family.has(f.object)) this.stopFire(key)\n for (const [key, started] of [...this.burnSounds]) if (family.has(started.object)) this.endBurnSound(key)\n for (const key of [...this.primedBurning]) if (ofFamily(key)) this.primedBurning.delete(key)\n for (let i = this.leaks.length - 1; i >= 0; i--) if (family.has(this.leaks[i]!.object)) this.leaks.splice(i, 1)\n for (let i = this.trickles.length - 1; i >= 0; i--) if (family.has(this.trickles[i]!.source ?? '')) this.trickles.splice(i, 1)\n for (const id of family) {\n this.fragments.removeHome(id)\n this.ground.removeHome(id)\n this.cages.removeObject(id)\n this.vfx.clearSource(id)\n }\n // the parts of the pieces go back to the object's binding (their meshes to where they were drawn, the ones made for them disposed)\n this.restore(objectId)\n for (const id of pieces) {\n this.pieceSys.remove(id)\n this.forgetBound(id)\n this.hitPoints.forget(id)\n this.broken.delete(id)\n this.staticDirty.add(id)\n if (this.world.has(id)) this.world.remove(id)\n }\n if (pieces.length > 0) this.o.onReleased?.(pieces)\n // groups of the object still loose in its world go back to the queue in the next work step (`unbind` drops it when the object leaves too)\n if (this.bounds.has(objectId)) this.checkLoose(objectId)\n return pieces\n }\n\n /** The object and every piece split from it (a piece holds parts whose home is the object, also a piece of a piece). */\n private familyOf(objectId: string): Set<string> {\n const family = new Set([objectId])\n for (const b of this.bounds.values()) {\n if (!b.isSplit) continue\n for (const pv of b.parts.values()) {\n if (pv.home !== objectId) continue\n family.add(b.id)\n break\n }\n }\n return family\n }\n\n private restoreHome(home: string): void {\n const homeBound = this.bounds.get(home)\n for (const b of [...this.bounds.values()]) {\n for (const [pid, pv] of [...b.parts]) {\n if (pv.home !== home) continue\n this.settlement.forget(pv)\n this.visuals.restorePart(pv)\n this.tagPart(pv, home)\n if (b !== homeBound && homeBound) {\n b.parts.delete(pid)\n homeBound.parts.set(pid, pv)\n }\n }\n if (b.isSplit && b.parts.size === 0) {\n this.scene.remove(b.root)\n this.pieceSys.remove(b.id)\n this.forgetBound(b.id)\n // its box leaves now: the periodic round only walks the objects still bound\n this.staticDirty.add(b.id)\n }\n }\n }\n\n clear(): void {\n // the meshes go back to their own draw before they are restored or removed\n this.settledBatches.clear()\n // what was bound is gone: the next read measures what is left, all of it\n this.staticAll = true\n this.queue.length = 0\n // a spread blast's events held or still to apply go with the world they were for\n this.heldStructural = undefined\n this.areEventsHeld = false\n this.slices.length = 0\n this.splitQueue.clear()\n this.looseToCheck.clear()\n this.prefitting.length = 0\n this.active.clear()\n for (const key of [...this.fires.keys()]) this.stopFire(key)\n for (const key of [...this.burnSounds.keys()]) this.endBurnSound(key)\n this.leaks.length = 0\n this.trickles.length = 0\n this.settlement.clear()\n for (const id of [...this.bounds.keys()]) if (this.bounds.has(id)) this.restore(id)\n // anything left of a split object whose home is gone\n for (const b of [...this.bounds.values()]) {\n if (b.isSplit) {\n for (const pv of b.parts.values()) this.visuals.restorePart(pv)\n this.scene.remove(b.root)\n this.pieceSys.remove(b.id)\n this.forgetBound(b.id)\n }\n }\n this.fragments.clear()\n this.ground.clear()\n this.cages.clear()\n this.primedBurning.clear()\n this.vfx.sprites().clear()\n this.ownVfx?.world.clear()\n }\n\n reset(): void {\n this.clear()\n this.rng = createRng(RNG_SEED)\n this.time = 0\n this.staticAt = 0\n this.staticRound = []\n this.staticAll = true\n this.throttles.clear()\n this.fragments.reset()\n this.pieceSys.reset()\n this.blastWakes?.clear()\n this.costMeter.reset()\n this.cost = null\n this.costFrame = 0\n }\n\n wakeRegion(x: number, z: number, radius: number): void {\n this.fragments.wakeRegion(x, z, radius)\n this.pieceSys.wakeRegion(x, z, radius)\n }\n\n stats(): { fragments: number; particles: number; pieces: number; decals: number } {\n return { fragments: this.fragments.count, particles: this.vfx.sprites().live + this.ownedVfxParticles(), pieces: this.pieceSys.list.length, decals: this.visuals.decalCount + this.ground.count }\n }\n\n private ownedVfxParticles(): number {\n if (!this.ownVfx) return 0\n const { puffs, sparks, glows, chunks } = this.vfx.stats()\n return puffs + sparks + glows + chunks\n }\n\n // The last warm-up keeps its materials until the next one: a material that does not use lights keeps the program of the lights it was first drawn with, so each warm-up needs materials of its own.\n private warmProbes: { readonly group: THREE_NS.Group; readonly geometry: THREE_NS.BufferGeometry; readonly materials: THREE_NS.Material[] } | undefined\n\n warmUpProbes(): WarmUpProbes {\n this.releaseWarmProbes()\n const { kit } = this.visuals\n const T = this.THREE\n const geometry = new T.BufferGeometry()\n geometry.setAttribute('position', new T.BufferAttribute(new Float32Array(6), 3))\n const materials = [kit.discMaterial().clone(), kit.patchMaterial(0x808080).clone(), kit.lineMaterial(0x000000).clone()]\n const group = new T.Group()\n group.add(new T.Mesh(kit.discGeometry(), materials[0]), new T.Mesh(kit.discGeometry(), materials[1]), new T.LineSegments(geometry, materials[2] as THREE_NS.LineBasicMaterial))\n group.add(...this.fragments.warmMeshes())\n for (const probe of group.children) probe.frustumCulled = false\n this.warmProbes = { group, geometry, materials }\n return { group, dispose: () => {} }\n }\n\n private releaseWarmProbes(): void {\n if (!this.warmProbes) return\n this.warmProbes.geometry.dispose()\n for (const material of this.warmProbes.materials) material.dispose()\n this.warmProbes = undefined\n }\n\n rebarCount(): number {\n return this.cages.count\n }\n\n dispose(): void {\n this.releaseWarmProbes()\n if (this.disposed) return\n this.unsubscribe()\n this.clear()\n for (const id of [...this.bounds.keys()]) this.unbind(id)\n this.fragments.dispose()\n this.ground.dispose()\n this.cages.dispose()\n this.stopLanding()\n this.pieceSys.dispose()\n this.visuals.dispose()\n this.ownVfx?.dispose()\n this.disposed = true\n }\n}\n\n/** `color` (0xRRGGBB) a share `t` of the way to white. */\nfunction lighten(color: number, t: number): number {\n const ch = (shift: number) => {\n const c = (color >> shift) & 0xff\n return Math.round(c + (255 - c) * t) << shift\n }\n return ch(16) | ch(8) | ch(0)\n}\n\n/** The convex hull (counter-clockwise) of points on the ground, (x, z). */\nfunction convexHull(points: Array<[number, number]>): Array<[number, number]> {\n const sorted = [...points].sort((a, b) => a[0] - b[0] || a[1] - b[1])\n if (sorted.length < 3) return sorted\n const cross = (o: [number, number], a: [number, number], b: [number, number]): number => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])\n const half = (list: Array<[number, number]>): Array<[number, number]> => {\n const out: Array<[number, number]> = []\n for (const p of list) {\n while (out.length >= 2 && cross(out[out.length - 2]!, out[out.length - 1]!, p) <= 0) out.pop()\n out.push(p)\n }\n out.pop()\n return out\n }\n return [...half(sorted), ...half([...sorted].reverse())]\n}\n\n/** The centre of a set of boxes weighted by their volumes (x, y, z). */\nfunction centreOfBoxes(boxes: ReadonlyArray<THREE_NS.Box3>): [number, number, number] {\n const sum: [number, number, number] = [0, 0, 0]\n let total = 0\n for (const one of boxes) {\n const volume = Math.max(1e-9, (one.max.x - one.min.x) * (one.max.y - one.min.y) * (one.max.z - one.min.z))\n sum[0] += ((one.min.x + one.max.x) / 2) * volume\n sum[1] += ((one.min.y + one.max.y) / 2) * volume\n sum[2] += ((one.min.z + one.max.z) / 2) * volume\n total += volume\n }\n return [sum[0] / total, sum[1] / total, sum[2] / total]\n}\n\n/** How far (m) a point is inside a convex polygon (counter-clockwise; negative outside), and the outward normal of the edge it is nearest. */\nfunction insideBy(hull: ReadonlyArray<[number, number]>, point: [number, number]): { depth: number; out: { x: number; z: number } } {\n let depth = Infinity\n let out = { x: 1, z: 0 }\n for (let i = 0; i < hull.length; i++) {\n const a = hull[i]!\n const b = hull[(i + 1) % hull.length]!\n const ex = b[0] - a[0]\n const ez = b[1] - a[1]\n const length = Math.hypot(ex, ez)\n if (length < 1e-9) continue\n // counter-clockwise in (x, z): the outward normal of an edge is (ez, -ex)\n const nx = ez / length\n const nz = -ex / length\n const d = -((point[0] - a[0]) * nx + (point[1] - a[1]) * nz)\n if (d < depth) {\n depth = d\n out = { x: nx, z: nz }\n }\n }\n return { depth: hull.length < 3 ? -Infinity : depth, out }\n}\n","import type { WakeQueueState, WorkBudgetOptions } from '@adatechnology/game-physics'\nimport { DEFAULT_CHIP_SIZE, DEFAULT_MAX_PHYSICS_PIECES, DEFAULT_MIN_PHYSICS_PIECES, DEFAULT_PHYSICS_COST_TARGET_MS, DEFAULT_MAX_QUEUED_WAKES, DEFAULT_PHYSICS_COST_PER_BODY_MS, DEFAULT_WAKE_COST_PER_BODY_MS, DEFAULT_MAX_WAKE_DELAY, DEFAULT_MIN_WAKES_PER_FRAME, DEFAULT_WAKE_COST_TARGET_MS, WakeQueue } from '@adatechnology/game-physics'\nexport type { PhysicsCostMeterState } from '@adatechnology/game-physics'\nexport { PhysicsCostMeter, chooseForPhysics, physicsPieceCount } from '@adatechnology/game-physics'\n\n/** What happens to debris that is far from the player and old (`FarDebrisOptions.action`): it sleeps where it lies, or shrinks away and leaves the scene. Debris at rest is already drawn merged by `settledBatches`. */\nexport type FarDebrisAction = 'sleep' | 'fade'\n\nexport interface FarDebrisOptions {\n /** Metres from `focus` past which debris is far. Default `BLAST_DEBRIS_DEFAULTS.far.distance`. */\n distance?: number\n /** Seconds a piece must have lived to be old. Default `BLAST_DEBRIS_DEFAULTS.far.age`. */\n age?: number\n /** What far and old debris at rest does. Default `'sleep'`. */\n action?: FarDebrisAction\n /** Seconds a faded piece takes to shrink away once its body is gone. Default `BLAST_DEBRIS_DEFAULTS.far.fadeSeconds`. */\n fadeSeconds?: number\n}\n\n/**\n * Everything the kit decides about the debris of a blast, each a number the host sets: per renderer (`RendererOptions.blastDebris`) or per explosion (`ExplodeOptions.debris`).\n * None is a constant of the code; `BLAST_DEBRIS_DEFAULTS` is what was measured (spec 008, evidence T3.6d).\n */\nexport interface BlastDebrisOptions {\n /**\n * Milliseconds the physics step may reach as the debris of blasts wakes: each frame wakes as many (nearest the player first, else the blast's centre) as the step cost measured\n * on the frames before leaves room for under this. A frame of a woken pile costs more than the same pile asleep; nothing is timed per body.\n */\n wakeCostTargetMs?: number\n /** Seconds a piece waits to wake at most, whatever the cost: the debris of a blast is all awake within tens of ms. */\n maxWakeDelay?: number\n /** Pieces waiting to wake at most; the farthest over it wake at once. */\n maxQueuedWakes?: number\n /** Pieces woken every frame at least, so a queue behind a heavy frame still drains. */\n minWakesPerFrame?: number\n /** Fewest pieces of one blast that enter physics, whatever the cost (the count adapts between this and `maxPhysicsPieces`). */\n minPhysicsPieces?: number\n /** Most pieces of one blast that enter physics. */\n maxPhysicsPieces?: number\n /** Milliseconds of physics step the debris of one blast may add in the frame it wakes: the count is this over the wake cost measured per body. */\n physicsCostTargetMs?: number\n /** Milliseconds one awake body costs a step, used until the world has been measured (`PhysicsFrame.stepMs`). */\n physicsCostPerBodyMs?: number\n /** The same in the frame a pile wakes in (a woken island costs several times what it costs settled): what sizes the wake batches until measured. */\n wakeCostPerBodyMs?: number\n /** Longest side (m) under which a loosened object is a chip: it goes after every big one when the blast's count is full. */\n chipSize?: number\n /** Most loose pieces alive at once, asleep or not: over it the far and old ones go first (`far`). */\n maxLivePieces?: number\n /** Which pieces are far and old, and what happens to them. They also go when the pieces alive pass `maxLivePieces`. */\n far?: FarDebrisOptions\n}\n\nexport interface ResolvedBlastDebris {\n readonly wakeCostTargetMs: number\n readonly maxWakeDelay: number\n readonly maxQueuedWakes: number\n readonly minWakesPerFrame: number\n readonly minPhysicsPieces: number\n readonly maxPhysicsPieces: number\n readonly physicsCostTargetMs: number\n readonly physicsCostPerBodyMs: number\n readonly wakeCostPerBodyMs: number\n readonly chipSize: number\n readonly maxLivePieces: number\n readonly far: Required<FarDebrisOptions>\n}\n\n/** Measured on \"Intel Core Ultra 9 275HX, 24 cores, Node 20\" (evidence T3.6d); an AMD or weaker range gets its own row after it is measured. */\nexport const BLAST_DEBRIS_DEFAULTS: ResolvedBlastDebris = {\n wakeCostTargetMs: DEFAULT_WAKE_COST_TARGET_MS,\n maxWakeDelay: DEFAULT_MAX_WAKE_DELAY,\n maxQueuedWakes: DEFAULT_MAX_QUEUED_WAKES,\n minWakesPerFrame: DEFAULT_MIN_WAKES_PER_FRAME,\n minPhysicsPieces: DEFAULT_MIN_PHYSICS_PIECES,\n maxPhysicsPieces: DEFAULT_MAX_PHYSICS_PIECES,\n physicsCostTargetMs: DEFAULT_PHYSICS_COST_TARGET_MS,\n physicsCostPerBodyMs: DEFAULT_PHYSICS_COST_PER_BODY_MS,\n wakeCostPerBodyMs: DEFAULT_WAKE_COST_PER_BODY_MS,\n chipSize: DEFAULT_CHIP_SIZE,\n maxLivePieces: 600,\n far: { distance: 40, age: 30, action: 'sleep', fadeSeconds: 0.5 },\n}\n\n/** The defaults with `options` over them: a number left out is the default. */\nexport const resolveBlastDebris = (...layers: ReadonlyArray<BlastDebrisOptions | undefined>): ResolvedBlastDebris => {\n let out: ResolvedBlastDebris = BLAST_DEBRIS_DEFAULTS\n for (const layer of layers) {\n if (!layer) continue\n const { far, ...rest } = layer\n const defined = Object.fromEntries(Object.entries(rest).filter(([, value]) => value !== undefined))\n out = { ...out, ...defined, far: { ...out.far, ...Object.fromEntries(Object.entries(far ?? {}).filter(([, value]) => value !== undefined)) } }\n }\n return out\n}\n\n/** What one frame's step cost: `PhysicsFrame.stepMs` and the bodies the world had awake. */\nexport interface DebrisCostSample {\n readonly stepMs: number\n readonly active: number\n}\n\n/**\n * Where the cost the debris policy adapts to comes from (`RendererOptions.debrisCost`). `measured` (the default, as the owner decided in D4) reads the loop's wall-clock step\n * time, so the batch sizes and piece counts depend on the machine's speed; `record` collects each frame's sample. `fixed` never reads the clock: batches and counts come only\n * from the configured numbers (`wakeCostTargetMs`, `physicsCostPerBodyMs`, `wakeCostPerBodyMs`...), the same on every machine (tests, lockstep). `replay` feeds a recorded list,\n * frame by frame, in place of the clock, so a session recorded on one machine plays the same decisions on another.\n */\nexport type DebrisCostOptions =\n | { readonly source: 'measured'; readonly record?: DebrisCostSample[] }\n | { readonly source: 'fixed' }\n | { readonly source: 'replay'; readonly samples: readonly DebrisCostSample[] }\n\n/** One push of a blast waiting its turn, as data (never a closure), so a save in the middle of a blast keeps it: the piece, the impulse and where it lands. */\nexport interface BlastWake {\n readonly objectId: string\n /** The body's `generation` when it was pushed: a piece removed and made again under the same id takes nothing. */\n readonly generation: number\n readonly impulse: readonly [number, number, number]\n readonly point: readonly [number, number, number]\n}\n\n/** The debris waiting to wake: one queue for every blast in flight, nearest the player first. */\nexport class BlastWakes {\n private readonly queue: WakeQueue<BlastWake>\n\n constructor(options: ResolvedBlastDebris) {\n this.queue = new WakeQueue({ costTargetMs: options.wakeCostTargetMs, maxDelay: options.maxWakeDelay, maxQueued: options.maxQueuedWakes, minPerFrame: options.minWakesPerFrame })\n }\n\n get pending(): number {\n return this.queue.size\n }\n\n push(priority: number, wake: BlastWake, maxDelay: number): void {\n this.queue.push(priority, wake, maxDelay)\n }\n\n /** One frame: hands `apply` what the cost leaves room for (at most `limit`, what a shared work budget leaves) and returns how many woke. */\n advance(options: { readonly dt: number; readonly lastStepMs: number; readonly costPerBodyMs: number; readonly limit?: number; readonly apply: (wake: BlastWake) => void }): number {\n const woken = this.queue.release(options.dt, options.lastStepMs, options.costPerBodyMs, options.limit ?? Infinity)\n for (const wake of woken) options.apply(wake)\n return woken.length\n }\n\n clear(): void {\n this.queue.clear()\n }\n\n /** The waiting pushes with their priority and delay: plain data. */\n saveState(): WakeQueueState<BlastWake> {\n return this.queue.saveState()\n }\n\n restoreState(state: WakeQueueState<BlastWake>): void {\n this.queue.restoreState(state)\n }\n}\n\n/**\n * Work units (`WorkBudget`, 1 unit = 10 µs on the reference machine) each kind of the explosion's deferred work is charged. Every one is an estimate from the size of the work,\n * never from what a cache holds: a split is charged as if none of its boxes were fitted ahead (spec 008, `design/orcamento-da-explosao.md` §7 D2), so the schedule does not\n * depend on how far a fit ahead got.\n */\nexport interface WorkUnitCosts {\n /** Units of one split whatever its size (making the new object, its piece and its bookkeeping). */\n readonly perSplit?: number\n /** Units per vertex of the loose group's meshes (its box fits and measure). */\n readonly perVertex?: number\n /** Units per vertex of a merged mesh the group is cut out of (the host mesh is rebuilt, normals and all). */\n readonly perHostVertex?: number\n /** Units per part of the object it is cut from (the world rebuilds both halves). */\n readonly perObjectPart?: number\n /** Units per fragment spawned. */\n readonly perFragment?: number\n /** Units charged per event applied (its effects show in the frame it happens, so it never waits; it only leaves less for the rest). */\n readonly perEvent?: number\n /** Units per body woken from the blast's wake queue. */\n readonly perWake?: number\n}\n\n/** The frame budget of the explosion's work (`RendererOptions.workBudget`): the budget, the machine's tier, the frames a loose group may wait, and the unit costs. */\nexport interface ExplosionWorkOptions extends WorkBudgetOptions {\n readonly costs?: WorkUnitCosts\n}\n\n/** First calibration on the main of 2026-11-15 (evidence T3.8aa); to be measured again on top of the box fits ahead, the batched bodies and the ground budget. */\nexport const WORK_UNIT_DEFAULTS: Required<WorkUnitCosts> = {\n perSplit: 120,\n perVertex: 0.05,\n perHostVertex: 0.01,\n perObjectPart: 0.3,\n perFragment: 4,\n perEvent: 40,\n perWake: 2,\n}\n\nexport const resolveWorkUnitCosts = (costs: WorkUnitCosts | undefined): Required<WorkUnitCosts> => ({\n ...WORK_UNIT_DEFAULTS,\n ...Object.fromEntries(Object.entries(costs ?? {}).filter(([, value]) => value !== undefined)),\n})\n\n/** What a split is estimated to cost, in units, from the sizes of its work. */\nexport const splitWorkUnits = (costs: Required<WorkUnitCosts>, size: { readonly vertices: number; readonly hostVertices: number; readonly objectParts: number }): number =>\n costs.perSplit + costs.perVertex * size.vertices + costs.perHostVertex * size.hostVertices + costs.perObjectPart * size.objectParts\n","import type { DestructionEvent, DestructionEventType } from '@adatechnology/game-destruction'\n\nexport type EventClass = 'structural' | 'visual'\n\n/**\n * What applying each event of the world does in the renderer. Structural: makes a body, changes the world, touches a collision mesh, enters the registry or draws on the\n * renderer's generator (`spall`, `drip` and `leak` do, until they get a generator of their own), so it applies inside the fixed step, on the step pose. Visual: only marks,\n * sounds and particles, so it may wait for the frame. A type that is in doubt is structural; a new type does not compile until it is listed here.\n */\nexport const EVENT_CLASS = {\n detach: 'structural',\n collapse: 'structural',\n fracture: 'structural',\n expose: 'structural',\n settle: 'structural',\n subside: 'structural',\n burnout: 'structural',\n destroyed: 'structural',\n explode: 'structural',\n chip: 'structural',\n stage: 'structural',\n dent: 'structural',\n bend: 'structural',\n spall: 'structural',\n drip: 'structural',\n leak: 'structural',\n ignite: 'structural',\n primed: 'structural',\n extinguish: 'structural',\n hole: 'visual',\n crack: 'visual',\n ricochet: 'visual',\n debris: 'visual',\n damage: 'visual',\n melt: 'visual',\n disassemble_progress: 'visual',\n reveal: 'visual',\n stress: 'visual',\n sway: 'visual',\n blast: 'visual',\n body: 'visual',\n fragment_hit: 'visual',\n} as const satisfies Readonly<Record<DestructionEventType, EventClass>>\n\nexport function isStructuralEvent(event: DestructionEvent): boolean {\n return EVENT_CLASS[event.type] === 'structural'\n}\n\n/**\n * Orders the events of a batch for applying: a visual event of an object that has a structural event in the batch applies before the first of them (after it the part\n * may belong to another object and its mark is lost). Everything else keeps the order of emission. Returns `batch` itself when nothing moves; reuses its own scratch.\n */\nexport class EventOrder {\n private readonly firstStructural = new Map<string, number>()\n private readonly ordered: DestructionEvent[] = []\n\n arrange(batch: DestructionEvent[]): DestructionEvent[] {\n this.firstStructural.clear()\n let isMovable = false\n for (let i = 0; i < batch.length; i++) {\n const event = batch[i]!\n if (isStructuralEvent(event)) {\n if (!this.firstStructural.has(event.object)) this.firstStructural.set(event.object, i)\n } else if (this.firstStructural.has(event.object)) isMovable = true\n }\n if (!isMovable) return batch\n this.ordered.length = 0\n for (let i = 0; i < batch.length; i++) {\n const event = batch[i]!\n const first = this.firstStructural.get(event.object)\n if (first === undefined) this.ordered.push(event)\n else if (!isStructuralEvent(event)) {\n if (i < first) this.ordered.push(event)\n } else {\n if (i === first) for (let j = i + 1; j < batch.length; j++) if (batch[j]!.object === event.object && !isStructuralEvent(batch[j]!)) this.ordered.push(batch[j]!)\n this.ordered.push(event)\n }\n }\n const result = this.ordered.slice()\n this.ordered.length = 0\n return result\n }\n}\n","import type { DestructionEvent, DestructionEventType } from '@adatechnology/game-destruction'\n\n/**\n * What applying one event of each type costs the renderer, in fixed units (a bullet hole is 10), for spreading the structural events of a large blast over frames\n * (`applyStructuralEventsSliced`). A table, never a clock: the same events give the same slices on any machine, so the world the slices build is the same.\n * Derived from the cost per event measured applying the M67's 1687 events in the room house (spec 018, 2026-11-22, `m2`: a fracture ~1.7 ms, a hole ~0.05 ms, a\n * stage ~0.1 ms, a chip ~0.04 ms, a spall ~0.01 ms, a debris ~0.005 ms); types not measured there take the weight of the nearest measured kind of work. Every\n * event costs at least 1, so a slice always moves. A new type does not compile until it is listed.\n */\nexport const EVENT_APPLY_WEIGHT = {\n fracture: 340,\n collapse: 340,\n destroyed: 120,\n expose: 60,\n subside: 30,\n settle: 30,\n detach: 10,\n stage: 20,\n dent: 20,\n bend: 20,\n burnout: 20,\n explode: 20,\n hole: 10,\n chip: 8,\n ignite: 4,\n primed: 2,\n extinguish: 2,\n spall: 2,\n leak: 2,\n drip: 1,\n crack: 1,\n debris: 1,\n ricochet: 1,\n damage: 1,\n melt: 1,\n disassemble_progress: 1,\n reveal: 1,\n stress: 1,\n sway: 1,\n blast: 1,\n body: 1,\n fragment_hit: 1,\n} as const satisfies Readonly<Record<DestructionEventType, number>>\n\n/** Units of `EVENT_APPLY_WEIGHT` a frame of a spread blast applies by default: ~5 ms of the measured costs, about a quarter of the M67's structural events. */\nexport const STRUCTURAL_UNITS_PER_FRAME = 1000\n\nexport function eventApplyWeight(event: DestructionEvent): number {\n return EVENT_APPLY_WEIGHT[event.type]\n}\n","import type * as THREE_NS from 'three'\nimport { markKitOrigin } from '@adatechnology/game-contracts'\nimport type { Fragment, SplitForm } from '@adatechnology/game-destruction'\n\nimport { pushFittedBoxes } from './fitted-boxes'\nimport { FragmentInstances } from './fragment-instances'\nimport type { FragmentInstanceStats } from './fragment-instances'\nimport { FRAGMENT_SHAPE_VARIANTS, buildBrokenBoardGeometry, buildLumpGeometry, buildRubbleGeometry, buildSliverGeometry, buildVeneerGeometry } from './fragment-shapes'\nimport { clamp, createRng, hashString } from './math'\nimport { PoseTrail } from './pose-trail'\nimport type { LooseBody } from './types'\n\n/** @internal */\nexport interface Live {\n mesh: THREE_NS.Mesh\n /** The surface under the fragment (ground or what is built), and where it was measured: measured again once the fragment moves off that spot. */\n floor: { x: number; z: number; y: number } | null\n home: string\n vel: THREE_NS.Vector3\n ang: THREE_NS.Vector3\n half: THREE_NS.Vector3\n baseScale: THREE_NS.Vector3\n still: number\n asleep: boolean\n /** It touched what is under it in its last step. */\n contact: boolean\n /** Seconds at rest. */\n rest: number\n /** 1 while alive; counts down to 0 while shrinking away. */\n fade: number\n dying: boolean\n /** Air drag per second: a loose sheet (a page) glides and flutters down instead of dropping. */\n air: number\n /** A big one (`isBig`): it stays where it lies, and what walks steps on it or kicks it. */\n body: LooseBody | null\n /** The `update` count when it was made. */\n born: number\n /** Seconds it stays at rest before it fades (0 = forever). */\n life: number\n /** Its box in the world while it rests, for what lands on it (`pileUnder`); dropped when it wakes. */\n box?: RestingBox | undefined\n /** Creation order: the order the fragments are stepped in, kept by the awake list. */\n seq: number\n /** The `clock` after which a fragment asleep fades away (Infinity: not asleep, or it never fades). */\n deadline: number\n /** In the awake list (`FragmentSystem.active`). */\n isActive: boolean\n /** In the list of the mortal sleepers (`FragmentSystem.mortal`; entries that woke are dropped at the next scan). */\n isMortal: boolean\n}\n\n/** The floor area a box covers, seen from above: a shape built from the floor images of its three half edges (x, z of each, in turn), centred on the box. */\ntype Shadow = readonly [number, number, number, number, number, number]\n\n/** @internal */\nexport interface RestingBox {\n readonly shadow: Shadow\n readonly x: number\n readonly z: number\n readonly reachX: number\n readonly reachZ: number\n readonly top: number\n}\n\n/** The rotation of a unit quaternion as a column-major 4×4 array, like `Matrix4.elements`. */\nfunction rotationOf(q: THREE_NS.Quaternion): readonly number[] {\n const { x, y, z, w } = q\n return [\n 1 - 2 * (y * y + z * z), 2 * (x * y + z * w), 2 * (x * z - y * w), 0,\n 2 * (x * y - z * w), 1 - 2 * (x * x + z * z), 2 * (y * z + x * w), 0,\n 2 * (x * z + y * w), 2 * (y * z - x * w), 1 - 2 * (x * x + y * y), 0,\n ]\n}\n\n/** The world box of a resting fragment: its centre, how far it reaches along x and z, and its top. */\n/** The floor images of the half edges of a box turned by the column-major rotation `e`. */\nfunction shadowOf(e: ArrayLike<number>, half: { readonly x: number; readonly y: number; readonly z: number }): Shadow {\n return [e[0]! * half.x, e[2]! * half.x, e[4]! * half.y, e[6]! * half.y, e[8]! * half.z, e[10]! * half.z]\n}\n\n/** How far a shadow reaches along (nx, nz): the sum of its three half edges' projections. */\nconst reachAlong = (shadow: Shadow, nx: number, nz: number): number => Math.abs(nx * shadow[0] + nz * shadow[1]) + Math.abs(nx * shadow[2] + nz * shadow[3]) + Math.abs(nx * shadow[4] + nz * shadow[5])\n\n/** Whether two shadows, `dx` and `dz` apart, share floor area: the separating axis test on the normals of the six half edges (exact for shapes made of segments). */\nfunction shadowsOverlap(first: Shadow, second: Shadow, dx: number, dz: number): boolean {\n for (const shadow of [first, second]) {\n for (let g = 0; g < 6; g += 2) {\n const nx = -shadow[g + 1]!\n const nz = shadow[g]!\n if (nx * nx + nz * nz < 1e-12) continue\n if (Math.abs(dx * nx + dz * nz) > reachAlong(first, nx, nz) + reachAlong(second, nx, nz)) return false\n }\n }\n return true\n}\n\n/** The world box of a resting fragment: its centre, how far it reaches along x and z, its top, and the floor area it really covers. Exported for tests. */\nexport function restingBox(f: Live): RestingBox {\n const e = rotationOf(f.mesh.quaternion)\n const { x, y, z } = f.half\n const p = f.mesh.position\n return {\n shadow: shadowOf(e, f.half),\n x: p.x,\n z: p.z,\n reachX: Math.abs(e[0]) * x + Math.abs(e[4]) * y + Math.abs(e[8]) * z,\n reachZ: Math.abs(e[2]) * x + Math.abs(e[6]) * y + Math.abs(e[10]) * z,\n top: p.y + Math.abs(e[1]) * x + Math.abs(e[5]) * y + Math.abs(e[9]) * z,\n }\n}\n\n/** What a fragment's resting time can depend on: the fragment (its material, size, shape) and the id of the object it came from. */\nexport type FragmentLifeRule = (fragment: Fragment, objectId: string) => number\n\nexport interface FragmentSystemOptions {\n /** Keep the pose of the step before the last, to draw between it and the step's (`presentPose`). Default off: the meshes are always the step's. */\n interpolate?: boolean\n scene: THREE_NS.Scene\n groundAt: (x: number, z: number) => number\n gravity: number\n max: number\n /** Seconds a resting fragment stays before it fades (0 = forever), or a rule that gives it per fragment. */\n life: number | FragmentLifeRule\n /** How a material comes apart (`MaterialDef.splitForm`): MDF lumps and plywood veneer get shapes of their own. Default: none. */\n formOf?: (materialId: string) => SplitForm | undefined\n /**\n * The top of whatever is under (x, z) below height y: the ground, or a slab, a wall, a piece of furniture a piece of rubble lands on. Default: the\n * ground (`groundAt`). Never below `groundAt(x, z)`: a resting fragment lying on the ground under no pile casts no ray at all, since nothing under it could be lost.\n */\n surfaceAt?: (x: number, y: number, z: number) => number\n /**\n * The first face of a standing part of the world on the way from `from` along the unit `direction`, within `distance`: what a flying fragment meets (a wall, a ceiling, a\n * piece of furniture) before it gets through it. Without it a fragment flies through walls and lands on whatever lies under it inside them (the head of a door in the wall,\n * the top of a slab), left showing out of the plaster. Default: none (only what is under it stops it).\n */\n sweep?: (from: readonly [number, number, number], direction: readonly [number, number, number], distance: number) => { point: readonly number[]; normal: readonly number[] } | null\n /** Whether a material crumbles (`MaterialDef.fracture` 'crumble': brick, block, concrete, plaster): its chunks are drawn broken, not as cut boxes. */\n crumbles?: (materialId: string) => boolean\n /**\n * Most fragments moving at once. Over it, the oldest that lie on what is under them and are as slow as one that settles (`isSlow`) are put to sleep where they lie at once,\n * instead of after `SETTLE_SECONDS`. Default: no limit.\n */\n maxAwake?: number\n}\n\nconst BUILDERS: Record<Exclude<SharedShape, 'shard'>, (THREE: typeof THREE_NS, seed: number) => THREE_NS.BufferGeometry> = {\n sliver: buildSliverGeometry,\n lump: buildLumpGeometry,\n veneer: buildVeneerGeometry,\n board: buildBrokenBoardGeometry,\n rubble: buildRubbleGeometry,\n}\n\n/** The shared shapes a fragment can take besides the box: glass shards, wood splinters, MDF lumps, plywood veneer and the torn stub of a broken board. */\ntype SharedShape = 'shard' | 'sliver' | 'lump' | 'veneer' | 'board' | 'rubble'\n\n/** How far (m) a fragment moves before what is under it is measured again. */\nconst FLOOR_REMEASURE = 0.5\n/** Thickest scrap that flies as a sheet (m), its air drag (1/s) and how hard it sways (m/s²). */\nconst SHEET_MAX = 0.004\nconst SHEET_AIR = 2.5\nconst SHEET_SWAY = 3\n/** A fragment at least this long (m) and this wide is a piece of the thing (half a board), not a splinter; a shard of glass never is. */\nconst BIG_LENGTH = 0.2\n/** Dynamic friction of debris sliding on a floor (wood, brick, concrete or glass on concrete, tile or soil: 0.4 to 0.6). */\nconst DEBRIS_FRICTION = 0.5\nconst BIG_WIDTH = 0.03\n/** The seed of the fragments' random stream (their spin and sway); `reset` takes it back here. */\nconst FRAGMENT_SEED = 0x51ed270b\n\n/** Fragments asleep whose ground is looked at again each update, in turn, and how far (m) over it one may lie before it falls: the table it lay on broke. */\nconst SUPPORT_CHECKS = 32\nconst SUPPORT_GAP = 0.02\n/** How far (m) above a falling fragment's bottom a resting top may be and still be what it lands on: a step it slides up onto rather than sinks into. */\nconst PILE_STEP = 0.01\n/** Speed (m/s) across and turn (rad/s) a piece lying with its centre off what holds it gets each step it stays so: it slides and tips off the edge. */\nconst TIP_SPEED = 0.6\nconst TIP_TURN = 3\n/** No room taken: a point, for whether a centre is over a shadow. */\nconst POINT: Shadow = [0, 0, 0, 0, 0, 0]\n\n/** How many shard shapes there are; a fragment takes one by the hash of its id. */\nconst SHARD_SHAPES = 6\n\n/**\n * Slowest fragment (m/s) whose way is swept for walls: a slower one moves a few centimetres a step and only what is under it matters (one lying on a floor falls g dt, a third\n * of a metre a second at 30 updates a second, into the floor every step, and the floor is the ground contact's).\n */\nconst SWEEP_MIN_SPEED = 1\n/** Share of the speed into a face it keeps bouncing back (brick or glass off plaster: little), and of the speed along it. */\nconst WALL_RESTITUTION = 0.25\nconst WALL_GLIDE = 0.7\n\n/** A fragment stays on a face other than its flattest only when that face is at least this fraction of its height across (it would tip past atan(0.6), 31°). */\nconst STAND_RATIO = 0.6\n/** Seconds a fragment stays slow on what is under it before it sleeps. */\nconst SETTLE_SECONDS = 0.4\n\n/** As slow as a fragment that settles: under about 0.11 m/s and 0.45 rad/s. */\nconst isSlow = (f: Live): boolean => f.vel.lengthSq() < 0.012 && f.ang.lengthSq() < 0.2\n\nconst isBig = (size: readonly number[]): boolean => {\n const [, middle, longest] = [...size].sort((a, b) => a - b)\n return longest >= BIG_LENGTH && middle >= BIG_WIDTH\n}\n\n/** Light physics for fracture debris: gravity, ground bounce and friction, spin damping, settling flat, sleep, shrink-away and removal. */\nexport class FragmentSystem {\n private readonly list: Live[] = []\n /** What `update` steps, in creation order: the fragments awake or fading. A fragment asleep costs nothing per frame. */\n private readonly active: Live[] = []\n /** The fragments asleep that fade away after their `life`; looked at only once the clock passes `nextDeadline`. */\n private mortal: Live[] = []\n private clock = 0\n private nextDeadline = Infinity\n private nextSeq = 0\n private readonly box: THREE_NS.BoxGeometry\n /** The mesh box of a fragment before its scale. */\n private readonly unitBox = { min: { x: -0.5, y: -0.5, z: -0.5 }, max: { x: 0.5, y: 0.5, z: 0.5 } }\n private shardGeos: THREE_NS.BufferGeometry[] = []\n private readonly shapeGeos = new Map<Exclude<SharedShape, 'shard'>, THREE_NS.BufferGeometry[]>()\n private readonly materials = new Map<string, THREE_NS.Material>()\n private readonly q: THREE_NS.Quaternion\n private readonly dq: THREE_NS.Quaternion\n private readonly m: THREE_NS.Matrix4\n private readonly v: THREE_NS.Vector3\n private readonly w: THREE_NS.Vector3\n private rng = createRng(FRAGMENT_SEED)\n /** The fragments in flight drawn by instances, a draw per shared geometry and material (`FragmentInstances`). */\n private readonly instances: FragmentInstances\n /** The instanced probe of the last `warmMeshes` (a new one each call, as the other probes are new meshes), freed by the next call or by `dispose`. */\n private warmInstanced: THREE_NS.InstancedMesh | null = null\n /** The pieces a fragment lies on (`pileUnder`), kept between calls. */\n private readonly under: RestingBox[] = []\n /** Count of `update` calls: what makes the fragments of one burst tell apart from older ones. */\n private tick = 0\n private supportTurn = 0\n /** The pose before the last update and after it, of the fragments that were awake (`interpolate`); null when the option is off. */\n private readonly trail: PoseTrail | null\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly o: FragmentSystemOptions,\n ) {\n this.box = new THREE.BoxGeometry(1, 1, 1)\n this.q = new THREE.Quaternion()\n this.dq = new THREE.Quaternion()\n this.m = new THREE.Matrix4()\n this.v = new THREE.Vector3()\n this.w = new THREE.Vector3()\n this.instances = new FragmentInstances(THREE, o.scene)\n this.trail = o.interpolate ? new PoseTrail() : null\n }\n\n /** What the instances draw now: their draws and the fragments in them. */\n instanceStats(): FragmentInstanceStats {\n return this.instances.stats()\n }\n\n /** The instanced meshes that draw the fragments in flight (tests). */\n instancedMeshes(): THREE_NS.InstancedMesh[] {\n return this.instances.instancedMeshes()\n }\n\n get count(): number {\n return this.list.length\n }\n\n /** Meshes of every live fragment (tests and picking). */\n meshes(): THREE_NS.Mesh[] {\n return this.list.map((f) => f.mesh)\n }\n\n /** Meshes of the fragments asleep in the scene, without marks on them (a mark is a mesh of its own on the fragment). */\n restingMeshes(): THREE_NS.Mesh[] {\n return this.list.filter((f) => f.asleep && !f.dying && f.mesh.children.length === 0 && f.mesh.parent === this.o.scene).map((f) => f.mesh)\n }\n\n /** One shared material per source material id + colour (+ transparency). */\n materialFor(materialId: string, color: number, transparent: boolean, opacity = 0.5): THREE_NS.Material {\n const key = `${materialId}:${color}:${transparent ? 1 : 0}`\n let m = this.materials.get(key)\n if (!m) {\n m = transparent\n ? new this.THREE.MeshStandardMaterial({ color, roughness: 0.15, metalness: 0.1, transparent: true, opacity, side: this.THREE.DoubleSide, depthWrite: false })\n : new this.THREE.MeshLambertMaterial({ color })\n this.materials.set(key, m)\n }\n return m\n }\n\n private shardGeometry(seed: number): THREE_NS.BufferGeometry {\n const idx = seed % SHARD_SHAPES\n let g = this.shardGeos[idx]\n if (!g) {\n const r = createRng(1000 + idx)\n const n = 3 + Math.floor(r() * 3) // triangle, quad or pentagon, irregular\n const shape = new this.THREE.Shape()\n const pts: Array<[number, number]> = []\n for (let i = 0; i < n; i++) {\n const a = (i / n) * Math.PI * 2 + (r() - 0.5) * 0.7\n const rad = 0.35 + r() * 0.15\n pts.push([Math.cos(a) * rad, Math.sin(a) * rad])\n }\n shape.moveTo(pts[0][0], pts[0][1])\n for (let i = 1; i < n; i++) shape.lineTo(pts[i][0], pts[i][1])\n shape.closePath()\n g = new this.THREE.ExtrudeGeometry(shape, { depth: 1, bevelEnabled: false })\n g.translate(0, 0, -0.5)\n this.shardGeos[idx] = g\n }\n return g\n }\n\n private sharedGeometry(shape: Exclude<SharedShape, 'shard'>, seed: number): THREE_NS.BufferGeometry {\n const idx = seed % FRAGMENT_SHAPE_VARIANTS\n let variants = this.shapeGeos.get(shape)\n if (!variants) {\n variants = []\n this.shapeGeos.set(shape, variants)\n }\n let g = variants[idx]\n if (!g) {\n g = BUILDERS[shape](this.THREE, idx)\n variants[idx] = g\n }\n return g\n }\n\n /**\n * The geometry a fragment is drawn with: a splinter is a pointed, frayed sliver; MDF breaks in lumps, plywood peels in ragged veneer, the stub of a broken\n * board ends in torn strands at +x; the rest are boxes.\n */\n private geometryOf(f: Fragment): THREE_NS.BufferGeometry {\n const seed = hashString(f.id)\n if (f.shape === 'shard') return this.shardGeometry(seed)\n if (f.shape === 'splinter') return this.sharedGeometry('sliver', seed)\n const form = this.o.formOf?.(f.material)\n if (f.shape === 'chunk' && form === 'granules') return this.sharedGeometry('lump', seed)\n if (f.shape === 'scrap' && form === 'plies') return this.sharedGeometry('veneer', seed)\n if (f.shape === 'slab' && (form === 'slivers' || form === 'plies')) return this.sharedGeometry('board', seed)\n // whole bricks and blocks that came out at their joints keep their faces (a laid unit is a brick, not a broken lump); a broken face of it is rubble\n if (f.shape === 'chunk' && !f.unit && this.o.crumbles?.(f.material)) return this.sharedGeometry('rubble', seed)\n return this.box\n }\n\n private markGeometry: THREE_NS.CircleGeometry | null = null\n private markMaterial: THREE_NS.MeshBasicMaterial | null = null\n\n private markParts(): { geometry: THREE_NS.CircleGeometry; material: THREE_NS.MeshBasicMaterial } {\n this.markGeometry ??= new this.THREE.CircleGeometry(1, 10)\n this.markMaterial ??= new this.THREE.MeshBasicMaterial({ color: 0x0b0a09, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -4, polygonOffsetUnits: -4 })\n return { geometry: this.markGeometry, material: this.markMaterial }\n }\n\n /**\n * Meshes, never put in a scene by this class, that draw every shared piece of a fragment once: the box, the six shards, the wood splinters, MDF lumps, plywood veneer, broken masonry, the bullet-hole disc, and the opaque and\n * glass materials. A host draws them at load so the first blast does not upload these buffers in the middle of a frame.\n */\n warmMeshes(): THREE_NS.Mesh[] {\n const opaque = this.materialFor('warm', 0x808080, false)\n const glass = this.materialFor('warm', 0x808080, true)\n const geometries = [this.box, ...Array.from({ length: SHARD_SHAPES }, (_, index) => this.shardGeometry(index))]\n const shaped = (['sliver', 'lump', 'veneer', 'board', 'rubble'] as const).flatMap((shape) => Array.from({ length: FRAGMENT_SHAPE_VARIANTS }, (_, index) => this.sharedGeometry(shape, index)))\n const { geometry, material } = this.markParts()\n // the fragments in flight draw instanced: that program (and its shadow's) is made at load too\n this.warmInstanced?.dispose()\n this.warmInstanced = new this.THREE.InstancedMesh(this.box, opaque, 1)\n this.warmInstanced.castShadow = true\n return [\n ...geometries.flatMap((shared) => [new this.THREE.Mesh(shared, opaque), new this.THREE.Mesh(shared, glass)]),\n ...shaped.map((shared) => new this.THREE.Mesh(shared, opaque)),\n new this.THREE.Mesh(geometry, material),\n this.warmInstanced,\n ]\n }\n\n /**\n * Bullet holes that stay on a fragment (`Fragment.marks`): dark discs that are children of its mesh, so they fall, spin and settle with it. The mesh is\n * a unit box scaled to the fragment, so each disc is scaled back; exact for a mark on a face, which is where a bullet hole is.\n */\n addMarks(mesh: THREE_NS.Mesh, f: Fragment): void {\n if (!f.marks?.length) return\n const { geometry, material } = this.markParts()\n const sc = mesh.scale\n for (const mark of f.marks) {\n const disc = new this.THREE.Mesh(geometry, material)\n const radius = Math.max(0.004, mark.diameter) * 0.6\n const n = this.v.set(mark.normal[0], mark.normal[1], mark.normal[2]).normalize()\n disc.position.set(mark.point[0] / sc.x + (n.x * 0.002) / sc.x, mark.point[1] / sc.y + (n.y * 0.002) / sc.y, mark.point[2] / sc.z + (n.z * 0.002) / sc.z)\n disc.quaternion.setFromUnitVectors(this.w.set(0, 0, 1), n)\n disc.scale.set(radius / sc.x, radius / sc.y, radius / sc.z)\n mesh.add(disc)\n }\n }\n\n /**\n * Create the mesh of a fragment and start its motion. `maxAllowed` is the live budget: over it the oldest fragment still showing fades out to make room, and a burst\n * bigger than the budget (every live fragment was made in this same frame) does not make the rest at all, so a blast never builds a thousand meshes only to fade them\n * out. Returns null when the fragment was not made.\n */\n /**\n * Throws `f` into the scene, within `maxAllowed` live fragments (the oldest small ones make room first). A `lasting` fragment (a steel bar) is debris that\n * stays: it has a body the player and the pieces run into, however thin it is, and it never fades.\n */\n spawn(f: Fragment, material: THREE_NS.Material, home: string, maxAllowed: number, lasting = false): THREE_NS.Mesh | null {\n if (this.list.length >= maxAllowed) {\n let alive = 0\n let oldest: Live | undefined\n let oldestSmall: Live | undefined\n for (const l of this.list) {\n if (l.dying) continue\n alive++\n oldest ??= l\n if (!l.body) oldestSmall ??= l\n }\n // the splinters go first; the big ones only when nothing else is left\n oldest = oldestSmall ?? oldest\n if (alive >= maxAllowed) {\n if (!oldest || oldest.born === this.tick) return null\n oldest.dying = true\n this.activate(oldest)\n }\n }\n const geo = this.geometryOf(f)\n const mesh = new this.THREE.Mesh(geo, material)\n mesh.position.set(f.center[0], f.center[1], f.center[2])\n mesh.quaternion.set(f.rotation[0], f.rotation[1], f.rotation[2], f.rotation[3]).normalize()\n const sz = f.size\n const sc = new this.THREE.Vector3(Math.max(0.005, sz[0]), Math.max(0.005, sz[1]), Math.max(0.003, sz[2]))\n mesh.scale.copy(sc)\n mesh.castShadow = true\n // pure visual debris: a host that picks with a raycast can skip it\n mesh.userData.destructionDebris = true\n mesh.name = 'fragment'\n markKitOrigin(mesh, { owner: 'game-destruction-three', kind: 'fragment', id: f.material })\n this.o.scene.add(mesh)\n const live: Live = {\n mesh,\n floor: null,\n home,\n vel: new this.THREE.Vector3(f.velocity[0], f.velocity[1], f.velocity[2]),\n ang: new this.THREE.Vector3(f.angularVelocity[0], f.angularVelocity[1], f.angularVelocity[2]),\n // shards are thin: the contact extent uses the real (small) thickness, the chunk uses half of each side\n half: sc.clone().multiplyScalar(0.5),\n baseScale: sc,\n still: 0,\n asleep: false,\n contact: false,\n rest: 0,\n fade: 1,\n dying: false,\n air: f.shape === 'scrap' && sz[2] <= SHEET_MAX ? SHEET_AIR : 0,\n body: null,\n born: this.tick,\n life: lasting ? 0 : Math.max(0, typeof this.o.life === 'function' ? this.o.life(f, home) : this.o.life),\n seq: this.nextSeq++,\n deadline: Infinity,\n isActive: true,\n isMortal: false,\n }\n // a big piece stays where it fell, whatever its shape: a slab of a roof tile is debris as much as a chunk of brick is\n if (lasting || isBig(f.size)) {\n live.body = {\n mass: f.mass,\n push: (x, z) => {\n live.vel.x = x\n live.vel.z = z\n live.vel.y = Math.max(live.vel.y, 0.3)\n this.rouse(live)\n },\n }\n }\n this.list.push(live)\n this.active.push(live)\n this.addMarks(mesh, f)\n return mesh\n }\n\n /** The boxes of the big fragments around (x, z). */\n solidsNear(x: number, z: number, radius: number, found: (home: string, min: [number, number, number], max: [number, number, number], body: LooseBody) => void): void {\n const boxes: number[] = []\n for (const f of this.list) {\n if (!f.body || f.dying) continue\n const reach = f.half.length() + radius\n if (Math.abs(f.mesh.position.x - x) > reach || Math.abs(f.mesh.position.z - z) > reach) continue\n f.mesh.updateMatrixWorld()\n boxes.length = 0\n pushFittedBoxes(this.unitBox, f.mesh.matrixWorld, boxes)\n for (let i = 0; i < boxes.length; i += 6) {\n if (x < boxes[i] - radius || x > boxes[i + 3] + radius || z < boxes[i + 2] - radius || z > boxes[i + 5] + radius) continue\n found(f.home, [boxes[i], boxes[i + 1], boxes[i + 2]], [boxes[i + 3], boxes[i + 4], boxes[i + 5]], f.body)\n }\n }\n }\n\n /** Add velocity to every fragment within `radius` of a point (blasts). */\n blast(point: [number, number, number], radius: number, speed: number): void {\n for (const f of this.list) {\n const d = this.v.copy(f.mesh.position).sub(this.w.set(point[0], point[1], point[2]))\n const dist = d.length()\n if (dist > radius || f.dying) continue\n const k = (1 - dist / radius) ** 2 * speed\n d.normalize().multiplyScalar(k)\n d.y += k * 0.4\n f.vel.add(d)\n f.ang.add(this.w.set(this.rng() - 0.5, this.rng() - 0.5, this.rng() - 0.5).multiplyScalar(k))\n this.rouse(f)\n }\n }\n\n /** A fragment that came to rest stops having its matrix recomputed on every frame; whatever moves it again calls this first. */\n private rouse(f: Live): void {\n f.asleep = false\n f.box = undefined\n f.rest = 0\n f.deadline = Infinity\n // what it lay on may be gone: the floor is measured again where it lies\n f.floor = null\n f.mesh.matrixAutoUpdate = true\n this.activate(f)\n }\n\n /** Into the awake list, at the place of its creation order (the order the fragments were always stepped in). */\n private activate(f: Live): void {\n if (f.isActive) return\n f.isActive = true\n let at = this.active.length\n while (at > 0 && this.active[at - 1].seq > f.seq) at--\n this.active.splice(at, 0, f)\n }\n\n private deactivate(f: Live): void {\n if (!f.isActive) return\n f.isActive = false\n this.active.splice(this.active.indexOf(f), 1)\n }\n\n /** The sleepers whose time at rest passed their life start to fade; the ones that woke since leave the list. */\n private expireSleepers(): void {\n if (this.clock <= this.nextDeadline) return\n let next = Infinity\n let kept = 0\n for (let i = 0; i < this.mortal.length; i++) {\n const f = this.mortal[i]\n if (f.deadline === Infinity || f.dying) {\n f.isMortal = false\n continue\n }\n if (this.clock > f.deadline) {\n f.isMortal = false\n f.dying = true\n f.mesh.matrixAutoUpdate = true\n this.activate(f)\n continue\n }\n if (f.deadline < next) next = f.deadline\n this.mortal[kept++] = f\n }\n this.mortal.length = kept\n this.nextDeadline = next\n }\n\n /** What lies inside the disc looks at the ground again: it was dug or heaped under it. */\n wakeRegion(x: number, z: number, radius: number): void {\n for (const f of this.list) {\n if (!f.asleep || Math.hypot(f.mesh.position.x - x, f.mesh.position.z - z) > radius) continue\n this.rouse(f)\n }\n }\n\n update(dt: number): void {\n this.tick++\n this.clock += dt\n this.wakeUnsupported()\n this.beginTick()\n const g = this.o.gravity\n for (let i = this.active.length - 1; i >= 0; i--) {\n const f = this.active[i]\n if (f.dying) {\n f.mesh.matrixAutoUpdate = true\n f.fade -= dt / 0.6\n if (f.fade <= 0) {\n this.instances.remove(f.mesh)\n this.o.scene.remove(f.mesh)\n f.isActive = false\n this.active.splice(i, 1)\n this.list.splice(this.list.indexOf(f), 1)\n continue\n }\n f.mesh.scale.copy(f.baseScale).multiplyScalar(f.fade)\n }\n if (f.asleep) continue\n this.step(f, dt, g)\n }\n this.expireSleepers()\n this.keepBudget()\n this.trail?.commit()\n this.drawInstanced()\n }\n\n /** The meshes go back to the step's pose and the ones awake are recorded as the previous one (`interpolate`). */\n private beginTick(): void {\n const trail = this.trail\n if (!trail) return\n trail.begin()\n for (const f of this.active) if (!f.asleep) trail.record(f.mesh)\n }\n\n /** The meshes get the step pose back, before anything reads them. The instances take it at the next `update`. */\n restoreStepPose(): void {\n this.trail?.restore()\n }\n\n /** The fragments awake drawn `alpha` of the way from their pose before the last update to the step's (1: the step's); the instances take the new transforms. */\n presentPose(alpha: number): void {\n if (!this.trail) return\n this.trail.blend(alpha)\n this.instances.sync()\n }\n\n /** The fragments in flight are drawn by the instances, those at rest on their own (the settled batches take them): then the instances take the transforms of this update. */\n private drawInstanced(): void {\n for (const f of this.active) {\n if (f.asleep) this.instances.remove(f.mesh)\n else this.instances.add(f.mesh)\n }\n this.instances.sync()\n }\n\n /** Over `maxAwake` fragments moving, the oldest at rest on what is under them sleep where they lie (`FragmentSystemOptions.maxAwake`). */\n private keepBudget(): void {\n const most = this.o.maxAwake\n if (most === undefined || !Number.isFinite(most)) return\n let awake = 0\n for (const f of this.active) if (!f.asleep && !f.dying) awake++\n if (awake <= most) return\n for (let i = 0; i < this.active.length; i++) {\n const f = this.active[i]\n if (awake <= most) return\n if (f.asleep || f.dying || !f.contact || !isSlow(f)) continue\n this.sleep(f)\n i--\n awake--\n }\n }\n\n /** The fragment stops where it lies, and its matrix is no longer recomputed every frame. */\n private sleep(f: Live): void {\n f.asleep = true\n f.box = undefined\n f.mesh.updateMatrix()\n f.mesh.matrixAutoUpdate = false\n f.vel.set(0, 0, 0)\n f.ang.set(0, 0, 0)\n if (f.dying) return\n this.instances.remove(f.mesh)\n this.deactivate(f)\n if (f.life > 0 && !f.body) {\n f.deadline = this.clock + f.life - f.rest\n this.nextDeadline = Math.min(this.nextDeadline, f.deadline)\n if (!f.isMortal) {\n f.isMortal = true\n this.mortal.push(f)\n }\n }\n }\n\n /** A few fragments asleep each update (`SUPPORT_CHECKS`, in turn) look at the ground under them again: one left over air falls. */\n private wakeUnsupported(): void {\n const n = this.list.length\n for (let k = 0; k < Math.min(SUPPORT_CHECKS, n); k++) {\n this.supportTurn = (this.supportTurn + 1) % n\n const f = this.list[this.supportTurn]\n if (!f.asleep || f.dying) continue\n const e = this.m.makeRotationFromQuaternion(f.mesh.quaternion).elements\n const ext = Math.abs(e[1]) * f.half.x + Math.abs(e[5]) * f.half.y + Math.abs(e[9]) * f.half.z\n // measured afresh: the floor kept from its landing is the top it landed on, which may have broken or been carried off since\n f.floor = null\n const bottom = f.mesh.position.y - ext\n const pile = this.pileUnder(f, bottom)\n const offEdge = this.offEdge\n // lying on the ground itself and on no pile above it: nothing it could lose is under it (what is built is never below the ground), so no ray is cast\n const ground = this.o.groundAt(f.mesh.position.x, f.mesh.position.z)\n if (bottom <= ground + SUPPORT_GAP && pile <= ground) continue\n const floor = this.floorUnder(f)\n if (bottom > Math.max(floor, pile) + SUPPORT_GAP || (pile > floor && offEdge)) this.rouse(f)\n }\n }\n\n /** What a fragment lands on: measured where it is, and again only once it moved `FLOOR_REMEASURE` m off that spot (a ray down is not free). */\n private floorUnder(f: Live): number {\n const p = f.mesh.position\n if (!this.o.surfaceAt) return this.o.groundAt(p.x, p.z)\n const at = f.floor\n if (!at || Math.abs(at.x - p.x) > FLOOR_REMEASURE || Math.abs(at.z - p.z) > FLOOR_REMEASURE || p.y < at.y - FLOOR_REMEASURE) {\n f.floor = { x: p.x, z: p.z, y: this.o.surfaceAt(p.x, p.y, p.z) }\n }\n return f.floor!.y\n }\n\n private step(f: Live, dt: number, g: number): void {\n const mesh = f.mesh\n // it moves now: the box others land on is made again from where it ends up\n f.box = undefined\n f.vel.y -= g * dt\n if (!this.hitWall(f, dt)) mesh.position.addScaledVector(f.vel, dt)\n const w = f.ang.length()\n if (w > 1e-5) {\n this.dq.setFromAxisAngle(this.v.copy(f.ang).multiplyScalar(1 / w), w * dt)\n mesh.quaternion.premultiply(this.dq).normalize()\n }\n // ground contact: lowest point of the oriented box\n this.m.makeRotationFromQuaternion(mesh.quaternion)\n const e = this.m.elements\n const h = f.half\n const sc = f.dying ? f.fade : 1\n const ext = (Math.abs(e[1]) * h.x + Math.abs(e[5]) * h.y + Math.abs(e[9]) * h.z) * sc\n const floor = this.floorUnder(f)\n const pile = this.pileUnder(f, mesh.position.y - ext + Math.max(0, -f.vel.y) * dt)\n const gy = Math.max(floor, pile)\n // lying on the pile with its centre past the edge of what holds it: it slides and turns off that edge\n const tip = pile > floor ? this.offEdge : null\n let contact = false\n if (mesh.position.y - ext < gy) {\n contact = true\n mesh.position.y = gy + ext\n if (f.vel.y < -0.6) {\n f.vel.y = -f.vel.y * 0.25\n f.vel.x *= 0.7\n f.vel.z *= 0.7\n f.ang.multiplyScalar(0.55)\n // a hit on a corner makes it tumble a little\n f.ang.x += (this.rng() - 0.5) * 2\n f.ang.z += (this.rng() - 0.5) * 2\n } else {\n f.vel.y = 0\n // Coulomb friction on the floor: the sliding speed falls by mu g each second, so a piece leaving at v slides v^2 / (2 mu g), as a body of the piece system\n // does (a snapped shovel handle thrown at 7.5 m/s comes to rest 5.7 m away, near the blade, not a metre from where it broke)\n const sliding = Math.hypot(f.vel.x, f.vel.z)\n const kept = sliding > 0 ? Math.max(0, sliding - DEBRIS_FRICTION * g * dt) / sliding : 0\n f.vel.x *= kept\n f.vel.z *= kept\n f.ang.multiplyScalar(Math.exp(-6 * dt))\n }\n } else {\n f.ang.multiplyScalar(Math.exp(-0.15 * dt))\n if (f.air > 0) this.flutter(f, dt)\n }\n if (contact && tip) {\n f.vel.x += tip.x * TIP_SPEED * dt * 10\n f.vel.z += tip.z * TIP_SPEED * dt * 10\n f.ang.x += tip.z * TIP_TURN * dt * 10\n f.ang.z -= tip.x * TIP_TURN * dt * 10\n } else if (contact && f.vel.lengthSq() < 4) this.settle(f, dt)\n f.contact = contact\n if (contact && isSlow(f)) {\n f.still += dt\n if (f.still > SETTLE_SECONDS) this.sleep(f)\n } else {\n f.still = 0\n }\n }\n\n /**\n * A fragment meets what stands in its way this step (`FragmentSystemOptions.sweep`): it stops on the face, out of it by its own reach along the face's normal, and bounces off\n * it, losing most of the speed into the face and some along it. A shard thrown at a wall falls at the foot of the wall, never into it. True when it met a face (it was moved).\n */\n private hitWall(f: Live, dt: number): boolean {\n const sweep = this.o.sweep\n if (!sweep) return false\n const speed = f.vel.length()\n if (speed < SWEEP_MIN_SPEED) return false\n // one sliding or bouncing on what is under it: that is the ground contact's\n if (f.contact && f.vel.y <= 0 && Math.hypot(f.vel.x, f.vel.z) < SWEEP_MIN_SPEED) return false\n const p = f.mesh.position\n const dir: [number, number, number] = [f.vel.x / speed, f.vel.y / speed, f.vel.z / speed]\n const e = this.m.makeRotationFromQuaternion(f.mesh.quaternion).elements\n // the fragment's reach along a direction: the half extents of its turned box projected on it\n const reach = (x: number, y: number, z: number) => (Math.abs(e[0] * x + e[1] * y + e[2] * z) * f.half.x + Math.abs(e[4] * x + e[5] * y + e[6] * z) * f.half.y + Math.abs(e[8] * x + e[9] * y + e[10] * z) * f.half.z) * (f.dying ? f.fade : 1)\n const ahead = reach(dir[0], dir[1], dir[2])\n const hit = sweep([p.x, p.y, p.z], dir, speed * dt + ahead)\n if (!hit) return false\n const nx = hit.normal[0] ?? 0, ny = hit.normal[1] ?? 0, nz = hit.normal[2] ?? 0\n const into = f.vel.x * nx + f.vel.y * ny + f.vel.z * nz\n // a face it is leaving (its normal along the way) does not hold it\n if (into >= 0) return false\n const off = reach(nx, ny, nz) + 0.002\n p.set((hit.point[0] ?? p.x) + nx * off, (hit.point[1] ?? p.y) + ny * off, (hit.point[2] ?? p.z) + nz * off)\n // the speed into the face turns back at a quarter; what runs along the face keeps most of it\n const tx = f.vel.x - into * nx, ty = f.vel.y - into * ny, tz = f.vel.z - into * nz\n f.vel.set(tx * WALL_GLIDE - into * WALL_RESTITUTION * nx, ty * WALL_GLIDE - into * WALL_RESTITUTION * ny, tz * WALL_GLIDE - into * WALL_RESTITUTION * nz)\n f.ang.multiplyScalar(0.55)\n // what it lands on is measured again from where it stopped (it was over the far side of the wall)\n f.floor = null\n return true\n }\n\n /**\n * The top of the debris lying under a falling fragment: a piece lands on the pile, not through it, so two flat pieces never end up inside each other. Only pieces\n * below it count (a resting one keeps its box), those whose top is at or below where the faller's bottom was a step ago plus a small step.\n */\n private pileUnder(f: Live, bottom: number): number {\n const p = f.mesh.position\n const e = this.m.makeRotationFromQuaternion(f.mesh.quaternion).elements\n const reachX = Math.abs(e[0]) * f.half.x + Math.abs(e[4]) * f.half.y + Math.abs(e[8]) * f.half.z\n const reachZ = Math.abs(e[2]) * f.half.x + Math.abs(e[6]) * f.half.y + Math.abs(e[10]) * f.half.z\n const mine = shadowOf(e, f.half)\n let top = Number.NEGATIVE_INFINITY\n // the pieces it lies on (those whose top is the highest under it) and whether one of them is under its centre\n const under = this.under\n under.length = 0\n for (const other of this.list) {\n if (other === f || other.dying) continue\n // kept until it moves again (`step`, `rouse`, `sleep` drop it)\n const box = (other.box ??= restingBox(other))\n if (box.top > bottom + PILE_STEP || box.top < top - PILE_STEP) continue\n if (Math.abs(box.x - p.x) >= box.reachX + reachX || Math.abs(box.z - p.z) >= box.reachZ + reachZ) continue\n // the wrapping boxes touch: what counts is whether the floor areas the two really cover do (a turned or leaning box wraps far more than it covers)\n if (!shadowsOverlap(mine, box.shadow, box.x - p.x, box.z - p.z)) continue\n if (box.top > top + PILE_STEP) under.length = 0\n under.push(box)\n top = Math.max(top, box.top)\n }\n // a brick on a brick stays only with its centre over it: one standing out past the edge goes over, away from what is under it\n this.offEdge = null\n if (under.length > 0 && !under.some((box) => box.top >= top - PILE_STEP && shadowsOverlap(POINT, box.shadow, box.x - p.x, box.z - p.z))) {\n let x = 0, z = 0\n for (const box of under) {\n x += p.x - box.x\n z += p.z - box.z\n }\n const d = Math.hypot(x, z)\n this.offEdge = d > 1e-6 ? { x: x / d, z: z / d } : { x: 1, z: 0 }\n }\n return top\n }\n\n /** Set by `pileUnder`: the way off the edge when the fragment's centre is past what it lies on, else null. */\n private offEdge: { x: number; z: number } | null = null\n\n /** A sheet in the air: drag slows it to a slow fall, and it sways and turns over as it goes. */\n private flutter(f: Live, dt: number): void {\n f.vel.multiplyScalar(Math.exp(-f.air * dt))\n f.vel.x += (this.rng() - 0.5) * SHEET_SWAY * dt\n f.vel.z += (this.rng() - 0.5) * SHEET_SWAY * dt\n f.ang.x += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt\n f.ang.z += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt\n }\n\n /** Tip the fragment towards lying on its flattest face. */\n private settle(f: Live, dt: number): void {\n const mesh = f.mesh\n this.m.makeRotationFromQuaternion(mesh.quaternion)\n const e = this.m.elements\n const up = [e[1], e[5], e[9]] // world-y component of each local axis\n const half = [f.half.x, f.half.y, f.half.z]\n let small = 0\n for (let i = 1; i < 3; i++) if (half[i] < half[small]) small = i\n let axis = small\n // landed on another face, it stays on it only if that face is wide enough for its height: a lump on its side does, a sheet on its edge or a board on its end goes flat\n if (Math.abs(up[small]) < 0.35 && !f.body) {\n let standing = 0\n for (let i = 1; i < 3; i++) if (Math.abs(up[i]) > Math.abs(up[standing])) standing = i\n const across = Math.min(...half.filter((_, i) => i !== standing))\n if (across >= STAND_RATIO * half[standing]) axis = standing\n }\n const sign = up[axis] >= 0 ? 1 : -1\n this.v.set(e[axis * 4], e[axis * 4 + 1], e[axis * 4 + 2]).multiplyScalar(sign)\n this.w.set(0, 1, 0)\n this.dq.setFromUnitVectors(this.v, this.w)\n this.q.copy(this.dq).multiply(mesh.quaternion)\n mesh.quaternion.slerp(this.q, clamp(dt * 7, 0, 1))\n }\n\n /** Remove the fragments of one object (after `restore`). */\n removeHome(home: string): void {\n for (let i = this.list.length - 1; i >= 0; i--) {\n if (this.list[i].home === home) {\n this.instances.remove(this.list[i].mesh)\n this.o.scene.remove(this.list[i].mesh)\n this.deactivate(this.list[i])\n this.list[i].deadline = Infinity\n this.list.splice(i, 1)\n }\n }\n }\n\n clear(): void {\n this.trail?.clear()\n this.instances.clear()\n for (const f of this.list) this.o.scene.remove(f.mesh)\n this.list.length = 0\n this.active.length = 0\n this.mortal.length = 0\n this.nextDeadline = Infinity\n }\n\n /** `clear`, the random stream back to its seed and the tick to 0: what comes next flies as on a new system. */\n reset(): void {\n this.clear()\n this.rng = createRng(FRAGMENT_SEED)\n this.tick = 0\n }\n\n dispose(): void {\n this.clear()\n this.instances.dispose()\n this.warmInstanced?.dispose()\n this.warmInstanced = null\n this.box.dispose()\n this.markGeometry?.dispose()\n this.markMaterial?.dispose()\n for (const g of this.shardGeos) g?.dispose()\n this.shardGeos = []\n for (const variants of this.shapeGeos.values()) for (const g of variants) g?.dispose()\n this.shapeGeos.clear()\n for (const m of this.materials.values()) m.dispose()\n this.materials.clear()\n }\n}\n","import type * as THREE_NS from 'three'\n\n/** Slice length (m) of a turned mesh and the most slices of one mesh. */\nconst SLICE_LENGTH = 0.12\nconst MAX_SLICES = 12\n/** A mesh whose axis box is at most this many times its own volume counts as not turned. */\nconst SNUG_RATIO = 1.1\n\ntype Corner = { readonly x: number; readonly y: number; readonly z: number }\ntype Local = { readonly min: Corner; readonly max: Corner }\n\n/**\n * Appends world axis boxes (min x, y, z, max x, y, z) around the local box of a mesh: one when it lies square, else slices along its longest side. The axis box of a board\n * lying askew is a wide square that holds mostly air, and what walks would hit that air.\n */\nexport function pushFittedBoxes(local: Local, matrix: THREE_NS.Matrix4, out: number[]): void {\n const e = matrix.elements\n const sizes = [0, 1, 2].map((k) => (k === 0 ? local.max.x - local.min.x : k === 1 ? local.max.y - local.min.y : local.max.z - local.min.z))\n const lengths = [0, 1, 2].map((k) => sizes[k] * Math.hypot(e[k * 4], e[k * 4 + 1], e[k * 4 + 2]))\n const longest = lengths.indexOf(Math.max(...lengths))\n const whole = worldBoxOf(local, matrix, longest, 0, 1)\n const span = (whole[3] - whole[0]) * (whole[4] - whole[1]) * (whole[5] - whole[2])\n const volume = lengths[0] * lengths[1] * lengths[2]\n const slices = span <= volume * SNUG_RATIO ? 1 : Math.min(MAX_SLICES, Math.ceil(lengths[longest] / SLICE_LENGTH))\n if (slices <= 1) {\n out.push(...whole)\n return\n }\n for (let i = 0; i < slices; i++) out.push(...worldBoxOf(local, matrix, longest, i / slices, (i + 1) / slices))\n}\n\nfunction worldBoxOf(local: Local, matrix: THREE_NS.Matrix4, axis: number, from: number, to: number): number[] {\n const e = matrix.elements\n const low = [local.min.x, local.min.y, local.min.z]\n const high = [local.max.x, local.max.y, local.max.z]\n const start = low[axis]\n const size = high[axis] - start\n low[axis] = start + size * from\n high[axis] = start + size * to\n const box = [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity]\n for (const x of [low[0], high[0]]) for (const y of [low[1], high[1]]) for (const z of [low[2], high[2]]) {\n for (let k = 0; k < 3; k++) {\n const v = e[k] * x + e[k + 4] * y + e[k + 8] * z + e[k + 12]\n box[k] = Math.min(box[k], v)\n box[k + 3] = Math.max(box[k + 3], v)\n }\n }\n return box\n}\n","import type * as THREE_NS from 'three'\nimport { kitOriginOf, markKitOrigin } from '@adatechnology/game-contracts'\nimport { BATCHED_LAYER } from '@adatechnology/game-render-three'\n\n/**\n * The camera layer a fragment's own mesh moves to while an instance draws it: a layer no camera enables, so neither the colour pass nor the shadow pass draws it (three's\n * `WebGLShadowMap` tests an object's layers against the viewing camera's, not the light's), and it is not drawn twice. Its mask is given back when it leaves the instances.\n * Apart from the batches' `BATCHED_LAYER` (30), which the settled batches read as \"drawn by a batcher already\".\n */\nexport const INSTANCED_FRAGMENT_LAYER = 29\n\n/** The name of the instanced meshes (not `fragment`: what counts the fragments in a scene counts their own meshes). */\nexport const FRAGMENT_INSTANCES_NAME = 'fragment-instances'\n\n/** Instances a bucket starts with; it doubles when full. */\nconst FIRST_CAPACITY = 16\n\ninterface Bucket {\n readonly key: string\n mesh: THREE_NS.InstancedMesh\n readonly members: THREE_NS.Mesh[]\n}\n\ninterface Slot {\n readonly bucket: Bucket\n index: number\n /** The layer mask the mesh gets back when it leaves (what it had when it joined, or what was set on it from outside since). */\n mask: number\n readonly geometry: THREE_NS.BufferGeometry\n readonly material: THREE_NS.Material\n}\n\n/** What the instances hold now: draws (one per bucket with members) and the fragments they draw. */\nexport interface FragmentInstanceStats {\n readonly buckets: number\n readonly drawn: number\n}\n\nconst HIDDEN_MASK = 1 << INSTANCED_FRAGMENT_LAYER\nconst BATCHED_MASK = 1 << BATCHED_LAYER\n\n/**\n * Whether a fragment's mesh can be drawn by an instance: one opaque material, no marks on it (a bullet hole is a mesh of its own on the fragment), and not drawn by a batch\n * now. A batched one woken without the batch letting go of it yet waits until the batcher gives it back its layers (the update after it moved): taking it before would\n * keep the batch's mask as the one to give back, and it would vanish when it lands.\n */\nexport const isInstanceable = (mesh: THREE_NS.Mesh): boolean =>\n !Array.isArray(mesh.material) && !mesh.material.transparent && mesh.children.length === 0 && (mesh.layers.mask & BATCHED_MASK) === 0\n\nconst keyOf = (geometry: THREE_NS.BufferGeometry, material: THREE_NS.Material): string => `${geometry.uuid}|${material.uuid}`\n\n/**\n * The fragments in flight drawn as one `InstancedMesh` per shared geometry and material instead of a draw each (and a shadow draw each). Only the drawing changes: each\n * fragment keeps its own mesh in the scene, with its name, origin and transform, moved to `INSTANCED_FRAGMENT_LAYER` while an instance draws it. `sync` copies the\n * transforms into the instances once per update; the instances' bounds wrap their members, so they are culled as a whole.\n */\nexport class FragmentInstances {\n private readonly buckets = new Map<string, Bucket>()\n private readonly slots = new Map<THREE_NS.Mesh, Slot>()\n private readonly sphere: THREE_NS.Sphere\n private readonly reaches = new WeakMap<THREE_NS.BufferGeometry, number>()\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly parent: THREE_NS.Object3D,\n ) {\n this.sphere = new THREE.Sphere()\n }\n\n has(mesh: THREE_NS.Mesh): boolean {\n return this.slots.has(mesh)\n }\n\n /** Draws `mesh` by an instance from now on; false (and nothing changes) when it cannot be (`isInstanceable`) or is already. */\n add(mesh: THREE_NS.Mesh): boolean {\n if (this.slots.has(mesh) || !isInstanceable(mesh)) return false\n const geometry = mesh.geometry\n const material = mesh.material as THREE_NS.Material\n const key = keyOf(geometry, material)\n let bucket = this.buckets.get(key)\n if (!bucket) {\n bucket = { key, mesh: this.makeMesh(geometry, material, FIRST_CAPACITY, mesh), members: [] }\n this.buckets.set(key, bucket)\n }\n if (bucket.members.length === bucket.mesh.instanceMatrix.count) this.grow(bucket)\n this.slots.set(mesh, { bucket, index: bucket.members.length, mask: mesh.layers.mask, geometry, material })\n bucket.members.push(mesh)\n mesh.layers.mask = HIDDEN_MASK\n return true\n }\n\n /** `mesh` draws on its own again (its layers back as they were); the last member of its bucket takes its place. */\n remove(mesh: THREE_NS.Mesh): void {\n const slot = this.slots.get(mesh)\n if (!slot) return\n this.slots.delete(mesh)\n const members = slot.bucket.members\n const last = members.pop()\n const instanced = slot.bucket.mesh\n if (last === undefined) throw new Error('FragmentInstances: a member has a slot in an empty bucket')\n if (last !== mesh) {\n const lastSlot = this.slots.get(last)\n if (!lastSlot) throw new Error('FragmentInstances: the last member of a bucket has no slot')\n members[slot.index] = last\n lastSlot.index = slot.index\n // drawn right even before the next sync (a fragment taken away between an update and the render)\n instanced.instanceMatrix.array.copyWithin(slot.index * 16, members.length * 16, members.length * 16 + 16)\n }\n instanced.count = members.length\n instanced.instanceMatrix.needsUpdate = true\n mesh.layers.mask = slot.mask\n }\n\n /**\n * Copies the members' transforms into the instances and wraps them in their bounds. A member whose geometry, material or marks changed moves to where it now belongs.\n * A member whose layers were set from outside (a batcher handing back the mask it kept for it) gets that mask back when it leaves, and is hidden again now.\n */\n sync(): void {\n for (const [mesh, slot] of this.slots) {\n const mask = mesh.layers.mask\n if (mask !== HIDDEN_MASK) {\n slot.mask = mask\n if ((mask & BATCHED_MASK) === 0) mesh.layers.mask = HIDDEN_MASK\n }\n if (mesh.geometry === slot.geometry && mesh.material === slot.material && isInstanceable(mesh)) continue\n this.remove(mesh)\n this.add(mesh)\n }\n for (const bucket of [...this.buckets.values()]) this.syncBucket(bucket)\n }\n\n stats(): FragmentInstanceStats {\n let buckets = 0\n for (const bucket of this.buckets.values()) if (bucket.members.length > 0) buckets++\n return { buckets, drawn: this.slots.size }\n }\n\n /** The instanced meshes (tests). */\n instancedMeshes(): THREE_NS.InstancedMesh[] {\n return [...this.buckets.values()].map((bucket) => bucket.mesh)\n }\n\n /** Every member draws on its own again; the instanced meshes leave the scene and their instance buffers are freed (geometries and materials are the fragment system's, shared). */\n clear(): void {\n for (const mesh of [...this.slots.keys()]) this.remove(mesh)\n for (const bucket of [...this.buckets.values()]) this.syncBucket(bucket)\n }\n\n dispose(): void {\n this.clear()\n }\n\n /** An empty bucket is let go (made again when a fragment of its kind flies): nothing empty is left in the scene. */\n private syncBucket(bucket: Bucket): void {\n const { mesh, members } = bucket\n if (members.length === 0) {\n this.buckets.delete(bucket.key)\n this.release(mesh)\n return\n }\n mesh.count = members.length\n const array = mesh.instanceMatrix.array as Float32Array\n const reach = this.reachOf(mesh.geometry)\n let minX = Infinity, minY = Infinity, minZ = Infinity, maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity\n for (let i = 0; i < members.length; i++) {\n const member = members[i] as THREE_NS.Mesh\n member.updateMatrix()\n array.set(member.matrix.elements, i * 16)\n const { x, y, z } = member.position\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n const sphere = this.sphere\n sphere.center.set((minX + maxX) / 2, (minY + maxY) / 2, (minZ + maxZ) / 2)\n let radius = 0\n for (const member of members) {\n const s = member.scale\n radius = Math.max(radius, member.position.distanceTo(sphere.center) + reach * Math.max(Math.abs(s.x), Math.abs(s.y), Math.abs(s.z)))\n }\n sphere.radius = radius\n mesh.boundingSphere ??= new this.THREE.Sphere()\n mesh.boundingSphere.copy(sphere)\n mesh.instanceMatrix.needsUpdate = true\n }\n\n /** How far the geometry reaches from its origin, kept per geometry; read from its vertices, so the shared geometry's own bounds are left as they were. */\n private reachOf(geometry: THREE_NS.BufferGeometry): number {\n let reach = this.reaches.get(geometry)\n if (reach === undefined) {\n const position = geometry.getAttribute('position')\n reach = 0\n for (let i = 0; i < position.count; i++) reach = Math.max(reach, Math.hypot(position.getX(i), position.getY(i), position.getZ(i)))\n this.reaches.set(geometry, reach)\n }\n return reach\n }\n\n private makeMesh(geometry: THREE_NS.BufferGeometry, material: THREE_NS.Material, capacity: number, like: THREE_NS.Mesh): THREE_NS.InstancedMesh {\n const mesh = new this.THREE.InstancedMesh(geometry, material, capacity)\n mesh.instanceMatrix.setUsage(this.THREE.DynamicDrawUsage)\n mesh.count = 0\n mesh.name = FRAGMENT_INSTANCES_NAME\n mesh.castShadow = like.castShadow\n mesh.receiveShadow = like.receiveShadow\n // pure visual debris, as each fragment is: a host that picks with a raycast can skip it\n mesh.userData.destructionDebris = true\n // a ray finds the fragment's own mesh (on its layer, for a raycaster that enables it): walking every instance again would only find the same fragments twice\n mesh.raycast = () => {}\n const origin = kitOriginOf(like)\n markKitOrigin(mesh, origin ?? { owner: 'game-destruction-three', kind: 'fragment' })\n this.parent.add(mesh)\n return mesh\n }\n\n private grow(bucket: Bucket): void {\n const old = bucket.mesh\n const bigger = this.makeMesh(old.geometry, old.material as THREE_NS.Material, old.instanceMatrix.count * 2, bucket.members[0] ?? old)\n this.release(old)\n bucket.mesh = bigger\n }\n\n /**\n * Out of the scene, its instance buffer freed. `dispose()` and not `discardObject3D`: the only resource of its own is the instance buffer, which `releaseObject3D` does not\n * free; its geometry and material are the fragment system's, shared with the fragments' meshes and freed by the fragment system's `dispose`.\n */\n private release(mesh: THREE_NS.InstancedMesh): void {\n mesh.removeFromParent()\n mesh.dispose()\n }\n}\n","import type { Vec3 } from '@adatechnology/game-destruction'\n\n/** Small deterministic PRNG (mulberry32): returns a function giving numbers in [0, 1). */\nexport function createRng(seed: number): () => number {\n let a = seed >>> 0\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\n/** Hash of a few numbers into an unsigned 32-bit seed. */\nexport function hashNumbers(...values: number[]): number {\n let h = 2166136261\n for (const v of values) {\n const n = Math.round(v * 1000) | 0\n h = Math.imul(h ^ n, 16777619)\n h ^= h >>> 13\n }\n return h >>> 0\n}\n\nexport function hashString(s: string): number {\n let h = 2166136261\n for (let i = 0; i < s.length; i++) h = Math.imul(h ^ s.charCodeAt(i), 16777619)\n return h >>> 0\n}\n\nexport const clamp = (v: number, lo: number, hi: number): number => (v < lo ? lo : v > hi ? hi : v)\nexport const lerp = (a: number, b: number, t: number): number => a + (b - a) * t\n\nexport function vec3Length(v: Vec3): number {\n return Math.hypot(v[0], v[1], v[2])\n}\n\nexport function normalize3(v: Vec3): Vec3 {\n const l = Math.hypot(v[0], v[1], v[2])\n return l > 1e-9 ? [v[0] / l, v[1] / l, v[2] / l] : [0, 1, 0]\n}\n\n/** `0xRRGGBB` -> `[r, g, b]` in 0..1. */\nexport function hexToRgb(hex: number): [number, number, number] {\n return [((hex >> 16) & 255) / 255, ((hex >> 8) & 255) / 255, (hex & 255) / 255]\n}\n\nexport function mixHex(a: number, b: number, t: number): number {\n const ar = (a >> 16) & 255\n const ag = (a >> 8) & 255\n const ab = a & 255\n const r = Math.round(ar + (((b >> 16) & 255) - ar) * t)\n const g = Math.round(ag + (((b >> 8) & 255) - ag) * t)\n const bl = Math.round(ab + ((b & 255) - ab) * t)\n return (r << 16) | (g << 8) | bl\n}\n","import type * as THREE_NS from 'three'\n\nimport { createRng } from './math'\n\n/** How many shapes of each kind there are; a fragment takes one by the hash of its id, so a burst shares a handful of buffers. */\nexport const FRAGMENT_SHAPE_VARIANTS = 6\n\n/** Cross-sections along a sliver (the last one is its point) and how much each corner may stray in or out (the torn fibres). */\nconst SLIVER_STATIONS = 6\nconst SLIVER_FRAY = 0.3\n\n/** Corners of a sliver's cross-section in the unit box: the four corners and a ridge on each wide face. */\nconst SLIVER_SECTION: ReadonlyArray<readonly [number, number]> = [[0.5, 0.5], [0, 0.5], [-0.5, 0.5], [-0.5, -0.5], [0, -0.5], [0.5, -0.5]]\n\n/** Width of the section along a sliver (0 at the broken end, 1 at the point): ragged and narrower at the break, full in the middle, tapering to the point. */\nconst sliverWidth = (t: number): number => (t < 0.25 ? 0.6 + 1.6 * t : t > 0.5 ? Math.max(0, (1 - t) / 0.5) ** 0.85 : 1)\n\nconst pushTriangle = (out: number[], a: readonly number[], b: readonly number[], c: readonly number[]): void => {\n out.push(a[0], a[1], a[2], b[0], b[1], b[2], c[0], c[1], c[2])\n}\n\nconst faceted = (THREE: typeof THREE_NS, positions: number[]): THREE_NS.BufferGeometry => {\n const geometry = new THREE.BufferGeometry()\n geometry.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3))\n geometry.computeVertexNormals()\n return geometry\n}\n\n/**\n * A splinter of wood in the unit box, long along x: a ragged broken end, a body whose corners stray in and out from section to section (the torn fibres\n * along its edges), bending a little, and a point at the other end that is off its axis. About 60 triangles, shared by every splinter of the variant.\n */\nexport function buildSliverGeometry(THREE: typeof THREE_NS, seed: number): THREE_NS.BufferGeometry {\n const rnd = createRng(7000 + seed)\n const rings: number[][][] = []\n const bendY = (rnd() - 0.5) * 0.3\n const bendZ = (rnd() - 0.5) * 0.3\n for (let i = 0; i < SLIVER_STATIONS - 1; i++) {\n const t = i / (SLIVER_STATIONS - 1)\n const x = -0.5 + t + (i > 0 ? (rnd() - 0.5) * 0.08 : 0)\n const width = sliverWidth(t)\n const lift = Math.sin(t * Math.PI)\n rings.push(SLIVER_SECTION.map(([y, z]) => {\n const fray = 1 - SLIVER_FRAY + SLIVER_FRAY * 1.4 * rnd()\n return [x, Math.max(-0.5, Math.min(0.5, y * width * fray + bendY * lift)), Math.max(-0.5, Math.min(0.5, z * width * fray + bendZ * lift))]\n }))\n }\n const tip = [0.5, (rnd() - 0.5) * 0.5, (rnd() - 0.5) * 0.3]\n // the broken end is torn, not cut: its centre stands out or sinks in\n const torn = [-0.5 + rnd() * 0.12, (rnd() - 0.5) * 0.2, (rnd() - 0.5) * 0.2]\n const sides = SLIVER_SECTION.length\n const positions: number[] = []\n for (let k = 0; k < sides; k++) {\n const next = (k + 1) % sides\n pushTriangle(positions, torn, rings[0][next], rings[0][k])\n for (let i = 0; i < rings.length - 1; i++) {\n const a = rings[i][k], b = rings[i][next], c = rings[i + 1][next], d = rings[i + 1][k]\n pushTriangle(positions, a, b, c)\n pushTriangle(positions, a, c, d)\n }\n const last = rings[rings.length - 1]\n pushTriangle(positions, last[k], last[next], tip)\n }\n return faceted(THREE, positions)\n}\n\n/**\n * A crumbly lump of pressed fibre (MDF) in the unit box: an icosahedron whose corners are pushed in and out by where they are (so the faces stay\n * closed), squashed to fill the box. 20 triangles.\n */\nexport function buildLumpGeometry(THREE: typeof THREE_NS, seed: number): THREE_NS.BufferGeometry {\n const rnd = createRng(8000 + seed)\n const base = new THREE.IcosahedronGeometry(0.5, 0)\n const source = base.getAttribute('position')\n const pushOf = new Map<string, number>()\n const positions: number[] = []\n for (let i = 0; i < source.count; i++) {\n const x = source.getX(i), y = source.getY(i), z = source.getZ(i)\n const key = `${x.toFixed(3)},${y.toFixed(3)},${z.toFixed(3)}`\n let push = pushOf.get(key)\n if (push === undefined) {\n push = 0.6 + 0.55 * rnd()\n pushOf.set(key, push)\n }\n positions.push(x * push, y * push, z * push)\n }\n base.dispose()\n const extent = [0, 0, 0]\n for (let i = 0; i < positions.length; i++) extent[i % 3] = Math.max(extent[i % 3], Math.abs(positions[i]))\n for (let i = 0; i < positions.length; i++) positions[i] *= 0.5 / Math.max(extent[i % 3], 1e-3)\n return faceted(THREE, positions)\n}\n\n/** Points along each long edge of a peeled sheet of veneer. */\nconst VENEER_EDGE = 11\n\n/**\n * A sheet of veneer peeled off plywood in the unit box (thin along z): long edges torn along the grain in fine teeth (now and then a deeper notch) and\n * the short ends broken across with a sliver standing out, extruded to its thickness.\n */\nexport function buildVeneerGeometry(THREE: typeof THREE_NS, seed: number): THREE_NS.BufferGeometry {\n const rnd = createRng(9000 + seed)\n const shape = new THREE.Shape()\n const outline: Array<[number, number]> = []\n // the long edges tear along the grain in fine teeth; each short end breaks across with one long sliver of veneer standing out\n const edge = (y: number, inward: number): number => y - inward * (rnd() * 0.16 + (rnd() < 0.15 ? 0.12 : 0))\n for (let i = 0; i <= VENEER_EDGE; i++) outline.push([-0.5 + i / VENEER_EDGE, edge(0.5, 1)])\n outline.push([0.5 - rnd() * 0.12, 0.2 * rnd()], [0.5, -0.1 + 0.2 * rnd()], [0.5 - rnd() * 0.12, -0.25 * rnd()])\n for (let i = VENEER_EDGE; i >= 0; i--) outline.push([-0.5 + i / VENEER_EDGE, edge(-0.5, -1)])\n outline.push([-0.5 + rnd() * 0.12, -0.2 * rnd()], [-0.5, 0.1 * rnd()], [-0.5 + rnd() * 0.12, 0.25 * rnd()])\n shape.moveTo(outline[0][0], outline[0][1])\n for (let i = 1; i < outline.length; i++) shape.lineTo(outline[i][0], outline[i][1])\n shape.closePath()\n const geometry = new THREE.ExtrudeGeometry(shape, { depth: 1, bevelEnabled: false })\n geometry.translate(0, 0, -0.5)\n return geometry\n}\n\n/** Share of a broken board's length its torn end takes, and how many strands of fibre (at least, at most) the end splits into across its width. */\nconst TORN_END = 0.24\nconst TORN_STRANDS: readonly [number, number] = [4, 7]\n\n/** Pushes the two triangles of the quad a-b-c-d, wound so that it faces where (b - a) x (c - b) points. */\nconst pushQuad = (out: number[], quad: ReadonlyArray<readonly number[]>): void => {\n pushTriangle(out, quad[0], quad[1], quad[2])\n pushTriangle(out, quad[0], quad[2], quad[3])\n}\n\n/** Uneven cuts of [-0.5, 0.5] into `count` widths, each between a third and twice the mean. */\nconst unevenCuts = (count: number, rnd: () => number): number[] => {\n const shares = Array.from({ length: count }, () => 0.35 + 1.65 * rnd())\n const total = shares.reduce((sum, share) => sum + share, 0)\n const cuts = [-0.5]\n for (const share of shares) cuts.push(cuts[cuts.length - 1] + share / total)\n cuts[cuts.length - 1] = 0.5\n return cuts\n}\n\n/**\n * The stub of a wooden board broken across, in the unit box, long along x: the sound part of the board, and at its +x end the break, torn into strands\n * of fibre of uneven widths and lengths that bend a little and fray before they come to points, not a clean saw cut. 58 to 94 triangles.\n */\nexport function buildBrokenBoardGeometry(THREE: typeof THREE_NS, seed: number): THREE_NS.BufferGeometry {\n const rnd = createRng(10000 + seed)\n const end = 0.5 - TORN_END\n const positions: number[] = []\n const lo = -0.5, hi = 0.5\n // the sound part of the board: a box from the far end to where the break starts (its face at the break is closed by the strands)\n pushQuad(positions, [[lo, lo, hi], [end, lo, hi], [end, hi, hi], [lo, hi, hi]])\n pushQuad(positions, [[lo, hi, lo], [end, hi, lo], [end, lo, lo], [lo, lo, lo]])\n pushQuad(positions, [[lo, hi, hi], [end, hi, hi], [end, hi, lo], [lo, hi, lo]])\n pushQuad(positions, [[lo, lo, lo], [end, lo, lo], [end, lo, hi], [lo, lo, hi]])\n pushQuad(positions, [[lo, lo, lo], [lo, lo, hi], [lo, hi, hi], [lo, hi, lo]])\n const count = TORN_STRANDS[0] + Math.floor(rnd() * (TORN_STRANDS[1] - TORN_STRANDS[0] + 1))\n const cuts = unevenCuts(count, rnd)\n for (let k = 0; k < count; k++) {\n const y0 = cuts[k], y1 = cuts[k + 1]\n const length = TORN_END * (0.15 + 0.85 * rnd())\n // halfway out the strand has narrowed and strays a little sideways and up or down; then it comes to a point off its middle\n const midX = end + length * (0.35 + 0.3 * rnd())\n const narrow = 0.55 + 0.35 * rnd()\n const shiftY = (rnd() - 0.5) * (y1 - y0) * 0.6\n const shiftZ = (rnd() - 0.5) * 0.5\n const cy = (y0 + y1) / 2 + shiftY, hy = ((y1 - y0) / 2) * narrow, hz = 0.5 * (0.4 + 0.5 * rnd())\n const base = [[end, y0, lo], [end, y1, lo], [end, y1, hi], [end, y0, hi]]\n const clampZ = (z: number): number => Math.max(lo, Math.min(hi, z))\n const mid = [[midX, cy - hy, clampZ(shiftZ - hz)], [midX, cy + hy, clampZ(shiftZ - hz)], [midX, cy + hy, clampZ(shiftZ + hz)], [midX, cy - hy, clampZ(shiftZ + hz)]]\n const tip = [end + length, y0 + (y1 - y0) * rnd(), clampZ(shiftZ + (rnd() - 0.5) * 0.4)]\n for (let i = 0; i < 4; i++) {\n const next = (i + 1) % 4\n pushQuad(positions, [base[i], base[next], mid[next], mid[i]])\n pushTriangle(positions, mid[i], mid[next], tip)\n }\n }\n return faceted(THREE, positions)\n}\n\n/**\n * A broken piece of brick, block or concrete in the unit box: a box whose corners are knocked off (each pulled in along its own axes) and whose edges are\n * nicked, so a heap of them reads as broken masonry, not as cut blocks. The faces of the box stay nearly flat (the faces of the brick); 48 triangles.\n */\nexport function buildRubbleGeometry(THREE: typeof THREE_NS, seed: number): THREE_NS.BufferGeometry {\n const rnd = createRng(9000 + seed)\n const base = new THREE.BoxGeometry(1, 1, 1, 2, 2, 2).toNonIndexed()\n const source = base.getAttribute('position')\n const moved = new Map<string, number[]>()\n const positions: number[] = []\n for (let i = 0; i < source.count; i++) {\n const p = [source.getX(i), source.getY(i), source.getZ(i)]\n const key = p.map((x) => x.toFixed(3)).join(',')\n let out = moved.get(key)\n if (!out) {\n // 3 coordinates on the box's surface: a corner; 2: the middle of an edge; 1: the middle of a face, which stays\n const outer = p.filter((x) => Math.abs(x) > 0.49).length\n const bite = outer === 3 ? 0.08 + 0.3 * rnd() : outer === 2 ? 0.1 * rnd() : 0\n out = p.map((x) => (Math.abs(x) > 0.49 ? x - Math.sign(x) * bite * (0.4 + 0.6 * rnd()) : x))\n moved.set(key, out)\n }\n positions.push(out[0]!, out[1]!, out[2]!)\n }\n base.dispose()\n return faceted(THREE, positions)\n}\n","import type * as THREE_NS from 'three'\n\nconst FLOATS = 7\nconst FIRST_CAPACITY = 64\n\n/** What a trail reads and writes of an object: its position and rotation. */\nexport type TrailObject = Pick<THREE_NS.Object3D, 'position' | 'quaternion' | 'updateMatrix' | 'updateMatrixWorld'>\n\n/**\n * The pose an object had before its last step and the one it has after, to draw between them (`interpolate`). Poses live in two typed arrays indexed in the order the\n * objects were recorded, so a frame makes no object; the arrays grow by doubling, only when more objects than ever are recorded. The step pose is kept apart from what is\n * drawn: `restore` gives it back to the objects before anything reads them, so a simulation never reads a drawn pose.\n *\n * A tick is `begin` (the objects as they stand are the previous pose), `record` for each object that may move, then `commit` (as they stand now is the pose of the step).\n * `blend` writes the pose between the two; `restore` writes the step pose back (also done by `begin`).\n */\nexport class PoseTrail {\n private objects: TrailObject[] = []\n private previous = new Float64Array(FIRST_CAPACITY * FLOATS)\n private current = new Float64Array(FIRST_CAPACITY * FLOATS)\n private count = 0\n private isCommitted = false\n private isBlended = false\n\n /** How many objects the trail holds. */\n get size(): number {\n return this.count\n }\n\n /** Whether the objects are showing a pose that is not the step's. */\n get isDrawing(): boolean {\n return this.isBlended\n }\n\n begin(): void {\n this.restore()\n this.objects.length = 0\n this.count = 0\n this.isCommitted = false\n }\n\n record(object: TrailObject): void {\n if ((this.count + 1) * FLOATS > this.previous.length) this.grow()\n write(this.previous, this.count * FLOATS, object)\n this.objects.push(object)\n this.count++\n }\n\n commit(): void {\n for (let i = 0; i < this.count; i++) write(this.current, i * FLOATS, this.objects[i] as TrailObject)\n this.isCommitted = true\n }\n\n /** The objects drawn `alpha` of the way from the previous pose to the step's (1 and over: the step's, to the bit). Nothing is drawn before a commit. */\n blend(alpha: number): void {\n if (!this.isCommitted) return\n const t = alpha < 0 ? 0 : alpha\n const p = this.previous\n const c = this.current\n for (let i = 0; i < this.count; i++) {\n const at = i * FLOATS\n const object = this.objects[i] as TrailObject\n if (t >= 1) copyPose(object, c, at)\n else if (t <= 0) copyPose(object, p, at)\n else put(object, p, at, c, at, t)\n object.updateMatrix()\n }\n this.isBlended = true\n }\n\n /** The step pose back on the objects, and their matrices with it: a simulation reads `matrixWorld` too. */\n restore(): void {\n if (!this.isBlended) return\n this.isBlended = false\n for (let i = 0; i < this.count; i++) {\n const object = this.objects[i] as TrailObject\n copyPose(object, this.current, i * FLOATS)\n object.updateMatrix()\n object.updateMatrixWorld()\n }\n }\n\n /** The objects are let go (what leaves the scene is not kept alive by the trail). */\n clear(): void {\n this.restore()\n this.objects.length = 0\n this.count = 0\n this.isCommitted = false\n }\n\n private grow(): void {\n const bigger = (old: Float64Array<ArrayBuffer>): Float64Array<ArrayBuffer> => {\n const array = new Float64Array(old.length * 2)\n array.set(old)\n return array\n }\n this.previous = bigger(this.previous)\n this.current = bigger(this.current)\n }\n}\n\nfunction write(into: Float64Array, at: number, object: TrailObject): void {\n const { position: p, quaternion: q } = object\n into[at] = p.x\n into[at + 1] = p.y\n into[at + 2] = p.z\n into[at + 3] = q.x\n into[at + 4] = q.y\n into[at + 5] = q.z\n into[at + 6] = q.w\n}\n\nfunction copyPose(object: TrailObject, from: Float64Array, at: number): void {\n object.position.set(from[at] as number, from[at + 1] as number, from[at + 2] as number)\n object.quaternion.set(from[at + 3] as number, from[at + 4] as number, from[at + 5] as number, from[at + 6] as number)\n}\n\n/** Writes the pose `t` (between 0 and 1, exclusive) of the way from `a` to `b` (lerp of the position, slerp of the rotation) into the object. */\nfunction put(object: TrailObject, a: Float64Array, ai: number, b: Float64Array, bi: number, t: number): void {\n const ax = a[ai] as number\n const ay = a[ai + 1] as number\n const az = a[ai + 2] as number\n object.position.set(ax + ((b[bi] as number) - ax) * t, ay + ((b[bi + 1] as number) - ay) * t, az + ((b[bi + 2] as number) - az) * t)\n slerpInto(object.quaternion, a, ai + 3, b, bi + 3, t)\n}\n\nfunction slerpInto(out: TrailObject['quaternion'], a: Float64Array, ai: number, b: Float64Array, bi: number, t: number): void {\n const ax = a[ai] as number\n const ay = a[ai + 1] as number\n const az = a[ai + 2] as number\n const aw = a[ai + 3] as number\n let bx = b[bi] as number\n let by = b[bi + 1] as number\n let bz = b[bi + 2] as number\n let bw = b[bi + 3] as number\n let dot = ax * bx + ay * by + az * bz + aw * bw\n if (dot < 0) {\n bx = -bx\n by = -by\n bz = -bz\n bw = -bw\n dot = -dot\n }\n let from = 1 - t\n let to = t\n if (dot < 0.9995) {\n const angle = Math.acos(dot)\n const sine = Math.sin(angle)\n from = Math.sin((1 - t) * angle) / sine\n to = Math.sin(t * angle) / sine\n }\n const x = ax * from + bx * to\n const y = ay * from + by * to\n const z = az * from + bz * to\n const w = aw * from + bw * to\n const length = Math.hypot(x, y, z, w) || 1\n out.set(x / length, y / length, z / length, w / length)\n}\n","import type * as THREE_NS from 'three'\nimport { lerp } from './math'\n\ninterface Spot {\n mesh: THREE_NS.Mesh\n kind: 'puddle' | 'ash'\n home: string\n x: number\n z: number\n radius: number\n target: number\n}\n\nconst MAX_RADIUS = 1.2\n\n/** Flat discs on the ground: puddles of melted material and piles of ash. Nearby ones merge; the oldest go when the cap is reached. */\nexport class GroundSpots {\n private readonly spots: Spot[] = []\n private readonly geometry: THREE_NS.CircleGeometry\n private readonly materials = new Map<string, THREE_NS.MeshBasicMaterial>()\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly scene: THREE_NS.Scene,\n private readonly groundAt: (x: number, z: number) => number,\n private readonly cap: number,\n ) {\n this.geometry = new THREE.CircleGeometry(1, 20)\n this.geometry.rotateX(-Math.PI / 2)\n }\n\n get count(): number {\n return this.spots.length\n }\n\n private material(kind: 'puddle' | 'ash', color: number): THREE_NS.MeshBasicMaterial {\n const key = `${kind}:${color}`\n let m = this.materials.get(key)\n if (!m) {\n m = new this.THREE.MeshBasicMaterial({\n color,\n transparent: true,\n opacity: kind === 'puddle' ? 0.88 : 0.95,\n depthWrite: false,\n polygonOffset: true,\n polygonOffsetFactor: -2,\n polygonOffsetUnits: -2,\n })\n this.materials.set(key, m)\n }\n return m\n }\n\n /** Add (or grow) a spot at (x, z). `radius` is the radius this addition contributes. */\n add(kind: 'puddle' | 'ash', x: number, z: number, radius: number, color: number, home: string): void {\n for (const s of this.spots) {\n if (s.kind !== kind) continue\n const d = Math.hypot(s.x - x, s.z - z)\n if (d < Math.max(s.target, radius) * 0.9) {\n s.target = Math.min(MAX_RADIUS, Math.sqrt(s.target * s.target + radius * radius * 0.5))\n return\n }\n }\n while (this.spots.length >= this.cap) this.remove(this.spots[0])\n const mesh = new this.THREE.Mesh(this.geometry, this.material(kind, color))\n const y = this.groundAt(x, z) + 0.004 + (this.spots.length % 8) * 0.0004\n mesh.position.set(x, y, z)\n mesh.scale.setScalar(0.001)\n mesh.renderOrder = 1\n mesh.userData.destructionDebris = true\n this.scene.add(mesh)\n this.spots.push({ mesh, kind, home, x, z, radius: 0.001, target: Math.min(MAX_RADIUS, radius) })\n }\n\n private remove(s: Spot): void {\n const i = this.spots.indexOf(s)\n if (i >= 0) this.spots.splice(i, 1)\n this.scene.remove(s.mesh)\n }\n\n update(dt: number): void {\n const k = Math.min(1, dt * 3)\n for (const s of this.spots) {\n if (Math.abs(s.radius - s.target) < 1e-4) continue\n s.radius = lerp(s.radius, s.target, k)\n s.mesh.scale.setScalar(s.radius)\n }\n }\n\n /** Remove the spots made for one object (after its `restore`). */\n removeHome(home: string): void {\n for (const s of [...this.spots]) if (s.home === home) this.remove(s)\n }\n\n clear(): void {\n for (const s of [...this.spots]) this.remove(s)\n }\n\n dispose(): void {\n this.clear()\n this.geometry.dispose()\n for (const m of this.materials.values()) m.dispose()\n this.materials.clear()\n }\n}\n","import type * as THREE_NS from 'three'\nimport type { MaterialId, PartSettlement, Vec3 } from '@adatechnology/game-destruction'\nimport type { Piece } from './types'\n\n/** A box of a part of a piece: centre and half sizes in the piece's frame from its centre of mass, and how it is turned in that frame (none: square to it). */\nexport interface PartBox {\n readonly center: Vec3\n readonly half: Vec3\n readonly rotation?: readonly [number, number, number, number]\n}\n\nconst rows = (r: readonly [number, number, number, number]): number[] => {\n const [x, y, z, w] = r\n return [1 - 2 * (y * y + z * z), 2 * (x * y - z * w), 2 * (x * z + y * w), 2 * (x * y + z * w), 1 - 2 * (x * x + z * z), 2 * (y * z - x * w), 2 * (x * z - y * w), 2 * (y * z + x * w), 1 - 2 * (x * x + y * y)]\n}\n\n/** Whether a part box is turned askew in its piece's frame: a quarter or half turn leaves it square, only its sizes swapped. */\nexport const isTurned = (box: PartBox): boolean => box.rotation !== undefined && rows(box.rotation).some((v) => Math.abs(v) > 1e-6 && Math.abs(Math.abs(v) - 1) > 1e-6)\n\n/**\n * The square box around a part box (its frame): what the kit's own solver, which knows only boxes square to the piece, meets in its place. A part not turned is itself.\n */\nexport const squareBoxOf = (box: PartBox): { readonly center: Vec3; readonly half: Vec3 } => {\n const r = box.rotation\n if (!r) return { center: box.center, half: box.half }\n // the rows of the rotation, by absolute value, times the half sizes (a quarter turn swaps them)\n const m = rows(r)\n const h = box.half\n const half: Vec3 = [0, 1, 2].map((i) => Math.abs(m[i * 3]) * h[0] + Math.abs(m[i * 3 + 1]) * h[1] + Math.abs(m[i * 3 + 2]) * h[2]) as Vec3\n return { center: box.center, half }\n}\n\n/** A decal child of a mesh (hole disc or crack star). `geometry` is set when the decal owns it. */\nexport interface Decal {\n obj: THREE_NS.Object3D\n geometry?: THREE_NS.BufferGeometry\n}\n\n/** One merged mesh whose vertex ranges are bound to several parts (or, after a split, the loose mesh of one part). */\nexport interface HostVis {\n mesh: THREE_NS.Mesh\n origGeometry: THREE_NS.BufferGeometry\n origMaterial: THREE_NS.Material | THREE_NS.Material[]\n /** `mesh.geometry` is a clone the renderer may edit. */\n ownGeo: boolean\n /** Current dented positions of the whole mesh (before melt), once the geometry is owned. */\n work: Float32Array | null\n /** `mesh.material` is a clone (vertex colours switched on). */\n ownMat: boolean\n /** Every MeshVis that draws a range of this mesh, or whose merged binding is this mesh. */\n sharers: MeshVis[]\n /**\n * While `work` is null the parts are measured by the mesh's own positions: the attribute and its `version` the sharers' `shapeVersion` account for. A write since (one\n * `needsUpdate`) counts against the ranges it declared (`markPositionsWritten`), or against every sharer when it declared none.\n */\n seen: { attribute: THREE_NS.BufferAttribute | null; version: number }\n /** Once `work` is set: the ranges another drawing collapses on the mesh (`userData.collapsedRanges`, flat `v0, v1, ...`) the sharers' `shapeVersion` account for. */\n collapsedSeen: number[]\n}\n\n/** Everything the renderer knows about one bound mesh: the original assets (kept to restore) and what has been changed. */\nexport interface MeshVis {\n mesh: THREE_NS.Mesh\n /** Object id the mesh belonged to when it was bound (restore goes back there). */\n home: string\n origGeometry: THREE_NS.BufferGeometry\n origMaterial: THREE_NS.Material | THREE_NS.Material[]\n origVisible: boolean\n origParent: THREE_NS.Object3D | null\n origPosition: THREE_NS.Vector3\n origQuaternion: THREE_NS.Quaternion\n origScale: THREE_NS.Vector3\n /** Material cloned (colour and emissive may change). */\n ownMat: boolean\n /** Geometry cloned (vertices may change). */\n ownGeo: boolean\n /** Current dented positions in mesh space (before melt), once the geometry is owned. */\n work: Float32Array | null\n /** Colours of the original materials, to lerp from when charring. */\n baseColors: THREE_NS.Color[] | null\n decals: Decal[]\n meltApplied: number\n /** World height of the bottom of the mesh when it first started melting. */\n bottomY: number\n moved: boolean\n /**\n * Set when the part is bound by a vertex range of a merged mesh: the mesh state lives in `host` and every edit is limited to `range`. After\n * the part detaches they point at its own loose mesh and `[0, vertices]`; `merged` always keeps the binding to go back to.\n */\n host: HostVis | null\n range: [number, number] | null\n merged: { host: HostVis; range: [number, number] } | null\n /** The part's faces were extracted into `mesh` (a mesh the renderer made and owns). */\n loose: boolean\n /** The range is collapsed to a point in the merged mesh (the part is hidden or loose). */\n collapsed: boolean\n /** The part is not drawn (broken, melted, ash). */\n hidden: boolean\n /** Dents, colours, melt or hiding differ from the original geometry. */\n touched: boolean\n /** Counts every write of the positions the part is measured by (`Visuals.positionsOf`): the same count is the same vertices, so `drawnSolidsOf` reads none of them. */\n shapeVersion: number\n charK: number\n charHex: number\n glowHex: number\n glowK: number\n}\n\nexport interface PartVis {\n id: string\n home: string\n material: MaterialId\n meshes: MeshVis[]\n charApplied: number\n glowApplied: number\n meltApplied: number\n /** `none` while the meshes are drawn; the reason they were hidden otherwise. */\n gone: 'none' | 'broken' | 'melted' | 'ashes'\n /** The settlement drawn on the part now (object-local line), when the ground under it went down. */\n settled?: PartSettlement\n /** Parts whose meshes draw this one's marks when it has none of its own (`BindOptions.marksOn`: a pillar under the plaster of its walls). */\n markHosts?: PartVis[]\n}\n\n/** Coulomb friction coefficients of a piece's surface: what holds it still and what drags it while it slides. */\nexport interface PieceFriction {\n readonly static: number\n readonly dynamic: number\n /** Rolling resistance coefficient of the surface, C_rr (a round thing rolling on it is held back by C_rr N); the softer of two surfaces sets it. */\n readonly rolling?: number\n /** Rolling damping of the surface (1/s): the share of its spin a round thing rolling on it loses per second on top of `rolling`; two surfaces add theirs. */\n readonly rollingDamping?: number\n}\n\nexport interface PieceBody extends Piece {\n /** Which body of `objectId` this is (counts up per body made): a push queued for a piece reaches only that body, never one made later under the same id. */\n readonly generation: number\n /** `localCenter` as a vector (kept in sync with it). */\n centerV: THREE_NS.Vector3\n /** Seconds the piece has been nearly still (sleeps after 0.5). */\n still: number\n /** Where the piece was when it last started to stay in place on the ground (centre and rotation), and for how many seconds since: see `CALM_SLEEP_AFTER`. */\n calmAt: { center: Vec3; quaternion: [number, number, number, number] } | null\n calm: number\n /** Its support in the last step was narrower than its centre of mass needs (on an edge, or held up at an angle): it does not sleep by `still`. */\n balancing?: boolean\n /** Its rotation when it last started to keep its tilt (within `STEADY_TURN`), and for how many seconds since; null after it sleeps. */\n steady?: { quaternion: [number, number, number, number]; seconds: number } | null\n /** Put to sleep by the budget (`PieceSystemOptions.maxAwake`): the points (its frame) it lay on, every one of which must keep its support, or it wakes (`wakeUnsupported`). */\n restPoints?: Vec3[]\n /** Time of the last hard-landing report. */\n lastHit: number\n onGround: boolean\n /** Hung on a hinge (`PieceSystem.hinge`): a shelf swinging down on the screw left at one end. */\n hinge?: PieceHinge\n /** Falling over (`tip`): the spin it is given per second on the ground, about x and z, and the seconds it may still take; null when it lies or never had to fall. */\n tipping: { x: number; z: number; seconds: number } | null\n /** The contact impulses each point of the box gave in the last substep (normal, friction x, friction z per point), to start the next one from. */\n warm?: Float64Array\n /** Height of the lowest support the piece last stood on: the floor under a top it was put beneath. */\n floor?: number\n /**\n * In the last step it was held up by a piece under it through their overlap (`separatePair`), not by a corner on a top (a case lying across two books by its middle): the\n * normal of that support, up from it.\n */\n propped?: Vec3\n /** Where it is held up through that overlap, from its centre of mass (world): a point of its support, with the corners that touch. */\n proppedAt?: Vec3\n /**\n * The points that touch the ground in place of the corners of its box (its frame, from the centre of mass): the corners of each part left of it. A top left on one leg\n * stands on that leg's foot, so it goes over, and lands on the edge of the top.\n */\n contacts?: Vec3[]\n /**\n * The boxes of its parts (its frame, from the centre of mass), turned as drawn (`rotation`, in its frame; none is square to it), what other pieces land on instead of\n * its box: a shelf's boards, a table's top and legs, a roof sheet lying askew.\n */\n partBoxes?: PartBox[]\n /** The friction of its surface (by its material); against another surface the two are mixed (geometric mean). Default 0.7 static, 0.6 dynamic. */\n friction?: PieceFriction\n /** The normal of the surface a round piece last lay on: where it touches is across it from the centre. */\n surfaceNormal?: Vec3\n /**\n * A round piece (a can, a bottle, a ball, a plate on its edge): `cylinder` round about its own `axis` (0 x, 1 y, 2 z of its frame) or a `sphere`. It touches the ground by\n * points around its rims (`contacts`), so it rolls, and the ground holds it back only by rolling resistance, not by the grip that stops a box from turning.\n */\n round?: PieceRound\n /** k of `round.inertia` as the host gave it (`MakePieceOptions.inertia`), kept over the measure of its walls when the piece is fitted again. */\n inertiaGiven?: number\n /** Kg the piece weighs less than its parts in the world (the liquid that left it), kept over the refits. */\n massOffset?: number\n /** Coefficient of restitution of its surface (by its material), mixed with the other surface's by geometric mean; default `SLAM_BOUNCE`. */\n restitution?: number\n}\n\n/** A hinge a piece hangs on (`PieceBody.hinge`): the point it turns about (world), that point in its frame from its centre of mass, its rotation when hung and the seconds left. */\nexport interface PieceHinge {\n readonly point: Vec3\n readonly local: Vec3\n readonly from: readonly [number, number, number, number]\n seconds: number\n}\n\n/** How a round piece is round (`PieceBody.round`). */\nexport interface PieceRound {\n readonly kind: 'cylinder' | 'sphere'\n readonly axis: 0 | 1 | 2\n /** The largest radius (m). */\n readonly radius: number\n /**\n * k of its moment of inertia about its axis, I = k m r^2: 0.5 a solid cylinder (a full tin), 1 a thin shell (an empty tin), 0.4 a solid ball, 2/3 a hollow one. On an incline\n * of angle t it rolls down at g sin t / (1 + k).\n */\n readonly inertia: number\n /**\n * Its radius along its axis (a cylinder): `[at, radius]` from one end to the other, `at` from the centre of mass along the axis. A tapered bottle or a cup lying on its side touches\n * by the lowest point of each, so it rolls round the wide end; a straight can rolls on straight. Without it, the two ends at `radius`.\n */\n readonly profile?: ReadonlyArray<readonly [number, number]>\n}\n\nexport interface Bound {\n id: string\n root: THREE_NS.Object3D\n sync: boolean\n parts: Map<string, PartVis>\n lastPos: Vec3 | null\n lastQuat: [number, number, number, number] | null\n piece: PieceBody | null\n /** Created by a `detach` (the root is a group the renderer made and owns). */\n isSplit: boolean\n /** The host's per-frame work for this object (`BindOptions.onFrame`). */\n onFrame?: (dt: number) => void\n /** Node between the root and its children that carries the settlement and tilt of the soil (`settle` events), made on the first one. */\n soilNode?: THREE_NS.Object3D\n /** The root's world matrix when it was last read for the world: an object whose matrix did not change is not decomposed again. */\n lastWorld?: Float64Array\n /** The root of a piece asleep stops recomputing its matrix (`matrixAutoUpdate = false`) until something moves it. */\n frozen?: boolean\n /** Moved by something that does not wake the piece (`DestructionRenderer.markMoved`): synced and thawed on the next `update`. */\n moved?: boolean\n}\n\n/** What a moving piece ran into (`PieceSystemOptions.sweep`). */\nexport interface PieceSweepHit {\n readonly object: string\n readonly part: string\n /** Metres along the way from the centre where the piece meets it. */\n readonly distance: number\n readonly point: Vec3\n readonly normal: Vec3\n /** Coefficient of restitution of what it met (by its material); mixed with the piece's (geometric mean). */\n readonly restitution?: number\n}\n","import { fitOrientedBox, hugs } from '@adatechnology/game-shapes'\nimport type { OrientedBox } from '@adatechnology/game-shapes'\n\nimport type { StaticSolid } from './engine-statics'\n\n/** A box fits a drawn part when each of its eight corners has a vertex within this (m): a box drawn is a box held, a cylinder or a chamfered post is not. */\nconst FIT = 0.01\n/** A box holds a part only when the part's own triangles lie in each of its faces and cover at least this share of the face (a raised panel leaves its edge short, a frame leaves most of it open): a door frame (two posts and a lintel) has a box's eight corners and none of its faces. */\nconst FILL = 0.5\n/** The thinnest half (m) a drawn plane (a sheet with no thickness) is held by. */\nconst MIN_HALF = 0.005\n/** A part whose every side is under this (m) is collapsed to a point (hidden by its host): nothing is drawn there. */\nconst COLLAPSED = 0.002\n/** A face of a box under this area (m²) is a plane's edge: it has nothing to cover. */\nconst MIN_FACE = 1e-6\n\ntype Points = ArrayLike<number>\n\n/**\n * One fixed drawn part to measure (`measureStaticPart`): plain arrays, so it crosses to a worker (`destruction.static-colliders`). The main thread reads the vertices,\n * the triangles and the mesh's world matrix (with three's own `decompose` of it); the measuring is here.\n */\nexport interface StaticPartJob {\n /** The part's vertices in the mesh's frame, three numbers each, with what another drawing collapses there already collapsed. */\n readonly points: Float64Array\n /** The mesh's world matrix (16 numbers, column major). */\n readonly matrix: Float64Array\n /** The world matrix decomposed (three's `Matrix4.decompose`): position, quaternion (x, y, z, w) and scale. */\n readonly position: readonly [number, number, number]\n readonly quaternion: readonly [number, number, number, number]\n readonly scale: readonly [number, number, number]\n /** The triangles of the part as vertex numbers of the host (three each), `from` its first vertex. */\n readonly found: Uint32Array\n readonly from: number\n}\n\nconst IDENTITY = [1, 0, 0, 0, 1, 0, 0, 0, 1]\n\n/** The axes (three rows of 3) of a box turned by the quaternion. */\nconst axesOfQuat = (x: number, y: number, z: number, w: number): number[] => [\n 1 - 2 * (y * y + z * z), 2 * (x * y + z * w), 2 * (x * z - y * w),\n 2 * (x * y - z * w), 1 - 2 * (x * x + z * z), 2 * (y * z + x * w),\n 2 * (x * z + y * w), 2 * (y * z - x * w), 1 - 2 * (x * x + y * y),\n]\n\n/** The point turned by the unit quaternion, in the very operations of three's `Vector3.applyQuaternion` (r160), so the numbers are the same bits. */\nconst turn = (vx: number, vy: number, vz: number, q: readonly [number, number, number, number]): [number, number, number] => {\n const [qx, qy, qz, qw] = q\n const tx = 2 * (qy * vz - qz * vy)\n const ty = 2 * (qz * vx - qx * vz)\n const tz = 2 * (qx * vy - qy * vx)\n return [vx + qw * tx + qy * tz - qz * ty, vy + qw * ty + qz * tx - qx * tz, vz + qw * tz + qx * ty - qy * tx]\n}\n\n/**\n * What a fixed drawn part collides as, in world space, for an engine: one box turned as drawn where a box fits it (every corner has a vertex within `FIT` and its\n * triangles cover its faces), else the box turned to fit the world vertices where that one fits, else the triangles as drawn (`mesh`, static only). A part collapsed to\n * a point is nothing (`CLAUDE.md` §12). A pure function of the job: the worker and the main thread give the same bits (`staticCollidersKind`).\n */\nexport function measureStaticPart(job: StaticPartJob): StaticSolid[] {\n const { points, matrix, position: pos, quaternion: quat, scale, found, from } = job\n const low = [Infinity, Infinity, Infinity]\n const high = [-Infinity, -Infinity, -Infinity]\n for (let i = 0; i < points.length; i += 3) {\n for (let k = 0; k < 3; k++) {\n const v = points[i + k]\n if (v < low[k]) low[k] = v\n if (v > high[k]) high[k] = v\n }\n }\n const size = [high[0] - low[0], high[1] - low[1], high[2] - low[2]]\n const s = [Math.abs(scale[0]), Math.abs(scale[1]), Math.abs(scale[2])]\n if (Math.max(size[0] * s[0], size[1] * s[1], size[2] * s[2]) < COLLAPSED) return []\n const centre = [(low[0] + high[0]) / 2, (low[1] + high[1]) / 2, (low[2] + high[2]) / 2]\n const half = [size[0] / 2, size[1] / 2, size[2] / 2]\n // the box of the geometry in its own frame, turned by the mesh: the drawn box of a wall, a table top, a beam\n const straight = { center: centre, half, axes: IDENTITY, tolerance: [FIT / s[0], FIT / s[1], FIT / s[2]] }\n if (hugs(points, straight) && fillsFaces(points, found, from, straight)) {\n const [cx, cy, cz] = turn(centre[0] * scale[0], centre[1] * scale[1], centre[2] * scale[2], quat)\n return [{ center: [cx + pos[0], cy + pos[1], cz + pos[2]], half: [Math.max(MIN_HALF, half[0] * s[0]), Math.max(MIN_HALF, half[1] * s[1]), Math.max(MIN_HALF, half[2] * s[2])], rotation: [quat[0], quat[1], quat[2], quat[3]] }]\n }\n const world = new Float64Array(points.length)\n const e = matrix\n for (let i = 0; i < points.length; i += 3) {\n const x = points[i], y = points[i + 1], z = points[i + 2]\n world[i] = e[0] * x + e[4] * y + e[8] * z + e[12]\n world[i + 1] = e[1] * x + e[5] * y + e[9] * z + e[13]\n world[i + 2] = e[2] * x + e[6] * y + e[10] * z + e[14]\n }\n const turned = fitOrientedBox(world as unknown as number[])\n if (turned && fitsTurned(world, turned) && fillsFaces(world, found, from, turnedBox(turned))) return [turned]\n return [trimeshOf(world, from, found)]\n}\n\n/** The buffers of a measured part to transfer back (the triangles of a trimesh). */\nexport const staticSolidsTransfer = (solids: readonly StaticSolid[]): ArrayBuffer[] => {\n const out: ArrayBuffer[] = []\n for (const solid of solids) if (solid.mesh) out.push(solid.mesh.vertices.buffer as ArrayBuffer, solid.mesh.indices.buffer as ArrayBuffer)\n return out\n}\n\ntype FitBox = { readonly center: readonly number[]; readonly half: readonly number[]; readonly axes: readonly number[]; readonly tolerance: readonly number[] }\n\nconst turnedBox = (box: OrientedBox): FitBox => ({ center: box.center, half: box.half, axes: axesOfQuat(box.rotation[0], box.rotation[1], box.rotation[2], box.rotation[3]), tolerance: [FIT, FIT, FIT] })\n\nconst fitsTurned = (world: Points, box: OrientedBox): boolean => hugs(world, turnedBox(box))\n\n/** The area of the triangle a, b, c (box frame, three numbers each). */\nconst areaOf = (a: ArrayLike<number>, b: ArrayLike<number>, c: ArrayLike<number>): number => {\n const ux = b[0] - a[0], uy = b[1] - a[1], uz = b[2] - a[2]\n const vx = c[0] - a[0], vy = c[1] - a[1], vz = c[2] - a[2]\n return Math.hypot(uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx) / 2\n}\n\n/** Whether the part's triangles (`found`: vertex numbers of the host, `from` the first of the part) cover each face of the box that has an area: what a box that fits holds is the part, not the air in it. */\nconst fillsFaces = (points: Points, found: ArrayLike<number>, from: number, box: FitBox): boolean => {\n if (found.length === 0) return true\n const covered = [0, 0, 0, 0, 0, 0]\n const frame = [new Float64Array(3), new Float64Array(3), new Float64Array(3)]\n const a = box.axes\n for (let i = 0; i + 2 < found.length; i += 3) {\n for (let v = 0; v < 3; v++) {\n const at = (found[i + v] - from) * 3\n const dx = points[at] - box.center[0], dy = points[at + 1] - box.center[1], dz = points[at + 2] - box.center[2]\n for (let k = 0; k < 3; k++) frame[v][k] = dx * a[k * 3] + dy * a[k * 3 + 1] + dz * a[k * 3 + 2]\n }\n let area = -1\n for (let k = 0; k < 3; k++) for (let side = 0; side < 2; side++) {\n const face = side ? box.half[k] : -box.half[k]\n if (Math.abs(frame[0][k] - face) > box.tolerance[k] || Math.abs(frame[1][k] - face) > box.tolerance[k] || Math.abs(frame[2][k] - face) > box.tolerance[k]) continue\n if (area < 0) area = areaOf(frame[0], frame[1], frame[2])\n covered[k * 2 + side] += area\n }\n }\n for (let k = 0; k < 3; k++) {\n const area = 4 * box.half[(k + 1) % 3] * box.half[(k + 2) % 3]\n if (area < MIN_FACE) continue\n if (covered[k * 2] < area * FILL || covered[k * 2 + 1] < area * FILL) return false\n }\n return true\n}\n\n/** The triangles of the part in world space (its vertices and the triangles of the geometry that start in its range), with the box around them as the box of the solid. */\nconst trimeshOf = (world: Float64Array, from: number, found: ArrayLike<number>): StaticSolid => {\n const indices = new Uint32Array(found.length)\n for (let i = 0; i < found.length; i++) indices[i] = found[i] - from\n const lo = [Infinity, Infinity, Infinity]\n const hi = [-Infinity, -Infinity, -Infinity]\n for (let i = 0; i < world.length; i += 3) {\n for (let k = 0; k < 3; k++) {\n lo[k] = Math.min(lo[k], world[i + k])\n hi[k] = Math.max(hi[k], world[i + k])\n }\n }\n return {\n center: [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2],\n half: [Math.max(MIN_HALF, (hi[0] - lo[0]) / 2), Math.max(MIN_HALF, (hi[1] - lo[1]) / 2), Math.max(MIN_HALF, (hi[2] - lo[2]) / 2)],\n rotation: [0, 0, 0, 1],\n mesh: { vertices: new Float32Array(world), indices },\n }\n}\n","import { WORKER_KIND_DEFAULTS, WORKER_KIND_ID } from '@adatechnology/game-contracts'\nimport type { TaskKind } from '@adatechnology/game-contracts'\n\nimport { computeGroundTile, jobTransferOf, transferOf } from './engine-ground-job'\nimport type { GroundTileJob, GroundTileResult } from './engine-ground-job'\nimport type { StaticSolid } from './engine-statics'\nimport { measureStaticPart, staticSolidsTransfer } from './static-part-job'\nimport type { StaticPartJob } from './static-part-job'\n\n/**\n * The engine's ground tiles as a task kind of the worker coordinator (`destruction.ground-tiles`, CLAUDE.md §14): a tile is a pure function\n * of the samples and the band read at the update it was asked for, so the worker and the main thread give the same bits. The engine's\n * `GroundSchedule` applies it at its update whatever the worker does (`createCoordinatorGroundPort`). No three.js here: a game's worker file\n * imports it from `@adatechnology/game-destruction-three/worker-kinds`.\n */\nexport const groundTilesKind: TaskKind<GroundTileJob, GroundTileResult> = Object.freeze({\n id: WORKER_KIND_ID.GROUND_TILES,\n kind: 'task' as const,\n ...WORKER_KIND_DEFAULTS[WORKER_KIND_ID.GROUND_TILES],\n run: computeGroundTile,\n transferOutput: transferOf,\n // the schedule posts copies from its pool and keeps the job for its own fallback: the samples and band (or the patch) go over without a structured clone, and come back with the answer\n transferInput: jobTransferOf,\n transferAwaitedInput: true,\n // no `warmup`: the engine warms its port with a real tile when the renderer is made (`GroundSchedule.warm`)\n})\n\n/** A cube, the first job each worker runs (`warm`). */\nconst WARM_PART: StaticPartJob = {\n points: new Float64Array([-0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5]),\n matrix: new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),\n position: [0, 0, 0],\n quaternion: [0, 0, 0, 1],\n scale: [1, 1, 1],\n found: new Uint32Array(0),\n from: 0,\n}\n\n/**\n * The fixed colliders measured from what is drawn (`destruction.static-colliders`, lane `build`, CLAUDE.md §14): a part of a house, a table, a wall measured anew is a\n * pure function of its vertices, its triangles and its world matrix (`measureStaticPart`), so the worker and the main thread give the same bits. The renderer hands its\n * parts to it when it has a coordinator (`RendererOptions.workers`); the object waits for the answer as a part out of turns waits for the next update.\n */\nexport const staticCollidersKind: TaskKind<StaticPartJob, StaticSolid[]> = Object.freeze({\n id: WORKER_KIND_ID.STATIC_COLLIDERS,\n kind: 'task' as const,\n ...WORKER_KIND_DEFAULTS[WORKER_KIND_ID.STATIC_COLLIDERS],\n run: measureStaticPart,\n transferOutput: staticSolidsTransfer,\n warmup: WARM_PART,\n})\n","import { cellCoordinate, heightPatchGrid } from '@adatechnology/game-terrain'\nimport type { HeightPatch } from '@adatechnology/game-terrain'\n\nimport { GROUND_CELL, readGround, sampleCount, shapeGround } from './engine-ground'\nimport type { GroundGrid, GroundTile } from './engine-ground'\nimport { SOLID_RING } from './engine-ground-ring'\nimport { NO_SOLID, buildSolidVolume } from './engine-ground-solid'\n\n/**\n * A tile of the engine's ground as plain data, so it can be made off the main thread (`engine-ground-port`): the main thread reads the tile's samples and the band of ground\n * past its edges its solid may read (`readGroundBand`), and the tile is a pure function of those (`computeGroundTile`), the same bits wherever it runs. Nothing here calls back\n * into the host: a worker has no `groundAt`.\n */\n\n/** What a tile is made from: its samples (`readGround`) and the band past its edges (`readGroundBand`), both read on the main thread at the frame it was asked for. */\nexport interface GroundTileJob {\n readonly id: number\n readonly x0: number\n readonly z0: number\n readonly size: number\n /** Whether the tile collided on the coarse field before (`collisionFieldOf`). */\n readonly wasCoarse: boolean\n /** Empty in a patch job (`patch`), whose samples and band are made where the tile is. */\n readonly samples: Float64Array\n readonly band: Float64Array\n /**\n * The terrain's vertices under the tile and its ring (`readGroundPatch`), in place of the samples and the band: about 26 x 26 numbers instead of 60 000. The tile is made from\n * the samples and band the patch gives (`heightPatchGrid`, the terrain's own blend), the same bits as read from the terrain on the main thread.\n */\n readonly patch?: HeightPatch\n}\n\n/** A tile made from a job, as arrays that cross threads; `samples` and `band` are the job's own, handed back for the next job. */\nexport interface GroundTileResult {\n readonly id: number\n readonly cells: number\n readonly collisionCells: number\n readonly level: number | null\n readonly heights: Float32Array\n readonly collision: Float32Array\n readonly boxes: Float64Array\n readonly solid: Float64Array\n readonly ring: Float64Array\n readonly samples: Float64Array\n readonly band: Float64Array\n /** A patch job's vertex heights, handed back for the next job. */\n readonly patch?: Float64Array\n}\n\n/** How many read cells the ring past a tile of `cells` cells of side `cell` is wide (`createGroundRing`). */\nconst ringOf = (cell: number): number => Math.round(SOLID_RING / cell)\n\n/** The length of the band of a tile of `size` m: one height per half cell over the tile and its ring (`GroundSource`). */\nexport const bandLength = (size: number): number => {\n const n = Math.round(size / GROUND_CELL)\n const width = 2 * (n + 2 * ringOf(size / n)) + 1\n return width * width\n}\n\n// the lattice of a band read through the grid, kept between reads (one at a time)\nlet lineX = new Float64Array(0)\nlet lineZ = new Float64Array(0)\nlet sideOut = new Float64Array(0)\n\n/**\n * Reads into `band` the ground past the tile's edges, as far as its solid may read it (`SOLID_RING`) and on the edges themselves: every half cell `(a, b)` with `a` or `b` on or\n * past an edge, at the very point the ring asks `groundAt` for (`x0 + (a / 2) * cell`). Through `grid` in four strips, else a call each. The tile's inside is left as it was.\n */\nexport const readGroundBand = (groundAt: (x: number, z: number) => number, band: Float64Array, x0: number, z0: number, size: number, grid?: GroundGrid): void => {\n const n = Math.round(size / GROUND_CELL)\n const cell = size / n\n const r = ringOf(cell)\n const lo = -2 * r\n const hi = 2 * n + 2 * r\n const width = hi - lo + 1\n const xAt = (a: number): number => x0 + (a / 2) * cell\n const zAt = (b: number): number => z0 + (b / 2) * cell\n if (!grid) {\n for (let b = lo; b <= hi; b++) {\n for (let a = lo; a <= hi; a++) {\n if (a > 0 && a < 2 * n && b > 0 && b < 2 * n) continue\n band[(b - lo) * width + a - lo] = groundAt(xAt(a), zAt(b))\n }\n }\n return\n }\n const strip = 2 * r + 1\n const middle = 2 * n - 1\n if (lineX.length < width) lineX = new Float64Array(width)\n if (lineZ.length < width) lineZ = new Float64Array(width)\n if (sideOut.length < strip * middle) sideOut = new Float64Array(strip * middle)\n for (let a = lo; a <= hi; a++) lineX[a - lo] = xAt(a)\n const xs = lineX.subarray(0, width)\n // the rows under the tile and over it, whole: straight into the band\n for (const from of [lo, 2 * n]) {\n for (let k = 0; k < strip; k++) lineZ[k] = zAt(from + k)\n grid(xs, lineZ.subarray(0, strip), band.subarray((from - lo) * width, (from - lo + strip) * width))\n }\n // the columns left and right of it, between those rows\n for (let k = 0; k < middle; k++) lineZ[k] = zAt(1 + k)\n const zs = lineZ.subarray(0, middle)\n for (const from of [lo, 2 * n]) {\n grid(lineX.subarray(from - lo, from - lo + strip), zs, sideOut)\n for (let k = 0; k < middle; k++) for (let i = 0; i < strip; i++) band[(1 + k - lo) * width + from - lo + i] = sideOut[k * strip + i]!\n }\n}\n\n/** The host's terrain as vertex heights under a rectangle (min x, max x, min z, max z), or null where it cannot (`Terrain.heightPatch` is one); written into `into` when long enough. */\nexport type GroundPatchRead = (minX: number, maxX: number, minZ: number, maxZ: number, into?: Float64Array) => HeightPatch | null\n\n/**\n * The terrain's vertices under the tile at (x0, z0) and its ring, the rectangle every sample and band point lies in (the band's own outermost points, as `readGroundBand` computes\n * them); null where the host has none (a tile crossing the terrain's bounds, where its `baseHeight` answers): that tile is read as before.\n */\nexport const readGroundPatch = (read: GroundPatchRead, x0: number, z0: number, size: number, into?: Float64Array): HeightPatch | null => {\n const n = Math.round(size / GROUND_CELL)\n const cell = size / n\n const r = ringOf(cell)\n const lo = -2 * r\n const hi = 2 * n + 2 * r\n return read(x0 + (lo / 2) * cell, x0 + (hi / 2) * cell, z0 + (lo / 2) * cell, z0 + (hi / 2) * cell, into)\n}\n\n/** The cell of `latticePatchRead`'s ground (m): a terrain's usual one. */\nconst LATTICE_CELL = 0.1\n\n/**\n * A `GroundPatchRead` of any ground as a terrain would hold it: `ground` sampled at the vertices of a `LATTICE_CELL` lattice laid a metre and more around each rectangle asked,\n * the patch found with the terrain's own cell rule (`cellCoordinate`). For the warm job of a patch tile, which has no terrain: whatever the tile size and ring are, its patch\n * covers them, as a real one does.\n */\nexport const latticePatchRead = (ground: (x: number, z: number) => number): GroundPatchRead => (minX, maxX, minZ, maxZ, into) => {\n const originX = Math.floor(minX) - 1\n const originZ = Math.floor(minZ) - 1\n const columns = Math.ceil((maxX - originX) / LATTICE_CELL) + 2\n const rows = Math.ceil((maxZ - originZ) / LATTICE_CELL) + 2\n const column0 = cellCoordinate(minX, originX, columns, LATTICE_CELL) | 0\n const row0 = cellCoordinate(minZ, originZ, rows, LATTICE_CELL) | 0\n const width = (cellCoordinate(maxX, originX, columns, LATTICE_CELL) | 0) + 2 - column0\n const depth = (cellCoordinate(maxZ, originZ, rows, LATTICE_CELL) | 0) + 2 - row0\n const heights = into && into.length >= width * depth ? into : new Float64Array(width * depth)\n for (let j = 0; j < depth; j++) for (let i = 0; i < width; i++) heights[j * width + i] = ground(originX + (column0 + i) * LATTICE_CELL, originZ + (row0 + j) * LATTICE_CELL)\n return { cellSize: LATTICE_CELL, originX, originZ, columns, rows, column0, row0, width, depth, heights }\n}\n\nconst NO_GROUND = (): number => {\n throw new Error('engine-ground-job: a patch job reads its patch only')\n}\n// the patch the grid below reads, and the samples and band a patch job is made into, kept between jobs (one at a time) so a job makes no arrays for them\nlet gridPatch: HeightPatch | null = null\nconst patchGrid: GroundGrid = (xs, zs, out) => heightPatchGrid(gridPatch as HeightPatch, xs, zs, out)\nlet patchSamples = new Float64Array(0)\nlet patchBand = new Float64Array(0)\n\n/** The samples and band of a patch job, read from its patch through the same lattices `readGround` and `readGroundBand` read the terrain at (module scratch: not reentrant). */\nconst groundOfPatch = (job: GroundTileJob, patch: HeightPatch): { samples: Float64Array; band: Float64Array } => {\n const count = sampleCount(Math.round(job.size / GROUND_CELL))\n if (patchSamples.length !== count) patchSamples = new Float64Array(count)\n if (patchBand.length !== bandLength(job.size)) patchBand = new Float64Array(bandLength(job.size))\n gridPatch = patch\n readGround(NO_GROUND, patchSamples, job.x0, job.z0, job.size, undefined, patchGrid)\n readGroundBand(NO_GROUND, patchBand, job.x0, job.z0, job.size, patchGrid)\n gridPatch = null\n return { samples: patchSamples, band: patchBand }\n}\n\n/**\n * The tile a job makes: `shapeGround` of its samples and, under a height field, its solid over the band (both made from its patch first, in a patch job). Pure of the job.\n * Not reentrant: a patch job's samples and band, and `readGround`'s lattice, are module scratch (one job at a time per thread, as a worker and the schedule run them).\n */\nexport const computeGroundTile = (job: GroundTileJob): GroundTileResult => {\n const { samples, band } = job.patch ? groundOfPatch(job, job.patch) : job\n const t = shapeGround(samples, job.x0, job.z0, job.size, null, job.wasCoarse)\n const solid = t.level === null ? buildSolidVolume(t.heights, t.cells, job.x0, job.z0, job.size / t.cells, band, t.cells / t.collisionCells) : NO_SOLID\n return {\n id: job.id, cells: t.cells, collisionCells: t.collisionCells, level: t.level, heights: t.heights, collision: t.collision,\n boxes: Float64Array.from(t.boxes), solid: Float64Array.from(solid.boxes), ring: Float64Array.from(solid.ring), samples: job.samples, band: job.band,\n ...(job.patch ? { patch: job.patch.heights } : {}),\n }\n}\n\n/** Each buffer of the arrays once, none empty (an empty one may be shared, and a buffer transferred twice throws). */\nconst buffersOf = (arrays: ReadonlyArray<Float32Array | Float64Array | undefined>): ArrayBuffer[] => {\n const out: ArrayBuffer[] = []\n for (const array of arrays) {\n const buffer = array?.buffer as ArrayBuffer | undefined\n if (buffer && buffer.byteLength > 0 && !out.includes(buffer)) out.push(buffer)\n }\n return out\n}\n\n/** The buffers a result hands over, each once and none empty (a height field may be its own collision field). */\nexport const transferOf = (r: GroundTileResult): ArrayBuffer[] => buffersOf([r.heights, r.collision, r.boxes, r.solid, r.ring, r.samples, r.band, r.patch])\n\n/** The buffers a job hands over: its samples and band, or its patch. */\nexport const jobTransferOf = (job: GroundTileJob): ArrayBuffer[] => buffersOf([job.samples, job.band, job.patch?.heights])\n\n/** The tile a result stands for, over the samples the main thread keeps for the tile (none for a patch tile, which keeps its patch instead). */\nexport const tileOfResult = (r: GroundTileResult, samples: Float64Array | null, patch?: HeightPatch): GroundTile => ({\n heights: r.heights, cells: r.cells, collision: r.collision, collisionCells: r.collisionCells, boxes: r.boxes,\n solid: r.level === null ? { boxes: r.solid, ring: r.ring } : NO_SOLID, level: r.level, samples, ...(patch ? { patch } : {}),\n})\n","/**\n * The engine collides with a tile's ground at a coarser grid than the tile is read at, as Unreal's \"Simple Collision\" mip level 1 does: every second corner of the 2.5 cm\n * grid, so a 5 cm height field. The read grid stays where the steps are found and the solid under the ground is made; the engine's narrow phase meets a quarter of the\n * triangles under a piece (the frame after a blast was mostly a piece resting on 2.5 cm triangles, T3.8ah). Owner decision 2026-11-17. The collision surface is off the drawn\n * ground by the bend of the ground across one of its cells: a tile keeps the coarse field only where that, with the engine's own 8 bit steps, is within 5 mm everywhere\n * on it, and has no step (`collisionFieldOf`); else it collides at the read grid.\n */\nexport const GROUND_COLLISION_CELL = 0.05\n\n/** The most (m) the collision surface may be off the drawn ground anywhere on a tile for the tile to collide at `GROUND_COLLISION_CELL` (the owner's bound). */\nexport const COLLISION_TOLERANCE = 0.005\n/**\n * A tile on the read grid goes to the coarse field only under this (m): one near the bound does not change field at every change of its ground (the bound stays hard). Not\n * lower: a room crater tile is 4.47 mm off at 5 cm, and a piece rests on it the frame after the blast.\n */\nexport const COLLISION_ENTER = 0.0045\n/** Samples a side of the engine's height field blocks (`game-physics-jolt` `HEIGHT_BLOCK`): each block's heights are 8 bit steps of its own range. */\nconst ENGINE_BLOCK = 4\n\n/** How many read cells (of `readCell` m, `cells` a side) a collision cell would span: 1 keeps the read grid (a collision cell that does not divide the tile). */\nexport const coarseStep = (cells: number, readCell: number): number => {\n const k = Math.max(1, Math.round(GROUND_COLLISION_CELL / readCell))\n return cells % k === 0 ? k : 1\n}\n\n/** A tile's collision field: every `step`-th corner of its read heights (1: the heights themselves). */\nexport interface CollisionField {\n readonly step: number\n readonly field: Float32Array\n}\n\n/**\n * A tile's collision field: the coarse one (`GROUND_COLLISION_CELL`) when the tile has no step boxes (a step's edge is between read corners, and a coarser field ramps or grooves\n * across it: 14 cm by a terrace's wall) and the coarse surface, on either diagonal and with the engine's 8 bit steps, is within `COLLISION_TOLERANCE` of the drawn ground at\n * every read corner (both are flat between them); within `COLLISION_ENTER` when the tile was on the read grid before (`wasCoarse` false: a fresh tile is one); else the read\n * grid itself.\n */\nexport const collisionFieldOf = (heights: Float32Array, cells: number, readCell: number, hasSteps: boolean, wasCoarse = false): CollisionField => {\n const k = coarseStep(cells, readCell)\n const fine = { step: 1, field: heights }\n if (k === 1 || hasSteps || heights.length === 0) return fine\n const m = cells + 1\n const get = (p: number, q: number): number => heights[q * m + p]!\n let off = 0\n for (let q = 0; q <= cells; q++) {\n for (let p = 0; p <= cells; p++) {\n collisionBoth(get, p, q, k)\n const h = heights[q * m + p]!\n off = Math.max(off, h - both[0]!, both[1]! - h)\n }\n }\n const field = collisionOf(heights, cells, k)\n return off + quantumOf(field, cells / k) <= (wasCoarse ? COLLISION_TOLERANCE : COLLISION_ENTER) ? { step: k, field } : fine\n}\n\n/** The most the engine's 8 bit heights may be off the field's own, over its blocks: half a step of a block's range. */\nconst quantumOf = (field: Float32Array, cells: number): number => {\n const m = cells + 1\n let most = 0\n for (let bj = 0; bj < cells; bj += ENGINE_BLOCK) {\n for (let bi = 0; bi < cells; bi += ENGINE_BLOCK) {\n let lo = Infinity, hi = -Infinity\n for (let j = bj; j <= Math.min(cells, bj + ENGINE_BLOCK); j++) {\n for (let i = bi; i <= Math.min(cells, bi + ENGINE_BLOCK); i++) {\n lo = Math.min(lo, field[j * m + i]!)\n hi = Math.max(hi, field[j * m + i]!)\n }\n }\n most = Math.max(most, (hi - lo) / 510)\n }\n }\n return most\n}\n\n/** The collision field of a tile's heights (`(cells + 1)^2`, x fastest): every `k`-th corner, `(cells / k + 1)^2` of them. */\nexport const collisionOf = (heights: Float32Array, cells: number, k: number): Float32Array => {\n if (k === 1) return heights\n const m = cells + 1\n const n = cells / k + 1\n const out = new Float32Array(n * n)\n for (let j = 0; j < n; j++) for (let i = 0; i < n; i++) out[j * n + i] = heights[j * k * m + i * k]!\n return out\n}\n\n/**\n * The collision surface at the read corner (`p`, `q`) (any integers: past the tile too), from `get` of the corners on the collision grid (multiples of `k`): the lower of the\n * two ways the engine may cut the collision cell into triangles, so whichever it uses is no lower than this.\n */\nexport const collisionAt = (get: (p: number, q: number) => number, p: number, q: number, k: number): number => {\n collisionBoth(get, p, q, k)\n return both[0]!\n}\n\n/** Where `collisionBoth` writes, the lower then the higher (one array for the module: no array per corner). */\nconst both = new Float64Array(2)\n\n/** The collision surface at the read corner (`p`, `q`) on the two ways a collision cell may be cut, into `both`: the lower then the higher. */\nconst collisionBoth = (get: (p: number, q: number) => number, p: number, q: number, k: number): void => {\n const p0 = Math.floor(p / k) * k, q0 = Math.floor(q / k) * k\n const u = (p - p0) / k, v = (q - q0) / k\n if (u === 0 && v === 0) {\n both[0] = both[1] = get(p0, q0)\n return\n }\n // on a collision cell's edge only that edge's corners are asked for (the tile's last row and column have no cell past them)\n const p1 = u === 0 ? p0 : p0 + k, q1 = v === 0 ? q0 : q0 + k\n const h00 = get(p0, q0), h10 = get(p1, q0), h01 = get(p0, q1), h11 = get(p1, q1)\n // the diagonal from (0, 0) to (1, 1), and the one from (1, 0) to (0, 1)\n const main = u >= v ? h00 + u * (h10 - h00) + v * (h11 - h10) : h00 + v * (h01 - h00) + u * (h11 - h01)\n const cross = u + v <= 1 ? h00 + u * (h10 - h00) + v * (h01 - h00) : h11 + (1 - u) * (h01 - h11) + (1 - v) * (h10 - h11)\n both[0] = Math.min(main, cross)\n both[1] = Math.max(main, cross)\n}\n\n/**\n * A tile's read heights lowered, corner by corner, to the collision surface where it is lower: a grid nothing over which (taken flat between corners, as the engine takes\n * both surfaces) rises over either surface. What must stay under the ground (the solid under it, §12) is made over this.\n */\nexport const underBoth = (heights: Float32Array, cells: number, k: number): Float32Array => {\n if (k === 1) return heights\n const m = cells + 1\n const get = (p: number, q: number): number => heights[q * m + p]!\n const out = new Float32Array(m * m)\n for (let q = 0; q <= cells; q++) for (let p = 0; p <= cells; p++) out[q * m + p] = Math.min(heights[q * m + p]!, collisionAt(get, p, q, k))\n return out\n}\n","/** How far (m) a sample may leave its cell's corners before the cell counts as holding a step. */\nexport const STEP_TOLERANCE = 0.005\n\n/**\n * Whether a cell holds a step, from its nine samples in `s`: the corners (x0 z0, x1 z0, x0 z1, x1 z1), the centre, and the middles of its edges (z0, z1, x0, x1). A step\n * moves the centre or an edge's middle off its corners. The one test the tile (`engine-ground`) and the ring past it (`engine-ground-ring`) make, so both see the same cells.\n */\nconst off = (a: number, b: number): boolean => Math.abs(a - b) > STEP_TOLERANCE\n\nexport const holdsStep = (s: ArrayLike<number>): boolean => {\n const c00 = s[0]!, c10 = s[1]!, c01 = s[2]!, c11 = s[3]!\n return off(s[4]!, (c00 + c10 + c01 + c11) / 4) || off(s[5]!, (c00 + c10) / 2) || off(s[6]!, (c01 + c11) / 2) || off(s[7]!, (c00 + c01) / 2) || off(s[8]!, (c10 + c11) / 2)\n}\n","import { collisionAt } from './engine-ground-collision'\nimport { holdsStep } from './engine-ground-step'\n\n/**\n * The ground a tile's solid reads around the tile: its own heights inside, and past its edges, as far as `SOLID_RING`, the ground the neighbour tile is made from (`groundAt`),\n * read only where a block of the solid reaches and once each. Every sample read past the edge is kept (`read`): the solid depends on them, so a change there makes it again.\n */\n\n/**\n * How far (m) past its tile's edges a block of the solid may reach: a cell of overlap, the skew of a top turned about both axes (a cell or two at the edge's block sizes), and a\n * box at least 15 cm deep at any slope (`engine-ground-solid` caps the depth of a box that would lean further). The host's changes this close to a tile make its solid again.\n */\nexport const SOLID_RING = 0.2\n/** One cell's nine samples, for `holdsStep`. */\nconst nine = new Float64Array(9)\n\n/**\n * Where the ring reads the ground past the tile's edges: the host's `groundAt`, or a band read ahead of time (`engine-ground-job` `readGroundBand`), one height per half cell\n * `(a, b)` at `(b + 2 * ring) * width + a + 2 * ring` (`width` = `2 * (cells + 2 * ring) + 1`), each the very height `groundAt` answers there. A worker has no `groundAt`.\n */\nexport type GroundSource = ((x: number, z: number) => number) | Float64Array\n\nexport interface GroundRing {\n /** How many cells the ring is wide. */\n readonly cells: number\n /** The four corners (`(i, j)`, `(i + 1, j)`, `(i, j + 1)`, `(i + 1, j + 1)`) of a cell past the tile's edge into `out`; a cell holding a step (`holdsStep`, as the neighbour builds it) has its lowest of nine samples at all four. */\n cell(i: number, j: number, out: Float64Array): void\n /** The samples read past the edge: x, z and height, three numbers each. */\n readonly read: number[]\n}\n\n// the samples and cells read for the ring being made, marked by the build they belong to (one at a time), so a ring costs no new arrays\nlet build = 0\nlet heldSamples = new Float64Array(0)\nlet sampleBuild = new Uint32Array(0)\nlet heldCells = new Float64Array(0)\nlet cellBuild = new Uint32Array(0)\n\n/**\n * `heights` are the tile's own (already under its collision field), `fieldStep` how many read cells a neighbour's coarse collision cell spans: past the edge a corner is the lower of\n * the ground there and that coarse field at it (the neighbour collides with it or with the ground itself).\n */\nexport const createGroundRing = (heights: Float32Array, cells: number, x0: number, z0: number, cell: number, groundAt: GroundSource, fieldStep = 1): GroundRing => {\n const band = typeof groundAt === 'function' ? null : groundAt\n const ring = Math.round(SOLID_RING / cell)\n const m = cells + 1\n const width = 2 * (cells + 2 * ring) + 1\n const across = cells + 2 * ring\n if (sampleBuild.length < width * width) {\n heldSamples = new Float64Array(width * width)\n sampleBuild = new Uint32Array(width * width)\n }\n if (cellBuild.length < across * across) {\n heldCells = new Float64Array(4 * across * across)\n cellBuild = new Uint32Array(across * across)\n }\n const mark = ++build\n const read: number[] = []\n /** The ground at the half cell (`a` / 2, `b` / 2): the tile's own height at its corners, the neighbour's ground elsewhere. */\n const half = (a: number, b: number): number => {\n if (a % 2 === 0 && b % 2 === 0 && a >= 0 && b >= 0 && a <= 2 * cells && b <= 2 * cells) return heights[(b / 2) * m + a / 2]!\n const key = (b + 2 * ring) * width + a + 2 * ring\n if (sampleBuild[key] === mark) return heldSamples[key]!\n const x = x0 + (a / 2) * cell\n const z = z0 + (b / 2) * cell\n const h = band === null ? (groundAt as (x: number, z: number) => number)(x, z) : band[key]!\n heldSamples[key] = h\n sampleBuild[key] = mark\n read.push(x, z, h)\n return h\n }\n /** The ground at the read corner (`p`, `q`). */\n const fine = (p: number, q: number): number => half(2 * p, 2 * q)\n return {\n cells: ring,\n read,\n cell(i, j, out) {\n const key = (j + ring) * across + i + ring\n if (cellBuild[key] !== mark) {\n const a = 2 * i, b = 2 * j\n nine[0] = half(a, b)\n nine[1] = half(a + 2, b)\n nine[2] = half(a, b + 2)\n nine[3] = half(a + 2, b + 2)\n nine[4] = half(a + 1, b + 1)\n nine[5] = half(a + 1, b)\n nine[6] = half(a + 1, b + 2)\n nine[7] = half(a, b + 1)\n nine[8] = half(a + 2, b + 1)\n // a cell the neighbour builds as a step: where the step runs in it is not known, so the ground there is no lower than its lowest sample\n const step = holdsStep(nine)\n let floor = Infinity\n for (let k = 0; k < 9; k++) floor = Math.min(floor, nine[k]!)\n const corner = (p: number, q: number, h: number): number => (fieldStep === 1 ? h : Math.min(h, collisionAt(fine, p, q, fieldStep)))\n const c00 = corner(i, j, nine[0]!), c10 = corner(i + 1, j, nine[1]!), c01 = corner(i, j + 1, nine[2]!), c11 = corner(i + 1, j + 1, nine[3]!)\n heldCells[4 * key] = step ? floor : c00\n heldCells[4 * key + 1] = step ? floor : c10\n heldCells[4 * key + 2] = step ? floor : c01\n heldCells[4 * key + 3] = step ? floor : c11\n cellBuild[key] = mark\n }\n for (let k = 0; k < 4; k++) out[k] = heldCells[4 * key + k]!\n },\n }\n}\n","import type { GroundRing } from './engine-ground-ring'\n\n/**\n * How far a turned box rises above the ground, over every column it has a point in, its leaning sides as much as its top: what it must be lowered by to be under the ground\n * everywhere (§12). The ground between a cell's corners is flat (the engine's two triangles, or bilinear), so a plane rises over it the most at a corner.\n * - Its top: the top's plane over every corner under the top's extent.\n * - Its sides, which lean uphill under the top: the box is its top slid down along -n, so where the ground over the box's shadow is nowhere steeper than the top's slope\n * allows (1 / its slope), no point of it is further over the ground than its top is. Else every cell of the shadow: a column's highest point is under each face that\n * looks up (the top, and the uphill side of each tilted axis), so over a cell under the lowest of those planes, found from the top down over a pyramid of planes under the\n * tile's ground (a block of cells whose plane is above every plane of the box over it is skipped whole).\n * - Past the tile's edges, every cell of the shadow there, over the ring's ground (`engine-ground-ring`).\n */\n\n/** A box: its centre, axes (x, y, z: the y axis is the normal of its top) and half sizes. */\nexport interface ReachBox {\n readonly c: ArrayLike<number>\n readonly axes: ReadonlyArray<ArrayLike<number>>\n readonly half: ArrayLike<number>\n}\n\n/**\n * Under each block of 2^l by 2^l cells (l from 1 up to one block over the whole tile), a plane no sample of the block is under: the block's corner slopes, lowered to its\n * lowest sample. Three numbers a block (its height at the block's first corner, and its slopes along x and z per cell), made when first asked for: over a slope or a\n * crater's wall the plane follows the ground, so a box whose planes are under it there is skipped whole.\n */\nexport interface LowPyramid {\n readonly heights: Float32Array\n readonly cells: number\n readonly sizes: readonly number[]\n readonly planes: readonly Float64Array[]\n /** The square of the steepest the ground is (m per m, any way) over each block: a cell's from its edges (its two triangles, or bilinear, are no steeper), a block's the steepest of its four. */\n readonly steepest: readonly Float64Array[]\n}\n\nexport const buildLowPyramid = (heights: Float32Array, cells: number, cell: number): LowPyramid => {\n const m = cells + 1\n const first = new Float64Array(cells * cells)\n for (let j = 0; j < cells; j++) {\n for (let i = 0; i < cells; i++) {\n const h00 = heights[j * m + i]!, h10 = heights[j * m + i + 1]!, h01 = heights[(j + 1) * m + i]!, h11 = heights[(j + 1) * m + i + 1]!\n const dx = Math.max(Math.abs(h10 - h00), Math.abs(h11 - h01)), dz = Math.max(Math.abs(h01 - h00), Math.abs(h11 - h10))\n first[j * cells + i] = (dx * dx + dz * dz) / (cell * cell)\n }\n }\n const sizes: number[] = [cells]\n const planes: Float64Array[] = [new Float64Array(0)]\n const steepest: Float64Array[] = [first]\n for (let s = 2; s < 2 * cells; s *= 2) {\n const below = steepest[steepest.length - 1]!\n const n = sizes[sizes.length - 1]!\n const k = Math.ceil(cells / s)\n const level = new Float64Array(k * k)\n for (let j = 0; j < n; j++) for (let i = 0; i < n; i++) level[(j >> 1) * k + (i >> 1)] = Math.max(level[(j >> 1) * k + (i >> 1)]!, below[j * n + i]!)\n sizes.push(k)\n planes.push(new Float64Array(3 * k * k).fill(NaN))\n steepest.push(level)\n }\n return { heights, cells, sizes, planes, steepest }\n}\n\n/** Whether the ground is steeper than `limit` (m per m) anywhere over the cells `ia`..`ib` (not included) by `ja`..`jb`. */\n// the question `steeperOver` is asking, for `visit` (one at a time)\nlet steepPyramid: LowPyramid | null = null\nlet steepSquare = 0\nlet steepIa = 0, steepIb = 0, steepJa = 0, steepJb = 0\n\nconst visit = (l: number, bi: number, bj: number): boolean => {\n const pyramid = steepPyramid!\n if (pyramid.steepest[l]![bj * pyramid.sizes[l]! + bi]! <= steepSquare) return false\n const s = 1 << l\n const a = bi * s, c = bj * s\n const b = Math.min(pyramid.cells, a + s), d = Math.min(pyramid.cells, c + s)\n if (a >= steepIb || b <= steepIa || c >= steepJb || d <= steepJa) return false\n if (l === 0) return true\n for (let dj = 0; dj < 2; dj++) for (let di = 0; di < 2; di++) if (visit(l - 1, 2 * bi + di, 2 * bj + dj)) return true\n return false\n}\n\nconst steeperOver = (pyramid: LowPyramid, ia: number, ib: number, ja: number, jb: number, limit: number): boolean => {\n steepPyramid = pyramid\n steepSquare = limit * limit\n steepIa = ia\n steepIb = ib\n steepJa = ja\n steepJb = jb\n const steeper = visit(pyramid.sizes.length - 1, 0, 0)\n // the last pyramid is not kept past the call (§8)\n steepPyramid = null\n return steeper\n}\n\n/** Where the plane under the block (`bi`, `bj`) of level `l` is in `pyramid.planes[l]`, made now if it was not. */\nconst planeUnder = (pyramid: LowPyramid, l: number, bi: number, bj: number): number => {\n const level = pyramid.planes[l]!\n const at = 3 * (bj * pyramid.sizes[l]! + bi)\n if (!Number.isNaN(level[at]!)) return at\n const { heights, cells } = pyramid\n const m = cells + 1\n const s = 1 << l\n const ia = bi * s, ja = bj * s, ib = Math.min(cells, ia + s), jb = Math.min(cells, ja + s)\n const h00 = heights[ja * m + ia]!, h10 = heights[ja * m + ib]!, h01 = heights[jb * m + ia]!, h11 = heights[jb * m + ib]!\n const sx = (h10 - h00 + h11 - h01) / 2 / (ib - ia), sz = (h01 - h00 + h11 - h10) / 2 / (jb - ja)\n let under = 0\n for (let j = ja; j <= jb; j++) for (let i = ia; i <= ib; i++) under = Math.min(under, heights[j * m + i]! - (h00 + sx * (i - ia) + sz * (j - ja)))\n level[at] = h00 + under\n level[at + 1] = sx\n level[at + 2] = sz\n return at\n}\n\nexport interface ReachTile {\n readonly heights: Float32Array\n readonly cells: number\n readonly x0: number\n readonly z0: number\n readonly cell: number\n readonly pyramid: LowPyramid\n readonly ring: GroundRing\n}\n\nexport interface Reach {\n /** The most the box rises over the ground of the tile's cells (0 when it is nowhere above), and over the ring's cells past its edges. */\n readonly tile: number\n readonly ring: number\n}\n\nconst corner4 = new Float64Array(4)\n/** A block whose bound is within this (m) of the most found is skipped: the heights are 32 bit floats, and a plane through them is that close to a plane under them. */\nconst PRUNE_SLACK = 1e-6\n// one box at a time: its planes (a, bx, bz each), the directions of its shadow's sides (x, z each) and its extent along each (low, high)\nconst planes = new Float64Array(9)\nconst dirs = new Float64Array(10)\nconst spans = new Float64Array(10)\nlet planeCount = 0\nlet dirCount = 0\n\n/** Whether the rectangle and the box's shadow are apart along one of its sides' directions. */\nconst apart = (xa: number, xb: number, za: number, zb: number): boolean => {\n for (let d = 0; d < dirCount; d += 2) {\n const dx = dirs[d]!, dz = dirs[d + 1]!\n const lo = (dx > 0 ? xa * dx : xb * dx) + (dz > 0 ? za * dz : zb * dz)\n const hi = (dx > 0 ? xb * dx : xa * dx) + (dz > 0 ? zb * dz : za * dz)\n if (hi < spans[d]! - 1e-9 || lo > spans[d + 1]! + 1e-9) return true\n }\n return false\n}\n\n/** The least, over the box's planes, of the most each rises over the four corner heights (`corner4`) of the rectangle. */\nconst over = (xa: number, xb: number, za: number, zb: number): number => {\n let best = Infinity\n for (let p = 0; p < planeCount; p += 3) {\n const a = planes[p]!, bx = planes[p + 1]!, bz = planes[p + 2]!\n const most = Math.max(a + bx * xa + bz * za - corner4[0]!, a + bx * xb + bz * za - corner4[1]!, a + bx * xa + bz * zb - corner4[2]!, a + bx * xb + bz * zb - corner4[3]!)\n if (most < best) best = most\n }\n return best\n}\n\n// the tile and box `search` walks (one at a time): the top's own extent in cells (from, to along x, then z), and the most found so far\nlet searchTile: ReachTile | null = null\nconst searchTop = new Int32Array(4)\nlet searchMost = 0\n\n/** The cell (`ia`, `ja`): its corners, and how far the box rises over them. */\nconst leaf = (ia: number, ja: number): void => {\n const { heights, cells, x0, z0, cell } = searchTile!\n const m = cells + 1\n const xa = x0 + ia * cell, za = z0 + ja * cell\n corner4[0] = heights[ja * m + ia]!\n corner4[1] = heights[ja * m + ia + 1]!\n corner4[2] = heights[(ja + 1) * m + ia]!\n corner4[3] = heights[(ja + 1) * m + ia + 1]!\n const e = over(xa, xa + cell, za, za + cell)\n if (e > searchMost) searchMost = e\n}\n\n/** The block (`bi`, `bj`) of level `l`, skipped when the box is apart from it or no higher over its low plane than the most found already, else its four. */\nconst search = (l: number, bi: number, bj: number): void => {\n const { cells, x0, z0, cell, pyramid } = searchTile!\n const s = 1 << l\n const ia = bi * s, ja = bj * s\n if (ia >= cells || ja >= cells) return\n const ib = Math.min(cells, ia + s), jb = Math.min(cells, ja + s)\n if (ia >= searchTop[0]! && ib <= searchTop[1]! && ja >= searchTop[2]! && jb <= searchTop[3]!) return\n const xa = x0 + ia * cell, xb = x0 + ib * cell, za = z0 + ja * cell, zb = z0 + jb * cell\n if (apart(xa, xb, za, zb)) return\n if (l === 0) return leaf(ia, ja)\n const level = pyramid.planes[l]!\n const at = planeUnder(pyramid, l, bi, bj)\n const h = level[at]!, sx = level[at + 1]!, sz = level[at + 2]!\n corner4[0] = h\n corner4[1] = h + sx * (ib - ia)\n corner4[2] = h + sz * (jb - ja)\n corner4[3] = h + sx * (ib - ia) + sz * (jb - ja)\n if (over(xa, xb, za, zb) <= searchMost + PRUNE_SLACK) return\n for (let dj = 0; dj < 2; dj++) for (let di = 0; di < 2; di++) search(l - 1, 2 * bi + di, 2 * bj + dj)\n}\n\nexport const reachOf = (box: ReachBox, t: ReachTile): Reach => {\n const { heights, cells, x0, z0, cell, pyramid, ring } = t\n const m = cells + 1\n // the planes over the box's columns, y <= a + bx x + bz z: one per axis, the face of it that looks up\n planeCount = 0\n for (let k = 0; k < 3; k++) {\n const a = box.axes[k]!\n if (Math.abs(a[1]!) < 1e-9) continue\n const bx = -a[0]! / a[1]!, bz = -a[2]! / a[1]!\n planes[planeCount++] = box.c[1]! + box.half[k]! / Math.abs(a[1]!) - bx * box.c[0]! - bz * box.c[2]!\n planes[planeCount++] = bx\n planes[planeCount++] = bz\n }\n // the box's shadow as a convex polygon: its extent along x, z and across each axis seen from above\n dirs[0] = 1\n dirs[1] = 0\n dirs[2] = 0\n dirs[3] = 1\n dirCount = 4\n for (const a of box.axes) {\n const l = Math.hypot(a[0]!, a[2]!)\n if (l < 1e-9) continue\n dirs[dirCount++] = -a[2]! / l\n dirs[dirCount++] = a[0]! / l\n }\n for (let d = 0; d < dirCount; d += 2) {\n const dx = dirs[d]!, dz = dirs[d + 1]!\n let r = 0\n for (let k = 0; k < 3; k++) r += box.half[k]! * Math.abs(box.axes[k]![0]! * dx + box.axes[k]![2]! * dz)\n const mid = box.c[0]! * dx + box.c[2]! * dz\n spans[d] = mid - r\n spans[d + 1] = mid + r\n }\n let inTile = 0\n // under the top's own extent, the top's plane over every corner (each cell's most is at a corner): the most found there skips most of the rest\n const n = box.axes[1]!, ax = box.axes[0]!, az = box.axes[2]!\n const tx = box.c[0]! + n[0]! * box.half[1]!, ty = box.c[1]! + n[1]! * box.half[1]!, tz = box.c[2]! + n[2]! * box.half[1]!\n const rx = box.half[0]! * Math.abs(ax[0]!) + box.half[2]! * Math.abs(az[0]!), rz = box.half[0]! * Math.abs(ax[2]!) + box.half[2]! * Math.abs(az[2]!)\n const ta = Math.max(0, Math.floor((tx - rx - x0) / cell)), tb = Math.min(cells, Math.ceil((tx + rx - x0) / cell))\n const sa = Math.max(0, Math.floor((tz - rz - z0) / cell)), sb = Math.min(cells, Math.ceil((tz + rz - z0) / cell))\n const bx = -n[0]! / n[1]!, bz = -n[2]! / n[1]!\n for (let j = sa; j <= sb; j++) {\n for (let i = ta; i <= tb; i++) {\n const e = ty + bx * (x0 + i * cell - tx) + bz * (z0 + j * cell - tz) - heights[j * m + i]!\n if (e > inTile) inTile = e\n }\n }\n // the box is its top slid down along -n: a point of it a slide s from the top at q stands s n_y under the top, over ground at most s |n_h| (the steepest) under q's.\n // Where the ground is nowhere steeper than 1 / (its top's slope), no point of the box is further over the ground than its top over its own extent (all in the tile)\n const ia = Math.floor((spans[0]! - x0) / cell), ib = Math.ceil((spans[1]! - x0) / cell)\n const ja = Math.floor((spans[2]! - z0) / cell), jb = Math.ceil((spans[3]! - z0) / cell)\n const within = ia >= 0 && ja >= 0 && ib <= cells && jb <= cells\n if (within && !steeperOver(pyramid, ia, ib, ja, jb, n[1]! / Math.max(1e-12, Math.hypot(n[0]!, n[2]!)))) return { tile: inTile, ring: 0 }\n searchTile = t\n searchTop[0] = ta\n searchTop[1] = tb\n searchTop[2] = sa\n searchTop[3] = sb\n searchMost = inTile\n // else every cell of its shadow, from the level whose blocks are as wide as the shadow's extent along x and z, over the (at most four) of them it covers\n const ua = Math.max(0, ia), ub = Math.min(cells, ib), va = Math.max(0, ja), vb = Math.min(cells, jb)\n if (ua < ub && va < vb) {\n let l = 0\n while (1 << l < Math.max(ub - ua, vb - va) && l < pyramid.sizes.length - 1) l++\n for (let bj = va >> l; bj <= (vb - 1) >> l; bj++) for (let bi = ua >> l; bi <= (ub - 1) >> l; bi++) search(l, bi, bj)\n }\n inTile = searchMost\n // the last tile (and the host's ground its ring holds) is not kept past the call (§8)\n searchTile = null\n // past the edges: the ring's cells the shadow's extent reaches\n let inRing = 0\n const r = ring.cells\n if (within) return { tile: inTile, ring: 0 }\n for (let j = Math.max(-r, ja); j < Math.min(cells + r, jb); j++) {\n const across = j >= 0 && j < cells\n for (let i = Math.max(-r, ia); i < Math.min(cells + r, ib); i++) {\n // over the tile, along the row: on to its far edge\n if (across && i >= 0 && i < cells) i = cells\n if (i >= Math.min(cells + r, ib)) break\n const xa = x0 + i * cell, za = z0 + j * cell\n if (apart(xa, xa + cell, za, za + cell)) continue\n ring.cell(i, j, corner4)\n const e = over(xa, xa + cell, za, za + cell)\n if (e > inRing) inRing = e\n }\n }\n return { tile: inTile, ring: inRing }\n}\n","import { coarseStep, underBoth } from './engine-ground-collision'\nimport { createGroundRing } from './engine-ground-ring'\nimport type { GroundSource } from './engine-ground-ring'\nimport { buildLowPyramid, reachOf } from './engine-ground-reach'\n\n/**\n * The solid under a height field. Jolt's height field is a surface: a body that ends up wholly below it (ground raised under a sleeping piece, a piece that\n * tunnelled) has nothing to push it out and falls for good. Under the surface of a tile there are blocks, from the lowest ground of the tile less `SOLID_DEPTH`\n * up to a top close under the surface and never above it (§12). A block is split until a plane through its corners is within `SOLID_RELIEF` of the surface or it is\n * `SOLID_MIN_CELLS` cells wide. A level block is a box topped at its lowest ground less `SOLID_MARGIN`; a sloped block is one box turned to its corner plane, its top that\n * plane over the block and a cell past it each way (turned boxes side by side lean apart under their tops: what is pushed out sideways meets the next one), lowered by the\n * most any point of it, top or leaning side, rises over the ground under it (`engine-ground-reach`) and `SOLID_MARGIN`. Where it reaches past the tile, the ground there is\n * the neighbour's (`engine-ground-ring`), read up to `SOLID_RING` out; a box that would lean further is made shallower. Under each turned box is its block's upright box\n * (topped at the block's lowest ground less `SOLID_MARGIN`): turned boxes side by side part under their tops, and what slips between them rests on it, its top no further\n * under the ground than the block's relief and its own size.\n * Every block is boxes: a sloped one used to be a prism (a convex hull each), and a crater tile's 400 hulls were most of the frame after the blast (T3.8ag).\n */\n\n/** How far (m) under the lowest corner of its tile the solid goes. */\nexport const SOLID_DEPTH = 0.5\n/** How far (m) under the surface a block's top may be before the block is split, unless it is already `SOLID_MIN_CELLS` cells wide. */\nconst SOLID_RELIEF = 0.005\nconst SOLID_MIN_CELLS = 3\n/**\n * A top is this far (m) under the lowest ground it stands for: 2 mm put the solid in the contacts of what rests on the surface and the bowl's seed 18 gained 4 cm. The engine\n * holds a height field's samples in 8 bit steps of each 4-sample block's range, up to half a step off (range / 510: 0.15 mm on a 0.75 slope at 2.5 cm, 0.3 mm at 5 cm), well\n * inside this margin.\n */\nexport const SOLID_MARGIN = 0.005\n/** The thinnest (m) a turned box is made; where that would lean past the ring, the block is split, or (at its smallest) left to its upright box. */\nconst SOLID_THINNEST = 0.05\n/** How much (m) more a block's box must be lowered for the ground past the tile than for its own before the block is split, so a fold at the seam lowers a narrow box only. */\nconst SEAM_SPLIT = 0.01\n/** Numbers per block in `SolidVolume.boxes`. */\nexport const SOLID_STRIDE = 10\n\nexport interface SolidVolume {\n /** The blocks: centre x, y, z, half x, y, z and turn x, y, z, w (`SOLID_STRIDE` numbers each); the box's own y is the normal of its top. */\n readonly boxes: readonly number[] | Float64Array\n /** The ground read past the tile's edges, x, z and height each (`engine-ground-ring`): the blocks are made again when one of these changes. */\n readonly ring: readonly number[] | Float64Array\n}\n\nexport const NO_SOLID: SolidVolume = { boxes: [], ring: [] }\n\n/** The unit vector along (x, y, z), into `out`. */\nconst unitInto = (out: Float64Array, x: number, y: number, z: number): Float64Array => {\n const l = Math.hypot(x, y, z)\n out[0] = x / l\n out[1] = y / l\n out[2] = z / l\n return out\n}\n\n// one block at a time: its corner plane's slopes, and the box the reach is asked about (filled in place, no arrays per block)\nconst slopes = new Float64Array(2)\nconst reachAxes = [new Float64Array(3), new Float64Array(3), new Float64Array(3)] as const\nconst reachBox = { c: new Float64Array(3), axes: [reachAxes[0], reachAxes[1], reachAxes[2]], half: new Float64Array(3) }\n\n/** The quaternion of the turn whose columns are the axes `a` (x), `b` (y) and `c` (z). */\nconst quatOfAxes = (a: ArrayLike<number>, b: ArrayLike<number>, c: ArrayLike<number>): [number, number, number, number] => {\n const m00 = a[0]!, m10 = a[1]!, m20 = a[2]!, m01 = b[0]!, m11 = b[1]!, m21 = b[2]!, m02 = c[0]!, m12 = c[1]!, m22 = c[2]!\n const trace = m00 + m11 + m22\n if (trace > 0) {\n const s = 0.5 / Math.sqrt(trace + 1)\n return [(m21 - m12) * s, (m02 - m20) * s, (m10 - m01) * s, 0.25 / s]\n }\n if (m00 > m11 && m00 > m22) {\n const s = 2 * Math.sqrt(1 + m00 - m11 - m22)\n return [0.25 * s, (m01 + m10) / s, (m02 + m20) / s, (m21 - m12) / s]\n }\n if (m11 > m22) {\n const s = 2 * Math.sqrt(1 + m11 - m00 - m22)\n return [(m01 + m10) / s, 0.25 * s, (m12 + m21) / s, (m02 - m20) / s]\n }\n const s = 2 * Math.sqrt(1 + m22 - m00 - m11)\n return [(m02 + m20) / s, (m12 + m21) / s, 0.25 * s, (m10 - m01) / s]\n}\n\n/** How thick (m) a box whose bottom moves by `lean` per metre of thickness may be and stay within `lo`..`hi`, its top spanning `low`..`high` (no thickness when the top does not fit). */\nconst thickWithin = (lean: number, low: number, high: number, lo: number, hi: number): number => {\n if (low < lo || high > hi) return -Infinity\n return lean > 1e-12 ? (hi - high) / lean : lean < -1e-12 ? (low - lo) / -lean : Infinity\n}\n\n/**\n * The blocks under a tile of `cells` cells of side `cell` from (`x0`, `z0`), over its `read` heights (`(cells + 1)^2`, x fastest) and the engine's coarser collision field of\n * them (`step`: every how many corners it is), and the ground around it (`groundAt`, read only past the tile's edges, up to `SOLID_RING`, and its collision field there too).\n */\nexport const buildSolidVolume = (read: Float32Array, cells: number, x0: number, z0: number, cell: number, groundAt: GroundSource, step = 1): SolidVolume => {\n // under the drawn ground and the engine's collision field (every `step`-th corner, `engine-ground-collision`) both, whichever is lower at each corner\n const heights = underBoth(read, cells, step)\n const m = cells + 1\n let low = Infinity\n for (const h of heights) low = Math.min(low, h)\n const bottom = low - SOLID_DEPTH\n const boxes: number[] = []\n // past the edge, under the neighbour's coarse field too, whichever it collides with\n const ring = createGroundRing(heights, cells, x0, z0, cell, groundAt, coarseStep(cells, cell))\n const reachTile = { heights, cells, x0, z0, cell, pyramid: buildLowPyramid(heights, cells, cell), ring }\n const outer = ring.cells * cell\n const loX = x0 - outer, hiX = x0 + cells * cell + outer, loZ = z0 - outer, hiZ = z0 + cells * cell + outer\n const at = (i: number, j: number): number => heights[j * m + i]!\n /** The slopes (per cell) of the plane through the block's corners, into `slopes` (x then z). */\n const slopesOf = (i0: number, j0: number, i1: number, j1: number): void => {\n slopes[0] = (at(i1, j0) - at(i0, j0) + at(i1, j1) - at(i0, j1)) / 2 / (i1 - i0)\n slopes[1] = (at(i0, j1) - at(i0, j0) + at(i1, j1) - at(i1, j0)) / 2 / (j1 - j0)\n }\n\n /** How far the surface rises above the plane through the block's corners lowered to its lowest sample: the block is split while it is more. */\n const planeGap = (i0: number, j0: number, i1: number, j1: number): number => {\n slopesOf(i0, j0, i1, j1)\n const sx = slopes[0]!, sz = slopes[1]!\n let least = Infinity\n let most = -Infinity\n for (let j = j0; j <= j1; j++) {\n for (let i = i0; i <= i1; i++) {\n const above = at(i, j) - (at(i0, j0) + sx * (i - i0) + sz * (j - j0))\n if (above < least) least = above\n if (above > most) most = above\n }\n }\n return most - least\n }\n\n /** A level block: an upright box topped at its lowest ground less `SOLID_MARGIN`. */\n const level = (i0: number, j0: number, i1: number, j1: number, least: number): void => {\n const top = least - SOLID_MARGIN\n boxes.push(x0 + ((i0 + i1) / 2) * cell, (top + bottom) / 2, z0 + ((j0 + j1) / 2) * cell, ((i1 - i0) * cell) / 2, (top - bottom) / 2, ((j1 - j0) * cell) / 2, 0, 0, 0, 1)\n }\n\n /**\n * A sloped block: one box turned to the plane through its corners, its top the rectangle on that plane over the block and a cell past it each way, down to under the\n * solid's bottom, lowered by the most it rises over the ground anywhere (`reachOf`) and `SOLID_MARGIN`. A box that would lean past the ring is made as deep as stays in\n * it (the block's upright box is under it); a box lowered by more than the block's relief is the upright box alone. False when the block should be split instead: its box would not\n * fit the ring, or the ground past the tile lowers it much more than its own.\n */\n const sloped = (i0: number, j0: number, i1: number, j1: number, least: number, most: number): boolean => {\n const span = Math.max(i1 - i0, j1 - j0)\n slopesOf(i0, j0, i1, j1)\n const gx = slopes[0]! / cell\n const gz = slopes[1]! / cell\n const ox = x0 + i0 * cell\n const oz = z0 + j0 * cell\n const base = at(i0, j0)\n // the box's axes, in the scratch the reach reads them from: n the normal of its top, ax along x up the slope, az across both\n const n = unitInto(reachAxes[1]!, -gx, 1, -gz)\n const ax = unitInto(reachAxes[0]!, 1, gx, 0)\n const az = reachAxes[2]!\n az[0] = ax[1]! * n[2]! - ax[2]! * n[1]!\n az[1] = ax[2]! * n[0]! - ax[0]! * n[2]!\n az[2] = ax[0]! * n[1]! - ax[1]! * n[0]!\n const xa = ox, xb = x0 + i1 * cell, za = oz, zb = z0 + j1 * cell\n const cx = (xa + xb) / 2, cz = (za + zb) / 2, cy = base + gx * (cx - ox) + gz * (cz - oz)\n let hx = 0\n let hz = 0\n for (let a = 0; a < 2; a++) {\n const x = a === 0 ? xa : xb\n for (let b = 0; b < 2; b++) {\n const z = b === 0 ? za : zb\n const d0 = x - cx, d1 = base + gx * (x - ox) + gz * (z - oz) - cy, d2 = z - cz\n hx = Math.max(hx, Math.abs(d0 * ax[0]! + d1 * ax[1]! + d2 * ax[2]!))\n hz = Math.max(hz, Math.abs(d0 * az[0]! + d1 * az[1]! + d2 * az[2]!))\n }\n }\n hx += cell\n hz += cell\n let minX = Infinity, maxX = -Infinity, minZ = Infinity, maxZ = -Infinity, highest = -Infinity\n for (let a = 0; a < 2; a++) {\n const su = a === 0 ? -1 : 1\n for (let b = 0; b < 2; b++) {\n const sw = b === 0 ? -1 : 1\n const qx = cx + su * hx * ax[0] + sw * hz * az[0]\n const qz = cz + su * hx * ax[2] + sw * hz * az[2]\n minX = Math.min(minX, qx)\n maxX = Math.max(maxX, qx)\n minZ = Math.min(minZ, qz)\n maxZ = Math.max(maxZ, qz)\n highest = Math.max(highest, cy + su * hx * ax[1] + sw * hz * az[1])\n }\n }\n // deep enough that its bottom face is under the solid's bottom everywhere (a box made only as deep as its block's upright box let what it pushed out the bottom through:\n // 17 of the 48 boxes of the push-up sweep fell, as with a730b5450's slab), unless its bottom would lean (uphill: by -n per metre of thickness) past the ring\n const deep = (highest - bottom) / n[1]\n const fits = Math.min(thickWithin(-n[0], minX, maxX, loX, hiX), thickWithin(-n[2], minZ, maxZ, loZ, hiZ))\n const thick = Math.max(SOLID_THINNEST, Math.min(deep, fits))\n if (fits < thick) {\n if (span > SOLID_MIN_CELLS) return false\n level(i0, j0, i1, j1, least)\n return true\n }\n const hy = thick / 2\n const centre = reachBox.c\n centre[0] = cx - n[0]! * hy\n centre[1] = cy - n[1]! * hy\n centre[2] = cz - n[2]! * hy\n reachBox.half[0] = hx\n reachBox.half[1] = hy\n reachBox.half[2] = hz\n const reach = reachOf(reachBox, reachTile)\n if (reach.ring > reach.tile + SEAM_SPLIT && span > SOLID_MIN_CELLS) return false\n const drop = SOLID_MARGIN + Math.max(reach.tile, reach.ring)\n // lowered further than the block's own relief, its top would be further under the ground than the upright box's\n if (drop - SOLID_MARGIN >= most - least) {\n level(i0, j0, i1, j1, least)\n return true\n }\n // and under it the block's upright box: what slips between two turned boxes (they part under their tops; a cell's overlap closes only so deep) rests on it, no\n // further under the ground than the block's relief\n level(i0, j0, i1, j1, least)\n const q = quatOfAxes(ax, n, az)\n boxes.push(centre[0]!, centre[1]! - drop, centre[2]!, hx, hy, hz, q[0], q[1], q[2], q[3])\n return true\n }\n\n const fill = (i0: number, j0: number, i1: number, j1: number): void => {\n let least = Infinity\n let most = -Infinity\n for (let j = j0; j <= j1; j++) {\n for (let i = i0; i <= i1; i++) {\n const h = at(i, j)\n if (h < least) least = h\n if (h > most) most = h\n }\n }\n if (most - least <= SOLID_RELIEF) return level(i0, j0, i1, j1, least)\n const span = Math.max(i1 - i0, j1 - j0)\n if ((planeGap(i0, j0, i1, j1) > SOLID_RELIEF && span > SOLID_MIN_CELLS) || !sloped(i0, j0, i1, j1, least, most)) {\n // in halves (a side under two cells stays whole), x's halves first\n const im = i1 - i0 < 2 ? i1 : (i0 + i1) >> 1\n const jm = j1 - j0 < 2 ? j1 : (j0 + j1) >> 1\n for (let a = i0; a < i1; a = im) {\n const b = a === i0 ? im : i1\n for (let d = j0; d < j1; d = jm) {\n const e = d === j0 ? jm : j1\n fill(a, d, b, e)\n if (e === j1) break\n }\n if (b === i1) break\n }\n }\n }\n fill(0, 0, cells, cells)\n return { boxes, ring: ring.read }\n}\n\n/** The same blocks. */\nexport const sameSolid = (a: SolidVolume, b: SolidVolume): boolean => same(a.boxes, b.boxes)\n\n/** The same numbers, in order (plain or typed arrays alike). */\nexport const sameNumbers = (a: ArrayLike<number>, b: ArrayLike<number>): boolean => {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false\n return true\n}\n\nconst same = sameNumbers\n","import type { HeightPatch } from '@adatechnology/game-terrain'\n\nimport { NO_SOLID, buildSolidVolume } from './engine-ground-solid'\nimport type { SolidVolume } from './engine-ground-solid'\nimport { collisionFieldOf } from './engine-ground-collision'\nimport { holdsStep } from './engine-ground-step'\n\n/**\n * The ground a physics engine stands the pieces on, one tile of `groundAt` at a time: a height field over the cell corners for what is smooth, and solid boxes\n * for the cells a hard step runs through (a crater's rim, a terraced slope) and the cells around them. A box's top is its cell's centre height and its\n * sides are vertical, so a step keeps its edge (within half a cell of where it is) instead of a ramp one cell wide; under the boxes the height field is lowered so\n * it does not ramp up through them. A level tile is one slab, solid below.\n *\n * Why not triangles: the step-keeping triangle mesh this replaces was one-sided (a thin piece pressed half through a triangle fell through for good) and had to be\n * made again, as a new body, for every change, which threw away the engine's contact cache. A height field of the same tile is made in about 0.3 ms and can be\n * swapped on the same body (`EnginePieces`), so the pieces on it keep their contacts.\n *\n * The tile is read at `GROUND_CELL`; the engine collides with every second corner of it, a 5 cm field (`engine-ground-collision`, owner decision 2026-11-17), and the solid\n * under it stays under both.\n */\n\n/** Cells of a tile (m), as Rapier's spike measured good enough for a 4 cm plate. */\nexport const GROUND_CELL = 0.025\n/** How far (m) under the lowest ground around them the step boxes go, and how far the height field drops under them. */\nconst BOX_DEPTH = 0.05\nconst UNDER_BOX = 0.01\n\nexport interface GroundTile {\n /** Corner heights, `(cells + 1)^2`, x fastest: `heights[iz * (cells + 1) + ix]`. Empty when the tile is level. */\n readonly heights: Float32Array\n readonly cells: number\n /** The height field the engine collides with (`engine-ground-collision`): every `cells / collisionCells`-th corner of `heights`, `(collisionCells + 1)^2`. Empty when level. */\n readonly collision: Float32Array\n readonly collisionCells: number\n /** The step boxes: centre x, y, z and half x, y, z, six numbers each (a typed array when the tile came from a worker, `engine-ground-job`). */\n readonly boxes: readonly number[] | Float64Array\n /** The solid under the height field (`engine-ground-solid`); none when the tile is level (a slab is solid already). */\n readonly solid: SolidVolume\n /** The height of a level tile (every sample equal), or null. */\n readonly level: number | null\n /** Every sample read, to tell whether the ground changed since; null for a tile proved level from the terrain's own bounds (`flatTile`), whose samples were never read. */\n readonly samples: Float64Array | null\n /** The terrain's vertices the tile was made from (`readGroundPatch`; its samples are then null): what tells whether the ground changed since. */\n readonly patch?: HeightPatch\n}\n\nconst NO_HEIGHTS = new Float32Array(0)\n/** One cell's nine samples, for `holdsStep`. */\nconst cellSamples = new Float64Array(9)\n\n/** The tile of a level `size` at `level`, laid without a sample read: the caller has proved, from the ground's own data, that every sample there is `level` (to 1e-9, as `shapeGround` calls level). */\nexport const flatTile = (level: number, size: number): GroundTile => ({ heights: NO_HEIGHTS, cells: Math.round(size / GROUND_CELL), collision: NO_HEIGHTS, collisionCells: 0, boxes: [], solid: NO_SOLID, level, samples: null })\n\n/** A rectangle of the ground, world x and z. */\nexport interface GroundRect {\n readonly minX: number\n readonly maxX: number\n readonly minZ: number\n readonly maxZ: number\n}\n\n/**\n * The four series of samples of a tile, one after the other in `samples`: the corners, the cells' centres, the middles of the edges along x and those along z.\n * `ox` and `oz` are where the series sits in a cell (0 or half), `width` and `rows` how many samples it has along x and along z.\n */\nconst seriesOf = (n: number): ReadonlyArray<{ offset: number; width: number; rows: number; ox: number; oz: number }> => {\n const m = n + 1\n return [\n { offset: 0, width: m, rows: m, ox: 0, oz: 0 },\n { offset: m * m, width: n, rows: n, ox: 0.5, oz: 0.5 },\n { offset: m * m + n * n, width: n, rows: m, ox: 0.5, oz: 0 },\n { offset: m * m + n * n + n * m, width: m, rows: n, ox: 0, oz: 0.5 },\n ]\n}\n\n/** The `samples` array of a tile of `n` cells. */\nexport const sampleCount = (n: number): number => (n + 1) * (n + 1) + n * n + 2 * n * (n + 1)\n\n/**\n * The ground over a lattice in one pass: the height at (`xs[i]`, `zs[j]`) into `out[j * xs.length + i]`, to the bit what the tile's `groundAt` answers at each point\n * (`Terrain.heightGrid` is one). A tile reads its 26 000 samples through it instead of a call each.\n */\nexport type GroundGrid = (xs: ArrayLike<number>, zs: ArrayLike<number>, out: Float64Array) => void\n\n// the points a grid read asks for and what it answers, kept between reads (one at a time) so a read does not make them again\nlet seriesX = new Float64Array(0)\nlet seriesZ = new Float64Array(0)\nlet seriesHeights = new Float64Array(0)\n\n/**\n * Reads the ground of the tile at (x0, z0) into `samples`: every sample, or only those a rectangle reaches (a sample a cell outside it is read too, so what the\n * rectangle's edge touches is not left old). True when a sample read differs from the one held. A crater in a corner of a tile asks `groundAt` for the corner.\n * With a `grid` each series is read in one pass over its own points, each the one `groundAt` would be asked for (`x0 + (i + ox) * c`), so the same heights.\n * Not reentrant: the points are module scratch, so neither reader may read a tile in turn.\n */\nexport const readGround = (groundAt: (x: number, z: number) => number, samples: Float64Array, x0: number, z0: number, size: number, rect?: GroundRect, grid?: GroundGrid): boolean => {\n const n = Math.round(size / GROUND_CELL)\n const c = size / n\n let changed = false\n for (const { offset, width, rows, ox, oz } of seriesOf(n)) {\n const i0 = rect ? Math.max(0, Math.floor((rect.minX - x0) / c - ox)) : 0\n const i1 = rect ? Math.min(width - 1, Math.ceil((rect.maxX - x0) / c - ox)) : width - 1\n const j0 = rect ? Math.max(0, Math.floor((rect.minZ - z0) / c - oz)) : 0\n const j1 = rect ? Math.min(rows - 1, Math.ceil((rect.maxZ - z0) / c - oz)) : rows - 1\n if (i0 > i1 || j0 > j1) continue\n if (!grid) {\n for (let j = j0; j <= j1; j++) {\n for (let i = i0; i <= i1; i++) {\n const h = groundAt(x0 + (i + ox) * c, z0 + (j + oz) * c)\n if (samples[offset + j * width + i] !== h) changed = true\n samples[offset + j * width + i] = h\n }\n }\n continue\n }\n const across = i1 - i0 + 1\n const along = j1 - j0 + 1\n if (seriesX.length < across) seriesX = new Float64Array(across)\n if (seriesZ.length < along) seriesZ = new Float64Array(along)\n if (seriesHeights.length < across * along) seriesHeights = new Float64Array(across * along)\n for (let i = 0; i < across; i++) seriesX[i] = x0 + (i0 + i + ox) * c\n for (let j = 0; j < along; j++) seriesZ[j] = z0 + (j0 + j + oz) * c\n grid(seriesX.subarray(0, across), seriesZ.subarray(0, along), seriesHeights)\n for (let j = 0; j < along; j++) {\n const from = j * across\n const to = offset + (j0 + j) * width + i0\n if (!changed) {\n for (let i = 0; i < across; i++) {\n if (samples[to + i] !== seriesHeights[from + i]) {\n changed = true\n break\n }\n }\n }\n samples.set(seriesHeights.subarray(from, from + across), to)\n }\n }\n return changed\n}\n\nexport const buildGroundTile = (groundAt: (x: number, z: number) => number, x0: number, z0: number, size: number, withSolid = true, grid?: GroundGrid): GroundTile => {\n const samples = new Float64Array(sampleCount(Math.round(size / GROUND_CELL)))\n readGround(groundAt, samples, x0, z0, size, undefined, grid)\n return shapeGround(samples, x0, z0, size, withSolid ? groundAt : null)\n}\n\n/**\n * The tile the samples make: level, or its height field, step boxes and (given the ground, which it reads past the tile's edges; else `NO_SOLID`, for a caller that may\n * not need it) the solid under it. Pure of the samples (and that ground), so a tile made from samples patched in place is the one made from all of them read again, but\n * for its collision field near the bound, which keeps the coarse one it had (`wasCoarse`, `collisionFieldOf`).\n */\nexport const shapeGround = (samples: Float64Array, x0: number, z0: number, size: number, solidGround: ((x: number, z: number) => number) | null, wasCoarse = false): GroundTile => {\n const n = Math.round(size / GROUND_CELL)\n const c = size / n\n const m = n + 1\n const [cornerSeries, centreSeries, midXSeries, midZSeries] = seriesOf(n)\n const corners = samples.subarray(cornerSeries!.offset, centreSeries!.offset)\n const centres = samples.subarray(centreSeries!.offset, midXSeries!.offset)\n const midX = samples.subarray(midXSeries!.offset, midZSeries!.offset)\n const midZ = samples.subarray(midZSeries!.offset)\n let low = Infinity\n let high = -Infinity\n for (const h of samples) {\n low = Math.min(low, h)\n high = Math.max(high, h)\n }\n if (high - low < 1e-9) return { heights: new Float32Array(0), cells: n, collision: NO_HEIGHTS, collisionCells: 0, boxes: [], solid: NO_SOLID, level: high, samples }\n const corner = (i: number, j: number): number => corners[j * m + i]\n // a cell whose centre or an edge's middle leaves its corners holds a step; it and the cells around it become boxes\n const mask = new Uint8Array(n * n)\n for (let j = 0; j < n; j++) {\n for (let i = 0; i < n; i++) {\n cellSamples[0] = corner(i, j)\n cellSamples[1] = corner(i + 1, j)\n cellSamples[2] = corner(i, j + 1)\n cellSamples[3] = corner(i + 1, j + 1)\n cellSamples[4] = centres[j * n + i]\n cellSamples[5] = midX[j * n + i]\n cellSamples[6] = midX[(j + 1) * n + i]\n cellSamples[7] = midZ[j * m + i]\n cellSamples[8] = midZ[j * m + i + 1]\n if (!holdsStep(cellSamples)) continue\n for (let dj = -1; dj <= 1; dj++) for (let di = -1; di <= 1; di++) if (i + di >= 0 && j + dj >= 0 && i + di < n && j + dj < n) mask[(j + dj) * n + i + di] = 1\n }\n }\n const heights = new Float32Array(m * m)\n for (let j = 0; j <= n; j++) {\n for (let i = 0; i <= n; i++) {\n // a corner whose four cells are all boxes goes under the lowest of them\n let inside = true\n let least = corner(i, j)\n for (let dj = -1; dj <= 0 && inside; dj++) for (let di = -1; di <= 0; di++) {\n const ii = i + di, jj = j + dj\n if (ii < 0 || jj < 0 || ii >= n || jj >= n || !mask[jj * n + ii]) {\n inside = false\n break\n }\n least = Math.min(least, centres[jj * n + ii], corner(ii, jj), corner(ii + 1, jj), corner(ii, jj + 1), corner(ii + 1, jj + 1))\n }\n heights[j * m + i] = inside ? least - UNDER_BOX : corner(i, j)\n }\n }\n // the boxes: runs along x of masked cells at one height, down to under the lowest ground around them\n const boxes: number[] = []\n for (let j = 0; j < n; j++) {\n let i = 0\n while (i < n) {\n if (!mask[j * n + i]) {\n i++\n continue\n }\n const top = centres[j * n + i]\n let end = i + 1\n while (end < n && mask[j * n + end] && Math.abs(centres[j * n + end] - top) < 0.001) end++\n let bottom = top\n for (let k = Math.max(0, i - 1); k <= Math.min(n, end + 1); k++) for (let jj = Math.max(0, j - 1); jj <= Math.min(n, j + 2); jj++) bottom = Math.min(bottom, corner(k, jj))\n bottom -= BOX_DEPTH\n boxes.push(x0 + ((i + end) / 2) * c, (top + bottom) / 2, z0 + (j + 0.5) * c, ((end - i) * c) / 2, (top - bottom) / 2, c / 2)\n i = end\n }\n }\n const { step, field } = collisionFieldOf(heights, n, c, boxes.length > 0, wasCoarse)\n return { heights, cells: n, collision: field, collisionCells: n / step, boxes, solid: solidGround ? buildSolidVolume(heights, n, x0, z0, c, solidGround, step) : NO_SOLID, level: null, samples }\n}\n","import type * as THREE_NS from 'three'\n\nimport type { WorkerCoordinator } from '@adatechnology/game-contracts'\n\nimport type { StaticSolid } from './engine-statics'\nimport type { MeshVis } from './internal'\nimport { measureStaticPart } from './static-part-job'\nimport type { StaticPartJob } from './static-part-job'\nimport type { Visuals } from './visual'\nimport { staticCollidersKind } from './worker-kinds'\n\ntype Points = ArrayLike<number>\n\n/** What was made of a part and what it was made from: the same source at the same versions is the same vertices, so nothing is measured (or read) twice. */\ninterface Made {\n readonly matrix: readonly number[]\n readonly from: number\n readonly to: number\n /** The positions' source (`Visuals.positionsOf`) by number, so a source replaced is not kept alive by what was made of it. */\n readonly source: number\n readonly version: number\n readonly shapeVersion: number\n readonly solids: StaticSolid[]\n}\n\nconst made = new WeakMap<MeshVis, Made>()\n/** A part handed to the workers (`MeasureBudget.workers`) and not answered yet: the same numbers are not handed again. */\nconst pending = new WeakMap<MeshVis, Omit<Made, 'solids'>>()\nconst sourceIds = new WeakMap<object, number>()\nlet lastSourceId = 0\nconst sourceIdOf = (source: object): number => {\n let id = sourceIds.get(source)\n if (id === undefined) {\n id = ++lastSourceId\n sourceIds.set(source, id)\n }\n return id\n}\n/** The triangles of each range of a merged mesh, by the index buffer they were found in (one pass over the buffer for all the parts of the host). */\nconst triangles = new WeakMap<object, Map<number, number[]>>()\n\n/** What a part costs besides its vertices (in vertices) to measure from scratch. */\nconst PART_COST = 24\n\n/** How many vertices may be measured from scratch in one call (a part whose numbers did not change is not measured at all); `incomplete` is set when a part had to wait. */\nexport interface MeasureBudget {\n left: number\n incomplete: boolean\n /**\n * The meshes whose world matrix this call has brought up to date: every part of a merged house shares its host mesh, and bringing it up to date walks its parents\n * again. Nothing moves while a call measures, so once per mesh is the same matrix.\n */\n readonly updated?: Set<object>\n /**\n * The game's worker coordinator (CLAUDE.md §14): a part measured from scratch is a `destruction.static-colliders` job (lane `build`) and its object waits, as a part\n * out of turns does (`incomplete`), until the answer comes; a later call takes the part from it. Without it every part is measured here, as before.\n */\n readonly workers?: WorkerCoordinator | null\n}\n\n/** The part's vertices out of the mesh's positions, with what another drawing collapses there collapsed as drawn (each range to its first vertex). */\nconst readPoints = (array: Points, from: number, to: number, collapsed: ReadonlyArray<readonly [number, number]> = []): Float64Array => {\n const points = new Float64Array((to - from) * 3)\n for (let i = 0; i < points.length; i++) points[i] = array[from * 3 + i]\n for (const [v0, v1] of collapsed) {\n for (let k = Math.max(v0 + 1, from); k < Math.min(v1, to); k++) {\n for (let c = 0; c < 3; c++) points[(k - from) * 3 + c] = array[v0 * 3 + c]\n }\n }\n return points\n}\n\n/**\n * What a fixed drawn part collides as, in world space, for an engine: one box turned as drawn where a box fits it (every corner has a vertex within `FIT`), else the\n * triangles as drawn (`mesh`, static only). A part drawn by a range of a merged mesh (a wall of the house) is its own vertices only. Nothing is drawn where a part is\n * collapsed to a point, so nothing is made there (`CLAUDE.md` §12). `key` names the part for the engine. The same part in the same place with the same vertices gives the very same list back,\n * told by the versions of its positions (every write counts), not by reading them: a part that did not change costs no pass over its vertices.\n */\nexport const drawnSolidsOf = (THREE: typeof THREE_NS, visuals: Visuals, mv: MeshVis, key: string, budget: MeasureBudget): StaticSolid[] => {\n const local = visuals.positionsOf(mv)\n if (!local || local.to <= local.from) return []\n if (!budget.updated?.has(mv.mesh)) {\n mv.mesh.updateWorldMatrix(true, false)\n budget.updated?.add(mv.mesh)\n }\n const matrix = mv.mesh.matrixWorld.elements\n const source = sourceIdOf(local.source)\n const known = made.get(mv)\n if (\n known &&\n known.source === source &&\n known.version === local.version &&\n known.shapeVersion === mv.shapeVersion &&\n known.from === local.from &&\n known.to === local.to &&\n known.matrix.every((v, k) => v === matrix[k])\n )\n return known.solids\n const sig = { matrix: [...matrix], from: local.from, to: local.to, source, version: local.version, shapeVersion: mv.shapeVersion }\n const waiting = budget.workers ? pending.get(mv) : undefined\n if (waiting && sameSig(waiting, sig)) {\n budget.incomplete = true\n return known?.solids ?? []\n }\n // out of turns: what was made before stays (its body is kept), a part never made waits for the next call\n if (budget.left <= 0) {\n budget.incomplete = true\n return known?.solids ?? []\n }\n budget.left -= local.to - local.from + PART_COST\n const job = jobOf(THREE, mv, readPoints(local.array, local.from, local.to, local.collapsed), matrix, local)\n const workers = budget.workers\n if (workers) {\n pending.set(mv, sig)\n budget.incomplete = true\n workers.run(staticCollidersKind, job).then(\n (solids) => {\n if (pending.get(mv) !== sig) return\n pending.delete(mv)\n made.set(mv, { ...sig, solids: solids.map((solid) => ({ ...solid, key })) })\n },\n () => {\n if (pending.get(mv) === sig) pending.delete(mv)\n },\n )\n return known?.solids ?? []\n }\n const solids = measureStaticPart(job).map((solid) => ({ ...solid, key }))\n made.set(mv, { ...sig, solids })\n return solids\n}\n\nconst sameSig = (a: Omit<Made, 'solids'>, b: Omit<Made, 'solids'>): boolean =>\n a.source === b.source && a.version === b.version && a.shapeVersion === b.shapeVersion && a.from === b.from && a.to === b.to && a.matrix.every((v, k) => v === b.matrix[k])\n\n/** The job of a part (`measureStaticPart`): its vertices, the triangles that start in its range and the mesh's world matrix with three's decomposition of it. */\nconst jobOf = (THREE: typeof THREE_NS, mv: MeshVis, points: Float64Array, matrix: readonly number[], local: { readonly from: number; readonly to: number }): StaticPartJob => {\n const pos = new THREE.Vector3()\n const quat = new THREE.Quaternion()\n const scale = new THREE.Vector3()\n mv.mesh.matrixWorld.decompose(pos, quat, scale)\n return {\n points,\n matrix: Float64Array.from(matrix),\n position: [pos.x, pos.y, pos.z],\n quaternion: [quat.x, quat.y, quat.z, quat.w],\n scale: [scale.x, scale.y, scale.z],\n found: Uint32Array.from(trianglesOfPart(mv, local)),\n from: local.from,\n }\n}\n\n/** The triangles of each range of the host's index buffer, found in one pass for all of them (the parts of a merged mesh are many, its buffer is one). */\nconst trianglesOfRanges = (mv: MeshVis, ranges: ReadonlyArray<readonly [number, number]>): Map<number, number[]> => {\n const index = mv.mesh.geometry.getIndex()\n const key = (index?.array ?? mv.mesh.geometry) as object\n const known = triangles.get(key)\n if (known) return known\n const sorted = [...ranges].sort((a, b) => a[0] - b[0])\n const owner = (vertex: number): number => {\n let lo = 0\n let hi = sorted.length - 1\n while (lo <= hi) {\n const mid = (lo + hi) >> 1\n if (vertex < sorted[mid][0]) hi = mid - 1\n else if (vertex >= sorted[mid][1]) lo = mid + 1\n else return sorted[mid][0]\n }\n return -1\n }\n const out = new Map<number, number[]>()\n const array = index?.array\n const count = index ? index.count : (mv.mesh.geometry.getAttribute('position')?.count ?? 0)\n for (let i = 0; i + 2 < count; i += 3) {\n const a = array ? array[i] : i\n const from = owner(a)\n if (from < 0) continue\n let list = out.get(from)\n if (!list) {\n list = []\n out.set(from, list)\n }\n if (array) list.push(a, array[i + 1], array[i + 2])\n else list.push(i, i + 1, i + 2)\n }\n triangles.set(key, out)\n return out\n}\n\n/** The triangles that start in the part's range of its host, as vertex numbers of the host (three each). */\nconst trianglesOfPart = (mv: MeshVis, local: { readonly from: number; readonly to: number }): number[] =>\n mv.host\n ? trianglesOfRanges(mv, mv.host.sharers.filter((s) => s.range && !s.loose).map((s) => s.range as [number, number])).get(local.from) ?? []\n : trianglesOfRanges(mv, [[0, local.to]]).get(0) ?? []\n","/** Vertices of one box as the house draws it (a face of four, six faces). */\nconst BOX_VERTICES = 24\n/** Most boxes a part may be drawn with to be held box by box. */\nconst MAX_BOXES = 16\n/** How far (in the mesh's own units) a vertex may be from a corner of its box. */\nconst CORNER = 1e-4\n/** A part drawn as separate boxes holds the air between them when held as one box: under this share of the box around them they are held one by one. */\nconst HOLLOW = 0.5\n\ntype DrawnBox = { readonly low: readonly number[]; readonly high: readonly number[] }\n\n/**\n * The boxes a part is drawn with when it is several of them and they leave most of the box around them empty (a door frame: two posts and a lintel, 24 vertices each, one range),\n * from its vertices in the mesh's own space (x y z). Null when it is not drawn that way: every group of 24 vertices must be the eight corners of an axis box, three vertices on\n * each, and the boxes must fill under `HOLLOW` of the box around them all.\n */\nexport const hollowBoxesOf = (points: ArrayLike<number>): DrawnBox[] | null => {\n const count = points.length / 3\n if (count % BOX_VERTICES !== 0 || count / BOX_VERTICES < 2 || count / BOX_VERTICES > MAX_BOXES) return null\n const boxes: DrawnBox[] = []\n const all = { low: [Infinity, Infinity, Infinity], high: [-Infinity, -Infinity, -Infinity] }\n for (let first = 0; first < count; first += BOX_VERTICES) {\n const low = [Infinity, Infinity, Infinity]\n const high = [-Infinity, -Infinity, -Infinity]\n for (let v = first; v < first + BOX_VERTICES; v++) {\n for (let k = 0; k < 3; k++) {\n low[k] = Math.min(low[k] as number, points[v * 3 + k] as number)\n high[k] = Math.max(high[k] as number, points[v * 3 + k] as number)\n }\n }\n const corners = new Set<number>()\n for (let v = first; v < first + BOX_VERTICES; v++) {\n let corner = 0\n for (let k = 0; k < 3; k++) {\n const x = points[v * 3 + k] as number\n if (Math.abs(x - (high[k] as number)) <= CORNER) corner |= 1 << k\n else if (Math.abs(x - (low[k] as number)) > CORNER) return null\n }\n corners.add(corner)\n }\n if (corners.size !== 8) return null\n for (let k = 0; k < 3; k++) {\n all.low[k] = Math.min(all.low[k] as number, low[k] as number)\n all.high[k] = Math.max(all.high[k] as number, high[k] as number)\n }\n boxes.push({ low, high })\n }\n const volume = (low: readonly number[], high: readonly number[]): number => (high[0]! - low[0]!) * (high[1]! - low[1]!) * (high[2]! - low[2]!)\n const filled = boxes.reduce((sum, box) => sum + volume(box.low, box.high), 0)\n return filled < HOLLOW * volume(all.low, all.high) ? boxes : null\n}\n","/**\n * How far (squared length of an axis from 1, dot of two axes from 0) a matrix may be from a turn and a move and still count as one: the error of composing and\n * decomposing poses (`getWorldQuaternion`, `attach`) is ~1e-16; a scale of 1 + 1e-6 is 5 µm on a 10 m house.\n */\nconst RIGID_TOLERANCE = 1e-6\n\n/**\n * Whether the 4x4 matrix (three.js `elements`, column by column) only turns and moves: unit axes square to each other, not mirrored, no projection. What such a matrix\n * carries a set of boxes into is the same boxes, turned and moved; a scale or a shear makes them other boxes (or no boxes at all).\n */\nexport const isRigidPose = (e: ArrayLike<number>): boolean => {\n // the bottom row of an inverse times a pose is 0 0 0 1 give or take the last bit (three.js inverts it by another expansion)\n if (Math.abs(e[3]!) > RIGID_TOLERANCE || Math.abs(e[7]!) > RIGID_TOLERANCE || Math.abs(e[11]!) > RIGID_TOLERANCE || Math.abs(e[15]! - 1) > RIGID_TOLERANCE) return false\n const xx = e[0]! * e[0]! + e[1]! * e[1]! + e[2]! * e[2]!\n const yy = e[4]! * e[4]! + e[5]! * e[5]! + e[6]! * e[6]!\n const zz = e[8]! * e[8]! + e[9]! * e[9]! + e[10]! * e[10]!\n const xy = e[0]! * e[4]! + e[1]! * e[5]! + e[2]! * e[6]!\n const xz = e[0]! * e[8]! + e[1]! * e[9]! + e[2]! * e[10]!\n const yz = e[4]! * e[8]! + e[5]! * e[9]! + e[6]! * e[10]!\n if (Math.abs(xx - 1) > RIGID_TOLERANCE || Math.abs(yy - 1) > RIGID_TOLERANCE || Math.abs(zz - 1) > RIGID_TOLERANCE) return false\n if (Math.abs(xy) > RIGID_TOLERANCE || Math.abs(xz) > RIGID_TOLERANCE || Math.abs(yz) > RIGID_TOLERANCE) return false\n // x cross y along z: a mirror would turn the boxes inside out\n const cross = (e[1]! * e[6]! - e[2]! * e[5]!) * e[8]! + (e[2]! * e[4]! - e[0]! * e[6]!) * e[9]! + (e[0]! * e[5]! - e[1]! * e[4]!) * e[10]!\n return cross > 0\n}\n","import type { Vec3 } from '@adatechnology/game-destruction'\nimport type { BodyDesc, BodyId, Material, Quat, SeamWorld, ShapeDesc } from '@adatechnology/game-physics'\n\n/** The triangles of a fixed drawn part where no box fits it (world space, three indices a triangle). */\nexport interface StaticMesh {\n readonly vertices: Float32Array\n readonly indices: Uint32Array\n}\n\n/** A fixed box of what does not move, as it is drawn: centre, half sizes and rotation (world). With `mesh` the part is those triangles, and the box is the one around them. */\nexport interface StaticSolid {\n readonly center: Vec3\n readonly half: Vec3\n readonly rotation: Quat\n readonly mesh?: StaticMesh\n /** Names the part across lists (a part measured again is the same part): without it, the place in the list. */\n readonly key?: string\n /** The Coulomb friction and rolling resistance of the part's material; without it the body has the ground's. */\n readonly friction?: { readonly static: number; readonly dynamic: number; readonly rolling: number; readonly rollingDamping?: number }\n}\n\ninterface Held {\n solid: StaticSolid\n id: BodyId\n}\n\ninterface Fixed {\n /** The list the host gave (by reference: the same list is the same parts), and the parts the engine holds. */\n solids: readonly StaticSolid[]\n held: Map<string, Held>\n /** Meshes left for a later update. */\n waiting: number\n /** Every part was made once: from then on what lies by a part that came or went wakes (when the house is first filled, nothing lies there). */\n settled: boolean\n}\n\n/** Triangles of meshes made per update (about a millisecond for a thousand): an object with hundreds of conduits and frames fills in over a few updates, not one frame. */\nconst TRIANGLES_PER_UPDATE = 1200\n\n/** Equal within this (m, and for the rotation's components) is the same box: the host measures again to the same numbers in new arrays. */\nconst SAME = 1e-6\n/** How far past a box that changed (m) what lies there is woken. */\nconst WAKE_MARGIN = 0.05\n\nconst near = (a: ArrayLike<number>, b: ArrayLike<number>): boolean => {\n for (let i = 0; i < a.length; i++) if (Math.abs(a[i] - b[i]) > SAME) return false\n return true\n}\n\nconst sameMesh = (a: StaticMesh | undefined, b: StaticMesh | undefined): boolean => {\n if (!a || !b) return a === b\n return a.indices.length === b.indices.length && a.vertices.length === b.vertices.length && near(a.vertices, b.vertices) && a.indices.every((v, i) => v === b.indices[i])\n}\n\nconst sameFriction = (a: StaticSolid['friction'], b: StaticSolid['friction']): boolean =>\n a === b || (a !== undefined && b !== undefined && a.static === b.static && a.dynamic === b.dynamic && a.rolling === b.rolling && a.rollingDamping === b.rollingDamping)\n\nconst sameShape = (a: StaticSolid, b: StaticSolid): boolean => near(a.center, b.center) && near(a.half, b.half) && near(a.rotation, b.rotation) && sameMesh(a.mesh, b.mesh)\n\n/** The same box with the same surface: a part whose material changed (its friction) is a changed part too. */\nconst sameBox = (a: StaticSolid, b: StaticSolid): boolean => a === b || (sameShape(a, b) && sameFriction(a.friction, b.friction))\n\nexport const sameSolids = (a: readonly StaticSolid[], b: readonly StaticSolid[]): boolean => a.length === b.length && a.every((s, i) => sameBox(s, b[i]))\n\nconst hasSize = (s: StaticSolid): boolean => s.half[0] > 0 && s.half[1] > 0 && s.half[2] > 0\n\nconst shapeOf = (s: StaticSolid): ShapeDesc => (s.mesh ? { kind: 'trimesh', vertices: s.mesh.vertices, indices: s.mesh.indices } : { kind: 'box', half: s.half })\n\n/**\n * The host's fixed things in the engine: one static body per drawn part of an object, a box turned as drawn or the triangles where no box fits. A new list for an object is\n * compared part by part with the last: an unchanged part is left alone, a changed one keeps its body and takes the new shape in place (`setShape`: what touches it keeps its\n * contacts), a part that went loses its body and a new one gets its own, so an object of hundreds of parts costs one body when one part breaks, and a leaking water tank's box wakes\n * only what lies by it (the room's `single_storey_a` after a blast). What wakes is only what lies by a part that went, came or moved. A mesh costs to build: each update\n * makes new ones up to `TRIANGLES_PER_UPDATE` triangles and leaves the rest for the next (boxes are made at once).\n */\nexport class EngineStatics {\n readonly bodies = new Map<string, Fixed>()\n /** The bodies that were made, changed or went in the last `lay`: what an outside input under a piece is, for a probe. */\n readonly changed = new Set<BodyId>()\n /** Every body it holds now: what a piece made or put is checked against (`EnginePieces.outOfStatics`; the ground has its own rule). */\n readonly ids = new Set<BodyId>()\n\n constructor(\n private readonly world: SeamWorld,\n private readonly material: Material,\n ) {}\n\n /** Whether the engine has a body for the object's drawn parts (what the kit's sweep need not set a piece back from). */\n has(objectId: string): boolean {\n const f = this.bodies.get(objectId)\n return f !== undefined && f.held.size > 0\n }\n\n lay(now: ReadonlyMap<string, readonly StaticSolid[]>): void {\n this.changed.clear()\n for (const [id, f] of this.bodies) {\n if (now.has(id)) continue\n for (const h of f.held.values()) this.release(h, f.settled)\n this.bodies.delete(id)\n }\n const budget = { triangles: TRIANGLES_PER_UPDATE }\n for (const [id, solids] of now) {\n const f = this.bodies.get(id)\n if (f?.solids === solids && f.waiting === 0) continue\n const fixed = f ?? { solids, held: new Map<string, Held>(), waiting: 0, settled: false }\n this.bodies.set(id, fixed)\n fixed.solids = solids\n this.fit(fixed, budget)\n }\n }\n\n clear(): void {\n for (const f of this.bodies.values()) for (const h of f.held.values()) this.drop(h.id)\n this.bodies.clear()\n this.changed.clear()\n }\n\n /** The object's parts of a list by name, the ones with a size only. */\n private named(solids: readonly StaticSolid[]): Map<string, StaticSolid> {\n const out = new Map<string, StaticSolid>()\n solids.forEach((s, i) => {\n if (!hasSize(s)) return\n let key = s.key ?? String(i)\n while (out.has(key)) key += '+'\n out.set(key, s)\n })\n return out\n }\n\n private fit(f: Fixed, budget: { triangles: number }): void {\n const next = this.named(f.solids)\n for (const [key, h] of f.held) {\n if (next.has(key)) continue\n this.release(h, f.settled)\n f.held.delete(key)\n }\n const fresh: Array<{ key: string; solid: StaticSolid }> = []\n let waiting = 0\n for (const [key, solid] of next) {\n const h = f.held.get(key)\n if (!h) {\n const cost = solid.mesh ? solid.mesh.indices.length / 3 : 0\n // a mesh over what is left waits, unless it is the first of the update (one bigger than the whole budget is made alone)\n if (cost > budget.triangles && budget.triangles < TRIANGLES_PER_UPDATE) {\n waiting++\n continue\n }\n budget.triangles -= cost\n fresh.push({ key, solid })\n continue\n }\n if (h.solid === solid || sameBox(h.solid, solid)) continue\n if (f.settled) {\n this.wakeAround(h.solid)\n this.wakeAround(solid)\n }\n this.reshape(h, solid)\n }\n if (fresh.length > 0) {\n const ids = this.world.createBodies(fresh.map((x) => this.describe(x.solid)))\n fresh.forEach((x, i) => {\n const id = ids[i]\n f.held.set(x.key, { solid: x.solid, id })\n this.ids.add(id)\n this.changed.add(id)\n if (f.settled) this.wakeAround(x.solid)\n })\n }\n f.waiting = waiting\n if (waiting === 0) f.settled = true\n }\n\n /** The held part takes the new solid: its shape where that changed, its surface where that did (only the friction: the same shape, no new one). */\n private reshape(h: Held, solid: StaticSolid): void {\n const was = h.solid\n h.solid = solid\n if (!sameFriction(was.friction, solid.friction)) this.world.setMaterial(h.id, this.materialOf(solid))\n this.changed.add(h.id)\n if (sameShape(was, solid)) return\n if (!solid.mesh) this.world.setPose(h.id, solid.center, solid.rotation, false)\n this.world.setShape(h.id, shapeOf(solid))\n }\n\n private describe(solid: StaticSolid): BodyDesc {\n return { shape: shapeOf(solid), motion: 'static', position: solid.mesh ? [0, 0, 0] : solid.center, ...(solid.mesh ? {} : { rotation: solid.rotation }), material: this.materialOf(solid), user: 0 }\n }\n\n private materialOf(solid: StaticSolid): Material {\n return solid.friction ? { ...this.material, frictionStatic: solid.friction.static, frictionDynamic: solid.friction.dynamic, rolling: solid.friction.rolling, rollingDamping: solid.friction.rollingDamping ?? 0 } : this.material\n }\n\n private release(h: Held, wake: boolean): void {\n if (wake) this.wakeAround(h.solid)\n this.changed.add(h.id)\n this.drop(h.id)\n }\n\n private drop(id: BodyId): void {\n this.ids.delete(id)\n this.world.removeBody(id)\n }\n\n private wakeAround(s: StaticSolid): void {\n const r = Math.hypot(s.half[0], s.half[1], s.half[2]) + WAKE_MARGIN\n this.world.wakeInBox([s.center[0] - r, s.center[1] - r, s.center[2] - r], [s.center[0] + r, s.center[1] + r, s.center[2] + r])\n }\n}\n","import type { PieceBody } from './internal'\n\n/**\n * The pieces the per-update loops walk: not asleep, held in the hand, or just changed. Kept in creation order (`generation`, the order of the system's list), so a walk visits\n * them in the order a walk over every piece would. A piece enters when it wakes and leaves once it is asleep on both sides and measured (`settle`).\n */\nexport class AwakeList {\n readonly items: PieceBody[] = []\n private readonly members = new Set<PieceBody>()\n /** Where a walk is: a piece that enters before it is not visited again, one that enters after it is, as in a walk over the whole list. */\n private cursor = -1\n\n has(body: PieceBody): boolean {\n return this.members.has(body)\n }\n\n enter(body: PieceBody): void {\n if (this.members.has(body)) return\n this.members.add(body)\n const items = this.items\n let low = 0\n let high = items.length\n while (low < high) {\n const middle = (low + high) >> 1\n if ((items[middle] as PieceBody).generation < body.generation) low = middle + 1\n else high = middle\n }\n items.splice(low, 0, body)\n if (low <= this.cursor) this.cursor++\n }\n\n leave(body: PieceBody): void {\n if (!this.members.delete(body)) return\n const at = this.items.indexOf(body)\n this.items.splice(at, 1)\n if (at <= this.cursor) this.cursor--\n }\n\n clear(): void {\n this.items.length = 0\n this.members.clear()\n this.cursor = -1\n }\n\n walk(visit: (body: PieceBody) => void): void {\n const outer = this.cursor\n for (this.cursor = 0; this.cursor < this.items.length; this.cursor++) visit(this.items[this.cursor] as PieceBody)\n this.cursor = outer\n }\n\n /** Drops what `isSettled` names, in place and in order. Not during a walk. */\n settle(isSettled: (body: PieceBody) => boolean): void {\n const items = this.items\n let kept = 0\n for (let i = 0; i < items.length; i++) {\n const body = items[i] as PieceBody\n if (isSettled(body)) this.members.delete(body)\n else items[kept++] = body\n }\n items.length = kept\n }\n}\n","import type { MaterialDef } from '@adatechnology/game-destruction'\nimport type { PieceFriction } from './internal'\n\n/** What a surface is to what touches it: its Coulomb friction and rolling resistance (`PieceFriction`) and its coefficient of restitution. */\nexport interface SurfaceDef extends PieceFriction {\n readonly restitution: number\n}\n\n/**\n * Coulomb friction, rolling resistance and restitution of a surface by its material. Two surfaces against each other mix the friction and the restitution by geometric mean\n * (`pieces.ts`), so each value is the coefficient of the material against itself: wood on wood 0.4 and 0.3, and then steel on wood sqrt(0.6 x 0.4) = 0.49, rubber on concrete\n * sqrt(1.0 x 0.7) = 0.84; the rolling resistance is the softer surface's (the larger).\n * Friction from the engineering tables of dry friction (The Engineering ToolBox, \"Friction and Friction Coefficients\"; Serway, Physics for Scientists and Engineers, table\n * 5.1): wood 0.25-0.5, steel 0.5-0.8 static and 0.4-0.6 sliding, glass 0.4 against other materials, ceramic 0.5, rubber 0.8-1.0, concrete and brick 0.6-0.7, plastic 0.3-0.4,\n * fabric and foam 0.5-0.8, paper 0.4. Rolling resistance (The Engineering ToolBox, \"Rolling Resistance\"): steel on steel 0.001-0.002, a hard wheel on concrete 0.01-0.02, on\n * wood 0.01, a carpet or foam 0.05-0.1. Restitution of a body bouncing on the material (drop tests): rubber 0.8, glass 0.7, steel 0.6, wood and plastic 0.5, concrete 0.4,\n * fabric and paper 0.2.\n * Rolling damping (1/s, `rollingDamping`): the share of its spin a roller made of the material loses per second against any surface, from its own give and roughness on top of\n * C_rr: a smooth hard glass or steel roller almost none (0.02), a wooden log with its bark and knots 0.4, plastic 0.1, rubber and cardboard 0.3, foam and cloth 1. It adds to the\n * ground's (`TerrainMaterial.rollingDamping`), so the pair decides: a bottle on glazed tile rolls on, a log on grass stops at once. Estimates, not a published table.\n */\nconst SURFACE_BY_KEY: ReadonlyArray<readonly [RegExp, SurfaceDef]> = [\n [/rubber|tire|tyre/, { static: 1.0, dynamic: 0.8, rolling: 0.03, rollingDamping: 0.3, restitution: 0.8 }],\n [/foam|sponge|fabric|cloth|leather|textile|carpet/, { static: 0.6, dynamic: 0.5, rolling: 0.08, rollingDamping: 1.0, restitution: 0.2 }],\n [/concrete|brick|stone|masonry|cement|asphalt|plaster/, { static: 0.7, dynamic: 0.6, rolling: 0.012, rollingDamping: 0.1, restitution: 0.4 }],\n [/steel|iron|metal|alumin|copper|brass|tin/, { static: 0.6, dynamic: 0.4, rolling: 0.002, rollingDamping: 0.02, restitution: 0.6 }],\n [/glass/, { static: 0.4, dynamic: 0.35, rolling: 0.002, rollingDamping: 0.02, restitution: 0.7 }],\n [/ceramic|porcelain|tile/, { static: 0.5, dynamic: 0.4, rolling: 0.005, rollingDamping: 0.03, restitution: 0.5 }],\n [/wood|mdf|plywood|board|cork/, { static: 0.4, dynamic: 0.3, rolling: 0.01, rollingDamping: 0.4, restitution: 0.5 }],\n [/plastic|polycarbonate|acrylic|nylon|pvc/, { static: 0.4, dynamic: 0.3, rolling: 0.01, rollingDamping: 0.1, restitution: 0.5 }],\n [/paper|cardboard|carton/, { static: 0.4, dynamic: 0.3, rolling: 0.02, rollingDamping: 0.3, restitution: 0.2 }],\n]\n\n/** The surface of a material by its id and tags (see `SURFACE_BY_KEY`), or undefined when nothing matches (the pieces' defaults then). */\nexport function surfaceOf(materialId: string, def?: MaterialDef): SurfaceDef | undefined {\n const keys = [materialId, ...(def?.tags ?? [])].join(' ').toLowerCase()\n return SURFACE_BY_KEY.find(([key]) => key.test(keys))?.[1]\n}\n\n/** The friction of a material by its id and tags (see `SURFACE_BY_KEY`), or undefined when nothing matches (the pieces' default then). */\nexport function frictionOf(materialId: string, def?: MaterialDef): PieceFriction | undefined {\n const surface = surfaceOf(materialId, def)\n return surface && { static: surface.static, dynamic: surface.dynamic, rolling: surface.rolling, rollingDamping: surface.rollingDamping }\n}\n\n/** Rolling damping (1/s) of a piece whose material says nothing (`PieceFriction.rollingDamping`): a hard roller. */\nexport const PIECE_ROLLING_DAMPING = 0.05\n/** Rolling damping (1/s) of the ground when the host says nothing (a hard floor, as `ROLLING_RESISTANCE`). */\nexport const GROUND_ROLLING_DAMPING = 0.3\n","import type { Vec3 } from '@adatechnology/game-destruction'\n\n/**\n * The shape two pieces meet each other by: a round piece is a capsule round its axis (a can lying on its side, a bottle, a ball when its segment is a point), anything else\n * the boxes of its parts (a table's top and legs, as drawn) or of itself, each a centre, rotation columns (`Matrix4.elements`) and half extents.\n */\nexport type ContactShape =\n | { readonly kind: 'capsule'; readonly from: Vec3; readonly to: Vec3; readonly radius: number }\n | { readonly kind: 'boxes'; readonly boxes: ReadonlyArray<{ readonly c: Vec3; readonly e: ArrayLike<number>; readonly half: Vec3 }> }\n\n/** Where two shapes meet: the point between them, the unit normal from the second to the first, and how deep they overlap (m). */\nexport interface ShapeContact {\n readonly point: Vec3\n readonly normal: Vec3\n readonly depth: number\n}\n\n/** Rounds of the closest-point search between a segment and a box (each a projection onto one, then the other: convex, so it closes in). */\nconst SEGMENT_BOX_ROUNDS = 4\n/** Two segments this near parallel (sin^2 of the angle between them) are side by side. */\nconst PARALLEL = 1e-4\n\nconst sub = (a: Vec3, b: Vec3): Vec3 => [a[0] - b[0], a[1] - b[1], a[2] - b[2]]\nconst dot = (a: Vec3, b: Vec3): number => a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\nconst along = (a: Vec3, d: Vec3, t: number): Vec3 => [a[0] + d[0] * t, a[1] + d[1] * t, a[2] + d[2] * t]\nconst clamp01 = (t: number): number => (t < 0 ? 0 : t > 1 ? 1 : t)\n\n/** The point of the segment `from`-`to` nearest to `p`. */\nconst nearestOnSegment = (from: Vec3, to: Vec3, p: Vec3): Vec3 => {\n const d = sub(to, from)\n const len2 = dot(d, d)\n return len2 < 1e-12 ? from : along(from, d, clamp01(dot(sub(p, from), d) / len2))\n}\n\n/** The nearest points of two segments (Ericson, Real-Time Collision Detection 5.1.9). */\nconst nearestOfSegments = (p1: Vec3, q1: Vec3, p2: Vec3, q2: Vec3): [Vec3, Vec3] => {\n const d1 = sub(q1, p1)\n const d2 = sub(q2, p2)\n const r = sub(p1, p2)\n const a = dot(d1, d1)\n const e = dot(d2, d2)\n const f = dot(d2, r)\n let s = 0\n let t = 0\n if (a < 1e-12 && e < 1e-12) return [p1, p2]\n if (a < 1e-12) t = clamp01(f / e)\n else {\n const c = dot(d1, r)\n if (e < 1e-12) s = clamp01(-c / a)\n else {\n const b = dot(d1, d2)\n const denom = a * e - b * b\n if (denom > PARALLEL * a * e) s = clamp01((b * f - c * e) / denom)\n else {\n // side by side (two cans lying parallel): they touch along the length they share, met at its middle, so the blow turns neither\n const s0 = clamp01(-c / a)\n const s1 = clamp01((b - c) / a)\n s = (s0 + s1) / 2\n }\n t = (b * s + f) / e\n if (t < 0) {\n t = 0\n s = clamp01(-c / a)\n } else if (t > 1) {\n t = 1\n s = clamp01((b - c) / a)\n }\n }\n }\n return [along(p1, d1, s), along(p2, d2, t)]\n}\n\n/** `p` in the frame of the box (its axes, from its centre). */\nconst toBox = (box: { c: Vec3; e: ArrayLike<number> }, p: Vec3): Vec3 => {\n const d = sub(p, box.c)\n const e = box.e\n return [e[0] * d[0] + e[1] * d[1] + e[2] * d[2], e[4] * d[0] + e[5] * d[1] + e[6] * d[2], e[8] * d[0] + e[9] * d[1] + e[10] * d[2]]\n}\n\n/** A point in the frame of the box back in the world. */\nconst fromBox = (box: { c: Vec3; e: ArrayLike<number> }, l: Vec3): Vec3 => {\n const e = box.e\n return [box.c[0] + e[0] * l[0] + e[4] * l[1] + e[8] * l[2], box.c[1] + e[1] * l[0] + e[5] * l[1] + e[9] * l[2], box.c[2] + e[2] * l[0] + e[6] * l[1] + e[10] * l[2]]\n}\n\n/** A capsule against one box: the nearest point of its segment to the box, and how far inside the capsule's radius the box comes. */\nconst capsuleBox = (from: Vec3, to: Vec3, radius: number, box: { c: Vec3; e: ArrayLike<number>; half: Vec3 }): ShapeContact | null => {\n let p = nearestOnSegment(from, to, box.c)\n let l = toBox(box, p)\n for (let round = 0; round < SEGMENT_BOX_ROUNDS; round++) {\n const clamped: Vec3 = [Math.max(-box.half[0], Math.min(box.half[0], l[0])), Math.max(-box.half[1], Math.min(box.half[1], l[1])), Math.max(-box.half[2], Math.min(box.half[2], l[2]))]\n p = nearestOnSegment(from, to, fromBox(box, clamped))\n l = toBox(box, p)\n }\n const q: Vec3 = [Math.max(-box.half[0], Math.min(box.half[0], l[0])), Math.max(-box.half[1], Math.min(box.half[1], l[1])), Math.max(-box.half[2], Math.min(box.half[2], l[2]))]\n const gap: Vec3 = [l[0] - q[0], l[1] - q[1], l[2] - q[2]]\n const distance = Math.hypot(gap[0], gap[1], gap[2])\n if (distance >= radius) return null\n const e = box.e\n if (distance > 1e-6) {\n const n: Vec3 = [gap[0] / distance, gap[1] / distance, gap[2] / distance]\n const normal: Vec3 = [e[0] * n[0] + e[4] * n[1] + e[8] * n[2], e[1] * n[0] + e[5] * n[1] + e[9] * n[2], e[2] * n[0] + e[6] * n[1] + e[10] * n[2]]\n return { point: fromBox(box, q), normal, depth: radius - distance }\n }\n // the segment runs inside the box: out through the nearest face\n let axis = 0\n for (let k = 1; k < 3; k++) if (box.half[k] - Math.abs(l[k]) < box.half[axis] - Math.abs(l[axis])) axis = k\n const sign = l[axis] < 0 ? -1 : 1\n return { point: p, normal: [sign * e[axis * 4], sign * e[axis * 4 + 1], sign * e[axis * 4 + 2]], depth: radius + box.half[axis] - Math.abs(l[axis]) }\n}\n\ntype Box = { readonly c: Vec3; readonly e: ArrayLike<number>; readonly half: Vec3 }\n\n/** An edge axis (the cross of an edge of each box) wins over a face axis only when it overlaps this much less: two faces flat on each other stay face to face. */\nconst EDGE_BIAS = 0.95\n/** A cross of two edges shorter than this is two parallel edges: their axis is a face axis already tried. */\nconst PARALLEL_EDGES = 1e-6\n\n/** How far a box reaches from its centre along the unit (lx, ly, lz). */\nconst reachAlong = (box: Box, lx: number, ly: number, lz: number): number => {\n const e = box.e\n const h = box.half\n return h[0] * Math.abs(e[0] * lx + e[1] * ly + e[2] * lz) + h[1] * Math.abs(e[4] * lx + e[5] * ly + e[6] * lz) + h[2] * Math.abs(e[8] * lx + e[9] * ly + e[10] * lz)\n}\n\n/** The 15 axes of a box pair (`pairAxes`), x y z each, and whether each is one (two parallel edges have none): filled per pair, never made anew. */\nconst AXES = new Float64Array(45)\nconst HAS_AXIS = new Uint8Array(15)\n\n/** The axes of a box pair to try into `AXES`: the 3 face axes of each (a's and b's in turn) and the 9 crosses of their edges, unit. */\nconst pairAxes = (a: Box, b: Box): void => {\n const ea = a.e\n const eb = b.e\n for (let k = 0; k < 3; k++) {\n for (let c = 0; c < 3; c++) {\n AXES[k * 6 + c] = ea[k * 4 + c]\n AXES[k * 6 + 3 + c] = eb[k * 4 + c]\n }\n HAS_AXIS[k * 2] = 1\n HAS_AXIS[k * 2 + 1] = 1\n }\n for (let i = 0; i < 3; i++) {\n const u0 = ea[i * 4], u1 = ea[i * 4 + 1], u2 = ea[i * 4 + 2]\n for (let j = 0; j < 3; j++) {\n const v0 = eb[j * 4], v1 = eb[j * 4 + 1], v2 = eb[j * 4 + 2]\n const x = u1 * v2 - u2 * v1\n const y = u2 * v0 - u0 * v2\n const z = u0 * v1 - u1 * v0\n const len = Math.sqrt(x * x + y * y + z * z)\n const n = 6 + i * 3 + j\n HAS_AXIS[n] = len < PARALLEL_EDGES ? 0 : 1\n if (len >= PARALLEL_EDGES) {\n AXES[n * 3] = x / len\n AXES[n * 3 + 1] = y / len\n AXES[n * 3 + 2] = z / len\n }\n }\n }\n}\n\n/**\n * Two boxes by their separating axes (Ericson, Real-Time Collision Detection 4.4.1): the 3 face axes of each and the 9 crosses of their edges. Apart on any axis, they do\n * not touch; else they meet along the axis they overlap least on, by that overlap, the normal from `b` to `a`, at the middle of the overlap between their centres. Pairs\n * apart (most of them, every update) make nothing.\n */\nconst boxBox = (a: Box, b: Box): ShapeContact | null => {\n const dx = a.c[0] - b.c[0], dy = a.c[1] - b.c[1], dz = a.c[2] - b.c[2]\n let nx = 0, ny = 1, nz = 0\n let depth = Infinity\n let faceDepth = Infinity\n pairAxes(a, b)\n for (let k = 0; k < 15; k++) {\n if (!HAS_AXIS[k]) continue\n const lx = AXES[k * 3], ly = AXES[k * 3 + 1], lz = AXES[k * 3 + 2]\n const centres = dx * lx + dy * ly + dz * lz\n const overlap = reachAlong(a, lx, ly, lz) + reachAlong(b, lx, ly, lz) - Math.abs(centres)\n if (overlap < 0) return null\n const face = k < 6\n if (face ? overlap < depth : overlap < depth && overlap < faceDepth * EDGE_BIAS) {\n depth = overlap\n if (face) faceDepth = overlap\n const sign = centres < 0 ? -1 : 1\n nx = sign * lx\n ny = sign * ly\n nz = sign * lz\n }\n }\n const normal: Vec3 = [nx, ny, nz]\n // the middle of the overlap along the normal, on the line between the centres\n const mid: Vec3 = [(a.c[0] + b.c[0]) / 2, (a.c[1] + b.c[1]) / 2, (a.c[2] + b.c[2]) / 2]\n const middle = (dot(a.c, normal) - reachAlong(a, nx, ny, nz) + dot(b.c, normal) + reachAlong(b, nx, ny, nz)) / 2\n return { point: along(mid, normal, middle - dot(mid, normal)), normal, depth }\n}\n\n/** An axis whose share along the ground is under this has no direction along it: it is not a way to slide apart. */\nconst LEVEL_SHARE = 1e-3\n\n/**\n * Two overlapping boxes put apart along the ground only: of the level directions of their separating axes (each axis laid flat) and the world's x and z, the one they\n * overlap least on, by that overlap, the normal (level) from `b` to `a`. Null when they do not touch (`boxBox`). Any direction bounds how far they must go apart along it.\n */\nconst boxBoxAlongGround = (a: Box, b: Box): ShapeContact | null => {\n if (!boxBox(a, b)) return null\n const dx = a.c[0] - b.c[0], dz = a.c[2] - b.c[2]\n let normal: Vec3 = [1, 0, 0]\n let depth = Infinity\n // the pair's axes (`boxBox` left them in `AXES`), then the world's x and z\n for (let k = 0; k < 17; k++) {\n if (k < 15 && !HAS_AXIS[k]) continue\n const lx = k < 15 ? AXES[k * 3] : k === 15 ? 1 : 0\n const lz = k < 15 ? AXES[k * 3 + 2] : k === 15 ? 0 : 1\n const flat = Math.sqrt(lx * lx + lz * lz)\n if (flat < LEVEL_SHARE) continue\n const gx = lx / flat, gz = lz / flat\n const centres = dx * gx + dz * gz\n const overlap = reachAlong(a, gx, 0, gz) + reachAlong(b, gx, 0, gz) - Math.abs(centres)\n if (overlap < depth) {\n depth = overlap\n normal = centres < 0 ? [-gx, 0, -gz] : [gx, 0, gz]\n }\n }\n const mid: Vec3 = [(a.c[0] + b.c[0]) / 2, (a.c[1] + b.c[1]) / 2, (a.c[2] + b.c[2]) / 2]\n return { point: mid, normal, depth: Math.max(0, depth) }\n}\n\n/**\n * Two box shapes put apart along the ground only (`boxBoxAlongGround`): the deepest of their overlapping part pairs, so moving by its depth clears them all. Null when no\n * part of one is in a part of the other.\n */\nexport function boxesAlongGround(a: ContactShape, b: ContactShape): ShapeContact | null {\n if (a.kind !== 'boxes' || b.kind !== 'boxes') return null\n let best: ShapeContact | null = null\n for (const boxA of a.boxes) {\n for (const boxB of b.boxes) {\n const hit = boxBoxAlongGround(boxA, boxB)\n if (hit && (!best || hit.depth > best.depth)) best = hit\n }\n }\n return best\n}\n\n/** A box pair whose way out has more than this share along the ground meets side by side (`levelBoxesApart`). */\nconst LEVEL_NORMAL = 0.5\n\n/** How one overlapping box pair goes apart along the ground, or null when it is not to be counted. */\ntype LevelWay = (a: Box, b: Box) => ShapeContact | null\n\n/** The pair's own contact, when its way out is mostly level (side by side); null for a pair one on the other. */\nconst sideBySide: LevelWay = (a, b) => {\n const hit = boxBox(a, b)\n return hit && Math.hypot(hit.normal[0], hit.normal[2]) > LEVEL_NORMAL ? hit : null\n}\n\n/**\n * Every pair's way out (`way`) as the move along the ground it asks for (its normal laid flat, by its depth over its share along the ground, as `slideApart` moves), the\n * deepest each way along x and along z, added: wedged between two parts of the other (a book between two boards of a fallen case), the ways out cancel and it stays\n * held there. By the deepest pair alone it was pushed out of one board into the other, and back, every step, and never slept. When the sum is the deepest pair's own move\n * (one pair, or all on its side) that pair's contact comes back as it is; else a level normal (from `b` to `a`) and depth of the sum, no depth when it is nothing. Null\n * when no pair counts.\n */\nconst apartAlongGround = (a: ContactShape, b: ContactShape, way: LevelWay): ShapeContact | null => {\n if (a.kind !== 'boxes' || b.kind !== 'boxes') return null\n let deepest: ShapeContact | null = null\n let deepestX = 0, deepestZ = 0\n let xPlus = 0, xMinus = 0, zPlus = 0, zMinus = 0\n for (const boxA of a.boxes) {\n for (const boxB of b.boxes) {\n const hit = way(boxA, boxB)\n if (!hit) continue\n const flat = Math.hypot(hit.normal[0], hit.normal[2])\n const x = (hit.normal[0] * hit.depth) / (flat * flat)\n const z = (hit.normal[2] * hit.depth) / (flat * flat)\n if (!deepest || hit.depth > deepest.depth) {\n deepest = hit\n deepestX = x\n deepestZ = z\n }\n xPlus = Math.max(xPlus, x)\n xMinus = Math.min(xMinus, x)\n zPlus = Math.max(zPlus, z)\n zMinus = Math.min(zMinus, z)\n }\n }\n if (!deepest) return null\n const x = xPlus + xMinus\n const z = zPlus + zMinus\n if (x === deepestX && z === deepestZ) return deepest\n const depth = Math.hypot(x, z)\n if (depth < 1e-9) {\n const flat = Math.hypot(deepest.normal[0], deepest.normal[2])\n return { point: deepest.point, normal: [deepest.normal[0] / flat, 0, deepest.normal[2] / flat], depth: 0 }\n }\n return { point: deepest.point, normal: [x / depth, 0, z / depth], depth }\n}\n\n/** Two box shapes side by side put apart along the ground by all their side-by-side part pairs (`apartAlongGround`); a pair one on the other is its support, not counted. */\nexport function levelBoxesApart(a: ContactShape, b: ContactShape): ShapeContact | null {\n return apartAlongGround(a, b, sideBySide)\n}\n\n/** Two box shapes made inside each other put apart along the ground by all their overlapping part pairs (`boxBoxAlongGround`, then `apartAlongGround`). */\nexport function boxesApartAlongGround(a: ContactShape, b: ContactShape): ShapeContact | null {\n return apartAlongGround(a, b, boxBoxAlongGround)\n}\n\n/** Where shape `a` meets shape `b` (the normal from `b` to `a`), the deepest of their boxes; null when they do not touch. */\nexport function shapeContact(a: ContactShape, b: ContactShape): ShapeContact | null {\n if (a.kind === 'capsule' && b.kind === 'capsule') {\n const [pa, pb] = nearestOfSegments(a.from, a.to, b.from, b.to)\n const d = sub(pa, pb)\n const distance = Math.hypot(d[0], d[1], d[2])\n const reach = a.radius + b.radius\n if (distance >= reach) return null\n // side by side on one line (a can rolled straight at the end of another): apart sideways on the ground\n const normal: Vec3 = distance > 1e-6 ? [d[0] / distance, d[1] / distance, d[2] / distance] : [1, 0, 0]\n return { point: along(pb, normal, b.radius - (reach - distance) / 2), normal, depth: reach - distance }\n }\n if (a.kind === 'capsule' && b.kind === 'boxes') {\n let best: ShapeContact | null = null\n for (const box of b.boxes) {\n const hit = capsuleBox(a.from, a.to, a.radius, box)\n if (hit && (!best || hit.depth > best.depth)) best = hit\n }\n return best\n }\n if (a.kind === 'boxes' && b.kind === 'capsule') {\n const hit = shapeContact(b, a)\n return hit && { point: hit.point, normal: [-hit.normal[0], -hit.normal[1], -hit.normal[2]], depth: hit.depth }\n }\n if (a.kind === 'boxes' && b.kind === 'boxes') {\n let best: ShapeContact | null = null\n for (const boxA of a.boxes) {\n for (const boxB of b.boxes) {\n const hit = boxBox(boxA, boxB)\n if (hit && (!best || hit.depth > best.depth)) best = hit\n }\n }\n return best\n }\n return null\n}\n","import type * as THREE_NS from 'three'\nimport type { Vec3 } from '@adatechnology/game-destruction'\nimport type { BodyDesc, BodyId, HeightRegion, Material, Quat, Rolling, SeamWorld, ShapeDesc } from '@adatechnology/game-physics'\nimport { samePatch } from '@adatechnology/game-terrain'\nimport type { HeightPatch } from '@adatechnology/game-terrain'\n\nimport { GROUND_CELL, buildGroundTile, flatTile, readGround, sampleCount, shapeGround } from './engine-ground'\nimport type { AwakeList } from './awake-list'\nimport type { GroundGrid, GroundRect, GroundTile } from './engine-ground'\nimport { changedHeights } from './engine-ground-heights'\nimport { bandLength, latticePatchRead, readGroundBand, readGroundPatch } from './engine-ground-job'\nimport type { GroundPatchRead } from './engine-ground-job'\nimport type { GroundWorkerPort } from './engine-ground-port'\nimport { GroundSchedule } from './engine-ground-schedule'\nimport type { PendingGround } from './engine-ground-schedule'\nimport { SOLID_RING } from './engine-ground-ring'\nimport { NO_SOLID, SOLID_STRIDE, buildSolidVolume, sameNumbers, sameSolid } from './engine-ground-solid'\nimport type { SolidVolume } from './engine-ground-solid'\nimport { EngineStatics } from './engine-statics'\nimport type { StaticSolid } from './engine-statics'\nimport type { PartBox, PieceBody, PieceRound, PieceSweepHit } from './internal'\n\nexport type { StaticSolid } from './engine-statics'\n\nexport interface EnginePieceOptions {\n readonly groundAt: (x: number, z: number) => number\n /**\n * The exact lowest and highest `groundAt` over a rectangle (min x, max x, min z, max z), or null when unknown. A tile it proves level is laid as a slab without reading its\n * samples; without it every tile is read. Must be exact: a loose bound lays a slab where there is a crater.\n */\n readonly groundRange?: (minX: number, maxX: number, minZ: number, maxZ: number) => { readonly low: number; readonly high: number } | null\n /** `groundAt` over a lattice in one pass, to the bit (`GroundGrid`): a tile reads its samples through it instead of a call each. Without it every sample is a call. */\n readonly groundGrid?: GroundGrid\n /**\n * The rolling resistance (C_rr) of the ground's surface at (x, z), from its material (`TerrainMaterial.rolling`), or undefined for the default (`ROLLING_RESISTANCE`, a hard\n * floor). A tile of ground has the one at its middle (`tileRollingAt`): a round piece on it rolls by the larger of its own and that one. A tile reads it when it is laid and\n * again when the host marks its ground changed (`groundChanged`, through `wakeRegion`), as for its heights: a surface that changes is marked like a height that does.\n */\n readonly groundRollingAt?: (x: number, z: number) => number | undefined\n /**\n * `groundAt`'s vertices under a rectangle (`GroundPatchRead`; `Terrain.heightPatch` is one), to the bit what `groundGrid` reads there. Under `groundWorker`, a tile it covers\n * (with its ring) is asked for with its patch, about 26 x 26 numbers, not its 60 000 samples and band: the samples are made where the tile is, and a change is told by\n * comparing patches. A tile it does not cover (across the terrain's bounds) is read as before.\n */\n readonly groundPatch?: GroundPatchRead\n readonly gravity: number\n /** The fixed boxes per object; a new array for an object means it changed (measured again, broken, gone). */\n readonly staticSolids?: () => ReadonlyMap<string, readonly StaticSolid[]>\n readonly sweep?: (piece: PieceBody, from: Vec3, to: Vec3) => PieceSweepHit | null\n readonly onSlam?: (piece: PieceBody, hit: PieceSweepHit, speed: number) => void\n readonly onKnock?: (a: PieceBody, b: PieceBody, point: Vec3, speed: number) => void\n readonly onHardLanding: (piece: PieceBody, point: Vec3, speed: number) => void\n /**\n * The most tiles of ground laid at a blast (`layAhead`), nearest the centre first; 0 turns it off. A blast's pieces come into being in the next update, on tiles not laid yet:\n * laying the ones the blast reaches at the blast, before any piece needs them, takes that cost out of the frame the pieces appear in, and puts it in the explosion's. Default `BLAST_TILES` (off).\n */\n readonly blastTiles?: number\n /** Lay the ground under each part box of a piece of several parts, not under the box around all of them (default off: the same tiles as before). */\n readonly tilesUnderParts?: boolean\n /**\n * Where the tiles that read the ground are made (`GroundWorkerPort`; `RendererOptions.groundWorker`): with it, a tile asked for at update N is applied at N + `groundWorkerFrames`\n * (`GroundSchedule`), the same tile whether the worker answered or not; a piece whose ground is not laid yet waits held still. Left out (the default), every tile is made in\n * the update it is needed, as before. The engine owns the port once handed: `dispose` stops it.\n */\n readonly groundWorker?: GroundWorkerPort\n /** Updates from asking for a tile to applying it under `groundWorker` (default `GROUND_WORKER_FRAMES`, at least 1). */\n readonly groundWorkerFrames?: number\n}\n\n/** What is done with a tile a piece needs (`EnginePieces.groundOf`): laid at once, or asked of the schedule. */\ntype TileVisit = (key: number, ix: number, iz: number) => void\n\n/** Updates from asking for a tile to applying it under `groundWorker` unless the host says otherwise (owner, 2026-11-17: 1 to 3 frames of delay accepted). */\nexport const GROUND_WORKER_FRAMES = 2\n\n/** Whether a tile's engine field is the coarse one (`collisionFieldOf`): a slab never is. */\nconst wasCoarseOf = (tile: { readonly slab: boolean; readonly collision: Float32Array; readonly heights: Float32Array }): boolean => !tile.slab && tile.collision.length < tile.heights.length\n\n/** A piece's box seen from above (`EnginePieces.footprint`). */\ninterface Footprint {\n readonly corners: Float64Array\n readonly normals: Float64Array\n minX: number\n maxX: number\n minZ: number\n maxZ: number\n}\n\n/** Side of a tile of ground (m); how far around an awake piece tiles are laid (m). */\nconst TILE = 2\nconst TILE_MARGIN = 0.5\n/** How far (m) past the disc the host names a change its ground is read again (the ground's own height is read between its grid points, so a change reaches a little past them). */\nconst GROUND_REACH = 0.25\n/**\n * The share of a height field's samples a change may cover and still be written into the shape (`updateHeights`): it costs about 23 ns a sample against 0.21 ms for a whole\n * new field of 81 x 81, so past about three quarters a new shape is the cheaper (measured, T3.8q); half leaves room for the engine's own work around the write.\n */\nconst IN_PLACE_SHARE = 0.5\n/** The tiles laid at a blast unless the host says otherwise: none. Measured (T3.8ad), 48 of them moved about 24 ms into the explosion frame and left the worst frame no better. A count, not a clock, so the same blast lays the same tiles on any machine. */\nconst BLAST_TILES = 0\n/** A blast's radius counts to this far (m) when the tiles it reaches are listed: the nearest ones are laid, and the count caps the rest. */\nconst BLAST_REACH = 32\n/** A tile whose ground varies by no more than this (m) over every sample is level (`shapeGround` calls 1e-9 level; half of it leaves room for rounding). */\nconst FLAT_SPAN = 5e-10\n/**\n * How many times in a row a height field is written in place before a whole new one is made from the exact heights. Jolt's `SetHeights` also requantizes the blocks\n * left of and above the written ones, and a sample requantized from its own dequantized value moves down: up to 4.4e-5 m a write, 1.8 mm over 50 (measured, T3.8q). Four\n * writes keep the ground within 0.18 mm of the exact heights, under one step of its 8 bit samples, and the new shape resets it.\n */\nconst MAX_IN_PLACE_WRITES = 4\n/** The most (m) a piece's tips swinging in one update widen the tiles laid around its footprint. */\nconst MAX_SWING = 3\n/** The most stops along a piece's path in one update where its footprint's tiles are laid (a piece that crosses a tile or more in an update lands on ground not laid yet). */\nconst MAX_PATH_STOPS = 6\n/** A tile's key: its column and row from `TILE_KEY_ORIGIN`, in one number (no text made per tile per update). */\nconst TILE_KEY = 65536\nconst TILE_KEY_ORIGIN = 32768\nconst MU_STATIC = 0.7\nconst ROLLING_RESISTANCE = 0.015\nconst MU_DYNAMIC = 0.6\nconst GROUND: Material = { frictionStatic: MU_STATIC, frictionDynamic: MU_DYNAMIC, restitution: 0, rolling: ROLLING_RESISTANCE }\n\n/** The key of the ground tile (x, z) falls in, the engine's own (`tiles`). */\nexport const groundTileKey = (x: number, z: number): number => (Math.floor(x / TILE) + TILE_KEY_ORIGIN) * TILE_KEY + (Math.floor(z / TILE) + TILE_KEY_ORIGIN)\n/**\n * The rolling resistance of the ground at (x, z) as both solvers read it: the surface at the middle of the tile it falls in (the engine's ground is one body a tile), so\n * a tile across a road's edge is all road or all verge, the same in the kit's solver and the engine's. Undefined: the default.\n */\nexport const tileRollingAt = (rollingAt: (x: number, z: number) => number | undefined, x: number, z: number): number | undefined =>\n rollingAt((Math.floor(x / TILE) + 0.5) * TILE, (Math.floor(z / TILE) + 0.5) * TILE)\nconst STILL_SPEED = 0.12\nconst STILL_SPIN = 0.45\nconst HARD_LANDING = 3\nconst SLAM_MIN_SPEED = 2\nconst SLAM_BOUNCE = 0.2\n/** Slower than this (m/s) into a wall the engine does not have, a piece does not bounce off it: the engine's own threshold (Jolt's `mMinVelocityForRestitution`). */\nconst BOUNCE_SPEED = 1\nconst SLAM_FLOOR_NORMAL = 0.7\nconst KNOCK_EVERY = 0.15\n/** Sleeping pieces whose ground is looked at again each update, and how far (m) it must have dropped for one to wake. */\nconst GROUND_CHECKS = 16\nconst GROUND_DROP = 0.02\n/** The kit's balancing rule: a support narrower than this share of the height of the centre of mass is a balancing act, and the push (rad/s^2 per metre) that ends it. */\nconst NARROW = 0.3\n/** Radii of a round piece's profile that differ by less than this (m) are one cylinder; the segments of the ring each profile point makes in the engine's shape. */\nconst TAPER_MIN = 0.002\nconst RING_SEGMENTS = 16\nconst TOPPLE = 3\n/** How many times the point-mass bound on gravity's hold the push is: the engine held a 5 cm leg against 2.5 times it, and tipped it at 3 (measured). */\nconst HOLD_MARGIN = 4\n/** A support whose middle is closer than this (m) to the centre of mass is under it: which way it goes over is then not read from the contact points, which flicker. */\nconst SIDE_DEAD = 0.01\n/** The strong push stops once it has turned a column this fast (rad/s): a 5 cm leg tips from it; measured on the bowl, 0.1 made 4.2 cm in seed 57 and 1 made 31 cm in seed 61, 0.3 is clean in all 128. */\nconst PUSH_SPIN = 0.3\n/** Corners this close (m) to the lowest one are what it stands on. */\nconst STEADY_TURN = 0.1\nconst STEADY_SECONDS = 1.5\n/** A piece on a narrow support that has not turned for this long (s) is propped by something its contact points do not read as support (a tent of two plates on their edges). */\nconst PROPPED_SECONDS = 0.3\n/** What is left of its friction while propped: it slips, and gravity, not the kit's push, brings it down. */\nconst PROPPED_GRIP = 0.1\n/** How far (m) a new piece may reach into the ground and be left to the engine's contact (over its slop, under a thin plate's half), and how far above it one lifted is put. */\nconst SINK = 0.005\nconst LIFT_MARGIN = 0.001\n/** Ground that rises under a piece by up to this (m) is cleared by the engine's contact within an update (2 mm of push-out in each of 2 passes a step, 2 to 6 steps): the kit does not lift the piece. */\nconst ENGINE_CLEARS = 0.01\n/** Two numbers of a pose further apart than this differ (the centre comes back through the root: equal within rounding is the same). */\nconst far = (a: number, b: number): boolean => Math.abs(a - b) > 1e-6\n/** How many times a piece made inside fixed things is moved out of the deepest one (it may be inside two, or wedged between them). */\nconst OUT_TRIES = 8\n/** The first step (m) a wedged piece is lifted by (`outOfStatics`). */\nconst WEDGE_LIFT = 0.1\n/** How far (m) around a removed piece a sleeping one is woken: what rested on it touched it. */\nconst WAKE_MARGIN = 0.1\n/** A lift that leaves more than this share of the depth it had is no way out of that fixed thing: the piece is in two (`outOfStatics`). */\nconst NO_PROGRESS = 0.75\n/** How far apart (m) the poses are that a wedge lift is checked at on its way up: about the piece's thinnest half, so it cannot step over a slab it would cross. */\nconst WAY_STEP_MIN = 0.02\nconst WAY_STEP_MAX = 0.1\n\ninterface Link {\n readonly id: BodyId\n /** The ground under its centre when it went to sleep: the engine does not see `groundAt` change, the kit looks (`groundTurn`). */\n groundAtSleep: number\n readonly user: number\n shapeKey: readonly unknown[]\n /** What `shapeKey` was made from, by reference: the same objects need no new key (most updates). */\n shapeFrom: readonly unknown[]\n readonly pos: number[]\n readonly quat: number[]\n readonly vel: number[]\n readonly ang: number[]\n held: boolean\n sleeping: boolean\n /** The update it was last handed in (`update`): one not handed any more is removed. */\n seen: number\n /** Held still while its ground is being made (`hold`): kinematic at rest in the engine, the piece's own pose and speeds kept for when it goes. */\n frozen: boolean\n /** Its centre and vertical speed before the step, when it was awake (`readBack`). */\n readonly before: Vec3\n beforeVy: number\n stepped: boolean\n /** The side (x, z) the balancing push goes to: kept while the support is centred under the piece, where the contact points only flicker either way (`topple`). */\n readonly side: [number, number]\n isSlipping: boolean\n}\n\n/** A walk over the pieces an update looks at: the awake ones, or all of them. */\ntype Each = (visit: (b: PieceBody) => void) => void\n\ninterface Tile {\n /** The ground body: a slab when the tile is level, else a height field; kept across changes so what lies on it keeps its contacts. */\n ground: BodyId\n slab: boolean\n /** The step boxes' body, if the tile has steps, and the boxes it was made from. */\n steps: BodyId | null\n boxes: readonly number[] | Float64Array\n /** The solid body under the height field (not under a slab) and the boxes it was made from: a second body, so the height field keeps its own shape across changes. */\n solid: BodyId | null\n volume: SolidVolume\n /** The read grid's heights, to find what a change moved (empty under a slab); the engine's coarser field of them (`engine-ground-collision`); and how many times in a row it was written in place (`MAX_IN_PLACE_WRITES`). */\n heights: Float32Array\n collision: Float32Array\n writes: number\n /** Null for a tile proved level without reading it (its level then is `level`), and for one made from a patch (`patch`). */\n samples: Float64Array | null\n /** The terrain's vertices a tile was made from (`EnginePieceOptions.groundPatch`), the schedule's to take back when the tile is made again; null when it was read. */\n patch: HeightPatch | null\n level: number | null\n /** Where the host said the ground changed (world x and z, widened by `GROUND_REACH`): only the samples there are read again. Null when it did not. */\n dirty: GroundRect | null\n /** The surface its bodies have (`groundMaterial`): set again on them when the ground there turns to another (a blast takes the asphalt off the soil). */\n material: Material\n}\n\n/**\n * Steps the loose pieces through the kit's physics contract (`game-physics`): each piece a dynamic body at its centre of mass with its parts' boxes (or its box, or\n * its round shape), its mass, and its surface's static and dynamic friction (the engine adapter applies Coulomb per contact). The ground is `groundAt` as triangles\n * that keep its steps (`engine-ground`); the fixed things are their drawn boxes, turned as drawn. On top stay the kit's rules the engine does not know: the sweep\n * against walls, hard landings, falling over (`tip`), the knock sound, and (in `PieceSystem`) the budget of awake pieces and their rest points.\n */\nexport class EnginePieces {\n private readonly links = new Map<PieceBody, Link>()\n private readonly byUser = new Map<number, PieceBody>()\n /** The pieces by object id: what the sweep meets that the engine already has (`sweepOn`). */\n private readonly byObject = new Map<string, PieceBody>()\n private readonly byBody = new Map<BodyId, PieceBody>()\n /** The engine's awake bodies as `finish` last read them (one crossing), and the pieces they are. */\n private readonly activeIds: BodyId[] = []\n private readonly active = new Set<PieceBody>()\n private nextUser = 1\n private updates = 0\n private turn = 0\n /**\n * Pieces found wholly under the ground after a step (through a one-sided ground triangle: the engine has no solid below it) and put back on it: the invariant\n * of §12 (nothing goes under the floor), counted so a test or the room log can fail on it. A net, not a cure: none in a healthy run.\n */\n fellThrough = 0\n private readonly tiles = new Map<number, Tile>()\n /** The ground's surfaces by rolling resistance (`groundMaterial`): one object each, so a tile tells a change of surface by identity. */\n private readonly groundMaterials = new Map<number, Material>()\n /** The tiles made off the main thread on a fixed schedule (`EnginePieceOptions.groundWorker`), or null. */\n readonly schedule: GroundSchedule | null\n /** The due tiles `applyDueGround` takes (kept, so an update makes no list). */\n private readonly due: PendingGround[] = []\n /** Whether a tile the piece being visited needs is not laid yet (`askAt`). */\n private waits = false\n /** Blast tiles to ask for again once the tile being made there is applied (`askBlastAt`), by key. */\n private readonly blastAgain = new Set<number>()\n /** The pieces held for their ground in this update (`layGroundLater`). */\n private readonly waiting = new Set<PieceBody>()\n /** The blasts told since the last `prepare` (`layAhead`). */\n private readonly blasts: Array<{ x: number; z: number; radius: number }> = []\n /** The host's fixed things (`staticSolids`) as static bodies. */\n readonly statics: EngineStatics\n private readonly ignored = new Set<string>()\n private readonly knocks = new Map<string, number>()\n private readonly footprintOut: Footprint = { corners: new Float64Array(16), normals: new Float64Array(6), minX: 0, maxX: 0, minZ: 0, maxZ: 0 }\n private readonly pose = new Float64Array(7)\n private readonly velocity = new Float64Array(6)\n private readonly contactXYZ = new Float32Array(48)\n private readonly outAxis = new Float64Array(3)\n private readonly wayAxis = new Float64Array(3)\n /** The centre `readBack` reads into (the sweep may move it). */\n private readonly readPos: Vec3 = [0, 0, 0]\n private readonly v: THREE_NS.Vector3\n private readonly u: THREE_NS.Vector3\n private readonly w: THREE_NS.Vector3\n private readonly turn3: THREE_NS.Quaternion\n private readonly partQuaternion: THREE_NS.Quaternion\n private readonly partCentre: THREE_NS.Vector3\n\n constructor(\n THREE: typeof THREE_NS,\n private readonly world: SeamWorld,\n private readonly o: EnginePieceOptions,\n ) {\n this.v = new THREE.Vector3()\n this.u = new THREE.Vector3()\n this.w = new THREE.Vector3()\n this.turn3 = new THREE.Quaternion()\n this.partQuaternion = new THREE.Quaternion()\n this.partCentre = new THREE.Vector3()\n this.statics = new EngineStatics(world, GROUND)\n this.schedule = o.groundWorker ? new GroundSchedule(o.groundWorker, Math.max(1, Math.round(o.groundWorkerFrames ?? GROUND_WORKER_FRAMES))) : null\n if (this.schedule) this.warmGround(this.schedule)\n }\n\n /** The worker's first job, a sloped tile with steps away from the host's ground (no host call): its code is parsed and hot before the first blast asks for real ones. */\n private warmGround(schedule: GroundSchedule): void {\n const warmGround = (x: number, z: number): number => 0.3 * x - 0.2 * z + 0.15 * Math.floor(x / 0.37) + 0.05 * Math.sin(3 * z)\n const samples = new Float64Array(sampleCount(Math.round(TILE / GROUND_CELL)))\n readGround(warmGround, samples, 0, 0, TILE)\n const band = new Float64Array(bandLength(TILE))\n readGroundBand(warmGround, band, 0, 0, TILE)\n schedule.warm(samples, band, 0, 0, TILE)\n // the warm patch is read the way a real one is (`readGroundPatch` over the tile and its ring), so it fits whatever the tile and the ring are\n if (this.o.groundPatch) schedule.warmPatch(readGroundPatch(latticePatchRead(warmGround), 0, 0, TILE) as HeightPatch, 0, 0, TILE)\n }\n\n /** A piece not handed in this update goes (`update`; a callback made once, so the walk makes no entry per piece). */\n private readonly removeUnseen = (link: Link, b: PieceBody): void => {\n if (link.seen !== this.updates) this.remove(b)\n }\n\n remove(b: PieceBody, wakeNeighbours = true): void {\n const link = this.links.get(b)\n if (!link) return\n this.world.removeBody(link.id)\n // an awake piece shares its island with what rests on it, so only a sleeping one leaves sleepers behind: asleep for the kit now, or asleep when the engine last\n // stepped and woken (a blow, its support looked at again) in this same frame, before the engine could wake what lay on it (CLAUDE.md §12)\n if (wakeNeighbours && (b.sleeping || link.sleeping)) this.wakeAround(b, link.pos)\n this.byUser.delete(link.user)\n this.byBody.delete(link.id)\n this.active.delete(b)\n if (this.byObject.get(b.objectId) === b) this.byObject.delete(b.objectId)\n this.links.delete(b)\n }\n\n /** What lay on a piece that went is awake again (a sleeping body holds no contact with what is no longer there). */\n private wakeAround(b: PieceBody, at: readonly number[]): void {\n const boxes: readonly PartBox[] = b.partBoxes && b.partBoxes.length > 0 ? b.partBoxes : [{ center: [0, 0, 0], half: b.halfExtents }]\n let reach = 0\n for (const box of boxes) reach = Math.max(reach, Math.hypot(...box.center) + Math.hypot(...box.half))\n reach += WAKE_MARGIN\n this.world.wakeInBox([at[0]! - reach, at[1]! - reach, at[2]! - reach], [at[0]! + reach, at[1]! + reach, at[2]! + reach])\n }\n\n clear(): void {\n for (const b of [...this.links.keys()]) this.remove(b, false)\n for (const t of this.tiles.values()) {\n this.world.removeBody(t.ground)\n if (t.steps !== null) this.world.removeBody(t.steps)\n if (t.solid !== null) this.world.removeBody(t.solid)\n }\n this.tiles.clear()\n this.schedule?.clear()\n this.blastAgain.clear()\n this.blasts.length = 0\n this.statics.clear()\n this.ignored.clear()\n }\n\n /** Everything cleared and the ground worker stopped (`EnginePieceOptions.groundWorker`). */\n dispose(): void {\n this.clear()\n this.schedule?.dispose()\n }\n\n /** A blast at (x, z): the tiles within `radius` of it that are not laid, or are marked, are laid at the start of the next `prepare`, after the ground the blast changed has been told. */\n layAhead(x: number, z: number, radius: number): void {\n if ((this.o.blastTiles ?? BLAST_TILES) <= 0) return\n this.blasts.push({ x, z, radius: Math.min(radius, BLAST_REACH) })\n }\n\n /**\n * The ground under the disc changed (the host dug or heaped it): its tiles are laid again before the next step, and what the new ground reaches into is lifted\n * onto it once, as one made in the ground is (`underGround`): the engine pushes a deep one out too slowly and puts it to sleep half way.\n */\n groundChanged(x: number, z: number, radius: number): void {\n this.markDirty(x, z, radius)\n for (const [b, link] of this.links) {\n if (b.held) continue\n const c = this.centre(b)\n if (Math.hypot(c.x - x, c.z - z) > radius + Math.hypot(...b.halfExtents)) continue\n // lifted, a 1 t pole whose wire tip meets settling rubble would gain its weight times the rise from nowhere\n const under = this.underGround(b)\n if (under <= 0) continue\n if (under <= ENGINE_CLEARS) {\n // a rise the engine clears by itself, but only an awake body is cleared: one asleep with its centre out of the disc stayed 8 mm in the ground for good\n if (b.sleeping) {\n b.sleeping = false\n b.still = 0\n b.calmAt = null\n }\n continue\n }\n b.root.position.y += under\n b.root.updateMatrixWorld(true)\n link.groundAtSleep = NaN\n }\n }\n\n /** The tiles the blasts told since the last update reach, nearest first up to `blastTiles`: made if new, laid again if marked. */\n private layBlastGround(): void {\n this.askBlastAgain()\n if (this.blasts.length === 0) return\n const wanted = new Map<number, { key: number; ix: number; iz: number; distance: number }>()\n for (const { x, z, radius } of this.blasts) {\n for (let ix = Math.floor((x - radius) / TILE); ix <= Math.floor((x + radius) / TILE); ix++) {\n for (let iz = Math.floor((z - radius) / TILE); iz <= Math.floor((z + radius) / TILE); iz++) {\n const key = (ix + TILE_KEY_ORIGIN) * TILE_KEY + (iz + TILE_KEY_ORIGIN)\n const tile = this.tiles.get(key)\n if (tile && tile.dirty === null) continue\n const distance = Math.hypot(Math.max(ix * TILE, Math.min(x, (ix + 1) * TILE)) - x, Math.max(iz * TILE, Math.min(z, (iz + 1) * TILE)) - z)\n if (distance > radius) continue\n const before = wanted.get(key)\n if (!before || distance < before.distance) wanted.set(key, { key, ix, iz, distance })\n }\n }\n }\n this.blasts.length = 0\n const nearest = [...wanted.values()].sort((a, b) => a.distance - b.distance || a.key - b.key)\n const visit = this.schedule ? this.askBlastAt : this.layAt\n for (const t of nearest.slice(0, this.o.blastTiles ?? BLAST_TILES)) visit(t.key, t.ix, t.iz)\n }\n\n /** Under the ground worker, a blast's tile already being made (from the ground before the blast) is asked for again once it is applied (`askBlastAgain`). */\n private readonly askBlastAt: TileVisit = (key, ix, iz) => {\n if ((this.schedule as GroundSchedule).pending.has(key)) this.blastAgain.add(key)\n else this.askAt(key, ix, iz)\n }\n\n /** The blast tiles that were being made when their blast came, asked for again now that they are applied (if their ground changed since). */\n private askBlastAgain(): void {\n const schedule = this.schedule\n if (!schedule || this.blastAgain.size === 0) return\n for (const key of this.blastAgain) {\n if (schedule.pending.has(key)) continue\n this.blastAgain.delete(key)\n this.askAt(key, Math.floor(key / TILE_KEY) - TILE_KEY_ORIGIN, (key % TILE_KEY) - TILE_KEY_ORIGIN)\n }\n }\n\n /**\n * The tiles the disc touches are laid again before the next step, reading the ground again where the disc is (and `GROUND_REACH` past it); and those within `SOLID_RING`\n * of it, whose solid reads the ground that far past their edges (`engine-ground-ring`): a neighbour's dig makes it again when it changed a sample it read.\n */\n private markDirty(x: number, z: number, radius: number): void {\n for (const [key, tile] of this.tiles) tile.dirty = this.markOf(key, tile.dirty, x, z, radius)\n // a fresh tile being made has no record yet: its mark waits on the schedule and goes onto the tile when applied\n if (this.schedule) for (const [key, p] of this.schedule.pending) if (p.fresh) p.dirty = this.markOf(key, p.dirty, x, z, radius)\n }\n\n /** The tile's mark widened by the change at (x, z) when it reaches the tile or its ring, else as it was. */\n private markOf(key: number, before: GroundRect | null, x: number, z: number, radius: number): GroundRect | null {\n const reach = radius + GROUND_REACH\n const ix = Math.floor(key / TILE_KEY) - TILE_KEY_ORIGIN\n const iz = (key % TILE_KEY) - TILE_KEY_ORIGIN\n const nx = Math.max(ix * TILE, Math.min(x, (ix + 1) * TILE))\n const nz = Math.max(iz * TILE, Math.min(z, (iz + 1) * TILE))\n if (Math.hypot(nx - x, nz - z) > radius + SOLID_RING) return before\n return {\n minX: Math.min(before?.minX ?? Infinity, x - reach),\n maxX: Math.max(before?.maxX ?? -Infinity, x + reach),\n minZ: Math.min(before?.minZ ?? Infinity, z - reach),\n maxZ: Math.max(before?.maxZ ?? -Infinity, z + reach),\n }\n }\n\n /**\n * Before the frame's fixed steps: the pairs in `apart` (by object id, `a\\0b`) do not meet in the engine; the kit puts them apart along the ground. `dt` is the frame's\n * time, `h` the fixed step a kinematic target is reached in.\n */\n prepare(list: readonly PieceBody[], dt: number, h: number, apart: ReadonlySet<string>, awake?: AwakeList): void {\n // nothing here is made anew per piece per update (the collector's pauses were the worst frames: gate 0 B5)\n const n = ++this.updates\n // handed the awake pieces only, the walks are over them and a piece goes by `remove`, not by being left out of the list\n const each: Each = awake ? awake.walk.bind(awake) : (visit) => list.forEach(visit)\n each((b) => {\n const link = this.links.get(b)\n if (link) link.seen = n\n })\n if (!awake) this.links.forEach(this.removeUnseen)\n this.groundTurn(list)\n // the fixed things first: a piece made or put this update is checked against them (`outOfStatics`)\n this.layStatics()\n // the tiles asked for `frames` updates ago, before anything asks again: at this update whatever the worker did\n this.applyDueGround()\n this.layBlastGround()\n this.makeBodies(each)\n each((b) => this.sync(b, dt, h))\n if (this.schedule) this.layGroundLater(each, dt)\n else this.layGround(each, dt)\n this.keepApart(apart)\n each((b) => {\n const link = this.links.get(b)\n if (!link) return\n link.stepped = !b.held && !b.sleeping && !link.frozen\n if (!link.stepped) return\n const c = this.centre(b)\n link.before[0] = c.x\n link.before[1] = c.y\n link.before[2] = c.z\n link.beforeVy = b.velocity[1]\n })\n }\n\n /** Before each fixed step after the first of a frame: a held piece's target again, so it moves by `h`, not by the frame's `dt`. */\n moveHeld(list: readonly PieceBody[], h: number, awake?: AwakeList): void {\n const each: Each = awake ? awake.walk.bind(awake) : (visit) => list.forEach(visit)\n each((b) => {\n const link = this.links.get(b)\n if (!link || !b.held) return\n const c = this.centre(b)\n const q = b.root.quaternion\n this.world.moveKinematic(link.id, [c.x, c.y, c.z], [q.x, q.y, q.z, q.w], h)\n })\n }\n\n /** After the frame's fixed steps: each piece read back with the kit's rules on it, then the knock sounds from the frame's contact rows. */\n finish(list: readonly PieceBody[], dt: number, time: number, awake?: AwakeList): void {\n if (awake) {\n this.readActive(awake)\n awake.walk((b) => this.readBack(b, dt, time, this.active))\n } else for (const b of list) this.readBack(b, dt, time, null)\n this.knock(time)\n }\n\n /** The engine's awake bodies in one crossing: a sleeping piece one of them wakes (a blow) is among the awake pieces from now on, and read back in this same step. */\n private readActive(awake: AwakeList): void {\n this.active.clear()\n const n = this.world.readActiveBodies(this.activeIds)\n for (let i = 0; i < n; i++) {\n const b = this.byBody.get(this.activeIds[i] as BodyId)\n if (!b) continue\n this.active.add(b)\n awake.enter(b)\n }\n }\n\n /** The host moved the piece's root or changed what its shape is made from since `sync` last looked: its body is not up to date. */\n private isPending(b: PieceBody, link: Link): boolean {\n if (!this.sameFrom(b, link.shapeFrom)) return true\n const c = this.centre(b)\n const q = b.root.quaternion\n return far(c.x, link.pos[0]) || far(c.y, link.pos[1]) || far(c.z, link.pos[2]) || far(q.x, link.quat[0]) || far(q.y, link.quat[1]) || far(q.z, link.quat[2]) || far(q.w, link.quat[3])\n }\n\n /** Before the measure: a settled piece the host moved or reshaped by hand is among the awake ones again, so its `sync` runs as it did when every piece was synced. */\n wakePending(list: readonly PieceBody[], awake: AwakeList): void {\n for (const b of list) {\n if (awake.has(b)) continue\n const link = this.links.get(b)\n if (link && this.isPending(b, link)) awake.enter(b)\n }\n }\n\n /** Asleep on both sides (as `finish` last read the engine's) and not waiting for its ground: nothing of it is read or written until it wakes. */\n isSettled(b: PieceBody): boolean {\n const link = this.links.get(b)\n if (!link || !b.sleeping || b.held || !link.sleeping || link.frozen || this.active.has(b) || this.isPending(b, link)) return false\n // the grip a propped piece lost is back before it sleeps unread: waking it (a blow) steps it with its own friction, as when its sync ran each update\n this.slip(b, link, false)\n link.stepped = false\n b.still = 0\n return true\n }\n\n /**\n * A few sleeping pieces each update (`GROUND_CHECKS`, in turn) look at the ground under them again: dug or slid away since they slept (and nobody called\n * `wakeRegion`), they wake and the ground there is laid again. Their other supports are the engine's: it wakes what lay on a body that moves.\n */\n private groundTurn(list: readonly PieceBody[]): void {\n const n = list.length\n for (let k = 0; k < Math.min(GROUND_CHECKS, n); k++) {\n this.turn = (this.turn + 1) % n\n const b = list[this.turn]\n const link = this.links.get(b)\n if (!link || !b.sleeping || b.held || Number.isNaN(link.groundAtSleep)) continue\n const c = this.centre(b)\n if (Math.abs(this.o.groundAt(c.x, c.z) - link.groundAtSleep) <= GROUND_DROP) continue\n b.sleeping = false\n b.still = 0\n this.groundChanged(c.x, c.z, Math.hypot(...b.halfExtents))\n }\n }\n\n /** A round piece whose radius changes along its axis (a bottle, a cup): its shape is not the straight cylinder at its widest, or it would roll straight. */\n private isTapered(round: PieceRound): boolean {\n const radii = round.profile?.map(([, radius]) => radius) ?? []\n return radii.length > 1 && Math.max(...radii) - Math.min(...radii) > TAPER_MIN\n }\n\n /** The hull of the rings of its profile (`PieceRound.profile`), in the piece's frame: a cone, or a bottle, rolls round its narrow end. */\n private ringPoints(round: PieceRound): number[] {\n const points: number[] = []\n const across = [0, 1, 2].filter((axis) => axis !== round.axis)\n for (const [at, radius] of round.profile ?? []) {\n for (let k = 0; k < RING_SEGMENTS; k++) {\n const angle = (2 * Math.PI * k) / RING_SEGMENTS\n const point = [0, 0, 0]\n point[round.axis] = at\n point[across[0]!] = Math.cos(angle) * radius\n point[across[1]!] = Math.sin(angle) * radius\n points.push(point[0]!, point[1]!, point[2]!)\n }\n }\n return points\n }\n\n private shapeOf(b: PieceBody): ShapeDesc {\n const round = b.round\n if (round) {\n if (round.kind === 'sphere') return { kind: 'sphere', radius: round.radius }\n if (this.isTapered(round)) return { kind: 'compound', children: [{ shape: { kind: 'convex', points: this.ringPoints(round) }, position: [0, 0, 0] }] }\n // a cylinder stands along its own y: turned onto x or z\n const rotation: Quat = round.axis === 0 ? [0, 0, Math.SQRT1_2, Math.SQRT1_2] : round.axis === 2 ? [Math.SQRT1_2, 0, 0, Math.SQRT1_2] : [0, 0, 0, 1]\n return { kind: 'compound', children: [{ shape: { kind: 'cylinder', halfHeight: b.halfExtents[round.axis], radius: round.radius }, position: [0, 0, 0], rotation }] }\n }\n if (b.partBoxes && b.partBoxes.length > 0) {\n return { kind: 'compound', children: b.partBoxes.map((part, i) => ({ shape: { kind: 'box', half: part.half }, position: part.center, ...(part.rotation ? { rotation: part.rotation } : {}), tag: i })) }\n }\n return { kind: 'box', half: b.halfExtents }\n }\n\n /**\n * How far (m) a new piece reaches under the ground: its part boxes' corners (a round piece: the lowest points of its rim) below `groundAt`. The ground is a surface\n * to the engine, and a piece made through it is caught by its sides and pushed down, not out; so it is lifted out once, when its body is made, never later.\n */\n private underGround(b: PieceBody): number {\n // from the root's own position and turn: its world matrix may not be up to date yet when the piece is new\n const c = this.centre(b)\n const cx = c.x, cy = c.y, cz = c.z\n const q = b.root.quaternion\n const p = this.u\n let under = 0\n const at = (x: number, y: number, z: number, below = 0): void => {\n p.set(x, y, z).applyQuaternion(q)\n under = Math.max(under, this.o.groundAt(cx + p.x, cz + p.z) - (cy + p.y - below))\n }\n const round = b.round\n if (round) {\n const axis: Vec3 = [round.axis === 0 ? 1 : 0, round.axis === 1 ? 1 : 0, round.axis === 2 ? 1 : 0]\n const tilt = p.set(axis[0], axis[1], axis[2]).applyQuaternion(q).y\n const reach = round.kind === 'sphere' ? round.radius : round.radius * Math.sqrt(Math.max(0, 1 - tilt * tilt))\n const h = round.kind === 'sphere' ? 0 : b.halfExtents[round.axis]\n for (const s of [-1, 1]) at(axis[0] * h * s, axis[1] * h * s, axis[2] * h * s, reach)\n return this.liftFor(b, under)\n }\n // the part boxes sit about the centre of mass, as the body's compound does\n const boxes: readonly PartBox[] = b.partBoxes && b.partBoxes.length > 0 ? b.partBoxes : [{ center: [0, 0, 0], half: b.halfExtents }]\n const corner = this.w\n for (const box of boxes) {\n const r = box.rotation\n for (let k = 0; k < 8; k++) {\n corner.set((k & 1 ? 1 : -1) * box.half[0], (k & 2 ? 1 : -1) * box.half[1], (k & 4 ? 1 : -1) * box.half[2])\n if (r) corner.applyQuaternion(this.turn3.set(r[0], r[1], r[2], r[3]))\n at(box.center[0] + corner.x, box.center[1] + corner.y, box.center[2] + corner.z)\n }\n }\n return this.liftFor(b, under)\n }\n\n /**\n * Made through the ground by more than a contact's sink and less than its own size: lifted onto it. Deeper than its largest half size it is not lying in the\n * ground but under something `groundAt` folds into it (a box on the floor half under a table top), and it is left where it is.\n */\n private liftFor(b: PieceBody, under: number): number {\n return under > SINK && under <= Math.max(...b.halfExtents) ? under + LIFT_MARGIN : 0\n }\n\n /** A round piece turns about its axis by its own k (a full can, an empty one); about the others, and for a box, the engine's from the shape. */\n private inertiaOf(b: PieceBody): Vec3 | undefined {\n const round = b.round\n if (!round) return undefined\n const [hx, hy, hz] = b.halfExtents\n const m = b.mass\n const out: [number, number, number] = [(m * (hy * hy + hz * hz)) / 3, (m * (hx * hx + hz * hz)) / 3, (m * (hx * hx + hy * hy)) / 3]\n const about = round.inertia * m * round.radius * round.radius\n if (round.kind === 'sphere') return [about, about, about]\n out[round.axis] = about\n return out\n }\n\n /** A round piece rolls to a stop by its surface's rolling resistance (the adapter's rule; the engine has none). */\n private rollingOf(b: PieceBody): Rolling | undefined {\n return b.round ? { coefficient: b.friction?.rolling ?? ROLLING_RESISTANCE, radius: b.round.radius } : undefined\n }\n\n private material(b: PieceBody): Material {\n return {\n frictionStatic: b.friction?.static ?? MU_STATIC,\n frictionDynamic: b.friction?.dynamic ?? MU_DYNAMIC,\n // a box lands dead (the kit never bounced them); a round piece bounces by its material\n restitution: b.round ? (b.restitution ?? SLAM_BOUNCE) : 0,\n rolling: b.friction?.rolling ?? ROLLING_RESISTANCE,\n }\n }\n\n /** The bodies of the pieces that have none yet, made in one batch (one broadphase insert, ids in list order) and then each checked against the fixed things. */\n private makeBodies(each: Each): void {\n const fresh: PieceBody[] = []\n each((b) => {\n if (!this.links.has(b)) fresh.push(b)\n })\n if (fresh.length === 0) return\n const users: number[] = []\n const descs = fresh.map((b) => {\n const under = this.underGround(b)\n if (under > 0) {\n b.root.position.y += under\n b.root.updateMatrixWorld(true)\n }\n const user = this.nextUser++\n users.push(user)\n return this.bodyDesc(b, user)\n })\n const ids = this.world.createBodies(descs)\n fresh.forEach((b, i) => {\n const c = this.centre(b)\n const q = b.root.quaternion\n const user = users[i] as number\n const id = ids[i] as BodyId\n const link: Link = {\n id, groundAtSleep: NaN, user, shapeKey: this.shapeKey(b), shapeFrom: this.shapeFrom(b), pos: [c.x, c.y, c.z], quat: [q.x, q.y, q.z, q.w], vel: [...b.velocity], ang: [...b.angularVelocity],\n held: b.held, sleeping: b.sleeping, seen: this.updates, frozen: false, before: [0, 0, 0], beforeVy: 0, stepped: false, side: [1, 1], isSlipping: false,\n }\n this.links.set(b, link)\n this.byUser.set(user, b)\n this.byBody.set(id, b)\n this.byObject.set(b.objectId, b)\n this.outOfStatics(b, link)\n })\n }\n\n private bodyDesc(b: PieceBody, user: number): BodyDesc {\n const c = this.centre(b)\n const q = b.root.quaternion\n return {\n shape: this.shapeOf(b),\n motion: b.held ? 'kinematic' : 'dynamic',\n position: [c.x, c.y, c.z],\n rotation: [q.x, q.y, q.z, q.w],\n mass: b.mass,\n inertia: this.inertiaOf(b),\n centreAtOrigin: true,\n material: this.material(b),\n layer: 'debris',\n // no air drag: the kit's pieces never had any (a round piece's rolling resistance is the adapter's, `rolling`)\n angularDamping: 0,\n linearDamping: 0,\n // swept (Jolt's linear cast) so nothing the engine has is passed through, now that the kit's sweep no longer sets a piece back from it (`sweepOn`); the\n // engine casts only a body that moves more than most of its own thickness in a step, so one at rest costs nothing more\n continuous: true,\n rolling: this.rollingOf(b),\n sleeping: b.sleeping,\n user,\n linearVelocity: [b.velocity[0], b.velocity[1], b.velocity[2]],\n angularVelocity: [b.angularVelocity[0], b.angularVelocity[1], b.angularVelocity[2]],\n }\n }\n\n /** Brings the body of a piece up to date with what changed on the piece since the last step (moved, pushed, picked up, put to sleep). */\n private sync(b: PieceBody, dt: number, h: number): void {\n const c = this.centre(b)\n const q = b.root.quaternion\n const link = this.links.get(b)\n if (!link) return\n // by value: the renderer hands new arrays for the same boxes when it measures a piece again, and a new shape wakes the body; the same objects as last time\n // are the same shape, and are not turned into text again (it was a sixth of an update with 200 pieces)\n if (!this.sameFrom(b, link.shapeFrom)) this.reshape(b, link)\n if (b.held !== link.held) {\n link.held = b.held\n this.world.setMotion(link.id, b.held ? 'kinematic' : 'dynamic')\n }\n if (b.held) {\n this.world.moveKinematic(link.id, [c.x, c.y, c.z], [q.x, q.y, q.z, q.w], h)\n return\n }\n // the centre comes back through the root (position minus the turned centre, then plus it again): equal within rounding is not moved\n const moved = far(c.x, link.pos[0]) || far(c.y, link.pos[1]) || far(c.z, link.pos[2]) || far(q.x, link.quat[0]) || far(q.y, link.quat[1]) || far(q.z, link.quat[2]) || far(q.w, link.quat[3])\n if (moved) this.world.setPose(link.id, [c.x, c.y, c.z], [q.x, q.y, q.z, q.w], !b.sleeping)\n if (moved && b.sleeping) {\n // nothing reads it back while it sleeps: where it was put is where it is, or it would look moved on every update\n link.pos[0] = c.x\n link.pos[1] = c.y\n link.pos[2] = c.z\n link.quat[0] = q.x\n link.quat[1] = q.y\n link.quat[2] = q.z\n link.quat[3] = q.w\n }\n if (link.frozen) return this.keepFrozen(b, link, moved)\n // `tip` is the kit solver's push for a piece whose feet are thinner than its box; here the engine stands it on its parts as drawn, so it goes over by itself\n b.tipping = null\n if (!b.round && b.onGround && !b.sleeping) this.topple(b, dt)\n else this.slip(b, link, false)\n const v = b.velocity\n const w = b.angularVelocity\n const pushed = v[0] !== link.vel[0] || v[1] !== link.vel[1] || v[2] !== link.vel[2] || w[0] !== link.ang[0] || w[1] !== link.ang[1] || w[2] !== link.ang[2]\n if (pushed) this.world.setVelocity(link.id, [v[0], v[1], v[2]], [w[0], w[1], w[2]])\n if (b.sleeping && !link.sleeping) this.world.sleep(link.id)\n else if (!b.sleeping && link.sleeping) {\n // woken from outside (its support looked at again, a blow): the ground under it may have been dug while it slept\n this.world.wake(link.id)\n this.markDirty(c.x, c.z, Math.hypot(...b.halfExtents))\n } else if (pushed) this.world.wake(link.id)\n }\n\n /**\n * A piece made or put by the kit or the host (not moved by the engine) inside a fixed thing goes out of it at once, the shortest way, as one made in the ground is\n * lifted (`underGround`). Left to the engine it is pushed out a little each step (`maxPushOut`), which reads as the piece rising by itself: a roof sheet made 1 m\n * into a shelf rose 0.83-0.94 m over the room's 11 s. Only past a contact's sink (`SINK`): resting on a shelf it is not moved.\n */\n private outOfStatics(b: PieceBody, link: Link): void {\n if (!this.world.penetration) return\n const axis = this.outAxis\n let px = 0, py = 0, pz = 0\n let wedged = false\n let lifts = 0\n // what the piece was made inside, how deep it was where it turned out to be wedged, and how far the tries moved it in all: a way out that is no better is put back (`putBack`)\n let found = 0\n let wedge = 0\n let previous = 0\n const moved = [0, 0, 0]\n for (let i = 0; i < OUT_TRIES; i++) {\n // the host's fixed things only: a piece made in the ground is the ground's rule (`underGround`; out of a step the shortest way too, the bowl's seed 39 made 3 mm)\n const depth = this.world.penetration(link.id, axis, this.statics.ids)\n if (depth <= SINK) return\n if (i === 0) found = depth\n // out of one the shortest way put it back into the other (a door made between its frame and a car parked against the wall), or no shallower for it (a door whose jamb it overlaps the same at any height rode up 0.4 m): it goes up out of both\n wedged ||= i > 0 && (axis[0] * px + axis[1] * py + axis[2] * pz < -0.5 || depth > previous * NO_PROGRESS)\n previous = depth\n px = axis[0]\n py = axis[1]\n pz = axis[2]\n if (wedged) {\n axis[0] = 0\n axis[1] = 1\n axis[2] = 0\n }\n // up out of a wedge, the depth across tells nothing of how high the two reach: a step that doubles each try, at most twice as high as it had to go\n const d = wedged ? depth + WEDGE_LIFT * 2 ** lifts++ : depth + LIFT_MARGIN\n this.world.readPose(link.id, this.pose, 0)\n // a lift that goes through a third fixed thing on its way (a door made in its doorway, lifted past the lintel, the ceiling slab and into the attic) is no exit\n if (wedged && wedge === 0) wedge = depth + SINK\n if (wedged && !this.isWayClear(b, link, d, wedge)) {\n this.putBack(b, link, moved)\n return\n }\n this.moveBy(b, link, axis, d, moved)\n }\n if (this.world.penetration(link.id, axis, this.statics.ids) > found) this.putBack(b, link, moved)\n }\n\n /** The piece is moved by `d` along `axis`, in the engine and on its root (`this.pose` is where it stands); `moved` adds it up. */\n private moveBy(b: PieceBody, link: Link, axis: Float64Array, d: number, moved: number[]): void {\n const p = this.pose\n p[0] += axis[0] * d\n p[1] += axis[1] * d\n p[2] += axis[2] * d\n this.world.setPose(link.id, [p[0], p[1], p[2]], [p[3], p[4], p[5], p[6]], !b.sleeping)\n for (let k = 0; k < 3; k++) moved[k] += axis[k] * d\n b.root.position.x += axis[0] * d\n b.root.position.y += axis[1] * d\n b.root.position.z += axis[2] * d\n b.root.updateMatrixWorld(true)\n link.pos[0] = p[0]\n link.pos[1] = p[1]\n link.pos[2] = p[2]\n }\n\n /** Back to where the piece was made: the tries moved it by `moved`, and the engine is left to push it out of what it is in (a little each step). */\n private putBack(b: PieceBody, link: Link, moved: number[]): void {\n const back = this.wayAxis\n back[0] = -moved[0]\n back[1] = -moved[1]\n back[2] = -moved[2]\n this.world.readPose(link.id, this.pose, 0)\n this.moveBy(b, link, back, 1, moved)\n }\n\n /** Whether going up by `d` from `this.pose` meets no fixed thing deeper than `limit` (m): sampled about every thinnest half of the piece, which leaves the body where it was. */\n private isWayClear(b: PieceBody, link: Link, d: number, limit: number): boolean {\n const p = this.pose\n const up = this.outAxis\n const step = Math.min(WAY_STEP_MAX, Math.max(WAY_STEP_MIN, Math.min(...b.halfExtents)))\n let isClear = true\n for (let s = step; s < d && isClear; s += step) {\n this.world.setPose(link.id, [p[0] + up[0] * s, p[1] + up[1] * s, p[2] + up[2] * s], [p[3], p[4], p[5], p[6]], false)\n isClear = (this.world.penetration?.(link.id, this.wayAxis, this.statics.ids) ?? 0) <= limit\n }\n this.world.setPose(link.id, [p[0], p[1], p[2]], [p[3], p[4], p[5], p[6]], false)\n return isClear\n }\n\n /**\n * Its shape, mass, friction or bounce changed (by value: the renderer hands new arrays for the same boxes when it measures a piece again, and a new shape wakes the\n * body; the same objects as last time are the same shape, and are not turned into text again: it was a sixth of an update with 200 pieces).\n */\n private reshape(b: PieceBody, link: Link): void {\n const from = this.shapeFrom(b)\n link.shapeFrom = from\n const shapeKey = this.shapeKey(b)\n if (!shapeKey.some((x, i) => x !== link.shapeKey[i])) return\n link.shapeKey = shapeKey\n // the piece's mass and moments go with its new shape: left to the engine, they would be the new shape's volume at 1000 kg/m^3\n const inertia = this.inertiaOf(b)\n this.world.setShape(link.id, this.shapeOf(b), inertia ? { mass: b.mass, inertia } : { mass: b.mass })\n this.world.setMaterial(link.id, this.material(b))\n this.world.setRolling(link.id, this.rollingOf(b))\n }\n\n /** Whether the objects its shape is made from are the ones it was made from (by reference, as `shapeFrom` lists them). */\n private sameFrom(b: PieceBody, from: readonly unknown[]): boolean {\n return (\n from[0] === b.halfExtents && from[1] === b.partBoxes && from[2] === b.round && from[3] === b.mass && from[4] === b.localCenter[0] && from[5] === b.localCenter[1] &&\n from[6] === b.localCenter[2] && from[7] === b.friction && from[8] === b.restitution\n )\n }\n\n private shapeFrom(b: PieceBody): unknown[] {\n return [b.halfExtents, b.partBoxes, b.round, b.mass, b.localCenter[0], b.localCenter[1], b.localCenter[2], b.friction, b.restitution]\n }\n\n private shapeKey(b: PieceBody): unknown[] {\n return [JSON.stringify(b.halfExtents), JSON.stringify(b.partBoxes), JSON.stringify(b.round), b.mass, b.localCenter[0], b.localCenter[1], b.localCenter[2], JSON.stringify(b.friction), b.restitution]\n }\n\n /**\n * The kit's balancing rule (§12: what stands on less than its centre of mass needs goes over): the points the engine has it touching by are its support; narrower than `NARROW` of the height of the centre of mass above them, or not under it, the piece gets the kit's push toward the side\n * it leans to. The engine alone keeps a door balanced on its 4 cm edge for ever.\n */\n /**\n * The push (rad/s2) that turns a piece about the edge of its support at `edge` (m from its centre, `height` m above it): the kit's `TOPPLE`, and on a support narrow both ways (a leg, a pole: a plate on its\n * edge is narrow one way only) at least what beats gravity's hold (at most `g |edge| / (height^2 + edge^2)` for any shape: a 5 cm leg 74 cm tall held against `TOPPLE` alone and stood for ever). Not where only\n * the contacts of one instant sit off its centre: a box rocking on a table's edge reads like that, and stays.\n */\n private topplePush(edge: number, height: number, isNarrow: boolean): number {\n const push = TOPPLE * Math.min(height, 1)\n return isNarrow ? Math.max(push, (HOLD_MARGIN * this.o.gravity * Math.abs(edge)) / (height * height + edge * edge)) : push\n }\n\n private topple(b: PieceBody, dt: number): void {\n const link = this.links.get(b)\n if (!link) return\n // where the engine has it touching (the floor, a step, another piece), from its centre of mass\n const n = this.world.contactPoints(link.id, this.contactXYZ)\n if (n === 0) {\n this.slip(b, link, false)\n return\n }\n const c = this.centre(b)\n const q = b.root.quaternion\n let low = Infinity\n for (let i = 0; i < n; i++) low = Math.min(low, this.contactXYZ[i * 3 + 1] - c.y)\n let x0 = Infinity, x1 = -Infinity, z0 = Infinity, z1 = -Infinity\n for (let i = 0; i < n; i++) {\n const rx = this.contactXYZ[i * 3] - c.x\n const rz = this.contactXYZ[i * 3 + 2] - c.z\n x0 = Math.min(x0, rx); x1 = Math.max(x1, rx)\n z0 = Math.min(z0, rz); z1 = Math.max(z1, rz)\n }\n const height = -low\n const wx = x1 - x0\n const wz = z1 - z0\n const isNarrow = Math.min(wx, wz) < NARROW * height\n const isColumn = Math.max(wx, wz) < NARROW * height\n b.balancing = isNarrow || x0 > 0 || x1 < 0 || z0 > 0 || z1 < 0\n // held up at an angle by something (leant on a wall, on another piece): once it has kept its tilt for `STEADY_SECONDS` the push stops and it may sleep. The\n // tilt is timed whether or not this update's contact points read as balancing: they come and go between the engine's steps at rest, and a timer started\n // again on each flicker kept a leaning plate pushed, and awake, for good\n const was = b.steady\n if (!was || Math.abs(was.quaternion[0] * q.x + was.quaternion[1] * q.y + was.quaternion[2] * q.z + was.quaternion[3] * q.w) < Math.cos(STEADY_TURN / 2)) {\n b.steady = { quaternion: [q.x, q.y, q.z, q.w], seconds: 0 }\n } else was.seconds += dt\n const held = b.steady?.seconds ?? 0\n this.slip(b, link, isNarrow && held >= PROPPED_SECONDS)\n if (!b.balancing || held >= STEADY_SECONDS) return\n if (Math.abs(x0 + x1) > SIDE_DEAD) link.side[0] = x0 + x1 > 0 ? -1 : 1\n if (Math.abs(z0 + z1) > SIDE_DEAD) link.side[1] = z0 + z1 > 0 ? -1 : 1\n const [dirX, dirZ] = link.side\n const w = b.angularVelocity\n const v = b.velocity\n // turned about the edge of its support it goes over (about its centre of mass it would press that edge into the floor, and the contact would take it back):\n // the spin, and the speed of the centre of mass that goes with it about that edge. Only while the centre is still over the edge it turns about: once past it,\n // gravity takes it over; pushed on through the fall, a 3 kg sheet 5 m wide was driven down faster than it falls (4 cm of energy made in the room)\n if (wx <= wz) {\n const edge = dirX > 0 ? x1 : x0\n const dw = edge * dirX > 0 ? -dirX * this.topplePush(edge, height, isColumn && Math.abs(w[2]!) < PUSH_SPIN) * dt : 0\n const rx = -edge\n const ry = -low\n w[2] += dw\n v[0] += -dw * ry\n v[1] += dw * rx\n } else {\n const edge = dirZ > 0 ? z1 : z0\n const dw = edge * dirZ > 0 ? dirZ * this.topplePush(edge, height, isColumn && Math.abs(w[0]!) < PUSH_SPIN) * dt : 0\n const rz = -edge\n const ry = -low\n w[0] += dw\n v[1] += -dw * rz\n v[2] += dw * ry\n }\n }\n\n /** Propped pieces lose most of their friction until they move or sleep (the push only presses them into the prop: an energy-free way to end a wedge). */\n private slip(b: PieceBody, link: Link, isSlipping: boolean): void {\n if (link.isSlipping === isSlipping) return\n link.isSlipping = isSlipping\n const m = this.material(b)\n this.world.setMaterial(link.id, isSlipping ? { ...m, frictionStatic: m.frictionStatic * PROPPED_GRIP, frictionDynamic: m.frictionDynamic * PROPPED_GRIP } : m)\n }\n\n private centre(b: PieceBody): THREE_NS.Vector3 {\n return this.v.copy(b.centerV).applyQuaternion(b.root.quaternion).add(b.root.position)\n }\n\n /**\n * Lays the tiles of ground under and around what is awake, and lays again those whose region changed (only if their ground did change). \"Around\" is the piece's own footprint\n * (its box as it stands now, seen from above) plus `TILE_MARGIN` and how far its tips swing in this update (up to `MAX_SWING`): a 45 m wire that fell lies on 23 tiles, not under the 625 of the\n * circle around it (a 480 ms update in the room).\n */\n private layGround(each: Each, dt: number): void {\n each((b) => {\n if (!b.sleeping) this.groundOf(b, dt, this.layAt)\n })\n }\n\n /** Hands `visit` the tiles an awake piece needs in this update, in scan order: under and around it, and along its path when it is fast. */\n private groundOf(b: PieceBody, dt: number, visit: TileVisit): void {\n const c = this.centre(b)\n const reach = Math.hypot(b.halfExtents[0], b.halfExtents[1], b.halfExtents[2])\n const swing = Math.hypot(b.angularVelocity[0] as number, b.angularVelocity[1] as number, b.angularVelocity[2] as number) * reach * Math.max(dt, 1 / 60)\n // a 45 m wire the blast spun to 47 rad/s swings 53 m a frame: the circle around it was 4290 tiles (2.4 s), and it is 4 m up; past a few metres the next update lays what it reached\n const margin = TILE_MARGIN + Math.min(swing, MAX_SWING)\n // a fast one (a blast's chip) moves further than the margin in an update, and would land on ground not laid yet: the tiles are laid along its path too, a tile apart\n const travel = Math.hypot(b.velocity[0] as number, b.velocity[1] as number, b.velocity[2] as number) * dt\n const stops = travel > TILE_MARGIN ? Math.min(MAX_PATH_STOPS, Math.ceil(travel / TILE)) : 0\n const x0 = c.x, y0 = c.y, z0 = c.z\n for (let stop = 0; stop <= stops; stop++) {\n const fraction = stops === 0 ? 0 : stop / stops\n const at = stop === 0 ? c : this.u.set(x0 + (b.velocity[0] as number) * dt * fraction, y0, z0 + (b.velocity[2] as number) * dt * fraction)\n this.beneath(b, at, margin, visit)\n }\n }\n\n /** A tile `groundOf` names is laid now (without the ground worker). */\n private readonly layAt: TileVisit = (key, ix, iz) => this.layTile(key, ix, iz, this.tiles.get(key))\n\n /** A tile `groundOf` names is asked of the schedule (`askTile`); `waits` when no ground is laid there yet. */\n private readonly askAt: TileVisit = (key, ix, iz) => {\n const tile = this.tiles.get(key)\n if (!(this.schedule as GroundSchedule).pending.has(key) && (!tile || tile.dirty !== null)) this.askTile(key, ix, iz, tile)\n if (!this.tiles.has(key)) this.waits = true\n }\n\n /**\n * Under the ground worker: the tiles each awake piece needs are asked for (`askTile`); a piece with a tile that has no ground yet waits held still (`hold`) until the update the\n * tile is applied at, then goes on (CLAUDE.md §12: never falling through ground that is not there). One whose tile is being made again stands on the old ground meanwhile.\n */\n private layGroundLater(each: Each, dt: number): void {\n const waiting = this.waiting\n waiting.clear()\n each((b) => {\n // one the kit put to sleep while held stays held while its ground is missing: let go asleep, a body landing on it would wake it over nothing\n if (b.sleeping && !this.links.get(b)?.frozen) return\n this.waits = false\n this.groundOf(b, dt, this.askAt)\n if (this.waits && !b.held) waiting.add(b)\n })\n each((b) => this.hold(b, waiting.has(b)))\n waiting.clear()\n }\n\n /**\n * A tile asked of the schedule: a level one the terrain's bounds prove is laid at once (it reads nothing); else its samples are read now (all of them, or again where it was\n * marked) with the band its solid reads past its edges, and the tile is made from them off the main thread and applied `frames` updates on (`applyDueGround`).\n */\n private askTile(key: number, ix: number, iz: number, tile: Tile | undefined): void {\n const schedule = this.schedule as GroundSchedule\n const x0 = ix * TILE\n const z0 = iz * TILE\n const flat = this.flatAt(tile, x0, z0)\n if (flat !== undefined) {\n if (flat) this.install(key, ix, iz, tile, flat, () => NO_SOLID, null)\n else if (tile) this.refreshMaterial(tile, ix, iz)\n return\n }\n const patch = this.o.groundPatch ? schedule.readPatch(this.o.groundPatch, x0, z0, TILE) : null\n if (patch) {\n this.askPatch({ key, ix, iz, x0, z0 }, tile, patch)\n return\n }\n let samples: Float64Array\n let wasCoarse = false\n if (tile && tile.samples) {\n const ringMoved = tile.dirty !== null && this.ringMoved(tile.volume, tile.dirty)\n const changed = readGround(this.o.groundAt, tile.samples, x0, z0, TILE, tile.dirty ?? undefined, this.o.groundGrid)\n tile.dirty = null\n if (!changed && !ringMoved) return this.refreshMaterial(tile, ix, iz)\n samples = tile.samples\n wasCoarse = wasCoarseOf(tile)\n } else {\n samples = new Float64Array(sampleCount(Math.round(TILE / GROUND_CELL)))\n readGround(this.o.groundAt, samples, x0, z0, TILE, undefined, this.o.groundGrid)\n if (tile) tile.dirty = null\n }\n const band = schedule.band(TILE)\n readGroundBand(this.o.groundAt, band, x0, z0, TILE, this.o.groundGrid)\n schedule.ask({ key, ix, iz, x0, z0, size: TILE, fresh: tile === undefined, wasCoarse, samples, patch: null }, band, this.updates)\n }\n\n /**\n * A tile asked for with the terrain's vertices under it and its ring (`groundPatch`): left as it is when they are the ones it was made from (the samples and the band it would\n * read are then the same, to the bit), else the tile is made from them where the schedule makes it. Nothing of its 60 000 samples is read here.\n */\n private askPatch(at: { key: number; ix: number; iz: number; x0: number; z0: number }, tile: Tile | undefined, patch: HeightPatch): void {\n const schedule = this.schedule as GroundSchedule\n if (tile) tile.dirty = null\n if (tile?.patch && samePatch(tile.patch, patch)) {\n schedule.givePatch(patch.heights)\n // the same heights, maybe another surface (a fill, a paint): its bodies take it now\n this.refreshMaterial(tile, at.ix, at.iz)\n return\n }\n const wasCoarse = tile !== undefined && wasCoarseOf(tile)\n schedule.ask({ ...at, size: TILE, fresh: tile === undefined, wasCoarse, samples: null, patch }, null, this.updates)\n }\n\n /** The tiles due at this update, laid in the order they were asked for: the worker's answer or the same tile made here (`GroundSchedule.resolve`). */\n private applyDueGround(): void {\n const schedule = this.schedule\n if (!schedule) return\n schedule.takeDue(this.updates, this.due)\n for (const p of this.due) {\n const made = schedule.resolve(p)\n const tile = this.tiles.get(p.key)\n this.install(p.key, p.ix, p.iz, tile, made, () => made.solid, tile ? tile.dirty : p.dirty)\n }\n this.due.length = 0\n }\n\n /**\n * A piece held still while its ground is made (kinematic at rest: what falls on it lands on it, it does not fall), or let go when the ground is laid: dynamic again with the\n * speeds the piece kept, awake or asleep as the piece is. A piece in a hand is never held for its ground (it is kinematic anyway).\n */\n private hold(b: PieceBody, wait: boolean): void {\n const link = this.links.get(b)\n if (!link || link.frozen === wait) return\n link.frozen = wait\n if (wait) {\n this.world.setMotion(link.id, 'kinematic')\n this.world.setVelocity(link.id, [0, 0, 0], [0, 0, 0])\n return\n }\n if (b.held) return\n this.world.setMotion(link.id, 'dynamic')\n const v = b.velocity\n const w = b.angularVelocity\n this.world.setVelocity(link.id, [v[0], v[1], v[2]], [w[0], w[1], w[2]])\n for (let i = 0; i < 3; i++) {\n link.vel[i] = v[i]\n link.ang[i] = w[i]\n }\n if (b.sleeping) this.world.sleep(link.id)\n else this.world.wake(link.id)\n link.sleeping = b.sleeping\n }\n\n /** A held piece the kit or the host moved (lifted out of risen ground, put out of a fixed thing) keeps that pose as the one to compare against; its speeds wait with it. */\n private keepFrozen(b: PieceBody, link: Link, moved: boolean): void {\n if (!moved) return\n const c = this.centre(b)\n const q = b.root.quaternion\n link.pos[0] = c.x\n link.pos[1] = c.y\n link.pos[2] = c.z\n link.quat[0] = q.x\n link.quat[1] = q.y\n link.quat[2] = q.z\n link.quat[3] = q.w\n }\n\n /** The tiles under what the piece is made of: with `tilesUnderParts`, its parts' boxes where it has them (a pole with its wires is 23 m across and mostly air); else its one box. */\n private beneath(b: PieceBody, at: THREE_NS.Vector3, margin: number, visit: TileVisit): void {\n const parts = b.partBoxes\n if (!this.o.tilesUnderParts || b.round || !parts || parts.length === 0) {\n this.tilesAround(this.footprint(b, at), margin, visit)\n return\n }\n const q = b.root.quaternion\n for (const part of parts) {\n this.partCentre.set(part.center[0], part.center[1], part.center[2]).applyQuaternion(q).add(at)\n this.partQuaternion.copy(q)\n if (part.rotation) this.partQuaternion.multiply(this.turn3.set(part.rotation[0], part.rotation[1], part.rotation[2], part.rotation[3]))\n this.tilesAround(this.footprintOf(part.half, this.partQuaternion, this.partCentre), margin, visit)\n }\n }\n\n /** The tiles within `margin` of the footprint that are not laid, or whose ground changed, handed to `visit`. */\n private tilesAround(foot: Footprint, margin: number, visit: TileVisit): void {\n for (let ix = Math.floor((foot.minX - margin) / TILE); ix <= Math.floor((foot.maxX + margin) / TILE); ix++) {\n for (let iz = Math.floor((foot.minZ - margin) / TILE); iz <= Math.floor((foot.maxZ + margin) / TILE); iz++) {\n const key = (ix + TILE_KEY_ORIGIN) * TILE_KEY + (iz + TILE_KEY_ORIGIN)\n const tile = this.tiles.get(key)\n if (tile && tile.dirty === null) continue\n if (!this.footprintReaches(foot, ix * TILE, iz * TILE, margin)) continue\n visit(key, ix, iz)\n }\n }\n }\n\n /** The piece's box seen from above: its 8 corners in x and z, the box around them, and the directions its edges run (the axes that tell a tile apart from it). */\n private footprint(b: PieceBody, c: THREE_NS.Vector3): Footprint {\n return this.footprintOf(b.halfExtents, b.root.quaternion, c)\n }\n\n private footprintOf(h: Vec3, q: THREE_NS.Quaternion, c: THREE_NS.Vector3): Footprint {\n const out = this.footprintOut\n let k = 0\n out.minX = out.minZ = Infinity\n out.maxX = out.maxZ = -Infinity\n for (let corner = 0; corner < 8; corner++) {\n this.w.set(corner & 1 ? h[0] : -h[0], corner & 2 ? h[1] : -h[1], corner & 4 ? h[2] : -h[2]).applyQuaternion(q)\n const x = c.x + this.w.x\n const z = c.z + this.w.z\n out.corners[k++] = x\n out.corners[k++] = z\n out.minX = Math.min(out.minX, x)\n out.maxX = Math.max(out.maxX, x)\n out.minZ = Math.min(out.minZ, z)\n out.maxZ = Math.max(out.maxZ, z)\n }\n // the three box axes seen from above: a tile and the footprint are apart when a gap shows along the x axis, the z axis or the normal of one of these\n for (let axis = 0; axis < 3; axis++) {\n this.w.set(axis === 0 ? 1 : 0, axis === 1 ? 1 : 0, axis === 2 ? 1 : 0).applyQuaternion(q)\n const length = Math.hypot(this.w.x, this.w.z)\n out.normals[axis * 2] = length > 1e-6 ? -this.w.z / length : 0\n out.normals[axis * 2 + 1] = length > 1e-6 ? this.w.x / length : 0\n }\n return out\n }\n\n /** Whether the tile at (x0, z0) is within `margin` of the footprint (a gap wider than that along any axis rules it out; narrower, it is laid). */\n private footprintReaches(foot: Footprint, x0: number, z0: number, margin: number): boolean {\n const gap = (nx: number, nz: number): number => {\n if (nx === 0 && nz === 0) return 0\n let low = Infinity, high = -Infinity\n for (let i = 0; i < 16; i += 2) {\n const p = foot.corners[i]! * nx + foot.corners[i + 1]! * nz\n low = Math.min(low, p)\n high = Math.max(high, p)\n }\n let tileLow = Infinity, tileHigh = -Infinity\n for (let i = 0; i < 4; i++) {\n const p = (x0 + (i & 1 ? TILE : 0)) * nx + (z0 + (i & 2 ? TILE : 0)) * nz\n tileLow = Math.min(tileLow, p)\n tileHigh = Math.max(tileHigh, p)\n }\n return Math.max(tileLow - high, low - tileHigh)\n }\n if (gap(1, 0) > margin || gap(0, 1) > margin) return false\n for (let axis = 0; axis < 3; axis++) if (gap(foot.normals[axis * 2]!, foot.normals[axis * 2 + 1]!) > margin) return false\n return true\n }\n\n /**\n * A tile of ground, made or brought up to date on the same bodies. A tile the host marked is read again only where it said (`readGround`) and left alone when nothing\n * there differs; a height field that stays one has just the samples that moved written into its shape (`updateHeights`, the same ground as a new one within the\n * quantisation: the body keeps its id, so the engine still warm-starts the contacts of what lies on it, and the whole field is not made again); a slab is moved; the\n * solid under a height field and the step boxes are made again only when the heights or the boxes changed, or the ground its solid read past the tile's edges did.\n */\n private layTile(key: number, ix: number, iz: number, tile: Tile | undefined): void {\n const x0 = ix * TILE\n const z0 = iz * TILE\n const ringMoved = tile !== undefined && tile.dirty !== null && this.ringMoved(tile.volume, tile.dirty)\n const made = this.flatOrRead(tile, x0, z0)\n if (!made) {\n if (ringMoved && tile) this.relaySolid(tile, x0, z0)\n // the heights did not change, but the surface may have (a mark over the same ground): the kit's solver reads it live, the bodies follow\n if (tile) this.refreshMaterial(tile, ix, iz)\n return\n }\n // the solid is a function of the heights and the ground it read past the edges: the same of both, the same solid\n this.install(key, ix, iz, tile, made, (moved) => (made.level !== null ? NO_SOLID : tile && !tile.slab && moved === null && !ringMoved ? tile.volume : buildSolidVolume(made.heights, made.cells, x0, z0, TILE / made.cells, this.o.groundAt, made.cells / made.collisionCells)), null)\n }\n\n /** The bodies of a tile brought to `made` (`layTile`): its solid from `volumeOf` the heights that moved (null: none); `dirty` the mark the new record keeps. */\n private install(key: number, ix: number, iz: number, tile: Tile | undefined, made: GroundTile, volumeOf: (moved: HeightRegion | null) => SolidVolume, dirty: GroundRect | null): void {\n const slab = made.level !== null\n const moved = tile && !tile.slab && !slab ? changedHeights(tile.heights, made.heights, made.cells + 1) : null\n // the engine's field is the coarser collision grid (`engine-ground-collision`): what it moved there is what is written in place\n // a tile that went from one field to the other (`collisionFieldOf`) moved all of it: a new shape, not a write in place\n const fieldSize = made.collisionCells + 1\n const sameField = tile !== undefined && tile.collision.length === made.collision.length\n const movedField = tile && !tile.slab && !slab && moved ? (sameField ? changedHeights(tile.collision, made.collision, fieldSize) : { x: 0, z: 0, sizeX: fieldSize, sizeZ: fieldSize }) : null\n const kept = tile !== undefined && tile.slab === slab\n const material = this.groundMaterial(ix, iz)\n const ground = kept ? tile.ground : this.replaceGround(tile, made, ix, iz, material)\n const writes = kept ? this.updateGround(tile, made, movedField, ix, iz) : 0\n let steps = tile?.steps ?? null\n const same = tile !== undefined && sameNumbers(tile.boxes, made.boxes)\n if (!same) {\n if (steps !== null) this.world.removeBody(steps)\n steps = made.boxes.length === 0 ? null : this.world.createBody({ shape: this.stepBoxes(made.boxes), motion: 'static', position: [0, 0, 0], material, user: 0 })\n }\n const volume = volumeOf(moved)\n const laid = { ...made, solid: volume }\n const solid = this.layVolume(laid, tile, material)\n // the bodies made here have it already; the ones kept get it when the surface changed\n if (tile && tile.material !== material) {\n if (kept) this.world.setMaterial(ground, material)\n if (same && steps !== null) this.world.setMaterial(steps, material)\n if (solid !== null && solid === tile.solid) this.world.setMaterial(solid, material)\n }\n const patch = made.patch ?? null\n // the patch the tile was made from before goes back for the next read (§8: one patch per tile, no more)\n if (tile?.patch && tile.patch !== patch) this.schedule?.givePatch(tile.patch.heights)\n this.tiles.set(key, { ground, slab, steps, boxes: made.boxes, solid, volume, heights: made.heights, collision: made.collision, writes, samples: made.samples, patch, level: made.level, dirty, material })\n }\n\n /** A tile whose ground did not change: its bodies take the surface there now (`groundMaterial`) if it is another. */\n private refreshMaterial(tile: Tile, ix: number, iz: number): void {\n const material = this.groundMaterial(ix, iz)\n if (material === tile.material) return\n tile.material = material\n this.world.setMaterial(tile.ground, material)\n if (tile.steps !== null) this.world.setMaterial(tile.steps, material)\n if (tile.solid !== null) this.world.setMaterial(tile.solid, material)\n }\n\n /** The surface of the tile's bodies: the ground's own rolling resistance at its middle (`tileRollingAt`), one shared object per value; `GROUND` without the host's. */\n private groundMaterial(ix: number, iz: number): Material {\n const rolling = this.o.groundRollingAt ? tileRollingAt(this.o.groundRollingAt, ix * TILE, iz * TILE) : undefined\n if (rolling === undefined || rolling === ROLLING_RESISTANCE) return GROUND\n let material = this.groundMaterials.get(rolling)\n if (!material) {\n material = { ...GROUND, rolling }\n this.groundMaterials.set(rolling, material)\n }\n return material\n }\n\n /** Whether a sample the solid read past the tile's edges, within the marked rectangle, is not the ground there now. */\n private ringMoved(volume: SolidVolume, rect: GroundRect): boolean {\n const r = volume.ring\n for (let k = 0; k < r.length; k += 3) {\n const x = r[k]!, z = r[k + 1]!\n if (x < rect.minX || x > rect.maxX || z < rect.minZ || z > rect.maxZ) continue\n if (this.o.groundAt(x, z) !== r[k + 2]) return true\n }\n return false\n }\n\n /** The solid of a tile whose own ground did not change, made again for the ground past its edges, which did. */\n private relaySolid(tile: Tile, x0: number, z0: number): void {\n const cells = Math.round(Math.sqrt(tile.heights.length)) - 1\n const collisionCells = Math.round(Math.sqrt(tile.collision.length)) - 1\n const volume = buildSolidVolume(tile.heights, cells, x0, z0, TILE / cells, this.o.groundAt, cells / collisionCells)\n tile.solid = this.layVolume({ heights: tile.heights, cells, collision: tile.collision, collisionCells, boxes: tile.boxes, solid: volume, level: null, samples: tile.samples }, tile, tile.material)\n tile.volume = volume\n }\n\n /**\n * The tile as the ground is now, or null (the mark cleared) when it did not change. A tile the terrain's own bounds prove level costs the vertices under it, not 26 000 samples:\n * the proof is exact (every sample is a blend of the vertices the tile covers), so a crater of any size under it takes the other way.\n */\n private flatOrRead(tile: Tile | undefined, x0: number, z0: number): GroundTile | null {\n const flat = this.flatAt(tile, x0, z0)\n if (flat !== undefined) return flat\n return tile && tile.samples ? this.readTile(tile, tile.samples, x0, z0) : buildGroundTile(this.o.groundAt, x0, z0, TILE, false, this.o.groundGrid)\n }\n\n /** The level tile the terrain's bounds prove, null (the mark cleared) when it is the slab laid there already, undefined when they do not prove it level. */\n private flatAt(tile: Tile | undefined, x0: number, z0: number): GroundTile | null | undefined {\n const range = this.o.groundRange?.(x0, x0 + TILE, z0, z0 + TILE)\n if (!range || range.high - range.low > FLAT_SPAN) return undefined\n const level = this.o.groundAt(x0 + TILE / 2, z0 + TILE / 2)\n if (tile?.slab && tile.level === level) {\n tile.dirty = null\n return null\n }\n return flatTile(level, TILE)\n }\n\n /** The tile as the ground is now, its marked samples read again; null (and the mark cleared) when none of them changed. */\n private readTile(tile: Tile, held: Float64Array, x0: number, z0: number): GroundTile | null {\n const changed = readGround(this.o.groundAt, held, x0, z0, TILE, tile.dirty ?? undefined, this.o.groundGrid)\n if (!changed) {\n tile.dirty = null\n return null\n }\n return shapeGround(held, x0, z0, TILE, null, !tile.slab && tile.collision.length < tile.heights.length)\n }\n\n /**\n * The ground body of a tile that stays a slab or a height field: the slab moved, or the height field's moved samples written in place (a whole new shape when the engine\n * cannot, when most of the field moved, or after `MAX_IN_PLACE_WRITES`). Returns how many times in a row the shape has been written in place.\n */\n private updateGround(tile: Tile, made: GroundTile, moved: HeightRegion | null, ix: number, iz: number): number {\n if (made.level !== null) {\n this.world.setPose(tile.ground, [(ix + 0.5) * TILE, made.level - 0.5, (iz + 0.5) * TILE], [0, 0, 0, 1], false)\n return 0\n }\n if (!moved) return tile.writes\n const size = made.collisionCells + 1\n const small = moved.sizeX * moved.sizeZ <= IN_PLACE_SHARE * size * size\n if (small && tile.writes < MAX_IN_PLACE_WRITES && this.world.updateHeights(tile.ground, moved, made.collision)) return tile.writes + 1\n this.world.setShape(tile.ground, this.heightField(made, ix, iz))\n return 0\n }\n\n /** A tile that is new, or went from a slab to a height field or back: its ground body made anew. */\n private replaceGround(tile: Tile | undefined, made: GroundTile, ix: number, iz: number, material: Material): BodyId {\n if (tile) this.world.removeBody(tile.ground)\n if (made.level === null) return this.world.createBody({ shape: this.heightField(made, ix, iz), motion: 'static', position: [0, 0, 0], material, user: 0 })\n return this.world.createBody({ shape: { kind: 'box', half: [TILE / 2, 0.5, TILE / 2] }, motion: 'static', position: [(ix + 0.5) * TILE, made.level - 0.5, (iz + 0.5) * TILE], material, user: 0 })\n }\n\n /** The solid under a height field, on its own body, swapped in place when the ground changed; none under a slab. Boxes only: a box costs nothing to make, a hull did (T3.8ag). */\n private layVolume(t: GroundTile, tile: Tile | undefined, material: Material): BodyId | null {\n const id = tile?.solid ?? null\n if (t.level !== null) {\n if (id !== null) this.world.removeBody(id)\n return null\n }\n if (id === null) return this.world.createBody({ shape: this.solidShape(t.solid), motion: 'static', position: [0, 0, 0], material, user: 0 })\n if (tile && t.solid !== tile.volume && !sameSolid(tile.volume, t.solid)) this.world.setShape(id, this.solidShape(t.solid))\n return id\n }\n\n private solidShape(solid: SolidVolume): ShapeDesc {\n const children: Array<{ shape: ShapeDesc; position: Vec3; rotation: Quat }> = []\n const b = solid.boxes\n for (let i = 0; i < b.length; i += SOLID_STRIDE) children.push({ shape: { kind: 'box', half: [b[i + 3]!, b[i + 4]!, b[i + 5]!] }, position: [b[i]!, b[i + 1]!, b[i + 2]!], rotation: [b[i + 6]!, b[i + 7]!, b[i + 8]!, b[i + 9]!] })\n return { kind: 'compound', children }\n }\n\n private heightField(t: GroundTile, ix: number, iz: number): ShapeDesc {\n return { kind: 'heightfield', origin: [ix * TILE, 0, iz * TILE], cell: TILE / t.collisionCells, size: t.collisionCells + 1, heights: t.collision }\n }\n\n private stepBoxes(boxes: ArrayLike<number>): ShapeDesc {\n const children: Array<{ shape: ShapeDesc; position: Vec3 }> = []\n for (let i = 0; i < boxes.length; i += 6) children.push({ shape: { kind: 'box', half: [boxes[i + 3], boxes[i + 4], boxes[i + 5]] }, position: [boxes[i], boxes[i + 1], boxes[i + 2]] })\n return { kind: 'compound', children }\n }\n\n /** The host's fixed boxes, one static body per object (`EngineStatics`). */\n private layStatics(): void {\n const now = this.o.staticSolids?.()\n if (now) this.statics.lay(now)\n }\n\n private keepApart(apart: ReadonlySet<string>): void {\n for (const key of this.ignored) {\n if (apart.has(key)) continue\n this.ignored.delete(key)\n this.ignore(key, false)\n }\n for (const key of apart) {\n if (this.ignored.has(key)) continue\n this.ignored.add(key)\n this.ignore(key, true)\n }\n }\n\n /** The engine leaves the pair (`a\\0b` by object id) alone, or meets it again. */\n private ignore(key: string, ignore: boolean): void {\n const cut = key.indexOf('\\u0000')\n const a = this.byObject.get(key.slice(0, cut))\n const b = this.byObject.get(key.slice(cut + 1))\n const x = a && this.links.get(a)\n const y = b && this.links.get(b)\n if (x && y) this.world.ignorePair(x.id, y.id, ignore)\n }\n\n /** Writes the body back to the piece, then the kit's rules: the sweep against walls, hard landings, `still` for the budget. */\n private readBack(b: PieceBody, dt: number, time: number, active: ReadonlySet<PieceBody> | null): void {\n const link = this.links.get(b)\n if (!link || b.held || link.frozen) return\n // asleep on both sides since the last update: the engine has not moved it, there is nothing to read\n if (link.sleeping && b.sleeping && (active ? !active.has(b) : this.world.isSleeping(link.id))) {\n b.still = 0\n return\n }\n this.world.readPose(link.id, this.pose, 0)\n this.world.readVelocity(link.id, this.velocity, 0)\n const pos = this.readPos\n pos[0] = this.pose[0]\n pos[1] = this.pose[1]\n pos[2] = this.pose[2]\n const v = b.velocity\n const w = b.angularVelocity\n for (let i = 0; i < 3; i++) {\n v[i] = this.velocity[i]\n w[i] = this.velocity[i + 3]\n }\n b.sleeping = this.world.isSleeping(link.id)\n if (!b.sleeping) b.onGround = this.world.touching(link.id)\n // the tilt it kept while asleep says nothing of the new fall, and what it stands on is judged now: the budget put a board back to sleep in the frame its step went\n if (link.sleeping && !b.sleeping) {\n b.steady = undefined\n if (b.onGround && !b.round) this.topple(b, 0)\n }\n // the sweep judges the engine's own move; the net under the ground comes after it, so nothing the sweep does (a face that turns it back) leaves it under the ground\n let moved = link.stepped && !b.sleeping && this.o.sweep !== undefined && this.sweepOn(b, link.before, pos, time)\n const reach = Math.hypot(b.halfExtents[0], b.halfExtents[1], b.halfExtents[2])\n const floor = this.o.groundAt(pos[0], pos[2])\n if (pos[1] + reach < floor - 0.05) {\n this.fellThrough++\n pos[1] = floor + reach\n v[1] = Math.max(0, v[1])\n moved = true\n }\n if (link.stepped && !b.sleeping) {\n const impact = -link.beforeVy\n if (b.onGround && impact > HARD_LANDING && v[1] > link.beforeVy + impact * 0.5 && time - b.lastHit > 0.15) {\n b.lastHit = time\n this.o.onHardLanding(b, [pos[0], pos[1] - Math.min(...b.halfExtents), pos[2]], impact)\n }\n }\n b.root.quaternion.set(this.pose[3], this.pose[4], this.pose[5], this.pose[6])\n const off = this.v.copy(b.centerV).applyQuaternion(b.root.quaternion)\n b.root.position.set(pos[0] - off.x, pos[1] - off.y, pos[2] - off.z)\n b.root.updateMatrixWorld(true)\n if (!b.sleeping) {\n const still = b.onGround && !b.tipping && Math.hypot(v[0], v[1], v[2]) < STILL_SPEED && Math.hypot(w[0], w[1], w[2]) < STILL_SPIN\n b.still = still ? b.still + dt : 0\n } else {\n b.still = 0\n }\n // only what the kit changed goes back: writing the pose wakes the body and starts its sleep timer again\n if (moved) this.world.setPose(link.id, pos, [this.pose[3], this.pose[4], this.pose[5], this.pose[6]], true)\n if (moved) this.world.setVelocity(link.id, [v[0], v[1], v[2]], [w[0], w[1], w[2]])\n // what is written back is what the next update compares against: a change from outside differs from it\n link.pos[0] = pos[0]\n link.pos[1] = pos[1]\n link.pos[2] = pos[2]\n const q = b.root.quaternion\n link.quat[0] = q.x\n link.quat[1] = q.y\n link.quat[2] = q.z\n link.quat[3] = q.w\n for (let i = 0; i < 3; i++) {\n link.vel[i] = v[i]\n link.ang[i] = w[i]\n }\n if (b.sleeping && !link.sleeping) {\n const c = this.centre(b)\n link.groundAtSleep = this.o.groundAt(c.x, c.z)\n }\n link.sleeping = b.sleeping\n }\n\n /**\n * A piece that ran into a wall on its way (`sweep`). Into what the engine has as a body (a fixed thing's drawn boxes, another piece) the engine already met it, so\n * the sweep only tells the blow (`onSlam`): setting it back there as well put a door sliding down a table edge back up every update, for good, and threw pieces\n * off a wall the engine was already holding them against. Into what the engine does not have (a wall left out of `staticSolids`), the kit's rule as before:\n * back to where it met it, the speed into it reflected.\n */\n private sweepOn(b: PieceBody, start: Vec3, pos: Vec3, time: number): boolean {\n const travel = Math.hypot(pos[0] - start[0], pos[1] - start[1], pos[2] - start[2])\n if (travel < 1e-3) return false\n const hit = this.o.sweep?.(b, start, pos)\n if (!hit || hit.normal[1] > SLAM_FLOOR_NORMAL) return false\n const v = b.velocity\n const n = hit.normal\n const into = -(v[0] * n[0] + v[1] * n[1] + v[2] * n[2])\n if (into <= 0) return false\n const engineHas = this.byObject.has(hit.object) || this.statics.has(hit.object)\n if (!engineHas) {\n const k = Math.min(1, hit.distance / travel)\n // below the engine's restitution threshold the speed into it is only taken away: reflected, a door pressed into a parked car (which the engine does not\n // have) by its own weight was sent back off it every update and never slept\n const bounce = into >= BOUNCE_SPEED ? Math.sqrt((b.restitution ?? SLAM_BOUNCE) * (hit.restitution ?? SLAM_BOUNCE)) : 0\n // up to where it met it, then the rest of the way along it: only the part into it is taken out (set back the whole way, a door sliding down a parked car\n // was put back up on every update)\n const rest = [0, 1, 2].map((i) => (pos[i] - start[i]) * (1 - k))\n const restInto = Math.min(0, rest[0] * n[0] + rest[1] * n[1] + rest[2] * n[2])\n for (let i = 0; i < 3; i++) {\n pos[i] = start[i] + (pos[i] - start[i]) * k + rest[i] - restInto * n[i]\n v[i] += (1 + bounce) * into * n[i]\n }\n for (let i = 0; i < 3; i++) b.angularVelocity[i] *= 0.5\n }\n if (into >= SLAM_MIN_SPEED && time - b.lastHit > 0.15) {\n b.lastHit = time\n this.o.onSlam?.(b, hit, into)\n }\n return !engineHas\n }\n\n /** Two pieces that hit each other hard enough sound (`onKnock`), from the engine's contact rows, once per pair per `KNOCK_EVERY`. */\n private knock(time: number): void {\n const on = this.o.onKnock\n if (!on) return\n const c = this.world.contacts\n for (let i = 0; i < c.count; i++) {\n if (c.approach[i] < SLAM_MIN_SPEED) continue\n const a = this.byUser.get(c.userA[i])\n const b = this.byUser.get(c.userB[i])\n if (!a || !b) continue\n const key = a.objectId < b.objectId ? `${a.objectId}\\u0000${b.objectId}` : `${b.objectId}\\u0000${a.objectId}`\n if (time - (this.knocks.get(key) ?? -Infinity) < KNOCK_EVERY) continue\n this.knocks.set(key, time)\n on(a, b, [c.point[i * 3], c.point[i * 3 + 1], c.point[i * 3 + 2]], c.approach[i])\n }\n }\n}\n","import type { HeightRegion } from '@adatechnology/game-physics'\n\n/** The smallest rectangle of samples of a height field (`size` a side, x fastest) that holds every one that differs between two versions of it; null when none differs. */\nexport const changedHeights = (before: Float32Array, after: Float32Array, size: number): HeightRegion | null => {\n let minX = size\n let maxX = -1\n let minZ = size\n let maxZ = -1\n for (let z = 0; z < size; z++) {\n for (let x = 0; x < size; x++) {\n if (before[z * size + x] === after[z * size + x]) continue\n minX = Math.min(minX, x)\n maxX = Math.max(maxX, x)\n minZ = Math.min(minZ, z)\n maxZ = Math.max(maxZ, z)\n }\n }\n return maxX < 0 ? null : { x: minX, z: minZ, sizeX: maxX - minX + 1, sizeZ: maxZ - minZ + 1 }\n}\n","import type { HeightPatch } from '@adatechnology/game-terrain'\n\nimport type { GroundRect, GroundTile } from './engine-ground'\nimport { bandLength, computeGroundTile, readGroundPatch, tileOfResult } from './engine-ground-job'\nimport type { GroundPatchRead, GroundTileResult } from './engine-ground-job'\nimport type { GroundWorkerPort } from './engine-ground-port'\n\n/** The most free patches kept (a few blasts' worth of tiles made again): past it a patch let go is left to the collector. */\nconst MAX_FREE_PATCHES = 64\n\n/** The samples and band of a patch job (it carries neither): never transferred (`jobTransferOf` skips empty buffers). */\nconst EMPTY = new Float64Array(0)\n\n/** A tile asked for and not applied yet (`GroundSchedule`). */\nexport interface PendingGround {\n readonly key: number\n readonly ix: number\n readonly iz: number\n readonly x0: number\n readonly z0: number\n readonly size: number\n /** The update it is applied at, whatever the worker does. */\n readonly due: number\n /** No tile was laid there before: what needs it waits held. */\n readonly fresh: boolean\n readonly wasCoarse: boolean\n /** The samples read at the ask, the main thread's own (the tile keeps them); the band too, from the pool, until applied. Both null in a patch job. */\n readonly samples: Float64Array | null\n readonly band: Float64Array | null\n /** A patch job's terrain vertices (`readGroundPatch`), the main thread's own (the tile keeps them, to tell a change); null in a samples job. */\n readonly patch: HeightPatch | null\n readonly id: number\n /** The worker's answer, if it came. */\n result: GroundTileResult | null\n /** Where the ground changed since the ask (a fresh tile has no record to hold the mark): read again after it is applied. */\n dirty: GroundRect | null\n}\n\nexport type GroundAsk = Omit<PendingGround, 'id' | 'result' | 'dirty' | 'band' | 'due' | 'patch'> & { readonly patch?: HeightPatch | null }\n\n/**\n * The fixed schedule of the ground tiles made off the main thread (owner decision 2026-11-17): a tile asked for at update N is applied at N + `frames`, never earlier and never\n * later. Its job is read at N (`readGround`, `readGroundBand`) and kept; at N + `frames` the tile is the worker's answer if it came, else `computeGroundTile` of the same job on\n * the main thread, the same bits (the answer is a pure function of the job). So the physics never depends on when, or whether, the worker answered.\n * The buffers sent are copies from a pool, and come back with the answer; the pool keeps them for the next job (no arrays made per job once warm).\n */\nexport class GroundSchedule {\n /** By tile key, in the order asked: the order they are applied in. */\n readonly pending = new Map<number, PendingGround>()\n private readonly byId = new Map<number, PendingGround>()\n private readonly pool = new Map<number, Float64Array[]>()\n private nextId = 1\n /** Pool buffers out (with a job, or with the worker): back to 0 when every job is applied and every answer came. */\n outstanding = 0\n /** Patches read and not used (the ground had not changed, or the tile that held one was made again), for the next read: not counted in `outstanding`. */\n private readonly freePatches: Float64Array[] = []\n /** The longest patch read yet: a free patch shorter than it is let go. */\n private patchLength = 0\n /** Tiles asked for; applied from the worker's answer (it came in time); made here at their update (it had not); answers that came after (dropped). */\n readonly stats = { asked: 0, inTime: 0, fellBack: 0, late: 0 }\n\n constructor(\n private readonly port: GroundWorkerPort,\n readonly frames: number,\n ) {\n port.onTile(this.answer)\n }\n\n /** A band from the pool, for `readGroundBand` (`ask` keeps it). */\n band(size: number): Float64Array {\n return this.take(bandLength(size))\n }\n\n /**\n * A first job the worker answers before any tile is asked for (its id 0 is nobody's, so the answer only gives its buffers back): the worker's script is parsed and its code\n * warm by the first blast, not started by it. Nothing is posted when nothing would answer.\n */\n warm(samples: Float64Array, band: Float64Array, x0: number, z0: number, size: number): void {\n if (this.port.transport === 'none') return\n const sentSamples = this.take(samples.length)\n sentSamples.set(samples)\n const sentBand = this.take(band.length)\n sentBand.set(band)\n this.port.postTile({ id: 0, x0, z0, size, wasCoarse: false, samples: sentSamples, band: sentBand })\n }\n\n /** The warm job of a patch tile (`warm`): the kernel that makes samples from a patch is hot too. */\n warmPatch(patch: HeightPatch, x0: number, z0: number, size: number): void {\n if (this.port.transport === 'none') return\n this.port.postTile({ id: 0, x0, z0, size, wasCoarse: false, samples: EMPTY, band: EMPTY, patch: this.sentPatch(patch) })\n }\n\n /**\n * The terrain's vertices under the tile at (x0, z0) and its ring, read into a patch of the main thread's own (from the free ones); null where the host has none (`readGroundPatch`).\n * Handed to `ask` or, unused, back with `givePatch`.\n */\n readPatch(read: GroundPatchRead, x0: number, z0: number, size: number): HeightPatch | null {\n const into = this.freePatches.pop() ?? (this.patchLength > 0 ? new Float64Array(this.patchLength) : undefined)\n const patch = readGroundPatch(read, x0, z0, size, into)\n if (patch && patch.heights !== into) this.patchLength = Math.max(this.patchLength, patch.heights.length)\n if (into && patch?.heights !== into) this.givePatch(into)\n return patch\n }\n\n /** A patch's heights back for the next read (a tile that let it go, a read not used). */\n givePatch(heights: Float64Array): void {\n if (heights.length >= this.patchLength && this.freePatches.length < MAX_FREE_PATCHES) this.freePatches.push(heights)\n }\n\n /** A job asked for at update `now`: of samples and a band from the pool (`band`), or of a patch (`job.patch`, band null). */\n ask(job: GroundAsk, band: Float64Array | null, now: number): void {\n this.stats.asked++\n const pending: PendingGround = { ...job, patch: job.patch ?? null, band, due: now + this.frames, id: this.nextId++, result: null, dirty: null }\n this.pending.set(job.key, pending)\n this.byId.set(pending.id, pending)\n if (this.port.transport === 'none') return\n const base = { id: pending.id, x0: job.x0, z0: job.z0, size: job.size, wasCoarse: job.wasCoarse }\n if (job.patch) {\n this.port.postTile({ ...base, samples: EMPTY, band: EMPTY, patch: this.sentPatch(job.patch) })\n return\n }\n const samples = this.take((job.samples as Float64Array).length)\n samples.set(job.samples as Float64Array)\n const sent = this.take((band as Float64Array).length)\n sent.set(band as Float64Array)\n this.port.postTile({ ...base, samples, band: sent })\n }\n\n /** A copy of the patch for the worker, its heights from the pool (they come back with the answer). */\n private sentPatch(patch: HeightPatch): HeightPatch {\n const count = patch.width * patch.depth\n const heights = this.take(count)\n heights.set(patch.heights.subarray(0, count))\n return { ...patch, heights }\n }\n\n /** The tiles due at update `now`, in the order asked, taken off the schedule into `out`. */\n takeDue(now: number, out: PendingGround[]): void {\n out.length = 0\n for (const p of this.pending.values()) if (p.due <= now) out.push(p)\n for (const p of out) {\n this.pending.delete(p.key)\n this.byId.delete(p.id)\n }\n }\n\n /** The tile of a due job: the worker's answer, or made here from the job; its band goes back to the pool. */\n resolve(p: PendingGround): GroundTile {\n if (p.result) this.stats.inTime++\n else this.stats.fellBack++\n const result = p.result ?? this.computeHere(p)\n if (p.band) this.give(p.band)\n p.result = null\n return tileOfResult(result, p.samples, p.patch ?? undefined)\n }\n\n /** The tile of a job the worker had not answered by its update, made on this thread from the same job. */\n computeHere(p: PendingGround): GroundTileResult {\n const base = { id: p.id, x0: p.x0, z0: p.z0, size: p.size, wasCoarse: p.wasCoarse }\n if (p.patch) return computeGroundTile({ ...base, samples: EMPTY, band: EMPTY, patch: p.patch })\n return computeGroundTile({ ...base, samples: p.samples as Float64Array, band: p.band as Float64Array })\n }\n\n /** Every pending job dropped (the ground is cleared); answers still on their way only give their buffers back. */\n clear(): void {\n for (const p of this.pending.values()) {\n if (p.band) this.give(p.band)\n if (p.patch) this.givePatch(p.patch.heights)\n }\n this.pending.clear()\n this.byId.clear()\n }\n\n dispose(): void {\n this.clear()\n this.port.dispose()\n this.pool.clear()\n this.freePatches.length = 0\n }\n\n /** How many buffers the pool holds now. */\n get pooled(): number {\n let n = 0\n for (const list of this.pool.values()) n += list.length\n return n\n }\n\n private readonly answer = (result: GroundTileResult): void => {\n if (result.samples.length > 0) this.give(result.samples)\n if (result.band.length > 0) this.give(result.band)\n if (result.patch) this.give(result.patch)\n const p = this.byId.get(result.id)\n if (p) p.result = result\n else if (result.id !== 0) this.stats.late++\n }\n\n private take(length: number): Float64Array {\n this.outstanding++\n return this.pool.get(length)?.pop() ?? new Float64Array(length)\n }\n\n private give(buffer: Float64Array): void {\n this.outstanding--\n const list = this.pool.get(buffer.length)\n if (list) list.push(buffer)\n else this.pool.set(buffer.length, [buffer])\n }\n}\n","import { createPhysicsLoop, isPhysicsLoop } from '@adatechnology/game-physics'\nimport type { PhysicsLoop, PhysicsWorld, SeamWorld } from '@adatechnology/game-physics'\n\n/**\n * The physics a seam is handed, always by its host and always spelled out: a `PhysicsLoop` (the host steps it; the seam registers phases), a world (the seam makes its own loop\n * and steps it in its `update`), or `'own'` (the kit's own solver, until it goes).\n */\nexport type PiecePhysics = PhysicsLoop | SeamWorld | 'own'\n\nexport class PhysicsOptionError extends Error {\n readonly code = 'PHYSICS_OPTION'\n constructor(message: string) {\n super(`game-destruction-three: ${message}`)\n this.name = 'PhysicsOptionError'\n }\n}\n\nexport interface ResolvedPhysics {\n readonly loop: PhysicsLoop\n /** True when the seam made the loop from a world: it steps it itself, inside its `update`. */\n readonly stepsItself: boolean\n}\n\n/** `null` for `'own'`; the option left out (a plain-JS host) or not a world nor a loop throws. */\nexport const resolvePhysics = (option: PiecePhysics | undefined): ResolvedPhysics | null => {\n if (option === 'own') return null\n if (option === undefined || typeof option !== 'object') {\n throw new PhysicsOptionError(\"the `physics` option is required: pass a PhysicsLoop, a world from the host, or 'own' for the kit's own solver\")\n }\n if (isPhysicsLoop(option)) return { loop: option, stepsItself: false }\n // the type says a seam world (no `step`); one given here to be stepped is the host's full world\n if (typeof (option as Partial<PhysicsWorld>).stepFixed !== 'function') {\n throw new PhysicsOptionError('a world given as `physics` must be able to step (a PhysicsWorld); to step it elsewhere, pass its PhysicsLoop')\n }\n return { loop: createPhysicsLoop(option as PhysicsWorld), stepsItself: true }\n}\n","/** A point on the ground plane: x and z in metres. */\nexport type PlanPoint = readonly [number, number]\n\nconst cross = (o: PlanPoint, a: PlanPoint, b: PlanPoint): number => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])\n\n/** The convex hull of the points, counter-clockwise, without repeats (monotone chain). */\nexport function planHull(points: readonly PlanPoint[]): PlanPoint[] {\n const sorted = [...points].sort((a, b) => a[0] - b[0] || a[1] - b[1])\n if (sorted.length < 3) return sorted\n const lower: PlanPoint[] = []\n for (const p of sorted) {\n while (lower.length >= 2 && cross(lower[lower.length - 2]!, lower[lower.length - 1]!, p) <= 0) lower.pop()\n lower.push(p)\n }\n const upper: PlanPoint[] = []\n for (let i = sorted.length - 1; i >= 0; i--) {\n const p = sorted[i]!\n while (upper.length >= 2 && cross(upper[upper.length - 2]!, upper[upper.length - 1]!, p) <= 0) upper.pop()\n upper.push(p)\n }\n return [...lower.slice(0, -1), ...upper.slice(0, -1)]\n}\n\n/** Distance from `p` to the segment `a`-`b`. */\nfunction toSegment(p: PlanPoint, a: PlanPoint, b: PlanPoint): number {\n const dx = b[0] - a[0]\n const dz = b[1] - a[1]\n const length = dx * dx + dz * dz\n const t = length > 0 ? Math.max(0, Math.min(1, ((p[0] - a[0]) * dx + (p[1] - a[1]) * dz) / length)) : 0\n return Math.hypot(p[0] - a[0] - t * dx, p[1] - a[1] - t * dz)\n}\n\n/**\n * Whether a body whose centre of mass projects to `centre` is balanced on the points it rests on: the centre is inside their convex hull, or within `tolerance` of it (a hull\n * of one or two points is a point or a line, and a centre that is not on it topples: a top on one leg always falls, §12).\n */\nexport function isOverSupport(points: readonly PlanPoint[], centre: PlanPoint, tolerance: number): boolean {\n const hull = planHull(points)\n if (hull.length === 0) return false\n if (hull.length === 1) return Math.hypot(centre[0] - hull[0]![0], centre[1] - hull[0]![1]) <= tolerance\n let inside = hull.length >= 3\n let nearest = Infinity\n for (let i = 0; i < hull.length; i++) {\n const a = hull[i]!\n const b = hull[(i + 1) % hull.length]!\n if (hull.length >= 3 && cross(a, b, centre) < 0) inside = false\n nearest = Math.min(nearest, toSegment(centre, a, b))\n }\n return inside || nearest <= tolerance\n}\n","import type * as THREE_NS from 'three'\nimport type { Vec3 } from '@adatechnology/game-destruction'\nimport { AwakeList } from './awake-list'\nimport { PoseTrail } from './pose-trail'\nimport type { PartBox, PieceBody, PieceFriction, PieceHinge, PieceSweepHit } from './internal'\nimport { squareBoxOf } from './internal'\nimport { GROUND_ROLLING_DAMPING, PIECE_ROLLING_DAMPING } from './friction'\nimport { clamp } from './math'\nimport { boxesApartAlongGround, levelBoxesApart, shapeContact } from './piece-contacts'\nimport type { ContactShape, ShapeContact } from './piece-contacts'\nimport type { PhysicsLoop } from '@adatechnology/game-physics'\nimport { EnginePieces, groundTileKey, tileRollingAt } from './engine-pieces'\nimport type { StaticSolid } from './engine-pieces'\nimport type { GroundGrid } from './engine-ground'\nimport type { GroundPatchRead } from './engine-ground-job'\nimport type { GroundWorkerPort } from './engine-ground-port'\nimport { resolvePhysics } from './physics-option'\nimport { isOverSupport } from './support-hull'\nimport type { PlanPoint } from './support-hull'\nimport type { PiecePhysics } from './physics-option'\nexport type { PieceSweepHit } from './internal'\n\nexport interface PieceSystemOptions {\n /** Keep the pose of the step before the last, to draw between it and the step's (`presentPose`). Default off: the roots are always the step's. */\n interpolate?: boolean\n groundAt: (x: number, z: number) => number\n /** The terrain alone (no top of furniture or of anything drawn): the ground of an engine, which has every drawn top as a body. Default `groundAt`. */\n terrainAt?: (x: number, z: number) => number\n /**\n * The rolling resistance of the terrain's surface at (x, z), undefined for the default (`RendererOptions.terrainRollingAt`). The kit's solver takes a contact to be on the\n * terrain where `groundAt` answers exactly `terrainAt` (or there is no `terrainAt`): `groundAt` must return the terrain's own value, to the bit, where nothing is on it.\n */\n terrainRollingAt?: (x: number, z: number) => number | undefined\n /** The rolling damping (1/s) of the terrain's surface at (x, z), undefined for the default (`RendererOptions.terrainRollingDampingAt`); read where `terrainRollingAt` is. */\n terrainRollingDampingAt?: (x: number, z: number) => number | undefined\n /** The most tiles of ground laid at a blast, nearest first (default 0: the tiles are laid as the pieces reach them; a count lays that many at a blast, which moves their cost into the explosion's frame). Engine physics only. */\n blastGroundTiles?: number\n /**\n * The lowest and highest `terrainAt` (else `groundAt`) can answer over a rectangle (min x, max x, min z, max z), exact bounds, or null when none is known. With it the engine lays a\n * tile it proves level without reading its 26 000 samples (`Terrain.heightRange` is one). A bound that is not exact makes a tile level that is not: leave it out if unsure.\n */\n terrainRangeAt?: (minX: number, maxX: number, minZ: number, maxZ: number) => { readonly low: number; readonly high: number } | null\n /** `terrainAt` over a lattice in one pass, to the bit (`GroundGrid`; `Terrain.heightGrid` is one). Used only with `terrainAt`; engine physics only. */\n terrainGridAt?: GroundGrid\n /** `terrainAt`'s vertices under a rectangle, to the bit (`GroundPatchRead`; `Terrain.heightPatch` is one): tiles asked of `groundWorker` carry them, not their samples. Used only with `terrainGridAt`. */\n terrainPatchAt?: GroundPatchRead\n /**\n * The highest top of what does not move (furniture, scenery) under `(x, z)` that a corner at height `y` can land on (at most `step` above it),\n * `-Infinity` when none. The ground and the other pieces are added by the system.\n */\n staticTopAt?: (x: number, z: number, y: number, step: number) => number\n gravity: number\n /** A piece hit the ground faster than 3 m/s (throttled per piece). */\n onHardLanding: (piece: PieceBody, point: Vec3, speed: number) => void\n /** Notified when a piece is about to be removed. */\n scene: THREE_NS.Scene\n /**\n * What a piece moving from `from` to `to` (its centre, world) runs into on the way: a wall, a car, a cupboard (`distance` along the way, the `normal` of what it met).\n * Without it a piece only meets the ground, the tops of fixed things and the other pieces.\n */\n sweep?: (piece: PieceBody, from: Vec3, to: Vec3) => PieceSweepHit | null\n /** A piece ran into something (`sweep`) faster than `SLAM_MIN_SPEED` m/s into it (throttled per piece): for the blow on both and the sound. */\n onSlam?: (piece: PieceBody, hit: PieceSweepHit, speed: number) => void\n /** Two pieces knocked into each other faster than `SLAM_MIN_SPEED` m/s (throttled per pair): for the sound. */\n onKnock?: (a: PieceBody, b: PieceBody, point: Vec3, speed: number) => void\n /**\n * Most pieces simulated at once (not asleep, not held). Over it, the oldest pieces that have come to rest (on the ground, slower than the speeds a piece sleeps under, and\n * one held up at an angle only once it kept its tilt for `STEADY_SECONDS`) sleep where they lie; nothing is moved. With a limit, one held up at an angle that kept its tilt\n * sleeps under it too. Default: no limit.\n */\n maxAwake?: number\n /** Engine only: lay the ground under each part box of a piece of several parts, not under the box around all of them (default off; `RendererOptions.tilesUnderParts`). */\n tilesUnderParts?: boolean\n /** Engine only: where the ground tiles are made, on a fixed schedule (`RendererOptions.groundWorker`); default none. */\n groundWorker?: GroundWorkerPort\n groundWorkerFrames?: number\n /**\n * The far and old rule and the cap of pieces alive (`BlastDebrisOptions`): a piece at rest, older than `far.age` seconds and farther than `far.distance` from `focus`, sleeps or is\n * handed to `onFade`; over `maxLive` pieces the far and old ones at rest go first, then the oldest, by `onFade`. Default: none.\n */\n keep?: { readonly maxLive: number; readonly far: { readonly distance: number; readonly age: number; readonly action: 'sleep' | 'fade' }; readonly focus?: () => Vec3; readonly onFade: (b: PieceBody) => void }\n /**\n * What steps the pieces, handed by the host and never defaulted (left out, it throws): a `PhysicsLoop` (`game-physics`; the host calls `loop.step(dt)` and then `update`, and the\n * system registers its phases on it), a world (the system makes its own loop and steps it inside `update`), or `'own'` for the kit's own solver. The kit's rules stay on top\n * (`EnginePieces`). There is no switching mid-game.\n */\n physics: PiecePhysics\n /** With `physics`: the fixed boxes of what does not move, as drawn (turned), per object. */\n staticSolids?: () => ReadonlyMap<string, readonly StaticSolid[]>\n}\n\n/** Slower than this (m/s) into a wall a piece only stops against it: no blow, no sound. */\nexport const SLAM_MIN_SPEED = 2\n/** Share of the speed into a wall a piece keeps, bouncing back, when neither surface says otherwise (`PieceBody.restitution`, `PieceSweepHit.restitution`). */\nconst SLAM_BOUNCE = 0.2\n/** Metres the centre of mass may stand off the hull of the points a piece rests on and still be balanced there (the drawing's tolerance). */\nconst BALANCE_TOLERANCE = 0.01\n/** Normals steeper than this (y) are a floor or a top: the support of the pieces answers those, not the sweep. */\nconst SLAM_FLOOR_NORMAL = 0.7\n\nconst SUB_DT = 1 / 120\n/** Coulomb friction of a piece when no material says otherwise: what holds it still (static) and what drags it while it slides (dynamic). */\nconst MU_STATIC = 0.7\nconst MU_DYNAMIC = 0.6\n/** Sliding faster than this (m/s) along the surface, a contact drags with the dynamic friction; slower, it holds with the static one. */\nconst SLIP_SPEED = 0.02\n/** Rolling resistance coefficient of the ground and of a surface that does not say (`PieceFriction.rolling`): a can or a bottle on a hard floor (0.01-0.02). */\nconst ROLLING_RESISTANCE = 0.015\n/** A round piece whose axis leans more than 45 degrees from upright lies on its side (the share of the world's down across its axis). */\nconst ROUND_LYING = Math.SQRT1_2\nconst SLEEP_AFTER = 0.5\n/** A piece on the ground slower than this (m/s) and turning slower than this (rad/s) is still: it sleeps after `SLEEP_AFTER`, or at once over `maxAwake`. */\nconst STILL_SPEED = 0.12\nconst STILL_SPIN = 0.45\n/**\n * A piece on the ground that neither moves farther than `CALM_DRIFT` (m) nor turns more than `CALM_TURN` (rad) in `CALM_SLEEP_AFTER` seconds sleeps, however\n * its speed flickers: a book propped on another, or trembling where its corners rest on two pieces, stays in place; a fall or a slide leaves the window sooner.\n */\nconst CALM_DRIFT = 0.01\nconst CALM_TURN = 0.05\nconst CALM_SLEEP_AFTER = 1.5\n/**\n * A piece held up at an angle (on its edge, leant on something) that turns less than `STEADY_TURN` (rad) in `STEADY_SECONDS` keeps its tilt: over `maxAwake` it may sleep. One\n * going over turns past it sooner: the topple alone (`TOPPLE`) turns even a low piece 0.17 rad in that time.\n */\nconst STEADY_TURN = 0.1\nconst STEADY_SECONDS = 1.5\nconst HARD_LANDING = 3\n/** Contact tolerance in metres: corners this close to the ground count as touching, which keeps the contact set (and a resting box) stable. */\nconst SLOP = 0.002\n/** A resting support narrower than this fraction of the centre-of-mass height is a balancing act, not a rest: the piece topples. */\nconst NARROW = 0.3\n/** Angular acceleration (rad/s^2 per metre of height) that pushes a balancing piece off its edge, toward the side its centre of mass leans to. */\nconst TOPPLE = 3\n/** Angular acceleration (rad/s^2) of a piece that falls over (`tip`), beyond what the box of its bounds would allow, and the height of the centre of mass (m) at which it lies. */\nconst TIP_ACCELERATION = 30\nconst TIP_LYING = 0.25\nconst TIP_SECONDS = 3\n/** How far (m) above a corner a top may be and still catch it (on top of what the corner falls in one sub-step): higher is beside it, not under it. */\nconst STEP = 0.03\n/** Slots of the warm start: the 8 corners and the points along the 12 edges. */\nconst WARM_SLOTS = 8 + 12 * 7\n/** Passes of the contact solver over the points that touch the ground, each substep. */\nconst SOLVER_PASSES = 10\n/** Restitution of a piece against the side of a step of the ground. */\nconst SIDE_BOUNCE = 0.1\n/**\n * Points along each edge of the box, between its corners (fractions of the half edge), that also touch the ground when the support under the corners is not level\n * (the piece is over a step): the edge of a table under a box's bottom is a support between its corners. On level ground the corners are enough.\n */\nconst EDGE_POINTS = [-0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75]\n/** Sleeping pieces whose support is looked at again each update, in turn: what held one up may have broken, fallen over or been carried off. */\nconst SUPPORT_CHECKS = 16\n/** A sleeping piece none of whose lowest points has a support within this many metres under it wakes and falls. */\nconst SUPPORT_GAP = 0.02\n/** A piece moving faster than this (m/s) or turning faster than this (rad/s) wakes what lies asleep on it. */\n/** How often (s) the far and old rule looks at the pieces. */\nconst KEEP_EVERY = 0.5\nconst WAKE_ABOVE_SPEED = 0.05\nconst WAKE_ABOVE_SPIN = 0.1\n/** Side (m) of the cells of the grid the surfaces are found by (`surfaceGrid`). */\nconst SURFACE_CELL = 0.5\n/** Most cells across one surface goes into; a wider one is looked at for every point (`wideSurfaces`). */\nconst SURFACE_CELLS_ACROSS = 24\nconst cellKey = (ix: number, iz: number): number => (ix + 32768) * 65536 + (iz + 32768)\n/** Most steps an update is split into while round pieces roll fast (`collisionSteps`). */\nconst MAX_COLLISION_STEPS = 8\n/** Radius (m) a round piece is taken to have at least when the update is split for it (`collisionSteps`): a degenerate one of nothing does not split it without end. */\nconst MIN_ROUND_RADIUS = 0.005\n/** Two pieces closing slower than this (m/s) only stop against each other; faster, they bounce by their restitution. */\nconst BOUNCE_MIN_SPEED = 0.1\n/**\n * A piece hung on a hinge (`hinge`: a shelf that lost the side at one end swings on the screw at the other) lets go once it has turned this far (rad) or after\n * `HINGE_SECONDS`: the screw tears out of the board.\n */\nconst HINGE_RELEASE = (40 * Math.PI) / 180\nconst HINGE_SECONDS = 1.5\n/** Two boxes closing faster than this (m/s) hit each other (`boxImpact`): a fall of 11 cm. Slower, they only rest on or lean against each other. */\nconst BOX_IMPACT_SPEED = 1.5\n/** A contact normal at least this level (its share along the ground) puts two pieces apart along the ground only. */\nconst KNOCK_FLAT = 0.5\n/** Fastest (m/s) a piece is put apart from the boxes it overlaps (`separatePair`, all its pairs of a step together): a deep overlap opens over a few frames instead of in a jump. */\nconst SEPARATE_SPEED = 1.5\n/**\n * Deepest (m) one box may be in the top of another and still be lifted out of it: as far as a resting corner sits in its support (`STEP`), more what the closing speed sinks it\n * in a step. Deeper, the two were made inside each other (chunks of one wall), not landed one on the other: lifting the upper out would give it m g d nothing supplied (a 3 m\n * chunk climbing 5 m through the pile), so they slide apart along the ground instead.\n */\nconst LIFT_DEPTH = STEP\n/**\n * Share of an overlap one step takes back (`separatePair`). Wedged between two it cannot push (asleep on either side), the full overlap each way swings a piece back and forth\n * for ever; half settles it where the pushes balance, and a single overlap still closes to a millimetre within ten steps.\n */\nconst SEPARATE_SHARE = 0.5\n/**\n * What is left of a piece's push each time it turns back against the last step's (`applyPushes`), and what it grows back by each step it goes on the same way (up to the\n * whole push). Held between pieces that are asleep (a book in a heap of boards, a fallen case on its books), each pushes it out into the other: it went back and forth by\n * up to `SEPARATE_SPEED` a step, for good, and never slept. A cycle that turns back at least once in four steps now shrinks (1.2^3 x 0.5 < 1), so it settles where the\n * pushes balance, as a book wedged in a heap stays where it is held; one put apart the same way step after step keeps its whole push.\n */\nconst TURN_BACK_SHARE = 0.5\nconst SAME_WAY_GROWTH = 1.2\n/** The least share a push keeps (its most, 2.5 cm a step at 60 Hz, then moves under `SLOP`: the wedged piece sleeps), so a neighbour that clears is left within a few steps. */\nconst MIN_PUSH_SHARE = 0.05\n/** How long (s) a piece's last push is remembered: past one frame, so the sub-steps of a split update (`collisionSteps`) that do not reach it keep its share. */\nconst PUSH_MEMORY_SECONDS = 0.1\n\n/** A piece's push in the last step and the share of its push it is given (`applyPushes`). */\ninterface ImpactParams {\n readonly a: PieceBody\n readonly b: PieceBody\n readonly ca: Vec3\n readonly cb: Vec3\n readonly hit: ShapeContact\n readonly apart: boolean\n readonly above: number\n}\n\ninterface PushStep {\n readonly push: Vec3\n share: number\n /** The clock (`time`) of that push. */\n at: number\n}\n\n/** Box of a piece in the world: centre, rotation columns (`Matrix4.elements`) and half extents. */\n/** Which pieces a step moves and which pairs it meets (`PieceSystem.update` splits only what closes in on a round piece). */\ninterface StepFilter {\n readonly moves: (b: PieceBody) => boolean\n readonly meets: (a: PieceBody, b: PieceBody) => boolean\n}\n\ninterface Solid {\n body: PieceBody\n c: Vec3\n e: number[]\n half: Vec3\n /** Radius of the box around its centre: a point farther than it on the ground plane misses it. */\n r: number\n}\n\n/** How far a box reaches from its centre along the world axis `k` (a function of the module: a closure made per call was made per pair per update). */\nconst extent = (s: Solid, k: number): number => Math.abs(s.e[k]) * s.half[0] + Math.abs(s.e[k + 4]) * s.half[1] + Math.abs(s.e[k + 8]) * s.half[2]\n\n/** A piece's boxes as `measure` keeps them: its whole box, its parts (square to it, from `from`), the list of its surfaces, and when it was last measured. */\ninterface MeasuredBody {\n readonly whole: Solid\n parts: Solid[]\n from: readonly PartBox[] | undefined\n squares: Array<{ readonly center: Vec3; readonly half: Vec3 }>\n readonly list: Solid[]\n stamp: number\n /** `list` as a contact shape (`apartDeep`). */\n shape?: ContactShape\n}\n\n/** The axis of the box whose face the last `boxTopAt` line left through (its top there): the face a point on that spot stands on. */\nlet topFace = 1\n\n/** Height where the vertical line through `(x, z)` leaves the top of a box, or -Infinity when it misses the box. */\nconst boxTopAt = (s: Solid, x: number, z: number): number => {\n const e = s.e\n const dx = x - s.c[0], dz = z - s.c[2]\n let t0 = -Infinity, t1 = Infinity\n for (let k = 0; k < 3; k++) {\n // the line is c + (dx, t, dz) with t the height over the centre; along axis k: p + t d\n const p = e[k * 4] * dx + e[k * 4 + 2] * dz\n const d = e[k * 4 + 1]\n const h = s.half[k]\n if (Math.abs(d) < 1e-9) {\n if (Math.abs(p) > h) return -Infinity\n continue\n }\n let a = (-h - p) / d, b = (h - p) / d\n if (a > b) [a, b] = [b, a]\n t0 = Math.max(t0, a)\n if (b < t1) {\n t1 = b\n topFace = k\n }\n if (t0 > t1) return -Infinity\n }\n return s.c[1] + t1\n}\n\nconst UP: Vec3 = [0, 1, 0]\n\n/** The key of a pair of pieces (`PieceSystem.apartDeep`), the same whichever comes first. */\nexport const apartKey = (a: string, b: string): string => (a < b ? `${a}\\u0000${b}` : `${b}\\u0000${a}`)\n\n/** The outward normal of face `axis` of a box on its upper side: the surface of a tilted table top under a point. */\nconst faceNormal = (s: Solid, axis: number): Vec3 => {\n const e = s.e\n const sign = e[axis * 4 + 1] < 0 ? -1 : 1\n return [sign * e[axis * 4], sign * e[axis * 4 + 1], sign * e[axis * 4 + 2]]\n}\n\n/** The friction of two surfaces against each other: the geometric mean of each one's coefficients. */\nconst pairFriction = (a: PieceFriction | undefined, b: PieceFriction | null): PieceFriction => ({\n static: Math.sqrt((a?.static ?? MU_STATIC) * (b?.static ?? MU_STATIC)),\n dynamic: Math.sqrt((a?.dynamic ?? MU_DYNAMIC) * (b?.dynamic ?? MU_DYNAMIC)),\n // the softer of the two sets how much a round thing rolling on the other sinks in and is held back\n rolling: Math.max(a?.rolling ?? 0, b?.rolling ?? ROLLING_RESISTANCE),\n // both lose energy in the contact: a log on grass is held by its bark and by the blades\n rollingDamping: (a?.rollingDamping ?? PIECE_ROLLING_DAMPING) + (b?.rollingDamping ?? GROUND_ROLLING_DAMPING),\n})\n\n/** The coefficient of restitution of two surfaces against each other: the geometric mean of each one's. */\nconst pairRestitution = (a: number | undefined, b: number | undefined): number => Math.sqrt((a ?? SLAM_BOUNCE) * (b ?? SLAM_BOUNCE))\n\n/** The angle (rad) between the rotation `a` and `q`. */\nconst turnBetween = (a: readonly [number, number, number, number], q: THREE_NS.Quaternion): number => 2 * Math.acos(Math.min(1, Math.abs(a[0] * q.x + a[1] * q.y + a[2] * q.z + a[3] * q.w)))\n\n/**\n * Light rigid-body physics for loose pieces: gravity, the 8 corners of the local box against the ground with an impulse (restitution, friction,\n * angular response), damping, sleeping, and a gentle horizontal separation between pieces side by side. The ground a corner lands on is the\n * highest of the terrain, the top of any other piece under it and what the host reports as fixed (`staticTopAt`): a falling shelf lands on the books\n * below it, a tipping panel on the chair in front of it. Over a step (a table's edge) points along the box's edges touch too, so the edge holds the box between\n * its corners, and the side of a step of the ground is a wall: a corner that comes at it from the side stops there. The contacts are solved together, warm started.\n * Not a general solver: what lies under a corner holds it, what stands beside it does not.\n */\nexport class PieceSystem {\n readonly list: PieceBody[] = []\n private time = 0\n private generations = 0\n private readonly p: THREE_NS.Vector3\n private readonly q: THREE_NS.Quaternion\n private readonly dq: THREE_NS.Quaternion\n private readonly nextQ: THREE_NS.Quaternion\n private readonly m: THREE_NS.Matrix4\n private readonly hingeM: THREE_NS.Matrix4\n private readonly ax: THREE_NS.Vector3\n private solids: Solid[] = []\n /** The engine stepping the pieces (`PieceSystemOptions.physics`), or null for the kit's own solver. */\n private readonly engine: EnginePieces | null\n /** The host's ground worker, disposed with the system: by the engine, or here when there is none (the kit's own solver lays no tiles). */\n private readonly groundWorker: GroundWorkerPort | null\n /** The loop the system steps itself (a world was handed), the loop it only registers on (a loop was handed), or null on `'own'`. */\n private readonly loop: PhysicsLoop | null\n private readonly stepsItself: boolean\n /** The phases' way out of the loop, and whether this frame's `prepare` ran (it runs once, in the first fixed step). */\n private readonly leaveLoop: Array<() => void> = []\n private prepared = false\n /** The pose before the last step and after it, of the pieces that were awake (`interpolate`); null when the option is off. */\n private readonly trail: PoseTrail | null\n /** The pieces the loops walk (`AwakeList`): the rest are asleep on both sides and measured, and cost nothing per update. */\n private readonly awake = new AwakeList()\n /** `solids` and `surfaces` must be written again from the list: a piece came, went, or changed its parts. */\n private layoutDirty = true\n private reshaped = false\n /** The time each piece was made (`keepFar`: how old it is). */\n private readonly bornAt = new WeakMap<PieceBody, number>()\n private keptAt = -Infinity\n /** The boxes other pieces land on: a piece's own parts when it has them (`partBoxes`), else its box. */\n private surfaces: Solid[] = []\n /** The surfaces by the cells of a grid on the ground (`SURFACE_CELL`) their bounding circle covers: what is under a point is looked for in its cell only. */\n private readonly surfaceGrid = new Map<number, Solid[]>()\n /** The surfaces wider than `SURFACE_CELLS_ACROSS` cells (a slab come down whole): looked at for every point. */\n private readonly wideSurfaces: Solid[] = []\n /** Each piece's box of the step (`solids`), by its body. */\n private readonly solidOf = new Map<PieceBody, Solid>()\n /** Each piece's surfaces of the step (its parts' boxes, or its box), by its body. */\n private readonly surfacesOf = new Map<PieceBody, Solid[]>()\n /** Each piece's boxes, reused by `measure` from one update to the next, and the count of measures (what a record was last measured in). */\n private readonly records = new WeakMap<PieceBody, MeasuredBody>()\n private measures = 0\n /** `apartDeep`'s marked pairs, kept from one update to the next, and the pieces it has already looked at when they were born. */\n private readonly apartKeys = new Set<string>()\n /** Pieces torn apart by a joint that tears (a wire and the pole it hung from): the engine leaves each pair alone for good, by `apartKey`. */\n private readonly tethered = new Set<string>()\n /** The object ids alive in this update (`apartAll`), kept to make no set per frame. */\n private readonly presentIds = new Set<string>()\n private readonly seenBorn = new WeakSet<PieceBody>()\n /** The grid's cells by key: each its list (the one in `surfaceGrid`) and how many it holds in this measure. */\n private readonly cellIndex = new Map<number, number>()\n private readonly cellLists: Solid[][] = []\n private cellCounts = new Int32Array(64)\n /** How far each piece is put apart from the boxes it overlaps this step (`separatePair`), summed over its pairs and applied once, bounded, at the end of `collide`. */\n private readonly pushes = new Map<PieceBody, Vec3>()\n /** What each piece was put apart by in the last step, and the share of its push it is given now (`applyPushes`), for the pairs met in `collide` and in `apartDeep` apart. */\n private readonly collideSteps = new Map<PieceBody, PushStep>()\n private readonly apartSteps = new Map<PieceBody, PushStep>()\n private supportTurn = 0\n /** The surface normal and the friction of what the last `supportAt` found under the point (the ground and fixed tops are level: up, and no piece). */\n private supportNormal: Vec3 = UP\n private supportFriction: PieceFriction | null = null\n /** The terrain's surfaces by rolling resistance and damping (`terrainSurface`), one object each. */\n private readonly terrainSurfaces = new Map<string, PieceFriction>()\n /** The terrain's surface by ground tile (`groundTileKey`) this update, null for the default: read once per tile, not per contact per substep. */\n private readonly surfaceByTile = new Map<number, PieceFriction | null>()\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly o: PieceSystemOptions,\n ) {\n this.p = new THREE.Vector3()\n this.q = new THREE.Quaternion()\n this.dq = new THREE.Quaternion()\n this.nextQ = new THREE.Quaternion()\n this.m = new THREE.Matrix4()\n this.hingeM = new THREE.Matrix4()\n this.ax = new THREE.Vector3()\n const resolved = resolvePhysics(o.physics)\n this.loop = resolved?.loop ?? null\n this.stepsItself = resolved?.stepsItself ?? false\n this.trail = o.interpolate ? new PoseTrail() : null\n this.engine = resolved\n ? new EnginePieces(THREE, resolved.loop.world, {\n groundAt: o.terrainAt ?? o.groundAt,\n ...(o.terrainRollingAt ? { groundRollingAt: o.terrainRollingAt } : {}),\n ...(o.terrainRangeAt ? { groundRange: o.terrainRangeAt } : {}),\n // the grid stands for `terrainAt` alone: without it the tiles read `groundAt`, which the grid may not be (a lot flattened, a slab)\n ...(o.terrainGridAt && o.terrainAt ? { groundGrid: o.terrainGridAt } : {}),\n ...(o.terrainPatchAt && o.terrainGridAt && o.terrainAt ? { groundPatch: o.terrainPatchAt } : {}),\n ...(o.blastGroundTiles !== undefined ? { blastTiles: o.blastGroundTiles } : {}),\n gravity: o.gravity,\n staticSolids: o.staticSolids,\n sweep: o.sweep,\n onSlam: o.onSlam,\n onKnock: o.onKnock,\n onHardLanding: o.onHardLanding,\n ...(o.tilesUnderParts ? { tilesUnderParts: true } : {}),\n ...(o.groundWorker ? { groundWorker: o.groundWorker } : {}),\n ...(o.groundWorkerFrames !== undefined ? { groundWorkerFrames: o.groundWorkerFrames } : {}),\n })\n : null\n this.groundWorker = o.groundWorker ?? null\n if (resolved && !resolved.stepsItself) this.joinLoop(resolved.loop, this.engine as EnginePieces)\n }\n\n /**\n * The loop mode: the system's work goes into the loop's phases. `prepare` (sync, kinematic targets, the kit's rules that came before the step) runs in the first fixed step of\n * a frame; a held piece's target again in each later one; the read-back and knock sounds after the steps (`contacts`); the budget and the measure after those (`rules`).\n */\n private joinLoop(loop: PhysicsLoop, engine: EnginePieces): void {\n const h = loop.world.fixedStep\n this.leaveLoop.push(\n loop.add(\n {\n beforeStep: (step, frame) => {\n if (this.prepared) return engine.moveHeld(this.list, step, this.awake)\n this.prepared = true\n engine.wakePending(this.list, this.awake)\n this.beginTick()\n this.measure()\n this.wakeUnsupported(true)\n engine.prepare(this.list, frame.steps * h, step, this.apartAll(frame.steps * h), this.awake)\n },\n },\n 'actors',\n ),\n loop.add(\n {\n afterSteps: (dt, frame) => {\n // a frame too short for a step has no events and nothing moved: nothing to read back\n if (frame.steps > 0) engine.finish(this.list, dt, frame.time, this.awake)\n },\n },\n 'contacts',\n ),\n loop.add(\n {\n afterSteps: () => {\n const ran = this.prepared\n this.prepared = false\n if (!ran) return\n this.trail?.commit()\n this.measure()\n this.keepBudget()\n },\n },\n 'rules',\n ),\n )\n }\n\n /** Takes the system's phases out of the loop it was handed. */\n dispose(): void {\n this.trail?.clear()\n for (const leave of this.leaveLoop.splice(0)) leave()\n if (this.engine) this.engine.dispose()\n else this.groundWorker?.dispose()\n }\n\n /**\n * Pairs born overlapping (both made in the same update, or one made inside the other) deeper than a contact (`LIFT_DEPTH`: chunks of one wall) go apart along the ground by\n * the kit's rule (`slideApart`), and the engine leaves the pair alone until they are apart: it would push them out along their least overlap, up through the pile. A pair\n * is marked once, when the second of them is first seen, and unmarked for good when apart; what comes to overlap later through the dynamics is the engine's. The pairs, by `apartKey`.\n */\n /** The engine is to leave these two pieces (by object id) alone from now on: they were one object, held by a joint that tore. */\n tether(a: string, b: string): void {\n this.tethered.add(apartKey(a, b))\n }\n\n /** The pairs the engine leaves alone: the deep ones, and the tethered ones whose two pieces both exist. */\n private apartAll(dt: number): Set<string> {\n const deep = this.apartDeep(dt)\n if (this.tethered.size === 0) return deep\n const present = this.presentIds\n present.clear()\n for (const b of this.list) present.add(b.objectId)\n const all = new Set(deep)\n for (const key of this.tethered) {\n const cut = key.indexOf('\\u0000')\n if (present.has(key.slice(0, cut)) && present.has(key.slice(cut + 1))) all.add(key)\n }\n return all\n }\n\n private apartDeep(dt: number): Set<string> {\n const keys = this.apartKeys\n const born = this.list.filter((b) => !this.seenBorn.has(b))\n for (const b of born) this.seenBorn.add(b)\n for (const b of born) {\n for (const o of this.list) {\n if (o === b || (born.includes(o) && o.objectId < b.objectId)) continue\n if (this.bornApart(b, o)) keys.add(apartKey(b.objectId, o.objectId))\n }\n }\n if (keys.size === 0) return keys\n const byObject = new Map<string, PieceBody>()\n for (const b of this.list) byObject.set(b.objectId, b)\n for (const key of keys) {\n const cut = key.indexOf('\\u0000')\n const a = byObject.get(key.slice(0, cut))\n const b = byObject.get(key.slice(cut + 1))\n const hit = a && b ? this.deepContact(a, b) : null\n if (!a || !b || !hit) {\n keys.delete(key)\n continue\n }\n const ima = a.held || a.sleeping ? 0 : 1 / a.mass\n const imb = b.held || b.sleeping ? 0 : 1 / b.mass\n this.slideApart(a, b, ima, imb, hit)\n }\n this.applyPushes(dt, this.apartSteps)\n return keys\n }\n\n /** Whether two pieces just seen are inside each other deeper than a contact. */\n private bornApart(a: PieceBody, b: PieceBody): boolean {\n if (a.round || b.round || ((a.held || a.sleeping) && (b.held || b.sleeping))) return false\n if (!this.partsOverlap(a, b)) return false\n const hit = shapeContact(this.measuredShape(a), this.measuredShape(b))\n return !!hit && hit.depth > LIFT_DEPTH\n }\n\n /** The contact to slide a marked pair apart by, or null once they are no deeper than a contact (or no longer both boxes that can be moved). */\n private deepContact(a: PieceBody, b: PieceBody): ShapeContact | null {\n if (a.round || b.round || ((a.held || a.sleeping) && (b.held || b.sleeping))) return null\n const sa = this.measuredShape(a)\n const sb = this.measuredShape(b)\n const hit = shapeContact(sa, sb)\n if (!hit || hit.depth <= LIFT_DEPTH) return null\n return Math.hypot(hit.normal[0], hit.normal[2]) > KNOCK_FLAT ? (levelBoxesApart(sa, sb) ?? hit) : boxesApartAlongGround(sa, sb)\n }\n\n /** A box piece's shape as `measure` left it (`surfacesOf`), one object per piece. */\n private measuredShape(b: PieceBody): ContactShape {\n const rec = this.measured(b)\n rec.shape ??= { kind: 'boxes', boxes: rec.list }\n return rec.shape\n }\n\n get(objectId: string): PieceBody | null {\n return this.list.find((b) => b.objectId === objectId) ?? null\n }\n\n /** Sets a piece falling over, about the world axes x and z (a unit axis): its feet are thinner than the box that stands for it, so the box alone would hold it up. */\n tip(body: PieceBody, x: number, z: number): void {\n body.tipping = { x, z, seconds: TIP_SECONDS }\n body.sleeping = false\n }\n\n /**\n * Hangs a piece on a hinge at `point` (world): that point of it stays where it is while the rest swings down about it, as a shelf that lost the side at one end swings on\n * the screw at the other and pours what lay on it off its free end. It lets go past `HINGE_RELEASE` or `HINGE_SECONDS`. The kit's own solver only (`physics` swings nothing).\n */\n hinge(body: PieceBody, point: Vec3): void {\n if (this.engine) return\n const c = this.centerOf(body, this.p)\n const q = body.root.quaternion\n const local = this.ax.set(point[0] - c.x, point[1] - c.y, point[2] - c.z).applyQuaternion(this.dq.copy(q).invert())\n body.hinge = { point: [point[0], point[1], point[2]], local: [local.x, local.y, local.z], from: [q.x, q.y, q.z, q.w], seconds: HINGE_SECONDS }\n body.sleeping = false\n }\n\n create(objectId: string, root: THREE_NS.Object3D, halfExtents: Vec3, localCenter: THREE_NS.Vector3, mass: number, velocity?: Vec3, angular?: Vec3): PieceBody {\n const existing = this.get(objectId)\n if (existing) {\n existing.root = root\n existing.halfExtents = halfExtents\n existing.mass = mass\n this.setCenter(existing, localCenter)\n if (velocity) existing.velocity = [...velocity]\n existing.sleeping = false\n return existing\n }\n const awake = this.awake\n let asleep = false\n let inHand = false\n const body: PieceBody = {\n objectId,\n generation: ++this.generations,\n tipping: null,\n root,\n velocity: velocity ? [...velocity] : [0, 0, 0],\n angularVelocity: angular ? [...angular] : [0, 0, 0],\n halfExtents: [Math.max(0.01, halfExtents[0]), Math.max(0.01, halfExtents[1]), Math.max(0.01, halfExtents[2])],\n mass: Math.max(0.05, mass),\n // asleep or held is read and written as a plain flag; waking or taking it in hand puts the piece among the awake ones\n get sleeping() {\n return asleep\n },\n set sleeping(value: boolean) {\n asleep = value\n if (!value) awake.enter(body)\n },\n get held() {\n return inHand\n },\n set held(value: boolean) {\n inHand = value\n if (value) awake.enter(body)\n },\n localCenter: [localCenter.x, localCenter.y, localCenter.z],\n centerV: localCenter.clone(),\n still: 0,\n calmAt: null,\n calm: 0,\n lastHit: -1,\n onGround: false,\n }\n this.list.push(body)\n awake.enter(body)\n this.layoutDirty = true\n this.bornAt.set(body, this.time)\n return body\n }\n\n /** What the loop's last frame cost (ms) and how many bodies the world had awake: the pair the cost of a body is read from. Null on the kit's own solver. */\n stepCost(): { stepMs: number; active: number } | null {\n return this.loop ? { stepMs: this.loop.frame.stepMs, active: this.loop.world.activeCount } : null\n }\n\n /** Bodies awake in the physics world, or the pieces not asleep on the kit's own solver. */\n activeBodies(): number {\n return this.loop ? this.loop.world.activeCount : this.list.filter((b) => !b.sleeping).length\n }\n\n /** Move the centre of mass (after a part broke off). */\n setCenter(b: PieceBody, c: THREE_NS.Vector3): void {\n b.centerV.copy(c)\n b.localCenter = [c.x, c.y, c.z]\n this.awake.enter(b)\n }\n\n remove(objectId: string): void {\n const i = this.list.findIndex((b) => b.objectId === objectId)\n if (i < 0) return\n // the boxes of the step forget it too: nothing keeps a removed piece's tree alive\n const [gone] = this.list.splice(i, 1)\n if (gone) this.awake.leave(gone)\n this.layoutDirty = true\n // its torn pairs go with it (§8); a pair whose other side is a fixed object, not a piece, stays until the piece goes: the pole may still fall\n for (const key of this.tethered) {\n const cut = key.indexOf('\\u0000')\n if (key.slice(0, cut) === objectId || key.slice(cut + 1) === objectId) this.tethered.delete(key)\n }\n if (gone) {\n this.forgetSolids(gone)\n this.engine?.remove(gone)\n }\n }\n\n clear(): void {\n this.trail?.clear()\n this.engine?.clear()\n this.list.length = 0\n this.awake.clear()\n this.layoutDirty = true\n this.solids = []\n this.surfaces = []\n this.solidOf.clear()\n this.surfacesOf.clear()\n this.collideSteps.clear()\n this.apartSteps.clear()\n this.surfaceGrid.clear()\n this.cellIndex.clear()\n this.cellLists.length = 0\n this.wideSurfaces.length = 0\n }\n\n /** Drops a piece from the boxes of the step (`solids`, `surfaces` and their grid) and from the pushes it is remembered by. */\n private forgetSolids(body: PieceBody): void {\n this.collideSteps.delete(body)\n this.apartSteps.delete(body)\n this.solidOf.delete(body)\n this.surfacesOf.delete(body)\n this.solids = this.solids.filter((s) => s.body !== body)\n this.surfaces = this.surfaces.filter((s) => s.body !== body)\n for (const [key, cell] of this.surfaceGrid) {\n // the cell's own list, cut in place: `gridSurfaces` fills the same lists again\n let kept = 0\n for (const one of cell) if (one.body !== body) cell[kept++] = one\n cell.length = kept\n if (kept > 0) continue\n this.surfaceGrid.delete(key)\n this.cellIndex.delete(key)\n }\n const wide = this.wideSurfaces.filter((s) => s.body !== body)\n this.wideSurfaces.length = 0\n this.wideSurfaces.push(...wide)\n }\n\n /** `clear` and the clock back to 0. */\n reset(): void {\n this.clear()\n this.time = 0\n }\n\n /** World position of the centre of mass. */\n centerOf(b: PieceBody, out: THREE_NS.Vector3): THREE_NS.Vector3 {\n return out.copy(b.centerV).applyQuaternion(b.root.quaternion).add(b.root.position)\n }\n\n impulse(b: PieceBody, impulse: Vec3, point?: Vec3): void {\n const inv = 1 / b.mass\n b.velocity[0] += impulse[0] * inv\n b.velocity[1] += impulse[1] * inv\n b.velocity[2] += impulse[2] * inv\n if (point) {\n const c = this.centerOf(b, this.p)\n const rx = point[0] - c.x\n const ry = point[1] - c.y\n const rz = point[2] - c.z\n // torque = r x J, angular velocity change = I^-1 torque\n const tx = ry * impulse[2] - rz * impulse[1]\n const ty = rz * impulse[0] - rx * impulse[2]\n const tz = rx * impulse[1] - ry * impulse[0]\n const w = this.mulInvInertia(b, tx, ty, tz)\n b.angularVelocity[0] += w[0]\n b.angularVelocity[1] += w[1]\n b.angularVelocity[2] += w[2]\n }\n b.sleeping = false\n b.still = 0\n b.calmAt = null\n }\n\n /** I^-1 * (x, y, z) in world space for a box with the body's half extents and mass (needs `this.m` to hold the body's rotation). */\n private mulInvInertia(b: PieceBody, x: number, y: number, z: number): Vec3 {\n this.m.makeRotationFromQuaternion(b.root.quaternion)\n return this.mulInvInertiaWith(b, this.m.elements, x, y, z)\n }\n\n private mulInvInertiaWith(b: PieceBody, e: ArrayLike<number>, x: number, y: number, z: number): Vec3 {\n const [hx, hy, hz] = b.halfExtents\n const k = 3 / b.mass\n let ix = k / (hy * hy + hz * hz)\n let iy = k / (hx * hx + hz * hz)\n let iz = k / (hx * hx + hy * hy)\n const round = b.round\n if (round) {\n // about the axis it rolls on, a round piece has I = k m r^2: a full can is a solid cylinder (k 0.5), an empty one a thin shell (k 1)\n const about = 1 / (round.inertia * b.mass * round.radius * round.radius)\n if (round.kind === 'sphere') ix = iy = iz = about\n else if (round.axis === 0) ix = about\n else if (round.axis === 1) iy = about\n else iz = about\n }\n // local = R^T v (columns of R are the local axes in world space)\n const lx = (e[0] * x + e[1] * y + e[2] * z) * ix\n const ly = (e[4] * x + e[5] * y + e[6] * z) * iy\n const lz = (e[8] * x + e[9] * y + e[10] * z) * iz\n return [e[0] * lx + e[4] * ly + e[8] * lz, e[1] * lx + e[5] * ly + e[9] * lz, e[2] * lx + e[6] * ly + e[10] * lz]\n }\n\n /** The points of the box that touch the ground, in its own frame: the 8 corners, then (with `edges`) `EDGE_POINTS` along each of its 12 edges; or the piece's own `contacts`. */\n private samples(b: PieceBody, edges: boolean): Vec3[] {\n if (b.contacts) return b.contacts\n const [hx, hy, hz] = b.halfExtents\n const out: Vec3[] = []\n for (let i = 0; i < 8; i++) out.push([i & 1 ? hx : -hx, i & 2 ? hy : -hy, i & 4 ? hz : -hz])\n if (!edges) return out\n const h = [hx, hy, hz]\n for (let axis = 0; axis < 3; axis++) {\n const a1 = (axis + 1) % 3\n const a2 = (axis + 2) % 3\n for (let k = 0; k < 4; k++) {\n for (const f of EDGE_POINTS) {\n const p: Vec3 = [0, 0, 0]\n p[axis] = f * h[axis]\n p[a1] = k & 1 ? h[a1] : -h[a1]\n p[a2] = k & 2 ? h[a2] : -h[a2]\n out.push(p)\n }\n }\n }\n return out\n }\n\n /**\n * An impulse along the unit normal `n` at `r` (from the centre of mass, world) that stops the point closing in along `n` (with `bounce`); `e` holds the body's rotation.\n */\n private contactImpulse(b: PieceBody, e: ArrayLike<number>, r: Vec3, n: Vec3, bounce: number): void {\n const v = b.velocity\n const w = b.angularVelocity\n const vn = (v[0] + w[1] * r[2] - w[2] * r[1]) * n[0] + (v[1] + w[2] * r[0] - w[0] * r[2]) * n[1] + (v[2] + w[0] * r[1] - w[1] * r[0]) * n[2]\n if (vn >= 0) return\n // I^-1 (r x n), then (I^-1 (r x n) x r) . n\n const a = this.mulInvInertiaWith(b, e, r[1] * n[2] - r[2] * n[1], r[2] * n[0] - r[0] * n[2], r[0] * n[1] - r[1] * n[0])\n const k = (a[1] * r[2] - a[2] * r[1]) * n[0] + (a[2] * r[0] - a[0] * r[2]) * n[1] + (a[0] * r[1] - a[1] * r[0]) * n[2]\n const j = (-(1 + bounce) * vn) / (1 / b.mass + k)\n for (let i = 0; i < 3; i++) {\n v[i] += (j * n[i]) / b.mass\n w[i] += a[i] * j\n }\n }\n\n /** A blast at (x, z) of `radius`: the ground within its reach is laid at the next update, before the pieces it makes need it (`EnginePieces.layAhead`). */\n layGroundAt(x: number, z: number, radius: number): void {\n this.engine?.layAhead(x, z, radius)\n }\n\n /** What lies inside the disc looks at the ground again: it was dug or heaped under it. */\n wakeRegion(x: number, z: number, radius: number): void {\n this.engine?.groundChanged(x, z, radius)\n for (const b of this.list) {\n if (!b.sleeping || b.held || Math.hypot(b.root.position.x - x, b.root.position.z - z) > radius) continue\n b.sleeping = false\n b.still = 0\n b.calmAt = null\n }\n }\n\n /** A step is about to move the pieces: the roots go back to the step's pose and the awake ones are recorded as the previous one (`interpolate`). */\n private beginTick(): void {\n const trail = this.trail\n if (!trail) return\n trail.begin()\n for (const body of this.awake.items) if (!body.sleeping) trail.record(body.root)\n }\n\n /** The roots get the step pose back, before anything reads them (the start of a tick; a host calls it first when it reads a root between `presentPose` and the step). */\n restoreStepPose(): void {\n this.trail?.restore()\n }\n\n /** The awake pieces drawn `alpha` of the way from their pose before the last step to the step's (1: the step's). Pieces asleep, and without `interpolate`, are left as they are. */\n presentPose(alpha: number): void {\n this.trail?.blend(alpha)\n }\n\n update(dt: number): void {\n if (this.trail && !(this.engine && this.loop && !this.stepsItself)) {\n this.beginTick()\n this.advance(dt)\n this.trail.commit()\n return\n }\n this.advance(dt)\n }\n\n private advance(dt: number): void {\n if (this.engine && this.loop) {\n // under a loop the host stepped it already, and its time is the one that counts\n if (!this.stepsItself) {\n this.time = this.loop.frame.time\n this.keepFar()\n return\n }\n this.time += dt\n this.engine.wakePending(this.list, this.awake)\n this.measure()\n // what the budget put to sleep (the engine did not) wakes when a point it lay on loses its support: the kit's rule. What the engine put to sleep it wakes\n // itself when what holds it moves; a fixed thing removed or the ground changed wakes what was there (`EnginePieces`)\n this.wakeUnsupported(true)\n if (dt > 0) {\n this.engine.prepare(this.list, dt, dt, this.apartAll(dt), this.awake)\n this.loop.step(dt)\n this.engine.finish(this.list, dt, this.time, this.awake)\n }\n this.measure()\n this.keepBudget()\n this.keepFar()\n return\n }\n const { steps, near } = this.collisionSteps(dt)\n if (steps === 1) {\n this.time += dt\n this.step(dt)\n return\n }\n // only the round pieces and what closes in on them are split: the rest (a wall's bricks falling far from the can) take the update whole, so their sweep runs once\n const start = this.time\n this.time = start + dt\n const far = (b: PieceBody): boolean => !near.has(b)\n this.step(dt, { moves: far, meets: (a, b) => far(a) && far(b) })\n for (let i = 0; i < steps; i++) {\n this.time = start + (dt * (i + 1)) / steps\n this.step(dt / steps, { moves: (b) => near.has(b), meets: (a, b) => near.has(a) || near.has(b) })\n }\n }\n\n /**\n * Steps of an update: one, or more while a round piece and a piece it could meet within the update close in fast enough to pass through each other between two (closing at\n * their two speeds they cover at most the round one's radius per step: two cans at 3.6 m/s close 12 cm in a frame, a can is 7 cm across; a plank thrown at a can still counts).\n * A round piece with nothing in reach takes one step, so its sweep against the world (the costly part) runs once; `near` holds the pieces of the pairs that need more.\n */\n private collisionSteps(dt: number): { steps: number; near: Set<PieceBody> } {\n let need = 1\n const near = new Set<PieceBody>()\n const p = this.p\n const speedOf = (b: PieceBody): number => (b.held ? 0 : Math.hypot(b.velocity[0], b.velocity[1], b.velocity[2]))\n for (const b of this.list) {\n if (!b.round || b.held) continue\n // a radius of nothing passes through nothing: one step\n const radius = Math.max(MIN_ROUND_RADIUS, b.round.radius)\n const speed = b.sleeping ? 0 : speedOf(b)\n const c = this.centerOf(b, p)\n const cx = c.x, cy = c.y, cz = c.z\n const rb = Math.hypot(b.halfExtents[0], b.halfExtents[1], b.halfExtents[2])\n for (const o of this.list) {\n if (o === b || (b.sleeping && o.sleeping)) continue\n const closing = speed + (o.sleeping ? 0 : speedOf(o))\n if (closing * dt < radius * 0.5) continue\n const reach = closing * dt + rb + Math.hypot(o.halfExtents[0], o.halfExtents[1], o.halfExtents[2])\n const oc = this.centerOf(o, p)\n if (Math.abs(oc.x - cx) > reach || Math.abs(oc.y - cy) > reach || Math.abs(oc.z - cz) > reach) continue\n const pair = Math.ceil((closing * dt) / radius)\n if (pair < 2) continue\n need = Math.max(need, pair)\n near.add(b)\n near.add(o)\n }\n }\n return { steps: Math.max(1, Math.min(MAX_COLLISION_STEPS, need)), near }\n }\n\n /** A step of `dt`: the pieces `only.moves` takes move (all when absent) and the pairs `only.meets` takes meet, so each pair meets in one of the steps of an update. */\n private step(dt: number, only?: StepFilter): void {\n this.surfaceByTile.clear()\n this.measure()\n this.wakeUnsupported()\n for (const b of this.list) {\n if (b.held) {\n b.velocity = [0, 0, 0]\n b.angularVelocity = [0, 0, 0]\n b.sleeping = false\n b.still = 0\n b.calmAt = null\n continue\n }\n if (b.sleeping || (only && !only.moves(b))) continue\n this.integrate(b, dt)\n if (b.sleeping) continue\n const v = b.velocity\n const w = b.angularVelocity\n if (Math.hypot(v[0], v[1], v[2]) > WAKE_ABOVE_SPEED || Math.hypot(w[0], w[1], w[2]) > WAKE_ABOVE_SPIN) this.wakeAbove(b)\n }\n this.collide(dt, only?.meets)\n this.keepBudget()\n this.keepFar()\n }\n\n /**\n * The boxes of the pieces as they stand (`solids`, `surfaces` and their grid): the boxes of the awake pieces are worked out again, the others kept as they were measured (a\n * piece leaves the awake list only after the measure that has its last pose). With none awake and no piece come or gone, nothing is done.\n */\n private measure(): void {\n // each piece's boxes are its own objects from one update to the next, written over in place: two measures an update over 200 pieces made a Vector3, a Matrix4,\n // its elements twice and the surfaces anew for each (90 MB in 200 updates of the debris bench, most of the collector's pauses)\n this.measures++\n this.reshaped = this.layoutDirty\n this.awake.walk(this.measureAwake)\n if (this.reshaped) this.writeLayout()\n else if (this.awake.items.length > 0) this.gridSurfaces()\n this.awake.settle(this.isSettled)\n }\n\n /** A piece is asleep on both sides (the engine's too) or, on the kit's own solver, asleep and not held: nothing of it changes until it wakes. */\n private readonly isSettled = (body: PieceBody): boolean => (this.engine ? this.engine.isSettled(body) : body.sleeping && !body.held)\n\n private readonly measureAwake = (body: PieceBody): void => {\n const rec = this.measured(body)\n const from = rec.from\n const count = rec.list.length\n const first = rec.list[0]\n const w = rec.whole\n const c = this.centerOf(body, this.p)\n w.c[0] = c.x\n w.c[1] = c.y\n w.c[2] = c.z\n const el = this.m.makeRotationFromQuaternion(body.root.quaternion).elements\n for (let k = 0; k < 16; k++) w.e[k] = el[k]\n const h = body.halfExtents\n w.half = h\n w.r = Math.sqrt(h[0] * h[0] + h[1] * h[1] + h[2] * h[2])\n // what lands on a piece lands on its parts (a shelf's boards, a table's top), not on the box around them all\n const parts = body.partBoxes\n if (!parts) {\n rec.list[0] = w\n if (rec.list.length !== 1) rec.list.length = 1\n } else this.measureParts(rec, parts)\n if (rec.from !== from || rec.list.length !== count || rec.list[0] !== first) this.reshaped = true\n }\n\n /** `solids`, `surfaces` and the maps by body written from the pieces' records, in the order of the list. */\n private writeLayout(): void {\n this.layoutDirty = false\n let solids = 0\n let surfaces = 0\n for (const body of this.list) {\n const rec = this.measured(body)\n this.solids[solids++] = rec.whole\n for (const one of rec.list) this.surfaces[surfaces++] = one\n rec.stamp = this.measures\n this.solidOf.set(body, rec.whole)\n this.surfacesOf.set(body, rec.list)\n }\n this.solids.length = solids\n this.surfaces.length = surfaces\n // a piece taken out goes through `forgetSolids`: this walk only finds one that left the list some other way\n if (this.solidOf.size !== this.list.length) for (const body of this.solidOf.keys()) {\n if (this.records.get(body)?.stamp === this.measures) continue\n this.solidOf.delete(body)\n this.surfacesOf.delete(body)\n }\n this.gridSurfaces()\n }\n\n /** A piece's own boxes for `measure`, made once. */\n private measured(body: PieceBody): MeasuredBody {\n let rec = this.records.get(body)\n if (!rec) {\n rec = { whole: { body, c: [0, 0, 0], e: new Array<number>(16).fill(0), half: body.halfExtents, r: 0 }, parts: [], from: undefined, squares: [], list: [], stamp: 0 }\n this.records.set(body, rec)\n }\n return rec\n }\n\n /** Its parts' boxes, square to the piece (`squareBoxOf`, worked out again only when its parts change), placed by its centre and turn of this update. */\n private measureParts(rec: MeasuredBody, parts: readonly PartBox[]): void {\n const w = rec.whole\n if (rec.from !== parts) {\n rec.from = parts\n rec.squares = parts.map(squareBoxOf)\n rec.parts = parts.map(() => ({ body: w.body, c: [0, 0, 0], e: w.e, half: w.half, r: 0 }))\n }\n const e = w.e\n for (let i = 0; i < rec.parts.length; i++) {\n const { center, half } = rec.squares[i]\n const one = rec.parts[i]\n one.c[0] = w.c[0] + e[0] * center[0] + e[4] * center[1] + e[8] * center[2]\n one.c[1] = w.c[1] + e[1] * center[0] + e[5] * center[1] + e[9] * center[2]\n one.c[2] = w.c[2] + e[2] * center[0] + e[6] * center[1] + e[10] * center[2]\n one.half = half\n one.r = Math.sqrt(half[0] * half[0] + half[1] * half[1] + half[2] * half[2])\n }\n for (let i = 0; i < rec.parts.length; i++) rec.list[i] = rec.parts[i]\n if (rec.list.length !== rec.parts.length) rec.list.length = rec.parts.length\n }\n\n /**\n * The surfaces into the cells of the grid they cover (`surfaceGrid`). The cells' lists are kept from one measure to the next, written over by index and cut to their\n * count at the end: emptied and pushed again, every list was made anew each measure (31 MB in 200 updates of the debris bench).\n */\n private gridSurfaces(): void {\n this.cellCounts.fill(0)\n this.wideSurfaces.length = 0\n for (const one of this.surfaces) {\n const x0 = Math.floor((one.c[0] - one.r) / SURFACE_CELL)\n const x1 = Math.floor((one.c[0] + one.r) / SURFACE_CELL)\n const z0 = Math.floor((one.c[2] - one.r) / SURFACE_CELL)\n const z1 = Math.floor((one.c[2] + one.r) / SURFACE_CELL)\n if (x1 - x0 > SURFACE_CELLS_ACROSS || z1 - z0 > SURFACE_CELLS_ACROSS) {\n this.wideSurfaces.push(one)\n continue\n }\n for (let ix = x0; ix <= x1; ix++) for (let iz = z0; iz <= z1; iz++) this.intoCell(cellKey(ix, iz), one)\n }\n for (const one of this.wideSurfaces) for (const key of this.surfaceGrid.keys()) this.intoCell(key, one)\n for (let i = 0; i < this.cellLists.length; i++) if (this.cellLists[i].length !== this.cellCounts[i]) this.cellLists[i].length = this.cellCounts[i]\n }\n\n private intoCell(key: number, one: Solid): void {\n let i = this.cellIndex.get(key)\n if (i === undefined) {\n i = this.cellLists.length\n const list: Solid[] = []\n this.cellLists.push(list)\n this.cellIndex.set(key, i)\n this.surfaceGrid.set(key, list)\n if (this.cellCounts.length <= i) {\n const grown = new Int32Array(Math.max(64, this.cellCounts.length * 2))\n grown.set(this.cellCounts)\n this.cellCounts = grown\n }\n }\n this.cellLists[i][this.cellCounts[i]++] = one\n }\n\n /** A few sleeping pieces each update (`SUPPORT_CHECKS`, in turn) look under them again: one whose table broke, or whose shelf fell over, falls. */\n private wakeUnsupported(onlyBudget = false): void {\n const n = this.list.length\n for (let k = 0; k < Math.min(SUPPORT_CHECKS, n); k++) {\n this.supportTurn = (this.supportTurn + 1) % n\n const b = this.list[this.supportTurn]\n if (!b.sleeping || b.held || (onlyBudget && !b.restPoints?.length)) continue\n // one put to sleep by the budget needs every point it went to sleep on: a board leaning on a step whose step is gone comes down, though its foot is still on the floor\n const rest = b.restPoints\n if (rest && rest.length > 0 ? rest.every((point) => this.supportsPoint(b, point)) : this.supported(b, false) || this.supported(b, true)) continue\n b.sleeping = false\n b.still = 0\n b.calmAt = null\n b.restPoints = undefined\n }\n }\n\n /**\n * Whether a point of `b` (its corners, or with `edges` the points along its edges too) has the ground, a piece or a fixed top under it. Any point, not only the lowest:\n * a book propped on a fallen case rests by a corner high on it while its lowest one hangs beside it.\n */\n private supported(b: PieceBody, edges: boolean): boolean {\n const c = this.centerOf(b, this.p)\n const e = this.m.makeRotationFromQuaternion(b.root.quaternion).elements\n for (const [sx, sy, sz] of this.samples(b, edges)) {\n const y = c.y + e[1] * sx + e[5] * sy + e[9] * sz\n const x = c.x + e[0] * sx + e[4] * sy + e[8] * sz\n const z = c.z + e[2] * sx + e[6] * sy + e[10] * sz\n if (this.supportAt(b, x, y, z, STEP) >= y - SUPPORT_GAP) return true\n }\n return false\n }\n\n /** The surfaces whose cell holds `(x, z)`, the wide ones (`wideSurfaces`) among them. */\n private surfacesAt(x: number, z: number): readonly Solid[] {\n return this.surfaceGrid.get(cellKey(Math.floor(x / SURFACE_CELL), Math.floor(z / SURFACE_CELL))) ?? this.wideSurfaces\n }\n\n /** The highest top of a piece (other than `self`) under `(x, z)` that a point at height `y` stands on (at most `step` above it), -Infinity when none; the boxes of the last update. */\n topAt(x: number, z: number, y: number, step: number, self?: string): number {\n let top = -Infinity\n for (const s of this.surfacesAt(x, z)) {\n if (s.body.objectId === self || (s.body.held && !s.body.carrying) || Math.abs(x - s.c[0]) > s.r || Math.abs(z - s.c[2]) > s.r) continue\n const t = boxTopAt(s, x, z)\n if (t > top && t <= y + step) top = t\n }\n return top\n }\n\n /** What lay asleep on `b` (a box over its top) wakes at once when `b` moves: a can on a table that goes over goes with it. */\n private wakeAbove(b: PieceBody): void {\n const below = this.solidOf.get(b)\n if (!below) return\n const top = below.c[1] + below.half[0] * Math.abs(below.e[1]) + below.half[1] * Math.abs(below.e[5]) + below.half[2] * Math.abs(below.e[9])\n // what can lie on it is in the cells its own circle covers\n const x0 = Math.floor((below.c[0] - below.r) / SURFACE_CELL)\n const x1 = Math.floor((below.c[0] + below.r) / SURFACE_CELL)\n const z0 = Math.floor((below.c[2] - below.r) / SURFACE_CELL)\n const z1 = Math.floor((below.c[2] + below.r) / SURFACE_CELL)\n const wide = x1 - x0 > SURFACE_CELLS_ACROSS || z1 - z0 > SURFACE_CELLS_ACROSS\n const look = (part: Solid): void => {\n const o = part.body\n const s = this.solidOf.get(o)\n if (!s || !o.sleeping || o.held || o === b) return\n if (s.c[1] < below.c[1] || s.c[1] - s.r > top + STEP || Math.hypot(s.c[0] - below.c[0], s.c[2] - below.c[2]) > s.r + below.r) return\n // what lies on it is over it: a board leaning over a can rolling by its foot is not on the can\n if (boxTopAt(below, s.c[0], s.c[2]) === -Infinity && !this.restsOn(o, b, true)) return\n o.sleeping = false\n o.still = 0\n o.calmAt = null\n }\n if (wide) for (const s of this.solids) look(s)\n else for (let ix = x0; ix <= x1; ix++) for (let iz = z0; iz <= z1; iz++) for (const part of this.surfaceGrid.get(cellKey(ix, iz)) ?? []) look(part)\n }\n\n /**\n * Whether `o` rests on a top of `below` (its parts, or its box): a corner of `o` (its contacts or its box) is over that top and within `STEP` of it. With `lowest`, only its\n * lowest corners count (within `STEP` of its lowest): a can rolling by another is beside it, not on it; without, a board leaning on a seat by its high end rests on the seat.\n */\n private restsOn(o: PieceBody, below: PieceBody, lowest: boolean): boolean {\n const c = this.centerOf(o, this.p)\n const e = this.m.makeRotationFromQuaternion(o.root.quaternion).elements\n const points = this.samples(o, false).map(([sx, sy, sz]): Vec3 => [c.x + e[0] * sx + e[4] * sy + e[8] * sz, c.y + e[1] * sx + e[5] * sy + e[9] * sz, c.z + e[2] * sx + e[6] * sy + e[10] * sz])\n let low = Infinity\n for (const p of points) low = Math.min(low, p[1])\n for (const [x, y, z] of points) {\n if (lowest && y > low + STEP) continue\n for (const s of this.surfacesAt(x, z)) if (s.body === below && Math.abs(y - boxTopAt(s, x, z)) <= STEP) return true\n }\n return false\n }\n\n /**\n * The terrain's own surface under a round piece's contact at (x, z) that stands at `y` on the ground `raw` (`groundAt` there), when it is the terrain and not a top above it\n * (`terrainAt`, which `groundAt` equals to the bit where nothing is on it); null otherwise (the default surface). Read as the engine reads it (`tileRollingAt`), once per tile\n * per update, and one object per value, so a substep makes none.\n */\n private terrainSurface(x: number, y: number, z: number, raw: number): PieceFriction | null {\n const rollingAt = this.o.terrainRollingAt\n if (!rollingAt || y !== raw || (this.o.terrainAt && y !== this.o.terrainAt(x, z))) return null\n const key = groundTileKey(x, z)\n let surface = this.surfaceByTile.get(key)\n if (surface === undefined) {\n surface = this.tileSurface(rollingAt, x, z)\n this.surfaceByTile.set(key, surface)\n }\n return surface\n }\n\n /** The terrain's surface of the tile at (x, z) (`tileRollingAt`), or null when it says nothing (the default surface). */\n private tileSurface(rollingAt: (x: number, z: number) => number | undefined, x: number, z: number): PieceFriction | null {\n const dampingAt = this.o.terrainRollingDampingAt\n const rolling = tileRollingAt(rollingAt, x, z)\n const rollingDamping = dampingAt ? tileRollingAt(dampingAt, x, z) : undefined\n if (rolling === undefined && rollingDamping === undefined) return null\n const id = `${rolling ?? ROLLING_RESISTANCE}|${rollingDamping ?? GROUND_ROLLING_DAMPING}`\n let surface = this.terrainSurfaces.get(id)\n if (!surface) {\n surface = { static: MU_STATIC, dynamic: MU_DYNAMIC, rolling: rolling ?? ROLLING_RESISTANCE, rollingDamping: rollingDamping ?? GROUND_ROLLING_DAMPING }\n this.terrainSurfaces.set(id, surface)\n }\n return surface\n }\n\n /** Where a corner of `self` at `(x, y, z)` lands: the ground, the top of another piece or of something fixed under it. */\n private supportAt(self: PieceBody, x: number, y: number, z: number, step: number): number {\n let top = this.o.groundAt(x, z)\n let on: Solid | null = null\n let face = 1\n for (const s of this.surfacesAt(x, z)) {\n if (s.body === self || (s.body.held && !s.body.carrying) || Math.abs(x - s.c[0]) > s.r || Math.abs(z - s.c[2]) > s.r) continue\n const t = boxTopAt(s, x, z)\n if (t > top && t <= y + step) {\n top = t\n on = s\n face = topFace\n }\n }\n const fixed = this.o.staticTopAt?.(x, z, y, step) ?? -Infinity\n if (fixed >= top) on = null\n this.supportNormal = on ? faceNormal(on, face) : UP\n this.supportFriction = on?.body.friction ?? null\n return Math.max(top, fixed)\n }\n\n /** Stops a piece that ran into something on its way from `start` to `pos` (`sweep`): moves it back to where it met it and takes the speed into it. */\n private sweepOn(b: PieceBody, start: Vec3, pos: Vec3): void {\n const travel = Math.hypot(pos[0] - start[0], pos[1] - start[1], pos[2] - start[2])\n if (travel < 1e-3) return\n const hit = this.o.sweep?.(b, start, pos)\n if (!hit || hit.normal[1] > SLAM_FLOOR_NORMAL) return\n const v = b.velocity\n const n = hit.normal\n const into = -(v[0] * n[0] + v[1] * n[1] + v[2] * n[2])\n if (into <= 0) return\n const k = Math.min(1, hit.distance / travel)\n const bounce = pairRestitution(b.restitution, hit.restitution)\n for (let i = 0; i < 3; i++) {\n pos[i] = start[i] + (pos[i] - start[i]) * k\n v[i] += (1 + bounce) * into * n[i]\n }\n const w = b.angularVelocity\n w[0] *= 0.5\n w[1] *= 0.5\n w[2] *= 0.5\n if (into >= SLAM_MIN_SPEED && this.time - b.lastHit > 0.15) {\n b.lastHit = this.time\n this.o.onSlam?.(b, hit, into)\n }\n }\n\n /**\n * The impulse that stops the hinge point of a piece: the point's velocity v + w x r goes to zero through J = -K^-1 (v + w x r), with K = 1/m - [r]x I^-1 [r]x, so what\n * gravity gave the centre turns into a swing about the hinge.\n */\n private holdOnHinge(b: PieceBody, hinge: PieceHinge, q: THREE_NS.Quaternion): void {\n const e = this.hingeM.makeRotationFromQuaternion(q).elements\n const [lx, ly, lz] = hinge.local\n const r: Vec3 = [e[0] * lx + e[4] * ly + e[8] * lz, e[1] * lx + e[5] * ly + e[9] * lz, e[2] * lx + e[6] * ly + e[10] * lz]\n const v = b.velocity\n const w = b.angularVelocity\n const point: Vec3 = [v[0] + w[1] * r[2] - w[2] * r[1], v[1] + w[2] * r[0] - w[0] * r[2], v[2] + w[0] * r[1] - w[1] * r[0]]\n // the columns of K: what a unit impulse along each axis does to the point's velocity\n const k: Vec3[] = [0, 1, 2].map((i) => {\n const d: Vec3 = [i === 0 ? 1 : 0, i === 1 ? 1 : 0, i === 2 ? 1 : 0]\n const t = this.mulInvInertiaWith(b, e, r[1] * d[2] - r[2] * d[1], r[2] * d[0] - r[0] * d[2], r[0] * d[1] - r[1] * d[0])\n return [d[0] / b.mass + t[1] * r[2] - t[2] * r[1], d[1] / b.mass + t[2] * r[0] - t[0] * r[2], d[2] / b.mass + t[0] * r[1] - t[1] * r[0]]\n })\n const j = solve3(k, [-point[0], -point[1], -point[2]])\n if (!j) return\n for (let i = 0; i < 3; i++) v[i] += j[i] / b.mass\n const dw = this.mulInvInertiaWith(b, e, r[1] * j[2] - r[2] * j[1], r[2] * j[0] - r[0] * j[2], r[0] * j[1] - r[1] * j[0])\n for (let i = 0; i < 3; i++) w[i] += dw[i]\n }\n\n /** Puts the hinge point back where it hangs (what the step's rounding moved it by), moving the centre. */\n private keepOnHinge(hinge: PieceHinge, pos: Vec3, q: THREE_NS.Quaternion): void {\n const e = this.hingeM.makeRotationFromQuaternion(q).elements\n const [lx, ly, lz] = hinge.local\n pos[0] = hinge.point[0] - (e[0] * lx + e[4] * ly + e[8] * lz)\n pos[1] = hinge.point[1] - (e[1] * lx + e[5] * ly + e[9] * lz)\n pos[2] = hinge.point[2] - (e[2] * lx + e[6] * ly + e[10] * lz)\n }\n\n /** The screw tears out: past `HINGE_RELEASE` of turn, or after `HINGE_SECONDS`, the piece falls free. */\n private wearHinge(b: PieceBody, hinge: PieceHinge, q: THREE_NS.Quaternion, dt: number): void {\n hinge.seconds -= dt\n const [x, y, z, w] = hinge.from\n const turned = 2 * Math.acos(Math.min(1, Math.abs(q.x * x + q.y * y + q.z * z + q.w * w)))\n if (turned >= HINGE_RELEASE || hinge.seconds <= 0) b.hinge = undefined\n }\n\n private integrate(b: PieceBody, dt: number): void {\n const c = this.centerOf(b, this.p)\n const pos: Vec3 = [c.x, c.y, c.z]\n const start: Vec3 = [c.x, c.y, c.z]\n const q = this.q.copy(b.root.quaternion)\n const v = b.velocity\n const w = b.angularVelocity\n const invM = 1 / b.mass\n const steps = clamp(Math.ceil(dt / SUB_DT), 1, 8)\n const h = dt / steps\n let landing = 0\n let landPoint: Vec3 = [pos[0], pos[1], pos[2]]\n let contactedLast = false\n const propped = b.propped\n const proppedAt = b.proppedAt\n b.propped = undefined\n b.proppedAt = undefined\n let touched = false\n let unstable = false\n\n // over a step of the ground (the corners find it at different heights: a table's edge under it) the points along the edges touch too\n const corners = this.samples(b, false)\n this.m.makeRotationFromQuaternion(q)\n let gLow = Infinity\n let gHigh = -Infinity\n for (const [sx, sy, sz] of corners) {\n const e0 = this.m.elements\n const y = pos[1] + e0[1] * sx + e0[5] * sy + e0[9] * sz\n const x = pos[0] + e0[0] * sx + e0[4] * sy + e0[8] * sz\n const z = pos[2] + e0[2] * sx + e0[6] * sy + e0[10] * sz\n // only the fixed ground counts here: other pieces touching it (a pile, things spawned together) keep the corners\n const g = Math.max(this.o.groundAt(x, z), this.o.staticTopAt?.(x, z, y, STEP) ?? -Infinity)\n gLow = Math.min(gLow, g)\n gHigh = Math.max(gHigh, g)\n }\n let local = b.round ? this.roundSamples(b, q) : gHigh - gLow > STEP ? this.samples(b, true) : corners\n let prev: Vec3[] = local.map(() => [0, 0, 0])\n\n for (let s = 0; s < steps; s++) {\n if (b.round) {\n // a round piece touches by its lowest points as it will be turned at the end of this substep: they move round it as it rolls\n const wl0 = Math.hypot(w[0], w[1], w[2])\n const next = this.nextQ.copy(q)\n if (wl0 > 1e-6) next.premultiply(this.dq.setFromAxisAngle(this.ax.set(w[0] / wl0, w[1] / wl0, w[2] / wl0), wl0 * h)).normalize()\n local = this.roundSamples(b, next)\n if (prev.length !== local.length) prev = local.map(() => [0, 0, 0])\n }\n // where each point was before this substep: a point that comes at a higher ground from below it hit the side of the step\n this.m.makeRotationFromQuaternion(q)\n const e0 = this.m.elements\n for (let i = 0; i < local.length; i++) {\n const [sx, sy, sz] = local[i]\n prev[i][0] = pos[0] + e0[0] * sx + e0[4] * sy + e0[8] * sz\n prev[i][1] = pos[1] + e0[1] * sx + e0[5] * sy + e0[9] * sz\n prev[i][2] = pos[2] + e0[2] * sx + e0[6] * sy + e0[10] * sz\n }\n v[1] -= this.o.gravity * h\n if (b.hinge) this.holdOnHinge(b, b.hinge, q)\n // what holds it up through their overlap pushes back what gravity drives into it, as a corner's support does\n if (propped) {\n const into = v[0] * propped[0] + v[1] * propped[1] + v[2] * propped[2]\n if (into < 0) for (let k = 0; k < 3; k++) v[k] -= into * propped[k]\n }\n pos[0] += v[0] * h\n pos[1] += v[1] * h\n pos[2] += v[2] * h\n const wl = Math.hypot(w[0], w[1], w[2])\n if (wl > 1e-6) {\n this.dq.setFromAxisAngle(this.ax.set(w[0] / wl, w[1] / wl, w[2] / wl), wl * h)\n q.premultiply(this.dq).normalize()\n }\n if (b.hinge) this.keepOnHinge(b.hinge, pos, q)\n // the air slows a box's spin a little; a round piece keeps rolling, held back only by its rolling resistance on the ground\n const damp = b.round ? 1 : Math.exp(-0.15 * h)\n w[0] *= damp\n w[1] *= damp\n w[2] *= damp\n\n this.m.makeRotationFromQuaternion(q)\n const e = this.m.elements\n const rs: Vec3[] = []\n const ids: number[] = []\n // per contact: the normal of the surface under it and the friction of the two surfaces\n const ns: Vec3[] = []\n const mus: PieceFriction[] = []\n let maxPen = 0\n // the normal of the surface under the deepest point: the piece is pushed out along it (straight up on the floor, across a tilted top)\n let penNormal: Vec3 = UP\n const rise = STEP + Math.max(0, -v[1]) * h * 2\n // the side of a step of the ground: how far back the piece goes (metres along -dir) and the point that hit it\n let side: { back: number; dir: [number, number]; r: Vec3 } | null = null\n let lowest = Infinity\n for (let i = 0; i < local.length; i++) {\n const [sx, sy, sz] = local[i]\n const r: Vec3 = [e[0] * sx + e[4] * sy + e[8] * sz, e[1] * sx + e[5] * sy + e[9] * sz, e[2] * sx + e[6] * sy + e[10] * sz]\n const px = pos[0] + r[0]\n const pz = pos[2] + r[2]\n const cy = pos[1] + r[1]\n // the ground's own step (a table, a counter) that the point was more than a step below before this substep: it came at its side or is\n // under it, and does not stand on it (nor ratchets up onto it as the rest of the piece is lifted)\n const was = prev[i]\n const raw = this.o.groundAt(px, pz)\n if (raw > cy - SLOP && was[1] < raw - STEP) {\n // under a top it was already beneath (put under an overhang), or coming at its side: either way that top does not hold it\n if (this.o.groundAt(was[0], was[2]) >= raw - STEP) {\n // beneath it, the point stands on the floor the piece last stood on (the height field cannot see under a top)\n const floor = b.floor\n if (floor !== undefined && floor - cy > -SLOP && floor < raw - STEP) {\n rs.push(r)\n ids.push(i)\n ns.push(UP)\n mus.push(pairFriction(b.friction, b.round ? this.terrainSurface(px, floor, pz, floor) : null))\n maxPen = Math.max(maxPen, floor - cy)\n }\n continue\n }\n const dx = px - was[0]\n const dz = pz - was[2]\n const len = Math.hypot(dx, dz)\n if (len > 1e-6) {\n // where along its move the point met the side: the first place the ground is up at this top\n let lo = 0\n let hi = 1\n for (let it = 0; it < 6; it++) {\n const mid = (lo + hi) / 2\n if (this.o.groundAt(was[0] + dx * mid, was[2] + dz * mid) >= raw - STEP) hi = mid\n else lo = mid\n }\n const back = (1 - lo) * len + 0.001\n if (!side || back > side.back) side = { back, dir: [dx / len, dz / len], r }\n }\n continue\n }\n // the points along the edges are there for the step of the ground; on other pieces only the corners stand, as everywhere else\n this.supportNormal = UP\n this.supportFriction = null\n const gy = i < 8 || b.contacts ? this.supportAt(b, px, cy, pz, rise) : Math.max(raw, this.o.staticTopAt?.(px, pz, cy, rise) ?? -Infinity)\n const pen = gy - cy\n if (pen > -SLOP) {\n rs.push(r)\n ids.push(i)\n ns.push(this.supportNormal)\n mus.push(pairFriction(b.friction, this.supportFriction ?? (b.round ? this.terrainSurface(px, gy, pz, raw) : null)))\n if (pen > maxPen) {\n maxPen = pen\n penNormal = this.supportNormal\n }\n lowest = Math.min(lowest, gy)\n }\n }\n if (lowest < Infinity) b.floor = lowest\n if (b.round && ns.length > 0) {\n const sum: Vec3 = [0, 0, 0]\n for (const one of ns) for (let k = 0; k < 3; k++) sum[k] += one[k]\n const len = Math.hypot(sum[0], sum[1], sum[2])\n b.surfaceNormal = len > 1e-6 ? [sum[0] / len, sum[1] / len, sum[2] / len] : UP\n } else if (b.round && rs.length === 0) b.surfaceNormal = UP\n if (side) {\n // the side of the step stops the piece: back out of it, and the point loses the speed it had into the side\n pos[0] -= side.dir[0] * side.back\n pos[2] -= side.dir[1] * side.back\n this.contactImpulse(b, e, side.r, [-side.dir[0], 0, -side.dir[1]], SIDE_BOUNCE)\n }\n contactedLast = rs.length > 0\n if (contactedLast) touched = true\n if (!contactedLast) continue\n // a point `maxPen` under a surface of normal n is `maxPen * n.y` inside it, along n\n const out = Math.max(0, maxPen - SLOP * 0.5) * penNormal[1]\n pos[0] += penNormal[0] * out\n pos[1] += penNormal[1] * out\n pos[2] += penNormal[2] * out\n let impact = 0\n for (const r of rs) impact = Math.max(impact, -(v[1] + w[2] * r[0] - w[0] * r[2]))\n const restitution = impact > 2 ? 0.25 : 0\n if (impact > landing) {\n landing = impact\n let sx = 0\n let sz = 0\n for (const r of rs) {\n sx += r[0]\n sz += r[2]\n }\n const lx = pos[0] + sx / rs.length\n const lz = pos[2] + sz / rs.length\n landPoint = [lx, pos[1] - Math.max(...rs.map((r) => -r[1])), lz]\n }\n // Contact impulses, solved together: each point keeps the impulse it has given so far (pushing only, never pulling) and the friction it has\n // given (within the paper's grip times that push), and every pass corrects them. Points spread unevenly under the box (a table's edge under\n // half of it) then share the weight as they should, instead of the first ones handled kicking the box into a spin.\n // the velocity of a point of the piece: v + w x r\n const pointV = (r: Vec3): Vec3 => [v[0] + w[1] * r[2] - w[2] * r[1], v[1] + w[2] * r[0] - w[0] * r[2], v[2] + w[0] * r[1] - w[1] * r[0]]\n const dot = (a: Vec3, c: Vec3): number => a[0] * c[0] + a[1] * c[1] + a[2] * c[2]\n const goal = rs.map((r, k) => {\n const vn = dot(pointV(r), ns[k])\n return vn < 0 ? -restitution * vn : 0\n })\n // a point that slides drags with the dynamic friction, one that holds with the static one (Coulomb)\n const slipping = rs.map((r, k) => {\n // as it moved before this substep's gravity: a thing at rest on a slope is held by the static grip, not let go by the pull it is to resist\n const pv = pointV(r)\n pv[1] += this.o.gravity * h\n const vn = dot(pv, ns[k])\n return Math.hypot(pv[0] - vn * ns[k][0], pv[1] - vn * ns[k][1], pv[2] - vn * ns[k][2]) > SLIP_SPEED\n })\n // the step moved the piece at the speed it had before the contacts: what they took from it along the ground is taken from the move too, so\n // a push the floor's grip holds does not creep the piece along\n const vx0 = v[0]\n const vz0 = v[2]\n // warm start: each point starts from what it gave in the last substep (a resting box carries its weight from the first pass)\n if (!b.warm || b.warm.length !== WARM_SLOTS * 4) b.warm = new Float64Array(WARM_SLOTS * 4)\n const warm = b.warm\n const accN = ids.map((id) => (id < WARM_SLOTS ? warm[id * 4] : 0))\n const accT = ids.map((id): Vec3 => (id < WARM_SLOTS ? [warm[id * 4 + 1], warm[id * 4 + 2], warm[id * 4 + 3]] : [0, 0, 0]))\n /** Gives the piece the impulse `j` (world) at `r`. */\n const push = (r: Vec3, j: Vec3): void => {\n v[0] += j[0] * invM\n v[1] += j[1] * invM\n v[2] += j[2] * invM\n const dw = this.mulInvInertiaWith(b, e, r[1] * j[2] - r[2] * j[1], r[2] * j[0] - r[0] * j[2], r[0] * j[1] - r[1] * j[0])\n w[0] += dw[0]\n w[1] += dw[1]\n w[2] += dw[2]\n }\n /** The mass the piece shows to an impulse along the unit `d` at `r`: 1 / (1/m + (I^-1 (r x d) x r) . d). */\n const reach = (r: Vec3, d: Vec3): number => {\n const a = this.mulInvInertiaWith(b, e, r[1] * d[2] - r[2] * d[1], r[2] * d[0] - r[0] * d[2], r[0] * d[1] - r[1] * d[0])\n return invM + (a[1] * r[2] - a[2] * r[1]) * d[0] + (a[2] * r[0] - a[0] * r[2]) * d[1] + (a[0] * r[1] - a[1] * r[0]) * d[2]\n }\n for (let k = 0; k < rs.length; k++) {\n const n = ns[k]\n const t = accT[k]\n if (accN[k] !== 0 || t[0] !== 0 || t[1] !== 0 || t[2] !== 0) push(rs[k], [n[0] * accN[k] + t[0], n[1] * accN[k] + t[1], n[2] * accN[k] + t[2]])\n }\n for (let it = 0; it < SOLVER_PASSES; it++) {\n for (let k = 0; k < rs.length; k++) {\n const r = rs[k]\n const n = ns[k]\n // the push along the normal of the surface (a tilted top pushes across it, not straight up)\n const vn = dot(pointV(r), n)\n const total = Math.max(0, accN[k] + (goal[k] - vn) / reach(r, n))\n const j = total - accN[k]\n accN[k] = total\n if (j !== 0) push(r, [n[0] * j, n[1] * j, n[2] * j])\n // friction in the plane of the surface, up to the static or dynamic coefficient times the push the point gives\n const pv = pointV(r)\n const pn = dot(pv, n)\n const vt: Vec3 = [pv[0] - pn * n[0], pv[1] - pn * n[1], pv[2] - pn * n[2]]\n const speed = Math.hypot(vt[0], vt[1], vt[2])\n const f: Vec3 = [accT[k][0], accT[k][1], accT[k][2]]\n if (speed > 1e-6) {\n const d: Vec3 = [vt[0] / speed, vt[1] / speed, vt[2] / speed]\n const jt = speed / reach(r, d)\n f[0] -= d[0] * jt\n f[1] -= d[1] * jt\n f[2] -= d[2] * jt\n } else if (f[0] === 0 && f[1] === 0 && f[2] === 0) continue\n const most = (slipping[k] ? mus[k].dynamic : mus[k].static) * accN[k]\n const fl = Math.hypot(f[0], f[1], f[2])\n if (fl > most) {\n f[0] *= most / fl\n f[1] *= most / fl\n f[2] *= most / fl\n }\n const dj: Vec3 = [f[0] - accT[k][0], f[1] - accT[k][1], f[2] - accT[k][2]]\n accT[k] = f\n if (dj[0] !== 0 || dj[1] !== 0 || dj[2] !== 0) push(r, dj)\n }\n }\n pos[0] += (v[0] - vx0) * h\n pos[2] += (v[2] - vz0) * h\n warm.fill(0)\n for (let k = 0; k < rs.length; k++) {\n const id = ids[k]\n if (id >= WARM_SLOTS) continue\n warm[id * 4] = accN[k]\n warm[id * 4 + 1] = accT[k][0]\n warm[id * 4 + 2] = accT[k][1]\n warm[id * 4 + 3] = accT[k][2]\n }\n // Support check. The corner contacts above are relative to the centre of mass, so they already give a torque when the centre of mass is\n // outside the support. What they cannot do is end a balancing act: a tall thin piece on its edge (or a single corner) is in equilibrium\n // with the centre of mass above a very small support, so it must not rest there. It gets a gentle topple push toward the side it leans\n // to (or toward the wider side when it leans nowhere), and it may not sleep.\n let x0 = Infinity, x1 = -Infinity, z0 = Infinity, z1 = -Infinity, low = 0\n for (const r of rs) {\n x0 = Math.min(x0, r[0]); x1 = Math.max(x1, r[0])\n z0 = Math.min(z0, r[2]); z1 = Math.max(z1, r[2])\n low = Math.min(low, r[1])\n }\n // held up through its overlap with a piece (`propped`), that point is a point of its support too\n if (proppedAt) {\n x0 = Math.min(x0, proppedAt[0]); x1 = Math.max(x1, proppedAt[0])\n z0 = Math.min(z0, proppedAt[2]); z1 = Math.max(z1, proppedAt[2])\n }\n const height = -low\n const wx = x1 - x0\n const wz = z1 - z0\n // a round piece lying on its side rests on a line: that is its rest, not a balancing act (it rolls if the ground slopes)\n unstable = !b.round && (Math.min(wx, wz) < NARROW * height || x0 > 0 || x1 < 0 || z0 > 0 || z1 < 0)\n if (b.tipping) {\n b.tipping.seconds -= h\n // lying is measured on the box as it is turned: a top corner held from above (a board it was joined to) says nothing of how it stands\n const [hx, hy, hz] = b.halfExtents\n const upHalf = Math.abs(e[1]) * hx + Math.abs(e[5]) * hy + Math.abs(e[9]) * hz\n if (upHalf < TIP_LYING || b.tipping.seconds <= 0) b.tipping = null\n else {\n w[0] += b.tipping.x * TIP_ACCELERATION * h\n w[2] += b.tipping.z * TIP_ACCELERATION * h\n unstable = true\n }\n }\n if (unstable) {\n // the support centre relative to the centre of mass: the piece falls away from it (toward +axis when it is centred)\n const dirX = x0 + x1 > 0 ? -1 : 1\n const dirZ = z0 + z1 > 0 ? -1 : 1\n const k = TOPPLE * Math.min(height, 1) * h\n // rotating about -z moves the top toward +x; rotating about +x moves it toward +z\n if (wx <= wz) w[2] -= dirX * k\n else w[0] += dirZ * k\n }\n // rolling / spinning resistance while touching the ground: a box loses its spin; a round piece rolls on, held back by its rolling resistance\n // (a deceleration of C_RR g / r about the axis it rolls on) and a little spin about the others\n if (b.round) {\n let rolling = 0\n let damping = 0\n for (const mu of mus) {\n rolling = Math.max(rolling, mu.rolling ?? ROLLING_RESISTANCE)\n damping = Math.max(damping, mu.rollingDamping ?? 0)\n }\n this.rollingResistance(b, q, w, h, { rolling, damping })\n } else {\n const rd = Math.exp((rs.length >= 3 ? -3 : -1.5) * h)\n w[0] *= rd\n w[1] *= rd\n w[2] *= rd\n const fd = Math.exp(-0.3 * h)\n v[0] *= fd\n v[2] *= fd\n }\n }\n\n if (b.hinge) this.wearHinge(b, b.hinge, q, dt)\n // what stands in the way (a wall, a car): the piece stops against it, bounces a little and both take the blow\n if (this.o.sweep && !b.held) this.sweepOn(b, start, pos)\n\n // write back\n b.root.quaternion.copy(q)\n const off = this.ax.copy(b.centerV).applyQuaternion(q)\n b.root.position.set(pos[0] - off.x, pos[1] - off.y, pos[2] - off.z)\n b.root.updateMatrixWorld(true)\n b.onGround = contactedLast\n\n if (landing > HARD_LANDING && this.time - b.lastHit > 0.15) {\n b.lastHit = this.time\n this.o.onHardLanding(b, landPoint, landing)\n }\n\n const still = touched && !unstable && Math.hypot(v[0], v[1], v[2]) < STILL_SPEED && Math.hypot(w[0], w[1], w[2]) < STILL_SPIN\n if (still) b.still += dt\n else b.still = 0\n b.balancing = unstable\n this.keepsTilt(b, q, dt)\n // held up through its overlap with what is under it (`propped`) it touches too: it may sleep where it stays, as a piece on its corners does\n const held = (touched || propped !== undefined) && !b.tipping\n if (!b.hinge && (b.still >= SLEEP_AFTER || this.staysInPlace(b, held, pos, q, dt))) this.sleep(b)\n }\n\n /** The piece sleeps where it lies: its speeds are dropped, nothing moves it. */\n private sleep(b: PieceBody): void {\n b.restPoints = undefined\n b.sleeping = true\n b.calmAt = null\n b.steady = null\n b.velocity[0] = b.velocity[1] = b.velocity[2] = 0\n b.angularVelocity[0] = b.angularVelocity[1] = b.angularVelocity[2] = 0\n }\n\n /** How long the piece has kept its tilt (within `STEADY_TURN`): one going over leaves it within a moment, one held up at an angle keeps it. */\n private keepsTilt(b: PieceBody, q: THREE_NS.Quaternion, dt: number): void {\n const at = b.steady\n if (at && turnBetween(at.quaternion, q) <= STEADY_TURN) {\n at.seconds += dt\n return\n }\n b.steady = { quaternion: [q.x, q.y, q.z, q.w], seconds: 0 }\n }\n\n /**\n * Over `maxAwake` pieces awake, the oldest that have come to rest sleep where they lie: on the ground, slower than `STILL_SPEED` and `STILL_SPIN`, not falling over (`tip`),\n * and one held up at an angle (a board leaning on a seat) only once it kept its tilt for `STEADY_SECONDS`; that one sleeps then under the budget too, since nothing else puts\n * it to sleep. It keeps the points it lies on (`restPoints`) and wakes when any of them loses its support (`wakeUnsupported`): put to sleep sooner than it would have slept by\n * itself, it answers to every point that holds it.\n */\n private keepBudget(): void {\n const most = this.o.maxAwake\n if (most === undefined || !Number.isFinite(most)) return\n let awake = 0\n for (const b of this.list) {\n if (b.sleeping || b.held) continue\n // one held up at an angle never sleeps by itself (`still`), though it has come to rest: with a budget it does, whatever the count\n if (b.balancing && this.hasComeToRest(b)) this.sleepByBudget(b)\n else awake++\n }\n for (const b of this.list) {\n if (awake <= most) return\n if (b.sleeping || b.held || !this.hasComeToRest(b)) continue\n this.sleepByBudget(b)\n awake--\n }\n }\n\n /**\n * The far and old rule (`PieceSystemOptions.keep`), looked at twice a second: a piece at rest, old and far, sleeps or fades; over `maxLive` pieces the far and old ones at rest\n * fade first, then the oldest at rest. Only what has come to rest goes, so nothing is taken from under a falling thing.\n */\n private keepFar(): void {\n const keep = this.o.keep\n if (!keep || this.time - this.keptAt < KEEP_EVERY) return\n this.keptAt = this.time\n const focus = keep.focus?.()\n const isFarAndOld = (b: PieceBody): boolean => {\n if (!focus || this.time - (this.bornAt.get(b) ?? this.time) < keep.far.age) return false\n const c = this.centerOf(b, this.p)\n return Math.hypot(c.x - focus[0], c.y - focus[1], c.z - focus[2]) > keep.far.distance\n }\n const atRest = this.list.filter((b) => !b.held && this.hasComeToRest(b))\n if (keep.far.action === 'sleep') {\n for (const b of atRest) if (!b.sleeping && isFarAndOld(b)) this.sleepByBudget(b)\n }\n const fades = keep.far.action === 'fade'\n let over = this.list.length - keep.maxLive\n const far = new Set(atRest.filter(isFarAndOld))\n // far and old first, the oldest next (the list is in the order the pieces were made)\n for (const b of [...atRest].sort((a, c) => Number(far.has(c)) - Number(far.has(a)))) {\n if (!(over > 0 || (fades && far.has(b)))) return\n keep.onFade(b)\n over--\n }\n }\n\n /**\n * A piece made where its parts already stood (a group loose at load) sleeps there when a point of it has the ground, a piece or a fixed top under it, and answers to those\n * points (`restPoints`) as one the budget put to sleep: it wakes and falls when any of them loses its support. With none it stays awake and falls: nothing loose hangs in\n * the air. Returns whether it sleeps.\n */\n restIfSupported(b: PieceBody): boolean {\n const points = this.restPointsOf(b)\n // balanced on the parts as drawn (a top on one leg stands on the leg, not on the corners of the box around both)\n if (points.length === 0 || !this.balancedOn(b, this.partCornersOf(b).filter((point) => this.supportsPoint(b, point)))) return false\n this.sleep(b)\n b.restPoints = points\n return true\n }\n\n /** The corners of the boxes of its parts (`partBoxes`, about its centre of mass), or the samples of its box when it has none. */\n private partCornersOf(b: PieceBody): Vec3[] {\n if (!b.partBoxes) return this.samples(b, false)\n const out: Vec3[] = []\n for (const box of b.partBoxes) {\n const [x, y, z, w] = box.rotation ?? [0, 0, 0, 1]\n for (let i = 0; i < 8; i++) {\n const hx = i & 1 ? box.half[0] : -box.half[0]\n const hy = i & 2 ? box.half[1] : -box.half[1]\n const hz = i & 4 ? box.half[2] : -box.half[2]\n // q * h * q^-1\n const tx = 2 * (y * hz - z * hy)\n const ty = 2 * (z * hx - x * hz)\n const tz = 2 * (x * hy - y * hx)\n out.push([box.center[0] + hx + w * tx + y * tz - z * ty, box.center[1] + hy + w * ty + z * tx - x * tz, box.center[2] + hz + w * tz + x * ty - y * tx])\n }\n }\n return out\n }\n\n /** Whether the centre of mass of `b` is over the hull of the points of it (its own frame) that rest on something: off it, the piece tips. */\n private balancedOn(b: PieceBody, points: readonly Vec3[]): boolean {\n // the points are about the centre of mass, as `supportsPoint` reads them\n const c = this.centerOf(b, this.p)\n const e = this.m.makeRotationFromQuaternion(b.root.quaternion).elements\n const plan = points.map(([sx, sy, sz]): PlanPoint => [c.x + e[0]! * sx + e[4]! * sy + e[8]! * sz, c.z + e[2]! * sx + e[6]! * sy + e[10]! * sz])\n return isOverSupport(plan, [c.x, c.z], BALANCE_TOLERANCE)\n }\n\n /** Sleeps sooner than it would by itself, so it answers to every point it lies on (`restPoints`). */\n private sleepByBudget(b: PieceBody): void {\n this.sleep(b)\n b.restPoints = this.restPointsOf(b)\n }\n\n private hasComeToRest(b: PieceBody): boolean {\n const v = b.velocity\n const w = b.angularVelocity\n if (!b.onGround || b.tipping || Math.hypot(v[0], v[1], v[2]) >= STILL_SPEED || Math.hypot(w[0], w[1], w[2]) >= STILL_SPIN) return false\n return !b.balancing || (b.steady?.seconds ?? 0) >= STEADY_SECONDS\n }\n\n /** The corners of `b` (its own frame, or its own `contacts`) that have the ground, a piece or a fixed top within `SUPPORT_GAP` under them now; the points along its edges when no corner has. */\n private restPointsOf(b: PieceBody): Vec3[] {\n const corners = this.samples(b, false).filter((point) => this.supportsPoint(b, point))\n return corners.length > 0 ? corners : this.samples(b, true).filter((point) => this.supportsPoint(b, point))\n }\n\n /** Whether the point of `b` (its own frame) has the ground, a piece or a fixed top within `SUPPORT_GAP` under it. */\n private supportsPoint(b: PieceBody, [sx, sy, sz]: Vec3): boolean {\n const c = this.centerOf(b, this.p)\n const e = this.m.makeRotationFromQuaternion(b.root.quaternion).elements\n const y = c.y + e[1] * sx + e[5] * sy + e[9] * sz\n return this.supportAt(b, c.x + e[0] * sx + e[4] * sy + e[8] * sz, y, c.z + e[2] * sx + e[6] * sy + e[10] * sz, STEP) >= y - SUPPORT_GAP\n }\n\n /** Whether the piece has kept to the same spot on the ground for `CALM_SLEEP_AFTER` (see `CALM_DRIFT`). */\n private staysInPlace(b: PieceBody, touched: boolean, center: Vec3, q: THREE_NS.Quaternion, dt: number): boolean {\n const at = b.calmAt\n const turned = at ? turnBetween(at.quaternion, q) : Infinity\n if (!touched || !at || Math.hypot(center[0] - at.center[0], center[1] - at.center[1], center[2] - at.center[2]) > CALM_DRIFT || turned > CALM_TURN) {\n b.calmAt = touched ? { center: [center[0], center[1], center[2]], quaternion: [q.x, q.y, q.z, q.w] } : null\n b.calm = 0\n return false\n }\n b.calm += dt\n return b.calm >= CALM_SLEEP_AFTER\n }\n\n /** Whether the centre `c` of `upper` is over the top of `lower`'s box (as it was at the start of the update). */\n private onTopOf(upper: PieceBody, lower: PieceBody, c: THREE_NS.Vector3): boolean {\n const s = this.solidOf.get(lower)\n if (!s) return false\n const top = boxTopAt(s, c.x, c.z)\n return top > -Infinity && c.y >= top - 0.01\n }\n\n /**\n * The points a round piece touches the ground by as it is turned now (`q`): its rims (`contacts`), which hold it standing on an end, and the exact lowest point of each\n * rim (of the ball), so lying on its side it rests on a line and rolls smoothly instead of over the corners of a polygon.\n */\n private roundSamples(b: PieceBody, q: THREE_NS.Quaternion): Vec3[] {\n const round = b.round\n const rims = b.contacts ?? []\n if (!round) return rims\n const e = this.m.makeRotationFromQuaternion(q).elements\n // into the surface it last lay on (the world's down on the floor), in the piece's frame: on a slope it touches below its centre across the slope, not straight down\n const n = b.surfaceNormal ?? UP\n const down: Vec3 = [-(e[0] * n[0] + e[1] * n[1] + e[2] * n[2]), -(e[4] * n[0] + e[5] * n[1] + e[6] * n[2]), -(e[8] * n[0] + e[9] * n[1] + e[10] * n[2])]\n if (round.kind === 'sphere') return [...rims, [down[0] * round.radius, down[1] * round.radius, down[2] * round.radius]]\n const k = round.axis\n const across: Vec3 = [down[0], down[1], down[2]]\n across[k] = 0\n const len = Math.hypot(across[0], across[1], across[2])\n // standing on an end: the rim holds it\n if (len < 1e-3) return rims\n const lowest = (at: number, radius: number): Vec3 => {\n const p: Vec3 = [(across[0] / len) * radius, (across[1] / len) * radius, (across[2] / len) * radius]\n p[k] = at\n return p\n }\n const half = b.halfExtents[k]\n // the lowest point of each ring along it: a straight can touches by both ends, a tapered bottle by its wide end and its narrow one, a bottle's neck not at all\n const low = (round.profile ?? [[-half, round.radius], [half, round.radius]]).map(([at, radius]) => lowest(at, radius))\n // lying (its axis nearer level than upright) it touches by those lowest points only: the points of the rims beside them move as it rolls and would brake it\n return len > ROUND_LYING ? low : [...rims, ...low]\n }\n\n /**\n * Slows the spin of a round piece on the ground by its rolling resistance: a torque C_rr N r about the axis it rolls on (N = m g n_y on a surface of normal n), so with\n * I = k m r^2 the spin loses C_rr g n_y / (k r) per second, and down a slope of angle t it rolls at g (sin t - C_rr cos t) / (1 + k). Standing on its rim, a can's spin\n * about the rest dies down; lying, it keeps turning about the line it touches by (a tapered bottle rounds its narrow end). Its rolling damping (`PieceFriction.rollingDamping`,\n * the pair's) then takes exp(-d h) of what is left, as the grass or the sand drag more the faster it rolls.\n */\n private rollingResistance(b: PieceBody, q: THREE_NS.Quaternion, w: Vec3, h: number, { rolling, damping }: { readonly rolling: number; readonly damping: number }): void {\n const round = b.round\n if (!round) return\n const e = this.m.makeRotationFromQuaternion(q).elements\n const cylinder = round.kind === 'cylinder'\n const a: Vec3 = cylinder ? [e[round.axis * 4], e[round.axis * 4 + 1], e[round.axis * 4 + 2]] : [0, 0, 0]\n const along = cylinder ? w[0] * a[0] + w[1] * a[1] + w[2] * a[2] : 0\n const roll: Vec3 = cylinder ? [a[0] * along, a[1] * along, a[2] * along] : [w[0], w[1], w[2]]\n const rest: Vec3 = [w[0] - roll[0], w[1] - roll[1], w[2] - roll[2]]\n const spin = Math.hypot(roll[0], roll[1], roll[2])\n const upright = b.surfaceNormal?.[1] ?? 1\n const slow = spin > 0 ? (Math.max(0, spin - (rolling * this.o.gravity * upright * h) / (round.inertia * round.radius)) / spin) * Math.exp(-damping * h) : 0\n const lying = cylinder && Math.abs(a[1]) < ROUND_LYING\n const damp = lying ? 1 : Math.exp(-3 * h)\n for (let i = 0; i < 3; i++) w[i] = roll[i] * slow + rest[i] * damp\n }\n\n /** Half the height of the box of a piece as it is turned now. */\n private halfHeight(b: PieceBody): number {\n const e = this.m.makeRotationFromQuaternion(b.root.quaternion).elements\n return Math.abs(e[1]) * b.halfExtents[0] + Math.abs(e[5]) * b.halfExtents[1] + Math.abs(e[9]) * b.halfExtents[2]\n }\n\n /**\n * Pieces against each other. Candidates by sweep and prune along x on their bounding spheres (sorted once per step: fifty cans cost a sort and a handful of pairs, not\n * 1225); a pair with a round piece in it meets by its shapes (`shapeContact`) and exchanges an impulse, two boxes are put apart by their separating axes (`separatePair`).\n */\n private collide(dt: number, meets?: StepFilter['meets']): void {\n const n = this.list.length\n if (n < 2) return\n const centers = this.list.map((b) => {\n const c = this.centerOf(b, this.p)\n return [c.x, c.y, c.z] as Vec3\n })\n const radii = this.list.map((b) => Math.hypot(b.halfExtents[0], b.halfExtents[1], b.halfExtents[2]))\n const order = this.list.map((_, i) => i).sort((i, j) => centers[i][0] - radii[i] - (centers[j][0] - radii[j]))\n for (let oi = 0; oi < n; oi++) {\n const i = order[oi]\n const reach = centers[i][0] + radii[i]\n for (let oj = oi + 1; oj < n; oj++) {\n const j = order[oj]\n if (centers[j][0] - radii[j] > reach) break\n const a = this.list[i]\n const b = this.list[j]\n if ((a.held || a.sleeping) && (b.held || b.sleeping)) continue\n if (meets && !meets(a, b)) continue\n const r = radii[i] + radii[j]\n const ca = centers[i]\n const cb = centers[j]\n if (Math.abs(ca[1] - cb[1]) > r || Math.abs(ca[2] - cb[2]) > r) continue\n // one lies on the other (a book on a shelf): the corners hold them apart, a sideways push would slide it off\n // (a round piece meets the other by their shapes, which tell lying on from beside: a can by a tall wardrobe whose middle is far above it still hits it)\n const stacked = !a.round && !b.round && Math.abs(ca[1] - cb[1]) >= (this.halfHeight(a) + this.halfHeight(b)) * 0.9\n // or on a tilted top (a table going over): the one above is over the other's top, whatever their boxes' heights\n const onTop = this.onTopOf(b, a, new this.THREE.Vector3(...cb)) || this.onTopOf(a, b, new this.THREE.Vector3(...ca))\n if (a.round || b.round) {\n if (!stacked && !onTop) this.knock(a, b, ca, cb)\n continue\n }\n // two boxes when a part of one is in a part of the other (a book lying in the hollow of a case on its back is inside its box, not in its boards); lying on each\n // other, or one leaning on the other's part (a board on a bench's seat), the support holds them while they only touch: beside each other or deeper, they go apart\n if (!this.partsOverlap(a, b)) continue\n this.boxImpact(a, b, ca, cb, dt)\n this.separatePair(a, b, ca, cb, dt, stacked || onTop || this.restsOn(a, b, false) || this.restsOn(b, a, false))\n }\n }\n this.applyPushes(dt)\n }\n\n /**\n * Moves each piece by what its pairs put it apart this step (`pushes`), at most `SEPARATE_SPEED` along the ground and as much up: a chunk in five others is not pushed five\n * times as fast, and nothing is ever moved down (into what holds it). A piece still being put apart is moving, though its speed is nil: it does not fall asleep in the other.\n */\n private applyPushes(dt: number, steps: Map<PieceBody, PushStep> = this.collideSteps): void {\n const most = SEPARATE_SPEED * dt\n // what has not been pushed for a while starts again from the whole push\n for (const [body, step] of steps) if (this.time - step.at > PUSH_MEMORY_SECONDS) steps.delete(body)\n for (const [body, push] of this.pushes) {\n const share = this.pushShare(steps, body, push)\n const level = Math.hypot(push[0], push[2])\n const k = (level > most ? most / level : 1) * share\n const up = Math.min(most, Math.max(0, push[1])) * share\n body.root.position.x += push[0] * k\n body.root.position.y += up\n body.root.position.z += push[2] * k\n if (Math.max(level * k, up) > SLOP) body.still = 0\n }\n this.pushes.clear()\n }\n\n /** The share of its push a piece is given: `TURN_BACK_SHARE` of it each step it turns back against the last one, `SAME_WAY_GROWTH` more (up to all) each step it goes on the same way. */\n private pushShare(steps: Map<PieceBody, PushStep>, body: PieceBody, push: Vec3): number {\n const last = steps.get(body)\n if (!last) {\n steps.set(body, { push: [push[0], push[1], push[2]], share: 1, at: this.time })\n return 1\n }\n const turnsBack = push[0] * last.push[0] + push[1] * last.push[1] + push[2] * last.push[2] < 0\n last.share = turnsBack ? Math.max(MIN_PUSH_SHARE, last.share * TURN_BACK_SHARE) : Math.min(1, last.share * SAME_WAY_GROWTH)\n last.at = this.time\n last.push[0] = push[0]\n last.push[1] = push[1]\n last.push[2] = push[2]\n return last.share\n }\n\n /** The shape a piece meets others by (`ContactShape`), as it stands now: a round one a capsule round its axis, any other the boxes of its parts or its box. */\n private contactShape(b: PieceBody, c: Vec3): ContactShape {\n const e = [...this.m.makeRotationFromQuaternion(b.root.quaternion).elements]\n const round = b.round\n if (round) {\n if (round.kind === 'sphere') return { kind: 'capsule', from: c, to: c, radius: round.radius }\n // the segment stops a radius short of each end, so end on it is as long as the piece\n const reach = Math.max(0, b.halfExtents[round.axis] - round.radius)\n const k = round.axis * 4\n const d: Vec3 = [e[k] * reach, e[k + 1] * reach, e[k + 2] * reach]\n return { kind: 'capsule', from: [c[0] - d[0], c[1] - d[1], c[2] - d[2]], to: [c[0] + d[0], c[1] + d[1], c[2] + d[2]], radius: round.radius }\n }\n const parts = b.partBoxes ?? [{ center: [0, 0, 0] as Vec3, half: b.halfExtents }]\n return {\n kind: 'boxes',\n boxes: parts.map(squareBoxOf).map(({ center, half }) => ({\n c: [c[0] + e[0] * center[0] + e[4] * center[1] + e[8] * center[2], c[1] + e[1] * center[0] + e[5] * center[1] + e[9] * center[2], c[2] + e[2] * center[0] + e[6] * center[1] + e[10] * center[2]] as Vec3,\n e,\n half,\n })),\n }\n }\n\n /**\n * Two pieces that met, one of them round: they are put apart along the normal (by their inverse masses) and, closing in, exchange an impulse\n * j = -(1 + e) v_n / (1/m_a + 1/m_b + the turning of each), with the restitution e of their two materials, and the friction of their surfaces across it. The impulses are\n * equal and opposite, so the momentum of the pair is kept. A held piece is not moved (the hand holds it); a sleeping one wakes when it is knocked.\n */\n private knock(a: PieceBody, b: PieceBody, ca: Vec3, cb: Vec3): void {\n const hit = shapeContact(this.contactShape(a, ca), this.contactShape(b, cb))\n if (!hit) return\n // one on the other (a can rolling down a board, off its end): the support of the pieces holds it, as it does on the floor\n if (Math.abs(hit.normal[1]) > SLAM_FLOOR_NORMAL) return\n this.impact({ a, b, ca, cb, hit, apart: true, above: 0 })\n }\n\n /**\n * Two boxes that hit each other (a book falling on the top edge of one standing, a board swinging into a row): they exchange the impulse of `knock` at the point they meet,\n * so the one hit turns about that point as well as moving, and a sleeping one wakes. Only a hit faster than `BOX_IMPACT_SPEED`, and no deeper than a contact: pieces resting on each other, or\n * made inside each other, are left to `separatePair`, which holds or slides them without a kick.\n */\n private boxImpact(a: PieceBody, b: PieceBody, ca: Vec3, cb: Vec3, dt: number): void {\n const hit = shapeContact(this.contactShape(a, ca), this.contactShape(b, cb))\n if (!hit) return\n // deeper than this step's closing could sink them, they were made inside each other (chunks of one wall): `separatePair` slides them apart, no blow\n const n = hit.normal\n const va = a.velocity\n const vb = b.velocity\n const closing = (va[0] - vb[0]) * n[0] + (va[1] - vb[1]) * n[1] + (va[2] - vb[2]) * n[2]\n if (hit.depth > LIFT_DEPTH + 2 * Math.max(0, -closing) * dt) return\n this.impact({ a, b, ca, cb, hit, apart: false, above: BOX_IMPACT_SPEED })\n }\n\n /** The impulse two pieces that met exchange (`knock`), put apart first when `apart`, and only when they close faster than `above` (m/s). */\n private impact({ a, b, ca, cb, hit, apart, above }: ImpactParams): void {\n const n = hit.normal\n const ra: Vec3 = [hit.point[0] - ca[0], hit.point[1] - ca[1], hit.point[2] - ca[2]]\n const rb: Vec3 = [hit.point[0] - cb[0], hit.point[1] - cb[1], hit.point[2] - cb[2]]\n const pointV = (body: PieceBody, r: Vec3): Vec3 => {\n const v = body.velocity\n const w = body.angularVelocity\n return [v[0] + w[1] * r[2] - w[2] * r[1], v[1] + w[2] * r[0] - w[0] * r[2], v[2] + w[0] * r[1] - w[1] * r[0]]\n }\n const relative = (): Vec3 => {\n const va = pointV(a, ra)\n const vb = pointV(b, rb)\n return [va[0] - vb[0], va[1] - vb[1], va[2] - vb[2]]\n }\n const vn0 = relative()\n const closing = vn0[0] * n[0] + vn0[1] * n[1] + vn0[2] * n[2]\n if (closing >= -above) return\n // a sleeping piece stays put for a touch (cans asleep side by side); knocked, it wakes\n const wake = (body: PieceBody): void => {\n body.sleeping = false\n body.still = 0\n body.calmAt = null\n }\n if (closing < -WAKE_ABOVE_SPEED) {\n if (a.sleeping) wake(a)\n if (b.sleeping) wake(b)\n }\n const ima = a.held || a.sleeping ? 0 : 1 / a.mass\n const imb = b.held || b.sleeping ? 0 : 1 / b.mass\n if (ima + imb === 0) return\n const ea = [...this.m.makeRotationFromQuaternion(a.root.quaternion).elements]\n const eb = [...this.m.makeRotationFromQuaternion(b.root.quaternion).elements]\n // apart: along the ground when they meet side by side (a can is not lifted off the floor by its neighbour), else along the normal\n const flat = Math.hypot(n[0], n[2])\n const out: Vec3 = flat > KNOCK_FLAT ? [n[0] / flat, 0, n[2] / flat] : n\n const depth = Math.max(0, hit.depth - SLOP) / (flat > KNOCK_FLAT ? flat : 1)\n for (const [body, share, sign] of [[a, ima, 1], [b, imb, -1]] as const) {\n if (share === 0 || !apart) continue\n const move = (depth * share * sign) / (ima + imb)\n body.root.position.x += out[0] * move\n body.root.position.y += out[1] * move\n body.root.position.z += out[2] * move\n }\n if (closing >= 0) return\n /** What the pair shows to an impulse along the unit `d`: 1/m_a + 1/m_b + (I_a^-1 (r_a x d) x r_a) . d + (the same for b). */\n const turning = (body: PieceBody, e: number[], r: Vec3, d: Vec3): number => {\n const t = this.mulInvInertiaWith(body, e, r[1] * d[2] - r[2] * d[1], r[2] * d[0] - r[0] * d[2], r[0] * d[1] - r[1] * d[0])\n return (t[1] * r[2] - t[2] * r[1]) * d[0] + (t[2] * r[0] - t[0] * r[2]) * d[1] + (t[0] * r[1] - t[1] * r[0]) * d[2]\n }\n const resist = (d: Vec3): number => ima + imb + (ima > 0 ? turning(a, ea, ra, d) : 0) + (imb > 0 ? turning(b, eb, rb, d) : 0)\n const give = (j: Vec3): void => {\n if (ima > 0) {\n for (let i = 0; i < 3; i++) a.velocity[i] += j[i] * ima\n const dw = this.mulInvInertiaWith(a, ea, ra[1] * j[2] - ra[2] * j[1], ra[2] * j[0] - ra[0] * j[2], ra[0] * j[1] - ra[1] * j[0])\n for (let i = 0; i < 3; i++) a.angularVelocity[i] += dw[i]\n }\n if (imb > 0) {\n for (let i = 0; i < 3; i++) b.velocity[i] -= j[i] * imb\n const dw = this.mulInvInertiaWith(b, eb, rb[1] * j[2] - rb[2] * j[1], rb[2] * j[0] - rb[0] * j[2], rb[0] * j[1] - rb[1] * j[0])\n for (let i = 0; i < 3; i++) b.angularVelocity[i] -= dw[i]\n }\n }\n // a touch slower than `BOUNCE_MIN_SPEED` only stops (two cans resting together do not chatter)\n const bounce = apart && -closing > BOUNCE_MIN_SPEED ? pairRestitution(a.restitution, b.restitution) : 0\n const j = (-(1 + bounce) * closing) / resist(n)\n give([n[0] * j, n[1] * j, n[2] * j])\n // the friction of the two surfaces across the normal, up to mu times the push (Coulomb)\n const v = relative()\n const vn = v[0] * n[0] + v[1] * n[1] + v[2] * n[2]\n const vt: Vec3 = [v[0] - vn * n[0], v[1] - vn * n[1], v[2] - vn * n[2]]\n const slide = Math.hypot(vt[0], vt[1], vt[2])\n if (slide < 1e-6) return\n const t: Vec3 = [vt[0] / slide, vt[1] / slide, vt[2] / slide]\n const jt = Math.min(slide / resist(t), pairFriction(a.friction, b.friction ?? null).dynamic * j)\n give([-t[0] * jt, -t[1] * jt, -t[2] * jt])\n if (-closing >= SLAM_MIN_SPEED && this.time - Math.max(a.lastHit, b.lastHit) > 0.15) {\n a.lastHit = b.lastHit = this.time\n this.o.onKnock?.(a, b, hit.point, -closing)\n }\n }\n\n /** Whether a part of `a` and a part of `b` (their boxes of the step, as world-aligned boxes around them) overlap. */\n private partsOverlap(a: PieceBody, b: PieceBody): boolean {\n for (const pa of this.surfacesOf.get(a) ?? []) {\n for (const pb of this.surfacesOf.get(b) ?? []) {\n let apart = false\n for (let k = 0; k < 3 && !apart; k++) apart = Math.abs(pa.c[k] - pb.c[k]) > extent(pa, k) + extent(pb, k)\n if (!apart) return true\n }\n }\n return false\n }\n\n /**\n * Two boxes overlapping, put apart by their separating axes (`shapeContact`); a held or sleeping piece is not moved. The move (`SEPARATE_SHARE` of the overlap less `SLOP`) is\n * summed into `pushes` and bounded per piece in `applyPushes`.\n * - Side by side (a normal at least `KNOCK_FLAT` level): apart along the ground only, as in `knock`, split by their inverse masses; the speed they close in with stops.\n * - One over the other as deep as a contact (`LIFT_DEPTH` and what the closing speed sank them this step): left alone when `resting` (stacked, on a top, leaning on a\n * part: its support holds it); else only the upper rises, held up by the lower (`propped`), and its point in the lower stops sinking (`contactImpulse`): never a kick up.\n * - One over the other deeper than that: they were made inside each other (chunks of one wall), or stand on one floor side by side. Lifting the upper out would give it\n * m g d nothing supplied (a 3 m chunk climbing 5 m through a pile), so they slide apart along the ground by their least level overlaps (`boxesApartAlongGround`).\n */\n private separatePair(a: PieceBody, b: PieceBody, ca: Vec3, cb: Vec3, dt: number, resting: boolean): void {\n const sa = this.contactShape(a, ca)\n const sb = this.contactShape(b, cb)\n const hit = shapeContact(sa, sb)\n if (!hit) return\n const ima = a.held || a.sleeping ? 0 : 1 / a.mass\n const imb = b.held || b.sleeping ? 0 : 1 / b.mass\n if (ima + imb === 0) return\n if (Math.hypot(hit.normal[0], hit.normal[2]) > KNOCK_FLAT) {\n this.slideApart(a, b, ima, imb, levelBoxesApart(sa, sb) ?? hit)\n return\n }\n const n = hit.normal\n const va = a.velocity\n const vb = b.velocity\n const contact = LIFT_DEPTH + Math.max(0, -((va[0] - vb[0]) * n[0] + (va[1] - vb[1]) * n[1] + (va[2] - vb[2]) * n[2])) * dt\n if (hit.depth > contact) {\n const level = boxesApartAlongGround(sa, sb)\n if (level) this.slideApart(a, b, ima, imb, level)\n return\n }\n if (resting) return\n const [upper, c, up]: [PieceBody, Vec3, Vec3] = n[1] > 0 ? [a, ca, n] : [b, cb, [-n[0], -n[1], -n[2]]]\n if (upper.held || upper.sleeping) return\n upper.propped = up\n const e = this.m.makeRotationFromQuaternion(upper.root.quaternion).elements\n const r: Vec3 = [hit.point[0] - c[0], hit.point[1] - c[1], hit.point[2] - c[2]]\n upper.proppedAt = r\n // the contact point comes out as a push at that point does (as the impulse below): the body moves by its share of the lift and turns by the rest, so what it still\n // stands on elsewhere (a corner on the ground) is not carried up with it and left to fall back into the same neighbour\n const turn = this.mulInvInertiaWith(upper, e, r[1] * up[2] - r[2] * up[1], r[2] * up[0] - r[0] * up[2], r[0] * up[1] - r[1] * up[0])\n const angular = (turn[1] * r[2] - turn[2] * r[1]) * up[0] + (turn[2] * r[0] - turn[0] * r[2]) * up[1] + (turn[0] * r[1] - turn[1] * r[0]) * up[2]\n const lift = (SEPARATE_SHARE * Math.max(0, hit.depth - SLOP)) / (1 + angular * upper.mass)\n // lifted by several pieces under it at once (a sheet across three slabs) it needs the deepest of them, not all: each overlap is measured from where it stood, and their sum\n // would lift it clear of all and leave it to fall back into them, step after step\n const push = this.pushes.get(upper) ?? [0, 0, 0]\n for (let i = 0; i < 3; i++) push[i] = Math.abs(up[i] * lift) > Math.abs(push[i]) ? up[i] * lift : push[i]\n this.pushes.set(upper, push)\n this.turnAboutCentre(upper, c, [turn[0] * lift * upper.mass, turn[1] * lift * upper.mass, turn[2] * lift * upper.mass])\n this.contactImpulse(upper, e, r, up, 0)\n }\n\n /** Turns a piece by the rotation vector `by` (rad) about its centre `c`, which stays where it is. */\n private turnAboutCentre(b: PieceBody, c: Vec3, by: Vec3): void {\n const angle = Math.hypot(by[0], by[1], by[2])\n if (angle < 1e-9) return\n b.root.quaternion.premultiply(this.dq.setFromAxisAngle(this.ax.set(by[0] / angle, by[1] / angle, by[2] / angle), angle)).normalize()\n const off = this.ax.copy(b.centerV).applyQuaternion(b.root.quaternion)\n b.root.position.set(c[0] - off.x, c[1] - off.y, c[2] - off.z)\n }\n\n /** Two boxes put apart along the ground by `hit` (its normal from `b` to `a`, laid level), split by their inverse masses; the speed they close in with along it stops. */\n private slideApart(a: PieceBody, b: PieceBody, ima: number, imb: number, hit: ShapeContact): void {\n const n = hit.normal\n const flat = Math.hypot(n[0], n[2])\n const out: Vec3 = [n[0] / flat, 0, n[2] / flat]\n const move = (SEPARATE_SHARE * Math.max(0, hit.depth - SLOP)) / flat / (ima + imb)\n const va = a.velocity\n const vb = b.velocity\n const closing = (va[0] - vb[0]) * out[0] + (va[2] - vb[2]) * out[2]\n const stop = closing < 0 ? -closing / (ima + imb) : 0\n for (const [body, share, sign] of [[a, ima, 1], [b, imb, -1]] as const) {\n if (share === 0) continue\n const push = this.pushes.get(body) ?? [0, 0, 0]\n push[0] += out[0] * move * share * sign\n push[2] += out[2] * move * share * sign\n body.velocity[0] += out[0] * stop * share * sign\n body.velocity[2] += out[2] * stop * share * sign\n this.pushes.set(body, push)\n }\n }\n\n}\n\n/** The solution x of the 3x3 system with columns `k` (K x = rhs), by Cramer's rule; null when K is singular. */\nfunction solve3(k: readonly Vec3[], rhs: Vec3): Vec3 | null {\n const det = (a: Vec3, b: Vec3, c: Vec3): number => a[0] * (b[1] * c[2] - b[2] * c[1]) - b[0] * (a[1] * c[2] - a[2] * c[1]) + c[0] * (a[1] * b[2] - a[2] * b[1])\n const d = det(k[0], k[1], k[2])\n if (Math.abs(d) < 1e-12) return null\n return [det(rhs, k[1], k[2]) / d, det(k[0], rhs, k[2]) / d, det(k[0], k[1], rhs) / d]\n}\n","import type * as THREE_NS from 'three'\nimport type { Vec3 } from '@adatechnology/game-destruction'\n\n/** A bar of a cage, in world space. */\nexport interface RebarBar {\n readonly center: Vec3\n readonly rotation: [number, number, number, number]\n readonly length: number\n}\n\n/** Bare rebar of reinforced parts: one instanced cylinder mesh per part, replaced whenever the part exposes more (or less) of its cage. */\nexport class RebarCages {\n private readonly cages = new Map<string, THREE_NS.InstancedMesh>()\n private readonly geometry: THREE_NS.CylinderGeometry\n private readonly material: THREE_NS.MeshStandardMaterial\n private readonly up: THREE_NS.Vector3\n private readonly dir: THREE_NS.Vector3\n private readonly mid: THREE_NS.Vector3\n private readonly q: THREE_NS.Quaternion\n private readonly scale: THREE_NS.Vector3\n private readonly m: THREE_NS.Matrix4\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly scene: THREE_NS.Scene,\n private readonly radius = 0.004,\n ) {\n this.geometry = new THREE.CylinderGeometry(radius, radius, 1, 6)\n this.material = new THREE.MeshStandardMaterial({ color: 0x74665c, roughness: 0.55, metalness: 0.6 })\n this.up = new THREE.Vector3(0, 1, 0)\n this.dir = new THREE.Vector3()\n this.mid = new THREE.Vector3()\n this.q = new THREE.Quaternion()\n this.scale = new THREE.Vector3()\n this.m = new THREE.Matrix4()\n }\n\n /** Bars drawn now, over every part. */\n get count(): number {\n let n = 0\n for (const mesh of this.cages.values()) n += mesh.count\n return n\n }\n\n /** Meshes of the live cages (tests and picking). */\n meshes(): THREE_NS.InstancedMesh[] {\n return [...this.cages.values()]\n }\n\n /**\n * Draw `bars` (world space) as the cage of `key`; an empty list removes it. The cage is a child of `holder` (the drawing of the part's object, the scene\n * by default), so it goes where the part goes: a beam that comes down takes its bare bars with it.\n */\n set(key: string, bars: ReadonlyArray<readonly [Vec3, Vec3]>, holder?: THREE_NS.Object3D): void {\n this.remove(key)\n if (bars.length === 0) return\n const parent = holder ?? this.scene\n parent.updateWorldMatrix(true, false)\n const toParent = new this.THREE.Matrix4().copy(parent.matrixWorld).invert()\n const mesh = new this.THREE.InstancedMesh(this.geometry, this.material, bars.length)\n bars.forEach(([a, b], i) => {\n this.dir.set(b[0] - a[0], b[1] - a[1], b[2] - a[2])\n const length = this.dir.length()\n this.mid.set((a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2)\n this.q.setFromUnitVectors(this.up, length > 1e-9 ? this.dir.divideScalar(length) : this.up)\n this.m.compose(this.mid, this.q, this.scale.set(1, Math.max(length, 1e-4), 1)).premultiply(toParent)\n mesh.setMatrixAt(i, this.m)\n })\n mesh.instanceMatrix.needsUpdate = true\n mesh.castShadow = true\n mesh.name = 'rebar-cage'\n parent.add(mesh)\n this.cages.set(key, mesh)\n }\n\n /** The cage of `from` now belongs to `to` (a part that left its object for one of its own) and hangs from `holder`, where it is in the world now. */\n move(from: string, to: string, holder: THREE_NS.Object3D): void {\n const mesh = this.cages.get(from)\n if (!mesh) return\n this.cages.delete(from)\n this.remove(to)\n holder.attach(mesh)\n this.cages.set(to, mesh)\n }\n\n /** Takes the cage of `key` away and gives its bars, where they are in the world now: centre, turn (the bar along its y) and length. */\n take(key: string): RebarBar[] {\n const mesh = this.cages.get(key)\n if (!mesh) return []\n mesh.updateWorldMatrix(true, false)\n const bars: RebarBar[] = []\n for (let i = 0; i < mesh.count; i++) {\n mesh.getMatrixAt(i, this.m)\n this.m.premultiply(mesh.matrixWorld).decompose(this.mid, this.q, this.scale)\n bars.push({ center: [this.mid.x, this.mid.y, this.mid.z], rotation: [this.q.x, this.q.y, this.q.z, this.q.w], length: this.scale.y })\n }\n this.remove(key)\n return bars\n }\n\n /** Radius of the bars drawn, metres. */\n get barRadius(): number {\n return this.radius\n }\n\n remove(key: string): void {\n const mesh = this.cages.get(key)\n if (!mesh) return\n mesh.removeFromParent()\n mesh.dispose()\n this.cages.delete(key)\n }\n\n /** Remove the cages of every part of `object` (keys are `object|part`). */\n removeObject(object: string): void {\n for (const key of [...this.cages.keys()]) if (key.startsWith(`${object}|`)) this.remove(key)\n }\n\n clear(): void {\n for (const key of [...this.cages.keys()]) this.remove(key)\n }\n\n dispose(): void {\n this.clear()\n this.geometry.dispose()\n this.material.dispose()\n }\n}\n","import type * as THREE_NS from 'three'\nimport { guessMaterial, inferJoints, MATERIALS, partMass } from '@adatechnology/game-destruction'\nimport type { JointKind, JointSpec, MaterialId, PartSpec } from '@adatechnology/game-destruction'\nimport type { Mesh, Object3D, SpecFromObjectOptions, SpecFromObjectResult, ThreeNamespace } from './types'\n\ninterface Entry {\n key: string\n meshes: Mesh[]\n box: THREE_NS.Box3\n material: MaterialId\n explicitId: string | null\n fill?: number\n hollow: boolean\n /** `userData.destructionSkin`: a layer drawn on a part (a label, a coat), never a part of its own. */\n skin: boolean\n tags?: string[]\n /** `userData.destructionContains`: the fluid the part holds (a hole in it makes it leak). */\n contains?: { fluid: string; liters: number }\n /** `userData.destructionPowder`: the loose dry contents the part holds (`PartSpec.powder`). */\n powder?: { color: number }\n /** `userData.destructionThickness`: the real wall thickness in metres (a can is a tenth of a millimetre, far less than its box says). */\n thickness?: number\n /** Part id wished by the host (`userData.destructionPart`). */\n fixedId: boolean\n name: string\n /** `parent` / `kind` of an object-valued `destructionPart`: the part is attached to `parent` by a joint of that kind. */\n parent?: string\n jointKind?: JointKind\n}\n\n/** What `userData.destructionPart` says: a string (the part id) or an object `{ id, material?, parent?, kind? }`. */\nexport interface PartHint {\n id: string\n material?: string\n parent?: string\n kind?: string\n}\n\n/** Read `userData.destructionContains` (`{ fluid, liters }`); undefined when it holds nothing. */\nfunction containsOf(value: unknown): { fluid: string; liters: number } | undefined {\n if (!value || typeof value !== 'object') return undefined\n const v = value as Record<string, unknown>\n return typeof v.fluid === 'string' && typeof v.liters === 'number' && v.liters > 0 ? { fluid: v.fluid, liters: v.liters } : undefined\n}\n\n/** Read `userData.destructionPart` (string or object with an `id`); null when it names no part. */\nexport function partHintOf(value: unknown): PartHint | null {\n if (typeof value === 'string') return value ? { id: value } : null\n if (!value || typeof value !== 'object') return null\n const v = value as Record<string, unknown>\n if (typeof v.id !== 'string' || !v.id) return null\n const str = (x: unknown): string | undefined => (typeof x === 'string' && x ? x : undefined)\n return { id: v.id, material: str(v.material), parent: str(v.parent), kind: str(v.kind) }\n}\n\nconst METAL = /steel|iron|metal|alumin|copper|brass|bronze|tin|titan|chrome|zinc|lead/i\n\nfunction sanitizeId(name: string): string {\n let id = name\n .trim()\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '_')\n .replace(/^_+|_+$/g, '')\n if (id && /^[0-9]/.test(id)) id = `p_${id}`\n return id\n}\n\nfunction isMesh(o: Object3D): o is Mesh {\n return (o as Mesh).isMesh === true\n}\n\nfunction sizeOf(box: THREE_NS.Box3): [number, number, number] {\n return [box.max.x - box.min.x, box.max.y - box.min.y, box.max.z - box.min.z]\n}\n\n/** Inverse of the root's world pose without its scale: world space to the metric frame the spec and the world's `setTransform` use. */\nexport function specFrameInverse(THREE: ThreeNamespace, root: Object3D): THREE_NS.Matrix4 {\n root.updateMatrixWorld(true)\n const position = new THREE.Vector3()\n const quaternion = new THREE.Quaternion()\n root.matrixWorld.decompose(position, quaternion, new THREE.Vector3())\n return new THREE.Matrix4().compose(position, quaternion, new THREE.Vector3(1, 1, 1)).invert()\n}\n\n/**\n * Build a `DestructibleSpec` from a three.js object: one part per mesh (meshes sharing `userData.destructionPart` become one part), each an\n * axis-aligned box in metres in the root's frame (its position and rotation removed, its world scale kept; rotation omitted), with the material taken from `options.materialOf`, `userData.destructionMaterial`\n * or a guess from the names. Tiny meshes are merged into the part they overlap most; joints are inferred from touching parts.\n *\n * `userData.destructionContains` (`{ fluid, liters }`) makes the part a container: a hole through it leaks. `userData.destructionPowder` (`{ color }`) fills it with a dry powder or flakes that puff out of a hole. `root.userData.destructionMass` (kg) fixes the total mass, split between the parts in proportion to their volume, density and fill.\n * A mesh with `userData.destructionSkin` (a label, a coat) joins the part it overlaps most instead of becoming a part: it stays drawn and bound to that part (decals, dents) but never breaks off.\n * Meshes that are invisible or have `userData.destructionIgnore` (or sit under such an object) are skipped. The result also tells which meshes\n * became which part, ready to be passed to `bind`.\n */\nexport function specFromObject3D(THREE: ThreeNamespace, root: Object3D, options: SpecFromObjectOptions = {}): SpecFromObjectResult {\n const fallback = options.fallback ?? 'plastic'\n const minSize = options.minSize ?? 0.015\n const inv = specFrameInverse(THREE, root)\n\n // 1. collect meshes -> entries (grouped by an explicit part name)\n const entries: Entry[] = []\n const byKey = new Map<string, Entry>()\n const visit = (o: Object3D): void => {\n if (!o.visible || o.userData?.destructionIgnore) return\n if (isMesh(o) && o.geometry) {\n const geom = o.geometry\n if (!geom.boundingBox) geom.computeBoundingBox()\n if (geom.boundingBox && !geom.boundingBox.isEmpty()) {\n const box = geom.boundingBox.clone().applyMatrix4(new THREE.Matrix4().multiplyMatrices(inv, o.matrixWorld))\n const mats = Array.isArray(o.material) ? o.material : [o.material]\n const matName = mats[0]?.name ?? ''\n const ud = o.userData ?? {}\n const hint = partHintOf(ud.destructionPart)\n const material =\n options.materialOf?.(o) ??\n (typeof ud.destructionMaterial === 'string' ? (ud.destructionMaterial as string) : undefined) ??\n hint?.material ??\n guessMaterial(`${o.name} ${matName} ${typeof ud.material === 'string' ? ud.material : ''}`) ??\n fallback\n const explicit = hint?.id ?? null\n const hollow = ud.hollow === true || /hollow/i.test(o.name)\n const skin = ud.destructionSkin === true\n const fill = options.fillOf?.(o, material)\n const tags = Array.isArray(ud.destructionTags) ? (ud.destructionTags as string[]) : undefined\n const contains = containsOf(ud.destructionContains)\n const powder = typeof (ud.destructionPowder as { color?: unknown } | undefined)?.color === 'number' ? { color: (ud.destructionPowder as { color: number }).color } : undefined\n const thickness = typeof ud.destructionThickness === 'number' && ud.destructionThickness > 0 ? (ud.destructionThickness as number) : undefined\n const existing = explicit ? byKey.get(explicit) : undefined\n if (existing) {\n const before = sizeOf(existing.box)\n const bv = before[0] * before[1] * before[2]\n const ns = sizeOf(box)\n existing.box.union(box)\n existing.meshes.push(o)\n if (ns[0] * ns[1] * ns[2] > bv) existing.material = material\n existing.hollow = existing.hollow || hollow\n existing.skin = existing.skin && skin\n if (fill !== undefined) existing.fill = fill\n if (contains) existing.contains = contains\n if (powder) existing.powder = powder\n if (thickness !== undefined) existing.thickness = Math.min(existing.thickness ?? thickness, thickness)\n } else {\n const e: Entry = { key: explicit ?? `m${entries.length}`, meshes: [o], box, material, explicitId: explicit, fill, hollow, skin, tags, fixedId: !!explicit, ...(contains ? { contains } : {}), ...(powder ? { powder } : {}), ...(thickness !== undefined ? { thickness } : {}), name: o.name, parent: hint?.parent, jointKind: hint?.kind as JointKind | undefined }\n entries.push(e)\n if (explicit) byKey.set(explicit, e)\n }\n }\n }\n for (const c of o.children) visit(c)\n }\n visit(root)\n\n // 2. merge tiny meshes and skins into the touching part they overlap most\n const eps = 0.005\n const overlapVolume = (a: THREE_NS.Box3, b: THREE_NS.Box3): number => {\n const x = Math.min(a.max.x, b.max.x) - Math.max(a.min.x, b.min.x) + eps\n const y = Math.min(a.max.y, b.max.y) - Math.max(a.min.y, b.min.y) + eps\n const z = Math.min(a.max.z, b.max.z) - Math.max(a.min.z, b.min.z) + eps\n return x > 0 && y > 0 && z > 0 ? x * y * z : 0\n }\n const largest = (e: Entry) => Math.max(...sizeOf(e.box))\n const kept: Entry[] = []\n const tiny: Entry[] = []\n for (const e of entries) (e.skin || (!e.fixedId && largest(e) < minSize) ? tiny : kept).push(e)\n for (const t of tiny) {\n let best: Entry | null = null\n let bestV = 0\n for (const k of kept) {\n const v = overlapVolume(t.box, k.box)\n if (v > bestV) {\n bestV = v\n best = k\n }\n }\n if (!best) {\n // not touching anything: join the nearest part within a small distance\n let bd = 0.05\n for (const k of kept) {\n const d = k.box.distanceToPoint(t.box.getCenter(new THREE.Vector3()))\n if (d < bd) {\n bd = d\n best = k\n }\n }\n }\n if (best) {\n best.meshes.push(...t.meshes) // the box stays: a tiny mesh sits inside or on the surface of its part\n } else {\n kept.push(t) // isolated crumb: keep it as its own part\n }\n }\n\n // 3. ids, parts\n const used = new Set<string>()\n const parts: PartSpec[] = []\n const meshesOf: Record<string, Object3D[]> = {}\n let counter = 0\n for (const e of kept) {\n counter++\n let base = (e.explicitId ? sanitizeId(e.explicitId) : '') || sanitizeId(e.name) || `part_${counter}`\n let id = base\n for (let n = 2; used.has(id); n++) id = `${base}_${n}`\n used.add(id)\n base = id\n const size = sizeOf(e.box)\n const center = e.box.getCenter(new THREE.Vector3())\n const part: PartSpec = {\n id,\n material: e.material,\n shape: { kind: 'box', size: [Math.max(size[0], 0.002), Math.max(size[1], 0.002), Math.max(size[2], 0.002)] },\n position: [center.x, center.y, center.z],\n }\n const minSide = Math.min(...size)\n if (e.fill !== undefined) part.fill = e.fill\n else if (e.hollow) part.fill = 0.05\n if (e.thickness !== undefined) part.thickness = e.thickness\n else if (minSide < 0.01 && METAL.test(e.material)) {\n part.fill = e.fill ?? 1\n part.thickness = Math.max(minSide, 0.0005)\n }\n if (e.tags) part.tags = [...e.tags]\n if (e.contains) part.contains = { ...e.contains }\n if (e.powder) part.powder = { ...e.powder }\n const ao = options.anchorBelow ?? -1\n if (ao >= 0 && e.box.min.y <= ao) part.anchored = true\n parts.push(part)\n meshesOf[id] = e.meshes\n }\n\n const knownMass = root.userData?.destructionMass\n if (typeof knownMass === 'number' && knownMass > 0) {\n const shares = parts.map((p) => {\n const material = MATERIALS.find((m) => m.id === p.material)\n return material ? partMass(p, material) : 0\n })\n const total = shares.reduce((a, b) => a + b, 0)\n if (total > 0) parts.forEach((p, i) => (p.mass = (knownMass * shares[i]) / total))\n }\n\n const spec: SpecFromObjectResult['spec'] = { parts }\n if (options.name !== undefined) spec.name = options.name\n else if (root.name) spec.name = root.name\n if (options.tags) spec.tags = [...options.tags]\n spec.joints = options.joints === false ? [] : inferJoints(parts)\n // explicit attachments from `destructionPart: { parent, kind }` win over the inferred joint between the same two parts\n if (options.joints !== false) {\n const finalId = new Map<Entry, string>()\n kept.forEach((e, i) => finalId.set(e, parts[i].id))\n const idOf = new Map<string, string>()\n for (const e of kept) if (e.explicitId) idOf.set(e.explicitId, finalId.get(e)!)\n const joints: JointSpec[] = spec.joints\n for (const e of kept) {\n if (!e.parent) continue\n const id = finalId.get(e)!\n const parent = idOf.get(e.parent) ?? (used.has(sanitizeId(e.parent)) ? sanitizeId(e.parent) : null)\n if (!parent || parent === id) continue\n const at = joints.findIndex((j) => (j.a === parent && j.b === id) || (j.a === id && j.b === parent))\n const kind = e.jointKind ?? (at >= 0 ? joints[at].kind : 'resting')\n const joint: JointSpec = { id: `${parent}~${id}`, a: parent, b: id, kind }\n if (at >= 0) joints[at] = joint\n else joints.push(joint)\n }\n }\n return { spec, parts: meshesOf }\n}\n","import { debrisColor, debrisFamily, dustColor } from '@adatechnology/game-destruction'\nimport type { DestructionEvent, MaterialDef, Vec3 } from '@adatechnology/game-destruction'\nimport { DEBRIS_COLOR_VARIABLE, DUST_COLOR_VARIABLE, PIECES_DRAWN_VARIABLE } from '@adatechnology/game-vfx'\n\n/** How long a hit point stays the place a stage of the same part happens at (s): the stage comes in the same batch as the hit. */\nconst HIT_POINT_SECONDS = 1\n\n/** The family and the colours an effect of the event map is played with: the `{material}` of the map and the values its recipe reads. */\nexport interface FamilyPlay {\n readonly material: string\n readonly values: Readonly<Record<string, number>>\n}\n\n/** The family of the material and the colours of its debris and dust, for `vfx.play`. The renderer draws the pieces of what broke itself (fragments, loose parts): the effect throws no stand-ins. */\nexport function familyPlay(def: MaterialDef | undefined, partColor?: number): FamilyPlay {\n const dust = dustColor(def, partColor)\n return {\n material: debrisFamily(def),\n values: { [PIECES_DRAWN_VARIABLE]: 1, [DEBRIS_COLOR_VARIABLE]: debrisColor(def, partColor), ...(dust !== undefined ? { [DUST_COLOR_VARIABLE]: dust } : {}) },\n }\n}\n\n/** The world point a destruction event happened at, when it carries one. */\nfunction pointOf(ev: DestructionEvent): Vec3 | undefined {\n switch (ev.type) {\n case 'hole':\n case 'crack':\n return ev.worldPoint\n case 'spall':\n case 'debris':\n return ev.point\n case 'chip':\n return ev.center\n default:\n return undefined\n }\n}\n\n/**\n * Where each part was last hit. A stage 1 carries no point of its own (only the stage 2 opening has one), so its splinters, chips or shards are thrown\n * from the hit that set it off, not from the root of the object (the middle of a house).\n */\nexport class HitPoints {\n private readonly points = new Map<string, { point: Vec3; time: number }>()\n\n note(ev: DestructionEvent, time: number): void {\n const point = pointOf(ev)\n if (!point || !('part' in ev)) return\n this.points.set(`${ev.object}|${ev.part}`, { point, time })\n }\n\n /** The last hit on the part, if it was recent. */\n of(objectId: string, partId: string, time: number): Vec3 | undefined {\n const hit = this.points.get(`${objectId}|${partId}`)\n return hit && time - hit.time <= HIT_POINT_SECONDS ? hit.point : undefined\n }\n\n forget(objectId: string): void {\n for (const key of this.points.keys()) if (key.startsWith(`${objectId}|`)) this.points.delete(key)\n }\n}\n","import type * as THREE_NS from 'three'\n\nimport { createDestruction, inferJoints } from '@adatechnology/game-destruction'\nimport type { JointSpec, PartSpec, Vec3 } from '@adatechnology/game-destruction'\nimport { KIT_WORLD, createPhysicsLoop } from '@adatechnology/game-physics'\nimport type { PhysicsEngine, PhysicsLoop, PhysicsWorld, WorldDesc } from '@adatechnology/game-physics'\nimport { discardObject3D } from '@adatechnology/game-shapes-three'\nimport { createVfx } from '@adatechnology/game-vfx'\n\nimport type { DestructionRenderer, RendererOptions, ThreeNamespace } from './types'\n\n/** What the warm-up runs on: the engine whose body creation, compounds and ground it heats (without one, the kit's own solver), and the numbers of the throwaway world. */\nexport interface JitWarmUpOptions {\n readonly engine?: PhysicsEngine\n /** The world the engine makes for the warm-up (default `KIT_WORLD`: the same code runs as in the game's world). */\n readonly world?: WorldDesc\n}\n\n/** What the warm-up saw: the loose pieces the blast made at most, and the fragments (so a test can tell the paths ran). */\nexport interface JitWarmUpReport {\n readonly pieces: number\n readonly fragments: number\n}\n\nconst COLUMNS = 6\nconst ROWS = 4\nconst BRICK: Vec3 = [0.5, 0.25, 0.2]\nconst FRAMES = 150\nconst FRAME_SECONDS = 1 / 60\nconst BLAST_AT: Vec3 = [0, 0.5, -1.5]\nconst BLAST_ENERGY = 4_000_000\nconst BLAST_RADIUS = 7\nconst CRATER_DEPTH = 0.3\nconst CRATER_RADIUS = 2.5\n// far from where a host puts anything: the throwaway scene never meets the game's\nconst ORIGIN: Vec3 = [4000, 0, 4000]\n\ninterface BlastAndRunParams {\n readonly world: ReturnType<typeof createDestruction>\n readonly loop: PhysicsLoop | undefined\n readonly renderer: DestructionRenderer\n readonly onCrater: () => void\n}\n\nconst warmed = new WeakSet<object>()\nconst OWN_SOLVER = {}\n\n/** A wall of bricks, each a part drawn by a range of one merged mesh (as the house is), and the ranges. */\nconst brickWall = (THREE: ThreeNamespace): { readonly parts: PartSpec[]; readonly joints: JointSpec[]; readonly mesh: THREE_NS.Mesh; readonly ranges: Array<[number, number]> } => {\n const parts: PartSpec[] = []\n const geometries: THREE_NS.BufferGeometry[] = []\n const ranges: Array<[number, number]> = []\n let vertices = 0\n for (let row = 0; row < ROWS; row++) {\n for (let column = 0; column < COLUMNS; column++) {\n const position: Vec3 = [(column - COLUMNS / 2 + 0.5 + (row % 2) * 0.25) * BRICK[0], (row + 0.5) * BRICK[1], 0]\n parts.push({ id: `brick_${row}_${column}`, material: 'brick', shape: { kind: 'box', size: BRICK }, position })\n const geometry = new THREE.BoxGeometry(...BRICK).translate(...position)\n const count = geometry.getAttribute('position').count\n geometries.push(geometry)\n ranges.push([vertices, vertices + count])\n vertices += count\n }\n }\n const merged = new THREE.BufferGeometry()\n const offsets = ['position', 'normal', 'uv'] as const\n for (const name of offsets) merged.setAttribute(name, new THREE.Float32BufferAttribute(geometries.flatMap((geometry) => Array.from(geometry.getAttribute(name).array)), name === 'uv' ? 2 : 3))\n let base = 0\n const index: number[] = []\n for (const geometry of geometries) {\n for (const entry of Array.from(geometry.getIndex()?.array ?? [])) index.push(entry + base)\n base += geometry.getAttribute('position').count\n geometry.dispose()\n }\n merged.setIndex(index)\n return { parts, joints: inferJoints(parts), mesh: new THREE.Mesh(merged, new THREE.MeshStandardMaterial()), ranges }\n}\n\n/**\n * One blast on a small wall, in a world, a scene and a renderer of its own, all freed at the end. Every path the first real explosion would run cold runs here once: the\n * fracture and the split of the loosened groups, the oriented boxes fitted to the parts, the engine's bodies and compounds, the ground laid under the pieces and written in place\n * where a crater was dug. Nothing of it touches a game world (own world, own renderer, own random stream) and nothing of it stays.\n */\nconst runScene = (THREE: ThreeNamespace, makeRenderer: (options: RendererOptions) => DestructionRenderer, options: JitWarmUpOptions): JitWarmUpReport => {\n const scene = new THREE.Scene()\n const world = createDestruction()\n // an effects world of its own: without one the renderer makes its own and warns the host, who did lend one\n const vfx = createVfx({})\n let craterDepth = 0\n const terrainAt = (x: number, z: number): number => -craterDepth * Math.max(0, 1 - Math.hypot(x - ORIGIN[0] - BLAST_AT[0], z - ORIGIN[2] - BLAST_AT[2]) / CRATER_RADIUS)\n let engineWorld: PhysicsWorld | undefined\n let renderer: DestructionRenderer | undefined\n let bound: string | undefined\n try {\n engineWorld = options.engine?.createWorld(options.world ?? KIT_WORLD)\n const loop: PhysicsLoop | undefined = engineWorld ? createPhysicsLoop(engineWorld) : undefined\n // a grid reader as a host's terrain gives one, so the tiles read their samples down the path the host's do\n const terrainGridAt = (xs: ArrayLike<number>, zs: ArrayLike<number>, out: Float64Array): void => {\n for (let j = 0; j < zs.length; j++) for (let i = 0; i < xs.length; i++) out[j * xs.length + i] = terrainAt(xs[i]!, zs[j]!)\n }\n renderer = makeRenderer({ physics: loop ?? 'own', scene, world, vfx, eventBudgetMs: Infinity, groundAt: terrainAt, terrainAt, terrainGridAt, jitWarmUp: false })\n const wall = brickWall(THREE)\n const root = new THREE.Group()\n root.position.set(...ORIGIN)\n root.add(wall.mesh)\n scene.add(root)\n root.updateMatrixWorld(true)\n bound = world.add({ parts: wall.parts, joints: wall.joints }, { position: ORIGIN })\n renderer.bind(bound, root, { parts: Object.fromEntries(wall.parts.map((part, index) => [part.id, { mesh: wall.mesh, range: wall.ranges[index] as [number, number] }])) })\n return blastAndRun({ world, loop, renderer, onCrater: () => (craterDepth = CRATER_DEPTH) })\n } finally {\n if (renderer && bound !== undefined) renderer.release(bound)\n renderer?.dispose()\n discardObject3D(scene.children.slice())\n vfx.clear()\n engineWorld?.dispose()\n }\n}\n\n/** The blast and the frames after it; the most pieces and fragments seen. */\nconst blastAndRun = ({ world, loop, renderer, onCrater }: BlastAndRunParams): JitWarmUpReport => {\n const seen = { pieces: 0, fragments: 0 }\n const point: Vec3 = [ORIGIN[0] + BLAST_AT[0], ORIGIN[1] + BLAST_AT[1], ORIGIN[2] + BLAST_AT[2]]\n const report = world.explode(point, BLAST_ENERGY, BLAST_RADIUS, 'warm-up')\n renderer.explode(point, BLAST_ENERGY, BLAST_RADIUS, { report, visual: false })\n onCrater()\n renderer.wakeRegion(point[0], point[2], CRATER_RADIUS)\n for (let frame = 0; frame < FRAMES; frame++) {\n world.update(FRAME_SECONDS)\n loop?.step(FRAME_SECONDS)\n renderer.update(FRAME_SECONDS)\n const stats = renderer.stats()\n seen.pieces = Math.max(seen.pieces, stats.pieces)\n seen.fragments = Math.max(seen.fragments, stats.fragments)\n }\n return seen\n}\n\n/**\n * Runs the first explosion once, off screen, so the code it needs is warm when the real one comes. Once per engine (and once for the kit's own solver): a second call is a\n * no-op (`undefined`). `makeRenderer` is the renderer factory of the package, so the throwaway renderer is the real one.\n */\nexport const warmUpDestructionJit = (THREE: ThreeNamespace, makeRenderer: (options: RendererOptions) => DestructionRenderer, options: JitWarmUpOptions = {}): JitWarmUpReport | undefined => {\n const key = options.engine ?? OWN_SOLVER\n if (warmed.has(key)) return undefined\n warmed.add(key)\n return runScene(THREE, makeRenderer, options)\n}\n","import type * as THREE_NS from 'three'\nimport type { Dent } from '@adatechnology/game-destruction'\nimport { markPositionsWritten, rangesWrittenSince } from '@adatechnology/game-shapes-three'\nimport { BEND_SMOOTH_RADIUS, bendPositions } from './bend'\nimport { heatColor } from './heat'\nimport { MeshRayProbe } from './mesh-ray-probe'\nimport type { Decal, HostVis, MeshVis, PartVis } from './internal'\nimport { clamp, createRng, lerp } from './math'\nimport { shellDisplacementAt, type ShellSnapshot } from './skin-dent'\nimport { pushFittedBoxes } from './fitted-boxes'\nimport { stairCrackPath, stairCrackStrip } from './stair-crack'\n\ntype Mesh = THREE_NS.Mesh\n\nconst POS_ATTR = 'position'\n\nfunction positionAttr(geo: THREE_NS.BufferGeometry): THREE_NS.BufferAttribute | null {\n const a = geo.getAttribute(POS_ATTR) as THREE_NS.BufferAttribute | THREE_NS.InterleavedBufferAttribute | undefined\n return a && !(a as THREE_NS.InterleavedBufferAttribute).isInterleavedBufferAttribute ? (a as THREE_NS.BufferAttribute) : null\n}\n\nfunction materialsOf(m: THREE_NS.Material | THREE_NS.Material[]): THREE_NS.Material[] {\n return Array.isArray(m) ? m : [m]\n}\n\nfunction colorOf(m: THREE_NS.Material): THREE_NS.Color | null {\n const c = (m as THREE_NS.MeshStandardMaterial).color\n return c && (c as THREE_NS.Color).isColor ? c : null\n}\n\n/** Shared resources for decals (one geometry, a few materials) created lazily and disposed together. */\nexport class DecalKit {\n private disc: THREE_NS.CircleGeometry | null = null\n private discMat: THREE_NS.MeshBasicMaterial | null = null\n private lineMats = new Map<number, THREE_NS.LineBasicMaterial>()\n private patchMats = new Map<number, THREE_NS.MeshBasicMaterial>()\n constructor(private readonly THREE: typeof THREE_NS) {}\n\n discGeometry(): THREE_NS.CircleGeometry {\n return (this.disc ??= new this.THREE.CircleGeometry(1, 14))\n }\n\n discMaterial(): THREE_NS.MeshBasicMaterial {\n return (this.discMat ??= new this.THREE.MeshBasicMaterial({\n color: 0x050505,\n transparent: true,\n opacity: 0.92,\n depthWrite: false,\n polygonOffset: true,\n polygonOffsetFactor: -4,\n polygonOffsetUnits: -4,\n side: this.THREE.DoubleSide,\n // flat disc: three would draw transparent + DoubleSide twice and rebuild the program on every draw\n forceSinglePass: true,\n }))\n }\n\n /** Opaque patch in the colour of what shows under a spalled coat. */\n patchMaterial(color: number): THREE_NS.MeshBasicMaterial {\n let m = this.patchMats.get(color)\n if (!m) {\n m = new this.THREE.MeshBasicMaterial({ color, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -3, polygonOffsetUnits: -3 })\n this.patchMats.set(color, m)\n }\n return m\n }\n\n lineMaterial(color: number): THREE_NS.LineBasicMaterial {\n let m = this.lineMats.get(color)\n if (!m) {\n m = new this.THREE.LineBasicMaterial({ color, transparent: true, opacity: 0.9, depthWrite: false })\n this.lineMats.set(color, m)\n }\n return m\n }\n\n dispose(): void {\n this.disc?.dispose()\n this.discMat?.dispose()\n for (const m of this.lineMats.values()) m.dispose()\n for (const m of this.patchMats.values()) m.dispose()\n this.patchMats.clear()\n this.disc = null\n this.discMat = null\n this.lineMats.clear()\n }\n}\n\nconst tmpV = (THREE: typeof THREE_NS) => new THREE.Vector3()\n\n/**\n * The positions a host drew a range with before it took the range out of the merged mesh to draw it another way (the house renderer collapses the range of a\n * wall it draws with holes, `userData.collapsedRanges`, and keeps the first positions in `userData.plainPositions`): a part that leaves the mesh takes those,\n * or it would leave as a collapsed, invisible range that still carries its decals and is still shot at.\n */\nexport function plainPositions(mesh: THREE_NS.Mesh, v0: number, v1: number): Float32Array | null {\n const { collapsedRanges, plainPositions: plain } = mesh.userData as { collapsedRanges?: ReadonlyArray<readonly [number, number]>; plainPositions?: Float32Array }\n if (!plain || !collapsedRanges?.some(([a, b]) => a < v1 && b > v0)) return null\n return plain\n}\n\n/** A whole mesh that leaves with its part draws again the ranges its host collapsed (`plainPositions`): it is the part now, and the part is still there. */\nexport function showCollapsedRanges(mesh: THREE_NS.Mesh): void {\n const data = mesh.userData as { collapsedRanges?: Array<[number, number]>; plainPositions?: Float32Array }\n const plain = data.plainPositions\n const position = mesh.geometry?.getAttribute(POS_ATTR) as THREE_NS.BufferAttribute | undefined\n if (!plain || !data.collapsedRanges?.length || !position) return\n const array = position.array as Float32Array\n for (const [v0, v1] of data.collapsedRanges) array.set(plain.subarray(v0 * 3, v1 * 3), v0 * 3)\n for (const [v0, v1] of data.collapsedRanges) markPositionsWritten(mesh, v0, v1)\n data.collapsedRanges = []\n mesh.geometry.computeBoundingBox()\n mesh.geometry.computeBoundingSphere()\n}\n\n/** Mesh-level visual changes: copy-on-write geometry and materials, dents, decals, char, glow, melt, hiding, restoring. */\n/** A dent reaches at least this many vertices of a mesh: fewer and the mesh cannot show its curve (it would be invisible or a sharp spike). */\nconst MIN_DENT_VERTICES = 10\n/** The reach of a dent that had to widen is this many times the distance to the farthest of those vertices, so they all get a falloff above zero. */\nconst WIDEN_MARGIN = 1.1\n/** A skin follows its shell this share of the way in: the two meshes triangulate the dent differently, and a skin left a bit outside never lets the shell through. */\nconst SKIN_FOLLOW = 0.85\n/** And stays this many metres outside, so the thin gap of a label (a millimetre) survives the two meshes triangulating the rim differently. */\nconst SKIN_SLACK = 0.0005\n/** Extra slack per metre a skin lies above its shell: skins stacked on one another (a label and its band) keep their order while the dent bends them. */\nconst SKIN_LAYER_SLACK = 4\n/** And at least this many times the distance to the nearest vertex, so even the nearest one is pushed visibly. */\nconst NEAREST_MARGIN = 1.5\n/**\n * The first positions of a merged mesh: `userData._p0` when another drawing keeps them there (the house renderer, which collapses the ranges of what it\n * draws itself, `userData.collapsedRanges`), else those of the geometry it was bound with.\n */\nconst basePositions = (host: { mesh: Mesh; origGeometry: THREE_NS.BufferGeometry }): Float32Array | null => {\n const p0 = host.mesh.userData._p0 as Float32Array | undefined\n if (p0) return p0\n const op = positionAttr(host.origGeometry)\n return op ? (op.array as unknown as Float32Array) : null\n}\n\n/** Collapses in `arr` the ranges another drawing hides on the mesh (`userData.collapsedRanges`, each to its first vertex). */\nconst collapseForeign = (mesh: Mesh, arr: Float32Array): void => {\n for (const [v0, v1] of (mesh.userData.collapsedRanges as Array<[number, number]> | undefined) ?? []) {\n for (let k = v0 + 1; k < v1; k++) {\n arr[k * 3] = arr[v0 * 3]!\n arr[k * 3 + 1] = arr[v0 * 3 + 1]!\n arr[k * 3 + 2] = arr[v0 * 3 + 2]!\n }\n }\n}\n\n/** Whether two position arrays hold the same vertices in the range. */\nconst sameRange = (a: ArrayLike<number>, b: ArrayLike<number>, range: readonly [number, number]): boolean => {\n for (let i = range[0] * 3; i < range[1] * 3; i++) if (a[i] !== b[i]) return false\n return true\n}\n\n/** Metres along its normal a mark looks for the drawn face under it (`onFace`). */\nconst DECAL_SNAP = 0.03\n/** Metres a stair-step crack sits off the face, and how narrow its far end is (share of its width). */\nconst STAIR_CRACK_LIFT = 0.002\nconst STAIR_CRACK_TAPER = 0.35\n\nexport class Visuals {\n readonly kit: DecalKit\n private readonly a: THREE_NS.Vector3\n private readonly b: THREE_NS.Vector3\n private readonly m4: THREE_NS.Matrix4\n private readonly q: THREE_NS.Quaternion\n private readonly meshRays: MeshRayProbe\n private readonly ray: THREE_NS.Raycaster\n private readonly box: THREE_NS.Box3\n private readonly t: THREE_NS.Vector3\n private readonly lbox: THREE_NS.Box3\n /** Total live decals across meshes (kept in sync by add/remove). */\n decalCount = 0\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly lowQuality: boolean,\n private readonly decalCap: number,\n ) {\n this.kit = new DecalKit(THREE)\n this.a = tmpV(THREE)\n this.b = tmpV(THREE)\n this.m4 = new THREE.Matrix4()\n this.q = new THREE.Quaternion()\n this.meshRays = new MeshRayProbe(THREE)\n this.ray = new THREE.Raycaster()\n // batched meshes leave the camera layer (createStaticBatcher), not the world: rays still find them\n this.ray.layers.enableAll()\n this.box = new THREE.Box3()\n this.t = tmpV(THREE)\n this.lbox = new THREE.Box3()\n }\n\n /**\n * @param range vertex range `[v0, v1)` of a merged mesh this part is drawn by (see `MeshRange`); `hosts` caches the shared state per mesh for one `bind`.\n */\n makeMeshVis(mesh: Mesh, home: string, range?: [number, number], hosts?: Map<Mesh, HostVis>): MeshVis {\n let host: HostVis | null = null\n if (range) {\n host = hosts?.get(mesh) ?? null\n if (!host) {\n const attribute = positionAttr(mesh.geometry)\n host = { mesh, origGeometry: mesh.geometry, origMaterial: mesh.material, ownGeo: false, work: null, ownMat: false, sharers: [], seen: { attribute, version: attribute?.version ?? 0 }, collapsedSeen: [] }\n hosts?.set(mesh, host)\n }\n }\n const mv: MeshVis = {\n mesh,\n home,\n origGeometry: mesh.geometry,\n origMaterial: mesh.material,\n origVisible: mesh.visible,\n origParent: mesh.parent,\n origPosition: mesh.position.clone(),\n origQuaternion: mesh.quaternion.clone(),\n origScale: mesh.scale.clone(),\n ownMat: false,\n ownGeo: false,\n work: null,\n baseColors: null,\n decals: [],\n meltApplied: 0,\n bottomY: 0,\n moved: false,\n host,\n range: range ? [range[0], range[1]] : null,\n merged: host && range ? { host, range: [range[0], range[1]] } : null,\n loose: false,\n collapsed: false,\n hidden: false,\n touched: false,\n shapeVersion: 0,\n charK: 0,\n charHex: 0,\n glowHex: 0,\n glowK: 0,\n }\n host?.sharers.push(mv)\n return mv\n }\n\n vertexCount(mv: MeshVis): number {\n if (mv.range) return mv.range[1] - mv.range[0]\n return mv.mesh.geometry.getAttribute(POS_ATTR)?.count ?? 0\n }\n\n /** Is the part drawn? (A ranged part shares its mesh, so `mesh.visible` says nothing about it.) */\n shown(mv: MeshVis): boolean {\n return mv.host ? !mv.hidden : mv.mesh.visible\n }\n\n /** Box of the part's vertices in the space of its mesh (the whole geometry for a plain mesh). */\n localBox(mv: MeshVis, out: THREE_NS.Box3): THREE_NS.Box3 {\n out.makeEmpty()\n if (!mv.host || !mv.range) {\n const geo = mv.mesh.geometry\n if (!geo.boundingBox) geo.computeBoundingBox()\n return geo.boundingBox ? out.copy(geo.boundingBox) : out\n }\n const arr = mv.host.work ?? (positionAttr(mv.mesh.geometry)?.array as unknown as ArrayLike<number> | undefined)\n if (!arr) return out\n for (let i = mv.range[0] * 3; i < mv.range[1] * 3; i += 3) out.expandByPoint(this.t.set(arr[i], arr[i + 1], arr[i + 2]))\n return out\n }\n\n /**\n * The current positions of the mesh the part is drawn by (its dented copy when it has one) and the vertex range of the part in them, with what says they are the same\n * as before without reading them: the same `source` with the same `version` (and the same `shapeVersion` of the part) is the same vertices. A part of a merged mesh\n * counts its writes in `shapeVersion` (its source is the host); a mesh of its own is its position attribute and its `version`, so **every write of the positions of a\n * mesh bound here must set `needsUpdate`** (three.js bumps `version` there; a write that does not is not drawn after the first upload either). A writer of a merged mesh\n * declares its range with `markPositionsWritten` (game-shapes-three), which flags it.\n */\n positionsOf(mv: MeshVis): {\n readonly array: ArrayLike<number>\n readonly from: number\n readonly to: number\n readonly source: object\n readonly version: number\n /** The ranges another drawing collapses on the mesh (each to its first vertex): drawn so (`rebuildHost`) but not in `work`, so they are applied to what is measured. */\n readonly collapsed?: ReadonlyArray<readonly [number, number]>\n } | null {\n if (mv.host) this.follow(mv.host)\n const attribute = positionAttr(mv.mesh.geometry)\n const work = mv.host?.work\n const array = work ?? (attribute?.array as unknown as ArrayLike<number> | undefined)\n if (!array) return null\n const source: object = mv.host ?? (attribute as THREE_NS.BufferAttribute)\n const from = mv.range ? mv.range[0] : 0\n const to = mv.range ? mv.range[1] : array.length / 3\n const collapsed = work ? (mv.mesh.userData.collapsedRanges as ReadonlyArray<readonly [number, number]> | undefined) : undefined\n return { array, from, to, source, version: mv.host ? 0 : (attribute as THREE_NS.BufferAttribute).version, ...(collapsed?.length ? { collapsed } : {}) }\n }\n\n /**\n * Counts on the sharers' `shapeVersion` what was written to the mesh's own positions since the last look, while the parts are measured by them (`work` is null): the\n * ranges the writes declared (`markPositionsWritten`), or every part when one did not.\n */\n private follow(host: HostVis): void {\n if (host.work) {\n this.followCollapsed(host)\n return\n }\n const attribute = positionAttr(host.mesh.geometry)\n const seen = host.seen\n if (seen.attribute === attribute && (!attribute || seen.version === attribute.version)) return\n const ranges = attribute && seen.attribute === attribute ? rangesWrittenSince(attribute, seen.version) : null\n for (const s of host.sharers) {\n if (s.host !== host || !s.range) continue\n const [a, b] = s.range\n if (!ranges || ranges.some(([v0, v1]) => v0 < b && v1 > a)) s.shapeVersion++\n }\n host.seen = { attribute, version: attribute?.version ?? 0 }\n }\n\n /**\n * Once the mesh's positions are copied (`work`), what another drawing collapses is applied when measuring (`positionsOf`): a range it collapsed or drew again since the\n * last look counts on the sharers drawn there. The list is small (the walls of a house drawn with holes), so it is compared whole.\n */\n private followCollapsed(host: HostVis): void {\n const list = (host.mesh.userData.collapsedRanges as ReadonlyArray<readonly [number, number]> | undefined) ?? []\n const seen = host.collapsedSeen\n if (seen.length === list.length * 2 && list.every(([v0, v1], i) => seen[i * 2] === v0 && seen[i * 2 + 1] === v1)) return\n const now = list.flatMap(([v0, v1]) => [v0, v1])\n const changed: Array<readonly [number, number]> = []\n const has = (flat: readonly number[], v0: number, v1: number): boolean => {\n for (let i = 0; i < flat.length; i += 2) if (flat[i] === v0 && flat[i + 1] === v1) return true\n return false\n }\n for (let i = 0; i < now.length; i += 2) if (!has(seen, now[i]!, now[i + 1]!)) changed.push([now[i]!, now[i + 1]!])\n for (let i = 0; i < seen.length; i += 2) if (!has(now, seen[i]!, seen[i + 1]!)) changed.push([seen[i]!, seen[i + 1]!])\n for (const s of host.sharers) {\n if (s.host !== host || !s.range) continue\n const [a, b] = s.range\n if (changed.some(([v0, v1]) => v0 < b && v1 > a)) s.shapeVersion++\n }\n host.collapsedSeen = now\n }\n\n /** The part's positions changed where it is measured: it, and every part drawn by a range of the same mesh that overlaps its own, measures again (`drawnSolidsOf`). */\n private reshaped(mv: MeshVis): void {\n mv.shapeVersion++\n const host = mv.host\n const range = mv.range\n if (!host || !range) return\n for (const s of host.sharers) if (s !== mv && s.host === host && s.range && s.range[0] < range[1] && s.range[1] > range[0]) s.shapeVersion++\n }\n\n /** The part's vertices (a ranged part: its own range only) through `matrix` (from its mesh's space), appended to `out` as x y z. */\n rangePoints(mv: MeshVis, matrix: THREE_NS.Matrix4, out: number[]): void {\n const arr = mv.host?.work ?? (positionAttr(mv.mesh.geometry)?.array as unknown as ArrayLike<number> | undefined)\n if (!arr) return\n const from = mv.range ? mv.range[0] : 0\n const to = mv.range ? mv.range[1] : arr.length / 3\n for (let i = from * 3; i < to * 3; i += 3) {\n this.t.set(arr[i], arr[i + 1], arr[i + 2]).applyMatrix4(matrix)\n out.push(this.t.x, this.t.y, this.t.z)\n }\n }\n\n /** Box of the part in world space. */\n /** Appends the boxes that follow the mesh in the world (`pushFittedBoxes`) to `out`. */\n fittedBoxes(mv: MeshVis, out: number[]): void {\n const box = new this.THREE.Box3()\n if (mv.host) this.localBox(mv, box)\n else {\n const geometry = mv.mesh.geometry\n if (!geometry.boundingBox) geometry.computeBoundingBox()\n if (geometry.boundingBox) box.copy(geometry.boundingBox)\n else box.makeEmpty()\n }\n if (box.isEmpty()) return\n mv.mesh.updateWorldMatrix(true, false)\n pushFittedBoxes(box, mv.mesh.matrixWorld, out)\n }\n\n worldBox(mv: MeshVis, out: THREE_NS.Box3): THREE_NS.Box3 {\n if (!mv.host) return out.setFromObject(mv.mesh)\n this.localBox(mv, out)\n mv.mesh.updateWorldMatrix(true, false)\n return out.isEmpty() ? out : out.applyMatrix4(mv.mesh.matrixWorld)\n }\n\n private readonly tints = new WeakMap<MeshVis, THREE_NS.Color | null>()\n\n /**\n * Average vertex colour of a mesh whose material uses `vertexColors` (computed once per mesh, from its original geometry), else null. Fragments\n * and debris of such a mesh multiply it by `material.color`; without it they come out white.\n */\n vertexTint(mv: MeshVis): THREE_NS.Color | null {\n if (this.tints.has(mv)) return this.tints.get(mv) ?? null\n let tint: THREE_NS.Color | null = null\n const used = materialsOf(mv.origMaterial).some((m) => (m as THREE_NS.MeshStandardMaterial).vertexColors === true)\n const attr = used ? (mv.origGeometry.getAttribute('color') as THREE_NS.BufferAttribute | undefined) : undefined\n if (attr && attr.count > 0 && attr.itemSize >= 3) {\n // a ranged part averages its own vertices only\n const from = mv.merged ? mv.merged.range[0] : 0\n const to = mv.merged ? Math.min(attr.count, mv.merged.range[1]) : attr.count\n let r = 0, g = 0, b = 0\n for (let i = from; i < to; i++) {\n r += attr.getX(i)\n g += attr.getY(i)\n b += attr.getZ(i)\n }\n const n = Math.max(1, to - from)\n tint = new this.THREE.Color(r / n, g / n, b / n)\n }\n this.tints.set(mv, tint)\n return tint\n }\n\n /** Colour of the original material (before any char) times the vertex tint, `0xRRGGBB`, or -1. */\n baseColorHex(mv: MeshVis): number {\n const c = mv.baseColors?.[0] ?? colorOf(materialsOf(mv.origMaterial)[0])\n if (!c) return -1\n const tint = this.vertexTint(mv)\n return tint ? c.clone().multiply(tint).getHex() : c.getHex()\n }\n\n /** Is the original material transparent? */\n isTransparent(mv: MeshVis): boolean {\n return materialsOf(mv.origMaterial).some((m) => m.transparent && m.opacity < 1)\n }\n\n ownMaterial(mv: MeshVis): void {\n if (mv.ownMat) return\n mv.ownMat = true\n const src = materialsOf(mv.origMaterial)\n const cloned = src.map((m) => m.clone())\n mv.baseColors = src.map((m) => colorOf(m)?.clone() ?? new this.THREE.Color(0x888888))\n mv.mesh.material = Array.isArray(mv.origMaterial) ? cloned : cloned[0]\n }\n\n /** Clone the geometry (vertex edits); false when its positions cannot be edited. */\n ownGeometry(mv: MeshVis): boolean {\n if (mv.host) return this.ownHostGeometry(mv.host)\n if (mv.ownGeo) return true\n const pos = positionAttr(mv.mesh.geometry)\n if (!pos) return false\n mv.ownGeo = true\n const g = mv.mesh.geometry.clone()\n mv.mesh.geometry = g\n mv.work = new Float32Array((positionAttr(g) as THREE_NS.BufferAttribute).array as ArrayLike<number>)\n return true\n }\n\n private ownHostGeometry(host: HostVis): boolean {\n if (host.ownGeo) return true\n const pos = positionAttr(host.mesh.geometry)\n if (!pos) return false\n this.follow(host)\n host.ownGeo = true\n const g = host.mesh.geometry.clone()\n host.mesh.geometry = g\n const base = basePositions(host)\n host.work = new Float32Array(base ?? ((positionAttr(g) as THREE_NS.BufferAttribute).array as ArrayLike<number>))\n // the parts were measured by the mesh's positions: the first ones differ only where another drawing collapsed a range, and those parts measure again (from now on\n // with that range collapsed on what is measured, as it is drawn)\n if (base) for (const s of host.sharers) if (s.host === host && s.range && !sameRange(pos.array as ArrayLike<number>, base, s.range)) s.shapeVersion++\n host.collapsedSeen = ((host.mesh.userData.collapsedRanges as ReadonlyArray<readonly [number, number]> | undefined) ?? []).flatMap(([v0, v1]) => [v0, v1])\n return true\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Dents\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n /**\n * Push the vertices of the mesh within `dent.radius` of `worldPoint` inwards along `worldNormal` by `depth * (1 - (d/r)^2)^2`.\n * Returns false when nothing was changed (too far, low quality on a heavy mesh, or no editable positions).\n */\n applyDent(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, dent: Dent, reachWorld = 0): boolean {\n const mesh = mv.mesh\n if (this.lowQuality && this.vertexCount(mv) > 20000) return false\n mesh.updateWorldMatrix(true, false)\n const s = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n const lp = mesh.worldToLocal(this.a.copy(worldPoint))\n const ln = this.b.copy(worldNormal).transformDirection(this.m4.copy(mesh.matrixWorld).invert()).normalize()\n const r = Math.max(dent.radius, reachWorld) / s\n const depth = dent.depth / s\n // quick reject: the point must be near the mesh bounds\n const geo = mesh.geometry\n let bb: THREE_NS.Box3 | null\n if (mv.host) bb = this.localBox(mv, this.lbox)\n else {\n if (!geo.boundingBox) geo.computeBoundingBox()\n bb = geo.boundingBox\n }\n if (bb && !bb.isEmpty() && bb.distanceToPoint(lp) > r) return false\n if (!this.ownGeometry(mv)) return false\n const work = (mv.host ? mv.host.work : mv.work) as Float32Array\n const pos = positionAttr(mesh.geometry) as THREE_NS.BufferAttribute\n const from = mv.range ? mv.range[0] * 3 : 0\n const to = mv.range ? mv.range[1] * 3 : work.length\n const reach = r\n const reach2 = reach * reach\n for (let i = from; i < to; i += 3) {\n const dx = work[i] - lp.x\n const dy = work[i + 1] - lp.y\n const dz = work[i + 2] - lp.z\n const d2 = dx * dx + dy * dy + dz * dz\n if (d2 >= reach2) continue\n const f = 1 - d2 / reach2\n const k = depth * f * f\n work[i] -= ln.x * k\n work[i + 1] -= ln.y * k\n work[i + 2] -= ln.z * k\n }\n mv.touched = true\n this.reshaped(mv)\n this.writePositions(mv, pos)\n return true\n }\n\n /**\n * World radius a dent needs on this mesh to reach `MIN_DENT_VERTICES` vertices (the dent's own radius when the mesh is fine enough). A part with several meshes\n * (a shell and its label) must dent them all with the largest of these, so the skin and the shell follow the same smooth surface and never cross.\n */\n dentReach(mv: MeshVis, worldPoint: THREE_NS.Vector3, dent: Dent): number {\n const mesh = mv.mesh\n mesh.updateWorldMatrix(true, false)\n const s = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n const lp = mesh.worldToLocal(this.a.copy(worldPoint))\n const source = (mv.host ? mv.host.work : mv.work) ?? ((positionAttr(mesh.geometry) as THREE_NS.BufferAttribute | undefined)?.array as ArrayLike<number> | undefined)\n if (!source) return dent.radius\n // a mesh the dent does not touch (the far cap of a can) must not widen it\n let bounds: THREE_NS.Box3 | null\n if (mv.host) bounds = this.localBox(mv, this.lbox)\n else {\n if (!mesh.geometry.boundingBox) mesh.geometry.computeBoundingBox()\n bounds = mesh.geometry.boundingBox\n }\n if (bounds && !bounds.isEmpty() && bounds.distanceToPoint(lp) > dent.radius / s) return dent.radius\n const from = mv.range ? mv.range[0] * 3 : 0\n const to = mv.range ? mv.range[1] * 3 : source.length\n const r2 = (dent.radius / s) ** 2\n const distances: number[] = []\n let inside = 0\n for (let i = from; i < to; i += 3) {\n const dx = source[i]! - lp.x\n const dy = source[i + 1]! - lp.y\n const dz = source[i + 2]! - lp.z\n const d2 = dx * dx + dy * dy + dz * dz\n if (d2 < r2) inside++\n distances.push(d2)\n }\n if (inside >= MIN_DENT_VERTICES || distances.length < MIN_DENT_VERTICES) return dent.radius\n distances.sort((x, y) => x - y)\n const nearest = Math.sqrt(distances[0]!)\n return Math.max(dent.radius, Math.sqrt(distances[MIN_DENT_VERTICES - 1]!) * s * WIDEN_MARGIN, nearest * s * NEAREST_MARGIN)\n }\n\n /**\n * Dent all the meshes of a part. The shells take the dent as `applyDent` gives it; a skin (label, coat: `userData.destructionSkin`) sits a hair above its shell\n * and moves with the shell's surface instead (see `shellDisplacementAt`), so the shell never shows through it whatever the two meshes' vertex grids are.\n */\n applyPartDent(meshes: readonly MeshVis[], worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, dent: Dent, reachWorld: number): void {\n const isSkin = (mv: MeshVis): boolean => mv.mesh.userData.destructionSkin === true && !mv.host\n const shells = meshes.filter((mv) => !isSkin(mv))\n const snapshots: ShellSnapshot[] = []\n for (const mv of shells) {\n const heavy = this.lowQuality && this.vertexCount(mv) > 20000\n const plain = !mv.host && !heavy && this.ownGeometry(mv) && mv.work\n const before = plain ? new Float32Array(mv.work as Float32Array) : null\n this.applyDent(mv, worldPoint, worldNormal, dent, reachWorld)\n if (before) snapshots.push({ mesh: mv.mesh, before, after: mv.work as Float32Array })\n }\n const displacement = this.t\n const vertex = this.a\n for (const mv of meshes) {\n if (!isSkin(mv)) continue\n if (snapshots.length === 0) {\n this.applyDent(mv, worldPoint, worldNormal, dent, reachWorld)\n continue\n }\n if (!this.ownGeometry(mv)) continue\n const work = mv.work as Float32Array\n const mesh = mv.mesh\n mesh.updateWorldMatrix(true, false)\n const toLocal = this.m4.copy(mesh.matrixWorld).invert()\n const scale = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n let touched = false\n for (let i = 0; i < work.length; i += 3) {\n vertex.set(work[i]!, work[i + 1]!, work[i + 2]!).applyMatrix4(mesh.matrixWorld)\n if (vertex.distanceTo(worldPoint) > reachWorld) continue\n const height = shellDisplacementAt(this.THREE, vertex, snapshots, displacement)\n const length = displacement.length()\n if (length === 0) continue\n // the shell's facets lie outside a dip (deeper than the shell, the skin would sink under it) and inside a rim (the smooth dent is shallower there): take the shallower of the two\n const falloff = 1 - (vertex.distanceTo(worldPoint) / reachWorld) ** 2\n const smooth = dent.depth * falloff * falloff\n const pull = Math.max(0, Math.min(length, smooth) * SKIN_FOLLOW - SKIN_SLACK - height * SKIN_LAYER_SLACK)\n displacement.transformDirection(toLocal).multiplyScalar(pull / scale)\n work[i] += displacement.x\n work[i + 1] += displacement.y\n work[i + 2] += displacement.z\n touched = true\n }\n if (!touched) continue\n this.reshaped(mv)\n this.writePositions(mv, positionAttr(mesh.geometry) as THREE_NS.BufferAttribute)\n }\n }\n\n /**\n * Bend the mesh of a plate by `angle` about the line through `worldPoint` along `worldAxis`, turning what lies towards `worldSide` (see `bendPositions`).\n * Works on the same `work` positions as the dents, so a bend keeps the dents the plate already has. Returns false when the mesh could not be edited.\n */\n applyBend(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldAxis: THREE_NS.Vector3, worldSide: THREE_NS.Vector3, angle: number): boolean {\n const mesh = mv.mesh\n if (this.lowQuality && this.vertexCount(mv) > 20000) return false\n mesh.updateWorldMatrix(true, false)\n if (!this.ownGeometry(mv)) return false\n const scale = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n const toLocal = this.m4.copy(mesh.matrixWorld).invert()\n const point = mesh.worldToLocal(this.a.copy(worldPoint))\n const axis = this.b.copy(worldAxis).transformDirection(toLocal)\n const side = this.t.copy(worldSide).transformDirection(toLocal)\n const work = (mv.host ? mv.host.work : mv.work) as Float32Array\n const from = mv.range ? mv.range[0] * 3 : 0\n const to = mv.range ? mv.range[1] * 3 : work.length\n bendPositions(work, from, to, [point.x, point.y, point.z], [axis.x, axis.y, axis.z], [side.x, side.y, side.z], angle, BEND_SMOOTH_RADIUS / scale)\n mv.touched = true\n this.reshaped(mv)\n this.writePositions(mv, positionAttr(mesh.geometry) as THREE_NS.BufferAttribute)\n return true\n }\n\n /** Copy `work` (dents) into the geometry, adding the melt sag when the mesh is melting. */\n private writePositions(mv: MeshVis, pos: THREE_NS.BufferAttribute): void {\n if (mv.host) {\n this.rebuildHost(mv.host)\n return\n }\n const work = mv.work as Float32Array\n const arr = pos.array as unknown as Float32Array\n const melt = mv.meltApplied\n if (melt <= 0 || (this.lowQuality && work.length / 3 > 20000)) {\n arr.set(work)\n } else {\n const geo = mv.mesh.geometry\n if (!geo.boundingBox) geo.computeBoundingBox()\n const bb = geo.boundingBox as THREE_NS.Box3\n const h = Math.max(1e-4, bb.max.y - bb.min.y)\n const minY = bb.min.y\n for (let i = 0, v = 0; i < work.length; i += 3, v++) {\n const n = ((Math.imul(v + 1, 2654435761) >>> 0) % 1000) / 1000\n const n2 = ((Math.imul(v + 7, 40503) >>> 0) % 1000) / 1000\n const lowness = 1 - (work[i + 1] - minY) / h // 1 at the bottom, 0 at the top\n const spread = 1 + 0.12 * melt * (0.4 + n2) * (0.3 + lowness)\n arr[i] = work[i] * spread\n arr[i + 2] = work[i + 2] * spread\n arr[i + 1] = Math.max(minY, work[i + 1] - n * melt * h * 0.08)\n }\n }\n pos.needsUpdate = true\n const geo = mv.mesh.geometry\n geo.computeVertexNormals()\n geo.boundingBox = null\n geo.boundingSphere = null\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Decals\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n /**\n * The point on the drawn face of `mesh` under a world point, within `DECAL_SNAP` metres along the normal: the world's box of a part and the face\n * the renderer drew (a coat of plaster, a merged house mesh) can be a few millimetres apart, and a mark behind the drawn face does not show.\n */\n private onFace(mesh: Mesh, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3): THREE_NS.Vector3 {\n if (!(mesh as { isMesh?: boolean }).isMesh || !mesh.geometry?.attributes?.position) return worldPoint\n this.flushRebuilds(false, mesh)\n const n = worldNormal.clone().normalize()\n this.ray.set(worldPoint.clone().addScaledVector(n, DECAL_SNAP), n.clone().negate())\n this.ray.near = 0\n this.ray.far = 2 * DECAL_SNAP\n const hits: THREE_NS.Intersection[] = []\n this.meshRays.raycast(mesh, this.ray, hits)\n // a wall the house cut where it was shot is drawn by a mesh of its own next to the merged one (`breach-shell` of the house renderer); where it is\n // cut (`userData.cutAt`), the mark goes on what shows through (`userData.behind`: the bricks)\n for (const c of mesh.parent?.children ?? []) {\n if (c === mesh || c.name !== 'breach-shell') continue\n c.raycast(this.ray, hits)\n const behind = (c.userData.behind as (() => THREE_NS.Object3D | null) | undefined)?.()\n if (behind) behind.raycast(this.ray, hits)\n }\n let best: THREE_NS.Intersection | null = null\n for (const h of hits) {\n if ((h.object.userData.cutAt as ((p: THREE_NS.Vector3) => boolean) | undefined)?.(h.point)) continue\n if (h.face && h.face.normal.clone().transformDirection(h.object.matrixWorld).dot(n) <= 0.3) continue\n if (!best || Math.abs(h.distance - DECAL_SNAP) < Math.abs(best.distance - DECAL_SNAP)) best = h\n }\n return best ? best.point : worldPoint\n }\n\n /** Decal pose in mesh space: position and a rotation taking +Z to the surface normal. */\n private decalPose(mesh: Mesh, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, lift: number): { s: number; pos: THREE_NS.Vector3; quat: THREE_NS.Quaternion } {\n mesh.updateWorldMatrix(true, false)\n const s = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n const ln = worldNormal.clone().transformDirection(this.m4.copy(mesh.matrixWorld).invert()).normalize()\n const pos = mesh.worldToLocal(this.onFace(mesh, worldPoint, worldNormal).clone()).addScaledVector(ln, lift / s)\n const quat = new this.THREE.Quaternion().setFromUnitVectors(new this.THREE.Vector3(0, 0, 1), ln)\n return { s, pos, quat }\n }\n\n private addDecal(mv: MeshVis, decal: Decal): void {\n decal.obj.userData.destructionDebris = true\n mv.mesh.add(decal.obj)\n mv.decals.push(decal)\n this.decalCount++\n while (mv.decals.length > 48 || this.decalCount > this.decalCap) {\n const old = mv.decals.shift()\n if (!old) break\n this.disposeDecal(old)\n }\n }\n\n private disposeDecal(d: Decal): void {\n d.obj.parent?.remove(d.obj)\n d.geometry?.dispose()\n this.decalCount = Math.max(0, this.decalCount - 1)\n }\n\n /**\n * Takes away the decals of a mesh that sit inside a box (world `center`, `half` extents along the axes of the world `rotation`): the surface they\n * marked is gone (a unit came out of the wall with its bullet holes and spalls).\n */\n clearDecals(mv: MeshVis, center: THREE_NS.Vector3, half: THREE_NS.Vector3, rotation: THREE_NS.Quaternion): void {\n if (mv.decals.length === 0) return\n // every decal is a child of the mesh: its world position is the mesh's matrix applied to its own, so the chain up to the root is walked once, not once per decal\n mv.mesh.updateWorldMatrix(true, false)\n const inv = this.q.copy(rotation).invert()\n const p = this.a\n for (let i = mv.decals.length - 1; i >= 0; i--) {\n const d = mv.decals[i]!\n p.copy(d.obj.position).applyMatrix4(mv.mesh.matrixWorld).sub(center).applyQuaternion(inv)\n if (Math.abs(p.x) > half.x || Math.abs(p.y) > half.y || Math.abs(p.z) > half.z) continue\n this.disposeDecal(d)\n mv.decals.splice(i, 1)\n }\n }\n\n addHole(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, diameter: number): void {\n const { s, pos, quat } = this.decalPose(mv.mesh, worldPoint, worldNormal, 0.0025)\n const work = (mv.host ? mv.host.work : mv.work) as Float32Array | undefined\n if (work && mv.touched) {\n const ln = worldNormal.clone().transformDirection(this.m4.copy(mv.mesh.matrixWorld).invert()).normalize()\n let minDistSq = Infinity\n let nearestDisp = 0\n const from = mv.range ? mv.range[0] * 3 : 0\n const to = mv.range ? mv.range[1] * 3 : work.length\n for (let i = from; i < to; i += 3) {\n const dx = work[i]! - pos.x\n const dy = work[i + 1]! - pos.y\n const dz = work[i + 2]! - pos.z\n const d2 = dx * dx + dy * dy + dz * dz\n if (d2 < minDistSq) {\n minDistSq = d2\n nearestDisp = dx * ln.x + dy * ln.y + dz * ln.z\n }\n }\n if (minDistSq < (0.06 / s) ** 2 && nearestDisp < 0) {\n pos.addScaledVector(ln, nearestDisp)\n }\n }\n const disc = new this.THREE.Mesh(this.kit.discGeometry(), this.kit.discMaterial())\n disc.position.copy(pos)\n disc.quaternion.copy(quat)\n disc.scale.setScalar((Math.max(0.004, diameter) * 0.5 * 1.25) / s)\n disc.renderOrder = 2\n this.addDecal(mv, { obj: disc })\n }\n\n /** A patch where a surface coat came off, in the colour of the core under it; drawn under the bullet holes. */\n addSpall(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, radius: number, color: number): void {\n const { s, pos, quat } = this.decalPose(mv.mesh, worldPoint, worldNormal, 0.0015)\n const disc = new this.THREE.Mesh(this.kit.discGeometry(), this.kit.patchMaterial(color))\n disc.position.copy(pos)\n disc.quaternion.copy(quat)\n disc.scale.setScalar(Math.max(0.01, radius) / s)\n disc.renderOrder = 1\n this.addDecal(mv, { obj: disc })\n }\n\n /** A star of jagged lines: `rays` rays up to `length` metres, seeded so the same event always draws the same star. */\n addCrack(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, rays: number, length: number, color: number, seed: number): void {\n const { s, pos, quat } = this.decalPose(mv.mesh, worldPoint, worldNormal, 0.002)\n const rnd = createRng(seed)\n const verts: number[] = []\n const n = clamp(Math.round(rays), 3, 16)\n const L = Math.max(0.02, length) / s\n for (let r = 0; r < n; r++) {\n let ang = (r / n) * Math.PI * 2 + (rnd() - 0.5) * 0.5\n let x = 0\n let y = 0\n const segs = 3\n const total = L * (0.6 + 0.4 * rnd())\n for (let k = 0; k < segs; k++) {\n const step = (total / segs) * (0.7 + 0.6 * rnd())\n ang += (rnd() - 0.5) * 0.45\n const nx = x + Math.cos(ang) * step\n const ny = y + Math.sin(ang) * step\n verts.push(x, y, 0, nx, ny, 0)\n if (k > 0 && rnd() < 0.5) {\n const ba = ang + (rnd() < 0.5 ? -1 : 1) * (0.5 + rnd() * 0.5)\n const bl = step * (0.6 + 0.6 * rnd())\n verts.push(nx, ny, 0, nx + Math.cos(ba) * bl, ny + Math.sin(ba) * bl, 0)\n }\n x = nx\n y = ny\n }\n }\n // a faint ring around the impact\n const ringR = L * 0.12\n for (let k = 0; k < 8; k++) {\n const a0 = (k / 8) * Math.PI * 2\n const a1 = ((k + 1) / 8) * Math.PI * 2\n if (rnd() < 0.75) verts.push(Math.cos(a0) * ringR, Math.sin(a0) * ringR, 0, Math.cos(a1) * ringR, Math.sin(a1) * ringR, 0)\n }\n const geo = new this.THREE.BufferGeometry()\n geo.setAttribute('position', new this.THREE.Float32BufferAttribute(verts, 3))\n const lines = new this.THREE.LineSegments(geo, this.kit.lineMaterial(color))\n lines.position.copy(pos)\n lines.quaternion.copy(quat)\n lines.renderOrder = 2\n this.addDecal(mv, { obj: lines, geometry: geo })\n }\n\n /**\n * A stair-step crack through the joints of a wall (settlement): from `worldPoint` on the face whose outward normal is `worldNormal`, climbing toward\n * `worldToward` (the side that went down) one unit at a time, `width` metres wide at its start. A strip of triangles in the mesh's space, owned by the\n * part's marks: it goes with them (cleared, restored, disposed).\n */\n addStairCrack(mv: MeshVis, worldPoint: THREE_NS.Vector3, worldNormal: THREE_NS.Vector3, worldToward: THREE_NS.Vector3, spec: { length: number; step: readonly [number, number]; width: number; color: number; seed: number }): void {\n const mesh = mv.mesh\n mesh.updateWorldMatrix(true, false)\n const n = worldNormal.clone().normalize()\n const up = new this.THREE.Vector3(0, 1, 0).addScaledVector(n, -n.y).normalize()\n const side = worldToward.clone().addScaledVector(n, -worldToward.dot(n)).addScaledVector(up, -worldToward.dot(up))\n if (side.lengthSq() < 1e-8) side.crossVectors(up, n)\n side.normalize()\n const start = this.onFace(mesh, worldPoint, n).clone().addScaledVector(n, STAIR_CRACK_LIFT)\n const flat = stairCrackStrip(stairCrackPath({ length: spec.length, step: spec.step, seed: spec.seed }), spec.width, STAIR_CRACK_TAPER)\n // the strip is wound counter-clockwise from side x up; it has to face out of the wall\n const flip = new this.THREE.Vector3().crossVectors(side, up).dot(n) < 0\n const verts: number[] = []\n const point = this.a\n for (let i = 0; i < flat.length; i += 6) {\n const order = flip ? [0, 2, 1] : [0, 1, 2]\n for (const k of order) {\n point.copy(start).addScaledVector(side, flat[i + k * 2]!).addScaledVector(up, flat[i + k * 2 + 1]!)\n mesh.worldToLocal(point)\n verts.push(point.x, point.y, point.z)\n }\n }\n const geo = new this.THREE.BufferGeometry()\n geo.setAttribute('position', new this.THREE.Float32BufferAttribute(verts, 3))\n const strip = new this.THREE.Mesh(geo, this.kit.patchMaterial(spec.color))\n strip.renderOrder = 2\n this.addDecal(mv, { obj: strip, geometry: geo })\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Settlement\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n /**\n * Moves the part's vertices and its marks down by `dropAt(world point)` metres (negative: up), where each of them is: a part that settled more at\n * one end tilts. Writes the geometry unless `write` is false (several parts of one merged mesh are then written once by `commit`).\n */\n sink(mv: MeshVis, dropAt: (world: THREE_NS.Vector3) => number, write = true): boolean {\n if (!this.ownGeometry(mv)) return false\n const mesh = mv.mesh\n mesh.updateWorldMatrix(true, false)\n const scale = mesh.matrixWorld.getMaxScaleOnAxis() || 1\n const down = this.b.set(0, -1, 0).transformDirection(this.m4.copy(mesh.matrixWorld).invert())\n const work = (mv.host ? mv.host.work : mv.work) as Float32Array\n const from = mv.range ? mv.range[0] * 3 : 0\n const to = mv.range ? mv.range[1] * 3 : work.length\n const point = this.a\n for (let i = from; i < to; i += 3) {\n const d = dropAt(point.set(work[i]!, work[i + 1]!, work[i + 2]!).applyMatrix4(mesh.matrixWorld)) / scale\n work[i] += down.x * d\n work[i + 1] += down.y * d\n work[i + 2] += down.z * d\n }\n for (const decal of mv.decals) decal.obj.position.addScaledVector(down, dropAt(decal.obj.getWorldPosition(point)) / scale)\n mv.touched = true\n this.reshaped(mv)\n if (write) this.commit(mv)\n return true\n }\n\n /** Writes what `sink` moved into the geometry. */\n commit(mv: MeshVis): void {\n const pos = positionAttr(mv.mesh.geometry)\n if (pos) this.writePositions(mv, pos)\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Char and heat glow\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n setChar(pv: PartVis, char: number, charColor: number): void {\n if (Math.abs(char - pv.charApplied) < 0.004) return\n pv.charApplied = char\n const target = new this.THREE.Color(charColor)\n for (const mv of pv.meshes) {\n if (mv.host) {\n mv.charK = clamp(char, 0, 1)\n mv.charHex = charColor\n this.paint(mv)\n continue\n }\n this.ownMaterial(mv)\n const mats = materialsOf(mv.mesh.material)\n mats.forEach((m, i) => {\n const c = colorOf(m)\n const base = mv.baseColors?.[i]\n if (c && base) c.copy(base).lerp(target, clamp(char, 0, 1))\n })\n }\n }\n\n /** Emissive glow of a hot part. `temperature` below the glow threshold switches it off. */\n setGlow(pv: PartVis, temperatureC: number): void {\n const hex = heatColor(temperatureC)\n const key = hex === 0 ? 0 : Math.round(temperatureC / 5) * 5\n if (key === pv.glowApplied) return\n pv.glowApplied = key\n const intensity = hex === 0 ? 0 : clamp(0.35 + (temperatureC - 450) / 900, 0, 1.4)\n for (const mv of pv.meshes) {\n if (mv.host) {\n mv.glowHex = hex\n mv.glowK = intensity\n this.paint(mv)\n continue\n }\n this.ownMaterial(mv)\n for (const m of materialsOf(mv.mesh.material)) {\n const e = (m as THREE_NS.MeshStandardMaterial).emissive\n if (e && (e as THREE_NS.Color).isColor) {\n e.setHex(hex)\n ;(m as THREE_NS.MeshStandardMaterial).emissiveIntensity = intensity\n }\n }\n }\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Melt\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n /** Sag the part: shorter in Y (down to 25 %), a bit wider, vertices pushed down with noise, the bottom stays put. */\n setMelt(pv: PartVis, melt: number): void {\n const m = clamp(melt, 0, 1)\n if (Math.abs(m - pv.meltApplied) < 0.01) return\n pv.meltApplied = m\n for (const mv of pv.meshes) {\n const mesh = mv.mesh\n if (mv.host) {\n // a range of a shared mesh cannot scale the mesh: squash and widen its own vertices\n mv.meltApplied = m\n mv.touched = true\n this.reshaped(mv)\n if (!(this.lowQuality && this.vertexCount(mv) > 20000) && this.ownGeometry(mv)) this.rebuildHost(mv.host)\n continue\n }\n if (mv.meltApplied === 0 && m > 0) {\n mesh.updateWorldMatrix(true, false)\n mv.bottomY = this.box.setFromObject(mesh).min.y\n }\n mv.meltApplied = m\n mv.moved = true\n const sy = lerp(1, 0.25, m)\n const sxz = 1 + 0.18 * m\n mesh.scale.set(mv.origScale.x * sxz, mv.origScale.y * sy, mv.origScale.z * sxz)\n mesh.position.copy(mv.origPosition)\n mesh.updateWorldMatrix(true, false)\n const bottom = this.box.setFromObject(mesh).min.y\n const dy = mv.bottomY - bottom\n if (Math.abs(dy) > 1e-6 && mesh.parent) {\n mesh.parent.updateWorldMatrix(true, false)\n const inv = this.m4.copy(mesh.parent.matrixWorld).invert()\n this.a.set(0, dy, 0).applyMatrix4(inv)\n this.b.set(0, 0, 0).applyMatrix4(inv)\n mesh.position.copy(mv.origPosition).add(this.a.sub(this.b))\n }\n if (!(this.lowQuality && this.vertexCount(mv) > 20000) && this.ownGeometry(mv)) {\n this.reshaped(mv)\n this.writePositions(mv, positionAttr(mesh.geometry) as THREE_NS.BufferAttribute)\n }\n }\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Visibility and restore\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n hide(pv: PartVis, reason: PartVis['gone']): void {\n pv.gone = reason\n for (const mv of pv.meshes) {\n if (!mv.host || mv.loose) {\n mv.mesh.visible = false\n mv.hidden = true\n continue\n }\n // a range of a shared mesh: collapse its vertices to a point and hide what was drawn on it\n mv.hidden = true\n for (const d of mv.decals) d.obj.visible = false\n this.collapse(mv)\n }\n }\n\n // ------------------------------------------------------------------------------------------------------------------------------------\n // Parts drawn by a vertex range of a merged mesh\n // ------------------------------------------------------------------------------------------------------------------------------------\n\n /** Collapse the part's vertices in the merged mesh to one point (its triangles become degenerate and vanish). */\n private collapse(mv: MeshVis): void {\n if (!mv.merged || !this.ownHostGeometry(mv.merged.host)) return\n mv.collapsed = true\n mv.touched = true\n this.reshaped(mv)\n this.rebuildHost(mv.merged.host, true)\n }\n\n /** Within a batch (`batchRebuilds`): the merged meshes written once already, and whether a change since is still to be written. */\n private rebuildBatch: Map<HostVis, { stale: boolean; urgent: boolean }> | null = null\n\n /**\n * Runs `work`, writing a merged mesh into its geometry for the first change it sees and once more at the end if others followed, not once per change. The geometry is a function of what\n * the host keeps (`work`, the collapsed ranges, the melt), so the last write is the same as the last of many; the first stays because `extract` of the next part reads the normals that write leaves.\n */\n batchRebuilds(work: () => void): void {\n if (this.rebuildBatch) {\n work()\n return\n }\n const hosts = (this.rebuildBatch = new Map<HostVis, { stale: boolean; urgent: boolean }>())\n let failure: { readonly error: unknown } | undefined\n try {\n work()\n } finally {\n this.rebuildBatch = null\n // a host that fails to write neither skips the others nor replaces the error `work` threw\n for (const [host, state] of hosts) {\n if (!state.stale) continue\n try {\n this.writeHost(host)\n } catch (error) {\n failure ??= { error }\n }\n }\n }\n if (failure) throw failure.error\n }\n\n /** Write `work` into the geometry again with the melt of ranged parts and the collapsed ranges applied. */\n private rebuildHost(host: HostVis, isCollapse = false): void {\n const batch = this.rebuildBatch\n if (batch) {\n const seen = batch.get(host)\n if (seen) {\n seen.stale = true\n // a change of the part's own vertices (dent, melt) must be in the geometry before `extract` reads its normals; another part's collapse need not\n if (!isCollapse) seen.urgent = true\n return\n }\n batch.set(host, { stale: false, urgent: false })\n }\n this.writeHost(host)\n }\n\n /** Within a batch: writes the merged meshes with a pending change (only the `urgent` ones, or every stale one), so a read of the geometry sees what a write per change would have left. */\n private flushRebuilds(onlyUrgent: boolean, mesh?: Mesh): void {\n const batch = this.rebuildBatch\n if (!batch) return\n for (const [key, state] of batch) {\n if (!state.stale || (onlyUrgent && !state.urgent) || (mesh && key.mesh !== mesh)) continue\n state.stale = false\n state.urgent = false\n this.writeHost(key)\n }\n }\n\n /** Within a batch: writes every merged mesh with a pending change, for a reader of the geometry's bounds that is not tied to one mesh (`shownArea`, `clipToDrawn`). */\n flushPendingRebuilds(): void {\n this.flushRebuilds(false)\n }\n\n private writeHost(host: HostVis): void {\n const geo = host.mesh.geometry\n const pos = positionAttr(geo)\n const work = host.work\n if (!pos || !work) return\n const arr = pos.array as unknown as Float32Array\n arr.set(work)\n collapseForeign(host.mesh, arr)\n for (const s of host.sharers) {\n if (s.merged && s.merged.host === host) {\n if (s.collapsed) this.collapseRange(arr, s.merged.range)\n else if (s.meltApplied > 0 && !s.loose) this.meltRange(arr, work, s.merged.range, s.meltApplied)\n } else if (s.host === host && s.range && s.meltApplied > 0) this.meltRange(arr, work, s.range, s.meltApplied)\n }\n pos.needsUpdate = true\n geo.computeVertexNormals()\n geo.boundingBox = null\n geo.boundingSphere = null\n }\n\n private collapseRange(arr: Float32Array, range: [number, number]): void {\n const x = arr[range[0] * 3]\n const y = arr[range[0] * 3 + 1]\n const z = arr[range[0] * 3 + 2]\n for (let i = range[0] * 3; i < range[1] * 3; i += 3) {\n arr[i] = x\n arr[i + 1] = y\n arr[i + 2] = z\n }\n }\n\n /** Melt of one range: shorter in Y (down to 25 %) with the bottom fixed, a bit wider around its centre, with the same noise as a whole mesh. */\n private meltRange(arr: Float32Array, work: Float32Array, range: [number, number], melt: number): void {\n let minY = Infinity\n let maxY = -Infinity\n let cx = 0\n let cz = 0\n const n = Math.max(1, range[1] - range[0])\n for (let i = range[0] * 3; i < range[1] * 3; i += 3) {\n minY = Math.min(minY, work[i + 1])\n maxY = Math.max(maxY, work[i + 1])\n cx += work[i]\n cz += work[i + 2]\n }\n cx /= n\n cz /= n\n const h = Math.max(1e-4, maxY - minY)\n const sy = lerp(1, 0.25, melt)\n const sxz = 1 + 0.18 * melt\n for (let i = range[0] * 3, v = 0; i < range[1] * 3; i += 3, v++) {\n const noise = ((Math.imul(v + 1, 2654435761) >>> 0) % 1000) / 1000\n arr[i] = cx + (work[i] - cx) * sxz\n arr[i + 2] = cz + (work[i + 2] - cz) * sxz\n arr[i + 1] = Math.max(minY, minY + (work[i + 1] - minY) * sy - noise * melt * h * 0.04)\n }\n }\n\n /** The colour attribute of the host's current geometry (created white when there is none) with vertex colours switched on in its material. */\n private ensureColors(host: HostVis): THREE_NS.BufferAttribute | null {\n if (!this.ownHostGeometry(host)) return null\n const geo = host.mesh.geometry\n let attr = geo.getAttribute('color') as THREE_NS.BufferAttribute | undefined\n if (!attr) {\n const n = geo.getAttribute(POS_ATTR).count\n attr = new this.THREE.BufferAttribute(new Float32Array(n * 3).fill(1), 3)\n geo.setAttribute('color', attr)\n }\n if (!host.ownMat) {\n host.ownMat = true\n const src = materialsOf(host.mesh.material)\n const cloned = src.map((m) => m.clone())\n host.mesh.material = Array.isArray(host.mesh.material) ? cloned : cloned[0]\n }\n for (const m of materialsOf(host.mesh.material)) {\n if ((m as THREE_NS.MeshStandardMaterial).vertexColors !== true) {\n ;(m as THREE_NS.MeshStandardMaterial).vertexColors = true\n m.needsUpdate = true\n }\n }\n return attr\n }\n\n /** Colour of the part's vertices from the original colours, its char and its heat. Only the part's range is written. */\n private paint(mv: MeshVis): void {\n if (!mv.host || !mv.range || !mv.merged) return\n const idle = mv.charK <= 0 && mv.glowK <= 0\n if (idle && !mv.touched) return\n const attr = this.ensureColors(mv.host)\n if (!attr) return\n const size = attr.itemSize\n const arr = attr.array as unknown as Float32Array\n const orig = mv.merged.host.origGeometry.getAttribute('color') as THREE_NS.BufferAttribute | undefined\n const oSize = orig?.itemSize ?? 3\n const oArr = orig?.array as unknown as ArrayLike<number> | undefined\n const shift = mv.merged.range[0] - mv.range[0]\n const ch = new this.THREE.Color(mv.charHex)\n const heat = new this.THREE.Color(mv.glowHex)\n const k = clamp(mv.charK, 0, 1)\n const gk = clamp(mv.glowK, 0, 1)\n const boost = 1 + Math.max(0, mv.glowK - 1)\n for (let i = mv.range[0]; i < mv.range[1]; i++) {\n const o = (i + shift) * oSize\n let r = oArr ? oArr[o] : 1\n let g = oArr ? oArr[o + 1] : 1\n let b = oArr ? oArr[o + 2] : 1\n if (k > 0) {\n r = lerp(r, ch.r, k)\n g = lerp(g, ch.g, k)\n b = lerp(b, ch.b, k)\n }\n if (gk > 0) {\n r = lerp(r, heat.r * boost, gk)\n g = lerp(g, heat.g * boost, gk)\n b = lerp(b, heat.b * boost, gk)\n }\n arr[i * size] = r\n arr[i * size + 1] = g\n arr[i * size + 2] = b\n }\n mv.touched = true\n attr.needsUpdate = true\n }\n\n /**\n * Move a ranged part to a mesh of its own: the faces whose vertices all lie in its range are copied (with the current dents and colours) into a\n * new mesh that takes the merged mesh's transform and material, then attached to `group`; the range is collapsed in the merged mesh. Decals\n * go with it.\n */\n extract(mv: MeshVis, group: THREE_NS.Object3D): void {\n if (!mv.host || !mv.range || !mv.merged || mv.loose) return\n const host = mv.host\n this.flushRebuilds(true, host.mesh)\n const [v0, v1] = mv.range\n const src = host.mesh.geometry\n const geo = new this.THREE.BufferGeometry()\n const count = v1 - v0\n for (const name of Object.keys(src.attributes)) {\n const a = src.getAttribute(name) as THREE_NS.BufferAttribute\n if ((a as unknown as { isInterleavedBufferAttribute?: boolean }).isInterleavedBufferAttribute) continue\n const size = a.itemSize\n const from = (name === POS_ATTR ? plainPositions(host.mesh, v0, v1) ?? host.work : null) ?? (a.array as unknown as Float32Array)\n const slice = (from as unknown as { slice(a: number, b: number): ArrayLike<number> }).slice(v0 * size, v1 * size)\n const Ctor = (a.array as unknown as { constructor: new (x: ArrayLike<number>) => ArrayLike<number> }).constructor\n geo.setAttribute(name, new this.THREE.BufferAttribute(new Ctor(slice) as never, size, a.normalized))\n }\n const index = src.getIndex()\n if (index) {\n const out: number[] = []\n for (let i = 0; i + 2 < index.count; i += 3) {\n const a = index.getX(i)\n const b = index.getX(i + 1)\n const c = index.getX(i + 2)\n if (a >= v0 && a < v1 && b >= v0 && b < v1 && c >= v0 && c < v1) out.push(a - v0, b - v0, c - v0)\n }\n geo.setIndex(count > 65535 ? new this.THREE.Uint32BufferAttribute(out, 1) : new this.THREE.Uint16BufferAttribute(out, 1))\n }\n const mats = materialsOf(host.mesh.material).map((m) => m.clone())\n const loose = new this.THREE.Mesh(geo, mats[0])\n loose.name = `${host.mesh.name || 'mesh'}:${v0}-${v1}`\n loose.castShadow = host.mesh.castShadow\n loose.receiveShadow = host.mesh.receiveShadow\n loose.renderOrder = host.mesh.renderOrder\n loose.frustumCulled = host.mesh.frustumCulled\n loose.layers.mask = host.mesh.layers.mask\n loose.position.copy(host.mesh.position)\n loose.quaternion.copy(host.mesh.quaternion)\n loose.scale.copy(host.mesh.scale)\n const parent = host.mesh.parent\n if (parent) parent.add(loose)\n loose.updateMatrixWorld(true)\n // the merged mesh loses the range; the decals and the part's state follow the new mesh\n this.collapse(mv)\n for (const d of mv.decals) {\n d.obj.visible = true\n loose.add(d.obj)\n }\n const lp = positionAttr(geo) as THREE_NS.BufferAttribute\n const lh: HostVis = {\n mesh: loose,\n origGeometry: geo,\n origMaterial: loose.material,\n ownGeo: true,\n work: new Float32Array(lp.array as ArrayLike<number>),\n ownMat: true,\n sharers: [mv],\n seen: { attribute: lp, version: lp.version },\n collapsedSeen: [],\n }\n mv.host = lh\n mv.range = [0, count]\n mv.mesh = loose\n mv.loose = true\n mv.moved = true\n this.reshaped(mv)\n group.attach(loose)\n for (const m of materialsOf(loose.material)) m.needsUpdate = true\n }\n\n private restoreRanged(mv: MeshVis): void {\n const merged = mv.merged as NonNullable<MeshVis['merged']>\n const host = merged.host\n for (const d of mv.decals) this.disposeDecal(d)\n mv.decals.length = 0\n if (mv.loose) {\n const loose = mv.mesh\n loose.parent?.remove(loose)\n loose.geometry.dispose()\n for (const m of materialsOf(loose.material)) m.dispose()\n mv.host = host\n mv.range = [merged.range[0], merged.range[1]]\n mv.mesh = host.mesh\n mv.loose = false\n mv.moved = false\n }\n this.reshaped(mv)\n mv.collapsed = false\n mv.hidden = false\n mv.meltApplied = 0\n mv.charK = 0\n mv.glowK = 0\n mv.touched = false\n if (!host.ownGeo) return\n // positions and colours of the range go back to the original ones\n const work = host.work as Float32Array\n const op = basePositions(host)\n const [v0, v1] = merged.range\n if (op) work.set(op.subarray(v0 * 3, v1 * 3), v0 * 3)\n const attr = host.mesh.geometry.getAttribute('color') as THREE_NS.BufferAttribute | undefined\n if (attr) {\n const orig = host.origGeometry.getAttribute('color') as THREE_NS.BufferAttribute | undefined\n const size = attr.itemSize\n const a = attr.array as unknown as Float32Array\n for (let i = v0; i < v1; i++) {\n for (let c = 0; c < 3; c++) a[i * size + c] = orig ? orig.array[i * orig.itemSize + c] : 1\n }\n attr.needsUpdate = true\n }\n if (host.sharers.every((s) => !s.touched)) {\n host.mesh.geometry.dispose()\n host.mesh.geometry = host.origGeometry\n // the original geometry as it is now: its first positions, with what another drawing keeps collapsed\n const base = basePositions(host), back = positionAttr(host.origGeometry)\n if (base && back) {\n const arr = back.array as unknown as Float32Array\n arr.set(base)\n collapseForeign(host.mesh, arr)\n back.needsUpdate = true\n }\n host.work = null\n host.ownGeo = false\n // measured by the mesh's own positions again, from what was just written there\n host.seen = { attribute: back, version: back?.version ?? 0 }\n for (const s of host.sharers) if (s.host === host) s.shapeVersion++\n if (host.ownMat) {\n for (const m of materialsOf(host.mesh.material)) m.dispose()\n host.mesh.material = host.origMaterial\n host.ownMat = false\n }\n } else this.rebuildHost(host)\n }\n\n /** Bring one mesh back to how it was when it was bound. */\n restoreMesh(mv: MeshVis): void {\n if (mv.merged) {\n this.restoreRanged(mv)\n return\n }\n const mesh = mv.mesh\n for (const d of mv.decals) this.disposeDecal(d)\n mv.decals.length = 0\n this.reshaped(mv)\n if (mv.ownGeo) {\n mesh.geometry.dispose()\n mesh.geometry = mv.origGeometry\n mv.ownGeo = false\n mv.work = null\n }\n if (mv.ownMat) {\n for (const m of materialsOf(mesh.material)) m.dispose()\n mesh.material = mv.origMaterial\n mv.ownMat = false\n mv.baseColors = null\n }\n mesh.visible = mv.origVisible\n if (mv.origParent && mesh.parent !== mv.origParent) {\n mv.origParent.add(mesh)\n mv.moved = true\n }\n if (mv.moved) {\n mesh.position.copy(mv.origPosition)\n mesh.quaternion.copy(mv.origQuaternion)\n mesh.scale.copy(mv.origScale)\n mv.moved = false\n }\n mv.meltApplied = 0\n }\n\n restorePart(pv: PartVis): void {\n for (const mv of pv.meshes) this.restoreMesh(mv)\n delete pv.settled\n pv.charApplied = 0\n pv.glowApplied = 0\n pv.meltApplied = 0\n pv.gone = 'none'\n }\n\n dispose(): void {\n this.kit.dispose()\n }\n}\n","/** Metres: how far either side of the hinge the fold is rounded, so a bent plate shows a curve and not a crease. */\nexport const BEND_SMOOTH_RADIUS = 0.012\n\ntype Triple = readonly [number, number, number]\n\n/**\n * Bend the vertices `from..to` (indices into `positions`, three numbers each) of a plate by `angle` radians about the line through `point` along `axis`:\n * what lies beyond the hinge in the direction `side` turns about it, and the stretch of `radius` either side of the line turns by a share of the angle\n * (smoothstep), so the fold is rounded. All three are unit-free vectors in the positions' own space and `radius` is in that space.\n */\nexport function bendPositions(positions: Float32Array, from: number, to: number, point: Triple, axis: Triple, side: Triple, angle: number, radius: number): void {\n const length = Math.hypot(axis[0], axis[1], axis[2])\n if (length === 0 || angle === 0) return\n const [kx, ky, kz] = [axis[0] / length, axis[1] / length, axis[2] / length]\n for (let i = from; i < to; i += 3) {\n const rx = positions[i]! - point[0]\n const ry = positions[i + 1]! - point[1]\n const rz = positions[i + 2]! - point[2]\n const along = rx * side[0] + ry * side[1] + rz * side[2]\n const share = radius > 0 ? Math.min(1, Math.max(0, (along + radius) / (2 * radius))) : along > 0 ? 1 : 0\n if (share === 0) continue\n const turn = angle * share * share * (3 - 2 * share)\n const cos = Math.cos(turn)\n const sin = Math.sin(turn)\n const dot = kx * rx + ky * ry + kz * rz\n // Rodrigues' rotation of the offset from the hinge point about the unit axis\n positions[i] = point[0] + rx * cos + (ky * rz - kz * ry) * sin + kx * dot * (1 - cos)\n positions[i + 1] = point[1] + ry * cos + (kz * rx - kx * rz) * sin + ky * dot * (1 - cos)\n positions[i + 2] = point[2] + rz * cos + (kx * ry - ky * rx) * sin + kz * dot * (1 - cos)\n }\n}\n","import { mixHex } from './math'\n\n/** Blackbody-ish stops: [temperature °C, colour]. Luminance grows with the temperature. */\nconst STOPS: Array<[number, number]> = [\n [450, 0x000000],\n [500, 0x2a0400],\n [650, 0x8a1500],\n [800, 0xd84a08],\n [950, 0xff8c14],\n [1100, 0xffc23a],\n [1250, 0xffe8a0],\n [1400, 0xffffff],\n]\n\n/**\n * Glow colour of a hot surface as `0xRRGGBB`: black (no glow) below about 450 °C, dark red around 500, orange around 800, yellow around 1100 and\n * white from 1400 °C. Brightness never decreases as the temperature rises. Use it as an emissive colour.\n */\nexport function heatColor(temperatureC: number): number {\n if (!(temperatureC > STOPS[0][0])) return 0\n const last = STOPS[STOPS.length - 1]\n if (temperatureC >= last[0]) return last[1]\n for (let i = 1; i < STOPS.length; i++) {\n const [t1, c1] = STOPS[i]\n if (temperatureC <= t1) {\n const [t0, c0] = STOPS[i - 1]\n return mixHex(c0, c1, (temperatureC - t0) / (t1 - t0))\n }\n }\n return last[1]\n}\n","import type * as THREE_NS from 'three'\n\ntype TriangleBoxes = {\n array: ArrayLike<number>\n positionVersion: number\n indexArray: ArrayLike<number> | null\n indexVersion: number\n count: number\n boxes: Float32Array\n}\n\n/** Padding of the segment's box in the mesh's space, for the rounding of carrying it there. */\nconst SEGMENT_PADDING = 1e-6\n\n/**\n * Raycasts a mesh against a short segment without visiting every triangle: it keeps the box of each triangle until the mesh is written again, hands the triangles whose box meets the\n * segment to the mesh's own `raycast` (through a stand-in that shares its vertex buffers, material and matrix), and gives back the same hits as `mesh.raycast` would. A mesh the stand-in\n * cannot copy faithfully (skinned, morphed, several materials, an own `raycast`) goes to `mesh.raycast` itself.\n */\nexport class MeshRayProbe {\n private readonly cache = new WeakMap<THREE_NS.BufferGeometry, TriangleBoxes>()\n private readonly stand: THREE_NS.Mesh\n private readonly idleMaterial: THREE_NS.Material\n private builds = 0\n private readonly inverse: THREE_NS.Matrix4\n private readonly from: THREE_NS.Vector3\n private readonly to: THREE_NS.Vector3\n private candidates = new Uint32Array(64)\n private candidateIndex: THREE_NS.BufferAttribute\n private triangles = new Uint32Array(64)\n\n constructor(private readonly THREE: typeof THREE_NS) {\n this.idleMaterial = new THREE.MeshBasicMaterial()\n this.stand = new THREE.Mesh(new THREE.BufferGeometry(), this.idleMaterial)\n this.stand.matrixAutoUpdate = false\n this.inverse = new THREE.Matrix4()\n this.from = new THREE.Vector3()\n this.to = new THREE.Vector3()\n this.candidateIndex = new THREE.BufferAttribute(this.candidates, 1)\n }\n\n /** How many times the per-triangle boxes were (re)built. @internal */\n get boxBuildCount(): number {\n return this.builds\n }\n\n raycast(mesh: THREE_NS.Mesh, raycaster: THREE_NS.Raycaster, hits: THREE_NS.Intersection[]): void {\n const geometry = mesh.geometry\n const position = geometry.attributes.position as THREE_NS.BufferAttribute | undefined\n if (!this.canStandIn(mesh) || !position || !Number.isFinite(raycaster.far)) {\n mesh.raycast(raycaster, hits)\n return\n }\n // `mesh.raycast` computes a missing bounding sphere on every call, a ray that misses it included: the sphere keeps the vertices of that moment, and the golden scenes read it later\n if (mesh.material !== undefined && geometry.boundingSphere === null) geometry.computeBoundingSphere()\n const triangleBoxes = this.boxesOf(geometry, position)\n const found = this.collect(mesh, raycaster, triangleBoxes)\n if (found === 0) return\n const stand = this.stand\n const standGeometry = stand.geometry\n standGeometry.setIndex(this.candidateIndex)\n standGeometry.setDrawRange(0, found * 3)\n for (const name of ['position', 'normal', 'uv', 'uv1'] as const) {\n const attribute = geometry.attributes[name]\n if (attribute) standGeometry.setAttribute(name, attribute)\n else standGeometry.deleteAttribute(name)\n }\n standGeometry.boundingSphere = geometry.boundingSphere\n standGeometry.boundingBox = geometry.boundingBox\n stand.material = mesh.material\n stand.matrixWorld.copy(mesh.matrixWorld)\n const first = hits.length\n try {\n stand.raycast(raycaster, hits)\n } finally {\n this.release()\n }\n for (let i = first; i < hits.length; i++) {\n const hit = hits[i]!\n hit.object = mesh\n hit.faceIndex = this.triangles[hit.faceIndex ?? 0]!\n }\n }\n\n /** The stand-in lives as long as the probe: it must not keep the geometry or material of a mesh that is later discarded. */\n private release(): void {\n const stand = this.stand\n const standGeometry = stand.geometry\n for (const name of ['position', 'normal', 'uv', 'uv1'] as const) standGeometry.deleteAttribute(name)\n standGeometry.boundingSphere = null\n standGeometry.boundingBox = null\n stand.material = this.idleMaterial\n }\n\n private canStandIn(mesh: THREE_NS.Mesh): boolean {\n const geometry = mesh.geometry\n const position = geometry.attributes.position\n if (mesh.raycast !== this.THREE.Mesh.prototype.raycast || Array.isArray(mesh.material) || geometry.groups.length > 0) return false\n if ((mesh as { isSkinnedMesh?: boolean }).isSkinnedMesh || mesh.morphTargetInfluences || geometry.morphAttributes.position) return false\n if (!position || (position as { isInterleavedBufferAttribute?: boolean }).isInterleavedBufferAttribute) return false\n if (position.normalized || !(position.array instanceof Float32Array)) return false\n return geometry.drawRange.start % 3 === 0\n }\n\n /** The box of every triangle of the geometry, rebuilt when its vertex buffer or index was written since. */\n private boxesOf(geometry: THREE_NS.BufferGeometry, position: THREE_NS.BufferAttribute): TriangleBoxes {\n const index = geometry.index\n const count = Math.floor((index ? index.count : position.count) / 3)\n const seen = this.cache.get(geometry)\n if (seen && seen.array === position.array && seen.positionVersion === position.version && seen.indexArray === (index?.array ?? null) && seen.indexVersion === (index?.version ?? 0) && seen.count === count) return seen\n this.builds++\n const boxes = seen && seen.boxes.length === count * 6 ? seen.boxes : new Float32Array(count * 6)\n const vertices = position.array\n const ids = index?.array\n for (let t = 0; t < count; t++) {\n const a = (ids ? ids[t * 3]! : t * 3) * 3\n const b = (ids ? ids[t * 3 + 1]! : t * 3 + 1) * 3\n const c = (ids ? ids[t * 3 + 2]! : t * 3 + 2) * 3\n for (let axis = 0; axis < 3; axis++) {\n const va = vertices[a + axis]!\n const vb = vertices[b + axis]!\n const vc = vertices[c + axis]!\n boxes[t * 6 + axis] = Math.min(va, vb, vc)\n boxes[t * 6 + 3 + axis] = Math.max(va, vb, vc)\n }\n }\n const built: TriangleBoxes = { array: position.array, positionVersion: position.version, indexArray: index?.array ?? null, indexVersion: index?.version ?? 0, count, boxes }\n this.cache.set(geometry, built)\n return built\n }\n\n /** Fills `candidates` with the vertex ids of the triangles whose box meets the ray's segment (in the mesh's space) and `triangles` with their numbers; returns how many. */\n private collect(mesh: THREE_NS.Mesh, raycaster: THREE_NS.Raycaster, { boxes, count }: TriangleBoxes): number {\n const geometry = mesh.geometry\n const ids = geometry.index?.array\n this.inverse.copy(mesh.matrixWorld).invert()\n const ray = raycaster.ray\n const from = this.from.copy(ray.origin).applyMatrix4(this.inverse)\n const to = this.to.copy(ray.direction).multiplyScalar(raycaster.far).add(ray.origin).applyMatrix4(this.inverse)\n const pad = SEGMENT_PADDING * (1 + Math.max(Math.abs(from.x), Math.abs(from.y), Math.abs(from.z), Math.abs(to.x), Math.abs(to.y), Math.abs(to.z)))\n const lowX = Math.min(from.x, to.x) - pad\n const lowY = Math.min(from.y, to.y) - pad\n const lowZ = Math.min(from.z, to.z) - pad\n const highX = Math.max(from.x, to.x) + pad\n const highY = Math.max(from.y, to.y) + pad\n const highZ = Math.max(from.z, to.z) + pad\n const first = Math.max(0, geometry.drawRange.start / 3)\n const last = Math.min(count, Math.ceil((geometry.drawRange.start + geometry.drawRange.count) / 3))\n let found = 0\n for (let t = first; t < last; t++) {\n const k = t * 6\n if (boxes[k + 3]! < lowX || boxes[k]! > highX || boxes[k + 4]! < lowY || boxes[k + 1]! > highY || boxes[k + 5]! < lowZ || boxes[k + 2]! > highZ) continue\n this.reserve(found + 1)\n for (let corner = 0; corner < 3; corner++) this.candidates[found * 3 + corner] = ids ? ids[t * 3 + corner]! : t * 3 + corner\n this.triangles[found++] = t\n }\n return found\n }\n\n private reserve(triangleCount: number): void {\n if (triangleCount * 3 <= this.candidates.length) return\n const size = Math.max(triangleCount * 3, this.candidates.length * 2)\n const grown = new Uint32Array(size)\n grown.set(this.candidates)\n this.candidates = grown\n const numbers = new Uint32Array(Math.max(this.triangles.length, Math.ceil(size / 3)))\n numbers.set(this.triangles)\n this.triangles = numbers\n this.candidateIndex = new this.THREE.BufferAttribute(this.candidates, 1)\n }\n}\n","import type * as THREE_NS from 'three'\n\n/** A shell mesh with its vertex positions before and after a dent, both in its own local space. */\nexport type ShellSnapshot = {\n readonly mesh: THREE_NS.Mesh\n readonly before: ArrayLike<number>\n readonly after: ArrayLike<number>\n}\n\n/**\n * How far the surface of the shells moved where `worldPoint` (a vertex of a skin: a label, a coat) lies on it, as a world vector: the displacement of the\n * nearest shell triangle, interpolated by barycentric weights. A skin that takes it moves with the shell, whatever the two meshes' vertex grids are.\n * Returns the distance (world metres) from the point to that triangle, how high above the shell the skin lies.\n */\nexport function shellDisplacementAt(THREE: typeof THREE_NS, worldPoint: THREE_NS.Vector3, shells: readonly ShellSnapshot[], out: THREE_NS.Vector3): number {\n const triangle = new THREE.Triangle()\n const corners = [new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3()] as const\n const local = new THREE.Vector3()\n const closest = new THREE.Vector3()\n const weights = new THREE.Vector3()\n const moved = new THREE.Vector3()\n let nearest = Infinity\n out.set(0, 0, 0)\n let nearestScale = 1\n for (const shell of shells) {\n shell.mesh.updateWorldMatrix(true, false)\n shell.mesh.worldToLocal(local.copy(worldPoint))\n const index = shell.mesh.geometry.index\n const triangles = index ? index.count / 3 : shell.before.length / 9\n for (let t = 0; t < triangles; t++) {\n const ids = [0, 1, 2].map((corner) => (index ? index.getX(t * 3 + corner) : t * 3 + corner))\n ids.forEach((id, corner) => corners[corner]!.set(shell.before[id * 3]!, shell.before[id * 3 + 1]!, shell.before[id * 3 + 2]!))\n triangle.set(corners[0], corners[1], corners[2])\n // a degenerate triangle (the tip of a lathe on its axis, the doubled rim of a can) has no surface to follow and no closest point (NaN must never win)\n if (triangle.getArea() <= 1e-14) continue\n triangle.closestPointToPoint(local, closest)\n const distance = closest.distanceToSquared(local)\n if (!(distance < nearest)) continue\n nearest = distance\n nearestScale = shell.mesh.matrixWorld.getMaxScaleOnAxis() || 1\n triangle.getBarycoord(closest, weights)\n moved.set(0, 0, 0)\n ids.forEach((id, corner) => {\n const weight = corner === 0 ? weights.x : corner === 1 ? weights.y : weights.z\n moved.x += weight * (shell.after[id * 3]! - shell.before[id * 3]!)\n moved.y += weight * (shell.after[id * 3 + 1]! - shell.before[id * 3 + 1]!)\n moved.z += weight * (shell.after[id * 3 + 2]! - shell.before[id * 3 + 2]!)\n })\n out.copy(moved).transformDirection(shell.mesh.matrixWorld)\n out.multiplyScalar(moved.length() * (shell.mesh.matrixWorld.getMaxScaleOnAxis() || 1))\n }\n }\n return Math.sqrt(nearest) * nearestScale\n}\n","import { createRng } from './math'\n\n/**\n * The path of a stair-step crack in a wall of units, in the wall's plane: `h` metres toward the side that went down, `u` metres up. In running bond a\n * crack through the joints goes half a unit along a bed joint and one course up a head joint, again and again, so it climbs at about 45 degrees for a\n * brick of 19 x 9 cm. `step` is the run of one unit and the rise of one course; `seed` makes the same crack every time.\n */\nexport function stairCrackPath(spec: { readonly length: number; readonly step: readonly [number, number]; readonly seed: number }): Array<[number, number]> {\n const rnd = createRng(spec.seed)\n const run = Math.max(0.02, spec.step[0] / 2)\n const rise = Math.max(0.02, spec.step[1])\n const points: Array<[number, number]> = [[0, 0]]\n let h = 0\n let u = 0\n let walked = 0\n while (walked < spec.length) {\n // a head joint is not always the next one along: now and then the crack runs on a whole unit before it climbs\n const along = run * (rnd() < 0.2 ? 2 : 1)\n h += along\n points.push([h, u])\n u += rise\n points.push([h, u])\n walked += along + rise\n }\n return points\n}\n\n/**\n * The crack as a strip of triangles over the path, `width` metres wide at its start and narrowing to `taper` of that at its end: flat (`h`, `u`)\n * pairs, three points a triangle, wound counter-clockwise seen from +h × +u.\n */\nexport function stairCrackStrip(points: ReadonlyArray<readonly [number, number]>, width: number, taper: number): number[] {\n const out: number[] = []\n const n = points.length - 1\n for (let k = 0; k < n; k++) {\n const [h0, u0] = points[k]!\n const [h1, u1] = points[k + 1]!\n const length = Math.hypot(h1 - h0, u1 - u0) || 1\n const half0 = (width * (1 - ((1 - taper) * k) / n)) / 2\n const half1 = (width * (1 - ((1 - taper) * (k + 1)) / n)) / 2\n // the side of the segment, and a joint's worth past each end so the steps meet without gaps\n const sh = -(u1 - u0) / length\n const su = (h1 - h0) / length\n const eh = ((h1 - h0) / length) * half0\n const eu = ((u1 - u0) / length) * half0\n const a: [number, number] = [h0 - eh - sh * half0, u0 - eu - su * half0]\n const b: [number, number] = [h1 + eh - sh * half1, u1 + eu - su * half1]\n const c: [number, number] = [h1 + eh + sh * half1, u1 + eu + su * half1]\n const d: [number, number] = [h0 - eh + sh * half0, u0 - eu + su * half0]\n out.push(...a, ...b, ...c, ...a, ...c, ...d)\n }\n return out\n}\n","import type * as THREE_NS from 'three'\nimport { settlementAt } from '@adatechnology/game-destruction'\nimport type { PartSettlement, Vec3 } from '@adatechnology/game-destruction'\nimport type { HostVis, MeshVis, PartVis } from './internal'\nimport type { Visuals } from './visual'\n\n/** Seconds a settlement takes to show: the ground slumps into the hole over about a second, it does not jump. */\nexport const SETTLE_SECONDS = 1.2\n/** Seconds between two redraws of a settling part (a merged house mesh is written again each time). */\nconst SETTLE_REDRAW = 0.1\n\ninterface Settling {\n pv: PartVis\n root: THREE_NS.Object3D\n /** The settlement drawn when this one started, and where it goes. */\n start: PartSettlement | undefined\n target: PartSettlement\n /** Share of the way already drawn, 0..1, and seconds since it started. */\n shown: number\n elapsed: number\n lastDrawn: number\n}\n\nconst dropOf = (line: PartSettlement | undefined, point: Vec3): number => (line ? settlementAt(line, point) : 0)\nconst sameLine = (a: PartSettlement | undefined, b: PartSettlement): boolean =>\n !!a && a.drop.length === b.drop.length && a.drop.every((v, k) => v === b.drop[k]) && a.from.every((v, k) => v === b.from[k]) && a.to.every((v, k) => v === b.to[k])\n\n/**\n * Draws the settlement of the parts the ground went down under (`PartState.settlement`): each point of a part goes down by the drop at its place along\n * the settlement line (so a part that went down more at one end tilts), smoothly over `SETTLE_SECONDS`, its marks with it.\n */\nexport class SettlementView {\n private readonly moving = new Map<PartVis, Settling>()\n private readonly local: THREE_NS.Vector3\n private readonly inverse: THREE_NS.Matrix4\n\n constructor(THREE: typeof THREE_NS, private readonly visuals: Visuals) {\n this.local = new THREE.Vector3()\n this.inverse = new THREE.Matrix4()\n }\n\n /** The parts of an object (`root` draws it in object space) and their settlement now: those that changed start going to it. */\n follow(root: THREE_NS.Object3D, parts: Iterable<readonly [PartVis, PartSettlement | undefined]>): void {\n for (const [pv, target] of parts) {\n if (!target || pv.gone !== 'none' || sameLine(this.moving.get(pv)?.target ?? pv.settled, target)) continue\n this.finish(pv)\n this.moving.set(pv, { pv, root, start: pv.settled, target, shown: 0, elapsed: 0, lastDrawn: -SETTLE_REDRAW })\n }\n }\n\n get count(): number {\n return this.moving.size\n }\n\n update(dt: number): void {\n for (const s of this.moving.values()) {\n s.elapsed += dt\n const done = s.elapsed >= SETTLE_SECONDS\n if (!done && s.elapsed - s.lastDrawn < SETTLE_REDRAW) continue\n s.lastDrawn = s.elapsed\n const t = Math.min(1, s.elapsed / SETTLE_SECONDS)\n this.draw(s, t * t * (3 - 2 * t))\n if (done) {\n s.pv.settled = s.target\n this.moving.delete(s.pv)\n }\n }\n }\n\n /** Draws the rest of a part's settlement at once (it is about to be split off or put back). */\n finish(pv: PartVis): void {\n const s = this.moving.get(pv)\n if (!s) return\n this.draw(s, 1)\n pv.settled = s.target\n this.moving.delete(pv)\n }\n\n /** Forget a part without drawing (it was put back as it was). */\n forget(pv: PartVis): void {\n this.moving.delete(pv)\n }\n\n clear(): void {\n this.moving.clear()\n }\n\n private draw(s: Settling, shown: number): void {\n const share = shown - s.shown\n if (share <= 0) return\n s.shown = shown\n s.root.updateWorldMatrix(true, false)\n this.inverse.copy(s.root.matrixWorld).invert()\n const dropAt = (world: THREE_NS.Vector3): number => {\n const p = this.local.copy(world).applyMatrix4(this.inverse)\n const at: Vec3 = [p.x, p.y, p.z]\n return (dropOf(s.target, at) - dropOf(s.start, at)) * share\n }\n // the meshes the part shares with others are written once each\n const writes = new Map<HostVis | MeshVis, MeshVis>()\n for (const mv of s.pv.meshes) if (this.visuals.sink(mv, dropAt, false)) writes.set(mv.host ?? mv, mv)\n for (const mv of writes.values()) this.visuals.commit(mv)\n }\n}\n","import type * as THREE_NS from 'three'\nimport { DEFERRED_QUEUE_ID, kitOriginOf, markKitOrigin } from '@adatechnology/game-contracts'\nimport type { DeferredQueue, KitOrigin } from '@adatechnology/game-contracts'\nimport { BATCHED_LAYER, createStaticBatchQueue, createStaticBatcher } from '@adatechnology/game-render-three'\nimport type { StaticBatcher } from '@adatechnology/game-render-three'\n\n/** How the debris at rest is drawn in batches (`RendererOptions.settledBatches`). */\nexport interface SettledBatchOptions {\n /** Draw the debris at rest in batches (default true). */\n readonly enabled?: boolean\n /** Debris meshes at rest outside a batch before the batches are made again (default 16). */\n readonly minMeshes?: number\n /** Seconds at least between two makings of the batches (default 1). */\n readonly intervalSeconds?: number\n /** Milliseconds of merging per update while the batches are made, with no frame budget running the queue (default 2): what is not merged yet draws on its own meanwhile. */\n readonly budgetMs?: number\n /** Vertices of the largest mesh a batch takes (default 4000): a bigger one (a slab come down whole) draws on its own. */\n readonly maxVertices?: number\n}\n\n/** What the batches of the debris at rest hold now (`DestructionRenderer.settledBatchStats`). */\nexport interface SettledBatchStats {\n /** Draws of the batches: one per material, shadow and attribute set. */\n readonly batches: number\n /** Debris meshes drawn by a batch instead of on their own. */\n readonly batched: number\n}\n\nexport const SETTLED_BATCH_DEFAULTS: Required<SettledBatchOptions> = { enabled: true, minMeshes: 16, intervalSeconds: 1, budgetMs: 2, maxVertices: 4000 }\n\n/** Keys of a material that say nothing about how it draws. */\nconst IDENTITY_KEYS: ReadonlySet<string> = new Set(['uuid', 'id', 'name', 'version', 'userData', '_listeners'])\n\ntype Described = { readonly isColor?: boolean; readonly isTexture?: boolean; readonly isVector2?: boolean; getHexString?: () => string; readonly uuid?: string; readonly x?: number; readonly y?: number }\n\n/** One setting of a material as text, or undefined when it cannot be told (a function, an unknown object): then the material is batched only with itself. */\nconst settingText = (value: unknown): string | undefined => {\n if (value === null || typeof value === 'number' || typeof value === 'boolean' || typeof value === 'string') return String(value)\n if (typeof value !== 'object') return undefined\n const described = value as Described\n if (described.isColor === true) return described.getHexString?.()\n if (described.isTexture === true) return described.uuid\n if (described.isVector2 === true) return `${described.x},${described.y}`\n // `defines` and the like: plain data\n if (Object.getPrototypeOf(value) === Object.prototype) {\n try {\n return JSON.stringify(value)\n } catch {\n return undefined\n }\n }\n return undefined\n}\n\n/**\n * What tells materials apart for the batches: its type and every setting it has. The renderer gives a mesh it chars or tints its own copy of its material, so the debris of one\n * wall or one kind of board carries many copies that draw the same; equal keys put them in one batch.\n */\nexport const materialKey = (material: THREE_NS.Material): string => {\n const record = material as unknown as Record<string, unknown>\n const settings: string[] = [material.type]\n for (const key of Object.keys(record).sort()) {\n // data a host keeps on it may mean anything to the host: such a material is batched only with itself\n if (key === 'userData' && Object.keys(material.userData).length > 0) return material.uuid\n if (IDENTITY_KEYS.has(key)) continue\n const text = settingText(record[key])\n if (text === undefined) return material.uuid\n settings.push(`${key}=${text}`)\n }\n return settings.join('|')\n}\n\n/** Where the batches come from when their meshes do not all come from one piece of the kit. */\nexport const SETTLED_BATCH_ORIGIN: KitOrigin = { owner: 'game-destruction-three', kind: 'debris' }\n\n/** The origin every one of `meshes` has (owner, kind and id alike), or null when they differ or one has none. */\nconst commonOrigin = (meshes: readonly THREE_NS.Mesh[]): KitOrigin | null => {\n const first = kitOriginOf(meshes[0])\n if (!first) return null\n for (const mesh of meshes) {\n const origin = kitOriginOf(mesh)\n if (!origin || origin.owner !== first.owner || origin.kind !== first.kind || origin.id !== first.id) return null\n }\n return first\n}\n\n/** A batch draws as the pieces it batches: their origin when they share one, the debris' otherwise (the group). */\nconst markBatch = (batch: THREE_NS.Mesh, meshes: readonly THREE_NS.Mesh[]): void => {\n const origin = commonOrigin(meshes)\n if (origin) markKitOrigin(batch, origin)\n}\n\n/** Whether a debris mesh at rest can be drawn by a batch: one opaque material, its own camera layer, not too big. */\nexport const isBatchableDebris = (mesh: THREE_NS.Mesh, maxVertices: number): boolean => {\n const material = mesh.material\n if (Array.isArray(material) || material.transparent) return false\n // a mesh another batcher already draws (the host's, `createStaticBatcher`) is left to it\n if (mesh.layers.isEnabled(BATCHED_LAYER)) return false\n return (mesh.geometry.attributes.position?.count ?? Infinity) <= maxVertices\n}\n\n/**\n * The debris at rest (pieces and fragments asleep) drawn as a batch per material instead of a draw each (`createStaticBatcher` of game-render-three). Only the drawing changes:\n * every mesh stays where it lies, with its collision, and the moment one moves, is hit, dented, hidden or removed it draws on its own again. The batches are made again,\n * from all the debris at rest, once enough of it lies outside them; the old ones are disposed. Making them is a `DeferredQueue` (`queue`, id `destruction.settled-batch`),\n * a unit being the merge of the meshes of one material; with no frame budget registered, `update` drains it for `budgetMs`.\n */\nexport class SettledBatches {\n private readonly options: Required<SettledBatchOptions>\n private batcher: StaticBatcher | null = null\n /** The meshes given to the batcher when it was made. */\n private members = new Set<THREE_NS.Mesh>()\n private sinceMade = Infinity\n private readonly staticQueue = createStaticBatchQueue({ id: DEFERRED_QUEUE_ID.SETTLED_BATCH })\n\n /** The merges still waiting, for a shared frame budget; asking for it changes nothing. */\n readonly queue: DeferredQueue = this.staticQueue.deferredQueue()\n\n constructor(\n private readonly THREE: typeof THREE_NS,\n private readonly scene: THREE_NS.Scene,\n options: SettledBatchOptions = {},\n ) {\n this.options = { ...SETTLED_BATCH_DEFAULTS, ...options }\n }\n\n /** Gives back to its own draw whatever changed, and makes the batches again when `atRest` (the debris meshes at rest) has enough outside them. Once per frame, after the bodies moved. */\n update(dt: number, atRest: () => THREE_NS.Mesh[]): void {\n this.batcher?.update()\n this.sinceMade += dt\n if (!this.options.enabled || this.sinceMade < this.options.intervalSeconds) return\n const meshes = atRest().filter((mesh) => isBatchableDebris(mesh, this.options.maxVertices) || this.batched(mesh))\n const outside = meshes.length - (this.batcher?.stats().batched ?? 0)\n if (outside < this.options.minMeshes) return\n this.make(meshes)\n }\n\n stats(): SettledBatchStats {\n const stats = this.batcher?.stats()\n return { batches: this.batcher ? this.batcher.group.children.filter((child) => child.visible).length : 0, batched: stats?.batched ?? 0 }\n }\n\n /** Whether any mesh is given to the batches now: with none, `release` has nothing to do for any meshes. */\n hasMembers(): boolean {\n return this.members.size > 0\n }\n\n /**\n * Something happened to one of `meshes` (a blow, fire, char): if any is drawn by a batch, every mesh draws on its own again at once and the batches are made again after\n * `intervalSeconds`. A change the batcher cannot see (a colour written in place) never shows late.\n */\n release(meshes: readonly THREE_NS.Mesh[]): void {\n if (this.members.size === 0 || !meshes.some((mesh) => this.batched(mesh))) return\n this.clear()\n this.sinceMade = 0\n }\n\n /** Every debris mesh draws on its own again and the batches are disposed. */\n clear(): void {\n this.batcher?.dispose()\n this.batcher = null\n this.members = new Set()\n this.sinceMade = Infinity\n }\n\n /** Drawn by one of these batches now (given to it, and not given back). */\n private batched(mesh: THREE_NS.Mesh): boolean {\n return this.members.has(mesh) && mesh.layers.isEnabled(BATCHED_LAYER)\n }\n\n /** Disposes the old batches and plans the new ones: a unit of the queue per material key and chunk (a lone mesh has no one to batch with). */\n private make(meshes: THREE_NS.Mesh[]): void {\n this.batcher?.dispose()\n const take = new Set(meshes)\n this.members = take\n this.batcher = createStaticBatcher(this.THREE, this.scene, { include: (mesh) => take.has(mesh), budgetMs: this.options.budgetMs, materialKey, onBatch: markBatch, queue: this.staticQueue })\n this.batcher.group.name = 'settled-debris-batches'\n markKitOrigin(this.batcher.group, SETTLED_BATCH_ORIGIN)\n this.sinceMade = 0\n }\n}\n","import type * as THREE_NS from 'three'\nimport type { Vec3 } from '@adatechnology/game-destruction'\nimport type { MeshVis } from './internal'\n\n/**\n * Where a lasting emitter (grit trickling off a broken face) sits on the mesh it came off, in that mesh's own space: it goes wherever the mesh goes\n * (the object tips, a loose group falls as a piece of its own), never left pouring where the object stood. `mv.mesh` is read each time, so a part\n * moved to a mesh of its own (`Visuals.extract`, same space) keeps it.\n */\nexport interface EmitterAnchor {\n readonly mv: MeshVis\n readonly local: Vec3\n readonly localNormal: Vec3\n}\n\ntype ThreeMath = Pick<typeof THREE_NS, 'Vector3' | 'Matrix4'>\n\nexport function anchorOnMesh(THREE: ThreeMath, mv: MeshVis, point: Vec3, normal: Vec3): EmitterAnchor {\n mv.mesh.updateWorldMatrix(true, false)\n const inverse = new THREE.Matrix4().copy(mv.mesh.matrixWorld).invert()\n const local = new THREE.Vector3(point[0], point[1], point[2]).applyMatrix4(inverse)\n const localNormal = new THREE.Vector3(normal[0], normal[1], normal[2]).transformDirection(inverse)\n return { mv, local: [local.x, local.y, local.z], localNormal: [localNormal.x, localNormal.y, localNormal.z] }\n}\n\nfunction inScene(object: THREE_NS.Object3D): boolean {\n let top = object\n while (top.parent) top = top.parent\n return (top as THREE_NS.Scene).isScene === true\n}\n\n/**\n * Writes where the anchor is now (world point, world normal). False when there is nothing left to emit from: the mesh is no longer shown (the part\n * broke into fragments, burnt away) or no longer in a scene (restored away, discarded).\n */\nexport function anchorWorld(anchor: EmitterAnchor, shown: boolean, point: THREE_NS.Vector3, normal: THREE_NS.Vector3): boolean {\n const mesh = anchor.mv.mesh\n if (!shown || !inScene(mesh)) return false\n mesh.updateWorldMatrix(true, false)\n point.set(anchor.local[0], anchor.local[1], anchor.local[2]).applyMatrix4(mesh.matrixWorld)\n normal.set(anchor.localNormal[0], anchor.localNormal[1], anchor.localNormal[2]).transformDirection(mesh.matrixWorld)\n return true\n}\n","import type { VfxWorld } from '@adatechnology/game-vfx'\n\n/**\n * The effects world as the renderer emits into it: every sprite, fire and explosion made while `current()` names an object carries that object as its\n * `source` (unless the call gave one), so `VfxWorld.clearSource` can take them away when the object leaves. Everything else reads through to `vfx`.\n */\nexport function stampSource(vfx: VfxWorld, current: () => string | undefined): VfxWorld {\n const stamped = Object.create(vfx) as VfxWorld\n stamped.burst = (kind, point, normal, count, speed, options) => {\n const source = current()\n vfx.burst(kind, point, normal, count, speed, source === undefined || options?.source !== undefined ? options : { ...options, source })\n }\n stamped.spawn = (kind, point, velocity, options) => {\n const source = current()\n vfx.spawn(kind, point, velocity, source === undefined || options?.source !== undefined ? options : { ...options, source })\n }\n stamped.explosion = (id, point, options) => {\n const source = current()\n return vfx.explosion(id, point, source === undefined || options?.source !== undefined ? options : { ...options, source })\n }\n stamped.fire = (options) => {\n const source = current()\n return vfx.fire(source === undefined || options.source !== undefined ? options : { ...options, source })\n }\n return stamped\n}\n","export { MIN_PIECE_MASS_KG, impactKey, shotKey, dragSoundKey, createDestructionRenderer, SUGGESTED_MAX_AWAKE_FRAGMENTS, SUGGESTED_MAX_AWAKE_PIECES } from './renderer'\nexport { isPhysicsLoop } from '@adatechnology/game-physics'\nexport { EVENT_CLASS } from './event-class'\nexport { EVENT_APPLY_WEIGHT, STRUCTURAL_UNITS_PER_FRAME, eventApplyWeight } from './event-weight'\nexport { BLAST_RAYS_PER_FRAME, BLAST_WAVE_PARTS_PER_FRAME, createBlastPacer } from './blast-pacer'\nexport type { BlastPacer, BlastPacerOptions, PacedBlast } from './blast-pacer'\nexport type { EventClass } from './event-class'\nexport { PhysicsOptionError } from './physics-option'\nexport { warmUpDestructionJit } from './jit-warmup'\nexport { createCoordinatorGroundPort, createInlineGroundPort, createMainThreadGroundPort, createWorkerGroundPort, installGroundWorker } from './engine-ground-port'\nexport { groundTilesKind, staticCollidersKind } from './worker-kinds'\nexport { measureStaticPart } from './static-part-job'\nexport type { StaticPartJob } from './static-part-job'\nexport type { GroundWorkerPort } from './engine-ground-port'\nexport { computeGroundTile, readGroundBand, readGroundPatch, bandLength } from './engine-ground-job'\nexport type { GroundPatchRead, GroundTileJob, GroundTileResult } from './engine-ground-job'\nexport { GROUND_WORKER_FRAMES } from './engine-pieces'\nexport type { JitWarmUpOptions, JitWarmUpReport } from './jit-warmup'\nexport type { PiecePhysics } from './physics-option'\nexport { BLAST_DEBRIS_DEFAULTS, WORK_UNIT_DEFAULTS, resolveBlastDebris, resolveWorkUnitCosts, physicsPieceCount, splitWorkUnits } from './blast-debris'\nexport type { BlastDebrisOptions, BlastWake, DebrisCostOptions, DebrisCostSample, ExplosionWorkOptions, FarDebrisAction, FarDebrisOptions, ResolvedBlastDebris, WorkUnitCosts } from './blast-debris'\nexport { DEFAULT_WORK_BUDGET_MS } from '@adatechnology/game-physics'\nexport { SETTLED_BATCH_DEFAULTS, SETTLED_BATCH_ORIGIN } from './settled-batches'\nexport type { SettledBatchOptions, SettledBatchStats } from './settled-batches'\nexport { specFromObject3D } from './spec'\nexport type { PartHint } from './spec'\nexport { heatColor } from './heat'\nexport type { FragmentLifeRule } from './fragments'\nimport type { SpriteKind } from '@adatechnology/game-vfx'\n\n/** Every particle kind the renderer can emit (the game's sprite kinds, see `@adatechnology/game-vfx`). */\nexport type ParticleKind = SpriteKind\nexport type {\n BindOptions,\n DestructionRenderer,\n ExplodeOptions,\n Mesh,\n MeshRange,\n Object3D,\n Piece,\n LooseBody,\n DeferredQueueRegistration,\n MakePieceOptions,\n SolidBox,\n Quality,\n Quat,\n RendererOptions,\n SpecFromObjectOptions,\n SoundDetail,\n SpecFromObjectResult,\n ThreeNamespace,\n Vec3,\n} from './types'\nexport { BURN_LOOP, DESTRUCTION_SOUND_BANK, DRAG_SOUNDS, EXPLOSION_BOOM, IMPACT_SOUNDS, SCENE_SOUNDS } from './audio/recipes'\nexport { IMPACT_FAMILY_TAGS, breakSoundKeys, impactFamily, impactSoundKeys, ricochetSoundKeys } from './audio/impact-keys'\nexport type { ImpactFamily, ImpactKeys } from './audio/impact-keys'\nexport { DEFAULT_CRACKLES, DEFAULT_FIRE, DEFAULT_INDOOR_CONFINEMENT, FIRE_FADE_SECONDS, DESTRUCTION_SOUND_KEYS, IMPACT_SOUND_KEYS, blastSoundIds, createDestructionSound, impactSoundIds } from './audio/sound'\nexport {\n BIG_BLAST_RADIUS,\n BLAST_FALLOFF,\n BLAST_FAR_DISTANCE,\n BLAST_FAR_FALLOFF,\n BLAST_KINDS,\n BLAST_KIND_OF,\n BLAST_SOUNDS,\n BLAST_SOUND_OF,\n FIRE_FALLOFF,\n FIRE_LOOP,\n FIRE_SOUNDS,\n GRENADE_PIN_PULL,\n ROCKET_MOTOR_LOOP,\n SMOKE_HISS_LOOP,\n} from './audio/blast-fire'\nexport type { BlastKind } from './audio/blast-fire'\nexport { DESTRUCTION_VOICE_GROUPS, IMPACT_BURST_GROUP } from './audio/voice-groups'\nexport { BLAST_FIRE_SAMPLES, blastFireSampleBank } from './audio/samples'\nexport type { BlastFireSampleBankOptions, BlastFireSampleDefaults } from './audio/samples'\nexport type { DestructionSound, DestructionSoundOptions, DestructionSoundStyle, SoundKeyRule } from './audio/sound'\n","import type { BlastOptions, DestructionWorld, ExplosionJob, HitResult, Vec3 } from '@adatechnology/game-destruction'\n\nimport { STRUCTURAL_UNITS_PER_FRAME } from './event-weight'\nimport type { DestructionRenderer } from './types'\n\n/** Fragment rays a frame of a spread blast casts by default: the M67's 256 in 4 frames and its wave in a fifth (spec 018, `proposta-d2.md`). */\nexport const BLAST_RAYS_PER_FRAME = 64\n/** Parts the wave of a spread blast reaches per frame by default, nearest first (`ExplosionJob.advance`): the wave of the M67 in the room house over a few frames. */\nexport const BLAST_WAVE_PARTS_PER_FRAME = 128\n\nexport type BlastPacerOptions = {\n readonly world: Pick<DestructionWorld, 'beginExplosion' | 'cancelExplosions'>\n readonly renderer: Pick<DestructionRenderer, 'holdEvents' | 'applyStructuralEventsSliced'>\n /** Fragment rays per frame (`ExplosionJob.advance`). Default `BLAST_RAYS_PER_FRAME`; Infinity runs every blast whole in `begin` (the one-shot blast, through the pacer). */\n readonly raysPerFrame?: number\n /** Parts of the wave per frame, once the rays are cast. Default `BLAST_WAVE_PARTS_PER_FRAME`; Infinity runs the wave in one frame. */\n readonly wavePartsPerFrame?: number\n /** Units of `EVENT_APPLY_WEIGHT` of structural events applied per frame once the blast is done. Default `STRUCTURAL_UNITS_PER_FRAME`. */\n readonly unitsPerFrame?: number\n}\n\n/** A blast for the pacer: the arguments of `DestructionWorld.explode`. */\nexport type PacedBlast = {\n readonly point: Vec3\n readonly energy: number\n readonly radius: number\n readonly source?: string\n readonly options?: BlastOptions\n}\n\nexport type BlastPacer = {\n /**\n * Begins a blast and runs its first slice now; `onDone` gets what `explode` would have returned when it ends (in this call when it fits in one slice). A blast begun\n * while another is open waits for it (`beginExplosion`).\n */\n begin(blast: PacedBlast, onDone: (results: HitResult[]) => void): void\n /** true while the world must not step: a blast still open, or the structural events of the blasts done still being applied. The host holds its fixed steps on it. */\n isHolding(): boolean\n /** Once per frame while holding, outside the fixed step: the next slice of the oldest open blast, or, all done, the next slice of their structural events. */\n step(): void\n /**\n * Drops every open blast (no `onDone`) and both holds: the host is clearing or replacing its world. It calls `world.cancelExplosions()`, which cancels every open\n * explosion of the world, also one begun outside this pacer.\n */\n clear(): void\n}\n\ntype OpenBlast = { readonly job: ExplosionJob; readonly onDone: (results: HitResult[]) => void; isFresh: boolean }\n\n/**\n * Spreads a large blast over frames with the world held (spec 018 D2): the fragments a fixed number of rays per frame, the wave a fixed number of the parts it reaches per frame, then the\n * structural events a fixed weight per frame, every count fixed so the world it leaves is the one the one-shot blast leaves. The host holds the fixed steps while\n * `isHolding` (`game-runtime`'s `holdFixed`) and calls `step` once per frame; the effects, the sound and the camera go on meanwhile.\n */\nexport function createBlastPacer(options: BlastPacerOptions): BlastPacer {\n const { world, renderer } = options\n const raysPerFrame = options.raysPerFrame ?? BLAST_RAYS_PER_FRAME\n const waveParts = raysPerFrame === Infinity ? Infinity : (options.wavePartsPerFrame ?? BLAST_WAVE_PARTS_PER_FRAME)\n const unitsPerFrame = options.unitsPerFrame ?? STRUCTURAL_UNITS_PER_FRAME\n const open: OpenBlast[] = []\n let isApplying = false\n\n /** With no blast left open, the events go; `isSpread`: their structural ones are applied a slice per frame from the next one, else in the tick as always. */\n const letGo = (isSpread: boolean): void => {\n if (open.length > 0) return\n renderer.holdEvents(false)\n if (isSpread) isApplying = true\n }\n\n /** Hands every blast that ended to its host, oldest first. A blast whose step threw is dropped (its `onDone` never runs) and the error goes on to the caller. */\n const settleDone = (isSpread: boolean): void => {\n while (open.length > 0 && open[0]!.job.isDone) {\n const done = open.shift()!\n let results: HitResult[]\n try {\n results = done.job.result()\n } catch (error) {\n // a failed blast is not spread: what it emitted applies in the next tick, whole\n letGo(false)\n throw error\n }\n done.onDone(results)\n }\n letGo(isSpread)\n }\n\n /** Runs a slice of the oldest open blast; a throw drops it (`settleDone`) and is thrown on. */\n const advanceOldest = (oldest: OpenBlast, isSpread: boolean): void => {\n try {\n oldest.job.advance(raysPerFrame, waveParts)\n } catch (error) {\n if (open[0] === oldest) open.shift()\n letGo(false)\n throw error\n }\n if (oldest.job.isDone) settleDone(isSpread)\n }\n\n return {\n begin(blast, onDone) {\n const job = world.beginExplosion(blast.point, blast.energy, blast.radius, blast.source, blast.options)\n // begun inside another blast's step (a charge it set off, from a listener) it ran whole there: its host hears of it now, as without the pacer\n if (job.isDone) {\n onDone(job.result())\n return\n }\n const isFirst = open.length === 0\n if (isFirst) renderer.holdEvents(true)\n // one queued behind another is advanced from the frame after the one before it ends\n const entry: OpenBlast = { job, onDone, isFresh: isFirst }\n open.push(entry)\n if (!isFirst) return\n // a blast that fits in one slice (or every blast, with `raysPerFrame` Infinity) is the one-shot blast: nothing is held, its events apply in the tick as always\n advanceOldest(entry, isApplying)\n while (raysPerFrame === Infinity && open[0] === entry) advanceOldest(entry, isApplying)\n },\n isHolding: () => open.length > 0 || isApplying,\n step() {\n const oldest = open[0]\n if (oldest) {\n // the frame that began it already ran its first slice\n if (oldest.isFresh) {\n oldest.isFresh = false\n return\n }\n advanceOldest(oldest, true)\n return\n }\n if (isApplying) isApplying = renderer.applyStructuralEventsSliced(unitsPerFrame) > 0\n },\n clear() {\n open.length = 0\n isApplying = false\n world.cancelExplosions()\n renderer.holdEvents(false)\n },\n }\n}\n","import { isWorkerInputLost } from '@adatechnology/game-contracts'\nimport type { WorkerCoordinator } from '@adatechnology/game-contracts'\nimport type { WorkerLike, WorkerScopeLike } from '@adatechnology/game-shapes'\n\nimport { computeGroundTile, jobTransferOf, transferOf } from './engine-ground-job'\nimport type { GroundTileJob, GroundTileResult } from './engine-ground-job'\nimport { groundTilesKind } from './worker-kinds'\n\n/**\n * Where the engine's ground tiles are made (`RendererOptions.groundWorker`): the main thread posts a job (`GroundTileJob`, plain arrays, transferred) and takes the tile back\n * when it comes. The engine applies a tile exactly `groundWorkerFrames` updates after it asked for it, from the answer if it came, else made on the main thread from the same\n * job: the answer is the same bits either way, so when it comes changes nothing but where the work ran (`GroundSchedule`).\n *\n * - `transfer`: the game's worker coordinator (`createCoordinatorGroundPort`, the `destruction.ground-tiles` kind, CLAUDE.md §14), or a\n * worker of the host's (`createWorkerGroundPort`, over game-shapes' `WorkerLike`); the answer comes whenever its event loop delivers it.\n * - `inline`: this thread, at once when posted (`createInlineGroundPort`): tests, Node.\n * - `none`: never answers and nothing is posted (`createMainThreadGroundPort`): every tile made on the main thread at its frame, the reference the other two match.\n */\nexport interface GroundWorkerPort {\n /** May turn `none` later (a worker that failed): read it at each job. */\n readonly transport: 'transfer' | 'inline' | 'none'\n /** Takes the job's arrays (they may be transferred: not to be read after). */\n postTile(job: GroundTileJob): void\n /** The one handler the answers go to. */\n onTile(handler: (result: GroundTileResult) => void): void\n /** Stops the worker, if any; no answer comes after. */\n dispose(): void\n}\n\n/** The one handler of a port: a port serves one engine, so a second one is an error (it would take the answers of the first). */\nconst oneHandler = (): { set(h: (result: GroundTileResult) => void): void; get(): ((result: GroundTileResult) => void) | null; drop(): void } => {\n let handler: ((result: GroundTileResult) => void) | null = null\n return {\n set: (h) => {\n if (handler) throw new Error('GroundWorkerPort: onTile set twice (a port serves one engine)')\n handler = h\n },\n get: () => handler,\n drop: () => {\n handler = null\n },\n }\n}\n\nexport const createInlineGroundPort = (): GroundWorkerPort => {\n const handler = oneHandler()\n return {\n transport: 'inline',\n postTile: (job) => handler.get()?.(computeGroundTile(job)),\n onTile: handler.set,\n dispose: handler.drop,\n }\n}\n\nexport const createMainThreadGroundPort = (): GroundWorkerPort => {\n const handler = oneHandler()\n return { transport: 'none', postTile: () => undefined, onTile: handler.set, dispose: handler.drop }\n}\n\n/**\n * A worker running `installGroundWorker` (the package's `ground-worker` entry): jobs and answers cross with their buffers transferred; `dispose` terminates it. A worker that\n * fails (`onerror`: its script did not load, it threw) is posted nothing more: the port turns `none` and every tile is made on the main thread at its update, as it would have\n * been anyway (game-shapes' pool fails its jobs the same way).\n */\nexport const createWorkerGroundPort = (worker: WorkerLike): GroundWorkerPort => {\n const handler = oneHandler()\n let failed = false\n worker.onmessage = (event) => handler.get()?.(event.data as GroundTileResult)\n worker.onerror = () => {\n failed = true\n }\n return {\n get transport() {\n return failed ? 'none' : 'transfer'\n },\n postTile: (job) => {\n if (!failed) worker.postMessage(job, jobTransferOf(job))\n },\n onTile: handler.set,\n dispose: () => {\n handler.drop()\n worker.onmessage = null\n worker.onerror = null\n worker.terminate()\n },\n }\n}\n\n/**\n * The tiles through the game's worker coordinator (CLAUDE.md §14): each job is a `destruction.ground-tiles` task the coordinator hands to a\n * worker, awaited (the engine's `GroundSchedule` applies the tile at its update, from the answer if it came, else made here from the same\n * job). A coordinator with no workers is posted nothing (`none`): every tile is made at its update, with no job run twice. The coordinator\n * is the game's: `dispose` lets go of the answers, not of the workers. The job's arrays are transferred (the kind's `transferAwaitedInput`):\n * `GroundSchedule` posts copies from its pool and keeps its own for the fallback. A job lost with its worker (it died holding it) is made here at\n * its update and the next ones still go to the workers (the coordinator replaces a dying worker a few times, then lets it go: `none` when none\n * is left); any other rejection (a worker that cannot run the kind) and nothing more is posted.\n */\nexport const createCoordinatorGroundPort = (workers: WorkerCoordinator): GroundWorkerPort => {\n const handler = oneHandler()\n let disposed = false\n let failed = false\n return {\n get transport() {\n return failed || workers.stats().workers === 0 ? 'none' : 'transfer'\n },\n postTile: (job) => {\n if (disposed || failed || workers.stats().workers === 0) return\n workers.run(groundTilesKind, job).then(\n (result) => {\n if (!disposed) handler.get()?.(result)\n },\n // the tile is made here at its update; a job lost with its worker leaves the next ones to the workers, anything else posts nothing more\n (error: unknown) => {\n if (!isWorkerInputLost(error)) failed = true\n },\n )\n },\n onTile: handler.set,\n dispose: () => {\n disposed = true\n handler.drop()\n },\n }\n}\n\n/** The worker side: each job answered with its tile, every array transferred back (the job's own included, for the main thread's pool). */\nexport const installGroundWorker = (scope: WorkerScopeLike): void => {\n scope.onmessage = (event) => {\n const result = computeGroundTile(event.data as GroundTileJob)\n scope.postMessage(result, transferOf(result))\n }\n}\n","// The sounds of materials breaking, as recipes of @adatechnology/game-audio. The art scene's `sfx.*` (cena L1354-L1367) are ported literally: the same\n// filters, frequencies, lengths, volumes and reverb sends, and the same random numbers drawn in the same order, so a recipe leaves the trace of the team\n// code. The game's `boom` (jogo L68278) is here too, as the game's explosion.\nimport { DISTANCE_CURVES, sceneMany as many, sceneNoise as noise, sceneRecipe, sceneTone as tone } from '@adatechnology/game-audio'\nimport type { Layer, LoopRecipe, SoundBank, SoundRecipe } from '@adatechnology/game-audio'\n\nimport { BLAST_SOUNDS, FIRE_FUEL_LOOPS, FIRE_LOOP, FIRE_SOUNDS, GRENADE_PIN_PULL, ROCKET_MOTOR_LOOP, SMOKE_HISS_LOOP } from './blast-fire'\n\nconst scene = (id: string, layers: readonly Layer[], line: string, vars?: SoundRecipe['vars'], group?: string): SoundRecipe =>\n sceneRecipe(id, layers, line, { ...(vars ? { vars } : {}), ...(group ? { group } : {}) })\n\nconst boomLayers = (big: boolean): Layer[] => [\n noise({ f: 1200, f2: 120, d: 1.8, vol: 2, wet: 1.2 }),\n tone({ f: 65, f2: 24, d: 1.0, vol: 1.8 }),\n noise({ type: 'highpass', f: 1500, d: 0.2, vol: 0.8 }),\n ...(big ? [noise({ f: 500, f2: 90, a: 0.2, d: 2.4, vol: 1.2, wet: 1, delay: 0.15 })] : []),\n ...many(8, () => tone({ f: [2600, 5600], d: 0.05, vol: 0.08, delay: [0.4, 1.6] })),\n]\n\n/** The art scene's destruction sounds, each with the team name in its `sources`. */\nexport const SCENE_SOUNDS: readonly SoundRecipe[] = [\n scene(\n 'glass_shatter',\n [noise({ type: 'highpass', f: 2800, d: 0.45, vol: 0.9, wet: 0.5 }), ...many(12, () => tone({ f: [3000, 7500], d: [0.06, 0.14], vol: 0.18, delay: [0, 0.55] }))],\n 'L1359 glass',\n ),\n scene(\n 'wood_hit',\n [noise({ type: 'bandpass', f: 850, q: 1, d: 0.25, vol: 0.9, wet: 0.3 }), tone({ f: 210, f2: 90, d: 0.1, vol: 0.6 }), noise({ type: 'highpass', f: 2000, d: 0.04, vol: 0.5 })],\n 'L1360 wood',\n ),\n // many parts coming loose at once share the `debris_knock` voices (game-audio voice-groups.json)\n scene('thunk', [noise({ type: 'bandpass', f: 700, q: 2, d: 0.07, vol: 0.4 })], 'L1361 thunk', undefined, 'debris_knock'),\n scene('ping', [tone({ f: [2600, 3500], f2: 1400, d: 0.14, vol: 0.18, wet: 0.3 })], 'L1362 ping'),\n scene('clang', [tone({ f: [520, 720], f2: 480, d: 0.5, vol: 0.35, wet: 0.4 }), tone({ f: 1370, f2: 1300, d: 0.3, vol: 0.15 }), noise({ type: 'highpass', f: 2000, d: 0.05, vol: 0.5 })], 'L1363 clang'),\n scene('chip', [noise({ type: 'bandpass', f: 1600, q: 1.2, d: 0.06, vol: 0.5 })], 'L1364 chip'),\n scene(\n 'crumble',\n [noise({ f: 900, f2: 200, d: 0.6, vol: 0.9, wet: 0.3 }), ...many(5, () => noise({ type: 'bandpass', f: [500, 1400], q: 2, d: 0.05, vol: 0.4, delay: [0.1, 0.5] }))],\n 'L1365 crumble',\n ),\n // `thud(x, z, v)`: `v` is the `scale` param (default 1)\n scene('thud', [tone({ f: 75, f2: 38, d: 0.22, vol: { param: 'scale', scale: 0.6 } }), noise({ f: 420, d: 0.16, vol: { param: 'scale', scale: 0.45 } })], 'L1358 thud', { scale: 1 }),\n // `hiss(x, z, d)`: `seconds` is the param `d` (default 1.2)\n // every melting part shares one `sizzle` voice\n scene('hiss', [noise({ type: 'highpass', f: 3500, a: 0.05, d: { param: 'seconds' }, vol: 0.35 })], 'L1366 hiss', { seconds: 1.2 }, 'sizzle'),\n scene('boom', boomLayers(false), 'L1367 boom'),\n scene('boom_big', boomLayers(true), 'L1367 boom (big)'),\n scene('burst', [noise({ f: 700, f2: 120, d: 0.7, vol: 1.4, wet: 0.5 }), noise({ type: 'highpass', f: 3000, a: 0.05, d: 1.2, vol: 0.4, delay: 0.1 })], 'L1357 burst'),\n scene('crack', [noise({ type: 'highpass', f: 1800, d: 0.05, vol: 0.8 }), tone({ f: 420, f2: 180, d: 0.06, vol: 0.4 })], 'L1354 crack'),\n]\n\n/** The game's explosion thump: a sine from 70 to 28 Hz over 1.2 s, `1.4 / (1 + d² × 0.002)` (jogo L68278). */\nexport const EXPLOSION_BOOM: SoundRecipe = {\n id: 'explosion_boom',\n bus: 'world',\n order: 'boom',\n duration: 1.6,\n tail: 0.1,\n layers: [\n {\n source: { kind: 'osc', wave: 'sine', frequency: { from: 70, to: 28, curve: 'exp', over: 1.2 } },\n envelope: [\n [0, 1, 'set'],\n ['1d', 0.001, 'exp', 'fixed'],\n ],\n },\n ],\n falloff: DISTANCE_CURVES.game_boom,\n sources: ['jogo:L68278-68285 boom'],\n}\n\n/**\n * The fire loop of the art scene (cena L1316): noise through a 1800 Hz bandpass (Q 0.6) into a gain that starts at 0. The page never raises it, so it is\n * silent there; here `createDestructionSound` raises it while something burns (the level is the kit's, in `fire`).\n */\nexport const BURN_LOOP: LoopRecipe = {\n id: 'burn_loop',\n bus: 'world',\n order: 'chain_loop',\n source: { kind: 'noise', loop: true },\n filters: { mode: 'serial', bank: [{ type: 'bandpass', frequency: { set: 1800 }, q: 0.6 }] },\n volume: 0,\n sources: ['cena:L1316 fire loop (silent in the page: its gain is never raised)', 'sdk: the level while burning'],\n}\n\nconst drag = (id: string, layers: readonly Layer[]): SoundRecipe => ({ ...sceneRecipe(id, layers, ''), sources: ['sdk: a base dragged on a floor, one grain per stretch'] })\n\n/** Something heavy dragged on a floor, by what its base is made of. */\nexport const DRAG_SOUNDS: readonly SoundRecipe[] = [\n drag('drag_wood', [noise({ type: 'bandpass', f: 380, q: 1.4, d: 0.28, vol: 0.5 }), noise({ type: 'bandpass', f: [900, 1300], q: 3, d: 0.08, vol: 0.14 })]),\n drag('drag_metal', [noise({ type: 'bandpass', f: 1500, q: 4, d: 0.26, vol: 0.32 }), tone({ f: [880, 1240], f2: 760, d: 0.18, vol: 0.05 })]),\n drag('drag_glass', [noise({ type: 'bandpass', f: 2600, q: 5, d: 0.2, vol: 0.22 })]),\n drag('drag_masonry', [noise({ type: 'bandpass', f: 260, q: 0.9, d: 0.3, vol: 0.62 }), ...many(3, () => noise({ type: 'bandpass', f: [600, 1200], q: 2, d: 0.04, vol: 0.14, delay: [0, 0.2] }))]),\n drag('drag_soft', [noise({ type: 'lowpass', f: 420, d: 0.28, vol: 0.3 })]),\n]\n\nconst leaf = (id: string, layers: readonly Layer[]): SoundRecipe => ({ ...sceneRecipe(id, layers, ''), sources: ['sdk: a door, lid or drawer worked by hand'] })\n\n/** A leaf worked by hand: the latch, the hinge as it turns (by what the leaf is made of), the leaf meeting its frame, a locked leaf shaken, a drawer on its runners. */\nexport const LEAF_SOUNDS: readonly SoundRecipe[] = [\n leaf('latch', [noise({ type: 'bandpass', f: 2400, q: 4, d: 0.03, vol: 0.35 }), tone({ f: 1900, f2: 1500, d: 0.025, vol: 0.06, delay: 0.035 })]),\n leaf('creak_wood', [tone({ f: [190, 240], f2: 310, d: 0.5, vol: 0.05 }), noise({ type: 'bandpass', f: 520, q: 6, a: 0.05, d: 0.45, vol: 0.12 })]),\n leaf('creak_metal', [tone({ f: [620, 760], f2: 900, d: 0.35, vol: 0.035 }), noise({ type: 'bandpass', f: 1400, q: 8, a: 0.04, d: 0.3, vol: 0.08 })]),\n leaf('shut_wood', [tone({ f: 120, f2: 60, d: 0.14, vol: 0.5 }), noise({ type: 'bandpass', f: 600, q: 1.2, d: 0.1, vol: 0.55, wet: 0.25 }), noise({ type: 'bandpass', f: 2400, q: 4, d: 0.03, vol: 0.25, delay: 0.02 })]),\n leaf('shut_metal', [tone({ f: 160, f2: 85, d: 0.18, vol: 0.55 }), noise({ type: 'bandpass', f: 900, q: 1.6, d: 0.12, vol: 0.45, wet: 0.3 }), tone({ f: 1250, f2: 1150, d: 0.12, vol: 0.06 })]),\n leaf('shut_soft', [tone({ f: 95, f2: 55, d: 0.12, vol: 0.35 }), noise({ type: 'lowpass', f: 500, d: 0.1, vol: 0.3 })]),\n leaf('rattle', many(5, () => noise({ type: 'bandpass', f: [1600, 2600], q: 3, d: 0.035, vol: 0.32, delay: [0, 0.45] }))),\n leaf('slide', [noise({ type: 'bandpass', f: 700, q: 2, a: 0.04, d: 0.35, vol: 0.22 }), noise({ type: 'bandpass', f: 2200, q: 5, d: 0.3, vol: 0.05 })]),\n // an item taken in the hand: the fingers on a hard surface and the sleeve moving, or a soft thing gathered up (the kit's recordings answer these ids)\n leaf('grab_hard', [noise({ type: 'bandpass', f: 1800, q: 3, d: 0.03, vol: 0.18 }), noise({ type: 'bandpass', f: 900, q: 1.2, a: 0.02, d: 0.14, vol: 0.08 })]),\n leaf('grab_soft', [noise({ type: 'lowpass', f: 1400, a: 0.02, d: 0.16, vol: 0.14 })]),\n]\n\nconst impact = (id: string, layers: readonly Layer[]): SoundRecipe => ({ ...sceneRecipe(id, layers, ''), sources: ['sdk: a blow on a material, by material and kind of blow (synthesised until the recorded samples arrive)'] })\n\n/**\n * A blow on a material, by what it is made of and what met it (`impactSoundKeys`): a bullet, a blunt blow (a punch, a kick, a fall), a blade. Each\n * is drawn from how the real thing sounds (checklist 5.3): a bullet rings steel and goes \"tchak\" on concrete with pebbles after it, a fist on steel is a\n * low \"bong\", a knife scrapes it; the ground is a dull \"tuf\", ceramic a dry \"tic\", plastic a hollow \"toc\", a sofa a \"fump\". Levels are matched so a\n * bullet on concrete is as loud as on wood.\n */\nexport const IMPACT_SOUNDS: readonly SoundRecipe[] = [\n // metal\n impact('metal_bullet', [noise({ type: 'highpass', f: 3000, d: 0.03, vol: 0.8 }), tone({ f: [2600, 3400], f2: 1800, d: 0.14, vol: 0.28, wet: 0.35 }), tone({ f: [520, 720], f2: 480, d: 0.35, vol: 0.22, wet: 0.35 })]),\n impact('metal_blunt', [noise({ type: 'bandpass', f: 800, q: 1, d: 0.05, vol: 0.5 }), tone({ f: [150, 210], f2: 120, d: 0.6, vol: 0.5, wet: 0.4 }), tone({ f: [420, 520], f2: 400, d: 0.4, vol: 0.12 })]),\n impact('metal_blade', [noise({ type: 'bandpass', f: [3500, 4500], q: 6, a: 0.01, d: 0.18, vol: 0.45 }), tone({ f: [2200, 2800], f2: 3000, d: 0.15, vol: 0.06 })]),\n impact('metal_ping', [noise({ type: 'highpass', f: 3500, d: 0.02, vol: 0.5 }), tone({ f: [2600, 3500], f2: 1400, d: 0.14, vol: 0.2, wet: 0.3 })]),\n impact('metal_thin', [noise({ type: 'highpass', f: 2500, d: 0.04, vol: 0.6 }), tone({ f: [900, 1300], f2: 700, d: 0.25, vol: 0.22, wet: 0.3 }), noise({ type: 'bandpass', f: 1200, q: 2, d: 0.08, vol: 0.3 })]),\n // wood (the bullet keeps the art scene's `wood_hit`)\n impact('wood_blunt', [tone({ f: [110, 150], f2: 70, d: 0.14, vol: 0.6 }), noise({ type: 'bandpass', f: 500, q: 1.2, d: 0.12, vol: 0.55, wet: 0.2 })]),\n impact('wood_blade', [noise({ type: 'bandpass', f: [1800, 2400], q: 2, a: 0.01, d: 0.12, vol: 0.5 }), ...many(3, () => noise({ type: 'bandpass', f: [2500, 4000], q: 3, d: 0.02, vol: 0.22, delay: [0.02, 0.1] }))]),\n impact('wood_splinter', [noise({ type: 'highpass', f: 1800, d: 0.05, vol: 0.6 }), tone({ f: [380, 480], f2: 170, d: 0.08, vol: 0.3 }), ...many(4, () => noise({ type: 'bandpass', f: [2500, 4200], q: 3, d: 0.02, vol: 0.2, delay: [0.03, 0.25] }))]),\n impact('mdf_puff', [noise({ type: 'lowpass', f: 900, d: 0.08, vol: 1 }), tone({ f: [180, 230], f2: 110, d: 0.06, vol: 0.3 }), noise({ type: 'highpass', f: 3000, a: 0.01, d: 0.2, vol: 0.1 })]),\n // glass and ceramic\n impact('glass_bullet', [noise({ type: 'highpass', f: 4000, d: 0.05, vol: 0.7 }), tone({ f: [3200, 4200], f2: 2600, d: 0.2, vol: 0.14, wet: 0.3 }), ...many(4, () => tone({ f: [4000, 7000], d: 0.05, vol: 0.07, delay: [0.02, 0.2] }))]),\n impact('glass_blunt', [noise({ type: 'bandpass', f: 2200, q: 3, d: 0.05, vol: 0.8 }), tone({ f: [1400, 1800], f2: 1300, d: 0.2, vol: 0.16, wet: 0.3 })]),\n impact('glass_blade', [noise({ type: 'bandpass', f: 5000, q: 8, a: 0.02, d: 0.25, vol: 0.3 })]),\n impact('ceramic_hit', [noise({ type: 'bandpass', f: 3000, q: 2, d: 0.03, vol: 0.6 }), tone({ f: [1800, 2400], f2: 1600, d: 0.1, vol: 0.2 })]),\n impact('ceramic_bullet', [noise({ type: 'highpass', f: 2500, d: 0.06, vol: 0.85 }), ...many(5, () => tone({ f: [2500, 5000], d: 0.04, vol: 0.09, delay: [0, 0.15] }))]),\n // masonry and the ground\n impact('masonry_bullet', [noise({ type: 'bandpass', f: [1600, 2000], q: 1, d: 0.05, vol: 1.8 }), noise({ type: 'lowpass', f: 600, d: 0.12, vol: 0.9, wet: 0.2 }), ...many(4, () => noise({ type: 'bandpass', f: [2000, 4000], q: 3, d: 0.02, vol: 0.28, delay: [0.03, 0.3] }))]),\n impact('masonry_blunt', [tone({ f: [70, 95], f2: 45, d: 0.12, vol: 0.55 }), noise({ type: 'lowpass', f: 400, d: 0.1, vol: 0.5 })]),\n impact('masonry_blade', [noise({ type: 'bandpass', f: [2500, 3500], q: 4, a: 0.01, d: 0.15, vol: 0.4 })]),\n impact('plaster_puff', [noise({ type: 'lowpass', f: 900, d: 0.09, vol: 0.7 }), noise({ type: 'highpass', f: 3000, a: 0.01, d: 0.2, vol: 0.14 })]),\n impact('soil_bullet', [noise({ type: 'lowpass', f: 700, d: 0.08, vol: 2.2 }), ...many(3, () => noise({ type: 'bandpass', f: [1200, 2200], q: 2, d: 0.03, vol: 0.18, delay: [0.02, 0.2] }))]),\n impact('soil_blunt', [tone({ f: [55, 70], f2: 40, d: 0.1, vol: 0.45 }), noise({ type: 'lowpass', f: 300, d: 0.08, vol: 0.4 })]),\n impact('sand_hit', [noise({ type: 'bandpass', f: 3500, q: 0.8, a: 0.005, d: 0.15, vol: 0.45 }), noise({ type: 'lowpass', f: 500, d: 0.06, vol: 0.45 })]),\n impact('gravel_hit', [noise({ type: 'lowpass', f: 500, d: 0.06, vol: 0.45 }), ...many(6, () => noise({ type: 'bandpass', f: [1500, 3500], q: 3, d: 0.025, vol: 0.28, delay: [0, 0.18] }))]),\n // plastic, rubber, wax\n impact('plastic_hit', [noise({ type: 'bandpass', f: 1600, q: 3, d: 0.04, vol: 0.5 }), tone({ f: [380, 520], f2: 300, d: 0.08, vol: 0.32 })]),\n impact('plastic_bullet', [noise({ type: 'bandpass', f: 2500, q: 2, d: 0.03, vol: 1.3 }), tone({ f: [600, 800], f2: 450, d: 0.06, vol: 0.4 })]),\n impact('rubber_hit', [tone({ f: [90, 130], f2: 60, d: 0.1, vol: 0.45 }), noise({ type: 'lowpass', f: 350, d: 0.06, vol: 0.28 })]),\n impact('wax_hit', [noise({ type: 'lowpass', f: 800, d: 0.05, vol: 0.45 }), tone({ f: [240, 280], f2: 180, d: 0.05, vol: 0.22 })]),\n // soft things, paper, plants\n impact('soft_bullet', [noise({ type: 'lowpass', f: 450, a: 0.003, d: 0.1, vol: 1.8 }), noise({ type: 'bandpass', f: 900, q: 1, d: 0.05, vol: 0.5 })]),\n impact('fabric_hit', [noise({ type: 'lowpass', f: 650, d: 0.14, vol: 0.5 }), tone({ f: [85, 115], f2: 50, d: 0.12, vol: 0.28 })]),\n impact('fabric_rip', [noise({ type: 'bandpass', f: [2000, 2800], q: 1.5, a: 0.02, d: 0.25, vol: 0.4 }), ...many(4, () => noise({ type: 'bandpass', f: [3000, 5000], q: 4, d: 0.02, vol: 0.14, delay: [0, 0.22] }))]),\n impact('paper_hit', [noise({ type: 'bandpass', f: 2200, q: 1, d: 0.05, vol: 0.45 })]),\n impact('paper_tear', [noise({ type: 'highpass', f: 2500, a: 0.02, d: 0.3, vol: 0.15 })]),\n impact('leaf_rustle', many(6, () => noise({ type: 'bandpass', f: [2500, 6000], q: 2, d: 0.05, vol: 0.16, delay: [0, 0.3] }))),\n impact('branch_cut', [noise({ type: 'bandpass', f: 1500, q: 2, d: 0.04, vol: 0.55 }), tone({ f: [260, 340], f2: 150, d: 0.05, vol: 0.22 })]),\n impact('fruit_splat', [noise({ type: 'lowpass', f: 1200, d: 0.12, vol: 0.55 }), noise({ type: 'bandpass', f: 600, q: 0.7, d: 0.2, vol: 0.32 })]),\n // a round glancing off: steel whines down in pitch (\"piiuu\"), stone and concrete give a short crack with grit\n impact('ricochet_metal', [noise({ type: 'highpass', f: 3000, d: 0.02, vol: 0.6 }), tone({ f: [2800, 3600], f2: 900, d: 0.38, vol: 0.2, wet: 0.4 }), tone({ f: [5200, 6400], f2: 2000, d: 0.2, vol: 0.05 })]),\n impact('ricochet_stone', [noise({ type: 'bandpass', f: [2200, 2800], q: 2, d: 0.04, vol: 0.8 }), tone({ f: [1800, 2400], f2: 1200, d: 0.08, vol: 0.1 }), ...many(3, () => noise({ type: 'bandpass', f: [2500, 4500], q: 3, d: 0.015, vol: 0.2, delay: [0.02, 0.12] }))]),\n // breaks a material has of its own (the rest keep the art scene's shatter, crumble and splinter)\n impact('ceramic_break', [noise({ type: 'highpass', f: 1800, d: 0.3, vol: 0.85, wet: 0.4 }), ...many(8, () => tone({ f: [1800, 4500], d: [0.04, 0.1], vol: 0.15, delay: [0, 0.4] }))]),\n impact('tempered_burst', [noise({ type: 'highpass', f: 3500, d: 0.6, vol: 0.9, wet: 0.4 }), ...many(16, () => tone({ f: [4000, 8000], d: 0.04, vol: 0.08, delay: [0, 0.8] }))]),\n impact('plastic_crack', [noise({ type: 'bandpass', f: 1800, q: 2, d: 0.06, vol: 0.75 }), tone({ f: [450, 550], f2: 250, d: 0.05, vol: 0.22 })]),\n impact('mdf_crumble', [noise({ type: 'lowpass', f: 700, d: 0.25, vol: 0.75, wet: 0.2 }), ...many(4, () => noise({ type: 'lowpass', f: 500, d: 0.05, vol: 0.32, delay: [0.05, 0.3] }))]),\n]\n\nexport const DESTRUCTION_SOUND_BANK: SoundBank = { id: 'destruction_three', sounds: [...SCENE_SOUNDS, ...DRAG_SOUNDS, ...LEAF_SOUNDS, ...IMPACT_SOUNDS, EXPLOSION_BOOM, ...BLAST_SOUNDS, ...FIRE_SOUNDS, GRENADE_PIN_PULL], loops: [BURN_LOOP, FIRE_LOOP, ...FIRE_FUEL_LOOPS, SMOKE_HISS_LOOP, ROCKET_MOTOR_LOOP] }\n","// Blasts and fire: the kit's synthesized sounds for each family of explosive (grenade, big charge, fuel, car, pipe bomb, rocket, flashbang, molotov),\n// the far and the indoor versions of a blast, and the fire (ignition, roar, crackle, gas leak, put out). Synthesized until recorded files reach the\n// SDK; each recipe is built so the loudest moment is the first few milliseconds (the crack of the blast lands on the frame of the event), the body\n// and the debris follow, and every frequency and timing is a range so no two plays sound alike.\nimport { sceneMany as many, sceneNoise as noise, sceneRecipe, sceneTone as tone } from '@adatechnology/game-audio'\nimport type { Falloff, FilterSpec, Layer, LoopRecipe, SoundRecipe } from '@adatechnology/game-audio'\n\n/** A blast near the listener: loud for tens of metres; lowpass cutoffs fall with distance. */\nexport const BLAST_FALLOFF: Falloff = { model: 'inverse_square', k: 0.0012, cutoffK: 0.006, minGain: 0.002 }\n/** A blast far away (past `BLAST_FAR_DISTANCE`): heard for hundreds of metres. */\nexport const BLAST_FAR_FALLOFF: Falloff = { model: 'inverse_square', k: 0.00008, scale: 0.3, minGain: 0.001 }\n/** Fire, ignition and crackles: a room-size sound. */\nexport const FIRE_FALLOFF: Falloff = { model: 'inverse_square', k: 0.01, cutoffK: 0.01, minGain: 0.005 }\n/** Metres from the listener past which a blast plays its far version. */\nexport const BLAST_FAR_DISTANCE = 60\n\n/** The explosion families, each with its own sound. */\nexport const BLAST_KINDS = ['grenade', 'big', 'fuel', 'car', 'pipe_bomb', 'rocket', 'flashbang', 'molotov'] as const\nexport type BlastKind = (typeof BLAST_KINDS)[number]\n\n/**\n * Which family each named explosion of `@adatechnology/game-vfx` (`explosions.json`, the `effect` of an explosive part) belongs to. Data: a game adds\n * or changes entries through `DestructionSoundOptions.blastKinds`. An explosion without a known effect is a grenade below `BIG_BLAST_RADIUS` and a big\n * charge above it.\n */\nexport const BLAST_KIND_OF: Readonly<Record<string, BlastKind>> = {\n m67: 'grenade',\n vog_25: 'grenade',\n m79_40mm: 'grenade',\n claymore: 'grenade',\n generic: 'grenade',\n c4: 'big',\n dynamite: 'big',\n fuel_station_tank: 'big',\n propane_p13: 'fuel',\n fuel_barrel: 'fuel',\n fuel_pump: 'fuel',\n car_fuel_tank: 'car',\n pipe_bomb: 'pipe_bomb',\n m72_66mm: 'rocket',\n at4_84mm: 'rocket',\n carl_gustaf_84mm: 'rocket',\n pg7v: 'rocket',\n flashbang: 'flashbang',\n molotov: 'molotov',\n}\n\n/** Blast radius (metres) from which an explosion with no known effect is a big charge. */\nexport const BIG_BLAST_RADIUS = 8\n\nconst blast = (id: string, layers: readonly Layer[], sources: readonly string[], falloff: Falloff = BLAST_FALLOFF): SoundRecipe => ({\n ...sceneRecipe(id, layers, ''),\n falloff,\n sources,\n})\n\n// the instant crack of the shock front: the loudest part, in the first milliseconds\nconst crack = (f: readonly [number, number], d: number, vol: number): Layer => noise({ type: 'highpass', f, a: 0.001, d, vol })\n// stones, wood and metal falling back after the blast, spread over `[from, to]` seconds\nconst debris = (count: number, from: number, to: number, vol: readonly [number, number]): Layer[] => [\n ...many(count, () => noise({ type: 'bandpass', f: [300, 1400], q: 2.5, d: [0.03, 0.09], vol, delay: [from, to] })),\n ...many(Math.ceil(count / 3), () => noise({ type: 'bandpass', f: [1800, 3600], q: 5, d: [0.02, 0.04], vol: [vol[0] * 0.6, vol[1] * 0.6] as const, delay: [from + 0.1, to] })),\n]\n// steel fragments whizzing and striking around the blast\nconst shrapnel = (count: number, to: number): Layer[] => many(count, () => noise({ type: 'bandpass', f: [2500, 6000], q: 6, d: [0.015, 0.045], vol: [0.08, 0.16], delay: [0.02, to] }))\n// glass panes breaking and their shards falling\nconst glass = (count: number, from: number): Layer[] => [\n noise({ type: 'highpass', f: [2600, 3000], d: 0.4, vol: 0.7, wet: 0.5, delay: from }),\n ...many(count, () => tone({ f: [3000, 7500], d: [0.05, 0.13], vol: 0.12, delay: [from, from + 0.7] })),\n]\n\n/** One sound per explosion family, the far and the indoor versions. */\nexport const BLAST_SOUNDS: readonly SoundRecipe[] = [\n blast(\n 'explosion_grenade',\n [\n crack([2300, 2700], 0.06, 2.4),\n noise({ f: [2500, 3000], f2: 160, d: 0.7, vol: 2, wet: 0.35 }),\n tone({ f: [80, 92], f2: 32, d: 0.5, vol: 1.6 }),\n noise({ type: 'bandpass', f: [620, 760], q: 0.8, d: 0.18, vol: 1.1 }),\n ...shrapnel(14, 0.7),\n ...debris(10, 0.35, 1.8, [0.1, 0.2]),\n ],\n ['sdk: frag grenade (M67, VOG-25, 40 mm): sharp crack, short body, fragments striking, a little debris'],\n ),\n blast(\n 'explosion_big',\n [\n crack([1900, 2300], 0.08, 2.4),\n noise({ f: [2200, 2600], f2: 90, d: 1.6, vol: 2.2, wet: 0.45 }),\n tone({ f: [52, 60], f2: 22, d: 1.6, vol: 1.9 }),\n noise({ f: [280, 330], f2: 60, a: 0.25, d: 2.8, vol: 0.8, wet: 0.6, delay: 0.05 }),\n ...debris(24, 0.5, 3.6, [0.12, 0.25]),\n ],\n ['sdk: big charge (C4, dynamite, a fuel station tank): crack, long deep roar, debris falling for 2 to 4 s'],\n ),\n blast(\n 'explosion_fuel',\n [\n noise({ type: 'highpass', f: [1700, 2000], a: 0.001, d: 0.05, vol: 1 }),\n tone({ f: [380, 450], f2: 300, d: 0.4, vol: 0.3 }),\n noise({ f: [1700, 2000], f2: 150, a: 0.03, d: 1.4, vol: 2.1, wet: 0.4 }),\n tone({ f: [48, 56], f2: 25, d: 1.2, vol: 1.7 }),\n noise({ type: 'bandpass', f: [450, 560], q: 0.6, a: 0.15, d: 2.2, vol: 0.85, wet: 0.5, delay: 0.1 }),\n ...debris(10, 0.5, 2.6, [0.08, 0.16]),\n ],\n ['sdk: a fuel vessel bursting (propane P13, fuel barrel, pump): the shell tearing, a fireball \"whoomp\" and its roar'],\n ),\n blast(\n 'explosion_car',\n [\n noise({ type: 'highpass', f: [1700, 2000], a: 0.001, d: 0.06, vol: 1.1 }),\n noise({ f: [1600, 1900], f2: 140, a: 0.03, d: 1.6, vol: 2.1, wet: 0.4 }),\n tone({ f: [44, 52], f2: 24, d: 1.4, vol: 1.8 }),\n noise({ type: 'bandpass', f: [420, 520], q: 0.6, a: 0.15, d: 2.6, vol: 0.9, wet: 0.5, delay: 0.1 }),\n ...glass(10, 0.04),\n tone({ f: [130, 150], f2: 85, d: 1.1, vol: 0.18, delay: [0.3, 0.5] }),\n ...debris(16, 0.6, 3.2, [0.1, 0.2]),\n ],\n ['sdk: a car going up: the fuel tank fireball, every window breaking, the body groaning, parts falling'],\n ),\n blast(\n 'explosion_pipe_bomb',\n [\n crack([2000, 2400], 0.07, 2.2),\n noise({ f: [2000, 2400], f2: 150, d: 0.8, vol: 1.9, wet: 0.35 }),\n tone({ f: [70, 82], f2: 30, d: 0.6, vol: 1.5 }),\n ...many(6, () => tone({ f: [1800, 3200], f2: 1200, d: [0.06, 0.12], vol: 0.06, delay: [0.05, 0.6] })),\n ...shrapnel(18, 0.9),\n ...debris(8, 0.4, 1.8, [0.08, 0.16]),\n ],\n ['sdk: pipe bomb: crack, body, the steel pipe flying apart in ringing pieces'],\n ),\n blast(\n 'explosion_rocket',\n [\n crack([2100, 2500], 0.08, 2.4),\n noise({ f: [2400, 2800], f2: 120, d: 1.1, vol: 2.1, wet: 0.4 }),\n tone({ f: [60, 70], f2: 26, d: 0.9, vol: 1.8 }),\n noise({ f: [350, 420], f2: 80, a: 0.08, d: 1.8, vol: 0.9, wet: 0.6, delay: 0.05 }),\n ...shrapnel(10, 0.8),\n ...debris(16, 0.4, 2.6, [0.1, 0.2]),\n ],\n ['sdk: rocket or anti-tank warhead (M72, AT4, RPG): hard crack, heavy body, debris'],\n ),\n blast(\n 'explosion_flashbang',\n [crack([1400, 1700], 0.12, 2.8), noise({ f: [1900, 2200], f2: 300, d: 0.35, vol: 1.3, wet: 0.3 }), tone({ f: [110, 130], f2: 60, d: 0.2, vol: 0.8 })],\n ['sdk: flashbang: a deafening crack with almost no body and no fragments'],\n ),\n blast(\n 'molotov_break_ignite',\n [\n ...glass(8, 0),\n noise({ f: [280, 340], f2: 2200, a: 0.12, d: 0.9, vol: 1.5, wet: 0.6, delay: 0.05 }),\n tone({ f: [85, 95], f2: 55, d: 0.4, vol: 0.5, delay: 0.08 }),\n ],\n ['sdk: molotov: the bottle breaking and the fuel catching with a \"fuuush\"'],\n FIRE_FALLOFF,\n ),\n blast(\n 'explosion_far',\n [\n noise({ f: [550, 650], f2: 80, a: 0.03, d: 2.5, vol: 2, wet: 1.4 }),\n tone({ f: [42, 48], f2: 25, d: 1.8, vol: 1.2 }),\n noise({ f: [350, 420], f2: 70, a: 0.1, d: 1.6, vol: 0.6, wet: 1.5, delay: [0.6, 1] }),\n ],\n ['sdk: any blast far away: no crack left, a dull thud and the echo rolling back'],\n BLAST_FAR_FALLOFF,\n ),\n blast(\n 'explosion_indoor_tail',\n [\n ...many(3, () => noise({ f: [650, 800], d: 0.12, vol: 0.5, delay: [0.04, 0.2] })),\n noise({ f: [850, 950], f2: 120, a: 0.05, d: 2.6, vol: 0.9, wet: 1.6, delay: 0.08 }),\n ],\n ['sdk: the room answering a blast inside it: slaps off the walls and a boomy tail'],\n ),\n]\n\n/** Fire: ignition, gas leaking from a vessel about to burst, a fire put out, and the crackles that ride on the fire loop. */\nexport const FIRE_SOUNDS: readonly SoundRecipe[] = [\n {\n ...blast(\n 'fire_ignite',\n [noise({ f: [230, 270], f2: 1500, a: 0.07, d: 0.5, vol: 1.6 }), tone({ f: [80, 90], f2: 55, d: 0.3, vol: 0.45 }), noise({ type: 'highpass', f: 3000, d: 0.3, vol: 0.1, delay: 0.1 })],\n ['sdk: fire catching, a soft \"fuuump\"'],\n FIRE_FALLOFF,\n ),\n group: 'fire_ignite',\n },\n {\n ...blast('gas_leak', [noise({ type: 'bandpass', f: [3200, 3800], q: 0.7, a: 0.08, d: { param: 'seconds' }, vol: 0.3 })], ['sdk: gas jetting from a punctured vessel'], FIRE_FALLOFF),\n vars: { seconds: 2 },\n },\n {\n ...blast(\n 'fire_extinguish',\n [noise({ type: 'highpass', f: [2300, 2700], a: 0.03, d: { param: 'seconds' }, vol: 0.3 }), noise({ type: 'bandpass', f: [800, 1000], q: 0.5, d: 0.5, vol: 0.25 })],\n ['sdk: water or foam on a fire: a steam puff and a sizzle'],\n FIRE_FALLOFF,\n ),\n vars: { seconds: 1.2 },\n },\n { ...blast('fire_crackle', [noise({ type: 'highpass', f: [1500, 3000], d: [0.01, 0.025], vol: [1.2, 2.2] })], ['sdk: a crackle of the fire'], FIRE_FALLOFF), group: 'fire_crackle' },\n { ...blast('fire_pop', [noise({ type: 'bandpass', f: [500, 1100], q: 1, d: [0.03, 0.06], vol: [3, 4.5] })], ['sdk: a log or a resin pocket popping'], FIRE_FALLOFF), group: 'fire_crackle' },\n]\n\n/** The roar of the fires: low, soft noise; `createDestructionSound` raises it with every part that burns and sprinkles crackles on it. */\nexport const FIRE_LOOP: LoopRecipe = {\n id: 'fire_loop',\n bus: 'world',\n order: 'chain_loop',\n source: { kind: 'noise', loop: true },\n filters: { mode: 'serial', bank: [{ type: 'lowpass', frequency: { set: 950 }, q: 0.5 }] },\n volume: 0,\n sources: ['sdk: the roar under the crackles of a fire'],\n}\n\n/** A rocket in flight (RPG-7, AT4, M72): the motor's steady roar behind it, dull and wide; the fallback of the recorded loop of the same id. */\nexport const ROCKET_MOTOR_LOOP: LoopRecipe = {\n id: 'rocket_motor_loop',\n bus: 'world',\n order: 'chain_loop',\n source: { kind: 'noise', loop: true },\n filters: { mode: 'serial', bank: [{ type: 'highpass', frequency: { set: 250 }, q: 0.6 }, { type: 'lowpass', frequency: { set: 5200 }, q: 0.5 }] },\n volume: 0,\n sources: ['sdk: the motor of a rocket in flight (a wide hiss with a low body, steady until the warhead goes off)'],\n}\n\n/** A smoke canister burning (an M18 and the like): a steady hiss of gas through the vents, bright and without crackles; the fallback of the recorded loop of the same id. */\nexport const SMOKE_HISS_LOOP: LoopRecipe = {\n id: 'smoke_grenade_hiss',\n bus: 'world',\n order: 'chain_loop',\n source: { kind: 'noise', loop: true },\n filters: { mode: 'serial', bank: [{ type: 'highpass', frequency: { set: 1400 }, q: 0.7 }, { type: 'lowpass', frequency: { set: 7000 }, q: 0.5 }] },\n volume: 0,\n sources: ['sdk: a smoke canister venting (the gas through its holes, steady for its whole burn)'],\n}\n\n/** The pin of a hand grenade pulled and the lever let go: two small metal clicks, heard only near. */\nexport const GRENADE_PIN_PULL: SoundRecipe = blast(\n 'grenade_pin_pull',\n [noise({ type: 'highpass', f: [3200, 4200], d: 0.025, vol: 0.5 }), noise({ type: 'bandpass', f: [2200, 2800], q: 2, d: 0.04, vol: 0.4, delay: 0.18 })],\n ['sdk: the ring pulled from the fuse, then the spoon flying off'],\n FIRE_FALLOFF,\n)\n\n/**\n * What is burning, for the sound: each fuel has its own roar (a gas jet, a fuel pool, wood, plastic) and its own share of crackles. The rules are the\n * same for all (the level grows with how much burns, fades with distance, never clips); only the timbre comes from the fuel.\n */\nexport const FIRE_FUELS = ['wood', 'fabric', 'plastic', 'gas', 'liquid'] as const\nexport type FireFuel = (typeof FIRE_FUELS)[number]\n\n/** The fuel of a burning material (`materials.json` of game-destruction). Data: a game adds its own materials through `DestructionSoundOptions.fuels`. */\nexport const FIRE_FUEL_OF: Readonly<Record<string, FireFuel>> = {\n wood_soft: 'wood',\n wood_hard: 'wood',\n plywood: 'wood',\n mdf: 'wood',\n green_wood: 'wood',\n foliage: 'wood',\n cactus: 'wood',\n paper: 'fabric',\n fabric: 'fabric',\n leather: 'fabric',\n foam: 'plastic',\n plastic: 'plastic',\n rubber: 'plastic',\n wax: 'plastic',\n}\n\n/** The loop each fuel plays. Fabric and paper share the wood roar until they have their own. */\nexport const FIRE_LOOP_OF: Readonly<Record<FireFuel, string>> = {\n wood: 'fire_loop',\n fabric: 'fire_loop',\n plastic: 'fire_loop_plastic',\n gas: 'fire_loop_gas',\n liquid: 'fire_loop_liquid',\n}\n\n/** How much each fuel crackles (0..1): wood snaps and pops, plastic now and then, a gas jet and a fuel pool not at all. */\nexport const FIRE_CRACKLE_OF: Readonly<Record<FireFuel, number>> = { wood: 1, fabric: 0.5, plastic: 0.35, gas: 0, liquid: 0 }\n\nconst roar = (id: string, bank: readonly FilterSpec[], source: string): LoopRecipe => ({\n id,\n bus: 'world',\n order: 'chain_loop',\n source: { kind: 'noise', loop: true },\n filters: { mode: 'serial', bank },\n volume: 0,\n sources: [source],\n})\n\n/** The synthesized roar of each fuel other than wood: the fallback of the recorded loops of the same id. */\nexport const FIRE_FUEL_LOOPS: readonly LoopRecipe[] = [\n // a gas jet: a steady, broad roar, brighter than wood and without crackles\n roar('fire_loop_gas', [{ type: 'highpass', frequency: { set: 220 }, q: 0.7 }, { type: 'lowpass', frequency: { set: 2400 }, q: 0.6 }], 'sdk: a gas jet burning (a vessel venting into the flame)'),\n // a fuel pool: a soft, low, rolling roar\n roar('fire_loop_liquid', [{ type: 'highpass', frequency: { set: 90 }, q: 0.7 }, { type: 'lowpass', frequency: { set: 650 }, q: 0.9 }], 'sdk: a pool of fuel burning'),\n // plastic and rubber: a thin sizzle over a low burn\n roar('fire_loop_plastic', [{ type: 'bandpass', frequency: { set: 1800 }, q: 0.6 }], 'sdk: plastic and rubber melting in the fire'),\n]\n\n/** The sound of a blast family. */\nexport const BLAST_SOUND_OF: Readonly<Record<BlastKind, string>> = {\n grenade: 'explosion_grenade',\n big: 'explosion_big',\n fuel: 'explosion_fuel',\n car: 'explosion_car',\n pipe_bomb: 'explosion_pipe_bomb',\n rocket: 'explosion_rocket',\n flashbang: 'explosion_flashbang',\n molotov: 'molotov_break_ignite',\n}\n","import type { Vec3 } from '@adatechnology/game-contracts'\nimport { FOLEY_BANK, GAME_SFX_BANK } from '@adatechnology/game-audio'\nimport type { AudioEngine, AudioLoopHandle } from '@adatechnology/game-audio'\n\nimport { IMPACT_BURST_GROUP } from './voice-groups'\nimport { BIG_BLAST_RADIUS, BLAST_FAR_DISTANCE, BLAST_KIND_OF, BLAST_SOUND_OF, FIRE_CRACKLE_OF, FIRE_FUEL_OF, FIRE_LOOP_OF } from './blast-fire'\nimport type { BlastKind, FireFuel } from './blast-fire'\nimport { DESTRUCTION_SOUND_BANK } from './recipes'\nimport type { SoundDetail } from '../types'\n\n/**\n * What a sound key plays: the recipe, its params, a scale on the volume the renderer gives, and (optionally) a louder recipe above a volume\n * (a big blast gets the long boom).\n */\nexport type SoundKeyRule = {\n readonly sound: string\n readonly params?: Readonly<Record<string, number>>\n readonly volumeScale?: number\n readonly above?: { readonly volume: number; readonly sound: string }\n /** A sound of this bank played when the engine does not know `sound` (a vehicle door without the vehicle bank registered shuts like metal). */\n readonly fallback?: string\n}\n\nexport type DestructionSoundStyle = 'art_scene' | 'game'\n\n/**\n * The keys of a blow on a material (`impactSoundKeys`, `breakSoundKeys`): `impact_<family>_<blow>`, `impact_<material>[_<blow>]`, `break_<...>`. The renderer\n * sends them before its legacy family key, so the first one with a rule plays; a game replaces any of them in `keys`.\n */\nexport const IMPACT_SOUND_KEYS: Readonly<Record<string, SoundKeyRule>> = {\n impact_metal_ballistic: { sound: 'metal_bullet' },\n impact_metal_blunt: { sound: 'metal_blunt' },\n impact_metal_slash: { sound: 'metal_blade' },\n impact_aluminium_ballistic: { sound: 'metal_thin' },\n impact_aluminium_blunt: { sound: 'metal_thin' },\n impact_copper_ballistic: { sound: 'metal_thin' },\n impact_copper_blunt: { sound: 'metal_thin' },\n impact_wood_ballistic: { sound: 'wood_hit' },\n impact_wood_blunt: { sound: 'wood_blunt' },\n impact_wood_slash: { sound: 'wood_blade' },\n break_wood: { sound: 'wood_splinter' },\n // the art scene's key for a part splintering and for a round striking steel or wood: the recordings answer them too\n splinter: { sound: 'wood_splinter' },\n shot_wood: { sound: 'wood_splinter' },\n shot_metal: { sound: 'metal_ping' },\n impact_mdf_ballistic: { sound: 'mdf_puff' },\n impact_mdf_blunt: { sound: 'mdf_puff', volumeScale: 0.8 },\n impact_glass_ballistic: { sound: 'glass_bullet' },\n impact_glass_blunt: { sound: 'glass_blunt' },\n impact_glass_slash: { sound: 'glass_blade' },\n impact_ceramic: { sound: 'ceramic_hit' },\n impact_ceramic_ballistic: { sound: 'ceramic_bullet' },\n impact_masonry_ballistic: { sound: 'masonry_bullet' },\n impact_masonry_blunt: { sound: 'masonry_blunt' },\n impact_masonry_slash: { sound: 'masonry_blade' },\n impact_plaster: { sound: 'plaster_puff' },\n impact_soil: { sound: 'soil_blunt' },\n impact_soil_ballistic: { sound: 'soil_bullet' },\n impact_sand: { sound: 'sand_hit' },\n impact_gravel: { sound: 'gravel_hit' },\n impact_plastic: { sound: 'plastic_hit' },\n impact_plastic_ballistic: { sound: 'plastic_bullet' },\n impact_rubber: { sound: 'rubber_hit' },\n impact_wax: { sound: 'wax_hit' },\n impact_soft_ballistic: { sound: 'soft_bullet' },\n impact_soft_blunt: { sound: 'fabric_hit' },\n impact_soft_slash: { sound: 'fabric_rip' },\n impact_paper: { sound: 'paper_hit' },\n impact_paper_slash: { sound: 'paper_tear' },\n impact_plant: { sound: 'leaf_rustle' },\n impact_plant_slash: { sound: 'branch_cut' },\n impact_flesh_fruit: { sound: 'fruit_splat' },\n ricochet_metal: { sound: 'ricochet_metal' },\n ricochet_masonry: { sound: 'ricochet_stone' },\n ricochet_soil: { sound: 'ricochet_stone' },\n ricochet_ceramic: { sound: 'ricochet_stone' },\n break_ceramic: { sound: 'ceramic_break' },\n break_tempered_glass: { sound: 'tempered_burst' },\n break_plastic: { sound: 'plastic_crack' },\n break_mdf: { sound: 'mdf_crumble' },\n break_soft: { sound: 'fabric_rip' },\n break_fabric: { sound: 'fabric_rip' },\n break_paper: { sound: 'paper_tear' },\n break_plant: { sound: 'branch_cut' },\n}\n\n/**\n * Every sound a blow, ricochet or break on a material can play (`sound`, `above.sound` and `fallback` of each rule of `rules`): a game preloads them on\n * the first input, so even the first ricochet or impact plays the recording instead of the synthesized recipe while the file is still loading.\n */\nexport const impactSoundIds = (rules: Readonly<Record<string, SoundKeyRule>> = IMPACT_SOUND_KEYS): string[] => {\n const ids = new Set<string>()\n for (const rule of Object.values(rules)) {\n ids.add(rule.sound)\n if (rule.above) ids.add(rule.above.sound)\n if (rule.fallback) ids.add(rule.fallback)\n }\n return [...ids]\n}\n\n/**\n * The keys `createDestructionRenderer` sends to `onSound`, mapped to the sounds the teams delivered. The Cena de Arte has a sound for every material\n * (clang, wood, glass, crumble, thud...); the game has four classes (impact, glass, wood, explosion) and its own explosion thump. Which team sound answers\n * which key is the kit's choice (the teams call the sounds, not the renderer's keys), so it is data: `keys` replaces any entry.\n */\nexport const DESTRUCTION_SOUND_KEYS: Readonly<Record<DestructionSoundStyle, Readonly<Record<string, SoundKeyRule>>>> = {\n art_scene: {\n impact_metal: { sound: 'clang' },\n impact_wood: { sound: 'wood_hit' },\n impact_glass: { sound: 'ping' },\n impact_masonry: { sound: 'chip' },\n impact_soft: { sound: 'thud' },\n // a round strikes: the steel rings high, glass cracks, wood and masonry chip, a soft part takes a dull thunk\n shot_metal: { sound: 'ping' },\n shot_wood: { sound: 'chip' },\n shot_glass: { sound: 'crack' },\n shot_masonry: { sound: 'chip' },\n shot_soft: { sound: 'thunk' },\n drag_wood: { sound: 'drag_wood' },\n drag_metal: { sound: 'drag_metal' },\n drag_glass: { sound: 'drag_glass' },\n drag_masonry: { sound: 'drag_masonry' },\n drag_soft: { sound: 'drag_soft' },\n // a leaf worked by hand (doors, lids, drawers): the latch, the hinge turning, the leaf meeting the frame, a locked one shaken\n leaf_latch: { sound: 'latch' },\n leaf_creak_wood: { sound: 'creak_wood' },\n leaf_creak_metal: { sound: 'creak_metal' },\n leaf_shut_wood: { sound: 'shut_wood' },\n leaf_shut_metal: { sound: 'shut_metal' },\n leaf_shut_glass: { sound: 'shut_metal', volumeScale: 0.6 },\n leaf_shut_masonry: { sound: 'shut_wood' },\n leaf_shut_soft: { sound: 'shut_soft' },\n leaf_rattle: { sound: 'rattle' },\n leaf_slide: { sound: 'slide' },\n // the keys of the item clips (furniture and vehicle doors, hoods, trunks, drawers)\n door_latch: { sound: 'latch' },\n hood_latch: { sound: 'latch' },\n trunk_latch: { sound: 'latch' },\n door_open: { sound: 'latch' },\n door_shut: { sound: 'shut_metal' },\n hood_shut: { sound: 'shut_metal' },\n trunk_shut: { sound: 'shut_metal' },\n door_close: { sound: 'shut_wood', volumeScale: 0.7 },\n // a vehicle's leaves (the vehicle bank of game-vehicles-three): a car door shuts with a padded thump and a latch, not like a fridge\n vehicle_door_open: { sound: 'car_door_open', fallback: 'latch' },\n vehicle_door_shut: { sound: 'car_door_close', fallback: 'shut_metal' },\n vehicle_trunk_open: { sound: 'car_door_open', fallback: 'latch' },\n vehicle_trunk_shut: { sound: 'car_trunk_close', fallback: 'shut_metal' },\n vehicle_hood_open: { sound: 'car_hood_open', fallback: 'latch' },\n vehicle_hood_shut: { sound: 'car_hood_close', fallback: 'shut_metal' },\n drawer_open: { sound: 'slide' },\n drawer_close: { sound: 'slide' },\n lid_open: { sound: 'latch' },\n lid_close: { sound: 'shut_soft' },\n flap_open: { sound: 'latch' },\n flap_close: { sound: 'shut_soft' },\n // an item taken in the hand, by what it is made of (game-audio's KIT_SAMPLE_ALIASES puts recordings on these ids)\n grab_metal: { sound: 'grab_hard' },\n grab_wood: { sound: 'grab_hard' },\n grab_glass: { sound: 'grab_hard', volumeScale: 0.7 },\n grab_masonry: { sound: 'grab_hard' },\n grab_soft: { sound: 'grab_soft' },\n shatter_glass: { sound: 'glass_shatter' },\n crumble: { sound: 'crumble' },\n splinter: { sound: 'crack' },\n ricochet: { sound: 'ping' },\n unscrew: { sound: 'chip' },\n detach: { sound: 'thunk' },\n ignite: { sound: 'fire_ignite' },\n primed: { sound: 'gas_leak' },\n extinguish: { sound: 'fire_extinguish' },\n melt_sizzle: { sound: 'hiss', params: { seconds: 0.6 } },\n // the blast family comes from the explosion's effect (`BLAST_KIND_OF`); this rule answers only an explosion the kit cannot place\n explode: { sound: 'explosion_grenade', above: { volume: 0.9, sound: 'explosion_big' } },\n ...IMPACT_SOUND_KEYS,\n },\n game: {\n impact_metal: { sound: 'sfx_impact' },\n impact_wood: { sound: 'sfx_wood' },\n impact_glass: { sound: 'sfx_glass' },\n impact_masonry: { sound: 'sfx_impact' },\n impact_soft: { sound: 'sfx_flesh' },\n shatter_glass: { sound: 'sfx_glass' },\n crumble: { sound: 'sfx_impact' },\n splinter: { sound: 'sfx_wood' },\n explode: { sound: 'explosion_boom' },\n },\n}\n\n/** The rumble of a blast past `blastFarDistance`, and the tail a confined one adds. */\nconst BLAST_FAR_SOUND = 'explosion_far'\nconst BLAST_INDOOR_TAIL_SOUND = 'explosion_indoor_tail'\n\n/**\n * Every sound an explosion and what it leaves can play: the boom of each blast family, the far rumble and the indoor tail, the fire loops and\n * crackles, and each blow, break and fall on a material (`impactSoundIds` of `rules`). A game preloads them (`AudioEngine.preload`) so that no\n * first blast decodes its recordings in play; derived from the tables, so a new family or material rule is covered with no list to update.\n */\nexport const blastSoundIds = (rules: Readonly<Record<string, SoundKeyRule>> = DESTRUCTION_SOUND_KEYS.art_scene): string[] => [\n ...new Set([...Object.values(BLAST_SOUND_OF), BLAST_FAR_SOUND, BLAST_INDOOR_TAIL_SOUND, ...Object.values(FIRE_LOOP_OF), 'fire_crackle', 'fire_pop', ...impactSoundIds(rules)]),\n]\n\nexport type DestructionSoundOptions = {\n /** Which team answers the keys (default `art_scene`, the kit mix). `game` falls back to the art scene for the keys the game has no sound for. */\n readonly style?: DestructionSoundStyle\n /** Replaces or adds a key's rule; `null` silences it. A key without a rule that is the id of a registered sound (the foley bank's) plays that sound. */\n readonly keys?: Readonly<Record<string, SoundKeyRule | null>>\n /** The fire loop: the volume each burning part adds and the most it reaches (the page never raises it, so these are the kit's). */\n readonly fire?: { readonly perFire?: number; readonly max?: number }\n /** Burn loop on or off (default on). */\n readonly burnLoop?: boolean\n /** The loop of the wood fire (default `fire_loop`; `burn_loop` is the art scene's bright one). */\n readonly fireLoop?: string\n /** Adds to or changes `FIRE_FUEL_OF`: which fuel a burning material sounds like. */\n readonly fuels?: Readonly<Record<string, FireFuel>>\n /** Adds to or changes `FIRE_LOOP_OF`: the loop of each fuel. */\n readonly fireLoops?: Partial<Readonly<Record<FireFuel, string>>>\n /** The fuel of a fire whose material is not in the table (default `wood`). */\n readonly defaultFuel?: FireFuel\n /** Crackles per second over the fire loop: `base + perSqrtFire × √(parts burning)`, at most `max` (default 2, 3, 14). `false` turns them off. */\n readonly crackles?: false | { readonly base?: number; readonly perSqrtFire?: number; readonly max?: number; readonly volume?: number }\n /** Adds to or changes `BLAST_KIND_OF`: which family a named explosion (`effect`) sounds like. */\n readonly blastKinds?: Readonly<Record<string, BlastKind>>\n /** Metres past which a blast plays `explosion_far` instead of its own sound (default `BLAST_FAR_DISTANCE`). */\n readonly blastFarDistance?: number\n /** `confinement` of a blast (from its report) from which the indoor tail plays too (default 1.3). */\n readonly indoorConfinement?: number\n /** Seed of the crackle timing (default 1). */\n readonly seed?: number\n}\n\nexport type DestructionSound = {\n /** Pass to `createDestructionRenderer({ onSound })`. */\n readonly onSound: (key: string, point: Vec3, volume: number, detail?: SoundDetail) => void\n /** Moves the fire crackles on; call once per frame with the frame time in seconds. */\n update(dt: number): void\n /** The sound an explosion plays (`explode` with its detail), for a listener at the engine's listener position. */\n blastSound(point: Vec3, volume: number, detail?: SoundDetail): string\n /** The rule a key resolves to, if any; with `detail`, the rule `onSound` would play (the first of `detail.keys` that has one, else `key`'s). */\n rule(key: string, detail?: SoundDetail): SoundKeyRule | undefined\n /** Parts burning now. */\n readonly burning: () => number\n /** Parts burning now, by fuel. */\n readonly burningBy: () => Readonly<Partial<Record<FireFuel, number>>>\n /** Puts every fire sound out (the scene was cleared); the engine and the bank stay. */\n reset(): void\n dispose(): void\n}\n\nexport const DEFAULT_FIRE = { perFire: 0.08, max: 0.45 } as const\n/** A fire loop that ends fades out over this many seconds (moved on by `update`) before it is stopped. */\nexport const FIRE_FADE_SECONDS = 0.4\nexport const DEFAULT_CRACKLES = { base: 2, perSqrtFire: 3, max: 14, volume: 0.5 } as const\nexport const DEFAULT_INDOOR_CONFINEMENT = 1.3\n\n/**\n * Plays the renderer's sound keys on a game-audio engine: the bank is registered in the engine, a key becomes a positional sound at the point, and\n * `burn_loop` / `burn_end` (a part starts to burn, a part burns out or is put out) drive one fire loop whose volume follows how many parts burn, with\n * crackles at the burning points (`update`). An explosion plays the sound of its family (`BLAST_KIND_OF` by its effect), the far rumble past\n * `blastFarDistance` and the indoor tail when the blast was confined.\n */\nexport function createDestructionSound(engine: AudioEngine, options: DestructionSoundOptions = {}): DestructionSound {\n engine.register(DESTRUCTION_SOUND_BANK)\n engine.register(GAME_SFX_BANK)\n // the foley of the hand (doors, lids, drawers, items): its ids are keys of their own, played as they are\n engine.register(FOLEY_BANK)\n const fire = { ...DEFAULT_FIRE, ...options.fire }\n const crackles = options.crackles === false ? null : { ...DEFAULT_CRACKLES, ...options.crackles }\n const fireLoop = options.fireLoop ?? 'fire_loop'\n const kinds: Readonly<Record<string, BlastKind>> = { ...BLAST_KIND_OF, ...options.blastKinds }\n const farDistance = options.blastFarDistance ?? BLAST_FAR_DISTANCE\n const indoorFrom = options.indoorConfinement ?? DEFAULT_INDOOR_CONFINEMENT\n const rules: Record<string, SoundKeyRule | null | undefined> = { ...DESTRUCTION_SOUND_KEYS.art_scene, ...(options.style === 'game' ? DESTRUCTION_SOUND_KEYS.game : {}), ...options.keys }\n // a blast takes its family's sound unless the host chose the explode rule itself (a style or a key of its own)\n const blastByKind = options.style !== 'game' && !(options.keys && 'explode' in options.keys)\n const channel = engine.channel({ seed: options.seed ?? 1 })\n const fuelOf: Readonly<Record<string, FireFuel>> = { ...FIRE_FUEL_OF, ...options.fuels }\n const loopOf: Readonly<Record<FireFuel, string>> = { ...FIRE_LOOP_OF, ...(options.fireLoop ? { wood: fireLoop, fabric: fireLoop } : {}), ...options.fireLoops }\n const defaultFuel = options.defaultFuel ?? 'wood'\n // one loop per sound (fuels that share a loop share its level); a loop stops when nothing of its fuels burns\n const loops = new Map<string, AudioLoopHandle>()\n // where the fires are and what burns there: the crackles come from the points whose fuel crackles\n const fires: { readonly point: Vec3; readonly fuel: FireFuel }[] = []\n let nextCrackle = 0\n // loops whose fire ended: silenced now, stopped when their fade is over\n const fading: { readonly handle: AudioLoopHandle; left: number }[] = []\n\n const fadeOut = (handle: AudioLoopHandle): void => {\n handle.set({ volume: 0 })\n fading.push({ handle, left: FIRE_FADE_SECONDS })\n }\n\n const fuelFor = (detail: SoundDetail | undefined): FireFuel => detail?.fuel ?? (detail?.material !== undefined ? fuelOf[detail.material] : undefined) ?? defaultFuel\n\n const setFire = (): void => {\n if (options.burnLoop === false) return\n const count = new Map<string, number>()\n for (const f of fires) {\n const id = loopOf[f.fuel]\n count.set(id, (count.get(id) ?? 0) + 1)\n }\n for (const [id, handle] of loops) {\n if (count.has(id)) continue\n fadeOut(handle)\n loops.delete(id)\n }\n for (const [id, n] of count) {\n let handle = loops.get(id)\n if (!handle) {\n handle = engine.loop(id)\n loops.set(id, handle)\n }\n handle.set({ volume: Math.min(fire.max, fire.perFire * n) })\n }\n }\n\n // the nearest fire of that fuel goes out (any fuel when the end does not say)\n const forget = (point: Vec3, fuel: FireFuel | undefined): void => {\n let best = -1\n let bestD = Infinity\n fires.forEach((f, i) => {\n if (fuel !== undefined && f.fuel !== fuel) return\n const d = (f.point[0] - point[0]) ** 2 + (f.point[1] - point[1]) ** 2 + (f.point[2] - point[2]) ** 2\n if (d < bestD) {\n bestD = d\n best = i\n }\n })\n if (best < 0 && fuel !== undefined) forget(point, undefined)\n else if (best >= 0) fires.splice(best, 1)\n }\n\n const reset = (): void => {\n for (const handle of loops.values()) fadeOut(handle)\n loops.clear()\n fires.length = 0\n }\n const dispose = (): void => {\n for (const handle of loops.values()) handle.stop()\n loops.clear()\n for (const { handle } of fading) handle.stop()\n fading.length = 0\n fires.length = 0\n }\n\n const blastSound = (point: Vec3, volume: number, detail?: SoundDetail): string => {\n const named = detail?.effect === undefined ? undefined : kinds[detail.effect]\n const kind = named ?? ((detail?.radius ?? 0) >= BIG_BLAST_RADIUS || volume >= 0.9 ? 'big' : 'grenade')\n const sound = BLAST_SOUND_OF[kind]\n const distance = engine.plan(sound, { position: point, seed: 1 })?.distance ?? 0\n // a molotov is a fire, not a blast: it never turns into the far rumble\n return kind !== 'molotov' && distance > farDistance ? BLAST_FAR_SOUND : sound\n }\n\n return {\n onSound(key, point, volume, detail) {\n if (key === 'burn_loop') {\n fires.push({ point, fuel: fuelFor(detail) })\n setFire()\n return\n }\n if (key === 'burn_end') {\n forget(point, detail?.fuel ?? (detail?.material !== undefined ? fuelOf[detail.material] : undefined))\n setFire()\n return\n }\n if (key === 'explode' && blastByKind) {\n const sound = blastSound(point, volume, detail)\n engine.play(sound, { position: point, volume })\n if (sound !== BLAST_FAR_SOUND && sound !== 'molotov_break_ignite' && (detail?.confinement ?? 1) >= indoorFrom) engine.play(BLAST_INDOOR_TAIL_SOUND, { position: point, volume })\n return\n }\n // the most specific key that has a rule (material and blow, material, family and blow, family), else the key itself (a `shot_` key with no rule\n // falls back to its `impact_` one); `null` on a specific key silences it\n let rule: SoundKeyRule | null | undefined\n for (const k of detail?.keys ?? []) {\n if (k in rules) {\n rule = rules[k]\n break\n }\n }\n if (rule === undefined) rule = key in rules ? rules[key] : rules[key.replace(/^shot_/, 'impact_')]\n if (rule === null) return\n if (!rule) {\n // a key with no rule that names a registered sound plays that sound (the foley ids: `door_wood_close`, `item_pickup_metal`...)\n if (engine.registry.sound(key)) engine.play(key, { position: point, volume })\n return\n }\n const wanted = rule.above && volume >= rule.above.volume ? rule.above.sound : rule.sound\n const sound = rule.fallback && !engine.registry.sound(wanted) ? rule.fallback : wanted\n const params = detail?.seconds === undefined ? rule.params : { ...rule.params, seconds: detail.seconds }\n engine.play(sound, { position: point, volume: volume * (rule.volumeScale ?? 1), intensity: Math.min(1, Math.max(0, volume)), group: IMPACT_BURST_GROUP, ...(params ? { params } : {}) })\n },\n update(dt) {\n for (let i = fading.length - 1; i >= 0; i--) {\n const entry = fading[i] as (typeof fading)[number]\n entry.left -= dt\n if (entry.left > 0) continue\n entry.handle.stop()\n fading.splice(i, 1)\n }\n if (!crackles || fires.length === 0 || options.burnLoop === false) return\n // only the fuels that crackle count: a gas jet or a fuel pool roars without snapping\n const weight = fires.reduce((sum, f) => sum + FIRE_CRACKLE_OF[f.fuel], 0)\n if (weight <= 0) return\n nextCrackle -= dt\n // at most a few crackles per frame, even after a long one\n for (let i = 0; i < 4 && nextCrackle <= 0; i++) {\n const rate = Math.min(crackles.max, crackles.base * Math.min(1, weight) + crackles.perSqrtFire * Math.sqrt(weight))\n nextCrackle += (0.4 + channel.random() * 1.2) / rate\n let pick = channel.random() * weight\n const at = fires.find((f) => (pick -= FIRE_CRACKLE_OF[f.fuel]) <= 0) ?? (fires[fires.length - 1] as (typeof fires)[number])\n engine.play(channel.random() < 0.18 ? 'fire_pop' : 'fire_crackle', { position: at.point, volume: crackles.volume })\n }\n if (nextCrackle < 0) nextCrackle = 0\n },\n blastSound,\n rule(key, detail) {\n for (const k of detail?.keys ?? []) if (k in rules) return rules[k] ?? undefined\n return rules[key] ?? undefined\n },\n burning: () => fires.length,\n burningBy: () => {\n const by: Partial<Record<FireFuel, number>> = {}\n for (const f of fires) by[f.fuel] = (by[f.fuel] ?? 0) + 1\n return by\n },\n reset,\n dispose,\n }\n}\n","import { VOICE_GROUPS } from '@adatechnology/game-audio'\nimport type { VoiceGroup } from '@adatechnology/game-audio'\n\n/** The voice group every impact, break and ricochet of the destruction sounds plays in (`createDestructionSound` passes it as `PlayOptions.group`). */\nexport const IMPACT_BURST_GROUP = 'impact_burst'\n\n/**\n * `VOICE_GROUPS` plus the cap on a burst of impacts: one blast with fragments makes hundreds of them in one frame (276 voices, about 12 ms), and only the\n * 16 loudest are built, 1.4x louder when others were dropped. 16 is half the engine's 32-voice cap, so impacts cannot take the weapons' and voices' places.\n * The host passes it as the engine's `groups`, which needs `deferredStart`.\n */\nexport const DESTRUCTION_VOICE_GROUPS: Readonly<Record<string, VoiceGroup>> = {\n ...VOICE_GROUPS,\n [IMPACT_BURST_GROUP]: {\n maxPerBurst: 16,\n burstBoost: 1.4,\n sources: ['sdk: a blast with fragments asks for hundreds of impact voices in one frame (room log: 276 voices, about 12 ms); the sixteen loudest play'],\n },\n}\n","// The recorded files of the blasts and the fire (`@adatechnology/game-audio/assets/sfx/explosoes-fogo`, field recordings): the numbers each sound id\n// needs on top of its files. Same ids as the synthesized recipes of `blast-fire.ts`, which stay as the fallback while the files load, when they fail,\n// and for every family that has no recording yet (fuel, pipe bomb, rocket, the indoor tail).\nimport { sampleBankFromManifest } from '@adatechnology/game-audio'\nimport type { SampleDefaults, SampleSound, SfxManifest, SoundBank } from '@adatechnology/game-audio'\nimport { BLAST_FALLOFF, BLAST_FAR_FALLOFF, FIRE_FALLOFF } from './blast-fire'\n\n/** The numbers of one recorded sound, plus whether it loops (the fire's roar). */\nexport type BlastFireSampleDefaults = SampleDefaults & { readonly loop?: boolean | { readonly crossfade?: number } }\n\nconst blast = (gain: number): BlastFireSampleDefaults => ({ bus: 'world', gain, falloff: BLAST_FALLOFF, cutoffK: 0.006, priority: 3 })\nconst fire = (gain: number, group?: string): BlastFireSampleDefaults => ({ bus: 'world', gain, falloff: FIRE_FALLOFF, cutoffK: 0.01, ...(group ? { group } : {}) })\n\n/**\n * The sounds of the blasts and the fire that have recorded takes, with their bus, level and distance curve (the recipes' own curves, so a file and its\n * fallback fade alike with distance). Data: a game passes its own table to `blastFireSampleBank`.\n */\nexport const BLAST_FIRE_SAMPLES: Readonly<Record<string, BlastFireSampleDefaults>> = {\n explosion_grenade: blast(1),\n explosion_big: blast(1),\n explosion_car: blast(1),\n explosion_flashbang: blast(1),\n explosion_rocket: blast(1),\n molotov_break_ignite: blast(0.8),\n // the far takes are already muffled: no extra distance lowpass\n explosion_far: { bus: 'world', gain: 1, falloff: BLAST_FAR_FALLOFF, cutoffK: 0, priority: 2 },\n fire_ignite: fire(0.8, 'fire_ignite'),\n fire_crackle: fire(0.8, 'fire_crackle'),\n fire_pop: fire(0.6, 'fire_crackle'),\n fire_extinguish: fire(0.7),\n gas_leak: fire(0.5),\n // the roar: recorded fires chained with a crossfade (the level comes from `createDestructionSound`, by how much burns)\n fire_loop: { bus: 'world', gain: 4, loop: { crossfade: 1 } },\n // each fuel has its own roar: a gas jet (burners and torches), a pool of fuel, plastic and rubber sizzling under the flames\n fire_loop_gas: { bus: 'world', gain: 6, loop: { crossfade: 1 } },\n fire_loop_liquid: { bus: 'world', gain: 3.5, loop: { crossfade: 1 } },\n fire_loop_plastic: { bus: 'world', gain: 1, loop: { crossfade: 0.6 } },\n // a smoke canister venting: a gas hiss chained like the fire roar (the level comes from the room, by how near the burning canisters are)\n smoke_grenade_hiss: { bus: 'world', gain: 1, loop: { crossfade: 0.8 } },\n // the motor of a rocket in flight, chained like the roar of a fire (the room sets the level by how near the rocket is)\n rocket_motor_loop: { bus: 'world', gain: 1, loop: { crossfade: 0.5 } },\n // the ring and the spoon of a hand grenade: a small metal latch\n grenade_pin_pull: fire(0.5),\n}\n\nexport type BlastFireSampleBankOptions = {\n /** Bank id (default 'destruction-samples'). */\n readonly id?: string\n /** Where the manifest's folder is served (`/sfx/`); default ''. */\n readonly baseUrl?: string\n /** Numbers per id (default `BLAST_FIRE_SAMPLES`). */\n readonly sounds?: Readonly<Record<string, BlastFireSampleDefaults>>\n}\n\n/**\n * A bank of the recorded blasts and fire from the kit's sound manifest. Register it with the engine next to `DESTRUCTION_SOUND_BANK`: each id plays\n * its files once loaded and its synthesized recipe until then.\n */\nexport function blastFireSampleBank(manifest: SfxManifest, options: BlastFireSampleBankOptions = {}): SoundBank {\n const sounds = options.sounds ?? BLAST_FIRE_SAMPLES\n const bank = sampleBankFromManifest(manifest, { id: options.id ?? 'destruction-samples', ...(options.baseUrl === undefined ? {} : { baseUrl: options.baseUrl }), sounds })\n const samples: SampleSound[] = (bank.samples ?? []).map((sample) => {\n const loop = sounds[sample.id]?.loop\n return loop === undefined ? sample : { ...sample, loop }\n })\n return { ...bank, samples }\n}\n"],"mappings":";;;;;AAWO,IAAM,qBAAgF;AAAA,EAC3F,CAAC,SAAS,OAAO;AAAA,EACjB,CAAC,SAAS,OAAO;AAAA,EACjB,CAAC,WAAW,SAAS;AAAA,EACrB,CAAC,QAAQ,MAAM;AAAA,EACf,CAAC,WAAW,SAAS;AAAA,EACrB,CAAC,QAAQ,MAAM;AAAA,EACf,CAAC,SAAS,OAAO;AAAA,EACjB,CAAC,WAAW,SAAS;AAAA,EACrB,CAAC,UAAU,QAAQ;AAAA,EACnB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,UAAU,MAAM;AACnB;AAGO,SAAS,aAAa,KAAwD;AACnF,QAAM,OAAO,KAAK,QAAQ,CAAC;AAC3B,aAAW,CAAC,KAAK,MAAM,KAAK,mBAAoB,KAAI,KAAK,SAAS,GAAG,EAAG,QAAO;AAC/E,SAAO;AACT;AAKA,IAAM,UAAU,CAAC,QAAgB,UAAkB,QAAkC,SAA2C;AAC9H,QAAM,OAAiB,CAAC;AACxB,MAAI,YAAY,KAAM,MAAK,KAAK,GAAG,MAAM,IAAI,QAAQ,IAAI,IAAI,EAAE;AAC/D,MAAI,SAAU,MAAK,KAAK,GAAG,MAAM,IAAI,QAAQ,EAAE;AAC/C,MAAI,UAAU,KAAM,MAAK,KAAK,GAAG,MAAM,IAAI,MAAM,IAAI,IAAI,EAAE;AAC3D,MAAI,OAAQ,MAAK,KAAK,GAAG,MAAM,IAAI,MAAM,EAAE;AAC3C,SAAO;AACT;AAMO,SAAS,g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AAY,SAAS,EAAE,GAAG,QAAQ,KAAK;AAAA,EACzD,CAAC;AACD,SAAO,EAAE,GAAG,MAAM,QAAQ;AAC5B;","names":["DEFERRED_QUEUE_ID","createVfx","far","markKitOrigin","extent","FIRST_CAPACITY","dot","glass","markKitOrigin","off","scene","off","cross","planes","bx","bz","r","s","rows","along","rows","solids","cross","visit","reachAlong","x","z","pending","WAKE_MARGIN","visit","apart","made","same","impact","off","SLAM_MIN_SPEED","SLAM_BOUNCE","SLAM_FLOOR_NORMAL","MU_STATIC","MU_DYNAMIC","ROLLING_RESISTANCE","STILL_SPEED","STILL_SPIN","STEADY_TURN","STEADY_SECONDS","HARD_LANDING","NARROW","TOPPLE","SUPPORT_CHECKS","SUPPORT_GAP","near","far","impact","dot","c","off","over","along","apart","v","t","j","turn","scene","visit","kitOriginOf","markKitOrigin","debrisColor","inferJoints","createPhysicsLoop","scene","along","turn","dot","triangles","along","geo","write","noise","SETTLE_SECONDS","kitOriginOf","markKitOrigin","BATCHED_LAYER","kitOriginOf","markKitOrigin","BATCHED_LAYER","scene","CRATER_RADIUS","debrisColor","materialsOf","sameNumbers","DEFERRED_QUEUE_ID","createVfx","put","axis","radius","ordered","same","made","kitOriginOf","crack","tone","fire","turn","markKitOrigin","triangles","pos","quat","scale","c","reachOf","cross","isPhysicsLoop","blast","many","noise","sceneRecipe","tone","sceneRecipe","noise","tone","many","leaf","fire","sound","blast"]}