@adatechnology/game-vehicles-three 0.12.1 → 0.13.1
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/{chunk-LVDWW5KZ.js → chunk-XULE4MKH.js} +58 -3
- package/dist/chunk-XULE4MKH.js.map +1 -0
- package/dist/index.global.js +205 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +10 -7
- package/dist/chunk-LVDWW5KZ.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/test-area/module.ts","../src/build.ts","../src/lite.ts","../src/colliders.ts","../src/collider-fit.ts","../src/hull-plan-cache.ts","../src/vehicle-lod.ts","../src/cabin-smoke.ts","../src/rain-cover.ts","../src/test-area/lane-damage.ts","../src/test-area/physical-car.ts","../src/crash-parts.ts","../src/crash-parts-clamp.ts","../src/crash-parts-chassis.ts","../src/crash-parts-math.ts","../src/crash-parts-bodies.ts","../src/test-area/run-over-link.ts","../src/test-area/scenarios.ts","../src/test-area/text.ts","../src/audio/profiles.ts","../src/test-area/types.ts","../src/audio/engine-mix.ts","../src/audio/vehicle-sound.ts","../src/audio/bank.ts","../src/test-area/proving/module.ts","../src/test-area/proving/cockpit.ts","../src/body.ts","../src/dashboard.ts","../src/lamps.ts","../src/windshield-mist.ts","../src/audio/engine-budget.ts","../src/wheel-roll.ts","../src/test-area/proving/crash.ts","../src/test-area/proving/systems-text.ts","../src/test-area/proving/text.ts"],"sourcesContent":["import type * as THREE_NS from 'three'\nimport { DEFERRED_PRIORITY, DEFERRED_QUEUE_ID, footprintBlocker } from '@adatechnology/game-contracts'\nimport { discardObject3D } from '@adatechnology/game-shapes-three'\nimport type { AnimationClipSpec, Footprint, BenchChange, ModuleArea, ModuleControl, ModuleHost, ModuleLayer, ModuleMetric, ModuleScenario, TestableItem, TestableModule, Vec3 } from '@adatechnology/game-contracts'\nimport { buildVehicleItem, crackedGlassMaterial, createCreaseQueue, createVehicleDestructible, createVehicleKit } from '@adatechnology/game-vehicles'\nimport type { ParticleMaterials, VehicleContext, VehicleItem, VehicleKit } from '@adatechnology/game-vehicles'\nimport { isRenderPools } from '@adatechnology/game-render-three'\nimport { createArcadeDriver, createSemiSimDriver, createSurfaces, vehicleCorners } from '@adatechnology/game-vehicles-driving'\n\nimport { colorFromSeed, fleetDims, fleetHullCeilingOf, installFleet, paintPalettes, paletteOf } from '@adatechnology/game-vehicles-fleet'\n\nimport { createVehiclesThree, primaryPaint } from '../build'\nimport { createVehicleColliders } from '../colliders'\nimport { createHullPlanCache } from '../hull-plan-cache'\nimport { createVehicleLod, createVehicleLodQueue } from '../vehicle-lod'\nimport type { VehicleLod } from '../vehicle-lod'\nimport { createCabinSmoke } from '../cabin-smoke'\nimport { createVehicleRainCovers } from '../rain-cover'\nimport { createLaneDamage, LANE_DAMAGE } from './lane-damage'\nimport type { LaneDamage } from './lane-damage'\nimport { createPhysicalCar, physicalCarColliders, physicsServicesOf } from './physical-car'\nimport { createRunOverLink } from './run-over-link'\nimport type { RunOverLink } from './run-over-link'\nimport type { PhysicalCar } from './physical-car'\nimport { createScenarios } from './scenarios'\nimport { fill, TEXT } from './text'\nimport { LIBRARY_BANK } from '@adatechnology/game-audio'\nimport { DEFAULT_TEST_WRECKS, defaultEffectIds, defaultSoundIds } from './types'\nimport type { EffectsLike, VehiclesContext, VehiclesTestFleet, VehiclesTestOptions } from './types'\nimport { createVehicleSound, slideOfGrip } from '../audio/vehicle-sound'\nimport type { VehicleSound } from '../audio/vehicle-sound'\nimport { VEHICLE_PRELOAD_SOUNDS, VEHICLE_SOUND_BANK } from '../audio/bank'\n\nexport const VEHICLES_AREA_ID = 'vehicles_area'\n\n/** The eight vehicles of the Frota test page, in its order, and the item id each one has in the area. */\nexport const DEFAULT_TEST_VEHICLES: readonly string[] = ['compact_hatch', 'midsize_sedan', 'midsize_pickup', 'sport_bike', 'box_truck', 'city_bus', 'battle_tank', 'attack_helicopter']\nconst ITEM_OF: Readonly<Record<string, string>> = { compact_hatch: 'hatch', midsize_sedan: 'sedan', midsize_pickup: 'pickup', sport_bike: 'sport_bike', box_truck: 'box_truck', city_bus: 'city_bus', battle_tank: 'battle_tank', attack_helicopter: 'attack_helicopter' }\nconst itemId = (key: string): string => ITEM_OF[key] ?? key\n\n/** One item of the area: the fleet vehicle it is built from, its item id and, for a wreck, the scenario built into it. */\ntype Entry = { readonly key: string; readonly id: string; readonly scenario?: string }\n\n/** Triangles of collider work per update when a vehicle is placed: a car fills in over about ten updates. */\nconst COLLIDER_BUDGET = 25000\nconst LANE = { z: 11, from: -12, wall: 13 }\nconst CRASH_WALL = { length: 6, height: 2, thickness: 0.15 } as const\n/** A rim on the road throws a burst of sparks this often. */\nconst SPARK_EVERY_S = 0.08\n/** The lane damages of a tyre. */\nconst TYRE_DAMAGE: ReadonlySet<LaneDamage> = new Set<LaneDamage>(['flat_tyre', 'torn_tyre', 'run_flat'])\n/** Radians a door, hood or lid may be off its rest and still count as shut. */\nconst LEAF_REST_RADIANS = 0.02\nconst MATERIAL_COLOURS: Record<string, number> = { metal: 0xcccccc, glass: 0x44aaff, rubber: 0xff9900, fuel: 0xff3300 }\n/** Seconds the lane car idles after the key is turned (the starter and the engine catching) before it pulls away. */\nconst LANE_START_S = 1.2\nconst ZONE_COLOURS: Record<string, number> = { door: 0x55dd55, hood: 0xdddd33, lid: 0xdd9933, bumper: 0xdd55dd, glass: 0x44aaff, light: 0xffffff, wheel: 0xff7733 }\n\ntype Three = typeof THREE_NS\n/** Parts whose bottom is above this (m, from the ground) are overhead: the player walks under them (the helicopter's rotor, the tank's gun). */\nconst BODY_HEIGHT = 1.7\ntype Placed = {\n readonly root: THREE_NS.Group\n readonly key: string\n /** The damage scenario built into a wreck (its size is not the design size, so it is left out of the size error). */\n readonly scenario?: string\n readonly item: VehicleItem\n readonly index: number\n paint?: THREE_NS.MeshStandardMaterial\n /** Near in full, far fused (`createVehicleLod`); none in the light quality, which is fused already. */\n lod?: VehicleLod\n /** Hit: its damage only exists on the full model. */\n touched?: boolean\n /** Leaves away from their rest (an open door): drawn in full while any is. */\n posedParts?: Set<string>\n size?: { length: number; width: number; height: number }\n /** What the walking player bumps into, in the root's own space: the box of the parts low enough to hit a body (a rotor overhead is walked under). */\n footprint?: Footprint\n helpers: THREE_NS.Object3D[]\n}\n\n/**\n * The vehicles test area as a `TestableModule`: the vehicles of the Frota test (hatch, sedan, pickup, sport bike, box truck, city bus, battle tank, attack helicopter), each with its own\n * `DestructibleImpl` and its door, hood and trunk clips, the eleven scenarios of that page (literal) and two for the drivers. The bench sets the quality (full or light mode), the paint\n * by seed and palette, the driving mode and the surface, and shows the damageable boxes by material, the zones by type and the axes of the output frame. Effects (fire, glass, sparks,\n * exhaust) are requested by id through `host.effects` when the host has it; this module draws none.\n */\nexport function createVehiclesTestModule(options: VehiclesTestOptions = {}): TestableModule<VehiclesContext> & { readonly placed: ReadonlyMap<string, unknown> } {\n const fleet: VehiclesTestFleet = options.fleet ?? { colorFromSeed, fleetDims, hullCeilingOf: fleetHullCeilingOf, installFleet, paintPalettes, paletteOf }\n const locale = options.locale ?? 'pt-BR'\n const text = TEXT[locale] ?? (TEXT['pt-BR'] as (typeof TEXT)[string])\n const keys = options.vehicles ?? DEFAULT_TEST_VEHICLES\n const wrecks = options.wrecks ?? DEFAULT_TEST_WRECKS\n const entries: Entry[] = [...keys.map((key): Entry => ({ key, id: itemId(key) })), ...wrecks.map((w): Entry => ({ key: w.vehicle, id: w.key, scenario: w.scenario }))]\n const effectIds = { ...defaultEffectIds, ...options.effects }\n const soundIds = { ...defaultSoundIds, ...options.sounds }\n const settings = { quality: 'high', paint: false, seed: 1, palette: 'auto', driving: 'arcade', surface: 'dry_asphalt', damage: 'none' as LaneDamage }\n const kits = new WeakMap<object, VehicleKit>()\n const placed = new Map<string, Placed>()\n // the cabins hold the room's smoke out: through a shut car it does not pass, it gets in only by an open door, a broken window or a bullet hole\n const cabins = createCabinSmoke()\n // and the rain keeps off what the cabins roof over: a broken roof or windshield lets it in\n const rainCovers = createVehicleRainCovers()\n let host: ModuleHost | null = null\n const physicalCars = new Set<PhysicalCar>()\n let runOverLink: RunOverLink | undefined\n const planCache = createHullPlanCache()\n let three: Three | null = null\n let counter = 0\n let helpersShown = ''\n let axes: THREE_NS.Object3D[] = []\n let lane: Lane | null = null\n\n type Lane = { car: ReturnType<ReturnType<typeof createVehiclesThree>['build']>; group: THREE_NS.Object3D; wall: THREE_NS.Object3D | null; mode: 'arcade' | 'semi'; step(dt: number): void; speed(): number; distance(): number; done: boolean; stopped: number }\n\n const effects = (): EffectsLike | undefined => host?.effects\n // the sounds are asked of the host's shared engine by id (the sink may be absent, and then the module is silent)\n const audio = () => host?.audio\n // the lane car's engine, tyres and crashes (the vehicle bank of this package)\n let carSound: VehicleSound | undefined\n const stopEngine = (): void => {\n carSound?.dispose()\n carSound = undefined\n }\n\n /** The puffs' materials come from the host's pool when it lends one (read at each puff: the host attaches after the first build). */\n const particleMaterials: ParticleMaterials = {\n own: <TMaterial>(build: () => TMaterial): TMaterial => (isRenderPools(host?.pools) ? (host.pools.materials.own(build as never) as unknown as TMaterial) : build()),\n release: (material) => (isRenderPools(host?.pools) ? host.pools.materials.release(material as never) : (material as { dispose?(): void }).dispose?.()),\n }\n\n const kitFor = (THREE: Three): VehicleKit => {\n three = THREE\n let kit = kits.get(THREE)\n if (!kit) {\n if (options.createKit) kit = options.createKit(THREE)\n else {\n kit = createVehicleKit({ THREE, locale, particleMaterials, effects: () => host?.effects, ...(options.document ? { document: options.document as never } : {}) })\n fleet.installFleet(kit)\n }\n kits.set(THREE, kit)\n }\n return kit\n }\n\n const paletteFor = (key: string) => (settings.palette === 'civil' ? fleet.paintPalettes.civil : settings.palette === 'military' ? fleet.paintPalettes.military : fleet.paletteOf(key))\n const paintOf = (entry: Placed): void => {\n if (!settings.paint) return\n entry.lod?.dispose()\n delete entry.lod\n const color = fleet.colorFromSeed(settings.seed + entry.index, paletteFor(entry.key))\n if (!entry.paint) {\n const vehicle = entry.item.vehicle as unknown as { vehicle: THREE_NS.Object3D }\n const primary = primaryPaint(entry.item.vehicle)\n if (!primary) return\n entry.paint = primary.clone()\n vehicle.vehicle.traverse((obj) => {\n const mesh = obj as THREE_NS.Mesh\n if (!mesh.isMesh) return\n if (Array.isArray(mesh.material)) mesh.material = mesh.material.map((m) => (m === primary ? entry.paint! : m))\n else if (mesh.material === primary) mesh.material = entry.paint!\n })\n }\n entry.paint.color.set(color)\n }\n\n const item = ({ key, id: itemKey, scenario }: Entry): TestableItem => ({\n id: itemKey,\n name: text.items[itemKey] ?? key,\n movable: false,\n // the first build of a vehicle takes most of a second\n slow: true,\n build: (THREE: unknown) => {\n const kit = kitFor(THREE as Three)\n const built = buildVehicleItem(kit, key, { lod: settings.quality === 'lite', ...(scenario ? { scenario } : {}) })\n built.root.userData.kit = kit\n const entry: Placed = { root: built.root, key, ...(scenario ? { scenario } : {}), item: built, index: counter++, helpers: [] }\n placed.set(built.root.uuid, entry)\n // measured now, before the destructible adds its own plates and mirrors: this is the size the fleet records\n measure(entry)\n paintOf(entry)\n return built.root\n },\n impl: (root: unknown, id: string) => {\n const r = root as { userData: Record<string, unknown> }\n const kit = r.userData.kit as VehicleKit\n // the host's fluid world lays what leaks, as much as came out: the car draws no puddle of its own\n const d = createVehicleDestructible(kit, r.userData.vehicle as VehicleContext, { id, frame: root, name: text.items[itemKey] ?? key, creaseQueue, puddles: false })\n tapEffects(d)\n // an engine collides with what the vehicle draws, piece by piece, not with its damage-zone boxes\n // (a vehicle that just spawned fills in over several updates)\n const services = physicsServicesOf(host)\n if (services) {\n // on the engine's loop the car is a body of its own (hulls, parts that come off): the fixed world keeps no copy of the drawing\n const colliders = physicalCarColliders(kit.THREE as Three, d, root as THREE_NS.Object3D, { budget: COLLIDER_BUDGET, fleetKey: key, hullCeilingOf: fleet.hullCeilingOf, planCache, workers: host?.workers })\n const car = createPhysicalCar({ THREE: kit.THREE as Three, services, vehicle: d, root: root as THREE_NS.Object3D, colliders, runOver: (runOverLink ??= createRunOverLink(services)) })\n const disposeVehicle = d.dispose?.bind(d)\n d.dispose = () => {\n physicalCars.delete(car)\n car.dispose()\n disposeVehicle?.()\n }\n physicalCars.add(car)\n r.userData.physicalCar = car\n d.colliders = car.colliders\n d.collidersPending = () => false\n } else {\n const colliders = createVehicleColliders(kit.THREE as Three, d, root as THREE_NS.Object3D, { budget: COLLIDER_BUDGET })\n d.colliders = colliders.pieces\n d.collidersPending = colliders.isPending\n }\n // a leaf the room swings (door, hood, lid) is posed through here: away from its rest the vehicle draws in full, or the fused one shows it shut\n const setPartPose = d.setPartPose?.bind(d)\n {\n const rests = new Map((d.describe().parts as Array<{ id: string; rotation?: Vec3 }>).map((part) => [part.id, part.rotation ?? [0, 0, 0]]))\n d.setPartPose = (partId: string, position: Vec3, rotation?: Vec3) => {\n const entry = [...placed.values()].find((candidate) => candidate.root === root)\n const rest = rests.get(partId) ?? [0, 0, 0]\n const isOpen = (rotation ?? [0, 0, 0]).some((angle, axis) => Math.abs(angle - (rest[axis] ?? 0)) > LEAF_REST_RADIANS)\n if (entry) {\n entry.posedParts ??= new Set()\n if (isOpen) entry.posedParts.add(partId)\n else entry.posedParts.delete(partId)\n }\n return setPartPose?.(partId, position, rotation)\n }\n }\n const hitBody = d.hit.bind(d)\n d.hit = (h: never) => {\n const entry = [...placed.values()].find((candidate) => candidate.root === root)\n if (entry) entry.touched = true\n return hitBody(h)\n }\n cabins.track(id, d, root as { parent: unknown | null })\n rainCovers.track(id, d, root as { parent: unknown | null })\n r.userData.destructible = d\n return d\n },\n ...(clipsOf(key) ? { animations: clipsOf(key) as AnimationClipSpec[] } : {}),\n })\n\n // the clips are numbers (rotations of the door, hood and lid parts), so any three.js namespace computes them: the one in the options, else the global one\n const clipCache = new Map<string, AnimationClipSpec[]>()\n const clipsOf = (key: string): AnimationClipSpec[] | undefined => {\n const THREE = options.three ?? (globalThis as { THREE?: unknown }).THREE\n if (!THREE) return undefined\n if (!clipCache.has(key)) {\n const kit = kitFor(THREE as Three)\n const built = buildVehicleItem(kit, key)\n const d = createVehicleDestructible(kit, built.vehicle, { id: `${itemId(key)}_clips`, frame: built.root, headless: true })\n clipCache.set(key, d.animations())\n kit.dispose(built.vehicle)\n }\n return clipCache.get(key)\n }\n\n // events of the vehicle become effect requests: the module owns no particle code\n const tapEffects = (d: { hit(h: never): unknown[]; update?(dt: number): unknown[] }): void => {\n const request = (events: unknown[]): void => {\n const fx = effects()\n if (!fx) return\n for (const e of events as { type: string; part?: string; point?: Vec3; worldPoint?: Vec3 }[]) {\n const position = e.point ?? e.worldPoint\n if (!position) continue\n // a pierced tank only leaks; when the leak catches fire the whole sequence plays (the fire runs to the tank, then the blast)\n if (e.type === 'ignite') fx.play({ effect: /fuel_tank|tank/.test(e.part ?? '') ? effectIds.leakIgnited : effectIds.ignite, point: position })\n else if (e.type === 'explode') fx.play({ effect: effectIds.explode, point: position })\n else if (e.type === 'leak') fx.play({ effect: effectIds.leak, point: position })\n else if (e.type === 'fracture' && /glass|window|windshield/.test(e.part ?? '')) fx.play({ effect: effectIds.glass, point: position })\n else if (e.type === 'hole') fx.play({ effect: /glass|window|windshield/.test(e.part ?? '') ? effectIds.glass : effectIds.sparks, point: position })\n }\n }\n const hit = d.hit.bind(d)\n d.hit = (h) => {\n const events = hit(h)\n request(events)\n return events\n }\n if (d.update) {\n const update = d.update.bind(d)\n d.update = (dt) => {\n const events = update(dt)\n request(events)\n return events\n }\n }\n }\n\n // ---- measuring and the layers ----------------------------------------------------------------------------------------------------------\n const rootMatrix = (entry: Placed): THREE_NS.Matrix4 => {\n const m = new three!.Matrix4().copy(entry.root.matrixWorld).invert()\n return m.multiply((entry.item.vehicle as unknown as { vehicle: THREE_NS.Object3D }).vehicle.matrixWorld)\n }\n const measure = (entry: Placed): { length: number; width: number; height: number } => {\n if (entry.size) return entry.size\n entry.root.updateMatrixWorld(true)\n const inverse = new three!.Matrix4().copy(entry.root.matrixWorld).invert()\n const bounds = new three!.Box3()\n const low = new three!.Box3()\n const piece = new three!.Box3()\n const matrix = new three!.Matrix4()\n entry.root.traverse((obj) => {\n const mesh = obj as THREE_NS.Mesh\n if (!mesh.isMesh || !mesh.geometry || mesh.userData.ghost) return\n for (let p: THREE_NS.Object3D | null = mesh; p; p = p.parent) if (p.visible === false) return\n if (mesh.userData.helper) return\n mesh.geometry.computeBoundingBox()\n piece.copy(mesh.geometry.boundingBox!).applyMatrix4(matrix.multiplyMatrices(inverse, mesh.matrixWorld))\n bounds.union(piece)\n if (piece.min.y < BODY_HEIGHT) low.union(piece)\n })\n const size = bounds.getSize(new three!.Vector3())\n entry.size = { length: size.z, width: size.x, height: size.y }\n if (!low.isEmpty()) entry.footprint = { minX: low.min.x, maxX: low.max.x, minZ: low.min.z, maxZ: low.max.z }\n return entry.size\n }\n const clearHelpers = (): void => {\n for (const entry of placed.values()) {\n discardObject3D(entry.helpers)\n entry.helpers = []\n }\n discardObject3D(axes)\n axes = []\n helpersShown = ''\n }\n const boxKey = (): string => `${host?.bench?.layer('damageables')}|${host?.bench?.layer('zones')}|${host?.bench?.layer('axes')}|${placed.size}`\n const refreshLayers = (): void => {\n if (!host?.bench || !three) return\n clearHelpers()\n const kit = [...placed.values()][0] && ((([...placed.values()][0] as Placed).root.userData.kit as VehicleKit | undefined) ?? undefined)\n const mark = (entry: Placed, box: THREE_NS.Box3, color: number): void => {\n const helper = new three!.Box3Helper(box, color)\n helper.userData.helper = true\n entry.root.add(helper)\n entry.helpers.push(helper)\n }\n if (kit) {\n for (const entry of placed.values()) {\n if (!entry.root.parent) continue\n entry.root.updateMatrixWorld(true)\n const matrix = rootMatrix(entry)\n if (host.bench.layer('damageables')) for (const d of kit.damageables(entry.item.vehicle, matrix) as { material: string; box: THREE_NS.Box3 }[]) mark(entry, d.box, MATERIAL_COLOURS[d.material] ?? 0xffffff)\n if (host.bench.layer('zones')) {\n for (const zone of (entry.item.vehicle as unknown as { zones: { type: string; box?: { x0: number; y0: number; z0: number; x1: number; y1: number; z1: number } }[] }).zones ?? []) {\n if (!zone.box || zone.type === 'internal') continue\n const box = new three.Box3(new three.Vector3(zone.box.x0, zone.box.y0, zone.box.z0), new three.Vector3(zone.box.x1, zone.box.y1, zone.box.z1)).applyMatrix4(matrix)\n mark(entry, box, ZONE_COLOURS[zone.type] ?? 0xffffff)\n }\n }\n }\n }\n if (host.bench.layer('axes')) {\n const front = new three.ArrowHelper(new three.Vector3(0, 0, 1), new three.Vector3(0, 0.05, 0), 3, 0x3366ff)\n const right = new three.ArrowHelper(new three.Vector3(-1, 0, 0), new three.Vector3(0, 0.05, 0), 3, 0xff3333)\n const up = new three.ArrowHelper(new three.Vector3(0, 1, 0), new three.Vector3(0, 0.05, 0), 3, 0x33cc33)\n for (const arrow of [front, right, up]) {\n ;(host.scene as THREE_NS.Object3D).add(arrow)\n axes.push(arrow)\n }\n }\n helpersShown = boxKey()\n }\n\n // ---- the walking player ------------------------------------------------------------------------------------------------------------------\n // every vehicle on the floor (and the car on the lane) is solid: the point is taken into the vehicle's own space, so a turned vehicle blocks by its turned footprint\n const laneBlocked = footprintBlocker(\n () => lane?.group,\n () => (lane ? { minX: -lane.car.width / 2, maxX: lane.car.width / 2, minZ: -lane.car.length / 2, maxZ: lane.car.length / 2 } : null),\n )\n const blocked = (x: number, z: number, radius: number): boolean => {\n for (const entry of placed.values()) if (entry.footprint && footprintBlocker(entry.root, entry.footprint)(x, z, radius)) return true\n return laneBlocked(x, z, radius)\n }\n\n // ---- the lane ---------------------------------------------------------------------------------------------------------------------------\n const clearLane = (): void => {\n stopEngine()\n if (!lane) return\n lane.group.parent?.remove(lane.group)\n if (lane.wall) {\n lane.wall.parent?.remove(lane.wall)\n discardObject3D(lane.wall)\n }\n lane = null\n }\n const startLane = (): void => {\n if (!host || !three) return\n clearLane()\n const kit = kitFor(three)\n const vehicles = createVehiclesThree(three, { kit, fleet })\n // damage needs the parts drawn: the car is built in full only then\n const built = vehicles.build('compact_hatch', { quality: settings.damage === 'none' ? 'lite' : 'high', seed: settings.seed })\n const wall = options.wall ? (options.wall(three, CRASH_WALL) as THREE_NS.Object3D) : null\n const scene = host.scene as THREE_NS.Object3D\n scene.add(built.group)\n if (wall) {\n wall.rotation.y = Math.PI / 2\n wall.position.set(LANE.wall + CRASH_WALL.thickness / 2, 0, LANE.z)\n scene.add(wall)\n }\n // damage acts through the semi driver's condition\n const mode = settings.driving === 'semi' || settings.damage !== 'none' ? 'semi' : 'arcade'\n const damage = settings.damage === 'none' || !built.context ? null : createLaneDamage({ kit, context: built.context as VehicleContext, frame: built.group, damage: settings.damage })\n const surfaces = createSurfaces()\n const idle = { throttle: 0, brake: 0, steer: 0, handbrake: false }\n const state = { time: 0, exhaust: 0, sparks: 0, ended: false, wasBlocked: false }\n const arcade = createArcadeDriver({ length: built.length, width: built.width })\n const semi = createSemiSimDriver({}, { surfaces })\n const driver = mode === 'semi' ? semi : arcade\n driver.place(LANE.from, LANE.z, 0)\n const gap = (): number => LANE.wall - (driver.state.x + built.length / 2)\n // brakes when the stopping distance (at the rule's deceleration, the surface's grip in the semi mode) plus a margin reaches the wall\n const decel = (): number => (mode === 'semi' ? 9 * surfaces.get(settings.surface).grip : arcade.spec.brakeAgainstMotion)\n const brakeAt = (): number => (lane ? (lane.speed() * lane.speed()) / (2 * decel()) + 3 : 3)\n const pose = (): void => {\n built.group.position.set(driver.state.x, 0, driver.state.z)\n built.group.rotation.y = driver.state.yaw + Math.PI / 2\n }\n pose()\n carSound = createVehicleSound(audio(), { sounds: soundIds })\n // the key is turned before the car moves: the starter, then the engine catches\n carSound.start([driver.state.x, 0.5, driver.state.z])\n const log = (key: 'crash' | 'end', value: number): void => host?.log(fill(text, locale, text.lane[key], value.toFixed(1)))\n lane = {\n car: built,\n group: built.group,\n wall,\n mode,\n done: false,\n stopped: 0,\n speed: () => ('u' in driver.state ? (driver.state as { u: number }).u : (driver.state as { v: number }).v),\n distance: () => driver.state.x - LANE.from,\n step(dt) {\n // the run is over, the damage is not: torn panels, crumples and leaks finish over the next frames\n if (state.ended) {\n damage?.settle(dt)\n // stopped at the wall or against it: ignition off, the loops run down to silence\n const at: Vec3 = [driver.state.x, 0.5, driver.state.z]\n if (carSound?.reading.running) carSound.stop(at)\n carSound?.update({ dt, position: at, speed: 0, throttle: 0 })\n return\n }\n state.time += dt\n // the crash run does not brake: it shows what the wall does to the car\n const braking = settings.damage !== 'into_wall' && gap() < brakeAt() && state.time > 0.5\n const moving = state.time > LANE_START_S\n // a run on a damaged tyre holds the wheel straight: the pull to the side of the tyre is the car's, not the driver's weave\n const straight = settings.damage === 'into_wall' || TYRE_DAMAGE.has(settings.damage) || !moving\n const input = { ...idle, throttle: braking || !moving ? 0 : 1, brake: braking ? 1 : 0, steer: straight ? 0 : Math.sin(state.time * 1.4) * 0.15 }\n if (mode === 'arcade') {\n const { events } = arcade.step(input, dt, { blocked: (x, z, yaw) => vehicleCorners(arcade.spec, x, z, yaw).some(([px]) => px >= LANE.wall) })\n for (const e of events) {\n if (e.type !== 'crash') continue\n log('crash', e.speed)\n carSound?.crash(e.speed, [driver.state.x + built.length / 2, 0.5, driver.state.z])\n }\n } else {\n semi.step(input, dt, { ground: () => ({ surface: settings.surface }) })\n const grinding = damage?.step({ dt, speed: Math.abs(lane?.speed() ?? 0), throttle: input.throttle, driver: semi }) ?? []\n state.sparks -= dt\n const fx = effects()\n if (fx && state.sparks <= 0 && Math.abs(lane?.speed() ?? 0) > 0.5) {\n state.sparks = grinding.length ? SPARK_EVERY_S : 0\n for (const point of grinding) fx.play({ effect: effectIds.sparks, point })\n }\n if (gap() <= 0) {\n state.ended = true\n const crashed = damage?.crash({ speed: Math.abs((semi.state as { u: number }).u), direction: [Math.cos(driver.state.yaw), 0, -Math.sin(driver.state.yaw)] })\n if (crashed) {\n const parts = (type: string): string => [...new Set(crashed.flatMap((e) => (e.type === type && 'part' in e ? [e.part] : [])))].join(', ') || '-'\n host?.log(fill(text, locale, text.lane.damage, parts('dent'), parts('fracture')))\n }\n log('crash', Math.abs((semi.state as { u: number }).u))\n carSound?.crash((semi.state as { u: number }).u, [driver.state.x + built.length / 2, 0.5, driver.state.z])\n }\n }\n pose()\n {\n const speed = Math.abs(lane?.speed() ?? 0)\n // the engine by RPM and load (the semi driver has its own RPM; the arcade one is guessed from the speed), the tyres by slip and speed\n const semiState = mode === 'semi' ? (semi.state as { rpm: number; slip: number[] }) : null\n carSound?.update({\n dt,\n position: [driver.state.x, 0.5, driver.state.z],\n speed,\n throttle: input.throttle,\n ...(semiState ? { rpm: semiState.rpm, slip: Math.max(0, ...semiState.slip.map(slideOfGrip)) } : { slip: braking && speed > 3 ? 0.6 : 0 }),\n surface: /dirt|gravel|sand|grass|mud/.test(settings.surface) ? 'dirt' : 'asphalt',\n brake: input.brake,\n })\n }\n state.exhaust -= dt\n const fx = effects()\n if (fx && state.exhaust <= 0 && Math.abs(lane?.speed() ?? 0) > 0.5) {\n state.exhaust = 0.4\n fx.play({ effect: effectIds.exhaust, point: [driver.state.x - Math.cos(driver.state.yaw) * (built.length / 2), 0.3, driver.state.z + Math.sin(driver.state.yaw) * (built.length / 2)], scale: Math.min(1, Math.abs(lane?.speed() ?? 0) / 17) })\n }\n if (!state.ended && state.time > LANE_START_S + 1 && Math.abs(lane?.speed() ?? 0) < 0.05) {\n state.ended = true\n log('end', Math.max(0, gap()))\n }\n },\n }\n }\n\n // ---- the bench ----------------------------------------------------------------------------------------------------------------------------\n const onChange = (change: BenchChange): void => {\n if (change.kind === 'layer') return refreshLayers()\n if (change.kind === 'action') {\n if (change.id === 'repaint') for (const entry of placed.values()) paintOf(entry)\n else if (change.id === 'drive_lane') startLane()\n else if (change.id === 'clear_lane') clearLane()\n else if (change.id === 'honk') audio()?.play({ sound: soundIds.horn, position: lane ? [lane.group.position.x, 1, lane.group.position.z] : undefined })\n return\n }\n switch (change.id) {\n case 'quality': settings.quality = String(change.value); break\n case 'paint_by_seed': settings.paint = Boolean(change.value); for (const entry of placed.values()) paintOf(entry); break\n case 'color_seed': settings.seed = Number(change.value); for (const entry of placed.values()) paintOf(entry); break\n case 'palette': settings.palette = String(change.value); for (const entry of placed.values()) paintOf(entry); break\n case 'driving': settings.driving = String(change.value); break\n case 'surface': settings.surface = String(change.value); break\n case 'lane_damage': settings.damage = String(change.value) as LaneDamage; break\n default: break\n }\n }\n\n // one crease queue for every vehicle of the area; a host with a frame budget runs it, any other leaves each vehicle smoothing in its own update\n const creaseQueue = createCreaseQueue()\n // and one for the batches of their level of detail\n const lodQueue = createVehicleLodQueue()\n\n const updateLod = (entry: Placed): void => {\n if (!host || settings.quality === 'lite') return\n entry.lod ??= createVehicleLod(entry.root.userData.kit, entry.item.vehicle, entry.root, entry.root.children[0], { queue: lodQueue })\n const at = host.player().position\n const distance = Math.hypot(at[0] - entry.root.position.x, at[2] - entry.root.position.z)\n // rolling over and blowing up move the body without a part pose: the fused copy would stay upright where the car was\n const c = entry.item.vehicle as { rollState?: unknown; flipped?: boolean; blast?: unknown; exploded?: boolean } | undefined\n if (c && (c.rollState || c.flipped || c.blast || c.exploded)) entry.touched = true\n // a wreck is built damaged: it never draws fused, only in batches (as a posed one)\n entry.lod.update(distance, entry.touched === true, entry.scenario !== undefined || (entry.posedParts?.size ?? 0) > 0)\n }\n\n const frame = (dt: number): void => {\n for (const [id, entry] of placed) {\n if (!entry.root.parent) {\n // its batches sit in the area's one LOD queue: left there, the queue would keep the whole vehicle after it left the scene\n entry.lod?.dispose()\n placed.delete(id)\n continue\n }\n measure(entry)\n updateLod(entry)\n }\n if (host?.bench && boxKey() !== helpersShown && (host.bench.layer('damageables') || host.bench.layer('zones') || helpersShown !== '')) refreshLayers()\n lane?.step(dt)\n cabins.sync(effects())\n rainCovers.sync(host?.rainCover, dt)\n }\n\n const count = (): { drawCalls: number; triangles: number } => {\n let drawCalls = 0\n let triangles = 0\n for (const entry of placed.values()) {\n entry.root.traverse((obj) => {\n const mesh = obj as THREE_NS.Mesh\n if (!mesh.isMesh || mesh.userData.helper) return\n for (let p: THREE_NS.Object3D | null = mesh; p; p = p.parent) if (p.visible === false) return\n drawCalls += 1\n const g = mesh.geometry\n triangles += (g.index ? g.index.count : g.attributes.position.count) / 3\n })\n }\n return { drawCalls, triangles: Math.round(triangles) }\n }\n const boxesOf = (material: string): number => {\n let total = 0\n for (const entry of placed.values()) {\n const kit = entry.root.userData.kit as VehicleKit | undefined\n if (kit) total += (kit.damageables(entry.item.vehicle) as { material: string }[]).filter((d) => d.material === material).length\n }\n return total\n }\n const sizeError = (): number => {\n let worst = 0\n for (const entry of placed.values()) {\n const want = fleet.fleetDims(entry.key)\n const got = entry.size\n if (!want || !got || entry.scenario) continue\n worst = Math.max(worst, Math.abs(got.length - want.length), Math.abs(got.width - want.width), Math.abs(got.height - want.height))\n }\n return Math.round(worst * 1000)\n }\n\n return {\n id: VEHICLES_AREA_ID,\n name: text.name,\n ground: { surface: 'road' },\n group: text.group,\n get placed() {\n return placed\n },\n items: () => entries.map(item),\n area: (): ModuleArea => {\n // the front row, each vehicle given room by its width, the front to +z; what is wider than a street (a helicopter with its rotor) stands alone in a row behind\n const gap = 1.6\n const WIDE = 6\n const rowOf = (list: readonly Entry[], z: number) => {\n let cursor = 0\n const spots = list.map((entry) => {\n const width = fleet.fleetDims(entry.key)?.width ?? 2\n const x = cursor + width / 2\n cursor += width + gap\n return { id: entry.id, x }\n })\n return { spots, z, width: Math.max(0, cursor - gap) }\n }\n const front = rowOf(entries.filter((e) => (fleet.fleetDims(e.key)?.width ?? 2) <= WIDE), 0)\n const back = rowOf(entries.filter((e) => (fleet.fleetDims(e.key)?.width ?? 2) > WIDE), -16)\n const placements = [front, back].flatMap((row) => row.spots.map(({ id, x }) => ({ item: id, position: [x - row.width / 2, 0, row.z] as Vec3, rotationY: 0 })))\n return { placements, view: { eye: [0, 5, Math.max(14, front.width * 0.6)], target: [0, 1, -2] } }\n },\n controls: (): ModuleControl[] => {\n const surfaceIds = createSurfaces().surfaces.map((s) => s.id)\n return [\n { kind: 'choice', id: 'quality', name: text.controls.quality, hint: text.hints.quality, options: (['high', 'lite'] as const).map((id) => ({ id, name: text.options.quality[id] as string })), default: 'high' },\n { kind: 'boolean', id: 'paint_by_seed', name: text.controls.paint_by_seed, hint: text.hints.paint_by_seed, default: false },\n { kind: 'number', id: 'color_seed', name: text.controls.color_seed, min: 0, max: 999, step: 1, default: 1 },\n { kind: 'choice', id: 'palette', name: text.controls.palette, hint: text.hints.palette, options: (['auto', 'civil', 'military'] as const).map((id) => ({ id, name: text.options.palette[id] as string })), default: 'auto' },\n { kind: 'choice', id: 'driving', name: text.controls.driving, hint: text.hints.driving, options: (['arcade', 'semi'] as const).map((id) => ({ id, name: text.options.driving[id] as string })), default: 'arcade' },\n { kind: 'choice', id: 'surface', name: text.controls.surface, hint: text.hints.surface, options: surfaceIds.map((id) => ({ id, name: text.options.surface[id] ?? id })), default: 'dry_asphalt' },\n { kind: 'choice', id: 'lane_damage', name: text.controls.lane_damage, hint: text.hints.lane_damage, options: LANE_DAMAGE.map((id) => ({ id, name: text.options.lane_damage[id] ?? id })), default: 'none' },\n { kind: 'action', id: 'repaint', name: text.actions.repaint },\n { kind: 'action', id: 'drive_lane', name: text.actions.drive_lane },\n { kind: 'action', id: 'clear_lane', name: text.actions.clear_lane },\n { kind: 'action', id: 'honk', name: text.actions.honk },\n ]\n },\n layers: (): ModuleLayer[] => (['damageables', 'zones', 'axes'] as const).map((id) => ({ id, name: text.layers[id], default: false })),\n metrics: (): ModuleMetric[] => [\n { id: 'vehicles', name: text.metrics.vehicles, read: () => placed.size },\n { id: 'triangles', name: text.metrics.triangles, read: () => count().triangles },\n { id: 'draw_calls', name: text.metrics.draw_calls, read: () => count().drawCalls },\n { id: 'size_error_mm', name: text.metrics.size_error_mm, unit: 'mm', read: sizeError },\n { id: 'metal', name: text.metrics.metal, read: () => boxesOf('metal') },\n { id: 'glass', name: text.metrics.glass, read: () => boxesOf('glass') },\n { id: 'rubber', name: text.metrics.rubber, read: () => boxesOf('rubber') },\n { id: 'fuel', name: text.metrics.fuel, read: () => boxesOf('fuel') },\n { id: 'speed', name: text.metrics.speed, unit: 'km/h', digits: 0, read: () => Math.round(Math.abs(lane?.speed() ?? 0) * 3.6) },\n { id: 'lane', name: text.metrics.lane, unit: 'm', digits: 1, read: () => lane?.distance() ?? 0 },\n ],\n scenarios: (): ModuleScenario<VehiclesContext>[] => createScenarios({ text, locale }),\n attach(lent) {\n host = lent\n three = lent.THREE as Three\n const stopChange = lent.bench?.onChange(onChange)\n const stopFrame = lent.onFrame(frame)\n const stopBlocker = lent.addBlocker?.(blocked)\n const stopCrease = lent.defer?.(creaseQueue.deferredQueue(), DEFERRED_PRIORITY[DEFERRED_QUEUE_ID.VEHICLE_CREASE])\n const stopLodBatch = lent.defer?.(lodQueue.deferredQueue(), DEFERRED_PRIORITY[DEFERRED_QUEUE_ID.VEHICLE_LOD_BATCH])\n if (isRenderPools(lent.pools)) lent.pools.materials.register('vehicles.cracked-glass', () => crackedGlassMaterial(three!, new three!.DataTexture(new Uint8Array(4), 1, 1)))\n // the engine loop and the horn live in the library bank of game-audio, which the room's engine does not carry on its own\n lent.audio?.register?.(LIBRARY_BANK)\n lent.audio?.register?.(VEHICLE_SOUND_BANK)\n // the recordings of the car (when the game has them) decode now, so the first door opened or engine started is already the file\n lent.audio?.preload?.(VEHICLE_PRELOAD_SOUNDS)\n return () => {\n stopChange?.()\n stopFrame()\n stopBlocker?.()\n stopCrease?.()\n stopLodBatch?.()\n for (const car of physicalCars) car.dispose()\n physicalCars.clear()\n runOverLink?.dispose()\n runOverLink = undefined\n cabins.clear(effects())\n rainCovers.clear()\n clearHelpers()\n clearLane()\n host = null\n }\n },\n }\n}\n\n/** What `loadVehiclesTestModule` needs of a room: `TestRoom.loadModule` has it. */\nexport type ModuleRoomLike = { loadModule(module: never): unknown }\n\n/**\n * Loads the vehicles module into a room. The door, hood and trunk clips of the items are computed when the room reads the items, before the module is lent the room's three.js\n * (`attach`), so this first lends an empty module to learn the namespace and then loads the real one with it. Pass `three` to skip that.\n */\nexport function loadVehiclesTestModule<Room extends ModuleRoomLike>(room: Room, options: VehiclesTestOptions = {}): ReturnType<Room['loadModule']> {\n return room.loadModule(createVehiclesTestModule({ ...options, three: learnThree(room, options) }) as never) as ReturnType<Room['loadModule']>\n}\n\n/** The three.js namespace the items are built with: the one given, or the room's, learned by lending it an empty module. */\nfunction learnThree(room: ModuleRoomLike, options: VehiclesTestOptions): unknown {\n let three = options.three\n if (!three) {\n room.loadModule({ id: 'vehicles_probe', name: 'Vehicles probe', group: 'Vehicles', items: () => [], attach: (lent: ModuleHost) => { three = lent.THREE; return () => undefined } } as never)\n }\n return three\n}\n\n/** What `loadVehiclesTestModuleAsync` needs of a room: `TestRoom.loadModuleAsync` has it. */\nexport type AsyncModuleRoomLike<TReport> = ModuleRoomLike & { loadModuleAsync(module: never, between: (itemId: string) => Promise<void>): Promise<TReport> }\n\n/**\n * `loadVehiclesTestModule` a vehicle at a time: building and checking a vehicle takes a while (the fleet's eight and two wrecks, seconds in all), so `between(itemId)` is\n * awaited before each one and the page paints and moves its bar instead of freezing.\n */\nexport function loadVehiclesTestModuleAsync<TReport>(room: AsyncModuleRoomLike<TReport>, between: (itemId: string) => Promise<void>, options: VehiclesTestOptions = {}): Promise<TReport> {\n return room.loadModuleAsync(createVehiclesTestModule({ ...options, three: learnThree(room, options) }) as never, between)\n}\n","import { markKitOrigin } from '@adatechnology/game-contracts'\nimport type { Damageable, VehicleContext, VehicleKit } from '@adatechnology/game-vehicles'\nimport type * as THREE_NS from 'three'\nimport type { Group, Material, Mesh, MeshStandardMaterial, Object3D } from 'three'\n\nimport { colorFromSeed as defaultColorFromSeed, fleetDims as defaultFleetDims, paintPalettes as defaultPaintPalettes, paletteOf as defaultPaletteOf } from '@adatechnology/game-vehicles-fleet'\n\nimport { fuse, liteMaterials, liteMeshes } from './lite'\n\nexport type VehicleQuality = 'high' | 'lite'\n\n/** The measured size of a fleet vehicle in metres (the shape of `FleetDims` of `game-vehicles-fleet`). */\nexport interface FleetDims {\n length: number\n width: number\n height: number\n}\n\n/**\n * The fleet content the builder reads: the paint palettes, the size the team measured and the colour a seed picks. It is the shape of what\n * `game-vehicles-fleet` exports (`defaultVehicleFleet()` of `game-kit-defaults` hands it over), so this adapter imports no content.\n */\nexport interface VehicleFleetContent {\n readonly paintPalettes: { readonly civil: unknown; readonly military: unknown }\n paletteOf(group: string): unknown\n colorFromSeed(seed: number | string, palette: unknown): string\n fleetDims(id: string): FleetDims | undefined\n /** The most hulls a vehicle may have on the engine, by its id; absent or undefined takes the largest ceiling. */\n hullCeilingOf?(id: string): number | undefined\n}\n\nexport interface BuildVehicleOptions {\n /** `high`: the kit's vehicle at full detail. `lite`: fused into six meshes. Default `high`. */\n quality?: VehicleQuality\n /** Body colour as a CSS colour. Wins over `seed`. */\n color?: string\n /** Picks the body colour from the palette of the vehicle's group. */\n seed?: number | string\n /** State of the vehicle. Default `intact`. */\n state?: 'intact' | 'damaged' | 'modified'\n}\n\nexport interface BuiltVehicle {\n key: string\n quality: VehicleQuality\n /** The colour the body ended up with, or null when the vehicle keeps its own paint. */\n color: string | null\n seed: number | string | null\n /** Group in the game frame: front on +z, right on -x, centred on x and z, wheels on y = 0. */\n group: Group\n /** Damageable boxes in the game frame. */\n damageables: Damageable[]\n triangles: number\n drawCalls: number\n /** Measured size of the group in metres: length along z, width along x, height along y. */\n length: number\n width: number\n height: number\n /** Pieces dropped for being smaller than 3 cm (lite only). */\n pruned: number\n /** The measured size the team recorded for this vehicle, when the fleet knows it. */\n expected: FleetDims | undefined\n /** The kit's context, for damage and animation (full detail only). */\n context: VehicleContext | null\n /**\n * The driver's eyes in the group frame: over the front seat on the driver's side (+x, left-hand drive), a seated person's eye height above the cushion.\n * Null when the vehicle has no seats drawn (lite detail, a boat deck).\n */\n driverEye: [number, number, number] | null\n dispose(): void\n}\n\nexport interface VehiclesThree {\n readonly THREE: typeof THREE_NS\n readonly kit: VehicleKit\n build(key: string, options?: BuildVehicleOptions): BuiltVehicle\n}\n\nexport interface VehiclesThreeOptions {\n kit: VehicleKit\n /**\n * The fleet's palettes and measured sizes (`defaultVehicleFleet()` of `game-kit-defaults`, or the game's own). Default the ones of `game-vehicles-fleet`.\n * @deprecated pass `fleet`; the default is removed in the next major.\n */\n fleet?: VehicleFleetContent\n /** Vehicle id to the group id whose palette paints it. Defaults to the fleet group of the vehicle (`military` for the military ones). */\n groupOf?: (key: string) => string\n}\n\n/** Triangles and draw calls of the visible meshes of an object (a multi-material mesh costs one call per group). */\nfunction count(root: Object3D): { triangles: number; drawCalls: number } {\n let triangles = 0\n let drawCalls = 0\n root.traverse((node) => {\n const o = node as Mesh\n if (!o.isMesh || !o.geometry) return\n for (let p: Object3D | null = o; p; p = p.parent) if (p.visible === false) return\n const g = o.geometry\n const n = g.index ? g.index.count : g.attributes.position ? g.attributes.position.count : 0\n if (Array.isArray(o.material) && g.groups.length) drawCalls += g.groups.length\n else drawCalls++\n triangles += n / 3\n })\n return { triangles: Math.round(triangles), drawCalls }\n}\n\n/** The material most triangles are painted with: the body colour. */\nexport function primaryPaint(c: { vehicle: Object3D; paints: ReadonlySet<Material> }): MeshStandardMaterial | null {\n let best: MeshStandardMaterial | null = null\n let bestCount = -1\n const counts = new Map<Material, number>()\n c.vehicle.traverse((node) => {\n const o = node as Mesh\n if (!o.isMesh || !o.geometry) return\n const mats = Array.isArray(o.material) ? o.material : [o.material]\n const g = o.geometry\n const n = (g.index ? g.index.count : g.attributes.position.count) / 3\n for (const m of mats) if (c.paints.has(m)) counts.set(m, (counts.get(m) || 0) + n)\n })\n counts.forEach((n, m) => {\n if (n > bestCount) {\n bestCount = n\n best = m as MeshStandardMaterial\n }\n })\n return best\n}\n\n/**\n * Builds vehicles in a game frame. Port of `FrotaLeve.criar(...).construir` (frota-leve.js 14311-14442): the kit builds with +x to the front\n * and +z to the right; the game wants +z to the front and -x to the right, the vehicle centred on x and z and standing on y = 0.\n */\n/** Eyes of a seated driver over the top of the seat cushion and behind its centre, metres: the cushion gives under the body and the hips sit at its back. */\nconst SEATED_EYE = { up: 0.55, back: 0.28 }\n\n/** The driver's eyes in the group frame (the group sits at the origin while it is built): the frontmost seat, on the driver's side. */\ntype Point = { x: number; y: number; z: number }\nfunction eyeOf(THREE: { Vector3: new (x: number, y: number, z: number) => Point }, c: { seatTops?: Point[]; vehicle: { localToWorld(v: Point): Point } }): [number, number, number] | null {\n const tops = c.seatTops ?? []\n if (!tops.length) return null\n const points = tops.map((t) => c.vehicle.localToWorld(new THREE.Vector3(t.x, t.y, t.z)))\n const front = Math.max(...points.map((p) => p.z))\n const row = points.filter((p) => p.z > front - 0.25)\n const seat = row.reduce((a, b) => (b.x > a.x ? b : a))\n return [+seat.x.toFixed(3), +(seat.y + SEATED_EYE.up).toFixed(3), +(seat.z - SEATED_EYE.back).toFixed(3)]\n}\n\nexport function createVehiclesThree(THREE: typeof THREE_NS, options: VehiclesThreeOptions): VehiclesThree {\n const kit = options.kit\n const fleet: VehicleFleetContent = options.fleet ?? { colorFromSeed: defaultColorFromSeed, fleetDims: defaultFleetDims, paintPalettes: defaultPaintPalettes, paletteOf: defaultPaletteOf }\n const { colorFromSeed, fleetDims, paintPalettes, paletteOf } = fleet\n const groupOf = options.groupOf || ((key: string) => (kit.find(key)?.group === kit.config.defaultGroup ? 'cars' : String(kit.find(key)?.group)))\n const militaryKeys = new Set<string>()\n const isMilitary = (key: string): boolean => militaryKeys.has(key) || paletteOf(groupOf(key)) === paintPalettes.military\n\n const build = (key: string, o: BuildVehicleOptions = {}): BuiltVehicle => {\n const quality: VehicleQuality = o.quality === 'lite' ? 'lite' : 'high'\n const spec = kit.find(key)\n if (!spec) throw new Error(`createVehiclesThree: unknown vehicle \"${key}\"`)\n const seed = o.seed == null ? null : o.seed\n const color = o.color || (seed != null ? colorFromSeed(seed, isMilitary(key) ? paintPalettes.military : paintPalettes.civil) : null)\n const c = kit.build(key, o.state || 'intact', undefined, { lod: quality === 'lite' })\n c.root.updateMatrixWorld(true)\n const primary = primaryPaint(c)\n const rotation = new THREE.Matrix4().makeRotationY(-Math.PI / 2)\n const bounds = new THREE.Box3()\n const piece = new THREE.Box3()\n const turned = new THREE.Matrix4()\n c.vehicle.traverse((node: Object3D) => {\n const m = node as Mesh\n if (!m.isMesh || !m.geometry || m.userData.ghost) return\n for (let p: Object3D | null = m; p; p = p.parent) if (p.visible === false) return\n m.geometry.computeBoundingBox()\n piece.copy(m.geometry.boundingBox!).applyMatrix4(turned.multiplyMatrices(rotation, m.matrixWorld))\n bounds.union(piece)\n })\n const cx = (bounds.min.x + bounds.max.x) / 2\n const cz = (bounds.min.z + bounds.max.z) / 2\n const pivotMatrix = new THREE.Matrix4().makeTranslation(-cx, -bounds.min.y, -cz).multiply(rotation)\n const group = new THREE.Group()\n group.name = `vehicle:${key}`\n markKitOrigin(group, { owner: 'game-vehicles-three', kind: 'vehicle', id: key })\n const damageables = kit.damageables(c, pivotMatrix)\n let pruned = 0\n let driverEye: [number, number, number] | null = null\n if (quality === 'high') {\n const pivot = new THREE.Group()\n pivot.name = 'vehicle'\n pivot.matrixAutoUpdate = false\n pivot.matrix.copy(pivotMatrix)\n pivot.matrixWorldNeedsUpdate = true\n c.vehicle.matrixAutoUpdate = true\n pivot.add(c.vehicle)\n group.add(pivot)\n // the kit refreshes the matrices of what it deforms from c.root: it has to be the group that now carries the vehicle\n c.root = group\n if (color && primary) {\n const repainted = primary.clone()\n repainted.color.set(color)\n c.vehicle.traverse((node: Object3D) => {\n const m = node as Mesh\n if (!m.isMesh) return\n if (Array.isArray(m.material)) m.material = m.material.map((x) => (x === primary ? repainted : x))\n else if (m.material === primary) m.material = repainted\n })\n }\n markDamageables(c, damageables)\n group.updateMatrixWorld(true)\n driverEye = eyeOf(THREE, c)\n } else {\n const fusion = fuse(THREE, c, pivotMatrix, color ? new THREE.Color(color) : null, primary, kit.lodHiddenMaterials())\n for (const mesh of liteMeshes(THREE, fusion, liteMaterials(THREE, kit.studioEnvironment()))) group.add(mesh)\n pruned = fusion.pruned\n }\n const size = new THREE.Box3().setFromObject(group).getSize(new THREE.Vector3())\n const counted = count(group)\n group.userData.damageables = damageables\n group.userData.key = key\n group.userData.quality = quality\n return {\n key,\n quality,\n color,\n seed,\n group,\n damageables,\n triangles: counted.triangles,\n drawCalls: counted.drawCalls,\n length: +size.z.toFixed(3),\n width: +size.x.toFixed(3),\n height: +size.y.toFixed(3),\n pruned,\n expected: fleetDims(key),\n context: quality === 'high' ? c : null,\n driverEye,\n dispose() {\n group.traverse((node) => {\n const m = node as Mesh\n if (m.geometry) m.geometry.dispose()\n })\n },\n }\n }\n\n return { THREE, kit, build }\n}\n\n/** Tags the meshes of each damageable zone (and the tyres) so a hit test can tell what it hit. */\nfunction markDamageables(c: VehicleContext, damageables: Damageable[]): void {\n const byZone: Record<string, Damageable> = {}\n for (const d of damageables) byZone[d.zone] = d\n for (const z of c.zones || []) {\n const d = byZone[z.id]\n if (!d) continue\n for (const o of z.objs || z.meshes || []) if (o && o.userData) o.userData.damageable = { material: d.material, zone: d.zone }\n }\n for (const w of c.wheels || []) {\n const z = (c.zones || []).find((zz) => zz.type === 'wheel' && zz.objs && zz.objs.indexOf(w) >= 0)\n w.userData.damageable = { material: 'rubber', zone: z ? z.id : 'wheel' }\n }\n}\n","/**\n * The light mode of the team's Frota Leve (frota-leve.js 14202-14310): a built vehicle fused into six meshes, one per class of material,\n * with the meshes nobody sees from outside left out. A literal port: the classes, the thresholds (3 cm prune, 0.99 opacity, 0.5 metalness,\n * 0.25 and 0.45 emissive) and the colours are the team's.\n */\nimport type * as THREE_NS from 'three'\nimport type { BufferGeometry, Color, Material, Matrix4, Mesh, MeshBasicMaterial, MeshStandardMaterial, Object3D, Texture } from 'three'\n\ntype Three = typeof THREE_NS\n\n/** The six classes of a fused vehicle, in the order they are added to the group. */\nexport const LITE_CLASSES = ['paint', 'trim', 'metal', 'glass', 'light', 'plate'] as const\nexport type LiteClass = (typeof LITE_CLASSES)[number]\n\n/** Smallest extent in metres a piece needs to survive the fusion (the plate is always kept). */\nexport const PRUNE_BELOW = 0.03\n\n/** A material of the built vehicle as the fusion reads it (standard, basic or line materials alike). */\nexport type LiteSourceMaterial = Material & {\n map?: Texture | null\n color: Color\n metalness?: number\n roughness?: number\n emissive?: Color\n emissiveIntensity?: number\n isMeshBasicMaterial?: boolean\n}\n\n/** What the fusion reads of the built vehicle: its root and the paints (`c.paints`). */\nexport interface LiteSource {\n vehicle: Object3D\n paints?: ReadonlySet<Material> | null\n}\n\n/** A material of the fused vehicle (`liteMaterials`). */\nexport type LiteMaterial = MeshStandardMaterial | MeshBasicMaterial\n\ninterface Accumulator {\n P: number[]\n N: number[]\n C: number[]\n U: number[]\n I: number[]\n nv: number\n alpha: boolean\n uv: boolean\n map: Texture | null | undefined\n}\n\nexport interface LiteFusion {\n acc: Record<LiteClass, Accumulator>\n pruned: number\n}\n\nconst createAccumulators = (): Record<LiteClass, Accumulator> => {\n const acc = {} as Record<LiteClass, Accumulator>\n for (const name of LITE_CLASSES) acc[name] = { P: [], N: [], C: [], U: [], I: [], nv: 0, alpha: name === 'glass', uv: name === 'plate', map: null }\n return acc\n}\n\n/** Which class a material belongs to, or `null` when it is left out. */\nexport function classify(mat: LiteSourceMaterial, mesh: Object3D, c: LiteSource): LiteClass | null {\n if (mat.map) {\n if (mesh.userData.plate) return 'plate'\n if ((mat.userData && mat.userData.grille) || mat.name === 'grille' || (mat.metalness != null && mat.roughness != null && !mat.transparent)) return 'trim'\n return null\n }\n if (mat.transparent && mat.opacity < 0.99) {\n const col = mat.color\n if (col.r > col.g + col.b * 0.9 && col.r > 0.35) return 'light'\n if (col.r > 0.8 && col.g > 0.8 && mat.opacity < 0.3) return null\n return 'glass'\n }\n if (mat.isMeshBasicMaterial) return null\n const e = mat.emissive\n const ei = mat.emissiveIntensity == null ? 1 : mat.emissiveIntensity\n if (e && ((e.r + e.g + e.b) / 3) * ei > 0.25 && !mat.metalness) return 'light'\n if (e && ((e.r + e.g + e.b) / 3) * ei > 0.45) return 'light'\n if ((mat.metalness as number) >= 0.5) return 'metal'\n if (c.paints && c.paints.has(mat)) return 'paint'\n if (mat.opacity < 1 && mat.transparent) return null\n return 'trim'\n}\n\n/** The vertex colour of a piece of a class. `paintColor` replaces the primary paint. */\nexport function classColor(mat: LiteSourceMaterial, cls: LiteClass, primary: Material | null | undefined, paintColor: Color | null | undefined, out: Color): Color {\n if (cls === 'paint' && paintColor && mat === primary) return out.copy(paintColor)\n if (cls === 'light') {\n const e = mat.emissive\n const ei = mat.emissiveIntensity == null ? 1 : mat.emissiveIntensity\n if (e && e.r + e.g + e.b > 0.05) {\n out.copy(e).multiplyScalar(Math.max(1, ei) * 1.0)\n out.r = Math.min(out.r, 1)\n out.g = Math.min(out.g, 1)\n out.b = Math.min(out.b, 1)\n return out\n }\n return out.copy(mat.color)\n }\n if (mat.map) return out.setRGB(0.12, 0.13, 0.14)\n return out.copy(mat.color)\n}\n\n/** The material of each class (vertex colours; glass blends; light is unlit; the plate keeps its canvas texture). */\nexport function liteMaterials(THREE: Three, environment: Texture | null): Record<LiteClass, LiteMaterial> {\n return {\n paint: new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.42, metalness: 0.3, side: THREE.DoubleSide, envMap: environment, envMapIntensity: 0.35 }),\n trim: new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.78, metalness: 0.08, side: THREE.DoubleSide }),\n metal: new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.32, metalness: 0.85, envMap: environment, envMapIntensity: 1.1, side: THREE.DoubleSide }),\n glass: new THREE.MeshStandardMaterial({ vertexColors: true, transparent: true, depthWrite: false, roughness: 0.06, metalness: 0.3, side: THREE.DoubleSide, envMap: environment, envMapIntensity: 0.9 }),\n light: new THREE.MeshBasicMaterial({ vertexColors: true, side: THREE.DoubleSide }),\n plate: new THREE.MeshStandardMaterial({ roughness: 0.5, metalness: 0.1, side: THREE.DoubleSide }),\n }\n}\n\n/**\n * Walks the built vehicle and collects every visible mesh, in the frame of `pivot`, into one set of arrays per class.\n * `hidden` is the set of materials nobody sees from outside (`kit.lodHiddenMaterials()`).\n */\nexport function fuse(THREE: Three, c: LiteSource, pivot: Matrix4, paintColor: Color | null, primary: Material | null | undefined, hidden: ReadonlySet<Material>): LiteFusion {\n const acc = createAccumulators()\n const mw = new THREE.Matrix4()\n const nm = new THREE.Matrix3()\n const v = new THREE.Vector3()\n const col = new THREE.Color()\n const tmp = new THREE.Box3()\n let pruned = 0\n c.vehicle.updateMatrixWorld(true)\n c.vehicle.traverse((node) => {\n const o = node as Mesh<BufferGeometry, LiteSourceMaterial | LiteSourceMaterial[]> & { isInstancedMesh?: boolean; isSkinnedMesh?: boolean }\n if (!o.isMesh || o.isInstancedMesh || o.isSkinnedMesh || !o.geometry || !o.geometry.attributes.position) return\n for (let p: Object3D | null = o; p; p = p.parent) if (p.visible === false) return\n if (o.userData && (o.userData.ghost || o.userData.skipLite)) return\n const mats = Array.isArray(o.material) ? o.material : [o.material]\n const geo = o.geometry\n mw.multiplyMatrices(pivot, o.matrixWorld)\n nm.getNormalMatrix(mw)\n const flip = mw.determinant() < 0\n geo.computeBoundingBox()\n tmp.copy(geo.boundingBox!).applyMatrix4(mw)\n const ext = Math.max(tmp.max.x - tmp.min.x, tmp.max.y - tmp.min.y, tmp.max.z - tmp.min.z)\n const pa = geo.attributes.position\n const na = geo.attributes.normal\n const ua = geo.attributes.uv\n const ca = geo.attributes.color\n const ix = geo.index\n const tot = ix ? ix.count : pa.count\n const groups = Array.isArray(o.material) && geo.groups.length ? geo.groups : [{ start: 0, count: tot, materialIndex: 0 }]\n groups.forEach((gr) => {\n const mat = mats[gr.materialIndex as number] || mats[0]\n if (!mat || hidden.has(mat)) return\n const cls = classify(mat, o, c)\n if (!cls) return\n if (ext < PRUNE_BELOW && cls !== 'plate') {\n pruned++\n return\n }\n const A = acc[cls]\n const a0 = Math.min(gr.start, tot)\n let n0 = Math.min(gr.count, tot - a0)\n n0 -= n0 % 3\n if (n0 < 3) return\n const cc = classColor(mat, cls, primary, paintColor, col)\n const alpha = cls === 'glass' ? (mat.transparent ? mat.opacity : 1) : 1\n if (cls === 'plate' && A.map && mat.map !== A.map) return\n if (cls === 'plate') A.map = mat.map\n const remap = new Map<number, number>()\n for (let i = 0; i < n0; i++) {\n const vi = ix ? ix.getX(a0 + i) : a0 + i\n if (remap.has(vi)) continue\n remap.set(vi, A.nv++)\n v.fromBufferAttribute(pa, vi).applyMatrix4(mw)\n A.P.push(v.x, v.y, v.z)\n if (na) {\n v.fromBufferAttribute(na, vi).applyMatrix3(nm).normalize()\n A.N.push(v.x, v.y, v.z)\n } else A.N.push(0, 1, 0)\n let cr = cc.r\n let cg = cc.g\n let cb = cc.b\n if (ca && cls !== 'plate') {\n cr *= ca.getX(vi)\n cg *= ca.getY(vi)\n cb *= ca.getZ(vi)\n }\n if (A.alpha) A.C.push(cr, cg, cb, alpha)\n else A.C.push(cr, cg, cb)\n if (A.uv) A.U.push(ua ? ua.getX(vi) : 0, ua ? ua.getY(vi) : 0)\n }\n for (let t = 0; t < n0; t += 3) {\n const i0 = remap.get(ix ? ix.getX(a0 + t) : a0 + t) as number\n const i1 = remap.get(ix ? ix.getX(a0 + t + 1) : a0 + t + 1) as number\n const i2 = remap.get(ix ? ix.getX(a0 + t + 2) : a0 + t + 2) as number\n if (flip) A.I.push(i0, i2, i1)\n else A.I.push(i0, i1, i2)\n }\n })\n })\n return { acc, pruned }\n}\n\n/** One mesh per class that has triangles. */\nexport function liteMeshes(THREE: Three, fusion: LiteFusion, materials: Record<LiteClass, LiteMaterial>): Mesh[] {\n const meshes: Mesh[] = []\n for (const name of LITE_CLASSES) {\n const A = fusion.acc[name]\n if (!A.I.length) continue\n const g = new THREE.BufferGeometry()\n g.setAttribute('position', new THREE.Float32BufferAttribute(A.P, 3))\n g.setAttribute('normal', new THREE.Float32BufferAttribute(A.N, 3))\n g.setAttribute('color', new THREE.Float32BufferAttribute(A.C, A.alpha ? 4 : 3))\n if (A.uv) g.setAttribute('uv', new THREE.Float32BufferAttribute(A.U, 2))\n g.setIndex(A.nv > 65535 ? new THREE.Uint32BufferAttribute(A.I, 1) : new THREE.Uint16BufferAttribute(A.I, 1))\n g.computeBoundingBox()\n g.computeBoundingSphere()\n let mt = materials[name]\n if (name === 'plate') {\n mt = mt.clone()\n mt.map = A.map as Texture | null\n if (mt.map) mt.map.needsUpdate = true\n }\n const mesh = new THREE.Mesh(g, mt)\n mesh.name = name\n mesh.castShadow = name !== 'glass' && name !== 'light'\n mesh.receiveShadow = name !== 'light'\n meshes.push(mesh)\n }\n return meshes\n}\n","import type * as THREE_NS from 'three'\nimport type { DrawnCollider, WorkerCoordinator } from '@adatechnology/game-contracts'\nimport { hullOf, hullPlanKind, leavesOf, newHullPlan, planHulls, unitsOf } from '@adatechnology/game-vehicles'\nimport type { HullPlan, HullPlanJob, HullPlanPiece, HullPlanResult, PartDef, VehicleDestructible } from '@adatechnology/game-vehicles'\n\nimport { addTriangle, colliderOf, soupOf } from './collider-fit'\nimport type { Soup } from './collider-fit'\nimport type { HullPlanCache, SharedHull, SharedHulls } from './hull-plan-cache'\n\n/** The parts of the body shell: what is drawn by the vehicle's merged meshes (skin, glass, pillars, a shut door) belongs to the smallest of these whose box holds it. */\nconst SHELL_ROLES: ReadonlySet<string> = new Set(['panel', 'fender', 'roof', 'frame', 'glass', 'pillar', 'door', 'lid', 'hood', 'bumper'])\n/** Statuses of a part that is not on the vehicle any more. */\nconst GONE: ReadonlySet<string> = new Set(['broken', 'melted', 'ashes'])\n/** Parts that are a solid block, not a thin shell: one hull each, whole (design 10.1). */\nconst SOLID_ROLES: ReadonlySet<string> = new Set(['light', 'mirror', 'engine', 'radiator', 'fuel_tank', 'oil_pan', 'battery', 'alternator', 'gearbox', 'steering', 'hitch'])\n/** The wheel and what hangs on it belong to the vehicle constraint, not to the chassis compound: no hull of theirs. */\nconst WHEEL_ROLES: ReadonlySet<string> = new Set(['rim', 'tyre', 'brakes', 'shocks'])\n/** The cross product (twice the area, m2) a triangle needs to be drawn at all. */\nconst MIN_AREA = 1e-9\n/** A part's triangles are held in pieces by the cell (m) of the vehicle their centre is in: a dent in one panel makes again the pieces it touched, not the whole panel. */\nconst CHUNK = 0.8\nconst CELL_BIAS = 512\nconst CELL_SPAN = 1024\nconst PART_SPAN = 2 ** 30\n/** Numbers (coordinates and corners) of the job for the worker made in a call of `hulls()`: about a millisecond of copying. */\nconst JOB_NUMBERS_PER_CALL = 200_000\n/** Triangles of work a call may do (placing triangles in pieces, gathering a piece); what is left waits for the next call. */\nconst DEFAULT_BUDGET = Infinity\n\ntype Three = typeof THREE_NS\n\nexport interface VehicleCollidersOptions {\n /** Triangles of work per `pieces()` call: a vehicle that spawns fills in over several calls. Default all at once. */\n readonly budget?: number\n /** Keeps what `hulls()` needs (the triangles of each piece); off by default, the pieces alone need none of it. */\n readonly hulls?: boolean\n /** Hulls the model may have at most: the adaptive division (design 10.3) stops there. Default no limit. */\n readonly maxHulls?: number\n /** Where the division of the first car of a model is made (CLAUDE.md §14): in a worker, while `hulls()` answers nothing and the car keeps the boxes of `pieces()`. Without it the division is made in the call. */\n readonly workers?: WorkerCoordinator\n /** The hulls of the models already made, shared by the cars of a model: the second car of a model is given them whole. */\n readonly planCache?: HullPlanCache\n /** The model this car is of, for `planCache`; default the vehicle's key, seed key and build state. Cars with the same key must be drawn the same when intact. */\n readonly planKey?: string\n}\n\n/** A convex hull of drawn vertices (at most 64), in the frame `pieces()` answers in: `id` is the part it belongs to, `key` names it across calls. */\nexport interface VehicleHull {\n readonly id: string\n readonly key: string\n readonly points: Float32Array\n}\n\nexport interface VehicleColliders {\n /** The pieces now: only what changed since the last call is made again. */\n pieces(): DrawnCollider[]\n /** Pieces are still to be made (the budget ran out): call `pieces()` again. */\n isPending(): boolean\n /** The convex hulls of what is drawn (design 10.1): one hull of the drawn vertices of each piece (part x cell of 0.8 m), a solid part one hull whole, the wheels none; only the pieces a dent touched are made again. Needs `options.hulls`. */\n hulls(): VehicleHull[]\n /** The division is being made in a worker (`options.workers`): `hulls()` answers nothing until it is back, and the one call after that installs it. */\n isHullPending(): boolean\n /** The drawn vertices (x y z triples, the frame of `pieces()`) a hull of the last `hulls()` call was made from; empty for a hull that is not one of them. */\n drawnPointsOf(hull: VehicleHull): number[]\n}\n\n/** The division of a car in a worker: how to make its job again, its answer when back, and whether the worker failed. */\ninterface PlanFlight {\n /** What the job was made for: a car whose pieces changed while it was away does not take the answer. */\n readonly signature: string\n readonly job: () => HullPlanJob\n result?: HullPlanResult\n failed: boolean\n}\n\n/** One drawn mesh as the cache knows it: where each of its triangles went, and what it looked like when it was last read. */\ninterface MeshEntry {\n readonly geometry: THREE_NS.BufferGeometry\n readonly owner: string | null\n readonly positions: ArrayLike<number>\n readonly indexArray: ArrayLike<number> | undefined\n readonly triangles: number\n /** The mesh in the frame (column-major) as it was read. */\n matrix: number[]\n version: number\n snapshot: Float32Array\n /** The piece (key) of each triangle; filled by `assigned` triangles, then `chunks` says which triangles each piece has. */\n readonly pieceOf: Float64Array\n assigned: number\n readonly chunks: Map<number, number[]>\n}\n\n/** A piece: the triangles of one part in one cell of the vehicle, from one or more meshes, and the collider made of them. */\ninterface Piece {\n readonly key: number\n readonly part: string\n readonly entries: Set<MeshEntry>\n dirty: boolean\n collider: DrawnCollider | null\n /** The triangles the collider was made from, kept when hulls are wanted; `version` counts how many times they were made. */\n soup: Soup | null\n version: number\n /** The hulls of `soup` as of `version` (and the drawn vertices of each), so a call that finds nothing changed hands back the same objects. */\n hulls: readonly SharedHull[]\n hullVersion: number\n}\n\n/**\n * Whether `mesh` is a drawn part of the vehicle under `stop` (`c.vehicle`): visibility walks only up to `stop` so `createVehicleLod` hiding the full group to draw the fused\n * copy (`vehicle-lite`) does not drop every collider and force a full rebuild when the car unfuses. Static-batch copies (`noSurfaceRay`) are skipped for the same reason as\n * `surfaceRay`: the parts they copy are already here.\n */\nconst isDrawn = (mesh: THREE_NS.Mesh, stop: THREE_NS.Object3D): boolean => {\n if (!mesh.isMesh || !mesh.geometry || mesh.userData.ghost || mesh.userData.helper) return false\n if (!mesh.geometry.getAttribute('position')) return false\n for (let node: THREE_NS.Object3D | null = mesh; node; node = node.parent) {\n if (node.visible === false || node.userData.noSurfaceRay) return false\n if (node === stop) break\n }\n return true\n}\n\n/** The part of the shell whose box holds the point (vehicle space), the smallest first; the hub when none does. */\nconst shellPartAt = (shell: readonly PartDef[], hub: string, x: number, y: number, z: number): string => {\n let best = hub\n let bestVolume = Infinity\n for (const part of shell) {\n const { center, size } = part.box\n if (Math.abs(x - center[0]) > size[0] / 2 || Math.abs(y - center[1]) > size[1] / 2 || Math.abs(z - center[2]) > size[2] / 2) continue\n const volume = size[0] * size[1] * size[2]\n if (volume < bestVolume) [best, bestVolume] = [part.id, volume]\n }\n return best\n}\n\n/** A triangle with a corner that is not a number, or with no area (two corners the same, three on a line), is not drawn: nothing to collide with. */\nconst isNotDrawn = (positions: ArrayLike<number>, [a, b, c]: readonly [number, number, number]): boolean => {\n const ux = (positions[b * 3] as number) - (positions[a * 3] as number), uy = (positions[b * 3 + 1] as number) - (positions[a * 3 + 1] as number), uz = (positions[b * 3 + 2] as number) - (positions[a * 3 + 2] as number)\n const wx = (positions[c * 3] as number) - (positions[a * 3] as number), wy = (positions[c * 3 + 1] as number) - (positions[a * 3 + 1] as number), wz = (positions[c * 3 + 2] as number) - (positions[a * 3 + 2] as number)\n const area = Math.hypot(uy * wz - uz * wy, uz * wx - ux * wz, ux * wy - uy * wx)\n return !(area > MIN_AREA)\n}\n\n/** The numbers as a typed array, which a worker takes by copying bytes (a plain array is cloned one number at a time). */\nconst float64Of = (numbers: readonly number[]): Float64Array => {\n const out = new Float64Array(numbers.length)\n for (let i = 0; i < out.length; i++) out[i] = numbers[i]!\n return out\n}\nconst uint32Of = (numbers: readonly number[]): Uint32Array => {\n const out = new Uint32Array(numbers.length)\n for (let i = 0; i < out.length; i++) out[i] = numbers[i]!\n return out\n}\n\n/** One piece of a job for the worker, its triangles as bytes. */\nconst pieceOfJob = (key: string, piece: Piece): HullPlanPiece => ({ key, vertices: float64Of(piece.soup!.vertices), indices: uint32Of(piece.soup!.indices) })\n\n/** What the one hull of a solid part was made from: its pieces and how many times each was made. */\nconst signatureOfSolid = (members: readonly Piece[]): string => members.map((piece) => `${piece.key}.${piece.version}`).join(',')\n\nconst sameMatrix = (a: readonly number[], b: ArrayLike<number>): boolean => {\n for (let i = 0; i < 16; i++) if (a[i] !== b[i]) return false\n return true\n}\n\n/**\n * What a vehicle collides with in an engine, as it is drawn: one piece per part that has a mesh of its own (a door, the hood, the lid, a bumper, a wheel, a tyre, a lamp, a\n * mirror), and the rest of what is drawn (the body's merged meshes, the glass, the interior) split by the part of the shell that holds each triangle. A part's triangles are\n * held in pieces by the 40 cm cell of the vehicle they are in; each piece is the box along the drawn vertices where that fits within 1 cm, else its triangles (coarsened, every\n * vertex a drawn one) with the box around them. In the frame `describe()` answers in. A part that broke or came off has none; a mirror is its own piece and never widens the cab.\n *\n * Kept between calls: where each triangle went is worked out once per mesh, and a call finds what moved (a mesh that was posed, vertices a dent pushed) and makes again only\n * the pieces it touched.\n */\nexport const createVehicleColliders = (THREE: Three, vehicle: VehicleDestructible, frame: THREE_NS.Object3D, options: VehicleCollidersOptions = {}): VehicleColliders => {\n const entries = new Map<THREE_NS.Mesh, MeshEntry>()\n const pieces = new Map<number, Piece>()\n const partIndex = new Map(vehicle.model.parts.map((part, index) => [part.id, index]))\n const isShown = new Map(vehicle.model.parts.map((part) => [part.id, part.visual]))\n const isSolid = new Map(vehicle.model.parts.map((part) => [part.id, SOLID_ROLES.has(part.role)]))\n const isWheel = new Map(vehicle.model.parts.map((part) => [part.id, WHEEL_ROLES.has(part.role)]))\n const shell = vehicle.model.parts.filter((part) => SHELL_ROLES.has(part.role))\n const toFrame = new THREE.Matrix4()\n const toVehicle = new THREE.Matrix4()\n const toShell = new THREE.Matrix4()\n const placed = new THREE.Vector3()\n const matrix = new THREE.Matrix4()\n let pending = false\n let shown: Piece[] = []\n let hullSources = new Map<VehicleHull, ReadonlyArray<ArrayLike<number>>>()\n let plan: HullPlan = newHullPlan()\n let isDivided = false\n let hullGroups = new Map<string, { readonly signature: string; readonly hulls: VehicleHull[] }>()\n /** What the model's cars share, once this car has it (or made it). */\n let shared: SharedHulls | undefined\n /** The division in a worker: its answer when back, and whether it failed. */\n let flight: PlanFlight | undefined\n /** A dent moved a vertex, or a part is gone: the car is not what its model is, and neither takes from nor gives to the cache. */\n let isDamaged = false\n /** The job for the worker as far as it is made (`hasJobBuilt`), and what it is of. */\n let building: { readonly signature: string; readonly pieces: HullPlanPiece[]; readonly solids: HullPlanPiece[] } | undefined\n\n const release = (entry: MeshEntry): void => {\n for (const key of entry.chunks.keys()) {\n const piece = pieces.get(key)\n if (!piece) continue\n piece.entries.delete(entry)\n piece.dirty = true\n }\n }\n\n const touch = (entry: MeshEntry, only?: Set<number>): void => {\n for (const key of entry.chunks.keys()) if (!only || only.has(key)) {\n const piece = pieces.get(key)\n if (piece) piece.dirty = true\n }\n }\n\n /** Places the next triangles of the mesh in the pieces of its parts; false when the budget ran out first. */\n const assign = (mesh: THREE_NS.Mesh, entry: MeshEntry, budget: { left: number }): boolean => {\n toShell.multiplyMatrices(toVehicle, mesh.matrixWorld)\n const positions = entry.positions\n const index = entry.indexArray\n const owner = entry.owner\n const e = toShell.elements\n for (; entry.assigned < entry.triangles && budget.left > 0; entry.assigned++, budget.left--) {\n const t = entry.assigned * 3\n const a = index ? (index[t] as number) : t, b = index ? (index[t + 1] as number) : t + 1, c = index ? (index[t + 2] as number) : t + 2\n placed.set(\n ((positions[a * 3] as number) + (positions[b * 3] as number) + (positions[c * 3] as number)) / 3,\n ((positions[a * 3 + 1] as number) + (positions[b * 3 + 1] as number) + (positions[c * 3 + 1] as number)) / 3,\n ((positions[a * 3 + 2] as number) + (positions[b * 3 + 2] as number) + (positions[c * 3 + 2] as number)) / 3,\n )\n const x = e[0]! * placed.x + e[4]! * placed.y + e[8]! * placed.z + e[12]!\n const y = e[1]! * placed.x + e[5]! * placed.y + e[9]! * placed.z + e[13]!\n const z = e[2]! * placed.x + e[6]! * placed.y + e[10]! * placed.z + e[14]!\n const part = owner ?? shellPartAt(shell, vehicle.model.hub, x, y, z)\n const cell = ((Math.floor(x / CHUNK) + CELL_BIAS) * CELL_SPAN + (Math.floor(y / CHUNK) + CELL_BIAS)) * CELL_SPAN + (Math.floor(z / CHUNK) + CELL_BIAS)\n entry.pieceOf[entry.assigned] = (partIndex.get(part) ?? 0) * PART_SPAN + cell\n }\n if (entry.assigned < entry.triangles) return false\n for (let t = 0; t < entry.triangles; t++) {\n const key = entry.pieceOf[t] as number\n let list = entry.chunks.get(key)\n if (!list) entry.chunks.set(key, (list = []))\n list.push(t)\n }\n for (const key of entry.chunks.keys()) {\n let piece = pieces.get(key)\n if (!piece) {\n const part = vehicle.model.parts[Math.floor(key / PART_SPAN)]!.id\n pieces.set(key, (piece = { key, part, entries: new Set(), dirty: true, collider: null, soup: null, version: 0, hulls: [], hullVersion: -1 }))\n }\n piece.entries.add(entry)\n piece.dirty = true\n }\n entry.snapshot = new Float32Array(positions)\n return true\n }\n\n /** What a dent changed: the pieces holding a triangle with a vertex that moved. */\n const follow = (entry: MeshEntry, position: THREE_NS.BufferAttribute | THREE_NS.InterleavedBufferAttribute): void => {\n const array = entry.positions\n const moved = new Set<number>()\n const changed = new Uint8Array(array.length / 3)\n for (let i = 0; i < array.length; i++) {\n if (array[i] === entry.snapshot[i]) continue\n isDamaged = true\n changed[Math.floor(i / 3)] = 1\n entry.snapshot[i] = array[i] as number\n }\n const index = entry.indexArray\n for (let t = 0; t < entry.triangles; t++) {\n const a = index ? (index[t * 3] as number) : t * 3, b = index ? (index[t * 3 + 1] as number) : t * 3 + 1, c = index ? (index[t * 3 + 2] as number) : t * 3 + 2\n if (changed[a] || changed[b] || changed[c]) moved.add(entry.pieceOf[t] as number)\n }\n entry.version = (position as THREE_NS.BufferAttribute).version\n touch(entry, moved)\n }\n\n const read = (mesh: THREE_NS.Mesh, owner: string | null, budget: { left: number }): void => {\n const geometry = mesh.geometry\n const position = geometry.getAttribute('position')\n const indexAttribute = geometry.getIndex()\n const triangles = Math.floor((indexAttribute ? indexAttribute.count : position.count) / 3)\n matrix.multiplyMatrices(toFrame, mesh.matrixWorld)\n let entry = entries.get(mesh)\n if (entry && (entry.geometry !== geometry || entry.owner !== owner || entry.positions !== position.array || entry.indexArray !== indexAttribute?.array || entry.triangles !== triangles)) {\n release(entry)\n entries.delete(mesh)\n entry = undefined\n }\n if (!entry) {\n entry = { geometry, owner, positions: position.array, indexArray: indexAttribute?.array, triangles, matrix: [...matrix.elements], version: (position as THREE_NS.BufferAttribute).version, snapshot: new Float32Array(0), pieceOf: new Float64Array(triangles), assigned: 0, chunks: new Map() }\n entries.set(mesh, entry)\n }\n if (entry.assigned < entry.triangles) {\n if (!assign(mesh, entry, budget)) pending = true\n return\n }\n if (!sameMatrix(entry.matrix, matrix.elements)) {\n entry.matrix = [...matrix.elements]\n touch(entry)\n }\n if ((position as THREE_NS.BufferAttribute).version !== entry.version) follow(entry, position)\n }\n\n const rebuild = (piece: Piece, budget: { left: number }): void => {\n const soup = soupOf()\n for (const entry of piece.entries) {\n for (const t of entry.chunks.get(piece.key) ?? []) {\n const index = entry.indexArray\n budget.left--\n const corners: [number, number, number] = index ? [index[t * 3] as number, index[t * 3 + 1] as number, index[t * 3 + 2] as number] : [t * 3, t * 3 + 1, t * 3 + 2]\n if (isNotDrawn(entry.positions, corners)) continue\n addTriangle(soup, entry, entry.positions, corners, entry.matrix)\n }\n }\n piece.collider = colliderOf(piece.part, `${piece.part}#${piece.key % PART_SPAN}`, soup)\n piece.soup = options.hulls ? soup : null\n piece.version++\n piece.dirty = false\n }\n\n const make = (): DrawnCollider[] => {\n // `vehicle.vehicle` is replaced on `reset()`: reading it each call follows the live vehicle instead of the disposed one\n const root = vehicle.vehicle.vehicle as THREE_NS.Object3D\n frame.updateWorldMatrix(true, true)\n root.updateWorldMatrix(true, true)\n toFrame.copy(frame.matrixWorld).invert()\n toVehicle.copy(root.matrixWorld).invert()\n const state = new Map(vehicle.state().parts.map((part) => [part.id, part]))\n const isGone = (id: string): boolean => {\n const part = state.get(id)\n const isOff = part !== undefined && (GONE.has(part.status) || part.group !== 0)\n if (isOff) isDamaged = true\n return isOff\n }\n const budget = { left: options.budget ?? DEFAULT_BUDGET }\n pending = false\n const live = new Map<THREE_NS.Mesh, string | null>()\n const claimed = new Set<THREE_NS.Mesh>()\n for (const part of vehicle.model.parts) {\n for (const object of vehicle.objectsOf(part.id)) {\n object.traverse((node) => {\n const mesh = node as THREE_NS.Mesh\n if (claimed.has(mesh)) return\n claimed.add(mesh)\n if (!isGone(part.id) && isDrawn(mesh, root)) live.set(mesh, part.id)\n })\n }\n }\n root.traverse((node) => {\n const mesh = node as THREE_NS.Mesh\n if (!claimed.has(mesh) && isDrawn(mesh, root)) live.set(mesh, null)\n })\n for (const [mesh, entry] of entries) {\n if (live.has(mesh)) continue\n release(entry)\n entries.delete(mesh)\n }\n for (const [mesh, owner] of live) read(mesh, owner, budget)\n const out: DrawnCollider[] = []\n shown = []\n for (const [key, piece] of pieces) {\n if (piece.entries.size === 0) {\n pieces.delete(key)\n continue\n }\n if (piece.dirty) {\n if (budget.left <= 0) pending = true\n else rebuild(piece, budget)\n }\n if (piece.collider && !(isGone(piece.part) && isShown.get(piece.part))) {\n out.push(piece.collider)\n shown.push(piece)\n }\n }\n return out\n }\n\n const nameOf = (piece: Piece): string => `${piece.part}#${piece.key % PART_SPAN}`\n\n /** The hulls of one piece: its body and its thin protrusions (hull-split.ts), each cut as the plan cut it; made again only when the piece was. */\n const hullsOfPiece = (piece: Piece): readonly SharedHull[] => {\n if (piece.hullVersion === piece.version) return piece.hulls\n const made: SharedHull[] = []\n for (const unit of unitsOf(nameOf(piece), piece.soup!, plan.taken.get(nameOf(piece)))) {\n for (const leaf of leavesOf(unit.key, unit.soup, plan.cuts.get(unit.key) ?? null)) {\n const points = hullOf(leaf.soup)\n if (points) made.push({ hull: { id: piece.part, key: leaf.key, points: new Float32Array(points) }, drawn: leaf.soup.vertices })\n }\n }\n piece.hulls = made\n piece.hullVersion = piece.version\n return piece.hulls\n }\n\n /** The pieces' triangles as the division reads them: the thin pieces, and the pieces of each solid part under the name of the part. */\n const jobOf = (thin: readonly Piece[], solids: ReadonlyMap<string, readonly Piece[]>): HullPlanJob => ({\n pieces: thin.map((piece) => pieceOfJob(nameOf(piece), piece)),\n solids: [...solids].flatMap(([part, members]) => members.map((piece) => pieceOfJob(part, piece))),\n maxHulls: (options.maxHulls ?? Infinity) - solids.size,\n })\n\n /** What a model's hulls were made for: the names and vertex counts of the pieces (thin and solid), and the ceiling. */\n const signatureOf = (thin: readonly Piece[], solids: ReadonlyMap<string, readonly Piece[]>): string =>\n `${options.maxHulls ?? Infinity}|${thin.map((piece) => `${nameOf(piece)}:${piece.soup!.vertices.length}`).join(',')}|${[...solids].map(([part, members]) => `${part}:${members.map((piece) => `${piece.key}.${piece.soup!.vertices.length}`).join('+')}`).join(',')}`\n\n const modelKeyOf = (): string | undefined => {\n if (options.planKey) return options.planKey\n const context = vehicle.vehicle as unknown as { readonly key?: string; readonly seedKey?: string; readonly state?: string }\n return context.key === undefined ? undefined : `${context.key}|${context.seedKey ?? context.key}|${context.state ?? ''}`\n }\n\n /** The division as the car holds it: the plan, and each piece's hulls. The pieces' hulls are the cars' to share, so they are made once from the result. */\n const install = (result: HullPlanResult, thin: readonly Piece[], solids: ReadonlyMap<string, readonly Piece[]>, signature: string, modelKey: string | undefined): void => {\n const owners = new Map(thin.map((piece) => [nameOf(piece), piece]))\n const made = new Map<string, SharedHull[]>()\n for (const leaf of result.leaves) {\n const name = leaf.unit.split('~')[0]!\n const owner = owners.get(name)\n if (!owner) continue\n const list = made.get(name) ?? []\n list.push({ hull: { id: owner.part, key: leaf.path ? `${leaf.unit}:${leaf.path}` : leaf.unit, points: leaf.points }, drawn: leaf.vertices })\n made.set(name, list)\n }\n plan = { cuts: new Map(result.cuts), taken: new Map(result.taken.map(([unit, numbers]) => [unit, new Set(numbers)])) }\n for (const piece of thin) {\n piece.hulls = made.get(nameOf(piece)) ?? []\n piece.hullVersion = piece.version\n }\n for (const solid of result.solids) {\n const members = solids.get(solid.key)\n if (members) hullGroups.set(solid.key, { signature: signatureOfSolid(members), hulls: solid.points.length > 0 ? [{ id: solid.key, key: solid.key, points: solid.points }] : [] })\n }\n isDivided = true\n if (modelKey && options.planCache && !isDamaged) {\n shared = { signature, plan, pieces: made, solids: new Map(hullGroups) }\n options.planCache.set(modelKey, shared)\n }\n }\n\n /** A car of a model whose hulls were made: its pieces get them as they are, with nothing to make. */\n const adopt = (from: SharedHulls, thin: readonly Piece[]): void => {\n plan = from.plan\n for (const piece of thin) {\n piece.hulls = from.pieces.get(nameOf(piece)) ?? []\n piece.hullVersion = piece.version\n }\n hullGroups = new Map(from.solids)\n shared = from\n isDivided = true\n options.planCache!.noteReused()\n }\n\n /**\n * The division is planned once per model, on the car as it is the first time all its pieces are there, and kept: later calls cut the same way, and a car of a model that was divided is given\n * the hulls. The solid parts (one hull each) count against `maxHulls`. With `options.workers` the first car of a model sends the division to a worker and this answers false until it is back\n * (the car keeps the boxes of `pieces()`); the one call after the answer installs it, so the switch is in a step of the caller's, not between two.\n */\n const divide = (thin: readonly Piece[], solids: ReadonlyMap<string, readonly Piece[]>): boolean => {\n const signature = signatureOf(thin, solids)\n const modelKey = modelKeyOf()\n const cache = options.planCache\n if (!flight) {\n const known = !isDamaged && modelKey && cache ? cache.get(modelKey) : undefined\n if (known && known.signature === signature) {\n adopt(known, thin)\n building = undefined\n return true\n }\n if (!options.workers) {\n cache?.noteDivided()\n install(planHulls(jobOf(thin, solids)), thin, solids, signature, modelKey)\n return true\n }\n const going = !isDamaged && modelKey ? cache?.flight(modelKey) : undefined\n const isGoing = going !== undefined && going.signature === signature\n if (!isGoing && !hasJobBuilt(thin, solids, signature)) return false\n const promise = isGoing ? going.promise : options.workers.run(hullPlanKind, { pieces: building!.pieces, solids: building!.solids, maxHulls: (options.maxHulls ?? Infinity) - solids.size })\n if (!isGoing) {\n cache?.noteDivided()\n if (modelKey && !isDamaged) cache?.setFlight(modelKey, { signature, promise })\n }\n building = undefined\n const mine: PlanFlight = { signature, job: () => jobOf(thin, solids), failed: false }\n flight = mine\n promise.then((result) => { mine.result = result }, () => { mine.failed = true }).finally(() => { if (modelKey && cache?.flight(modelKey)?.promise === promise) cache.clearFlight(modelKey) })\n }\n if (!flight.result && !flight.failed) return false\n const arrived = flight\n flight = undefined\n if (arrived.signature !== signature) return divide(thin, solids)\n const known = !isDamaged && modelKey && cache ? cache.get(modelKey) : undefined\n if (arrived.failed && known && known.signature === signature) adopt(known, thin)\n else install(arrived.result ?? planHulls(arrived.job()), thin, solids, signature, modelKey)\n return true\n }\n\n /** Makes the next pieces of the job for the worker, `JOB_NUMBERS_PER_CALL` numbers at most a call (a plain array is copied into bytes at some 5 ns a number: the first car of a model would hold the frame for as long as it has triangles); true when it is whole. */\n const hasJobBuilt = (thin: readonly Piece[], solids: ReadonlyMap<string, readonly Piece[]>, signature: string): boolean => {\n if (!building || building.signature !== signature) building = { signature, pieces: [], solids: [] }\n const solidPieces = [...solids].flatMap(([part, members]) => members.map((piece) => [part, piece] as const))\n let room = JOB_NUMBERS_PER_CALL\n while (building.pieces.length < thin.length && room > 0) {\n const piece = thin[building.pieces.length]!\n building.pieces.push(pieceOfJob(nameOf(piece), piece))\n room -= piece.soup!.vertices.length + piece.soup!.indices.length\n }\n while (building.pieces.length === thin.length && building.solids.length < solidPieces.length && room > 0) {\n const [part, piece] = solidPieces[building.solids.length]!\n building.solids.push(pieceOfJob(part, piece))\n room -= piece.soup!.vertices.length + piece.soup!.indices.length\n }\n return building.pieces.length === thin.length && building.solids.length === solidPieces.length\n }\n\n /** The one hull of a solid part: its pieces' triangles together. */\n const hullOfSolid = (part: string, members: readonly Piece[]): VehicleHull[] => {\n const signature = signatureOfSolid(members)\n let made = hullGroups.get(part)\n if (!made || made.signature !== signature) {\n const vertices: number[] = []\n const indices: number[] = []\n for (const piece of members) {\n const offset = vertices.length / 3\n for (const v of piece.soup!.vertices) vertices.push(v)\n for (const i of piece.soup!.indices) indices.push(i + offset)\n }\n const points = hullOf({ vertices, indices })\n made = { signature, hulls: points ? [{ id: part, key: part, points: new Float32Array(points) }] : [] }\n hullGroups.set(part, made)\n }\n return made.hulls\n }\n\n const hulls = (): VehicleHull[] => {\n if (!options.hulls) throw new Error('createVehicleColliders: hulls() needs options.hulls')\n make()\n hullSources = new Map()\n const out: VehicleHull[] = []\n const solids = new Map<string, Piece[]>()\n const thin: Piece[] = []\n for (const piece of shown) {\n if (!piece.soup || isWheel.get(piece.part)) continue\n if (!isSolid.get(piece.part)) {\n thin.push(piece)\n continue\n }\n const list = solids.get(piece.part)\n if (list) list.push(piece)\n else solids.set(piece.part, [piece])\n }\n if (!isDivided && !pending && !divide(thin, solids)) return out\n for (const piece of thin) {\n for (const { hull, drawn } of hullsOfPiece(piece)) {\n out.push(hull)\n hullSources.set(hull, [drawn])\n }\n }\n for (const id of hullGroups.keys()) if (!solids.has(id)) hullGroups.delete(id)\n for (const [part, members] of solids) {\n for (const hull of hullOfSolid(part, members)) {\n out.push(hull)\n hullSources.set(hull, members.map((piece) => piece.soup!.vertices))\n }\n }\n return out\n }\n\n const drawnPointsOf = (hull: VehicleHull): number[] => (hullSources.get(hull) ?? []).flatMap((vertices) => Array.from(vertices))\n\n return { pieces: make, isPending: () => pending, hulls, isHullPending: () => flight !== undefined || building !== undefined, drawnPointsOf }\n}\n\n/** The pieces of a vehicle once, all at once (`createVehicleColliders` keeps them between calls). */\nexport const vehicleColliders = (THREE: Three, vehicle: VehicleDestructible, frame: THREE_NS.Object3D): DrawnCollider[] => createVehicleColliders(THREE, vehicle, frame).pieces()\n\n/** The convex hulls of a vehicle once, all at once (`createVehicleColliders` with `hulls` keeps them between calls). */\nexport const vehicleHulls = (THREE: Three, vehicle: VehicleDestructible, frame: THREE_NS.Object3D): VehicleHull[] => createVehicleColliders(THREE, vehicle, frame, { hulls: true }).hulls()\n","import type { DrawnCollider } from '@adatechnology/game-contracts'\nimport { fitOrientedBox, fitOrientedBoxes, hugs } from '@adatechnology/game-shapes'\nimport type { OrientedBox } from '@adatechnology/game-shapes'\n\n/** A box fits a drawn piece when each of its eight corners has a vertex within this (m): the same rule as the fixed things of `game-destruction-three`. */\nconst FIT = 0.01\n/** The thinnest half (m) a drawn plane (a sheet with no thickness) is held by. */\nconst MIN_HALF = 0.005\n/** A drawn piece with more triangles than this is held by a coarser mesh: the cars draw tens of thousands of triangles to take cuts, and an engine collides with a surface, not with a tessellation. */\nconst COARSEN_ABOVE = 60\n/** The cell (m) the vertices of a coarsened piece are merged in. */\nexport const COARSE_CELL = 0.008\n/** A coarsened piece with fewer triangles than this is not worth the loss: the piece keeps all of its own. */\nconst COARSE_MIN_TRIANGLES = 12\nconst IDENTITY_AXES = [1, 0, 0, 0, 1, 0, 0, 0, 1]\nconst CELL_BIAS = 4096\nconst CELL_SPAN = 8192\n\n/** A drawn piece in the making: the triangles of its meshes in the vehicle's frame. */\nexport interface Soup {\n readonly vertices: number[]\n readonly indices: number[]\n /** Where each vertex of a source (one mesh as placed: two meshes may share a geometry) went in `vertices`, so a vertex the triangles share is kept once. */\n readonly placed: Map<object, Map<number, number>>\n}\n\nexport const soupOf = (): Soup => ({ vertices: [], indices: [], placed: new Map() })\n\n/** Adds one triangle of a mesh (`source` names it, its `positions`, the three vertex numbers) to the soup, moved by `matrix` (column-major, as three.js holds it). */\nexport const addTriangle = (soup: Soup, source: object, positions: ArrayLike<number>, corners: readonly [number, number, number], matrix: ArrayLike<number>): void => {\n let placed = soup.placed.get(source)\n if (!placed) soup.placed.set(source, (placed = new Map()))\n for (const corner of corners) {\n let at = placed.get(corner)\n if (at === undefined) {\n const x = positions[corner * 3] as number, y = positions[corner * 3 + 1] as number, z = positions[corner * 3 + 2] as number\n at = soup.vertices.length / 3\n placed.set(corner, at)\n soup.vertices.push(\n matrix[0]! * x + matrix[4]! * y + matrix[8]! * z + matrix[12]!,\n matrix[1]! * x + matrix[5]! * y + matrix[9]! * z + matrix[13]!,\n matrix[2]! * x + matrix[6]! * y + matrix[10]! * z + matrix[14]!,\n )\n }\n soup.indices.push(at)\n }\n}\n\nconst cellKey = (x: number, y: number, z: number, cell: number): number =>\n ((Math.floor(x / cell) + CELL_BIAS) * CELL_SPAN + (Math.floor(y / cell) + CELL_BIAS)) * CELL_SPAN + (Math.floor(z / cell) + CELL_BIAS)\n\n/**\n * The soup with the vertices of each `COARSE_CELL` cube merged into the drawn vertex nearest their mean, so the collision surface starts on the drawn one and no triangle\n * can leave it by more than a cell; triangles that collapsed or repeat are left out.\n */\nconst coarsen = (soup: Soup): Soup => {\n const count = soup.vertices.length / 3\n const cells = new Map<number, number>()\n const sums: number[] = []\n const counts: number[] = []\n const to = new Uint32Array(count)\n for (let i = 0; i < count; i++) {\n const x = soup.vertices[i * 3] as number, y = soup.vertices[i * 3 + 1] as number, z = soup.vertices[i * 3 + 2] as number\n const key = cellKey(x, y, z, COARSE_CELL)\n let at = cells.get(key)\n if (at === undefined) {\n at = counts.length\n cells.set(key, at)\n counts.push(0)\n sums.push(0, 0, 0)\n }\n to[i] = at\n counts[at] = (counts[at] as number) + 1\n sums[at * 3] = (sums[at * 3] as number) + x\n sums[at * 3 + 1] = (sums[at * 3 + 1] as number) + y\n sums[at * 3 + 2] = (sums[at * 3 + 2] as number) + z\n }\n const best = new Float64Array(counts.length).fill(Infinity)\n const vertices = new Array<number>(counts.length * 3).fill(0)\n for (let i = 0; i < count; i++) {\n const at = to[i] as number\n const n = counts[at] as number\n const x = soup.vertices[i * 3] as number, y = soup.vertices[i * 3 + 1] as number, z = soup.vertices[i * 3 + 2] as number\n const d = (x - (sums[at * 3] as number) / n) ** 2 + (y - (sums[at * 3 + 1] as number) / n) ** 2 + (z - (sums[at * 3 + 2] as number) / n) ** 2\n if (d >= (best[at] as number)) continue\n best[at] = d\n vertices[at * 3] = x\n vertices[at * 3 + 1] = y\n vertices[at * 3 + 2] = z\n }\n const indices: number[] = []\n const seen = new Set<number>()\n const stride = counts.length\n for (let i = 0; i + 2 < soup.indices.length; i += 3) {\n const a = to[soup.indices[i] as number] as number, b = to[soup.indices[i + 1] as number] as number, c = to[soup.indices[i + 2] as number] as number\n if (a === b || b === c || a === c) continue\n const lo = Math.min(a, b, c), hi = Math.max(a, b, c)\n const key = (lo * stride + (a + b + c - lo - hi)) * stride + hi\n if (seen.has(key)) continue\n seen.add(key)\n indices.push(a, b, c)\n }\n return { vertices, indices, placed: new Map() }\n}\n\n/** The axes (three rows of 3) of a box turned by the quaternion. */\nconst axesOf = ([x, y, z, w]: readonly [number, number, number, 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 box with its sides on the points: the fitted box is at least 2 cm thick, a drawn sheet is not, and no collider reaches 1 cm past what is drawn. */\nconst tightened = (points: readonly number[], box: OrientedBox): OrientedBox => {\n const axes = axesOf(box.rotation)\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 t = (points[i] as number) * (axes[k * 3] as number) + (points[i + 1] as number) * (axes[k * 3 + 1] as number) + (points[i + 2] as number) * (axes[k * 3 + 2] as number)\n if (t < low[k]!) low[k] = t\n if (t > high[k]!) high[k] = t\n }\n }\n const mid = [0, 1, 2].map((k) => (low[k]! + high[k]!) / 2)\n const center = [0, 1, 2].map((k) => mid[0]! * (axes[k] as number) + mid[1]! * (axes[3 + k] as number) + mid[2]! * (axes[6 + k] as number)) as [number, number, number]\n const half = [0, 1, 2].map((k) => Math.max(MIN_HALF, (high[k]! - low[k]!) / 2)) as [number, number, number]\n return { center, half, rotation: box.rotation }\n}\n\n/** Whether the SDK fit (`fitOrientedBoxes`, which reads the surface between the vertices) holds the drawing in one box: a box with a vertex at each corner can still be mostly air inside when the piece is made of separate solids (a ladder frame of loose rails, a block with a loose detail). */\nconst isOneBox = (soup: Soup): boolean => fitOrientedBoxes(soup.vertices, soup.indices).length <= 1\n\n/** The box that holds the soup: axis-aligned in the frame where that fits, else along its principal axes where that fits, else the triangles with the box around them. */\nexport const colliderOf = (id: string, key: string, soup: Soup): DrawnCollider | null => {\n const points = soup.vertices\n if (points.length < 9) return null\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] as number\n if (v < low[k]!) low[k] = v\n if (v > high[k]!) high[k] = v\n }\n }\n const center: [number, number, number] = [(low[0]! + high[0]!) / 2, (low[1]! + high[1]!) / 2, (low[2]! + high[2]!) / 2]\n const half: [number, number, number] = [(high[0]! - low[0]!) / 2, (high[1]! - low[1]!) / 2, (high[2]! - low[2]!) / 2]\n const held = half.map((h) => Math.max(MIN_HALF, h)) as [number, number, number]\n let oneBox: boolean | undefined\n const isHeldByOneBox = (): boolean => (oneBox ??= isOneBox(soup))\n if (hugs(points, { center, half, axes: IDENTITY_AXES, tolerance: [FIT, FIT, FIT] }) && isHeldByOneBox()) return { id, key, center, half: held, rotation: [0, 0, 0, 1] }\n const turned = fitOrientedBox(points)\n if (turned && hugs(points, { center: turned.center, half: turned.half, axes: axesOf(turned.rotation), tolerance: [FIT, FIT, FIT] }) && isHeldByOneBox()) return { id, key, ...tightened(points, turned) }\n const coarse = soup.indices.length / 3 > COARSEN_ABOVE ? coarsen(soup) : soup\n const kept = coarse.indices.length >= COARSE_MIN_TRIANGLES * 3 ? coarse : soup\n return { id, key, center, half: held, rotation: [0, 0, 0, 1], mesh: { vertices: new Float32Array(kept.vertices), indices: new Uint32Array(kept.indices) } }\n}\n","import type { HullPlan, HullPlanResult } from '@adatechnology/game-vehicles'\n\nimport type { VehicleHull } from './colliders'\n\n/** A hull and the drawn vertices (x y z triples) it was made from. */\nexport interface SharedHull {\n readonly hull: VehicleHull\n readonly drawn: ArrayLike<number>\n}\n\n/** The hulls of an intact model, made once: what every car of it is given instead of making them. */\nexport interface SharedHulls {\n /** The pieces (names and vertex counts) and the hull ceiling it was made for: a car whose pieces differ makes its own. */\n readonly signature: string\n readonly plan: HullPlan\n readonly pieces: ReadonlyMap<string, readonly SharedHull[]>\n /** The solid parts' hulls (one each, whole), filled in by the first car that made them. */\n readonly solids: Map<string, { readonly signature: string; readonly hulls: VehicleHull[] }>\n}\n\n/** A division on its way (in a worker): the cars of the same model wait for it instead of sending another. */\nexport interface HullPlanFlight {\n readonly signature: string\n readonly promise: Promise<HullPlanResult>\n}\n\nexport interface HullPlanCacheStats {\n readonly models: number\n /** Divisions made (here or in a worker). */\n readonly planned: number\n /** Cars given the hulls of a model that was already made. */\n readonly reused: number\n}\n\n/**\n * The hulls of the intact models, by model (the vehicle key, its seed key and its build state, and the ceiling): the division of a car is the same for every car of the model, so it is\n * made once. `dispose` lets everything go (design 10.4: the memory is the engine's shapes and these, nothing is kept after).\n */\nexport interface HullPlanCache {\n get(key: string): SharedHulls | undefined\n set(key: string, shared: SharedHulls): void\n flight(key: string): HullPlanFlight | undefined\n setFlight(key: string, flight: HullPlanFlight): void\n clearFlight(key: string): void\n noteReused(): void\n noteDivided(): void\n stats(): HullPlanCacheStats\n dispose(): void\n}\n\nexport const createHullPlanCache = (): HullPlanCache => {\n const shared = new Map<string, SharedHulls>()\n const flights = new Map<string, HullPlanFlight>()\n let planned = 0, reused = 0\n let isDisposed = false\n return {\n get: (key) => shared.get(key),\n set: (key, value) => {\n if (!isDisposed && !shared.has(key)) shared.set(key, value)\n },\n flight: (key) => flights.get(key),\n setFlight: (key, flight) => void (isDisposed || flights.set(key, flight)),\n clearFlight: (key) => void flights.delete(key),\n noteReused: () => void reused++,\n noteDivided: () => void planned++,\n stats: () => ({ models: shared.size, planned, reused }),\n dispose: () => {\n isDisposed = true\n shared.clear()\n flights.clear()\n planned = 0\n reused = 0\n },\n }\n}\n","import { DEFERRED_QUEUE_ID, markKitOrigin } from '@adatechnology/game-contracts'\nimport { BATCHED_LAYER, createStaticBatchQueue, createStaticBatcher } from '@adatechnology/game-render-three'\nimport type { StaticBatchQueue, StaticBatcher } from '@adatechnology/game-render-three'\nimport type { VehicleContext } from '@adatechnology/game-vehicles'\nimport type * as THREE_NS from 'three'\nimport type { Group, Material, Mesh, Object3D, Texture } from 'three'\n\nimport { fuse, liteMaterials, liteMeshes } from './lite'\nimport { primaryPaint } from './build'\n\n/** Past this distance (m) an untouched vehicle draws fused: nobody sees a door seam from here, and the full model costs hundreds of draw calls. */\nexport const VEHICLE_LOD_DISTANCE = 14\n/**\n * The most vertices per batch of a hit vehicle: its batches are made in the frames of the blast, and one batch is merged within one update (the\n * sedan, 320k vertices: its largest material merged in one piece took 16 to 22 ms in one frame; in 16k pieces no update passed ~6 ms, for ~6\n * more draws once it settles: 70 + 37 shadow instead of 67 + 34).\n */\nconst HIT_BATCH_VERTICES = 16384\n/**\n * A vehicle hit in play changes part by part (dents, holes, a door torn off). Its still parts are batched at once and only the parts that change\n * leave the batch. The parts it gave back rejoin a new batch, in their new shape, once nothing has changed on it for this long; a batch that\n * emptied (every part changed: a blast threw the whole body) is made again only after this quiet time too. Before 2026-11-03 a hit vehicle never\n * batched again and drew one call per part for good (~950 draws per frame for the sedan, colour and shadow, after the first blast of the horde\n * chain). Until 2026-11-18 a hit one also waited this long before its first batch: a far (fused) car hit by the house blast drew ~620 calls a\n * frame (428 parts and 194 shadows) for up to 1.5 s, in the worst frames of the blast; now ~10 frames as its batches are merged.\n */\nexport const VEHICLE_REBATCH_AFTER_MS = 1500\n\n/** The one queue of an owner's vehicles (`vehicles.lod-batch`): pass it as `queue` to every `createVehicleLod` and register `queue.deferredQueue()` with the frame budget. */\nexport const createVehicleLodQueue = (): StaticBatchQueue => createStaticBatchQueue({ id: DEFERRED_QUEUE_ID.VEHICLE_LOD_BATCH })\n\nexport type VehicleLodOptions = {\n /** The queue the batches are merged by, within a frame budget (`createVehicleLodQueue`). Not registered with a budget (or not given), each update merges for up to 2 ms, as ever. */\n readonly queue?: StaticBatchQueue\n /** The clock (ms) the quiet time is read from (default `performance.now`). */\n readonly now?: () => number\n}\n\nexport type VehicleLod = {\n /** `touched`: hit or driven, from now on it always draws in full (its damage only exists there); `posed`: a door, hood or lid is open now (fused only while all are shut). */\n update(distance: number, touched: boolean, posed?: boolean): void\n readonly fused: boolean\n dispose(): void\n}\n\n/** What the level of detail reads of the vehicle kit: its three.js, the materials nobody sees from outside and the studio environment. */\nexport type VehicleLodKit = {\n readonly THREE: typeof THREE_NS\n lodHiddenMaterials(): ReadonlySet<Material>\n studioEnvironment(): Texture | null\n}\n\nconst isShown = (object: Object3D, top: Object3D): boolean => {\n for (let node: Object3D | null = object; node && node !== top; node = node.parent) if (node.visible === false) return false\n return true\n}\n\n/** Shows `full` near and the kit's fused light mode (one mesh per class of material) far, in `root`'s own space. Hit tests read the full model, visible or not. */\nexport function createVehicleLod(kit: VehicleLodKit, context: VehicleContext, root: Object3D, full: Object3D, options: VehicleLodOptions = {}): VehicleLod {\n const THREE = kit.THREE\n const now = options.now ?? (() => performance.now())\n const queue = options.queue ?? createVehicleLodQueue()\n // when the vehicle last changed (hit, rebuilt, a batched part given back): a hit one whose batch emptied is batched again only after a quiet time\n let changedAt = Number.NEGATIVE_INFINITY\n // a batch that emptied (every part changed) or a model rebuilt in play: the next batch waits for the quiet time, or it would empty as fast as it is made\n let isRestless = false\n // the full model is drawn whole once, off-camera parts included, before it may hide: its buffers reach the GPU then, not in the frame of a\n // blast. A model rebuilt in place (the destructible's reset) is new geometry, so it is drawn whole again.\n let isUploaded = false\n let modelKey = ''\n const culled = new Map<Mesh, boolean>()\n const keyOf = (): string => full.children.filter((child) => child.name !== 'static-batches').map((child) => child.uuid).join()\n const armUpload = (): void => {\n // a model rebuilt again before its first draw (frames skipped on a slow machine) lets go of the old one's meshes\n for (const [mesh, wasCulled] of culled) mesh.frustumCulled = wasCulled\n culled.clear()\n modelKey = keyOf()\n isUploaded = false\n full.traverse((node) => {\n const object = node as Mesh\n if (!object.isMesh || culled.has(object)) return\n culled.set(object, object.frustumCulled)\n object.frustumCulled = false\n })\n const probe = [...culled.keys()][0]\n if (!probe) {\n isUploaded = true\n return\n }\n const before = probe.onAfterRender\n probe.onAfterRender = function (this: Mesh, ...args: Parameters<Mesh['onAfterRender']>) {\n isUploaded = true\n probe.onAfterRender = before\n before?.apply(this, args)\n }\n }\n armUpload()\n let lite: Group | null = null\n let isFused = false\n let isLocked = false\n // near, the full model draws its still parts in batches by material; a part that moves, dents or falls draws on its own again\n let batcher: StaticBatcher | null = null\n // the parts a hit vehicle gave back, batched again once it is quiet: one more batcher per quiet time, over those parts alone (never the whole\n // vehicle again: dropping its batches to make them anew drew every part on its own, ~590 calls, for the frames of the merge)\n const rejoined: StaticBatcher[] = []\n // parts given back so far, and how many of them were already offered to a batcher of `rejoined`\n let givenBack = 0\n let offered = 0\n let shadow: Mesh | null = null\n const castsShadow = new Set<Mesh>()\n /** One mesh with the shape of the fused body, drawn only into the shadow map. */\n const shadowProxyOf = (fused: Group): Mesh => {\n const positions: number[] = []\n const indices: number[] = []\n for (const child of fused.children) {\n const mesh = child as Mesh\n if (!mesh.isMesh || !mesh.castShadow) continue\n const geometry = mesh.geometry.clone().applyMatrix4(mesh.matrix)\n const offset = positions.length / 3\n const position = geometry.attributes.position\n for (let at = 0; at < position.count; at++) positions.push(position.getX(at), position.getY(at), position.getZ(at))\n const index = geometry.index ? Array.from(geometry.index.array as ArrayLike<number>) : Array.from({ length: position.count }, (_, at) => at)\n for (const vertex of index) indices.push(vertex + offset)\n geometry.dispose()\n }\n const geometry = new THREE.BufferGeometry()\n geometry.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3))\n geometry.setIndex(indices)\n geometry.computeBoundingSphere()\n const proxy = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial({ colorWrite: false, depthWrite: false }))\n proxy.name = 'vehicle-shadow'\n markKitOrigin(proxy, { owner: 'game-vehicles-three', kind: 'vehicle', id: root.name })\n proxy.castShadow = true\n proxy.userData.skipLite = true\n proxy.raycast = () => undefined\n root.add(proxy)\n return proxy\n }\n /** A batcher of the hit vehicle's parts that draw on their own now (`include`): none already in a batch, nor a batch itself. */\n const lockedBatcher = (include?: (mesh: Mesh) => boolean): StaticBatcher => {\n // the parts keep their own shadows (the proxy has the shape of the vehicle before the hit); the batches cast for the still ones\n const made = createStaticBatcher(THREE, full, { queue, budgetMs: 2, maxVertices: HIT_BATCH_VERTICES, ...(include ? { include } : {}) })\n made.group.traverse((object) => (object.userData.skipLite = true))\n // the batches copy the parts' triangles: a hit test reads the parts (`surfaceRay`), never the copy\n made.group.userData.noSurfaceRay = true\n markKitOrigin(made.group, { owner: 'game-vehicles-three', kind: 'vehicle', id: root.name })\n return made\n }\n const batchLocked = (): void => {\n batcher = lockedBatcher()\n }\n const isOnItsOwn = (mesh: Mesh): boolean => mesh.layers.mask !== 1 << BATCHED_LAYER && mesh.parent?.name !== 'static-batches'\n const disposeRejoined = (): void => {\n for (const made of rejoined) made.dispose()\n rejoined.length = 0\n }\n const drawFull = (): void => {\n // a vehicle hit in play: its still parts are batched at once (a hit dents a few parts; the rest would draw one call each, with a shadow\n // each, for the whole quiet time), unless its last batch emptied, which would be given back as fast as it is made\n if (!batcher && isLocked) {\n if (!isRestless || now() - changedAt >= VEHICLE_REBATCH_AFTER_MS) {\n isRestless = false\n batchLocked()\n }\n return\n }\n if (!batcher) {\n lite ??= build()\n lite.visible = isFused\n shadow ??= shadowProxyOf(lite)\n shadow.visible = !isFused\n // the shadow comes from the one proxy, not from each part: a part's own shadow would be one more pass per draw\n full.traverse((node) => {\n const object = node as Mesh\n if (!object.isMesh || !object.castShadow) return\n castsShadow.add(object)\n object.castShadow = false\n })\n // merged a chunk at a time over the next frames, never in one frame\n batcher = createStaticBatcher(THREE, full, { queue, budgetMs: 2 })\n batcher.group.traverse((object) => (object.userData.skipLite = true))\n batcher.group.userData.noSurfaceRay = true\n markKitOrigin(batcher.group, { owner: 'game-vehicles-three', kind: 'vehicle', id: root.name })\n return\n }\n if (!batcher) return\n let changed = batcher.update()\n for (const made of rejoined) changed += made.update()\n givenBack += changed\n if (changed > 0) changedAt = now()\n // every part changed (the model was rebuilt, or all of it dented): batch what stands now (a hit vehicle, once it is quiet again)\n const { batched, released } = batcher.stats()\n const rejoinedBatched = rejoined.reduce((sum, made) => sum + made.stats().batched, 0)\n if (batched === 0 && released > 0 && rejoinedBatched === 0) {\n batcher.dispose()\n batcher = null\n disposeRejoined()\n givenBack = offered = 0\n isRestless = true\n } else if (isLocked && givenBack - offered >= 2 && now() - changedAt >= VEHICLE_REBATCH_AFTER_MS) {\n // the parts the hit dented or moved settled: batched again, in their new shape (left out, they drew one call each for good)\n offered = givenBack\n rejoined.push(lockedBatcher(isOnItsOwn))\n }\n }\n const build = (): Group => {\n root.updateMatrixWorld(true)\n const inverse = new THREE.Matrix4().copy(root.matrixWorld).invert()\n // a painted texture (a livery, a lettering) does not survive the fusion into vertex colours: those meshes stay as they are, drawn from the same geometry\n const textured: Mesh[] = []\n full.traverse((node) => {\n const object = node as Mesh\n if (!object.isMesh || object.userData.skipLite || !isShown(object, full)) return\n const materials = Array.isArray(object.material) ? object.material : [object.material]\n if (materials.some((material) => (material as Material & { map?: Texture | null })?.map && !/plate/i.test(material.name ?? '')) && !/plate/i.test(object.name ?? '')) textured.push(object)\n })\n for (const mesh of textured) mesh.userData.skipLite = true\n const fusion = fuse(THREE, { ...context, vehicle: full }, inverse, null, primaryPaint(context), kit.lodHiddenMaterials())\n for (const mesh of textured) delete mesh.userData.skipLite\n const group = new THREE.Group()\n group.name = 'vehicle-lite'\n markKitOrigin(group, { owner: 'game-vehicles-three', kind: 'vehicle', id: root.name })\n for (const mesh of liteMeshes(THREE, fusion, liteMaterials(THREE, kit.studioEnvironment()))) group.add(mesh)\n for (const mesh of textured) {\n const copy = new THREE.Mesh(mesh.geometry, mesh.material)\n copy.matrixAutoUpdate = false\n copy.matrix.multiplyMatrices(inverse, mesh.matrixWorld)\n copy.castShadow = mesh.castShadow\n copy.receiveShadow = mesh.receiveShadow\n group.add(copy)\n }\n root.add(group)\n return group\n }\n const show = (shouldFuse: boolean): void => {\n if (shouldFuse === isFused) return\n isFused = shouldFuse\n full.visible = !shouldFuse\n if (lite) lite.visible = shouldFuse\n if (shadow) shadow.visible = !shouldFuse\n }\n const api: VehicleLod = {\n update(distance, touched, posed = false) {\n if (touched && !isLocked) changedAt = now()\n isLocked ||= touched\n if (keyOf() !== modelKey) {\n changedAt = now()\n isRestless = true\n // the fused copy and the batches were made from the old model\n api.dispose()\n armUpload()\n }\n if (!isUploaded) return show(false)\n if (culled.size > 0) {\n for (const [mesh, wasCulled] of culled) mesh.frustumCulled = wasCulled\n culled.clear()\n }\n const shouldFuse = !isLocked && !posed && distance > (isFused ? VEHICLE_LOD_DISTANCE * 0.9 : VEHICLE_LOD_DISTANCE)\n if (shouldFuse && !lite) lite = build()\n show(shouldFuse)\n if (!shouldFuse) drawFull()\n },\n get fused() {\n return isFused\n },\n dispose() {\n show(false)\n batcher?.dispose()\n batcher = null\n disposeRejoined()\n givenBack = offered = 0\n for (const mesh of castsShadow) mesh.castShadow = true\n castsShadow.clear()\n shadow?.removeFromParent()\n shadow?.geometry.dispose()\n shadow = null\n if (!lite) return\n lite.removeFromParent()\n lite.traverse((object) => (object as Mesh).geometry?.dispose())\n lite = null\n },\n }\n return api\n}\n","import type { EffectSink, Enclosure } from '@adatechnology/game-contracts'\nimport { cabinEnclosure } from '@adatechnology/game-vehicles'\nimport type { CabinSource } from '@adatechnology/game-vehicles'\n\n/** One vehicle whose cabin holds out the host's smoke: its destructible and the object the host placed it in. */\ninterface Tracked {\n readonly source: CabinSource\n readonly frame: { readonly parent: unknown | null }\n declared: boolean\n /** It has been in the scene: leaving it now means it was taken away. */\n placed: boolean\n}\n\n/**\n * Keeps the host's effects told where the cabins of the vehicles are and how open they are (`EffectSink.enclose`), so the smoke, dust and steam\n * do not pass through a shut car: they go round it and get in only through an open door, a broken window or a bullet hole. `sync` every frame;\n * a vehicle whose object left the scene is forgotten and its cabin ended.\n */\nexport interface CabinSmoke {\n /** Follows the cabin of a vehicle by its object id; `frame` is the object the host placed it in (the destructible's `frame`). */\n track(id: string, source: CabinSource, frame: { readonly parent: unknown | null }): void\n /** Ends the cabin of one vehicle now. */\n untrack(id: string, effects: EffectSink | undefined): void\n /** Tells `effects` where every cabin is now. A host without `enclose` lets the smoke through, as before. */\n sync(effects: EffectSink | undefined): void\n /** Ends every cabin (the module leaves). */\n clear(effects: EffectSink | undefined): void\n /** The ids followed now. */\n ids(): string[]\n}\n\nexport function createCabinSmoke(): CabinSmoke {\n const tracked = new Map<string, Tracked>()\n const end = (id: string, entry: Tracked, effects: EffectSink | undefined): void => {\n if (entry.declared) effects?.enclose?.(id, null)\n tracked.delete(id)\n }\n return {\n track(id, source, frame) {\n tracked.set(id, { source, frame, declared: false, placed: false })\n },\n untrack(id, effects) {\n const entry = tracked.get(id)\n if (entry) end(id, entry, effects)\n },\n sync(effects) {\n if (!effects?.enclose) return\n for (const [id, entry] of tracked) {\n if (!entry.frame.parent) {\n // not placed yet (built, not added): wait; taken out of the scene: forget it\n if (entry.placed) end(id, entry, effects)\n continue\n }\n entry.placed = true\n const enclosure: Enclosure | null = cabinEnclosure(entry.source, { frame: entry.frame })\n if (enclosure || entry.declared) effects.enclose(id, enclosure)\n entry.declared = enclosure !== null\n }\n },\n clear(effects) {\n for (const [id, entry] of [...tracked]) end(id, entry, effects)\n },\n ids: () => [...tracked.keys()],\n }\n}\n","import type { RainCover } from '@adatechnology/game-contracts'\nimport { createVehicleRainCover } from '@adatechnology/game-vehicles'\nimport type { CabinSource, VehicleRainCover } from '@adatechnology/game-vehicles'\n\n/** How often a vehicle's damage state is read for the roof and the panes it has left, seconds: a hit shows within this; moving costs nothing of it. */\nexport const RAIN_SHELL_INTERVAL = 0.4\n\ntype Tracked = {\n readonly rain: VehicleRainCover\n readonly frame: { readonly parent: unknown | null }\n /** Takes the cover out of the host's rain; present while the vehicle is in the scene. */\n remove: (() => void) | undefined\n untilShell: number\n}\n\n/**\n * Keeps the host's rain told what the cars roof over (`ModuleHost.rainCover`): the cabin of each vehicle in the scene is a cover that follows it, and a broken\n * roof or windshield opens it. `sync` every frame; a vehicle that left the scene is taken out. A host without a rain cover keeps the old rain.\n */\nexport interface VehicleRainCovers {\n /** Follows the cabin of a vehicle by its object id; `frame` is the object the host placed it in (the destructible's `frame`). */\n track(id: string, source: CabinSource, frame: { readonly parent: unknown | null }): void\n untrack(id: string): void\n sync(cover: RainCover | undefined, dt: number): void\n /** Takes every cover out (the module leaves). */\n clear(): void\n /** The ids followed now. */\n ids(): string[]\n}\n\nexport function createVehicleRainCovers(): VehicleRainCovers {\n const tracked = new Map<string, Tracked>()\n let counter = 0\n const end = (id: string): void => {\n tracked.get(id)?.remove?.()\n tracked.delete(id)\n }\n return {\n track(id, source, frame) {\n tracked.set(id, { rain: createVehicleRainCover(source, { frame }), frame, remove: undefined, untilShell: (counter++ % 8) * (RAIN_SHELL_INTERVAL / 8) })\n },\n untrack: end,\n sync(cover, dt) {\n if (!cover) return\n for (const [id, entry] of tracked) {\n if (!entry.frame.parent) {\n // not placed yet (built, not added): wait; taken out of the scene: forget it\n if (entry.remove) end(id)\n continue\n }\n if (!entry.remove) {\n entry.remove = cover.add(entry.rain.source)\n entry.rain.refreshShell()\n }\n entry.untilShell -= dt\n if (entry.untilShell <= 0) {\n entry.untilShell = RAIN_SHELL_INTERVAL\n entry.rain.refreshShell()\n }\n entry.rain.place()\n }\n },\n clear() {\n for (const id of [...tracked.keys()]) end(id)\n },\n ids: () => [...tracked.keys()],\n }\n}\n","import { crashVehicle, createVehicleDestructible } from '@adatechnology/game-vehicles'\nimport type { VehicleContext, VehicleKit } from '@adatechnology/game-vehicles'\nimport { conditionFromDamage } from '@adatechnology/game-vehicles-driving'\nimport type { SemiDriver } from '@adatechnology/game-vehicles-driving'\nimport type { DestructionEvent, Vec3 } from '@adatechnology/game-contracts'\n\n/** What the drive lane's car starts with: whole, driven into the wall without braking (its front crumples), a tyre burst by a rifle round, that tyre already torn off, the same burst on an armoured car (run-flat), the brake fluid drained. */\nexport const LANE_DAMAGE = ['none', 'into_wall', 'flat_tyre', 'torn_tyre', 'run_flat', 'no_brake_fluid'] as const\nexport type LaneDamage = (typeof LANE_DAMAGE)[number]\n\nconst RIFLE = { energy: 3500, caliber: 7.8, penetration: { steel: 18 } }\n/** Far enough on a flat tyre to tear it off. */\nconst TEAR_OFF_M = 5000\n/** The lane car's mass, kg; how wide its front meets the wall, metres; how far ahead of the bumper's centre the wall is touched. */\nconst LANE_CAR_KG = 1150\nconst LANE_WALL_CONTACT = 1.6\nconst WALL_REACH = 0.15\n/** Seconds the drained brake lines are left to empty. */\nconst DRAIN_S = 600\n\nexport type LaneDamageModel = {\n /** Drives the damage `dt` seconds at `speed` m/s and `throttle`, and gives the driver the condition it leaves. Answers where rims grind on the road. */\n step(params: { readonly dt: number; readonly speed: number; readonly throttle: number; readonly driver: SemiDriver }): Vec3[]\n /** The car ran into the lane's wall at `speed` m/s, moving along `direction`: its front takes the crash. */\n crash(params: { readonly speed: number; readonly direction: Vec3 }): DestructionEvent[]\n /** Lets the damage play out `dt` seconds with the car standing (after the run). */\n settle(dt: number): void\n}\n\nexport type CreateLaneDamageParams = {\n readonly kit: VehicleKit\n /** The lane car drawn in full (the lite build has no parts to show the damage on), and the group that carries it. */\n readonly context: VehicleContext\n readonly frame: unknown\n readonly damage: Exclude<LaneDamage, 'none'>\n}\n\n/** The lane car's damage model, drawn on the car (the tyre sags or is gone), only while the lane has a damage set. */\nexport function createLaneDamage(params: CreateLaneDamageParams): LaneDamageModel {\n const d = createVehicleDestructible(params.kit, params.context, { id: 'lane', frame: params.frame, armour: params.damage === 'run_flat' ? 'IIIA' : null })\n const part = (prefix: string): string | undefined => (d.describe().parts as Array<{ id: string }>).find((p) => p.id.startsWith(prefix))?.id\n const shoot = (id: string | undefined): void => {\n if (id) d.hit({ type: 'ballistic', point: d.partWorldCenter(id), part: id, direction: [0, 0, 1], ...RIFLE })\n }\n if (params.damage === 'into_wall') {\n // nothing broken before the run\n } else if (params.damage === 'no_brake_fluid') {\n shoot(part('brakes'))\n for (let t = 0; t < DRAIN_S; t++) d.update?.(1)\n } else {\n shoot(part('tyre_front_left'))\n if (params.damage === 'torn_tyre') d.rollFlat(TEAR_OFF_M, 8)\n }\n return {\n step({ dt, speed, throttle, driver }) {\n d.rollFlat(speed * dt, speed)\n d.runEngine(dt, throttle)\n const events = d.update?.(dt) ?? []\n driver.condition = conditionFromDamage(driver.spec, d.driveReport())\n return events.flatMap((e) => (e.type === 'debris' && e.kind === 'sparks' ? [e.point] : []))\n },\n settle(dt) {\n d.update?.(dt)\n },\n crash({ speed, direction }) {\n const front = part('bumper_front')\n if (!front) return []\n const at = d.partWorldCenter(front)\n return crashVehicle(d, { point: [at[0] + direction[0] * WALL_REACH, at[1], at[2] + direction[2] * WALL_REACH], direction, speed, massKg: LANE_CAR_KG, otherMassKg: Infinity, contactWidth: LANE_WALL_CONTACT }).events\n },\n }\n}\n","import type * as THREE_NS from 'three'\nimport type { DrawnCollider, ModuleHost, WorkerCoordinator } from '@adatechnology/game-contracts'\nimport { isPhysicsServices } from '@adatechnology/game-physics'\nimport type { BodyId, PhysicsServices, Quat, ShapeDesc, Vec3 } from '@adatechnology/game-physics'\nimport type { VehicleDestructible } from '@adatechnology/game-vehicles'\n\nimport { createVehicleColliders } from '../colliders'\nimport type { VehicleColliders } from '../colliders'\nimport { createCrashParts } from '../crash-parts'\nimport type { CrashParts } from '../crash-parts'\nimport { bodyMassOf } from '../crash-parts-math'\nimport type { HullPlanCache } from '../hull-plan-cache'\nimport type { RunOverLink } from './run-over-link'\n\ntype Three = typeof THREE_NS\n\n/** The ceiling of a model the fleet content gives none for: the largest of design 10.3 (K7). */\nconst DEFAULT_HULL_CEILING = 550\n\nexport interface PhysicalCarOptions {\n readonly THREE: Three\n readonly services: PhysicsServices\n readonly vehicle: VehicleDestructible\n /** The vehicle's root: the frame of the hulls and of the drawing, its pose the chassis body's. */\n readonly root: THREE_NS.Object3D\n /** Made with `physicalCarColliders`. */\n readonly colliders: VehicleColliders\n /** The crowd the car runs over, when the host has one. */\n readonly runOver?: RunOverLink\n}\n\nexport interface PhysicalCar {\n /** What the engine's fixed world collides with in place of the drawing: nothing, the chassis body holds it. */\n colliders(): DrawnCollider[]\n /** The chassis is in the world (the pieces are all made and the hull plan is back). */\n isBuilt(): boolean\n chassis(): BodyId | undefined\n parts(): CrashParts | undefined\n /** Takes the chassis and the bodies of the parts out of the world and stops following the loop. */\n dispose(): void\n}\n\nconst HALF_TURN: number = Math.SQRT1_2\n\n/** One child of the chassis compound for a drawn tyre: a cylinder as long and as wide as the box of what is drawn, its axis on the box's shortest side. */\nconst wheelChildOf = (size: Vec3, center: Vec3): { readonly shape: ShapeDesc; readonly position: Vec3; readonly rotation?: Quat } => {\n const axis = size[0] <= size[1] && size[0] <= size[2] ? 0 : size[2] <= size[1] ? 2 : 1\n const radius = Math.max(...size.filter((_, side) => side !== axis)) / 2\n const shape: ShapeDesc = { kind: 'cylinder', halfHeight: size[axis]! / 2, radius }\n if (axis === 1) return { shape, position: center }\n return { shape, position: center, rotation: axis === 0 ? [0, 0, HALF_TURN, HALF_TURN] : [HALF_TURN, 0, 0, HALF_TURN] }\n}\n\n/** The box the run-over sweeps for the car: the parts' reach to each side and the height of the top (the box is centred on the chassis origin, at the ground, so it spans the car's height above it). */\nconst runOverHalfOf = (parts: readonly { readonly box: { readonly center: Vec3; readonly size: Vec3 } }[]): Vec3 => {\n const half: [number, number, number] = [0, 0, 0]\n for (const { box } of parts) {\n half[0] = Math.max(half[0], Math.abs(box.center[0]) + box.size[0] / 2)\n half[1] = Math.max(half[1], box.center[1] + box.size[1] / 2)\n half[2] = Math.max(half[2], Math.abs(box.center[2]) + box.size[2] / 2)\n }\n return half\n}\n\n/** The services the host lent, when it runs the pieces on a loop (the engine path); undefined on the kit's own solver. */\nexport const physicsServicesOf = (host: ModuleHost | null): PhysicsServices | undefined => (host && isPhysicsServices(host.physics) ? host.physics : undefined)\n\n/** How the car's colliders are made for the engine: hulls (method B), the plan in the host's workers when it has them, shared by the cars of a model. */\nexport const physicalCarColliders = (THREE: Three, vehicle: VehicleDestructible, root: THREE_NS.Object3D, options: { readonly budget: number; readonly fleetKey: string; readonly hullCeilingOf?: ((id: string) => number | undefined) | undefined; readonly planCache: HullPlanCache; readonly workers: WorkerCoordinator | undefined }): VehicleColliders =>\n createVehicleColliders(THREE, vehicle, root, {\n budget: options.budget,\n hulls: true,\n maxHulls: options.hullCeilingOf?.(options.fleetKey) ?? DEFAULT_HULL_CEILING,\n planCache: options.planCache,\n ...(options.workers ? { workers: options.workers } : {}),\n })\n\n/** The car as a dynamic body of the loop's world: made once its root is in the scene and its hulls are ready, followed by its drawing and fed its damage after every frame of the loop. */\nexport const createPhysicalCar = ({ THREE, services, vehicle, root, colliders, runOver }: PhysicalCarOptions): PhysicalCar => {\n const { world } = services\n const pose = new Float64Array(7)\n const matrix = new THREE.Matrix4()\n const parentInverse = new THREE.Matrix4()\n const position = new THREE.Vector3()\n const rotation = new THREE.Quaternion()\n const unusedScale = new THREE.Vector3()\n const wheelHandles = new Map<string, number>()\n let crash: CrashParts | undefined\n let chassis: BodyId | undefined\n let stopRunOver: (() => void) | undefined\n\n // the tyres are drawn but have no hull: a child each, after the hulls (their handles are the hulls' own numbers), so the car rests at the height it is drawn\n const withWheels = (hulls: ShapeDesc): ShapeDesc => {\n if (hulls.kind !== 'compound') return hulls\n const tyres = vehicle.model.parts.filter((part) => part.role === 'tyre')\n tyres.forEach((part, index) => wheelHandles.set(part.id, hulls.children.length + index))\n const inverse = new THREE.Matrix4().copy(root.matrixWorld).invert()\n const drawn = new THREE.Box3()\n const piece = new THREE.Box3()\n const centre = new THREE.Vector3()\n const size = new THREE.Vector3()\n const children = tyres.map((part) => {\n drawn.makeEmpty()\n for (const object of vehicle.objectsOf(part.id)) drawn.union(piece.setFromObject(object).applyMatrix4(inverse))\n if (drawn.isEmpty()) return wheelChildOf(part.box.size, part.box.center)\n return wheelChildOf(drawn.getSize(size).toArray() as Vec3, drawn.getCenter(centre).toArray() as Vec3)\n })\n return { ...hulls, children: [...hulls.children, ...children] }\n }\n\n const build = (): void => {\n if (!root.parent) return\n colliders.pieces()\n if (colliders.isPending()) return\n colliders.hulls()\n if (colliders.isHullPending()) return\n root.updateWorldMatrix(true, false)\n root.matrixWorld.decompose(position, rotation, unusedScale)\n const mass = bodyMassOf(vehicle.model.parts)\n crash = createCrashParts({\n THREE, world, vehicle, frame: root, colliders, mass,\n onPartLost: (part) => {\n const handle = wheelHandles.get(part.id)\n if (handle !== undefined && chassis !== undefined) world.setChildShape(chassis, handle, null)\n },\n })\n chassis = world.createBody({\n shape: withWheels(crash.shape()), motion: 'dynamic', mass: mass.mass, inertia: mass.inertia, layer: 'vehicle', user: 0,\n position: [position.x, position.y, position.z], rotation: [rotation.x, rotation.y, rotation.z, rotation.w],\n })\n crash.bind(chassis)\n stopRunOver = runOver?.track({ body: chassis, half: runOverHalfOf(vehicle.model.parts) })\n }\n\n const follow = (): void => {\n world.readPose(chassis!, pose, 0)\n matrix.compose(position.set(pose[0]!, pose[1]!, pose[2]!), rotation.set(pose[3]!, pose[4]!, pose[5]!, pose[6]!), unusedScale.set(1, 1, 1))\n root.parent!.updateWorldMatrix(true, false)\n matrix.premultiply(parentInverse.copy(root.parent!.matrixWorld).invert())\n matrix.decompose(root.position, root.quaternion, unusedScale)\n root.updateMatrixWorld(true)\n crash!.step()\n }\n\n const stopPhase = services.loop.add({\n afterSteps: (_dt, frame) => {\n if (!chassis) return build()\n if (frame.steps > 0 && root.parent) follow()\n },\n }, 'contacts')\n\n return {\n colliders: () => [],\n isBuilt: () => chassis !== undefined,\n chassis: () => chassis,\n parts: () => crash,\n dispose: () => {\n stopPhase()\n stopRunOver?.()\n stopRunOver = undefined\n crash?.dispose()\n if (chassis !== undefined && world.has(chassis)) world.removeBody(chassis)\n crash = undefined\n chassis = undefined\n },\n }\n}\n","import type * as THREE_NS from 'three'\nimport type { BodyId, SeamWorld, ShapeDesc, Vec3 } from '@adatechnology/game-physics'\nimport { CONTACT_READ_STRIDE } from '@adatechnology/game-physics'\nimport { crashVehicle } from '@adatechnology/game-vehicles'\nimport type { PartDef, VehicleDestructible } from '@adatechnology/game-vehicles'\n\nimport type { VehicleColliders } from './colliders'\nimport { createChassisHulls } from './crash-parts-chassis'\nimport type { ChassisSettle } from './crash-parts-chassis'\nimport { createPartBodies } from './crash-parts-bodies'\nimport type { PartBody } from './crash-parts-bodies'\nimport { boxInertia, withoutPart } from './crash-parts-math'\nimport type { BodyMass } from './crash-parts-math'\n\ntype Three = typeof THREE_NS\n\n/** Contact points of the car's body read each step. */\nconst CONTACT_POINTS = 64\n/** Steps the car must be still before its hulls are made again (at 120 Hz, a quarter of a second), and how still (m/s, rad/s). */\nconst SETTLE_STEPS = 30\nconst SETTLED_SPEED = 0.05\n/** A contact point this near (m) the box round a hull is the part touching. */\nconst TOUCH_MARGIN = 0.05\n\nexport interface CrashPartsOptions {\n readonly THREE: Three\n readonly world: SeamWorld\n readonly vehicle: VehicleDestructible\n /** The frame the hulls and the drawn meshes are in (`createVehicleColliders`' frame); its pose is the body's. */\n readonly frame: THREE_NS.Object3D\n /** Made with `hulls: true`, and its plan back (`isHullPending()` false). */\n readonly colliders: VehicleColliders\n /** The kit's numbers for the whole car, in the frame: its mass, centre of mass and moments. */\n readonly mass: BodyMass\n /** A part left the car (the host remakes what depends on it: a wheel, the vehicle's constraint). */\n readonly onPartLost?: (part: PartDef) => void\n}\n\nexport interface CrashParts {\n /** The chassis compound: make the body from it (dynamic, `mass.mass`, `mass.inertia`, `centreAtOrigin` off) and `bind` it. */\n shape(): ShapeDesc\n bind(chassis: BodyId): void\n /** Once after each step: the contact rows become damage, the parts' drawings follow their bodies, and a car at rest has its hulls made again. */\n step(): void\n /** What the car weighs now. */\n mass(): BodyMass\n partBodies(): ReadonlyMap<string, BodyId>\n /** The kit's numbers each part that came off took with it (its mass, its centre in the frame, its moments). */\n partNumbers(): ReadonlyMap<string, BodyMass>\n stats(): {\n readonly released: number\n readonly pushedOut: number\n /** Times the hulls were looked at again, how many were given to the engine again, held back by the touching rule, and left without a child to go in. */\n readonly settles: number\n readonly remade: number\n readonly held: number\n readonly unplaced: number\n /** Blows the contact rows made (`crashVehicle` calls), the damage events they gave, and the parts whose hull was in those rows. */\n readonly blows: number\n readonly events: number\n readonly hitParts: ReadonlySet<string>\n /** Children left in the chassis compound. */\n readonly children: number\n }\n /** Takes the part bodies out of the world and gives the fling back to the vehicle. The chassis body is the host's. */\n dispose(): void\n}\n\nexport const createCrashParts = (options: CrashPartsOptions): CrashParts => {\n const { THREE, world, vehicle, frame, colliders } = options\n const parts = vehicle.model.parts\n const partIndexOf = new Map(parts.map((part, index) => [part.id, index]))\n const chassisHulls = createChassisHulls(colliders, partIndexOf)\n const bodies = createPartBodies(THREE, world, frame)\n const pose = new Float64Array(7)\n const speed = new Float64Array(6)\n const touches = new Float32Array(CONTACT_READ_STRIDE * CONTACT_POINTS)\n const strongest = new Map<number, number>()\n let chassis: BodyId | undefined\n let current = options.mass\n let calm = 0\n let cooldown = 0\n let isDirty = false\n let released = 0\n let settles = 0\n let held = 0\n let remade = 0\n let unplaced = 0\n let blows = 0\n let events = 0\n const hitParts = new Set<string>()\n\n const numbers = new Map<string, BodyMass>()\n const carried = (partIndex: number): PartBody | undefined => bodies.bodies.get(partIndex)\n\n const takePart = (part: PartDef, partIndex: number, holder: THREE_NS.Object3D): void => {\n const body = carried(partIndex)\n const extent = bodies.extentOf(holder)\n if (body) return bodies.follow(body, holder, extent)\n const hulls = chassisHulls.release(world, chassis!, part.id)\n const solid = hulls.length > 0 ? hulls : [boxPoints(extent.size, extent.centre)]\n bodies.create({ partIndex, mass: part.mass, hulls: solid, extent, holder, chassis: chassis!, chassisMass: current })\n const own: BodyMass = { mass: part.mass, centre: extent.centre, inertia: boxInertia(part.mass, extent.size) }\n numbers.set(part.id, own)\n current = withoutPart(current, own)\n world.setMassProperties(chassis!, { mass: current.mass, inertia: current.inertia, centreOfMass: current.centre })\n released++\n options.onPartLost?.(part)\n }\n\n const isTouching = (points: Float32Array): boolean => {\n if (!chassis) return false\n const count = world.readContacts(chassis, touches)\n if (count === 0) return false\n world.readPose(chassis, pose, 0)\n let lowX = Infinity, lowY = Infinity, lowZ = Infinity\n let highX = -Infinity, highY = -Infinity, highZ = -Infinity\n for (let i = 0; i < points.length; i += 3) {\n const x = points[i]!, y = points[i + 1]!, z = points[i + 2]!\n if (x < lowX) lowX = x\n if (x > highX) highX = x\n if (y < lowY) lowY = y\n if (y > highY) highY = y\n if (z < lowZ) lowZ = z\n if (z > highZ) highZ = z\n }\n // the contact in the chassis frame: the pose's rotation conjugated, applied to the offset\n const qx = -pose[3]!, qy = -pose[4]!, qz = -pose[5]!, qw = pose[6]!\n for (let c = 0; c < count; c++) {\n const at = c * CONTACT_READ_STRIDE\n const vx = touches[at]! - pose[0]!, vy = touches[at + 1]! - pose[1]!, vz = touches[at + 2]! - pose[2]!\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 const x = vx + qw * tx + qy * tz - qz * ty\n const y = vy + qw * ty + qz * tx - qx * tz\n const z = vz + qw * tz + qx * ty - qy * tx\n if (x >= lowX - TOUCH_MARGIN && x <= highX + TOUCH_MARGIN && y >= lowY - TOUCH_MARGIN && y <= highY + TOUCH_MARGIN && z >= lowZ - TOUCH_MARGIN && z <= highZ + TOUCH_MARGIN) return true\n }\n return false\n }\n\n const feedDamage = (): void => {\n const rows = world.contacts\n strongest.clear()\n for (let i = 0; i < rows.count; i++) {\n const mine = rows.a[i] === chassis ? 0 : rows.b[i] === chassis ? 1 : -1\n if (mine < 0) continue\n const tag = mine === 0 ? rows.tagA[i]! : rows.tagB[i]!\n if (tag < 0 || tag >= parts.length) continue\n const at = strongest.get(tag)\n if (at === undefined || rows.approach[i]! > rows.approach[at]!) strongest.set(tag, i)\n }\n for (const [tag, i] of strongest) {\n const mine = rows.a[i] === chassis\n const other = mine ? rows.b[i]! : rows.a[i]!\n const otherMass = world.has(other as BodyId) ? world.massOf(other as BodyId) : 0\n const sign = mine ? 1 : -1\n const part = parts[tag]!\n const result = crashVehicle(vehicle, {\n point: [rows.point[i * 3]!, rows.point[i * 3 + 1]!, rows.point[i * 3 + 2]!],\n direction: [sign * rows.normal[i * 3]!, sign * rows.normal[i * 3 + 1]!, sign * rows.normal[i * 3 + 2]!],\n speed: rows.approach[i]!, massKg: current.mass, otherMassKg: otherMass > 0 ? otherMass : Infinity, contactWidth: Math.max(0.2, part.box.size[2]), source: part.id,\n })\n blows++\n events += result.events.length\n hitParts.add(part.id)\n if (result.events.length > 0) {\n isDirty = true\n cooldown = 0\n }\n }\n }\n\n const settle = (): void => {\n world.readVelocity(chassis!, speed, 0)\n const still = Math.hypot(speed[0]!, speed[1]!, speed[2]!) < SETTLED_SPEED && Math.hypot(speed[3]!, speed[4]!, speed[5]!) < SETTLED_SPEED\n calm = still ? calm + 1 : 0\n if (calm < SETTLE_STEPS || !(isDirty || chassisHulls.hasWork())) return\n if (cooldown > 0) {\n cooldown--\n return\n }\n const done: ChassisSettle = chassisHulls.settle(world, chassis!, isTouching)\n settles++\n held += done.held\n remade += done.remade\n unplaced += done.unplaced\n isDirty = done.held > 0 || colliders.isHullPending()\n cooldown = done.held > 0 && !colliders.isHullPending() ? SETTLE_STEPS : 0\n }\n\n vehicle.setPartSink((part, holder) => {\n const partIndex = partIndexOf.get(part.id)\n if (chassis === undefined || partIndex === undefined) return false\n takePart(part, partIndex, holder)\n return true\n })\n\n return {\n shape: () => chassisHulls.shape(),\n bind: (body) => {\n chassis = body\n world.watchContacts(body, true)\n world.setMassProperties(body, { mass: current.mass, inertia: current.inertia, centreOfMass: current.centre })\n },\n step: () => {\n if (chassis === undefined) return\n feedDamage()\n bodies.step(chassis)\n settle()\n },\n mass: () => current,\n partNumbers: () => numbers,\n partBodies: () => new Map([...bodies.bodies].map(([index, body]) => [parts[index]!.id, body.id])),\n stats: () => ({ released, pushedOut: bodies.pushedOut(), settles, remade, held, unplaced, blows, events, hitParts, children: chassisHulls.count() }),\n dispose: () => {\n vehicle.setPartSink(null)\n bodies.dispose()\n if (chassis !== undefined && world.has(chassis)) world.watchContacts(chassis, false)\n },\n }\n}\n\nconst boxPoints = (size: Vec3, centre: Vec3): Float32Array => {\n const out = new Float32Array(24)\n for (let k = 0; k < 8; k++) {\n out[k * 3] = centre[0] + (k & 1 ? size[0] : -size[0]) / 2\n out[k * 3 + 1] = centre[1] + (k & 2 ? size[1] : -size[1]) / 2\n out[k * 3 + 2] = centre[2] + (k & 4 ? size[2] : -size[2]) / 2\n }\n return out\n}\n\nexport type { BodyMass } from './crash-parts-math'\n","import { convexFaces } from '@adatechnology/game-vehicles'\n\n/** Passes over the faces of the old hull: each pass brings a point past a face back to it, and the next may undo a little of that at a corner. */\nconst PASSES = 8\n\n/**\n * The points of a rebuilt hull held to the old one while the part is touching something (design 10.5): a point may move in as far as it likes and out at most `slop` past\n * a face of the old hull, so the rebuilt hull does not push what rests on it (energy made). The points past that are brought back along the face they are past; what\n * is left of the move waits for the contact to end. Returns `next` itself when nothing was past the old hull, and the old points when the old hull is not a solid.\n */\nexport const holdWithin = (old: ArrayLike<number>, next: Float32Array, slop: number): Float32Array => {\n const faces = convexFaces(old)\n if (!faces) return next\n const middle = [0, 1, 2].map((k) => {\n let sum = 0\n for (let i = k; i < old.length; i += 3) sum += old[i]!\n return sum / (old.length / 3)\n })\n const planes = faces.map(([a, b, c]) => {\n const ux = old[b * 3]! - old[a * 3]!, uy = old[b * 3 + 1]! - old[a * 3 + 1]!, uz = old[b * 3 + 2]! - old[a * 3 + 2]!\n const wx = old[c * 3]! - old[a * 3]!, wy = old[c * 3 + 1]! - old[a * 3 + 1]!, wz = old[c * 3 + 2]! - old[a * 3 + 2]!\n const nx = uy * wz - uz * wy, ny = uz * wx - ux * wz, nz = ux * wy - uy * wx\n const length = Math.hypot(nx, ny, nz) || 1\n const towardMiddle = nx * (middle[0]! - old[a * 3]!) + ny * (middle[1]! - old[a * 3 + 1]!) + nz * (middle[2]! - old[a * 3 + 2]!)\n const sign = (towardMiddle > 0 ? -1 : 1) / length\n const normal = [nx * sign, ny * sign, nz * sign] as const\n return { normal, offset: normal[0] * old[a * 3]! + normal[1] * old[a * 3 + 1]! + normal[2] * old[a * 3 + 2]! + slop }\n })\n let out: Float32Array | undefined\n for (let i = 0; i < next.length; i += 3) {\n const p = [next[i]!, next[i + 1]!, next[i + 2]!]\n let moved = false\n for (let pass = 0; pass < PASSES; pass++) {\n let clean = true\n for (const { normal, offset } of planes) {\n const past = normal[0] * p[0]! + normal[1] * p[1]! + normal[2] * p[2]! - offset\n if (past <= 0) continue\n p[0] = p[0]! - normal[0] * past\n p[1] = p[1]! - normal[1] * past\n p[2] = p[2]! - normal[2] * past\n moved = true\n clean = false\n }\n if (clean) break\n }\n if (!moved) continue\n out ??= Float32Array.from(next)\n out[i] = p[0]!\n out[i + 1] = p[1]!\n out[i + 2] = p[2]!\n }\n return out ?? next\n}\n","import type { BodyId, SeamWorld, ShapeDesc } from '@adatechnology/game-physics'\n\nimport { holdWithin } from './crash-parts-clamp'\nimport type { VehicleColliders, VehicleHull } from './colliders'\n\n/** How far (m) a hull of a part that is touching something may go out past the hull it had (`KIT_WORLD.penetrationSlop`: what a resting body sinks anyway). */\nexport const HULL_SLOP = 0.002\n\n/** One child of the chassis compound: the hull it holds now, and the one the drawing wants when the two are not the same yet (held back while the part touches something). */\ninterface Child {\n readonly handle: number\n readonly key: string\n readonly partId: string\n readonly partIndex: number\n applied: Float32Array\n wanted: VehicleHull\n isHeld: boolean\n}\n\nexport interface ChassisSettle {\n /** Hulls the engine was given again. */\n readonly remade: number\n /** Hulls that were left out or held back this time. */\n readonly held: number\n /** Hulls the drawing has that the compound has no child for (a compound cannot gain a child). */\n readonly unplaced: number\n}\n\nexport interface ChassisHulls {\n /** The compound of the car's hulls, each child tagged with its part's number. */\n shape(): ShapeDesc\n /** Takes the part's children out of the compound; the points they held (frame), for the body the part becomes. */\n release(world: SeamWorld, chassis: BodyId, partId: string): Float32Array[]\n /** The hulls the drawing has now, in the compound: those that changed are given to the engine, held to the old ones where `isTouching` says the part touches something. */\n settle(world: SeamWorld, chassis: BodyId, isTouching: (points: Float32Array) => boolean): ChassisSettle\n /** Children still in the compound. */\n count(): number\n /** Whether some hull is held back, or the drawing's division is not back yet: the next settle has work. */\n hasWork(): boolean\n}\n\nconst convexOf = (points: Float32Array): ShapeDesc => ({ kind: 'convex', points })\n\nexport const createChassisHulls = (colliders: VehicleColliders, partIndexOf: ReadonlyMap<string, number>): ChassisHulls => {\n let children: Child[] = []\n\n const shape = (): ShapeDesc => {\n const hulls = colliders.hulls()\n if (hulls.length === 0) throw new Error('crash parts: the car has no hulls yet (its plan is still in the worker: wait for `isHullPending()`)')\n children = hulls.map((hull, handle) => ({ handle, key: hull.key, partId: hull.id, partIndex: partIndexOf.get(hull.id) ?? -1, applied: hull.points, wanted: hull, isHeld: false }))\n return { kind: 'compound', mutable: true, children: children.map((child) => ({ shape: convexOf(child.applied), position: [0, 0, 0], tag: child.partIndex })) }\n }\n\n const release: ChassisHulls['release'] = (world, chassis, partId) => {\n const mine = children.filter((child) => child.partId === partId)\n for (const child of mine) world.setChildShape(chassis, child.handle, null)\n children = children.filter((child) => child.partId !== partId)\n return mine.map((child) => child.applied)\n }\n\n const settle: ChassisHulls['settle'] = (world, chassis, isTouching) => {\n const now = new Map(colliders.hulls().map((hull) => [hull.key, hull]))\n let remade = 0\n let held = 0\n const next: Child[] = []\n for (const child of children) {\n const hull = now.get(child.key)\n now.delete(child.key)\n if (!hull) {\n world.setChildShape(chassis, child.handle, null)\n continue\n }\n next.push(child)\n if (hull === child.wanted && !child.isHeld) continue\n const points = isTouching(child.applied) ? holdWithin(child.applied, hull.points, HULL_SLOP) : hull.points\n child.wanted = hull\n child.isHeld = points !== hull.points\n if (child.isHeld) held++\n if (points === child.applied) continue\n world.setChildShape(chassis, child.handle, convexOf(points))\n child.applied = points\n remade++\n }\n children = next\n return { remade, held, unplaced: now.size }\n }\n\n return { shape, release, settle, count: () => children.length, hasWork: () => colliders.isHullPending() || children.some((child) => child.isHeld) }\n}\n","import type { Quat, Vec3 } from '@adatechnology/game-physics'\n\n/** What a body weighs and how it turns: its mass, centre of mass and moments about the principal axes, all in the body's frame. */\nexport interface BodyMass {\n readonly mass: number\n readonly centre: Vec3\n readonly inertia: Vec3\n}\n\n/** The least a moment may fall to when a part's moments are taken off (kg m^2 per kg): a body never reaches zero inertia. */\nconst MIN_INERTIA_PER_MASS = 1e-3\n\nexport const rotateBy = (q: Quat, v: Vec3): Vec3 => {\n const [x, y, z, w] = q\n const tx = 2 * (y * v[2] - z * v[1])\n const ty = 2 * (z * v[0] - x * v[2])\n const tz = 2 * (x * v[1] - y * v[0])\n return [v[0] + w * tx + y * tz - z * ty, v[1] + w * ty + z * tx - x * tz, v[2] + w * tz + x * ty - y * tx]\n}\n\nexport const conjugate = (q: Quat): Quat => [-q[0], -q[1], -q[2], q[3]]\n\nexport const multiplyQuat = (a: Quat, b: Quat): Quat => [\n a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],\n a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],\n a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],\n a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2],\n]\n\n/** Moments of a solid box of `mass` and full `size` about its own centre. */\nexport const boxInertia = (mass: number, size: Vec3): Vec3 => [\n (mass / 12) * (size[1] * size[1] + size[2] * size[2]),\n (mass / 12) * (size[0] * size[0] + size[2] * size[2]),\n (mass / 12) * (size[0] * size[0] + size[1] * size[1]),\n]\n\n/** The moment about axis `k` of a point mass `mass` at offset `d` (parallel axis term). */\nconst lever = (mass: number, d: Vec3, k: number): number => mass * (d[0] * d[0] + d[1] * d[1] + d[2] * d[2] - d[k]! * d[k]!)\n\n/**\n * What is left of `total` when `part` (its own mass, centre and moments, in the same frame) leaves: the mass, the centre of mass the rest has, and its moments about that\n * centre (the whole's moments about its centre, less the part's about that centre, moved to the rest's centre by the parallel axis theorem).\n */\nexport const withoutPart = (total: BodyMass, part: BodyMass): BodyMass => {\n const mass = total.mass - part.mass\n if (!(mass > 0)) throw new Error(`crash parts: a part of ${part.mass} kg cannot leave a body of ${total.mass} kg`)\n const centre: Vec3 = [0, 1, 2].map((k) => (total.mass * total.centre[k]! - part.mass * part.centre[k]!) / mass) as unknown as Vec3\n const partOffset: Vec3 = [part.centre[0] - total.centre[0], part.centre[1] - total.centre[1], part.centre[2] - total.centre[2]]\n const shift: Vec3 = [centre[0] - total.centre[0], centre[1] - total.centre[1], centre[2] - total.centre[2]]\n const floor = mass * MIN_INERTIA_PER_MASS\n const inertia = [0, 1, 2].map((k) => Math.max(floor, total.inertia[k]! - (part.inertia[k]! + lever(part.mass, partOffset, k)) - lever(mass, shift, k))) as unknown as Vec3\n return { mass, centre, inertia }\n}\n\n/** The whole car as the kit has it: every part's mass at the centre of its box, the centre of mass of them all, and the moments about that centre. */\nexport const bodyMassOf = (parts: readonly { readonly mass: number; readonly box: { readonly center: Vec3; readonly size: Vec3 } }[]): BodyMass => {\n const mass = parts.reduce((sum, part) => sum + part.mass, 0)\n const centre = [0, 1, 2].map((k) => parts.reduce((sum, part) => sum + part.mass * part.box.center[k]!, 0) / mass) as unknown as Vec3\n const inertia = [0, 1, 2].map((k) => parts.reduce((sum, part) => {\n const offset: Vec3 = [part.box.center[0] - centre[0], part.box.center[1] - centre[1], part.box.center[2] - centre[2]]\n return sum + boxInertia(part.mass, part.box.size)[k]! + lever(part.mass, offset, k)\n }, 0)) as unknown as Vec3\n return { mass, centre, inertia }\n}\n","import type * as THREE_NS from 'three'\nimport type { BodyId, SeamWorld, Quat, ShapeDesc, Vec3 } from '@adatechnology/game-physics'\n\nimport { boxInertia, multiplyQuat, rotateBy } from './crash-parts-math'\nimport type { BodyMass } from './crash-parts-math'\n\ntype Three = typeof THREE_NS\n\n/** Steps between looks at whether a part is clear of the car it came off (it does not meet the car until it is). */\nconst CLEAR_CHECK_STEPS = 30\n/** Times a part found inside the fixed world is moved out along the way the engine gives. */\nconst PUSH_OUT_PASSES = 3\n\n/** A drawn holder that follows the part's body: where it sits against the body's origin and how it is turned against the frame, both fixed when the part came off. */\ninterface Follower {\n readonly holder: THREE_NS.Object3D\n readonly offset: Vec3\n readonly turn: Quat\n}\n\nexport interface PartBody {\n readonly id: BodyId\n readonly partIndex: number\n readonly shape: ShapeDesc\n /** Where the first drawn holder was: the origin the others are placed against. */\n readonly extent: PartExtent\n readonly followers: Follower[]\n /** Still not meeting the car it came off. */\n isIgnoring: boolean\n}\n\n/** Where a part sits in the frame: the centre and size of the box round its drawn meshes (the frame's axes). */\nexport interface PartExtent {\n readonly centre: Vec3\n readonly size: Vec3\n}\n\nexport interface PartBodies {\n /** The part's box in the frame, from what is drawn on `holder`. */\n extentOf(holder: THREE_NS.Object3D): PartExtent\n /** Makes the part's body from `hulls` (frame points) at `extent`, thrown with the point's speed of the chassis; its holder follows from now on. */\n create(options: { readonly partIndex: number; readonly mass: number; readonly hulls: readonly ArrayLike<number>[]; readonly extent: PartExtent; readonly holder: THREE_NS.Object3D; readonly chassis: BodyId; readonly chassisMass: BodyMass }): PartBody\n /** Another drawn holder of a part that already has its body. */\n follow(body: PartBody, holder: THREE_NS.Object3D, extent: PartExtent): void\n /** Holders onto their bodies; releases the parts that are clear of the car. Once a step. */\n step(chassis: BodyId): void\n /** Takes every body out of the world. */\n dispose(): void\n readonly bodies: ReadonlyMap<number, PartBody>\n readonly pushedOut: () => number\n}\n\nexport const createPartBodies = (THREE: Three, world: SeamWorld, frame: THREE_NS.Object3D): PartBodies => {\n const bodies = new Map<number, PartBody>()\n const pose = new Float64Array(7)\n const speed = new Float64Array(6)\n const clearOut: BodyId[] = []\n const push = new Float64Array(3)\n const scratch = { box: new THREE.Box3(), corner: new THREE.Vector3(), position: new THREE.Vector3(), quaternion: new THREE.Quaternion(), parent: new THREE.Quaternion() }\n let steps = 0\n let pushed = 0\n\n const extentOf = (holder: THREE_NS.Object3D): PartExtent => {\n holder.updateWorldMatrix(true, true)\n frame.updateWorldMatrix(true, false)\n const { box, corner } = scratch\n box.setFromObject(holder)\n const low = [Infinity, Infinity, Infinity]\n const high = [-Infinity, -Infinity, -Infinity]\n for (let k = 0; k < 8; k++) {\n corner.set(k & 1 ? box.max.x : box.min.x, k & 2 ? box.max.y : box.min.y, k & 4 ? box.max.z : box.min.z)\n frame.worldToLocal(corner)\n low[0] = Math.min(low[0]!, corner.x); low[1] = Math.min(low[1]!, corner.y); low[2] = Math.min(low[2]!, corner.z)\n high[0] = Math.max(high[0]!, corner.x); high[1] = Math.max(high[1]!, corner.y); high[2] = Math.max(high[2]!, corner.z)\n }\n return { centre: [(low[0]! + high[0]!) / 2, (low[1]! + high[1]!) / 2, (low[2]! + high[2]!) / 2], size: [high[0]! - low[0]!, high[1]! - low[1]!, high[2]! - low[2]!] }\n }\n\n const holderTurn = (holder: THREE_NS.Object3D): Quat => {\n holder.getWorldQuaternion(scratch.quaternion)\n frame.getWorldQuaternion(scratch.parent)\n const turn = scratch.parent.clone().invert().multiply(scratch.quaternion)\n return [turn.x, turn.y, turn.z, turn.w]\n }\n\n const follower = (holder: THREE_NS.Object3D, offset: Vec3): Follower => ({ holder, offset, turn: holderTurn(holder) })\n\n const pushOutOfTheFixedWorld = (body: PartBody): void => {\n for (let pass = 0; pass < PUSH_OUT_PASSES; pass++) {\n const depth = world.penetration(body.id, push)\n if (depth <= 0) return\n world.readPose(body.id, pose, 0)\n world.setPose(body.id, [pose[0]! + push[0]! * depth, pose[1]! + push[1]! * depth, pose[2]! + push[2]! * depth], [pose[3]!, pose[4]!, pose[5]!, pose[6]!], true)\n pushed++\n }\n }\n\n const create: PartBodies['create'] = ({ partIndex, mass, hulls, extent, holder, chassis, chassisMass }) => {\n world.readPose(chassis, pose, 0)\n world.readVelocity(chassis, speed, 0)\n const rotation: Quat = [pose[3]!, pose[4]!, pose[5]!, pose[6]!]\n const lever = rotateBy(rotation, [extent.centre[0] - chassisMass.centre[0], extent.centre[1] - chassisMass.centre[1], extent.centre[2] - chassisMass.centre[2]])\n const around: Vec3 = [speed[3]!, speed[4]!, speed[5]!]\n const linear: Vec3 = [speed[0]! + around[1] * lever[2] - around[2] * lever[1], speed[1]! + around[2] * lever[0] - around[0] * lever[2], speed[2]! + around[0] * lever[1] - around[1] * lever[0]]\n const origin = rotateBy(rotation, extent.centre)\n const shape: ShapeDesc = {\n kind: 'compound',\n children: hulls.map((points) => ({ shape: { kind: 'convex', points: shifted(points, extent.centre) } as ShapeDesc, position: [0, 0, 0] as Vec3, tag: partIndex })),\n }\n const id = world.createBody({\n shape, motion: 'dynamic', mass, inertia: boxInertia(mass, extent.size), centreAtOrigin: true, continuous: true, layer: 'debris', user: partIndex,\n position: [pose[0]! + origin[0], pose[1]! + origin[1], pose[2]! + origin[2]], rotation, linearVelocity: linear, angularVelocity: around,\n })\n const body: PartBody = { id, partIndex, shape, extent, followers: [follower(holder, [0, 0, 0])], isIgnoring: true }\n world.ignorePair(id, chassis, true)\n pushOutOfTheFixedWorld(body)\n bodies.set(partIndex, body)\n return body\n }\n\n const follow: PartBodies['follow'] = (body, holder, extent) => {\n const base = body.extent.centre\n body.followers.push(follower(holder, [extent.centre[0] - base[0], extent.centre[1] - base[1], extent.centre[2] - base[2]]))\n }\n\n const place = (body: PartBody): void => {\n world.readPose(body.id, pose, 0)\n const rotation: Quat = [pose[3]!, pose[4]!, pose[5]!, pose[6]!]\n for (const { holder, offset, turn } of body.followers) {\n const at = rotateBy(rotation, offset)\n scratch.position.set(pose[0]! + at[0], pose[1]! + at[1], pose[2]! + at[2])\n const turned = multiplyQuat(rotation, turn)\n const parent = holder.parent\n if (parent) parent.worldToLocal(scratch.position)\n holder.position.copy(scratch.position)\n scratch.quaternion.set(turned[0], turned[1], turned[2], turned[3])\n if (parent) {\n parent.getWorldQuaternion(scratch.parent)\n scratch.quaternion.premultiply(scratch.parent.invert())\n }\n holder.quaternion.copy(scratch.quaternion)\n holder.updateMatrix()\n }\n }\n\n const release = (body: PartBody, chassis: BodyId): void => {\n world.readPose(body.id, pose, 0)\n // the part's box, not its hulls: the engine holds a query shape by its dimensions, and a compound of hulls is a new one for every body\n world.overlapShape({ kind: 'box', half: [body.extent.size[0] / 2, body.extent.size[1] / 2, body.extent.size[2] / 2] }, [pose[0]!, pose[1]!, pose[2]!], [pose[3]!, pose[4]!, pose[5]!, pose[6]!], clearOut, { layers: ['vehicle'] })\n if (clearOut.includes(chassis)) return\n world.ignorePair(body.id, chassis, false)\n body.isIgnoring = false\n }\n\n return {\n extentOf, create, follow, bodies,\n pushedOut: () => pushed,\n step: (chassis) => {\n steps++\n const check = steps % CLEAR_CHECK_STEPS === 0\n for (const body of bodies.values()) {\n place(body)\n if (check && body.isIgnoring) release(body, chassis)\n }\n },\n dispose: () => {\n for (const body of bodies.values()) if (world.has(body.id)) world.removeBody(body.id)\n bodies.clear()\n },\n }\n}\n\nconst shifted = (points: ArrayLike<number>, by: Vec3): Float32Array => {\n const out = new Float32Array(points.length)\n for (let i = 0; i < out.length; i += 3) {\n out[i] = points[i]! - by[0]\n out[i + 1] = points[i + 1]! - by[1]\n out[i + 2] = points[i + 2]! - by[2]\n }\n return out\n}\n","import { CROWD_AGENTS_CHANNEL } from '@adatechnology/game-physics'\nimport type { PhysicsServices } from '@adatechnology/game-physics'\nimport { createRunOver } from '@adatechnology/game-vehicles-driving'\nimport type { RunOver, RunOverAgents, RunOverCrowd, RunOverVehicle } from '@adatechnology/game-vehicles-driving'\n\n/** What a crowd module lends on `CROWD_AGENTS_CHANNEL`: its crowd and the kinematic capsules of its agents (`createAgentBodies` of `game-crowd`). */\ntype LentCrowd = { readonly crowd: RunOverCrowd; readonly agents: RunOverAgents }\n\nexport interface RunOverLink {\n /** The car runs over the lent crowd from the next step on, whichever of the two the host attached first; returns the way to stop. */\n track(vehicle: RunOverVehicle): () => void\n dispose(): void\n}\n\n/** Cars against the crowd of the same host: one `createRunOver` for the crowd lent now, made again when the crowd changes (the bench rebuilt it) and with the cars tracked so far. */\nexport const createRunOverLink = (services: PhysicsServices): RunOverLink => {\n const channel = services.channel<LentCrowd>(CROWD_AGENTS_CHANNEL)\n const vehicles = new Set<RunOverVehicle>()\n const stops = new Map<RunOverVehicle, () => void>()\n let runOver: RunOver | undefined\n\n const follow = (): void => {\n runOver?.dispose()\n runOver = undefined\n stops.clear()\n const lent = channel.values[0]\n if (!lent) return\n runOver = createRunOver(services.loop, { crowd: lent.crowd, agents: lent.agents })\n for (const vehicle of vehicles) stops.set(vehicle, runOver.track(vehicle))\n }\n\n const stopListening = channel.onChange(follow)\n follow()\n return {\n track: (vehicle) => {\n vehicles.add(vehicle)\n if (runOver) stops.set(vehicle, runOver.track(vehicle))\n return () => {\n vehicles.delete(vehicle)\n stops.get(vehicle)?.()\n stops.delete(vehicle)\n }\n },\n dispose: () => {\n stopListening()\n runOver?.dispose()\n runOver = undefined\n vehicles.clear()\n stops.clear()\n },\n }\n}\n","import type { ModuleScenario, Vec3 } from '@adatechnology/game-contracts'\nimport { createArcadeDriver, createSemiSimDriver, createSurfaces, vehicleCorners } from '@adatechnology/game-vehicles-driving'\nimport type { SemiInput, SemiWorld } from '@adatechnology/game-vehicles-driving'\nimport type { VehicleContext } from '@adatechnology/game-vehicles'\n\nimport { fill } from './text'\nimport type { VehiclesText } from './text'\nimport type { PartView, VehiclesContext, VehiclesRoom } from './types'\n\ntype Destructible = {\n partWorldCenter(part: string): Vec3\n detachedParts(): string[]\n describe(): { parts: { id: string; hp: number; shape: { size: Vec3 } }[] }\n status(): { leaking: unknown[]; exploded: boolean; lightsOn: boolean; canStart: boolean; canDrive: boolean }\n state(): { groups: unknown[] }\n rollover(): void\n vehicle: { flipped?: boolean }\n}\n\ntype Spawned = { id: string; d: Destructible }\n\nexport type ScenarioDeps = {\n readonly text: VehiclesText\n readonly locale: string\n}\n\nconst add = (p: Vec3, dx: number, dy: number, dz: number): Vec3 => [p[0] + dx, p[1] + dy, p[2] + dz]\n\n/**\n * The scenarios of the vehicles area. The first eleven are the Frota test page's, literal (same shots, same hits, same checks and the same sentences); the vehicle faces +z,\n * its left is +x and its right -x. Then the burnt sedan built by the kit's `burnt` scenario, the arcade driver down a lane that ends in a wall, and the semi-simulation braking on three surfaces (new in the kit).\n */\nexport const createScenarios = (deps: ScenarioDeps): ModuleScenario<VehiclesContext>[] => {\n const { text, locale } = deps\n const say = (id: string, ...values: unknown[]): string => fill(text, locale, text.checks[id] as string, ...values)\n const scenario = (id: string, run: ModuleScenario<VehiclesContext>['run']): ModuleScenario<VehiclesContext> => ({ id, name: text.scenarios[id] ?? id, run })\n const put = (room: VehiclesRoom, item: string, z = -7): Spawned => {\n const spawned = room.spawn(item, [0, 0, z], 0)\n return { id: spawned.objectId, d: spawned.root.userData.destructible as Destructible }\n }\n const part = (room: VehiclesRoom, v: Spawned, id: string): PartView => room.world.part(v.id, id)\n const events = (room: VehiclesRoom, type: string, v: Spawned): number => room.log.entries({ type, objectId: v.id }).length\n\n return [\n scenario('vehicles_9mm_windshield', ({ room, step, expect }) => {\n const v = put(room, 'hatch')\n const c = v.d.partWorldCenter('windshield')\n room.setTool('pistol_9mm')\n room.waitUntilReady()\n room.look(add(c, 0, 0.5, 3), c)\n step(0.1)\n room.use()\n step(0.4)\n const w = part(room, v, 'windshield')\n expect(w.holes.length >= 1 && !!w.holes[0]?.through, say('windshield_holes', w.holes.length, w.holes[0]?.through))\n expect(w.cracks.length >= 1 && w.status === 'damaged', say('windshield_cracks', w.cracks.length, w.status))\n }),\n scenario('vehicles_shotgun_door', ({ room, step, expect }) => {\n const v = put(room, 'sedan')\n const c = v.d.partWorldCenter('door_front_left')\n room.setTool('shotgun_pump_12')\n room.waitUntilReady()\n room.look(add(c, 2.5, 0, 0), c)\n step(0.1)\n room.use()\n step(0.4)\n const p = part(room, v, 'door_front_left')\n const marks = p.holes.length + p.dents.length\n expect(marks >= 2 && p.hp < p.maxHp, say('door_marks', p.holes.length, p.dents.length, Math.round(p.hp), p.maxHp))\n }),\n scenario('vehicles_ram_front', ({ room, step, expect }) => {\n const v = put(room, 'hatch')\n const c = v.d.partWorldCenter('bumper_front')\n room.world.hit(v.id, { type: 'blunt', point: c, direction: [0, 0, -1], energy: 45000, radius: 0.6, source: 'teste' })\n step(2.5)\n const b = part(room, v, 'bumper_front')\n const h = part(room, v, 'hood')\n expect(b.dents.length >= 1 && h.dents.length >= 1, say('front_crush', b.dents.length, h.dents.length))\n const det = v.d.detachedParts()\n expect(det.indexOf('bumper_front') >= 0, say('bumper_off', det.join(', ')))\n }),\n scenario('vehicles_engine_fire', ({ room, step, expect }) => {\n const v = put(room, 'pickup')\n const c = v.d.partWorldCenter('engine')\n for (let i = 0; i < 80; i++) {\n room.world.hit(v.id, { type: 'fire', point: c, temperature: 900, radius: 0.5, duration: 0.1, source: 'teste' })\n step(0.1)\n }\n const e = part(room, v, 'engine')\n expect(e.burning && e.temperature > 250, say('engine_burning', e.burning, Math.round(e.temperature)))\n expect(events(room, 'ignite', v) >= 1, say('ignite_lines', events(room, 'ignite', v)))\n }),\n scenario('vehicles_fuel_tank', ({ room, step, expect }) => {\n const v = put(room, 'hatch')\n const spec = v.d.describe().parts.filter((p) => p.id === 'fuel_tank')[0] as { shape: { size: Vec3 } }\n const c = v.d.partWorldCenter('fuel_tank')\n // the shot comes in from below, under the fuel level\n const low: Vec3 = [c[0], c[1] - spec.shape.size[1] / 2 + 0.06, c[2]]\n room.setTool('pistol_9mm')\n room.waitUntilReady()\n room.look(add(low, 0, 0, -2.5), low)\n step(0.1)\n room.use()\n step(1)\n const t = part(room, v, 'fuel_tank')\n const nl = v.d.status().leaking.length\n expect(nl >= 1 && t.liters < 55, say('tank_leaking', nl, t.liters.toFixed(1)))\n for (let i = 0; i < 160 && !events(room, 'explode', v); i++) {\n room.world.hit(v.id, { type: 'fire', point: c, temperature: 900, radius: 0.6, duration: 0.1, source: 'teste' })\n step(0.1)\n }\n expect(events(room, 'ignite', v) >= 1, say('ignited', events(room, 'ignite', v)))\n step(2)\n expect(events(room, 'explode', v) === 1 && v.d.status().exploded, say('exploded', events(room, 'explode', v)))\n const vc = v.d.partWorldCenter('engine')\n room.look(add(vc, 4, 0, -3), vc)\n }),\n scenario('vehicles_unbolt_wheel', ({ room, step, expect }) => {\n const v = put(room, 'sedan')\n const joint = 'wheel_front_left~underbody'\n const c = v.d.partWorldCenter('wheel_front_left')\n room.setTool('wrench')\n // the wrench turns the hub bolts (the wheel~chassis joint), the same path as the first-person use\n for (let k = 0; k < 120 && room.world.disassemble(v.id, joint, 'wrench', 0.1) < 1; k++) step(0.1)\n step(1)\n const st = room.world.state(v.id)\n const open = !!st.joints.filter((j) => j.id === joint)[0]?.open\n expect(open && st.groups.length >= 2 && events(room, 'detach', v) >= 1, say('wheel_wrench', open, st.groups.length, events(room, 'detach', v)))\n step(2)\n room.look(add(c, 2.2, 0, 0.2), add(c, 0, -0.1, 0))\n }),\n scenario('vehicles_tear_bumper', ({ room, step, expect }) => {\n const v = put(room, 'hatch')\n const c = v.d.partWorldCenter('bumper_front')\n room.world.hit(v.id, { type: 'blunt', point: c, direction: [0, 0, -1], energy: 30000, radius: 0.6, source: 'teste' })\n step(2.5)\n const det = v.d.detachedParts()\n expect(det.indexOf('bumper_front') >= 0, say('loose_parts', det.join(', ')))\n room.look(add(c, 2, 0, 3.5), add(c, 0, 0, -0.5))\n }),\n scenario('vehicles_break_mirror', ({ room, step, expect }) => {\n const v = put(room, 'sedan')\n const c = v.d.partWorldCenter('mirror_left')\n room.world.hit(v.id, { type: 'blunt', point: c, direction: [-1, 0, 0], energy: 2500, radius: 0.1, source: 'teste' })\n step(2)\n const m = part(room, v, 'mirror_left')\n expect(m.status === 'broken' && v.d.state().groups.length >= 1, say('mirror_broken', m.status))\n }),\n scenario('vehicles_kill_battery', ({ room, step, expect }) => {\n const v = put(room, 'pickup')\n expect(v.d.status().lightsOn && v.d.status().canStart, say('battery_before'))\n room.playAnimation('open_hood', v.id)\n step(1.5)\n for (let i = 0; i < 80 && room.world.disassemble(v.id, 'battery~underbody', 'wrench', 0.1) < 1; i++) step(0.1)\n step(0.5)\n const s = v.d.status()\n expect(!s.lightsOn && !s.canStart && !s.canDrive, say('battery_after', s.lightsOn, s.canStart))\n }),\n scenario('vehicles_rollover', ({ room, step, expect }) => {\n const v = put(room, 'sedan')\n const maxRoof = (v.d.describe().parts.filter((p) => p.id === 'roof')[0] as { hp: number }).hp\n v.d.rollover()\n step(8)\n const roof = part(room, v, 'roof')\n expect(!!v.d.vehicle.flipped, say('rolled_over', !!v.d.vehicle.flipped))\n expect(roof.hp < maxRoof && roof.dents.length >= 1, say('roof', Math.round(roof.hp), maxRoof, roof.dents.length))\n }),\n scenario('vehicles_melt', ({ room, step, expect }) => {\n const v = put(room, 'hatch')\n const c = v.d.partWorldCenter('tyre_front_left')\n for (let i = 0; i < 60; i++) {\n room.world.hit(v.id, { type: 'fire', point: c, temperature: 900, radius: 0.7, duration: 0.1, source: 'teste' })\n step(0.1)\n }\n step(30)\n const t = part(room, v, 'tyre_front_left')\n expect(events(room, 'melt', v) >= 1 && (t.status === 'melted' || t.melt > 0.5), say('tyre_melt', t.status, Math.round(t.melt * 100), events(room, 'melt', v)))\n }),\n // new in the kit: the burnt wreck comes ready from the kit (the fleet's `burnt` scenario built into the vehicle), no damage applied by the area\n scenario('vehicles_burnt_wreck', ({ room, expect }) => {\n const c = room.spawn('sedan_burnt', [0, 0, -7], 0).root.userData.vehicle as VehicleContext\n expect(c.zoneState.flags.burnt === true, say('wreck_burnt', c.zoneState.flags.burnt === true))\n const glass = c.zones.filter((z) => z.type === 'glass')\n const up = glass.filter((z) => (c.zoneState.health[z.id] ?? 100) > 0)\n expect(glass.length >= 1 && up.length === 0, say('wreck_glass', glass.length, up.length))\n }),\n // new in the kit: the drivers, headless (no vehicle is spawned)\n scenario('vehicles_drive_arcade', ({ expect }) => {\n const driver = createArcadeDriver()\n const wallX = 60\n driver.place(0, 0, 0)\n const world = { blocked: (x: number, z: number, yaw: number) => vehicleCorners(driver.spec, x, z, yaw).some(([px]) => px >= wallX) }\n let crashSpeed = 0\n let engine = 0\n let crashNoise = 0\n let after = 0\n for (let t = 0; t < 12; t += 1 / 60) {\n const { events: out } = driver.step({ throttle: 1, brake: 0, steer: 0, handbrake: false }, 1 / 60, world)\n for (const e of out) {\n if (e.type === 'crash' && !crashSpeed) {\n crashSpeed = e.speed\n after = driver.state.v\n }\n if (e.type === 'noise' && e.source === 'engine') engine++\n if (e.type === 'noise' && e.source === 'crash') crashNoise++\n }\n }\n expect(crashSpeed > driver.spec.crash.damageSpeed && crashSpeed <= driver.spec.maxForward + 1e-6, say('arcade_crash', crashSpeed.toFixed(1), driver.spec.maxForward))\n expect(after < 0, say('arcade_bounce', after.toFixed(1)))\n expect(engine >= 1 && crashNoise >= 1, say('arcade_noise', engine, crashNoise))\n }),\n scenario('vehicles_drive_semi', ({ expect }) => {\n const surfaces = createSurfaces()\n const coast: SemiInput = { throttle: 0, brake: 0, steer: 0, handbrake: false }\n const dt = 1 / 60\n const world = (surface: string): SemiWorld => ({ ground: () => ({ surface }) })\n const braking = (surface: string): number => {\n const driver = createSemiSimDriver({}, { surfaces })\n driver.state.u = 80 / 3.6\n for (let t = 0; t < 1; t += dt) driver.step({ ...coast, throttle: 0.3 }, dt, world(surface))\n driver.state.u = 80 / 3.6\n const start = driver.state.x\n for (let t = 0; t < 30 && driver.state.u > 0.1; t += dt) driver.step({ ...coast, brake: 1 }, dt, world(surface))\n return driver.state.x - start\n }\n const dry = braking('dry_asphalt')\n const wet = braking('wet_asphalt')\n const mud = braking('mud')\n expect(dry < wet && wet < mud, say('semi_order', dry.toFixed(1), wet.toFixed(1), mud.toFixed(1)))\n const bog = createSemiSimDriver({}, { surfaces })\n let bogged = 0\n for (let t = 0; t < 8; t += dt) bogged += bog.step({ ...coast, throttle: 1 }, dt, world('mud')).events.filter((e) => e.type === 'bogged').length\n expect(bog.state.bogged && bogged >= 1, say('semi_mud', bog.state.bogged))\n }),\n ]\n}\n","/** Words and sentences of the vehicles area. The check lines keep the sentences of the Frota test page; `{0}`, `{1}`... are filled in order, `{0:b}` is yes / no (true / false in English), `{0:open}` open / tight, `{0:on}` on / off. */\nexport type VehiclesText = {\n group: string\n name: string\n items: Record<string, string>\n controls: Record<'quality' | 'paint_by_seed' | 'color_seed' | 'palette' | 'driving' | 'surface' | 'lane_damage', string>\n hints: Record<'quality' | 'paint_by_seed' | 'palette' | 'driving' | 'surface' | 'lane_damage', string>\n options: { quality: Record<string, string>; palette: Record<string, string>; driving: Record<string, string>; surface: Record<string, string>; lane_damage: Record<string, string> }\n actions: Record<'repaint' | 'drive_lane' | 'clear_lane' | 'honk', string>\n layers: Record<'damageables' | 'zones' | 'axes', string>\n metrics: Record<'vehicles' | 'triangles' | 'draw_calls' | 'size_error_mm' | 'metal' | 'glass' | 'rubber' | 'fuel' | 'speed' | 'lane', string>\n words: { yes: string; no: string; open: string; tight: string; on: string; off: string }\n lane: Record<'crash' | 'end' | 'damage', string>\n scenarios: Record<string, string>\n checks: Record<string, string>\n}\n\nconst scenarioIds = [\n 'vehicles_9mm_windshield',\n 'vehicles_shotgun_door',\n 'vehicles_ram_front',\n 'vehicles_engine_fire',\n 'vehicles_fuel_tank',\n 'vehicles_unbolt_wheel',\n 'vehicles_tear_bumper',\n 'vehicles_break_mirror',\n 'vehicles_kill_battery',\n 'vehicles_rollover',\n 'vehicles_melt',\n 'vehicles_burnt_wreck',\n 'vehicles_drive_arcade',\n 'vehicles_drive_semi',\n] as const\n\nexport const VEHICLE_SCENARIO_IDS: readonly string[] = scenarioIds\n\n/** The ids of the Frota test page, for whoever keeps a report or a link made against it. */\nexport const PAGE_SCENARIO_ALIASES: Readonly<Record<string, string>> = {\n veiculos_9mm_parabrisa: 'vehicles_9mm_windshield',\n veiculos_espingarda_porta: 'vehicles_shotgun_door',\n veiculos_bater_frente: 'vehicles_ram_front',\n veiculos_fogo_motor: 'vehicles_engine_fire',\n veiculos_tanque: 'vehicles_fuel_tank',\n veiculos_soltar_roda: 'vehicles_unbolt_wheel',\n veiculos_arrancar_parachoque: 'vehicles_tear_bumper',\n veiculos_quebrar_retrovisor: 'vehicles_break_mirror',\n veiculos_matar_bateria: 'vehicles_kill_battery',\n veiculos_capotar: 'vehicles_rollover',\n veiculos_derreter: 'vehicles_melt',\n}\n\nexport const PAGE_ITEM_ALIASES: Readonly<Record<string, string>> = {\n hatch: 'hatch',\n sedan: 'sedan',\n picape: 'pickup',\n moto: 'sport_bike',\n caminhao: 'box_truck',\n onibus: 'city_bus',\n tanque: 'battle_tank',\n helicoptero: 'attack_helicopter',\n}\n\nexport const TEXT: Record<string, VehiclesText> = {\n en: {\n group: 'Vehicles',\n name: 'Vehicles area',\n items: { hatch: 'Compact hatch', sedan: 'Midsize sedan', pickup: 'Midsize pickup', sport_bike: 'Sport bike', box_truck: 'Box truck', city_bus: 'City bus', battle_tank: 'Battle tank', attack_helicopter: 'Attack helicopter', sedan_burnt: 'Burnt sedan', hatch_burnt: 'Burnt hatch' },\n controls: { quality: 'Quality', paint_by_seed: 'Paint by seed', color_seed: 'Colour seed', palette: 'Palette', driving: 'Driving', surface: 'Surface', lane_damage: 'Lane damage' },\n hints: {\n quality: 'High: the kit at full detail. Light: fewer segments and no interior (the light mode of the fleet); applies to the vehicles placed from now on',\n paint_by_seed: 'Off: every vehicle keeps its own paint. On: the body colour comes from the seed and the palette',\n palette: 'Auto: the palette of the vehicle group (civil, or military for the army vehicles)',\n driving: 'Arcade: the game car, simple and forgiving. Semi: a rigid body with springs, tyre friction, gears and surfaces',\n surface: 'The ground under the wheels in the semi mode (grip and aquaplaning)',\n lane_damage: 'What the lane car starts with; it drives in the semi mode and the damage model sets its tyres, brakes and engine',\n },\n options: {\n quality: { high: 'High', lite: 'Light' },\n palette: { auto: 'Auto', civil: 'Civil', military: 'Military' },\n driving: { arcade: 'Arcade', semi: 'Semi-simulation' },\n surface: { dry_asphalt: 'Dry asphalt', wet_asphalt: 'Wet asphalt', dirt: 'Dirt', grass: 'Grass', mud: 'Mud', blood: 'Blood' },\n lane_damage: { none: 'None', into_wall: 'Into the wall, no braking', flat_tyre: 'Flat tyre (rifle round)', torn_tyre: 'Tyre torn off: rim on the road', run_flat: 'Armoured, flat tyre (run-flat)', no_brake_fluid: 'No brake fluid' },\n },\n actions: { repaint: 'Repaint with the seed', drive_lane: 'Drive the lane', clear_lane: 'Remove the lane car', honk: 'Honk the horn' },\n layers: { damageables: 'Damageable boxes by material', zones: 'Zone boxes by type', axes: 'Output frame axes' },\n metrics: { vehicles: 'Vehicles', triangles: 'Triangles', draw_calls: 'Draw calls', size_error_mm: 'Size against DIMS', metal: 'Metal boxes', glass: 'Glass boxes', rubber: 'Rubber boxes', fuel: 'Fuel boxes', speed: 'Lane speed', lane: 'Lane distance' },\n words: { yes: 'true', no: 'false', open: 'open', tight: 'tight', on: 'on', off: 'off' },\n lane: { crash: 'Lane: the car hit the wall at {0} m/s', end: 'Lane: the car stopped {0} m from the wall', damage: 'Lane: the crash dented {0} and broke {1}' },\n scenarios: {\n vehicles_9mm_windshield: 'Vehicles: 9 mm through the windshield',\n vehicles_shotgun_door: 'Vehicles: shotgun on the door',\n vehicles_ram_front: 'Vehicles: ram the front',\n vehicles_engine_fire: 'Vehicles: fire on the engine',\n vehicles_fuel_tank: 'Vehicles: shoot the fuel tank (leaks, ignites, explodes)',\n vehicles_unbolt_wheel: 'Vehicles: unbolt the wheel with the wrench',\n vehicles_tear_bumper: 'Vehicles: tear off the bumper',\n vehicles_break_mirror: 'Vehicles: break the mirror',\n vehicles_kill_battery: 'Vehicles: kill the battery (lights go out)',\n vehicles_rollover: 'Vehicles: roll over',\n vehicles_melt: 'Vehicles: melt (long fire burns the tyres)',\n vehicles_drive_arcade: 'Vehicles: arcade driving down a lane that ends in a wall',\n vehicles_drive_semi: 'Vehicles: semi-simulation braking on dry, wet and mud',\n vehicles_burnt_wreck: 'Vehicles: the burnt sedan comes out of the kit burnt, with the glass gone',\n },\n checks: {\n windshield_holes: 'Windshield: {0} hole(s), went through {1:b} (expected: 1, true)',\n windshield_cracks: 'Windshield cracked: {0} crack(s), state {1} (expected: damaged)',\n door_marks: 'Front left door: {0} hole(s), {1} dent(s), hp {2}/{3} (expected: 2 marks or more)',\n front_crush: 'Front crushed: bumper {0} dent(s), hood {1} (expected: 1 or more each)',\n bumper_off: 'The bumper came off: {0} (expected: bumper_front)',\n engine_burning: 'Engine: burning {0:b}, {1} °C (expected: true, above 250)',\n ignite_lines: 'Ignite lines in the log: {0} (expected: 1 or more)',\n tank_leaking: 'Tank leaking: {0} leak(s), {1} L left (expected: 1 or more, below 55)',\n ignited: 'Ignited: {0} ignite line(s) (expected: 1 or more)',\n exploded: 'Exploded: {0} explosion(s) (expected: 1)',\n wheel_wrench: 'Wrench on the wheel: bolts {0:open}, {1} group(s), {2} detach line(s) (expected: open, 2 or more, 1)',\n loose_parts: 'Loose parts: {0} (expected: bumper_front)',\n mirror_broken: 'Left mirror: {0} (expected: broken)',\n battery_before: 'Before: lights on and it starts (expected: yes)',\n battery_after: 'No battery: lights {0:on}, start {1:b} (expected: off, false)',\n rolled_over: 'Rolled over: {0:b} (expected: true)',\n roof: 'Roof: hp {0}/{1}, {2} dent(s) (expected: below max, 1 or more)',\n tyre_melt: 'Tyre: {0}, melted {1}%, {2} melt line(s) (expected: melted or above 50%)',\n arcade_crash: 'Arcade: the wall is hit at {0} m/s (expected: the crash above 4 m/s, at most {1})',\n arcade_bounce: 'Arcade: the car bounces back at {0} m/s (expected: below 0)',\n arcade_noise: 'Arcade: {0} engine noise(s) and {1} crash noise(s) (expected: 1 or more each)',\n semi_order: 'Semi: braking from 80 km/h takes dry {0} m, wet {1} m, mud {2} m (expected: dry shorter than wet shorter than mud)',\n semi_mud: 'Semi: a 2WD car on mud {0:on} (expected: bogged on, a bog event)',\n wreck_burnt: 'Burnt sedan: burnt flag {0:b} (expected: yes)',\n wreck_glass: 'Burnt sedan: {0} glass zone(s), {1} still above 0 (expected: 1 or more, none above 0)',\n },\n },\n 'pt-BR': {\n group: 'Veículos',\n name: 'Área de veículos',\n items: { hatch: 'Hatch compacto', sedan: 'Sedã médio', pickup: 'Picape média', sport_bike: 'Moto esportiva', box_truck: 'Caminhão baú', city_bus: 'Ônibus urbano', battle_tank: 'Tanque de guerra', attack_helicopter: 'Helicóptero de ataque', sedan_burnt: 'Sedã queimado', hatch_burnt: 'Hatch queimado' },\n controls: { quality: 'Qualidade', paint_by_seed: 'Pintar pela semente', color_seed: 'Semente da cor', palette: 'Paleta', driving: 'Direção', surface: 'Piso', lane_damage: 'Dano na pista' },\n hints: {\n quality: 'Alta: o kit com todo o detalhe. Leve: menos segmentos e sem interior (o modo leve da frota); vale para os veículos postos daqui em diante',\n paint_by_seed: 'Desligado: cada veículo mantém a própria pintura. Ligado: a cor da carroceria vem da semente e da paleta',\n palette: 'Auto: a paleta do grupo do veículo (civil, ou militar para os do exército)',\n driving: 'Arcade: o carro do jogo, simples e tolerante. Semi: corpo rígido com molas, atrito do pneu, marchas e pisos',\n surface: 'O chão sob as rodas no modo semi (aderência e aquaplanagem)',\n lane_damage: 'Com o que o carro da pista sai; ele anda no modo semi e o modelo de dano define pneus, freio e motor',\n },\n options: {\n quality: { high: 'Alta', lite: 'Leve' },\n palette: { auto: 'Auto', civil: 'Civil', military: 'Militar' },\n driving: { arcade: 'Arcade', semi: 'Semissimulação' },\n surface: { dry_asphalt: 'Asfalto seco', wet_asphalt: 'Asfalto molhado', dirt: 'Terra', grass: 'Grama', mud: 'Lama', blood: 'Sangue' },\n lane_damage: { none: 'Nenhum', into_wall: 'Contra o muro, sem frear', flat_tyre: 'Pneu furado (tiro de fuzil)', torn_tyre: 'Pneu desfeito: aro no chão', run_flat: 'Blindado, pneu furado (run-flat)', no_brake_fluid: 'Sem fluido de freio' },\n },\n actions: { repaint: 'Repintar com a semente', drive_lane: 'Percorrer a pista', clear_lane: 'Tirar o carro da pista', honk: 'Buzinar' },\n layers: { damageables: 'Caixas danificáveis por material', zones: 'Caixas das zonas por tipo', axes: 'Eixos do quadro de saída' },\n metrics: { vehicles: 'Veículos', triangles: 'Triângulos', draw_calls: 'Chamadas de desenho', size_error_mm: 'Medida contra DIMS', metal: 'Caixas de metal', glass: 'Caixas de vidro', rubber: 'Caixas de borracha', fuel: 'Caixas de combustível', speed: 'Velocidade na pista', lane: 'Distância na pista' },\n words: { yes: 'sim', no: 'não', open: 'soltos', tight: 'presos', on: 'acesos', off: 'apagados' },\n lane: { crash: 'Pista: o carro bateu no muro a {0} m/s', end: 'Pista: o carro parou a {0} m do muro', damage: 'Pista: a batida amassou {0} e quebrou {1}' },\n scenarios: {\n vehicles_9mm_windshield: 'Veículos: 9 mm atravessa o para-brisa',\n vehicles_shotgun_door: 'Veículos: espingarda na porta',\n vehicles_ram_front: 'Veículos: bater de frente',\n vehicles_engine_fire: 'Veículos: fogo no motor',\n vehicles_fuel_tank: 'Veículos: atirar no tanque (vaza, pega fogo, explode)',\n vehicles_unbolt_wheel: 'Veículos: soltar a roda com a chave inglesa',\n vehicles_tear_bumper: 'Veículos: arrancar o para-choque',\n vehicles_break_mirror: 'Veículos: quebrar o retrovisor',\n vehicles_kill_battery: 'Veículos: matar a bateria (faróis apagam)',\n vehicles_rollover: 'Veículos: capotar',\n vehicles_melt: 'Veículos: derreter (fogo longo queima os pneus)',\n vehicles_drive_arcade: 'Veículos: direção arcade numa pista que acaba num muro',\n vehicles_drive_semi: 'Veículos: frenagem da semissimulação no seco, no molhado e na lama',\n vehicles_burnt_wreck: 'Veículos: o sedã queimado sai do kit queimado, sem os vidros',\n },\n checks: {\n windshield_holes: 'Para-brisa: {0} furo(s), atravessou {1:b} (esperado: 1, sim)',\n windshield_cracks: 'Para-brisa trincou: {0} trinca(s), estado {1} (esperado: damaged)',\n door_marks: 'Porta dianteira esquerda: {0} furo(s), {1} amassado(s), vida {2}/{3} (esperado: 2 marcas ou mais)',\n front_crush: 'Frente amassada: para-choque {0} amassado(s), capô {1} (esperado: 1 ou mais cada)',\n bumper_off: 'O para-choque soltou: {0} (esperado: bumper_front)',\n engine_burning: 'Motor: pegando fogo {0:b}, {1} °C (esperado: sim, acima de 250)',\n ignite_lines: 'Linhas de ignição no log: {0} (esperado: 1 ou mais)',\n tank_leaking: 'Tanque vazando: {0} vazamento(s), {1} L restantes (esperado: 1 ou mais, menos de 55)',\n ignited: 'Pegou fogo: {0} linha(s) de ignição (esperado: 1 ou mais)',\n exploded: 'Explodiu: {0} explosão (esperado: 1)',\n wheel_wrench: 'Chave na roda: parafusos {0:open}, {1} grupo(s), {2} linha(s) de soltura (esperado: soltos, 2 ou mais, 1)',\n loose_parts: 'Peças soltas: {0} (esperado: bumper_front)',\n mirror_broken: 'Retrovisor esquerdo: {0} (esperado: broken)',\n battery_before: 'Antes: faróis acesos e dá partida (esperado: sim)',\n battery_after: 'Sem bateria: faróis {0:on}, partida {1:b} (esperado: apagados, não)',\n rolled_over: 'Capotou: {0:b} (esperado: sim)',\n roof: 'Teto: vida {0}/{1}, {2} amassado(s) (esperado: menos que o máximo, 1 ou mais)',\n tyre_melt: 'Pneu: {0}, derretido {1}%, {2} linha(s) de derretimento (esperado: melted ou mais de 50%)',\n arcade_crash: 'Arcade: bate no muro a {0} m/s (esperado: a batida acima de 4 m/s, no máximo {1})',\n arcade_bounce: 'Arcade: o carro volta a {0} m/s (esperado: abaixo de 0)',\n arcade_noise: 'Arcade: {0} ruído(s) de motor e {1} de batida (esperado: 1 ou mais de cada)',\n semi_order: 'Semi: frear de 80 km/h leva no seco {0} m, no molhado {1} m, na lama {2} m (esperado: seco menor que molhado menor que lama)',\n semi_mud: 'Semi: um carro 2WD na lama {0:on} (esperado: atolado, com evento de atolamento)',\n wreck_burnt: 'Sedã queimado: marca de queimado {0:b} (esperado: sim)',\n wreck_glass: 'Sedã queimado: {0} zona(s) de vidro, {1} ainda acima de 0 (esperado: 1 ou mais, nenhuma acima de 0)',\n },\n },\n}\n\n/** Fills a check sentence: `{i}` plain, `{i:b}` yes / no, `{i:open}` open / tight, `{i:on}` on / off. In English the `:b` form prints the value itself (true, false, undefined), as the page does. */\nexport function fill(text: VehiclesText, locale: string, template: string, ...values: readonly unknown[]): string {\n return template.replace(/\\{(\\d+)(?::(b|open|on))?\\}/g, (_match, index: string, kind?: string) => {\n const value = values[Number(index)]\n if (kind === 'b') return locale === 'en' ? String(value) : value ? text.words.yes : text.words.no\n if (kind === 'open') return value ? text.words.open : text.words.tight\n if (kind === 'on') return value ? text.words.on : text.words.off\n return String(value)\n })\n}\n","/**\n * How a vehicle sounds, as data. An engine is a few loops crossfaded by RPM (idle, low/mid, high) plus a load layer (intake and exhaust roar) that\n * follows the throttle, the way a sampled engine is mixed: when recorded loops arrive they take the same ids and the same crossfade. The pitch of\n * each tone layer is the firing frequency of the engine (`rpm / 60 × cylinders / 2` for a four-stroke) times its harmonic.\n */\n\n/** One tone layer of the engine: the loop id, where in the RPM range it is loudest (0 idle … 1 redline), and its level and cutoff. */\nexport type EngineLayer = {\n readonly sound: string\n /** Normalised RPM (0 at idle, 1 at the redline) where the layer is loudest. */\n readonly centre: number\n /** How far from `centre` the layer fades out (equal-power crossfade). */\n readonly width: number\n /** Multiple of the firing frequency the oscillator plays at. */\n readonly harmonic: number\n /** Level at full load. */\n readonly gain: number\n /** Low-pass cutoff, Hz, from no load at idle to full load at the redline. */\n readonly cutoff: readonly [min: number, max: number]\n}\n\n/** The roar of the intake and exhaust: a noise loop that opens with the throttle and the RPM. */\nexport type EngineLoadLayer = { readonly sound: string; readonly gain: number; readonly cutoff: readonly [min: number, max: number] }\n\nexport type EngineProfile = {\n readonly id: string\n readonly cylinders: number\n readonly idleRpm: number\n readonly redlineRpm: number\n /** Gear ratios times final drive per m/s, to guess the RPM from the speed when the driver has no engine model (the arcade driver). */\n readonly rpmPerMps: readonly number[]\n readonly layers: readonly EngineLayer[]\n readonly load: EngineLoadLayer\n /** Level with the throttle closed, as a share of full load (engine braking is quieter and darker). */\n readonly closedThrottle: number\n}\n\n/** The sound ids a vehicle plays besides its engine. Every one is a key of `VEHICLE_SOUND_BANK`, and a game can point any of them elsewhere. */\nexport type VehicleSoundKeys = {\n readonly start: string\n readonly stop: string\n readonly fail: string\n readonly crashLight: string\n readonly crashMedium: string\n readonly crashHeavy: string\n readonly skidAsphalt: string\n readonly skidDirt: string\n readonly roll: string\n /** Tyres rolling on earth, gravel, sand or grass (`frame.surface` `dirt`), in place of `roll`. */\n readonly rollDirt: string\n /** Compressed air let out of the brake chambers as a truck stops (`VehicleSoundOptions.airBrake`). */\n readonly airBrake: string\n /** Pads squealing on the discs as a car brakes to a stop (not a skid: the tyres still grip). */\n readonly brakeSqueal: string\n /** A body hit by the vehicle; a game points it at its own (a zombie, an animal) through `sounds` or the `hit` call. */\n readonly hitBody: string\n /** An emergency siren, its pitch swept by the vehicle (`frame.siren`). */\n readonly siren: string\n /** A helicopter's blades (`frame.rotor`). */\n readonly rotor: string\n}\n\nexport const DEFAULT_VEHICLE_SOUND_KEYS: VehicleSoundKeys = {\n start: 'engine_start',\n stop: 'engine_stop',\n fail: 'engine_fail',\n crashLight: 'crash_light',\n crashMedium: 'crash_medium',\n crashHeavy: 'crash_heavy',\n skidAsphalt: 'tire_skid_asphalt',\n skidDirt: 'tire_skid_dirt',\n roll: 'tire_roll',\n rollDirt: 'tire_roll_gravel',\n airBrake: 'air_brake',\n brakeSqueal: 'brake_squeal',\n hitBody: 'vehicle_hit_pedestrian',\n siren: 'siren',\n rotor: 'helicopter_rotor_loop',\n}\n\n/** The speed of the hit, m/s, where a crash stops being light (≈ 22 km/h: dents and plastic) and where it turns heavy (≈ 50 km/h: metal folds, glass goes). */\nexport const CRASH_SPEEDS = { medium: 6, heavy: 14 } as const\n\nconst layers = (id: string, cutoffs: readonly (readonly [number, number])[], gains: readonly number[]): EngineLayer[] => [\n { sound: `engine_${id}_low`, centre: 0, width: 0.5, harmonic: 1, gain: gains[0] as number, cutoff: cutoffs[0] as readonly [number, number] },\n { sound: `engine_${id}_mid`, centre: 0.45, width: 0.5, harmonic: 1, gain: gains[1] as number, cutoff: cutoffs[1] as readonly [number, number] },\n { sound: `engine_${id}_high`, centre: 1, width: 0.6, harmonic: 2, gain: gains[2] as number, cutoff: cutoffs[2] as readonly [number, number] },\n]\n\n/** A four-cylinder petrol car: 800 to 6 500 rpm. */\nexport const CAR_ENGINE: EngineProfile = {\n id: 'car',\n cylinders: 4,\n idleRpm: 800,\n redlineRpm: 6500,\n // a 5-speed hatch: 1st tops at ~13 m/s, 5th at ~50 m/s\n rpmPerMps: [500, 300, 205, 155, 125],\n layers: layers('car', [[220, 520], [420, 1300], [900, 2600]], [0.11, 0.075, 0.04]),\n load: { sound: 'engine_car_load', gain: 0.05, cutoff: [350, 1600] },\n closedThrottle: 0.55,\n}\n\n/** A six-cylinder diesel truck or bus: 650 to 2 600 rpm, low and clattering. */\nexport const TRUCK_ENGINE: EngineProfile = {\n id: 'truck',\n cylinders: 6,\n idleRpm: 650,\n redlineRpm: 2600,\n rpmPerMps: [420, 260, 170, 120, 90, 72],\n layers: layers('truck', [[160, 380], [300, 800], [600, 1500]], [0.13, 0.08, 0.035]),\n load: { sound: 'engine_truck_load', gain: 0.06, cutoff: [250, 900] },\n closedThrottle: 0.6,\n}\n\n/** A four-cylinder sport bike: 1 300 to 12 000 rpm, bright and fast to rev. */\nexport const BIKE_ENGINE: EngineProfile = {\n id: 'bike',\n cylinders: 4,\n idleRpm: 1300,\n redlineRpm: 12000,\n rpmPerMps: [900, 640, 500, 410, 350, 310],\n layers: layers('bike', [[350, 900], [700, 2200], [1500, 4200]], [0.08, 0.07, 0.05]),\n load: { sound: 'engine_bike_load', gain: 0.045, cutoff: [600, 2600] },\n closedThrottle: 0.5,\n}\n\nexport const ENGINE_PROFILES: Readonly<Record<string, EngineProfile>> = { car: CAR_ENGINE, truck: TRUCK_ENGINE, bike: BIKE_ENGINE }\n\n/** The fleet groups whose engine is a truck's (heavy trucks, buses, tractors) and a bike's (motorcycles); every other group is a car. */\nconst TRUCK_GROUPS: ReadonlySet<string> = new Set(['heavy', 'agricultural'])\n\n/** The engine profile of a fleet group (`ProvingSubject.category`): `motorcycles` a bike, `heavy` and `agricultural` a truck, the rest a car. */\nexport const engineProfileOfGroup = (group: string): EngineProfile => (group === 'motorcycles' ? BIKE_ENGINE : TRUCK_GROUPS.has(group) ? TRUCK_ENGINE : CAR_ENGINE)\n\n/** The horn of a fleet group: a motorcycle's thin beep, a truck's air horn, a car's. */\nexport const hornOfGroup = (group: string): string => (group === 'motorcycles' ? 'horn_bike' : TRUCK_GROUPS.has(group) ? 'horn_truck' : 'horn_car')\n","import { DEFAULT_VEHICLE_SOUND_KEYS } from '../audio/profiles'\nimport type { VehicleSoundKeys } from '../audio/profiles'\nimport type { EffectSink, Vec3 } from '@adatechnology/game-contracts'\nimport type { VehicleKit } from '@adatechnology/game-vehicles'\n\nimport type { VehicleFleetContent } from '../build'\n\n/** The fleet the area runs on: its palettes and sizes, and how it is installed in a kit (`defaultVehicleFleet()` of `game-kit-defaults`). */\nexport type VehiclesTestFleet = VehicleFleetContent & { installFleet(kit: VehicleKit): void }\n\n/** What the module needs of a document (canvas textures of the kit): a real `document`, or a stub in Node. */\nexport type DocumentLike = { createElement(tag: string): unknown }\n\n/** The host's effects (`host.effects`, an `EffectSink` of the contracts: `game-vfx-three` is one): the module asks by id and writes no particle code. */\nexport type EffectsLike = EffectSink\n\n/** The events the module turns into effect requests, and the effect id each one asks for. A game maps its own ids over these. */\nexport type VehicleEffectIds = {\n readonly ignite: string\n readonly explode: string\n readonly glass: string\n readonly sparks: string\n readonly leak: string\n /** The leak of a pierced tank caught fire: the whole sequence (fire along the pool, then the blast). `leak` is only the pool and the drips. */\n readonly leakIgnited: string\n readonly exhaust: string\n}\n\nexport const defaultEffectIds: VehicleEffectIds = {\n ignite: 'volumetric_fire',\n explode: 'car_fuel_tank',\n glass: 'glass_burst',\n sparks: 'impact_metal',\n leak: 'vehicle_leak',\n leakIgnited: 'vehicle_leak_ignited',\n exhaust: 'vehicle_exhaust',\n}\n\n/**\n * The sounds the module asks of `host.audio`, by id of the host's banks: the horn (placed at the car), and the vehicle's own sounds (`createVehicleSound`: the starter, the\n * crashes by speed, the tyres). The engine loops come from the engine profile.\n */\nexport type VehicleSoundIds = { readonly horn: string } & VehicleSoundKeys\n\nexport const defaultSoundIds: VehicleSoundIds = { horn: 'horn_car', ...DEFAULT_VEHICLE_SOUND_KEYS }\n\n/** A damaged vehicle of the area: the item id, the fleet vehicle it is built from and the scenario of the kit applied while building. */\nexport type VehicleWreck = { readonly key: string; readonly vehicle: string; readonly scenario: string }\n\nexport const DEFAULT_TEST_WRECKS: readonly VehicleWreck[] = [\n { key: 'sedan_burnt', vehicle: 'midsize_sedan', scenario: 'burnt' },\n { key: 'hatch_burnt', vehicle: 'compact_hatch', scenario: 'burnt' },\n]\n\nexport type VehiclesTestOptions = {\n /**\n * The fleet content: paint palettes, measured sizes and the install into the default kit (`defaultVehicleFleet()` of `game-kit-defaults`). Default the ones of `game-vehicles-fleet`.\n * @deprecated pass `fleet`; the default is removed in the next major.\n */\n readonly fleet?: VehiclesTestFleet\n /** `en` or `pt-BR` (default). */\n readonly locale?: string\n /** The kit the vehicles are built with, per three.js namespace. Default: `createVehicleKit` with the fleet installed (`fleet.installFleet`). */\n readonly createKit?: (THREE: unknown) => VehicleKit\n readonly document?: DocumentLike\n /** The three.js namespace the door, hood and trunk clips are computed with (they are plain numbers, so any copy works). Default: the global `THREE`; without either the items bring no clips. */\n readonly three?: unknown\n /** The vehicles to lay out, as fleet ids (default the 8 of the Frota test: hatch, sedan, pickup, sport bike, box truck, city bus, battle tank, attack helicopter). */\n readonly vehicles?: readonly string[]\n /** Wrecks laid out after the vehicles: item `key` is the fleet vehicle `vehicle` built with the registered damage `scenario` (default `sedan_burnt` and `hatch_burnt`, the fleet's `burnt`; an empty list lays none). */\n readonly wrecks?: readonly VehicleWreck[]\n /** Effect ids requested through `host.effects` (the defaults are ids of `game-vfx`: the Garagem's `car_fuel_tank` blast, the `vehicle_fire`, `vehicle_leak` (pool and drips only), `vehicle_leak_ignited` (the whole sequence) and `vehicle_exhaust` recipes written around a car from `engine_smoke` and `fuel_leak`, and the point-based `glass_burst` and `impact_metal`). */\n readonly effects?: Partial<VehicleEffectIds>\n /** Sound ids requested through `host.audio` (the defaults: the vehicle bank of this package). */\n readonly sounds?: Partial<VehicleSoundIds>\n /** Crash wall builder for the driving lane (`wallPiece` from `@adatechnology/game-floorplan-three`, base at origin along x). Omitted: no wall mesh drawn. */\n readonly wall?: (three: unknown, spec: { readonly length: number; readonly height: number; readonly thickness: number }) => unknown\n}\n\n/** The part of the test room the scenarios use (the room's `ScenarioContext.room` has all of it). */\nexport type PartView = {\n holes: { through?: boolean }[]\n cracks: unknown[]\n dents: unknown[]\n status: string\n hp: number\n maxHp: number\n temperature: number\n burning: boolean\n liters: number\n melt: number\n}\n\nexport type SpawnedVehicle = { objectId: string; root: { userData: Record<string, unknown> } }\n\nexport type VehiclesRoom = {\n spawn(item: string, position?: Vec3, rotationY?: number): SpawnedVehicle\n setTool(weaponId: string): void\n /** Lets the tool in hand finish its draw time (the room's rule: a weapon cannot fire the moment it is taken). */\n waitUntilReady(): void\n look(position: Vec3, target: Vec3): void\n use(hold?: number): void\n playAnimation(clipId: string, objectId?: string): boolean\n world: {\n part(object: string, part: string): PartView\n hit(object: string, hit: Record<string, unknown>): unknown\n disassemble(object: string, joint: string, tool: string, dt: number): number\n state(object: string): { joints: { id: string; open: boolean }[]; groups: unknown[][] }\n }\n log: { entries(filter: { type?: string; objectId?: string }): readonly unknown[] }\n}\n\n/** What a scenario needs of the room: the pass/fail line, time, and the room for the ones that shoot and hit. */\nexport type VehiclesContext = {\n room: VehiclesRoom\n expect(condition: boolean, label: string, data?: Record<string, unknown>): void\n step(seconds: number): void\n}\n","import type { EngineProfile } from './profiles'\n\n/** What one engine loop is set to this frame. `frequency` is absent for the load layer (noise has no pitch). */\nexport type EngineLayerSetting = { readonly sound: string; readonly volume: number; readonly frequency?: number; readonly cutoff: number }\n\nexport type EngineMixInput = {\n readonly rpm: number\n /** 0..1, how open the throttle is (the engine's load). */\n readonly throttle: number\n}\n\nconst clamp01 = (v: number): number => (v < 0 ? 0 : v > 1 ? 1 : v)\n\n/** The firing frequency of a four-stroke engine, Hz: every cylinder fires once every two turns. */\nexport const firingHz = (profile: EngineProfile, rpm: number): number => (rpm / 60) * (profile.cylinders / 2)\n\n/** RPM as a share of the range: 0 at idle, 1 at the redline. */\nexport const rpmShare = (profile: EngineProfile, rpm: number): number => clamp01((rpm - profile.idleRpm) / (profile.redlineRpm - profile.idleRpm))\n\n/** Equal-power weight of a layer centred at `centre` with `width` at the normalised RPM `n`. */\nexport const layerWeight = (centre: number, width: number, n: number): number => {\n const d = Math.abs(n - centre) / width\n return d >= 1 ? 0 : Math.cos((d * Math.PI) / 2)\n}\n\n/**\n * The engine's loops for an RPM and a throttle: every tone layer at the firing frequency times its harmonic, faded in and out across the RPM range so\n * the sum stays even, louder and brighter under load; the load layer opens with the throttle. A stopped engine (`rpm` 0) is silent.\n */\nexport function engineMix(profile: EngineProfile, input: EngineMixInput): EngineLayerSetting[] {\n const throttle = clamp01(input.throttle)\n const on = input.rpm > 0\n const n = rpmShare(profile, input.rpm)\n const level = on ? profile.closedThrottle + (1 - profile.closedThrottle) * throttle : 0\n const open = 0.5 * n + 0.5 * throttle\n const hz = firingHz(profile, input.rpm)\n const tones = profile.layers.map((layer) => ({\n sound: layer.sound,\n volume: layer.gain * level * layerWeight(layer.centre, layer.width, n),\n frequency: hz * layer.harmonic,\n cutoff: layer.cutoff[0] + (layer.cutoff[1] - layer.cutoff[0]) * open,\n }))\n const load = profile.load\n return [\n ...tones,\n { sound: load.sound, volume: on ? load.gain * (0.15 + 0.85 * throttle) * (0.35 + 0.65 * n) : 0, cutoff: load.cutoff[0] + (load.cutoff[1] - load.cutoff[0]) * open },\n ]\n}\n\n/**\n * A guess of the RPM from the speed for a driver without an engine model: the gear is kept between calls (up above 85% of the redline, down below\n * 40%), so the RPM climbs and drops at each shift as it does in a real car.\n */\nexport function createGearGuess(profile: EngineProfile): { rpm(speed: number, throttle: number): number; readonly gear: number } {\n let gear = 0\n return {\n rpm(speed, throttle) {\n const v = Math.abs(speed)\n const ratios = profile.rpmPerMps\n if (v < 0.3) {\n gear = 0\n return profile.idleRpm + (profile.redlineRpm - profile.idleRpm) * 0.12 * clamp01(throttle)\n }\n const at = (g: number): number => v * (ratios[g] as number)\n while (gear < ratios.length - 1 && at(gear) > profile.redlineRpm * 0.85) gear++\n while (gear > 0 && at(gear) < profile.redlineRpm * 0.4) gear--\n return Math.max(profile.idleRpm, Math.min(profile.redlineRpm, at(gear)))\n },\n get gear() {\n return gear\n },\n }\n}\n","import type { AudioSink, LoopHandle, Vec3 } from '@adatechnology/game-contracts'\n\nimport type { EngineBudget } from './engine-budget'\nimport { createGearGuess, engineMix } from './engine-mix'\nimport { CAR_ENGINE, CRASH_SPEEDS, DEFAULT_VEHICLE_SOUND_KEYS, TRUCK_ENGINE } from './profiles'\nimport type { EngineProfile, VehicleSoundKeys } from './profiles'\n\n/** What the vehicle is doing this frame. Without `rpm` (a driver with no engine model) the RPM is guessed from the speed through the profile's gears. */\nexport type VehicleSoundFrame = {\n readonly dt: number\n readonly position: Vec3\n /** m/s, signed or not. */\n readonly speed: number\n /** 0..1. */\n readonly throttle: number\n readonly rpm?: number\n /** 0..1: how much the tyres slide (the largest wheel slip; 1 = locked or spinning). */\n readonly slip?: number\n /** What the tyres are on: `dirt` for earth, gravel, sand or grass; anything else squeals as asphalt. */\n readonly surface?: 'asphalt' | 'dirt'\n /** 0..1, how hard the brakes are pressed: the pads squeal as the car comes to a stop without skidding. */\n readonly brake?: number\n /** An emergency vehicle's siren: `wail` sweeps 650–1500 Hz in ~4 s, `yelp` in a quarter second; absent or `off`, silent. */\n readonly siren?: 'off' | 'wail' | 'yelp'\n /** 0..1, how fast a helicopter's rotor turns (the blades spool up and down with it). */\n readonly rotor?: number\n}\n\nexport type VehicleSoundOptions = {\n readonly profile?: EngineProfile\n /** Any of the one-shot and tyre ids, pointed at other sounds. */\n readonly sounds?: Partial<VehicleSoundKeys>\n /** Seconds the starter turns before the engine catches (the `engine_start` recipe catches at 0.75 s). */\n readonly crankSeconds?: number\n /** Shared by the vehicles of a scene: only the nearest few keep their loops (`createEngineBudget`). */\n readonly budget?: EngineBudget\n /** Lets the brake chambers out as the vehicle stops on the brakes (a truck's air brakes). Default: only for the truck profile. */\n readonly airBrake?: boolean\n}\n\n/** What was asked of the sink, for the checks and the bench: the RPM in use and the level of each loop. */\nexport type VehicleSoundReading = {\n readonly running: boolean\n readonly rpm: number\n readonly levels: Readonly<Record<string, number>>\n}\n\nexport type VehicleSound = {\n /** Turns the key: the starter, then the engine catches with a flare of RPM. `fail` cranks without catching (no fuel, a dead engine). */\n start(position: Vec3, options?: { readonly fail?: boolean }): void\n /** Ignition off: the engine runs down. */\n stop(position: Vec3): void\n /** A hit at `speed` m/s: light, medium or heavy by speed, louder with it. */\n crash(speed: number, position: Vec3): 'light' | 'medium' | 'heavy'\n /** A body hit at `speed` m/s (a person, an animal; `sound` names another id, a zombie in a game), louder with the speed. */\n hit(speed: number, position: Vec3, sound?: string): void\n update(frame: VehicleSoundFrame): void\n readonly reading: VehicleSoundReading\n dispose(): void\n}\n\nconst clamp01 = (v: number): number => (v < 0 ? 0 : v > 1 ? 1 : v)\n\n/**\n * A tyre's slide for `VehicleSoundFrame.slip`, from how much of its grip it uses (the semi driver's `state.slip`: force over what the tyre\n * holds, 1 = saturated). A tyre pulling hard but still holding is silent; it squeals only near the limit and slides fully once saturated,\n * so full throttle that the tyre carries is no skid, and wheelspin or a locked wheel is.\n */\nexport const slideOfGrip = (usage: number): number => clamp01((Math.abs(usage) - 0.9) / 0.1)\n\n/**\n * The sounds of one vehicle on a host's sink (`ModuleHost.audio`): the engine loops by RPM and load, the starter, the tyres skidding and rolling,\n * and crashes by speed. The loops are placed at the vehicle every frame (distance and side come from the sink). Works without a sink (silent).\n */\nexport function createVehicleSound(audio: AudioSink | undefined, options: VehicleSoundOptions = {}): VehicleSound {\n const profile = options.profile ?? CAR_ENGINE\n const keys = { ...DEFAULT_VEHICLE_SOUND_KEYS, ...options.sounds }\n const crankSeconds = options.crankSeconds ?? 0.75\n const airBrake = options.airBrake ?? profile.id === TRUCK_ENGINE.id\n const gears = createGearGuess(profile)\n const loops = new Map<string, LoopHandle>()\n const budget = options.budget\n // the key the budget knows this vehicle by\n const self = {}\n const levels: Record<string, number> = {}\n // running: the engine turns; cranking counts down the starter; flare is the RPM the engine overshoots to as it catches\n const state = { running: false, cranking: 0, catches: false, flare: 0, rpm: 0, sirenPhase: 0, rolling: false }\n\n const loopOf = (sound: string): LoopHandle | undefined => {\n let handle = loops.get(sound)\n if (!handle && audio?.loop) {\n handle = audio.loop(sound)\n loops.set(sound, handle)\n }\n return handle\n }\n const setLoop = (sound: string, volume: number, position: Vec3, extra: { frequency?: number; cutoff?: number } = {}): void => {\n levels[sound] = volume\n // a silent loop that was never made stays unmade\n if (volume <= 0 && !loops.has(sound)) return\n loopOf(sound)?.set({ volume, position, ...(extra.frequency === undefined ? {} : { frequency: extra.frequency }), ...(extra.cutoff === undefined ? {} : { params: { cutoff: extra.cutoff } }) })\n }\n const play = (sound: string, position: Vec3, volume = 1): void => void audio?.play({ sound, position, volume })\n\n return {\n start(position, startOptions = {}) {\n if (state.running || state.cranking > 0) return\n state.catches = !startOptions.fail\n state.cranking = state.catches ? crankSeconds : 1.7\n play(state.catches ? keys.start : keys.fail, position)\n },\n stop(position) {\n if (!state.running && state.cranking <= 0) return\n state.running = false\n state.cranking = 0\n play(keys.stop, position)\n },\n crash(speed, position) {\n const v = Math.abs(speed)\n const kind = v >= CRASH_SPEEDS.heavy ? 'heavy' : v >= CRASH_SPEEDS.medium ? 'medium' : 'light'\n play(kind === 'heavy' ? keys.crashHeavy : kind === 'medium' ? keys.crashMedium : keys.crashLight, position, Math.min(1, 0.35 + v / 20))\n return kind\n },\n hit(speed, position, sound) {\n const v = Math.abs(speed)\n if (v < 0.5) return\n play(sound ?? keys.hitBody, position, Math.min(1, 0.3 + v / 15))\n },\n update(frame) {\n if (state.cranking > 0) {\n state.cranking -= frame.dt\n if (state.cranking <= 0 && state.catches) {\n state.running = true\n state.flare = 1\n }\n }\n state.flare = Math.max(0, state.flare - frame.dt / 0.9)\n const throttle = clamp01(frame.throttle)\n const driven = frame.rpm ?? gears.rpm(frame.speed, throttle)\n // as it catches the engine overshoots to ~2.2× idle and settles back\n const rpm = state.running ? Math.max(driven, profile.idleRpm * (1 + 1.2 * state.flare * state.flare)) : 0\n state.rpm = rpm\n // out of the budget (too many vehicles nearer the listener) every loop goes quiet; the state above keeps running so it comes back in step\n const heard = budget ? (budget.admit(self, frame.position) ? 1 : 0) : 1\n for (const layer of engineMix(profile, { rpm, throttle: Math.max(throttle, state.flare * 0.6) })) {\n setLoop(layer.sound, heard * layer.volume, frame.position, { ...(layer.frequency === undefined ? {} : { frequency: layer.frequency }), cutoff: layer.cutoff })\n }\n const speed = Math.abs(frame.speed)\n // a slide squeals once the slip passes ~15% and the car moves; on dirt it is a hiss, not a squeal\n const slide = clamp01(((frame.slip ?? 0) - 0.15) / 0.5) * clamp01(speed / 4)\n const dirt = frame.surface === 'dirt'\n setLoop(keys.skidAsphalt, heard * (dirt ? 0 : 0.16 * slide), frame.position, { cutoff: 1700 + 600 * slide })\n setLoop(keys.skidDirt, heard * (dirt ? 0.2 * slide : 0), frame.position, { cutoff: 500 + 500 * slide })\n // road noise grows with the speed and gets brighter\n setLoop(keys.roll, heard * (dirt ? 0 : 0.06 * clamp01(speed / 25)), frame.position, { cutoff: 250 + 45 * Math.min(speed, 40) })\n setLoop(keys.rollDirt, heard * (dirt ? 0.1 * clamp01(speed / 20) : 0), frame.position, { cutoff: 700 + 60 * Math.min(speed, 30) })\n // a truck that stops on its brakes lets the air out of its chambers once\n if (airBrake) {\n if (speed > 2) state.rolling = true\n else if (state.rolling && speed < 0.8) {\n // a truck that coasted to rest without the brakes has nothing to let out: a later press while parked stays silent\n state.rolling = false\n if ((frame.brake ?? 0) > 0.3 && heard > 0) play(keys.airBrake, frame.position, 0.8)\n }\n }\n // the pads squeal in the last metres of a stop on the brakes, while the tyres still grip (a skid is the tyres' sound, not the pads')\n const squeal = clamp01(((frame.brake ?? 0) - 0.3) / 0.4) * clamp01(speed / 0.8) * clamp01((5 - speed) / 2) * (slide > 0 ? 0 : 1)\n setLoop(keys.brakeSqueal, heard * 0.05 * squeal, frame.position, { cutoff: 3200 + 400 * squeal })\n // the siren's sweep is a triangle in time: up and down between 650 and 1500 Hz\n const siren = frame.siren ?? 'off'\n if (siren !== 'off' || loops.has(keys.siren)) {\n const period = siren === 'yelp' ? 0.25 : 4\n state.sirenPhase = (state.sirenPhase + frame.dt / period) % 1\n const tri = state.sirenPhase < 0.5 ? state.sirenPhase * 2 : 2 - state.sirenPhase * 2\n setLoop(keys.siren, heard * (siren === 'off' ? 0 : 0.07), frame.position, { frequency: 650 + 850 * tri, cutoff: 2600 })\n }\n const rotor = clamp01(frame.rotor ?? 0)\n setLoop(keys.rotor, heard * 0.12 * rotor, frame.position, { cutoff: 180 + 220 * rotor })\n },\n get reading() {\n return { running: state.running, rpm: state.rpm, levels: { ...levels } }\n },\n dispose() {\n budget?.release(self)\n for (const handle of loops.values()) handle.stop()\n loops.clear()\n },\n }\n}\n","// The vehicle sounds as recipes of @adatechnology/game-audio, made by the kit (no team delivered vehicle sounds beyond the game's saw, horn and crash):\n// engines as loops crossfaded by RPM, the starter, tyres, crashes by speed and the doors, hood and trunk of a car. The ids follow the sound list\n// (`sons/checklist-sons.md`, 5.6), so a recorded loop or one-shot replaces a recipe by registering the same id.\nimport { sceneMany as many, sceneNoise as noise, sceneRecipe, sceneTone as tone } from '@adatechnology/game-audio'\nimport type { Falloff, Layer, LoopRecipe, SampleAlias, SoundBank, SoundRecipe } from '@adatechnology/game-audio'\n\nimport { firingHz } from './engine-mix'\nimport { BIKE_ENGINE, CAR_ENGINE, TRUCK_ENGINE } from './profiles'\nimport type { EngineProfile } from './profiles'\n\n/** How a vehicle loop falls off: `1 / (1 + d² × 0.004)`, the game's one-shot curve, with the cutoff muffled by `1 + d × 0.01` (a car far away is dull). */\nexport const VEHICLE_LOOP_FALLOFF: Falloff = { model: 'inverse_square', k: 0.004, cutoffK: 0.01 }\n\nconst SDK = 'sdk: vehicle sounds (sons/checklist-sons.md 5.6)'\n\n// the loops are set every frame by the vehicle: short time constants, so the pitch follows the RPM through a shift\nconst SMOOTHING = { volume: 0.06, frequency: 0.04 } as const\n\nconst toneLoop = (id: string, wave: OscillatorType, filter: BiquadFilterType, cutoff: number, q: number, line: string): LoopRecipe => ({\n id,\n bus: 'world',\n order: 'game_loop',\n source: { kind: 'osc', wave, loop: true },\n filters: { mode: 'serial', bank: [{ type: filter, frequency: { set: cutoff }, q }] },\n smoothing: SMOOTHING,\n falloff: VEHICLE_LOOP_FALLOFF,\n pan: true,\n sources: [SDK, line],\n})\n\nconst noiseLoop = (id: string, filter: BiquadFilterType, cutoff: number, q: number, line: string): LoopRecipe => ({\n id,\n bus: 'world',\n order: 'game_loop',\n source: { kind: 'noise', offset: 'random', loop: true },\n filters: { mode: 'serial', bank: [{ type: filter, frequency: { set: cutoff }, q }] },\n smoothing: SMOOTHING,\n falloff: VEHICLE_LOOP_FALLOFF,\n pan: true,\n sources: [SDK, line],\n})\n\nconst engineLoops = (id: string, low: number, mid: number, high: number, load: number): LoopRecipe[] => [\n toneLoop(`engine_${id}_low`, 'sawtooth', 'lowpass', low, 1.4, 'idle and low RPM: the firing frequency, a saw through a low-pass'),\n toneLoop(`engine_${id}_mid`, 'square', 'lowpass', mid, 0.9, 'mid RPM: odd harmonics, the bark'),\n toneLoop(`engine_${id}_high`, 'sawtooth', 'bandpass', high, 1.2, 'high RPM: the second harmonic through a band-pass, the scream near the redline'),\n noiseLoop(`engine_${id}_load`, 'bandpass', load, 0.8, 'intake and exhaust roar, opened by the throttle'),\n]\n\n/** The engines (car, truck, bike) and the tyres, as loops. */\nexport const VEHICLE_LOOPS: readonly LoopRecipe[] = [\n ...engineLoops('car', 400, 900, 1600, 700),\n ...engineLoops('truck', 280, 600, 1000, 500),\n ...engineLoops('bike', 600, 1400, 2800, 1200),\n noiseLoop('tire_skid_asphalt', 'bandpass', 1900, 5, 'rubber squealing on asphalt: a narrow band of noise near 2 kHz'),\n noiseLoop('tire_skid_dirt', 'lowpass', 700, 0.8, 'tyres sliding on dirt and gravel: a dull, wide hiss'),\n noiseLoop('tire_roll', 'lowpass', 400, 0.7, 'road noise of the tyres rolling, brighter with the speed'),\n noiseLoop('tire_roll_gravel', 'bandpass', 1400, 0.6, 'tyres rolling on gravel: a wide crunching hiss, louder with the speed'),\n // a pad on a disc: a thin, nearly pure whistle near 3.4 kHz (a narrow band of noise, so it wavers as a real squeal does)\n // a siren: a square through a low-pass, its pitch swept by the vehicle every frame (wail: a slow rise and fall; yelp: a fast one)\n toneLoop('siren', 'square', 'lowpass', 2600, 0.8, 'emergency siren, the sweep driven by the vehicle'),\n // the blades: a low rumble chopped at the blade-pass rate (≈ 18 Hz for a light helicopter's main rotor)\n {\n ...noiseLoop('helicopter_rotor_loop', 'lowpass', 320, 0.9, 'helicopter rotor: low rumble chopped by the blades'),\n modulators: [{ target: 'gain', wave: 'sine', rate: 18, depth: 0.45, base: 0.55 }],\n },\n noiseLoop('brake_squeal', 'bandpass', 3400, 28, 'brake pads squealing on the discs as the car comes to a stop'),\n]\n\nconst recipe = (id: string, layers: readonly Layer[], line: string): SoundRecipe => ({ ...sceneRecipe(id, layers, line), sources: [SDK, line] })\n\n// the starter turning the engine over: a compression pulse every ~0.1 s and the motor's whine\nconst crank = (count: number, spacing: number): Layer[] => [\n { ...noise({ type: 'bandpass', f: [300, 380], q: 1.5, d: 0.07, vol: 0.45 }), repeat: { count, spacing } },\n tone({ wave: 'sawtooth', f: 95, f2: count > 8 ? 70 : 110, d: count * spacing, vol: 0.035 }),\n]\n\n// a latch: a short click and a tiny ring\nconst latch = (delay: number, vol: number): Layer[] => [\n noise({ type: 'bandpass', f: [2600, 3200], q: 3, d: 0.018, vol, delay }),\n tone({ f: 1300, f2: 1180, d: 0.025, vol: vol * 0.15, delay: delay + 0.004 }),\n]\n\n/** The one-shots: the starter, the engine stopping, crashes by speed, and the doors, trunk and hood of a car. */\nexport const VEHICLE_SOUNDS: readonly SoundRecipe[] = [\n // the engine catches at 0.75 s: the loops take over from there (the vehicle flares the RPM)\n recipe('engine_start', [...crank(7, 0.105), tone({ wave: 'sawtooth', f: 45, f2: 27, d: 0.35, vol: 0.3, delay: 0.72 }), noise({ f: 260, d: 0.3, vol: 0.35, delay: 0.72 })], 'starter cranking, then the engine catches'),\n recipe('engine_fail', [...crank(13, 0.125), ...latch(1.65, 0.2)], 'starter cranking slower and slower, the engine never catches, the key released'),\n recipe('engine_stop', [tone({ wave: 'sawtooth', f: 27, f2: 8, d: 0.45, vol: 0.3 }), noise({ f: 200, f2: 60, d: 0.4, vol: 0.32 }), noise({ type: 'bandpass', f: 120, q: 2, d: 0.12, vol: 0.3, delay: 0.32 })], 'ignition off: the engine runs down and shudders to a stop'),\n // light: a dent and plastic giving; medium: the body folding and a pane cracking; heavy: metal folding, glass going, debris falling\n recipe(\n 'crash_light',\n [tone({ f: 110, f2: 55, d: 0.16, vol: 0.7 }), noise({ type: 'bandpass', f: 1100, q: 1, d: 0.18, vol: 0.85, wet: 0.2 }), noise({ type: 'highpass', f: 2500, d: 0.05, vol: 0.45 }), ...many(3, () => noise({ type: 'bandpass', f: [1800, 3200], q: 3, d: 0.03, vol: 0.2, delay: [0.03, 0.2] }))],\n 'crash below 22 km/h: bumper and plastic, a dull dent',\n ),\n recipe(\n 'crash_medium',\n [\n tone({ f: 85, f2: 38, d: 0.3, vol: 1.1 }),\n noise({ type: 'bandpass', f: 700, q: 0.9, d: 0.5, vol: 0.8, wet: 0.3 }),\n ...many(5, () => noise({ type: 'bandpass', f: [500, 1300], q: 2, d: [0.08, 0.18], vol: 0.55, delay: [0, 0.35] })),\n ...many(6, () => tone({ f: [3500, 7000], d: 0.06, vol: 0.08, delay: [0.05, 0.5] })),\n ],\n 'crash at 22–50 km/h: the body folding, a pane cracking',\n ),\n recipe(\n 'crash_heavy',\n [\n tone({ f: 65, f2: 28, d: 0.6, vol: 1.5 }),\n noise({ f: 900, f2: 150, d: 0.9, vol: 1.3, wet: 0.5 }),\n ...many(9, () => noise({ type: 'bandpass', f: [300, 1200], q: 2, d: [0.1, 0.25], vol: 0.6, delay: [0, 0.7] })),\n noise({ type: 'highpass', f: 3200, d: 0.5, vol: 0.7, delay: 0.03, wet: 0.4 }),\n ...many(14, () => tone({ f: [3000, 7500], d: [0.05, 0.12], vol: 0.12, delay: [0.05, 1.2] })),\n ...many(6, () => noise({ type: 'bandpass', f: [1500, 3000], q: 2, d: 0.04, vol: 0.25, delay: [0.5, 1.5] })),\n ],\n 'crash above 50 km/h: metal folding, the glass going, debris falling',\n ),\n // a body hit by a car: the dull slap of the bumper on a person, the body folding over the bonnet, at speed a crack of the windscreen\n recipe(\n 'vehicle_hit_pedestrian',\n [\n tone({ f: 95, f2: 50, d: 0.14, vol: 0.9 }),\n noise({ type: 'lowpass', f: 600, d: 0.12, vol: 0.8 }),\n noise({ type: 'bandpass', f: 280, q: 1.2, d: 0.18, vol: 0.55, delay: 0.09 }),\n noise({ type: 'highpass', f: 2600, d: 0.05, vol: 0.18, delay: 0.1 }),\n ],\n 'a person hit by a car: the bumper slap, the body on the bonnet',\n ),\n // the game's horn (two squares at 415 and 523 Hz, jogo L70272) heard from where the car is; a truck's air horn lower and longer\n recipe('horn_car', [tone({ wave: 'square', f: 415, d: 0.6, vol: 0.09 }), tone({ wave: 'square', f: 523, d: 0.6, vol: 0.09 })], 'car horn: the game chord, placed and panned'),\n recipe('horn_truck', [tone({ wave: 'sawtooth', f: 220, d: 1.1, vol: 0.1 }), tone({ wave: 'sawtooth', f: 277, d: 1.1, vol: 0.08 }), noise({ type: 'bandpass', f: 900, q: 2, d: 1.1, vol: 0.05 })], 'truck air horn: low reedy chord'),\n recipe('horn_bike', [tone({ wave: 'square', f: 620, d: 0.35, vol: 0.07 }), tone({ wave: 'square', f: 780, d: 0.35, vol: 0.07 })], 'motorcycle horn: a short, thin two-note beep'),\n // the compressed air let out of a truck's brake chambers as it stops: a hiss that dies away\n recipe('air_brake', [noise({ type: 'highpass', f: 2200, a: 0.01, d: 1.1, vol: 0.28 }), noise({ type: 'bandpass', f: 900, q: 0.8, d: 0.35, vol: 0.2 }), tone({ f: 120, f2: 70, d: 0.12, vol: 0.2 })], 'air brakes: the chambers venting as the truck stops'),\n // a car door is a padded \"tum\" with a latch, not a hollow metal box (the fridge's shut_metal)\n recipe('car_door_open', [...latch(0, 0.32), noise({ f: 400, d: 0.06, vol: 0.14, delay: 0.035 })], 'car door: the handle pulled, the latch released, the seal letting go'),\n recipe('car_door_close', [tone({ f: 75, f2: 48, d: 0.16, vol: 0.75 }), noise({ f: 320, d: 0.1, vol: 0.6 }), ...latch(0.012, 0.3)], 'car door shut: a dull padded thump and the latch catching'),\n recipe('car_trunk_close', [tone({ f: 90, f2: 55, d: 0.15, vol: 0.65 }), noise({ type: 'bandpass', f: 500, q: 1, d: 0.12, vol: 0.5 }), ...latch(0.01, 0.28), noise({ type: 'bandpass', f: 1800, q: 3, d: 0.04, vol: 0.1, delay: 0.06 })], 'trunk or hatch shut: a lighter thump, the latch and a small rattle'),\n recipe('car_hood_open', [...latch(0, 0.3), tone({ f: [180, 230], f2: 140, d: 0.3, vol: 0.04, delay: 0.06 }), noise({ type: 'bandpass', f: 700, q: 2, d: 0.25, vol: 0.12, delay: 0.05 })], 'hood released: the latch giving and the lid rising a little on its springs'),\n recipe('car_hood_close', [tone({ f: 70, f2: 40, d: 0.22, vol: 0.8 }), noise({ type: 'bandpass', f: 850, q: 1.4, d: 0.2, vol: 0.6, wet: 0.3 }), tone({ f: 900, f2: 860, d: 0.18, vol: 0.05 }), ...latch(0.015, 0.3)], 'hood slammed: a big sheet of metal ringing a little, the latch'),\n]\n\n/**\n * The RPM each car recording runs at, measured on the files (the crank turning at 16.7 and 42 Hz, the firing at four times that: a V8). A layer\n * plays its file at `rpm / recorded rpm`.\n */\nexport const CAR_RECORDED_RPM = { idle: 1000, high: 2520 } as const\n\n/** Where the start and the stop sit in the recording of a car starting, running and stopping (`engine_start_run_stop`), in seconds. */\nexport const CAR_START_RUN_STOP = {\n /** The take the times below were measured on. */\n take: '_01.',\n /** The starter and the engine catching (at 0.58 s) and flaring; the loops take over at the crank time of the vehicle. */\n start: { offset: 0, duration: 1.3 },\n /** The ignition off: the engine running down to the end of the file. */\n stop: { offset: 9.96, duration: 0.64 },\n} as const\n\n/** A layer of another engine profile read from its idle recording, played at the pitch it was recorded at when the engine idles. */\nconst idleLayer = (id: string, file: string, rpm: number, profile: EngineProfile): SampleAlias => ({\n id,\n file,\n loop: true,\n baseFrequency: firingHz(profile, rpm),\n falloff: VEHICLE_LOOP_FALLOFF,\n})\n\nconst carLayer = (id: string, file: string, rpm: number, harmonic: number, offset?: number): SampleAlias => ({\n id,\n file,\n loop: true,\n // the layer's oscillator plays the firing frequency times its harmonic: the file sounds at that frequency for the RPM it was recorded at\n baseFrequency: firingHz(CAR_ENGINE, rpm) * harmonic,\n falloff: VEHICLE_LOOP_FALLOFF,\n ...(offset === undefined ? {} : { offset }),\n})\n\n/**\n * The vehicle ids answered by the recordings of the kit's manifest (files kept by the game, never in the SDK): the car engine layers by RPM, the\n * start and the stop cut out of one recording, the door, the trunk and the hood, the crashes, the tyres on asphalt and on gravel, and the idle of a\n * truck and of a motorcycle. Each recipe above stays as the fallback while the files load or where the game has none. `car_door_open`, `car_hood_open`,\n * `air_brake` and the horns (`horn_car`, `horn_truck`, `horn_bike`) are file ids of their own and need no alias.\n */\nexport const VEHICLE_SAMPLE_ALIASES: readonly SampleAlias[] = [\n carLayer('engine_car_low', 'engine_loop_car_idle', CAR_RECORDED_RPM.idle, 1),\n carLayer('engine_car_mid', 'engine_loop_car_high', CAR_RECORDED_RPM.high, 1),\n // the same file as the mid layer, read from two seconds in, so the two do not sum in phase where they cross\n carLayer('engine_car_high', 'engine_loop_car_high', CAR_RECORDED_RPM.high, 2, 2),\n // the cut points are of take _01 (10.6 s); _02 (21.9 s) starts already running and idles at 9.96 s, so it is left out of both\n { id: 'engine_start', file: 'engine_start_run_stop', only: CAR_START_RUN_STOP.take, ...CAR_START_RUN_STOP.start, falloff: VEHICLE_LOOP_FALLOFF },\n { id: 'engine_stop', file: 'engine_start_run_stop', only: CAR_START_RUN_STOP.take, ...CAR_START_RUN_STOP.stop, falloff: VEHICLE_LOOP_FALLOFF },\n { id: 'car_door_close', file: 'car_door_shut' },\n { id: 'car_trunk_close', file: 'car_trunk_shut' },\n { id: 'car_hood_close', file: 'car_hood_shut' },\n // a crash by speed: a dent in the plastic, the body folding, the wreck (file ids that are not the recipes' own: `crash_light` and its kin would read as tiers of `crash`)\n { id: 'crash_light', file: 'crash_dent' },\n { id: 'crash_medium', file: 'crash_fold' },\n { id: 'crash_heavy', file: 'crash_wreck' },\n // tyres: the squeal of rubber on asphalt and the crunch of gravel, chained like the engines\n { id: 'tire_skid_asphalt', file: 'tire_skid_asphalt_loop', loop: { crossfade: 0.6 }, falloff: VEHICLE_LOOP_FALLOFF },\n { id: 'tire_roll_gravel', file: 'tire_roll_gravel_loop', loop: { crossfade: 0.6 }, falloff: VEHICLE_LOOP_FALLOFF },\n // the idle of a truck and of a motorcycle, at the profile's idle RPM (the take plays at its own pitch there); the other layers stay on their recipes\n idleLayer('engine_truck_low', 'engine_loop_truck_idle', TRUCK_ENGINE.idleRpm, TRUCK_ENGINE),\n idleLayer('engine_bike_low', 'engine_loop_bike_idle', BIKE_ENGINE.idleRpm, BIKE_ENGINE),\n]\n\n/** The ids a host should decode as the vehicles load (`AudioSink.preload`): every aliased recording and the door's own file id. */\nexport const VEHICLE_PRELOAD_SOUNDS: readonly string[] = [...VEHICLE_SAMPLE_ALIASES.map((alias) => alias.id), 'car_door_open', 'car_hood_open', 'horn_car', 'horn_truck', 'horn_bike', 'air_brake']\n\nexport const VEHICLE_SOUND_BANK: SoundBank = { id: 'vehicles_three', sounds: VEHICLE_SOUNDS, loops: VEHICLE_LOOPS, sampleAliases: VEHICLE_SAMPLE_ALIASES }\n","import { createVehicleCamera, defaultEye, mirrorPoses } from '@adatechnology/game-camera'\nimport type { MirrorPose, VehicleCameraMode, VehicleFrame, VehicleThreeLib } from '@adatechnology/game-camera'\nimport { markKitOrigin } from '@adatechnology/game-contracts'\nimport type * as THREE_NS from 'three'\nimport type { CanvasTexture, Group, Mesh, MeshStandardMaterial, Object3D, PerspectiveCamera, PlaneGeometry } from 'three'\nimport type { BenchChange, ModuleArea, ModuleControl, ModuleHost, ModuleLayer, ModuleMetric, ModuleScenario, TestableModule } from '@adatechnology/game-contracts'\nimport { CABIN_BANK, LIBRARY_BANK, RADIO_BANK } from '@adatechnology/game-audio'\nimport type { VehicleKit } from '@adatechnology/game-vehicles'\nimport { createSemiSimDriver } from '@adatechnology/game-vehicles-driving'\nimport type { SemiDriver, StorageStack } from '@adatechnology/game-vehicles-driving'\nimport { certify, createProvingTests, startRun, STEPS_PER_TICK, statusOf, subjectSpec, withResult } from '@adatechnology/game-vehicles-proving'\nimport type { ProvingCertificate, ProvingResult, ProvingRun, ProvingSubject, ProvingTestRegistry } from '@adatechnology/game-vehicles-proving'\nimport { discardObject3D } from '@adatechnology/game-shapes-three'\n\nimport { createVehiclesThree } from '../../build'\nimport type { BuiltVehicle } from '../../build'\nimport { defaultSoundIds } from '../types'\nimport { createVehicleSound, slideOfGrip } from '../../audio/vehicle-sound'\nimport type { VehicleSound } from '../../audio/vehicle-sound'\nimport type { VehicleSoundIds } from '../types'\nimport { createCockpit } from './cockpit'\nimport type { Cockpit } from './cockpit'\nimport { VEHICLE_PRELOAD_SOUNDS, VEHICLE_SOUND_BANK, engineProfileOfGroup, hornOfGroup } from '../../audio'\nimport { createWheelRoll } from '../../wheel-roll'\nimport type { WheelRoll } from '../../wheel-roll'\nimport { createProvingCrash } from './crash'\nimport type { ProvingCrash } from './crash'\nimport { SYSTEMS_TEXT } from './systems-text'\nimport type { SystemsText } from './systems-text'\nimport { fillText, PROVING_TEXT } from './text'\nimport type { ProvingText } from './text'\n\nexport const PROVING_AREA_ID = 'vehicles_proving'\n\ntype Three = typeof THREE_NS\n\n/** Content comes in by option (the adapter does not import a content pack): the example wires the kit's fleet, a game its own catalogue. */\nexport interface ProvingModuleOptions {\n locale?: string\n /** Vehicles offered on the bench, by catalogue id. */\n vehicles: readonly string[]\n /** Catalogue id of the person thrown out of a crash without a belt (a person item of the characters module); without it the crash only logs. */\n occupant?: string\n /** Catalogue id of the car parked behind for the parking sensors (a vehicle item of the vehicles module). Default `sedan` (the vehicles module's midsize sedan). */\n parkedCar?: string\n /** The proving subject of a vehicle (`fleetProvingSubject` of game-vehicles-fleet); `mass` is the kit's own when it has one. Null hides the vehicle. */\n subject(id: string, mass: number | undefined): ProvingSubject | null\n /** The vehicle's name on the bench and the board (default: the id). */\n nameOf?(id: string): string | undefined\n /** The tests (default: the kit's, see `createProvingTests`). */\n tests?: ProvingTestRegistry\n /** Builds the vehicle kit, with the catalogue installed, for a three.js namespace. */\n createKit(THREE: Three): VehicleKit\n sounds?: Partial<VehicleSoundIds>\n /** Called whenever a certificate changes (a result in, a sign-off), so a page can keep or show them. */\n onCertificate?(certificate: ProvingCertificate): void\n /** What the glovebox and the trunk of `vehicle` hold when someone gets in (items of the host's catalogue, as `game-items` finds them for a car). Default empty. */\n stock?(compartment: string, vehicle: string): readonly StorageStack[]\n /** The name of an item of the host's catalogue, for the log (default: its id). */\n itemName?(id: string): string | undefined\n}\n\n/** Track: a straight strip along +x (the semi driver's forward at yaw 0), drawn as a 260 m tile the vehicle wraps on so a top-speed run of kilometres stays on the same tarmac. */\nconst TRACK = { x0: -30, z: 22, tile: 260, width: 14, start: 4 }\nconst SURFACE_LOOK: Record<string, { color: number; roughness: number }> = { dry_asphalt: { color: 0x2b2d31, roughness: 0.95 }, wet_asphalt: { color: 0x1c1f24, roughness: 0.18 }, mud: { color: 0x4a3524, roughness: 1 } }\nconst VISUAL_CHECKS = ['cabin', 'cameras', 'mirrors'] as const\nconst MIRROR_RECTS: Record<string, { x: number; y: number; width: number; height: number; rounded: number }> = {\n rear_view: { x: 0.38, y: 0.02, width: 0.24, height: 0.09, rounded: 0.35 },\n left: { x: 0.02, y: 0.72, width: 0.19, height: 0.13, rounded: 0.3 },\n right: { x: 0.79, y: 0.72, width: 0.19, height: 0.13, rounded: 0.3 },\n reverse: { x: 0.36, y: 0.13, width: 0.28, height: 0.18, rounded: 0.06 },\n}\n\n/**\n * The proving ground as a `TestableModule`: a track where a fleet vehicle runs the measured tests of `game-vehicles-proving` live (0-100, top speed, braking, turning circle, wet braking, mud)\n * on the same semi-simulation driver the headless runner uses, with the vehicle cameras of `game-camera` (chase, cockpit, hood) taking over the room's view, the rear-view and side mirrors\n * and the reversing camera with its guide lines as extra views of the host, a board by the track with the vehicle's certificate, and the sign-off of the visual checks.\n */\nconst ADJUST_KEYS = { seat_forward: 'seatForward', seat_height: 'seatHeight', mirror_left: 'mirrorLeft', mirror_right: 'mirrorRight' } as const\n\nexport function createProvingModule(options: ProvingModuleOptions): TestableModule & { certificates(): ProvingCertificate[]; certificate(id: string): ProvingCertificate | undefined } {\n const locale = options.locale ?? 'pt-BR'\n const text: ProvingText = PROVING_TEXT[locale] ?? (PROVING_TEXT['pt-BR'] as ProvingText)\n const sysText: SystemsText = SYSTEMS_TEXT[locale] ?? (SYSTEMS_TEXT['pt-BR'] as SystemsText)\n const tests = options.tests ?? createProvingTests()\n const vehicles = options.vehicles\n const sounds = { ...defaultSoundIds, ...options.sounds }\n const measured = tests.tests.filter((t) => t.kind === 'measured').map((t) => t.id)\n const settings = { vehicle: vehicles.includes('compact_hatch') ? 'compact_hatch' : (vehicles[0] ?? 'compact_hatch'), test: measured[0] ?? 'accel_0_100', camera: 'chase', timeScale: 4, visual: 'cameras' as string }\n const certificates = new Map<string, ProvingCertificate>()\n const kits = new WeakMap<object, VehicleKit>()\n\n let host: ModuleHost | null = null\n // set in attach (nothing runs before it)\n let three = null as unknown as Three\n let track: Group | null = null\n let strip: Mesh<PlaneGeometry, MeshStandardMaterial> | null = null\n let board: { mesh: Mesh; canvas: HTMLCanvasElement; texture: CanvasTexture } | null = null\n let car: { built: BuiltVehicle; guides: Group; subject: ProvingSubject } | null = null\n let run: ProvingRun | null = null\n let parking: { driver: SemiDriver; time: number } | null = null\n /** The player at the wheel: the room's walking keys are held and the vehicle takes them. */\n let driving: Cockpit | null = null\n let crashes: ProvingCrash | null = null\n /** The wheels rolling with the distance the car covers, and where it was last frame (x, z of the driver). */\n let wheels: WheelRoll | null = null\n let lastAt: { x: number; z: number } | null = null\n let parked: { root: { position: { x: number; z: number } }; remove(): void } | null = null\n /** The driver's seat (metres) and the side mirrors (turn of their aim, out positive). */\n const adjust = { seatForward: 0, seatHeight: 0, mirrorLeft: 0, mirrorRight: 0 }\n const aimed = (pose: MirrorPose): MirrorPose => {\n const turn = pose.id === 'left' ? adjust.mirrorLeft : pose.id === 'right' ? -adjust.mirrorRight : 0\n return turn ? { ...pose, look: [pose.look[0] + turn, pose.look[1], pose.look[2]] } : pose\n }\n let gearbox: 'automatic' | 'manual' = 'automatic'\n /** The key is in the ignition (the bench takes it out to hotwire the car), and the weather the glass mists by. */\n let hasKey = true\n let weather = { outsideC: 25, rain: 0 }\n let misted = false\n let lastGear: number | null = null\n let driveClock = 0\n let boardHalfSecond = 0\n let queue: string[] = []\n /** True while the room has this area open: nothing is built or simulated otherwise, so loading the module costs nothing elsewhere in the room. */\n let open = false\n let lastWrap = 0\n // the car's own sounds (engine by RPM and load, starter, tyres), as on the lane of the vehicles area\n let engine: VehicleSound | undefined\n const rig = { camera: null as PerspectiveCamera | null, vehicle: null as ReturnType<typeof createVehicleCamera> | null, mirrors: [] as Array<{ pose: MirrorPose; camera: PerspectiveCamera; remove: () => void }> }\n\n const name = (id: string): string => options.nameOf?.(id) ?? id.replace(/_/g, ' ')\n const kitFor = (THREE: Three): VehicleKit => {\n let kit = kits.get(THREE)\n if (!kit) {\n kit = options.createKit(THREE)\n kits.set(THREE, kit)\n }\n return kit\n }\n const subjectOf = (id: string): ProvingSubject | null => {\n const mass = three ? (kitFor(three).find(id) as { mass?: number } | null)?.mass : undefined\n return options.subject(id, mass)\n }\n const blank = (subject: ProvingSubject): ProvingCertificate => {\n const results: ProvingResult[] = tests.forDomain(subject.domain).map((t) => ({ test: t.id, kind: t.kind, unit: t.unit, range: t.range?.(subject) ?? {}, value: null, verdict: 'pending', note: t.kind === 'measured' ? 'not run' : t.kind === 'visual' ? 'awaiting sign-off' : 'room not built yet' }))\n return { vehicle: subject.id, domain: subject.domain, category: subject.category, status: statusOf(results), results }\n }\n const certificateOf = (id: string): ProvingCertificate | undefined => {\n if (!certificates.has(id)) {\n const subject = subjectOf(id)\n if (subject) certificates.set(id, blank(subject))\n }\n return certificates.get(id)\n }\n const store = (certificate: ProvingCertificate): void => {\n certificates.set(certificate.vehicle, certificate)\n options.onCertificate?.(certificate)\n drawBoard()\n }\n\n // ---- the track ----------------------------------------------------------------------------------------------------------------------\n const buildTrack = (): void => {\n if (!host || track) return\n const THREE = three\n track = markKitOrigin(new THREE.Group(), { owner: '@adatechnology/game-vehicles-three', kind: 'room', id: 'proving_track' })\n track.name = 'proving_track'\n const look = SURFACE_LOOK.dry_asphalt!\n strip = new THREE.Mesh(new THREE.PlaneGeometry(TRACK.tile + 80, TRACK.width), new THREE.MeshStandardMaterial({ color: look.color, roughness: look.roughness, metalness: 0.05 }))\n strip.rotation.x = -Math.PI / 2\n strip.position.set(TRACK.x0 + TRACK.tile / 2, 0.012, TRACK.z)\n strip.receiveShadow = true\n track.add(strip)\n const paint = new THREE.MeshBasicMaterial({ color: 0xe8e8e2 })\n const yellow = new THREE.MeshBasicMaterial({ color: 0xf2c230 })\n const dash = new THREE.PlaneGeometry(3, 0.14)\n const edge = new THREE.PlaneGeometry(TRACK.tile + 80, 0.16)\n for (const side of [-1, 1]) {\n const line = new THREE.Mesh(edge, paint)\n line.rotation.x = -Math.PI / 2\n line.position.set(TRACK.x0 + TRACK.tile / 2, 0.016, TRACK.z + side * (TRACK.width / 2 - 0.4))\n track.add(line)\n }\n for (let x = TRACK.x0 - 40; x < TRACK.x0 + TRACK.tile + 40; x += 9) {\n const d = new THREE.Mesh(dash, paint)\n d.rotation.x = -Math.PI / 2\n d.position.set(x, 0.016, TRACK.z - 1.5)\n track.add(d)\n }\n // a distance board every 50 m of the tile and the start line\n const post = new THREE.BoxGeometry(0.12, 1.4, 0.12)\n const plate = new THREE.BoxGeometry(0.06, 0.5, 0.9)\n for (let m = 0; m <= TRACK.tile; m += 50) {\n const p = new THREE.Mesh(post, yellow)\n p.position.set(TRACK.x0 + m, 0.7, TRACK.z - TRACK.width / 2 - 0.6)\n const q = new THREE.Mesh(plate, m === 0 ? yellow : paint)\n q.position.set(TRACK.x0 + m, 1.45, TRACK.z - TRACK.width / 2 - 0.6)\n track.add(p, q)\n }\n const startLine = new THREE.Mesh(new THREE.PlaneGeometry(0.5, TRACK.width - 1), yellow)\n startLine.rotation.x = -Math.PI / 2\n startLine.position.set(TRACK.x0, 0.017, TRACK.z)\n track.add(startLine)\n ;(host.scene as Object3D).add(track)\n buildBoard()\n }\n const setSurface = (surface: string): void => {\n if (!strip) return\n const look = SURFACE_LOOK[surface] ?? SURFACE_LOOK.dry_asphalt!\n strip.material.color.setHex(look.color)\n strip.material.roughness = look.roughness\n }\n\n // ---- the certificate board ------------------------------------------------------------------------------------------------------------\n const buildBoard = (): void => {\n if (!host || board || typeof document === 'undefined') return\n const THREE = three\n const canvas = document.createElement('canvas')\n canvas.width = 1024\n canvas.height = 640\n const texture = new THREE.CanvasTexture(canvas)\n texture.colorSpace = THREE.SRGBColorSpace\n const mesh = markKitOrigin(new THREE.Mesh(new THREE.PlaneGeometry(9.6, 6), new THREE.MeshBasicMaterial({ map: texture, toneMapped: false })), { owner: '@adatechnology/game-vehicles-three', kind: 'room', id: 'proving_board' })\n mesh.position.set(TRACK.x0 + 6, 3.6, TRACK.z - TRACK.width / 2 - 3)\n const legs = new THREE.Mesh(new THREE.BoxGeometry(9.8, 0.2, 0.2), new THREE.MeshStandardMaterial({ color: 0x1c1f25 }))\n legs.position.set(0, -3.1, -0.05)\n const stand = new THREE.Mesh(new THREE.BoxGeometry(0.25, 3.4, 0.25), legs.material)\n stand.position.set(0, -4.6, -0.1)\n mesh.add(legs, stand)\n track!.add(mesh)\n board = { mesh, canvas, texture }\n drawBoard()\n }\n const fmtRange = (r: ProvingResult['range']): string => (r.min == null && r.max == null ? '—' : `${r.min ?? '…'}–${r.max ?? '…'}`)\n const drawBoard = (): void => {\n if (!board) return\n const cert = certificateOf(settings.vehicle)\n const g = board.canvas.getContext('2d')\n if (!g || !cert) return\n const W = board.canvas.width\n g.fillStyle = '#16181c'\n g.fillRect(0, 0, W, board.canvas.height)\n g.fillStyle = '#f2c230'\n g.fillRect(0, 0, W, 10)\n g.font = '600 26px monospace'\n g.fillStyle = '#8d95a3'\n g.fillText(text.board.title.toUpperCase(), 32, 50)\n g.font = '700 46px sans-serif'\n g.fillStyle = '#e7e9ec'\n g.fillText(name(cert.vehicle), 32, 102)\n const colour = { approved: '#5cc98a', rejected: '#ef6a5b', pending: '#a7a0f0' }[cert.status]\n g.font = '700 34px sans-serif'\n const status = text.status[cert.status]\n const sw = g.measureText(status).width + 32\n g.strokeStyle = colour\n g.lineWidth = 3\n g.strokeRect(W - sw - 32, 66, sw, 48)\n g.fillStyle = colour\n g.fillText(status, W - sw - 16, 102)\n g.font = '22px monospace'\n g.fillStyle = '#8d95a3'\n const cols = [32, 430, 640, 860]\n ;[text.board.test, text.board.value, text.board.range, text.board.verdict].forEach((h, i) => g.fillText(h.toUpperCase(), cols[i]!, 150))\n let y = 190\n for (const r of cert.results) {\n const live = run && run.test.id === r.test && !run.done\n g.fillStyle = '#e7e9ec'\n g.font = '26px sans-serif'\n g.fillText(text.tests[r.test] ?? r.test, cols[0]!, y)\n g.font = '26px monospace'\n g.fillStyle = '#5fd4e0'\n const value = live ? text.board.running : r.value == null ? (r.kind === 'measured' && r.note === 'not run' ? text.board.notRun : '—') : `${r.value} ${r.unit}`\n g.fillText(value, cols[1]!, y)\n g.fillStyle = '#8d95a3'\n g.fillText(r.kind === 'measured' ? fmtRange(r.range) : r.kind === 'visual' ? 'visual' : 'sala', cols[2]!, y)\n g.fillStyle = { pass: '#5cc98a', fail: '#ef6a5b', pending: '#a7a0f0' }[r.verdict]\n g.fillText(r.verdict === 'pass' ? '✓ ' + text.verdict.pass : r.verdict === 'fail' ? '✗ ' + text.verdict.fail : '…', cols[3]!, y)\n y += 30\n }\n // the gearbox live: the gear and the engine speed of the run or of the driver\n const live = run?.driver.state ?? driving?.driver.state\n if (live) {\n g.font = '24px monospace'\n g.fillStyle = '#f2c230'\n g.fillText(fillText(text.board.gear, gearName(live.gear), Math.round(live.rpm), Math.round(Math.abs(live.u) * 3.6)), cols[0]!, y + 16)\n }\n board.texture.needsUpdate = true\n }\n\n // ---- the vehicle ----------------------------------------------------------------------------------------------------------------------\n const removeCar = (): void => {\n if (!car) return\n wheels = null\n lastAt = null\n discardObject3D(car.built.group)\n car = null\n }\n const placeCar = (): void => {\n if (!host || !three) return\n const subject = subjectOf(settings.vehicle)\n if (!subject) return\n removeCar()\n const built = createVehiclesThree(three, { kit: kitFor(three) }).build(settings.vehicle, { quality: 'high' })\n const guides = reverseGuides(built)\n built.group.add(guides)\n ;(host.scene as Object3D).add(built.group)\n car = { built, guides, subject }\n wheels = createWheelRoll(three, built)\n pose({ x: 0, z: TRACK.start, yaw: 0, pitch: 0, roll: 0, height: 0 }, 0)\n rig.vehicle?.reset()\n drawBoard()\n }\n /** Guide lines of the reversing camera (on layer 1, which only that camera sees): green, yellow and red at 3, 2 and 1 m behind the bumper, bending with the steering. */\n const reverseGuides = (built: BuiltVehicle): Group => {\n const THREE = three\n const group = new THREE.Group()\n group.name = 'reverse_guides'\n const half = built.width / 2 - 0.05\n const tail = -built.length / 2\n const bands: Array<[number, number, number]> = [\n [0.2, 1, 0xef4a3b],\n [1, 2, 0xf2c230],\n [2, 3.2, 0x5cc98a],\n ]\n for (const [a, b, colour] of bands) {\n const material = new THREE.MeshBasicMaterial({ color: colour, transparent: true, opacity: 0.85, depthTest: false })\n for (const side of [-1, 1]) {\n const bar = new THREE.Mesh(new THREE.PlaneGeometry(0.06, b - a), material)\n bar.rotation.x = -Math.PI / 2\n bar.position.set(side * half, 0.03, tail - (a + b) / 2)\n bar.userData.side = side\n bar.userData.mid = (a + b) / 2\n group.add(bar)\n }\n const cross = new THREE.Mesh(new THREE.PlaneGeometry(half * 2, 0.05), material)\n cross.rotation.x = -Math.PI / 2\n cross.position.set(0, 0.03, tail - a)\n cross.userData.mid = a\n group.add(cross)\n }\n group.traverse((o) => o.layers.set(1))\n return group\n }\n const bendGuides = (steer: number): void => {\n if (!car) return\n // the lines follow the arc the rear will take: sideways offset grows with the square of the distance\n for (const bar of car.guides.children) {\n const d = bar.userData.mid as number\n const offset = -steer * 0.18 * d * d\n bar.position.x = (bar.userData.side ?? 0) * (car.built.width / 2 - 0.05) + offset\n }\n }\n const pose = (s: { x: number; z: number; yaw: number; pitch: number; roll: number; height: number }, steer: number): void => {\n if (!car) return\n const wrapped = ((s.x % TRACK.tile) + TRACK.tile) % TRACK.tile\n if (Math.abs(wrapped - lastWrap) > TRACK.tile / 2) rig.vehicle?.reset()\n lastWrap = wrapped\n car.built.group.position.set(TRACK.x0 + wrapped, 0, TRACK.z + s.z)\n car.built.group.rotation.set(-s.pitch, s.yaw + Math.PI / 2, s.roll, 'YXZ')\n bendGuides(steer)\n // the distance along the car's heading since the last frame turns the wheels (a jump to a new run starts them afresh)\n if (lastAt) {\n const along = (s.x - lastAt.x) * Math.cos(s.yaw) - (s.z - lastAt.z) * Math.sin(s.yaw)\n if (Math.abs(along) < 5) wheels?.roll(along, steer)\n }\n lastAt = { x: s.x, z: s.z }\n }\n const frameOf = (speed: number): VehicleFrame | null => {\n if (!car) return null\n const g = car.built.group\n const size = { length: car.built.length, width: car.built.width, height: car.built.height }\n // the seat moves the eyes: forward along the car and up\n const [ex, ey, ez] = car.built.driverEye ?? defaultEye(size)\n return { x: g.position.x, y: g.position.y, z: g.position.z, yaw: g.rotation.y, pitch: -g.rotation.x, roll: g.rotation.z, speed, ...size, eye: [ex, ey + adjust.seatHeight, ez + adjust.seatForward] }\n }\n\n // ---- cameras and mirrors --------------------------------------------------------------------------------------------------------------\n const applyCamera = (): void => {\n // closed, the room's view is the room's: the bench's first values (sent when the module loads) and a camera picked on the panel wait for area()\n if (!host?.setViewCamera || !open) return\n host.setViewCamera(settings.camera === 'room' ? null : rig.camera)\n if (settings.camera !== 'room') rig.vehicle?.setMode(settings.camera as VehicleCameraMode)\n }\n const refreshMirrors = (): void => {\n for (const m of rig.mirrors) m.remove()\n rig.mirrors = []\n if (!host?.addView || !car) return\n const poses = mirrorPoses(car.built)\n const want = (id: string): boolean => (id === 'reverse' ? !!host?.bench?.layer('reverse_camera') : !!host?.bench?.layer('mirrors'))\n for (const pose of poses) {\n if (!want(pose.id)) continue\n const camera = new three.PerspectiveCamera(pose.fov, 2, 0.05, 400)\n if (pose.id === 'reverse') camera.layers.enable(1)\n const rect = MIRROR_RECTS[pose.id]!\n const remove = host.addView({ camera, rect, mirror: pose.mirror, rounded: rect.rounded, label: pose.id, resolution: pose.id === 'reverse' ? 0.6 : 0.45 })\n rig.mirrors.push({ pose, camera, remove })\n }\n }\n let mirrorKey = ''\n\n // ---- runs -----------------------------------------------------------------------------------------------------------------------------\n const stopEngine = (): void => {\n engine?.dispose()\n engine = undefined\n }\n const startTest = (id: string): void => {\n const test = tests.get(id)\n if (!host || !test || test.kind !== 'measured') return\n if (!car || car.subject.id !== settings.vehicle) placeCar()\n if (!car) return\n parking = null\n run = startRun(test, car.subject)\n boardHalfSecond = 0\n setSurface(run.surface)\n // the turning circle needs room on the left: start it at the right edge\n if (id === 'turn_circle') run.driver.place(0, TRACK.start, 0)\n rig.vehicle?.reset()\n stopEngine()\n engine = createVehicleSound(host.audio, { sounds, profile: engineProfileOfGroup(car.subject.category) })\n engine.start([car.built.group.position.x, 0.5, car.built.group.position.z])\n host.log(fillText(text.log.start, name(settings.vehicle), text.tests[id] ?? id))\n drawBoard()\n }\n const finishTest = (): void => {\n if (!run || !car) return\n const result = run.result()\n const cert = certificateOf(car.subject.id)\n if (cert) store(withResult(cert, result))\n host?.log(fillText(text.log.result, name(car.subject.id), text.tests[result.test] ?? result.test, result.value ?? '—', result.unit, fmtRange(result.range), result.verdict), { vehicle: car.subject.id, ...result, trace: undefined }, 'proving_result')\n run = null\n stopEngine()\n const next = queue.shift()\n if (next) startTest(next)\n else setSurface('dry_asphalt')\n }\n const startParking = (): void => {\n if (!host) return\n if (!car || car.subject.id !== settings.vehicle) placeCar()\n if (!car) return\n run = null\n queue = []\n setSurface('dry_asphalt')\n const driver = createSemiSimDriver(subjectSpec(car.subject))\n driver.place(40, 0, 0)\n parking = { driver, time: 0 }\n }\n\n const stopDriving = (): void => {\n if (!driving) return\n driving.stop()\n driving = null\n host?.holdPlayer?.(false)\n host?.bench?.sheet?.(null)\n stopEngine()\n host?.log(text.log.leave)\n }\n const startDriving = (): void => {\n if (!host || !three) return\n if (!car || car.subject.id !== settings.vehicle) placeCar()\n if (!car) return\n run = null\n queue = []\n parking = null\n setSurface(weather.rain > 0 ? 'wet_asphalt' : 'dry_asphalt')\n misted = false\n driving = createCockpit({\n THREE: three,\n host,\n built: car.built,\n subject: car.subject,\n place: [0, 0, 0],\n kit: kitFor(three),\n obstacles: () => (parked ? [[parked.root.position.x, parked.root.position.z] as const] : []),\n gauge: (kitFor(three) as { materials?: Record<string, unknown> }).materials?.gauge,\n needle: (kitFor(three) as { materials?: Record<string, unknown> }).materials?.amber,\n // the engine's own sound turns the key (starter, catch, idle by RPM)\n sounds: { starter: '', horn: hornOfGroup(car.subject.category) },\n hasKey,\n weather,\n stock: (compartment) => options.stock?.(compartment, settings.vehicle) ?? [],\n onExit: () => stopDriving(),\n onEvent: (event) => {\n if (event.type === 'hotwire') {\n host?.log(sysText.events[event.stage === 'joined' ? 'hotwire_joined' : 'hotwire_started'], { vehicle: settings.vehicle, stage: event.stage }, 'proving_system')\n if (event.stage === 'joined' && car && driving?.systems.canCrank() !== false) engine?.start([car.built.group.position.x, 0.5, car.built.group.position.z])\n return\n }\n if (event.type === 'refused') return host?.log(text.cabin.refused[event.reason] ?? sysText.refused[event.reason as keyof SystemsText['refused']] ?? event.reason)\n if (event.type === 'sound') return\n if (event.type !== 'command') {\n if (event.type === 'out_of_fuel' || event.type === 'stall' || event.type === 'seized') engine?.stop([car?.built.group.position.x ?? 0, 0.5, car?.built.group.position.z ?? 0])\n return host?.log(sysText.events[event.type as keyof SystemsText['events']] ?? event.type, { vehicle: settings.vehicle, ...event }, 'proving_system')\n }\n const st = event.state\n const line = cabinLine(event.command, st)\n if (line) host?.log(line)\n if (event.command === 'ignition' && car) {\n const at: [number, number, number] = [car.built.group.position.x, 0.5, car.built.group.position.z]\n if (st.ignition && driving?.systems.canCrank() !== false) engine?.start(at)\n else engine?.stop(at)\n }\n if (event.command === 'gearbox') {\n gearbox = st.gearbox\n host?.bench?.patch('gearbox', { value: st.gearbox })\n }\n },\n })\n if (gearbox !== driving.controls.state.gearbox) driving.controls.command('gearbox')\n host.holdPlayer?.(true)\n if (settings.camera === 'room') {\n settings.camera = 'cockpit'\n host.bench?.patch('camera', { value: 'cockpit' })\n applyCamera()\n }\n rig.vehicle?.reset()\n stopEngine()\n // the engine is off until the key turns (I): the sound cranks, catches and idles by the RPM\n engine = createVehicleSound(host.audio, { sounds, profile: engineProfileOfGroup(car.subject.category) })\n host.bench?.sheet?.({ kicker: text.name, title: fillText(text.log.drive, name(settings.vehicle)), body: `${text.cabin.keys} · ${sysText.keys} · ${sysText.bodyKeys}` })\n host.log(fillText(text.log.drive, name(settings.vehicle)))\n }\n const onOff = (on: boolean): string => (on ? text.cabin.on : text.cabin.off)\n const cabinLine = (command: string, st: Cockpit['controls']['state']): string | null => {\n const c = text.cabin\n switch (command) {\n case 'ignition': return `${c.ignition}: ${onOff(st.ignition)}`\n case 'gearbox': return `${c.gearbox}: ${text.gearbox[st.gearbox]}`\n case 'gear_up':\n case 'gear_down': return `${c.gear}: ${gearName(st.gear)}`\n case 'parking_brake': return `${c.parkingBrake}: ${onOff(st.parkingBrake)}`\n case 'drive_mode': return `${c.driveMode}: ${c.modes[st.driveMode]}`\n case 'lights':\n case 'high_beam': return `${c.lights}: ${c.lampModes[st.lamps.mode]}`\n case 'fog_lights': return `${c.fog}: ${onOff(st.lamps.fog)}`\n case 'interior_light': return `${c.interior}: ${onOff(st.lamps.interior)}`\n case 'alarm': return `${c.alarm}: ${c.alarmStates[st.alarm]}`\n case 'radio':\n case 'radio_source':\n case 'radio_track': return `${c.radio}: ${st.radio.on ? `${c.sources[st.radio.source]} · ${fillText(sysText.track, st.radio.track + 1)}` : c.off}`\n case 'indicator_left':\n case 'indicator_right':\n case 'hazard': return `${c.indicator}: ${c.indicators[st.indicator]}`\n case 'wipers': return `${c.wipers}: ${sysText.wiperModes[st.wipers]}`\n case 'drive_profile': return `${sysText.profile}: ${sysText.profiles[st.profile]}`\n case 'traction_control': return `${sysText.traction}: ${onOff(st.tractionControl)}`\n case 'abs': return `${sysText.abs}: ${onOff(st.abs)}`\n case 'cruise': return st.cruise.on ? fillText(sysText.cruiseSet, Math.round(st.cruise.speed * 3.6)) : `${sysText.cruise}: ${c.off}`\n case 'climate': return `${sysText.climate}: ${onOff(st.climate.on)}`\n case 'demist': return `${sysText.demist}: ${onOff(st.climate.demist)}`\n case 'seatbelt': return `${c.seatbelt}: ${onOff(st.seatbelt)}`\n case 'siren': return `${sysText.siren}: ${sysText.sirenModes[st.siren]}`\n case 'beacon': return `${sysText.beacon}: ${onOff(st.beacon)}`\n case 'glovebox': return `${sysText.glovebox}: ${sysText.lid[st.glovebox ? 'open' : 'shut']}`\n default: return null\n }\n }\n const itemName = (id: string): string => options.itemName?.(id) ?? id\n /** What a compartment holds, for the log: refused while shut, empty, or its stacks with the weight. */\n const listCompartment = (cockpit: Cockpit, id: 'glovebox' | 'trunk'): void => {\n const label = sysText.storage.names[id]\n const data = { vehicle: settings.vehicle, compartment: id }\n if (!cockpit.storage.compartments.some((c) => c.id === id)) return host?.log(fillText(sysText.storage.none, label.toLowerCase()), data, 'proving_storage')\n if (!cockpit.storage.reachable(id, cockpit.access())) return host?.log(fillText(sysText.storage.shut, label), data, 'proving_storage')\n const stacks = cockpit.storage.contents(id).filter((x): x is StorageStack => x !== null)\n if (!stacks.length) return host?.log(fillText(sysText.storage.empty, label), data, 'proving_storage')\n host?.log(fillText(sysText.storage.list, label, cockpit.storage.loadKg(id).toFixed(1), stacks.map((x) => (x.count > 1 ? `${x.count}× ${itemName(x.itemId)}` : itemName(x.itemId))).join(', ')), { ...data, stacks: stacks.map((x) => ({ item: x.itemId, count: x.count })) }, 'proving_storage')\n }\n /** The bench's tests of the car's systems, on the car being driven (the driving seat opens if nobody is in it). */\n const systemsAction = (id: keyof SystemsText['actions']): void => {\n if (id === 'take_key') {\n // the key out (or back): the driver gets in again with or without it\n hasKey = !hasKey\n if (driving) stopDriving()\n startDriving()\n host?.log(hasKey ? sysText.keyBack : sysText.keyTaken, { vehicle: settings.vehicle, hasKey }, 'proving_system')\n return\n }\n if (id === 'cold_rain') {\n weather = weather.rain > 0 ? { outsideC: 25, rain: 0 } : { outsideC: 8, rain: 1 }\n if (driving) driving.weather = { ...weather }\n setSurface(weather.rain > 0 ? 'wet_asphalt' : 'dry_asphalt')\n host?.log(weather.rain > 0 ? sysText.fog.weather : sysText.fog.fair, { vehicle: settings.vehicle, ...weather }, 'proving_system')\n return\n }\n if (!driving) startDriving()\n const cockpit = driving\n if (!cockpit) return\n const d = cockpit.driver\n const done = (key: keyof SystemsText['done']): void => host?.log(sysText.done[key], { vehicle: settings.vehicle, action: key }, 'proving_system')\n switch (id) {\n case 'puncture': {\n const tyres = d.spec.wheels.map((_, i) => d.condition.tyres?.[i] ?? 1)\n tyres[0] = 0\n d.condition = { ...d.condition, tyres }\n return done('puncture')\n }\n case 'fit_spare': {\n const flat = d.spec.wheels.findIndex((_, i) => (d.condition.tyres?.[i] ?? 1) < 0.2)\n const event = cockpit.systems.fitSpare(d, Math.max(0, flat))\n host?.log(sysText.events[event.type], { vehicle: settings.vehicle, ...event }, 'proving_system')\n return\n }\n case 'refuel':\n d.refuel(d.spec.tank.capacity)\n return done('refuel')\n case 'empty_tank':\n d.state.fuel = Math.min(d.state.fuel, d.spec.tank.capacity * 0.04)\n return done('empty_tank')\n case 'drain_battery':\n // below what the starter needs (a quarter): the key clicks and nothing turns\n cockpit.systems.charge(-(cockpit.systems.state.charge - 0.15))\n return done('drain_battery')\n case 'jump_start':\n cockpit.systems.charge(1)\n return done('jump_start')\n case 'break_radiator':\n cockpit.radiator = 0.05\n return done('break_radiator')\n case 'remote_lock':\n case 'remote_unlock': {\n const lock = id === 'remote_lock'\n cockpit.body?.lock(lock)\n // the remote arms the alarm with a chirp and blinks the hazards once; unlocking disarms it\n cockpit.controls.state.alarm = lock ? 'armed' : 'off'\n host?.audio?.play?.({ sound: 'alarm_chirp', position: [car?.built.group.position.x ?? 0, 1, car?.built.group.position.z ?? 0] })\n host?.log(sysText.remote[lock ? 'locked' : 'unlocked'], { vehicle: settings.vehicle, locked: lock }, 'proving_system')\n return\n }\n case 'crash_wall': {\n const g = car?.built.group as { position: { x: number; y: number; z: number }; rotation: { y: number } } | undefined\n if (!g || !host) return\n crashes ??= createProvingCrash(host, options.occupant)\n const speed = d.state.u\n const ejection = crashes.crash({ car: { position: g.position, rotationY: g.rotation.y }, u: d.state.u, w: d.state.w, belted: cockpit.controls.state.seatbelt, destructible: cockpit.destructible })\n d.state.u = d.state.w = d.state.yawRate = 0\n const kmh = Math.round(Math.abs(speed) * 3.6)\n const belted = cockpit.controls.state.seatbelt\n host.log(ejection ? fillText(sysText.crash.ejected, kmh, sysText.crash.exits[ejection.exit]) : fillText(belted ? sysText.crash.stayed : sysText.crash.mild, kmh), { vehicle: settings.vehicle, kmh, belted: cockpit.controls.state.seatbelt, ejection }, 'proving_crash')\n return\n }\n case 'park_behind': {\n // a car parked three metres behind the bumper: backing up, the sensors beep faster as it comes close\n const g = car?.built.group as { position: { x: number; z: number }; rotation: { y: number } } | undefined\n if (!g || !host) return\n parked?.remove()\n const back = (car?.built.length ?? 4.5) / 2 + 3 + 2.3\n const at: [number, number, number] = [g.position.x - Math.sin(g.rotation.y) * back, 0, g.position.z - Math.cos(g.rotation.y) * back]\n const placed = host.addObject?.(options.parkedCar ?? 'sedan', { position: at, rotationY: g.rotation.y })\n parked = placed ? { root: placed.root as { position: { x: number; z: number } }, remove: placed.remove } : null\n host.log(placed ? sysText.parking.placed : sysText.parking.none, { vehicle: settings.vehicle }, 'proving_system')\n return\n }\n case 'glovebox_contents':\n return listCompartment(cockpit, 'glovebox')\n case 'trunk_contents':\n return listCompartment(cockpit, 'trunk')\n case 'take_from_trunk': {\n const storage = cockpit.storage\n if (!storage.compartments.some((c) => c.id === 'trunk')) return listCompartment(cockpit, 'trunk')\n const slot = storage.contents('trunk').findIndex((x) => x !== null)\n if (slot < 0 || !storage.reachable('trunk', cockpit.access())) return listCompartment(cockpit, 'trunk')\n const stack = storage.take('trunk', slot, cockpit.access())\n if (!stack) return\n // it lands on the ground behind the car, an item of the host's like any other\n const g = car?.built.group as { position: { x: number; z: number }; rotation: { y: number } } | undefined\n const back = (car?.built.length ?? 4.5) / 2 + 0.8\n const placed = g ? host?.addObject?.(stack.itemId, { position: [g.position.x - Math.sin(g.rotation.y) * back, 0, g.position.z - Math.cos(g.rotation.y) * back] }) : null\n host?.log(fillText(placed ? sysText.storage.taken : sysText.storage.ground, itemName(stack.itemId)), { vehicle: settings.vehicle, item: stack.itemId, count: stack.count, placed: !!placed }, 'proving_storage')\n return\n }\n case 'force_door': {\n // a locked door forced open: with the alarm armed, it goes off\n const body = cockpit.body\n if (!body) return\n if (body.locked) body.lock(false)\n body.toggle('door_front_left')\n if (cockpit.controls.state.alarm === 'armed') cockpit.controls.state.alarm = 'ringing'\n host?.log(sysText.remote.forced, { vehicle: settings.vehicle, alarm: cockpit.controls.state.alarm }, 'proving_system')\n return\n }\n }\n }\n const gearName = (gear: number): string => (gear < 0 ? 'R' : gear === 0 ? 'N' : String(gear))\n\n const onChange = (change: BenchChange): void => {\n if (change.kind === 'layer') {\n if (change.id === 'scoreboard' && board) board.mesh.visible = !!host?.bench?.layer('scoreboard')\n return refreshMirrors()\n }\n if (change.kind === 'action') {\n if (change.id === 'drive') return driving ? stopDriving() : startDriving()\n if (change.id in sysText.actions) return systemsAction(change.id as keyof SystemsText['actions'])\n if (change.id === 'run_test' || change.id === 'run_all' || change.id === 'reverse_park') stopDriving()\n if (change.id === 'run_test') {\n queue = []\n startTest(settings.test)\n } else if (change.id === 'run_all') {\n queue = measured.slice(1)\n startTest(measured[0]!)\n } else if (change.id === 'certify_now') {\n const subject = subjectOf(settings.vehicle)\n if (!subject) return\n const prior = certificateOf(subject.id)\n const signOffs = (prior?.results ?? []).filter((r) => r.kind !== 'measured' && r.verdict !== 'pending').map((r) => ({ vehicle: subject.id, test: r.test, ok: r.verdict === 'pass', by: r.signedBy ?? 'test room' }))\n const cert = certify(subject, { tests, signOffs })\n store(cert)\n host?.log(fillText(text.log.certified, name(subject.id), text.status[cert.status]), { vehicle: subject.id, status: cert.status }, 'proving_certificate')\n } else if (change.id === 'reverse_park') startParking()\n else if (change.id === 'sign_ok' || change.id === 'sign_fail') {\n const cert = certificateOf(settings.vehicle)\n if (!cert) return\n const ok = change.id === 'sign_ok'\n store(withResult(cert, { test: settings.visual, kind: 'visual', unit: '', range: {}, value: null, verdict: ok ? 'pass' : 'fail', signedBy: 'test room' }))\n host?.log(fillText(text.log.signed, name(settings.vehicle), text.tests[settings.visual] ?? settings.visual, ok ? text.verdict.pass : text.verdict.fail))\n } else if (change.id === 'reset') {\n const subject = subjectOf(settings.vehicle)\n if (subject) store(blank(subject))\n }\n return\n }\n switch (change.id) {\n case 'vehicle':\n settings.vehicle = String(change.value)\n stopDriving()\n run = null\n queue = []\n parking = null\n stopEngine()\n placeCar()\n refreshMirrors()\n break\n case 'test':\n settings.test = String(change.value)\n break\n case 'camera':\n settings.camera = String(change.value)\n applyCamera()\n break\n case 'seat_forward':\n case 'seat_height':\n case 'mirror_left':\n case 'mirror_right':\n adjust[ADJUST_KEYS[change.id]] = Number(change.value)\n break\n case 'time_scale':\n settings.timeScale = Math.max(1, Math.round(Number(change.value)))\n break\n case 'gearbox':\n gearbox = change.value === 'manual' ? 'manual' : 'automatic'\n if (driving && driving.controls.state.gearbox !== gearbox) driving.controls.command('gearbox')\n break\n case 'visual_check':\n settings.visual = String(change.value)\n break\n default:\n break\n }\n }\n\n const frame = (dt: number): void => {\n if (!host || !open) return\n if (!track) buildTrack()\n if (!car) {\n placeCar()\n refreshMirrors()\n }\n let speed = 0\n let steer = 0\n if (run) {\n const s = run.driver.state\n pose(s, s.steerAngle)\n speed = s.u\n steer = s.steerAngle\n if (run.done) finishTest()\n } else if (driving) {\n const d = driving\n d.step(dt)\n if (!driving) return\n // the mist on the glass to the log as it comes and goes\n if (!misted && d.fog.state.fog > 0.6) {\n misted = true\n host.log(sysText.fog.misted, { vehicle: settings.vehicle, fog: +d.fog.state.fog.toFixed(2), humidity: +d.fog.state.humidity.toFixed(2) }, 'proving_system')\n } else if (misted && d.fog.state.fog < 0.1) {\n misted = false\n host.log(sysText.fog.clear, { vehicle: settings.vehicle }, 'proving_system')\n }\n pose(d.driver.state, d.driver.state.steerAngle)\n speed = d.driver.state.u\n steer = d.driver.state.steerAngle\n } else if (parking) {\n // backs up 12 m along a gentle curve to the right, the way a driver parks watching the reversing camera\n parking.time += dt\n const p = parking\n p.driver.step({ throttle: 0, brake: p.time < 7 ? 0.35 : 1, steer: p.time > 2 ? -0.6 : 0, handbrake: false }, dt)\n pose(p.driver.state, p.driver.state.steerAngle)\n speed = p.driver.state.u\n steer = p.driver.state.steerAngle\n if (p.time > 9) parking = null\n }\n if (car) {\n // the controls the run's procedure asked for (a brake test lets go of the throttle and stands on the brake), or the driver's\n const semi = run?.driver.state ?? driving?.driver.state\n const asked = run ? run.input : { throttle: driving?.throttle ?? 0, brake: driving?.brake ?? 0 }\n engine?.update({\n dt,\n position: [car.built.group.position.x, 0.5, car.built.group.position.z],\n speed,\n throttle: asked.throttle,\n brake: asked.brake,\n ...(semi ? { rpm: semi.rpm, slip: Math.max(0, ...semi.slip.map(slideOfGrip)) } : {}),\n })\n }\n const f = frameOf(speed)\n if (f && rig.vehicle && settings.camera !== 'room') rig.vehicle.update(rig.camera!, f, dt)\n if (f && rig.vehicle) for (const m of rig.mirrors) rig.vehicle.placeMirror(m.camera, aimed(m.pose), f)\n void steer\n const key = `${host.bench?.layer('mirrors')}|${host.bench?.layer('reverse_camera')}`\n if (key !== mirrorKey) {\n mirrorKey = key\n refreshMirrors()\n }\n // each shift of the gearbox goes to the log (the automatic climbs the gears on a run, the driver shifts by hand)\n const geared = run?.driver.state ?? driving?.driver.state\n if (geared && geared.gear !== lastGear) {\n if (lastGear !== null && geared.gear > 0) host.log(fillText(text.log.shift, gearName(lastGear), gearName(geared.gear), Math.round(Math.abs(geared.u) * 3.6)), { from: lastGear, to: geared.gear, kmh: +(Math.abs(geared.u) * 3.6).toFixed(1), rpm: Math.round(geared.rpm) }, 'proving_shift')\n lastGear = geared.gear\n drawBoard()\n } else if (!geared) lastGear = null\n if ((run && Math.floor(run.time * 2) !== boardHalfSecond) || (driving && Math.floor(driveClock * 2) !== Math.floor((driveClock - dt) * 2))) drawBoard()\n if (run) boardHalfSecond = Math.floor(run.time * 2)\n if (driving) driveClock += dt\n }\n\n const speedNow = (): number => Math.abs(run?.driver.state.u ?? driving?.driver.state.u ?? parking?.driver.state.u ?? 0) * 3.6\n const counts = (verdict: 'pass' | 'fail' | 'pending'): number => certificateOf(settings.vehicle)?.results.filter((r) => r.verdict === verdict).length ?? 0\n\n const teardown = (): void => {\n crashes?.dispose()\n crashes = null\n parked?.remove()\n parked = null\n stopDriving()\n stopEngine()\n for (const m of rig.mirrors) m.remove()\n rig.mirrors = []\n removeCar()\n mirrorKey = ''\n if (track) discardObject3D(track)\n track = null\n strip = null\n board = null\n run = null\n parking = null\n }\n\n return {\n id: PROVING_AREA_ID,\n name: text.name,\n group: text.name,\n ground: { surface: 'road' },\n certificates: () => [...certificates.values()],\n certificate: (id) => certificateOf(id),\n items: () => [],\n area: (): ModuleArea => {\n // the room asks for the layout right after clearing for this area: from now on the track is built and the runs step\n open = true\n applyCamera()\n // the room's own view opens by the start line, the board in front and the track running away to the right\n return { placements: [], view: { eye: [TRACK.x0 - 4, 3.2, TRACK.z + 9], target: [TRACK.x0 + 6, 2.2, TRACK.z - TRACK.width / 2 - 3] } }\n },\n controls: (): ModuleControl[] => [\n { kind: 'choice', id: 'vehicle', name: text.controls.vehicle, hint: text.hints.vehicle, options: vehicles.map((id) => ({ id, name: name(id) })), default: settings.vehicle },\n { kind: 'choice', id: 'test', name: text.controls.test, hint: text.hints.test, options: measured.map((id) => ({ id, name: text.tests[id] ?? id })), default: settings.test },\n { kind: 'choice', id: 'camera', name: text.controls.camera, hint: text.hints.camera, options: (['room', 'chase', 'cockpit', 'hood'] as const).map((id) => ({ id, name: text.cameras[id] })), default: settings.camera },\n { kind: 'number', id: 'seat_forward', name: sysText.adjust.seat_forward, min: -0.2, max: 0.2, step: 0.02, default: 0 },\n { kind: 'number', id: 'seat_height', name: sysText.adjust.seat_height, min: -0.1, max: 0.1, step: 0.01, default: 0 },\n { kind: 'number', id: 'mirror_left', name: sysText.adjust.mirror_left, min: -0.3, max: 0.3, step: 0.02, default: 0 },\n { kind: 'number', id: 'mirror_right', name: sysText.adjust.mirror_right, min: -0.3, max: 0.3, step: 0.02, default: 0 },\n { kind: 'number', id: 'time_scale', name: text.controls.time_scale, hint: text.hints.time_scale, min: 1, max: 20, step: 1, default: settings.timeScale },\n { kind: 'choice', id: 'visual_check', name: text.controls.visual_check, hint: text.hints.visual_check, options: VISUAL_CHECKS.map((id) => ({ id, name: text.tests[id] ?? id })), default: settings.visual },\n { kind: 'action', id: 'drive', name: text.actions.drive },\n ...(Object.keys(sysText.actions) as Array<keyof SystemsText['actions']>).map((id): ModuleControl => ({ kind: 'action', id, name: sysText.actions[id] })),\n { kind: 'choice', id: 'gearbox', name: text.controls.gearbox, hint: text.hints.gearbox, options: (['automatic', 'manual'] as const).map((id) => ({ id, name: text.gearbox[id] })), default: gearbox },\n { kind: 'action', id: 'run_test', name: text.actions.run_test },\n { kind: 'action', id: 'run_all', name: text.actions.run_all },\n { kind: 'action', id: 'certify_now', name: text.actions.certify_now },\n { kind: 'action', id: 'reverse_park', name: text.actions.reverse_park },\n { kind: 'action', id: 'sign_ok', name: text.actions.sign_ok },\n { kind: 'action', id: 'sign_fail', name: text.actions.sign_fail },\n { kind: 'action', id: 'reset', name: text.actions.reset },\n ],\n layers: (): ModuleLayer[] => [\n { id: 'mirrors', name: text.layers.mirrors, default: false },\n { id: 'reverse_camera', name: text.layers.reverse_camera, default: false },\n { id: 'scoreboard', name: text.layers.scoreboard, default: true },\n ],\n metrics: (): ModuleMetric[] => [\n { id: 'speed', name: text.metrics.speed, unit: 'km/h', digits: 0, read: speedNow },\n { id: 'gear', name: text.metrics.gear, read: () => driving?.driver.state.gear ?? run?.driver.state.gear ?? 0 },\n { id: 'rpm', name: text.metrics.rpm, unit: 'rpm', digits: 0, read: () => driving?.driver.state.rpm ?? run?.driver.state.rpm ?? 0 },\n { id: 'time', name: text.metrics.time, unit: 's', digits: 1, read: () => run?.time ?? 0 },\n { id: 'fog', name: sysText.fog.metric, unit: '%', digits: 0, read: () => (driving?.fog.state.fog ?? 0) * 100 },\n { id: 'value', name: text.metrics.value, digits: 1, read: () => (run ? (run.trace[run.trace.length - 1]?.[1] ?? 0) : 0) },\n { id: 'passed', name: text.metrics.passed, read: () => counts('pass') },\n { id: 'failed', name: text.metrics.failed, read: () => counts('fail') },\n { id: 'pending', name: text.metrics.pending, read: () => counts('pending') },\n { id: 'status', name: text.metrics.status, read: () => ({ approved: 1, rejected: -1, pending: 0 })[certificateOf(settings.vehicle)?.status ?? 'pending'] },\n ],\n scenarios: (): ModuleScenario[] => [],\n attach(lent) {\n host = lent\n three = lent.THREE as Three\n rig.camera = new three.PerspectiveCamera(60, 1.6, 0.05, 900)\n rig.vehicle = createVehicleCamera(three as VehicleThreeLib)\n lent.audio?.register?.(LIBRARY_BANK)\n lent.audio?.register?.(CABIN_BANK)\n lent.audio?.register?.(VEHICLE_SOUND_BANK)\n lent.audio?.register?.(RADIO_BANK)\n // the recordings of the vehicles decode now, so the first horn, hood or engine started is already the file\n lent.audio?.preload?.(VEHICLE_PRELOAD_SOUNDS)\n const stopChange = lent.bench?.onChange(onChange)\n const stopFrame = lent.onFrame(frame)\n // the run owns no clock: the room's tick steps it, `time_scale` is how many ticks' worth of steps each tick runs (a fast-forward of the test, not of the room)\n const stopRunTick = lent.onFrame(() => run?.stepFixed(STEPS_PER_TICK * settings.timeScale), { phase: 'fixedSimulate' })\n const stopClear = lent.onClear?.(() => {\n // the room cleared its area (another area opens, or this one again): the track and the car go until `area()` is asked again\n open = false\n teardown()\n lent.setViewCamera?.(null)\n })\n return () => {\n stopChange?.()\n stopFrame()\n stopRunTick()\n stopClear?.()\n teardown()\n lent.setViewCamera?.(null)\n host = null\n }\n },\n }\n}\n\n/** What `loadProvingModule` needs of a room: `TestRoom.loadModule` has it. */\nexport type ProvingRoomLike = { loadModule(module: never): unknown; openArea?(id: string): unknown }\n\nexport function loadProvingModule<Room extends ProvingRoomLike>(room: Room, options: ProvingModuleOptions): ReturnType<Room['loadModule']> {\n return room.loadModule(createProvingModule(options) as never) as ReturnType<Room['loadModule']>\n}\n","/**\n * The player at the wheel of the proving ground's vehicle: the keyboard read into the vehicle controls of `game-vehicles-driving` (pedals, wheel, gearbox,\n * handbrake, ignition, drive mode, lamps, indicators, wipers, belt, horn, alarm and radio), the semi driver stepped with them, the car's systems\n * (`createVehicleSystems`: battery, coolant, spare tyre) stepped after it, the lamps of the built vehicle\n * switched (`createVehicleLamps`, the beacon of an emergency vehicle flashing with them), the glovebox and the trunk holding items (`createVehicleStorage`), the\n * glass misting up inside by the weather and the people in it (`createWindshieldFog`, drawn by `createWindshieldMist`) and the cabin sounds asked of the host.\n * Without the key (`hasKey: false`) the ignition key held hotwires the car. The driving keys are taken before the room sees them (capture phase), so W does\n * not also walk and F gets the driver out instead of the room's own use. Everything is removed by `stop`.\n */\nimport { RADIO_TRACKS } from '@adatechnology/game-audio'\nimport type { ModuleHost } from '@adatechnology/game-contracts'\nimport { bumperDistance, createSemiSimDriver, createVehicleControls, createVehicleStorage, createVehicleSystems, createWindshieldFog, GLOVEBOX, parkingBeepInterval, trunkFor } from '@adatechnology/game-vehicles-driving'\nimport type { CompartmentSpec, ControlEvent, SemiDriver, SemiEvent, StorageAccess, StorageStack, SystemsEvent, VehicleControls, VehicleStorage, VehicleSystems, WindshieldFog } from '@adatechnology/game-vehicles-driving'\nimport { subjectSpec } from '@adatechnology/game-vehicles-proving'\nimport type { ProvingSubject } from '@adatechnology/game-vehicles-proving'\n\nimport { createVehicleDestructible } from '@adatechnology/game-vehicles'\nimport type { VehicleContext, VehicleDestructible, VehicleKit } from '@adatechnology/game-vehicles'\n\nimport { createVehicleBody } from '../../body'\nimport type { BodyEvent, BodyThree, VehicleBody, WindowId } from '../../body'\nimport type { BuiltVehicle } from '../../build'\nimport { createVehicleDashboard } from '../../dashboard'\nimport type { VehicleDashboard } from '../../dashboard'\nimport { createVehicleLamps } from '../../lamps'\nimport type { VehicleLamps } from '../../lamps'\nimport { createWindshieldMist } from '../../windshield-mist'\nimport type { MistThree, WindshieldMist } from '../../windshield-mist'\n\n/** The cabin's sounds; an empty name stays silent (the starter, when the host's engine sound turns the key itself). */\nexport type CockpitSounds = { horn: string; blinker: string; starter: string; alarm: string; chirp: string; wiper: string; chime: string; radio: string; beep: string; wail: string; yelp: string; spark: string; glovebox: string }\nexport const DEFAULT_COCKPIT_SOUNDS: CockpitSounds = {\n horn: 'horn',\n blinker: 'blinker_tick',\n starter: 'starter_crank',\n alarm: 'car_alarm',\n chirp: 'alarm_chirp',\n wiper: 'wiper_swish',\n chime: 'seatbelt_chime',\n radio: 'radio_static',\n beep: 'parking_beep',\n wail: 'siren_wail',\n yelp: 'siren_yelp',\n spark: 'hotwire_spark',\n glovebox: 'glovebox_latch',\n}\n\n/** The weather around the car, for the mist on its glass: air temperature (°C) and rain on the glass (0..1). */\nexport interface CockpitWeather {\n outsideC: number\n rain: number\n}\n\n/** What the cockpit reports: a control used or refused, the engine (stall, out of fuel) and the systems (flat battery, overheating, spare). */\nexport type CockpitEvent = ControlEvent | SemiEvent | SystemsEvent | BodyEvent\n\n/** Keys of the body (doors 1-4, hood 5, trunk 6, the windows with Shift, the sunroof Shift+5, the central locking V). */\nexport const BODY_KEYS: Readonly<Record<string, string>> = {\n Digit1: 'door_front_left',\n Digit2: 'door_front_right',\n Digit3: 'door_rear_left',\n Digit4: 'door_rear_right',\n Digit5: 'hood',\n Digit6: 'lid',\n}\nconst WINDOW_KEYS: Readonly<Record<string, WindowId>> = { Digit1: 'front_left', Digit2: 'front_right', Digit3: 'rear_left', Digit4: 'rear_right' }\nconst LOCK_KEY = 'KeyV'\n/** Sweeps a second of the wiper blades in each mode (intermittent sweeps once every four seconds or so). */\nconst WIPE_RATE: Readonly<Record<string, number>> = { off: 0, intermittent: 0.25, slow: 0.7, fast: 1.4 }\n\nexport interface Cockpit {\n readonly driver: SemiDriver\n readonly controls: VehicleControls\n readonly systems: VehicleSystems\n /** The doors, windows, sunroof, wipers and locks (null on a vehicle drawn without its damage model). */\n readonly body: VehicleBody | null\n /** The car's damage model (null without the kit). */\n readonly destructible: VehicleDestructible | null\n /** What is left of the radiator, 0..1 (a punctured one barely cools). */\n radiator: number\n readonly lamps: VehicleLamps\n readonly dashboard: VehicleDashboard | null\n /** The gas this step, 0..1 (what the engine's sound loads by). */\n readonly throttle: number\n /** The brake pedal this step, 0..1 (what the pads' squeal follows). */\n readonly brake: number\n /** The glovebox and the trunk (only those the vehicle has: no trunk without a lid). */\n readonly storage: VehicleStorage\n /** What reaches the glovebox and the trunk now (the driver is seated). */\n access(): StorageAccess\n /** The glass misting up inside, and its look on the panes. */\n readonly fog: WindshieldFog\n readonly mist: WindshieldMist\n /** The weather the mist reads; change it at will. */\n weather: CockpitWeather\n /** The vehicle has a siren and a beacon. */\n readonly emergency: boolean\n step(dt: number): void\n stop(): void\n}\n\nexport function createCockpit(o: {\n THREE: Parameters<typeof createVehicleLamps>[0] & Parameters<typeof createVehicleDashboard>[0] & BodyThree & MistThree\n /** World points (x, z) the parking sensors see: obstacles near the bumpers. */\n obstacles?: () => ReadonlyArray<readonly [number, number]>\n /** The vehicle kit: with it the car gets its damage model, whose hinges the doors, hood and lid open on. */\n kit?: VehicleKit\n /** The kit's dial material (`kit.materials.gauge`): with it the cluster reads live. */\n gauge?: unknown\n /** The kit's needle material (`kit.materials.amber`). */\n needle?: unknown\n host: ModuleHost\n built: BuiltVehicle\n subject: ProvingSubject\n sounds?: Partial<CockpitSounds>\n /** The driver has the key. Default true; without it the ignition key held hotwires the car. */\n hasKey?: boolean\n /** What the glovebox and the trunk hold when the driver gets in (the host's items), by compartment id. */\n stock?: (compartment: string) => readonly StorageStack[]\n /** Trunk size, litres. Default 450. */\n trunkLitres?: number\n weather?: CockpitWeather\n place: [number, number, number]\n onEvent?: (event: CockpitEvent) => void\n onExit: () => void\n}): Cockpit {\n const sounds = { ...DEFAULT_COCKPIT_SOUNDS, ...o.sounds }\n const spec = subjectSpec(o.subject)\n const driver = createSemiSimDriver(spec)\n driver.place(o.place[0], o.place[1], o.place[2])\n const lamps = createVehicleLamps(o.THREE, o.built, { lights: o.host.lights, owner: 'proving-ground' })\n const mist = createWindshieldMist(o.THREE, o.built)\n const fog = createWindshieldFog()\n const audio = o.host.audio\n // the cluster: the speedometer to the next 20 km/h over the vehicle's top speed, the rev counter to its red line\n const top = o.subject.stats.maxSpeedKmh\n const dashboard = o.gauge ? createVehicleDashboard(o.THREE, o.built, { gauge: o.gauge, needle: o.needle, redlineRpm: spec.engine.redlineRpm, maxKmh: top ? Math.ceil((top + 10) / 20) * 20 : undefined }) : null\n const at = (): [number, number, number] => [o.built.group.position.x, 1, o.built.group.position.z]\n const play = (sound: string, volume = 1): void => void audio?.play?.({ sound, position: at(), volume })\n let alarmAgain = 0\n let hornAgain = 0\n let wipeAgain = 0\n let chimeAgain = 0\n let radioAgain = 0\n let beepAgain = 0\n let bar = 0\n let exitAsked = false\n let sirenAgain = 0\n let sparkAgain = 0\n let wiresBefore = 0\n let gas = 0\n let pedal = 0\n const systems = createVehicleSystems()\n const context = o.built.context as VehicleContext | null\n const destructible: VehicleDestructible | null = o.kit && context ? createVehicleDestructible(o.kit, context, { id: 'driven', frame: o.built.group }) : null\n const body = destructible ? createVehicleBody(o.built, { THREE: o.THREE, clips: destructible.animations() }) : null\n // the glovebox behind the dashboard of a vehicle with doors, the trunk behind its lid\n const compartments: CompartmentSpec[] = []\n if (!body || body.parts.some((p) => p.startsWith('door'))) compartments.push(GLOVEBOX)\n if (body?.parts.includes('lid')) compartments.push(trunkFor(o.trunkLitres))\n const storage = createVehicleStorage({ compartments })\n for (const c of compartments) storage.stock(c.id, o.stock?.(c.id) ?? [])\n const access = (): StorageAccess => ({\n seated: true,\n frontDoorOpen: (body?.openness('door_front_left') ?? 0) >= 0.5 || (body?.openness('door_front_right') ?? 0) >= 0.5,\n gloveboxOpen: controls.state.glovebox,\n lid: body?.openness('lid') ?? 0,\n })\n const bodyEvents = (events: readonly BodyEvent[]): void => {\n for (const event of events) {\n if (event.type === 'sound') play(event.key, 0.9)\n o.onEvent?.(event)\n }\n }\n\n const controls = createVehicleControls({\n canCrank: systems.canCrank,\n onCrank: systems.crank,\n powerLimit: systems.powerLimit,\n gears: spec.gears?.length ?? 5,\n fourWheelDrive: !!o.subject.body.fourWheelDrive,\n fogLamps: lamps.has.fog,\n clutchPedal: true,\n radioTracks: RADIO_TRACKS.length,\n hasKey: o.hasKey,\n emergency: lamps.has.beacon,\n onEvent: (event) => {\n if (event.type === 'command') {\n if (event.command === 'ignition' && !event.state.ignition) driver.state.engineOn = false\n if (event.command === 'alarm' && event.state.alarm === 'armed') play(sounds.chirp)\n if (event.command === 'alarm') alarmAgain = 0\n if (event.command === 'radio' || event.command === 'radio_source' || event.command === 'radio_track') {\n radioAgain = 0\n bar = 0\n }\n if (event.command === 'exit') exitAsked = true\n if (event.command === 'siren') sirenAgain = 0\n if (event.command === 'glovebox') play(sounds.glovebox, 0.8)\n }\n o.onEvent?.(event)\n },\n })\n // the driver gets in with the engine off: the key (I) or the gas pedal starts it\n driver.state.engineOn = false\n\n const target: Window | null = typeof window !== 'undefined' ? window : null\n const bodyKey = (e: KeyboardEvent): boolean => {\n if (!body) return false\n if (e.code === LOCK_KEY) bodyEvents(body.lock(!body.locked))\n else if (e.shiftKey && e.code === 'Digit5') body.toggleSunroof()\n else if (e.shiftKey && WINDOW_KEYS[e.code]) body.toggleWindow(WINDOW_KEYS[e.code] as WindowId)\n else if (!e.shiftKey && BODY_KEYS[e.code]) bodyEvents(body.toggle(BODY_KEYS[e.code] as string))\n else return false\n return true\n }\n const down = (e: KeyboardEvent): void => {\n if (!e.repeat && bodyKey(e)) {\n e.stopImmediatePropagation()\n return\n }\n if (!controls.key(e.code, true)) return\n // the room listens on the window too: a driving key stops here\n e.stopImmediatePropagation()\n if (e.code.startsWith('Arrow') || e.code === 'Space') e.preventDefault()\n }\n const up = (e: KeyboardEvent): void => {\n if (controls.key(e.code, false)) e.stopImmediatePropagation()\n }\n const blur = (): void => controls.release()\n target?.addEventListener('keydown', down, true)\n target?.addEventListener('keyup', up, true)\n target?.addEventListener('blur', blur)\n\n const cockpit: Cockpit = {\n radiator: 1,\n storage,\n access,\n fog,\n mist,\n weather: { ...(o.weather ?? { outsideC: 25, rain: 0 }) },\n emergency: lamps.has.beacon,\n driver,\n controls,\n systems,\n body,\n destructible,\n lamps,\n dashboard,\n get throttle() {\n return gas\n },\n get brake() {\n return pedal\n },\n step(dt) {\n const input = controls.input(dt, driver)\n gas = input.throttle\n pedal = input.brake\n if (input.start && sounds.starter) play(sounds.starter)\n const engine = driver.step(input, dt).events\n controls.after(driver, dt)\n const s = controls.state\n const report = [...engine.filter((e) => e.type !== 'shift'), ...systems.step({ driver, controls: s, throttle: input.throttle, dt, radiator: cockpit.radiator })]\n for (const event of report) o.onEvent?.(event)\n // a flat battery with the engine off lights nothing\n const powered = driver.state.engineOn || systems.state.charge > 0\n const high = s.lamps.mode === 'high' || s.lamps.flash\n lamps.set({\n mode: !powered ? 'off' : s.lamps.flash ? 'high' : s.lamps.mode,\n fog: s.lamps.fog,\n interior: s.lamps.interior,\n brake: s.brakeLights,\n reverse: s.reverseLights,\n left: s.blinkOn && (s.indicator === 'left' || s.indicator === 'hazard'),\n right: s.blinkOn && (s.indicator === 'right' || s.indicator === 'hazard'),\n beacon: s.beacon && powered ? s.beaconSide : null,\n })\n // the glass mists by the people inside (the driver), the weather and the rain on it; the windows and the demister clear it\n const w = cockpit.weather\n const windows = body ? body.windows.reduce((sum, id) => sum + body.window(id), 0) / Math.max(1, body.windows.length) : 0\n const warm = systems.state.temperature\n const cabinC = s.climate.on ? 22 : w.outsideC + (driver.state.engineOn ? 3 + 5 * Math.min(1, warm * 2) : 2)\n mist.set(fog.step({ dt, occupants: 1, outsideC: w.outsideC, cabinC, rain: w.rain, speed: Math.abs(driver.state.u), windows, climate: s.climate, engineWarm: driver.state.engineOn ? Math.min(1, warm * 2) : 0 }).fog)\n // the siren: its tone again as it ends; the wires sparking while the hotwire key is held\n if (s.siren !== 'off' && powered && (sirenAgain -= dt) <= 0) {\n play(s.siren === 'wail' ? sounds.wail : sounds.yelp)\n sirenAgain = s.siren === 'wail' ? 2.95 : 1.95\n }\n const working = s.hotwire.progress > wiresBefore\n wiresBefore = s.hotwire.progress\n if (working && (sparkAgain -= dt) <= 0) {\n play(sounds.spark, 0.7)\n sparkAgain = 0.45 + 0.4 * ((s.hotwire.progress * 7) % 1)\n }\n dashboard?.update(\n {\n kmh: Math.abs(driver.state.u) * 3.6,\n rpm: driver.state.engineOn ? driver.state.rpm : 0,\n gear: driver.state.gear,\n ignition: s.ignition,\n engineOn: driver.state.engineOn,\n left: s.blinkOn && (s.indicator === 'left' || s.indicator === 'hazard'),\n right: s.blinkOn && (s.indicator === 'right' || s.indicator === 'hazard'),\n highBeam: high,\n fuel: driver.state.fuel / spec.tank.capacity,\n temperature: systems.state.temperature,\n cruise: s.cruise.on,\n profile: s.profile,\n tractionOff: !s.tractionControl,\n absOff: !s.abs,\n charging: systems.state.netW >= 0,\n lowBeam: s.lamps.mode === 'low' || s.lamps.mode === 'position',\n fog: s.lamps.fog,\n parkingBrake: s.parkingBrake,\n seatbelt: s.seatbelt,\n fourWheel: s.fourWheelEngaged,\n },\n dt,\n )\n if (body) bodyEvents(body.update(dt, s.washer ? 1.2 : (WIPE_RATE[s.wipers] ?? 0)))\n if (s.tick) play(sounds.blinker, 0.8)\n // parking sensors: in reverse the rear bumper, creeping forward the front one\n const near = o.obstacles?.() ?? []\n if (s.ignition && near.length && Math.abs(driver.state.u) < 3) {\n const g = o.built.group as { position: { x: number; z: number }; rotation: { y: number } }\n const reversing = driver.state.gear < 0 || driver.state.u < -0.05\n const distance = bumperDistance({ x: g.position.x, z: g.position.z, heading: [Math.sin(g.rotation.y), Math.cos(g.rotation.y)], length: o.built.length, width: o.built.width, forward: !reversing, obstacles: near })\n const every = parkingBeepInterval(distance)\n if (every != null && (beepAgain -= dt) <= 0) {\n play(sounds.beep, 0.7)\n beepAgain = every === 0 ? 0.09 : every\n }\n }\n // the horn's note is 0.6 s: held, it sounds again before the last one ends\n if (s.horn && (hornAgain -= dt) <= 0) {\n play(sounds.horn)\n hornAgain = 0.5\n } else if (!s.horn) hornAgain = 0\n if (s.alarm === 'ringing' && (alarmAgain -= dt) <= 0) {\n play(sounds.alarm)\n alarmAgain = 2.9\n }\n if ((s.wipers !== 'off' || s.washer) && (wipeAgain -= dt) <= 0) {\n play(sounds.wiper, 0.7)\n wipeAgain = s.washer || s.wipers === 'fast' ? 0.6 : s.wipers === 'slow' ? 1.4 : 4\n }\n // moving without the belt: the chime, every few seconds\n const kmh = Math.abs(driver.state.u) * 3.6\n if (!s.seatbelt && s.ignition && kmh > 10 && (chimeAgain -= dt) <= 0) {\n play(sounds.chime, 0.6)\n chimeAgain = 6\n }\n // the radio: the track picked, from the station (a little hiss under it) or the tape; a loop plays again when it ends\n if (s.radio.on && (radioAgain -= dt) <= 0) {\n const song = RADIO_TRACKS[s.radio.track % RADIO_TRACKS.length]\n if (song) {\n play(song.bars[bar % song.bars.length] as string, s.radio.source === 'tape' ? 0.8 : 0.7)\n bar++\n }\n if (s.radio.source === 'radio') play(sounds.radio, 0.12)\n radioAgain = song?.barSeconds ?? 2\n }\n if (exitAsked) {\n exitAsked = false\n o.onExit()\n }\n },\n stop() {\n target?.removeEventListener('keydown', down, true)\n target?.removeEventListener('keyup', up, true)\n target?.removeEventListener('blur', blur)\n controls.release()\n lamps.dispose()\n mist.dispose()\n storage.clear()\n dashboard?.dispose()\n body?.dispose()\n destructible?.dispose?.()\n },\n }\n return cockpit\n}\n","/**\n * The openings of a built vehicle worked by hand: each door, the hood and the trunk lid swing on the hinges the vehicle destructible draws (their open\n * pose is the one of its `open_*` clips, so the door takes its skin, glass and trim with it), each side window slides down into its door, a sunroof\n * slides back when the model has one, the wiper blades sweep, and the central locking keeps the doors and the lid shut. It moves only what the kit\n * drew and puts every part back on `dispose`.\n */\nimport type { AnimationClipSpec } from '@adatechnology/game-contracts'\n\nimport type { BuiltVehicle } from './build'\n\ntype Vec = { x: number; y: number; z: number; copy(v: Vec): Vec; clone(): Vec; sub(v: Vec): Vec; add(v: Vec): Vec; applyQuaternion(q: Quat): Vec }\ntype Quat = { copy(q: Quat): Quat; clone(): Quat; setFromAxisAngle(axis: Vec, angle: number): Quat; multiply(q: Quat): Quat }\n/** What the body needs of three.js: vectors and quaternions to turn a wiper about its spindle. */\nexport type BodyThree = { Vector3: new (x?: number, y?: number, z?: number) => Vec; Quaternion: new () => Quat }\ntype Obj = { name: string; parent: Obj | null; position: Vec; quaternion: Quat; rotation: { x: number; y: number; z: number; set(x: number, y: number, z: number): void }; userData: Record<string, unknown>; visible: boolean; traverse(fn: (o: Obj) => void): void; getObjectByName(name: string): Obj | undefined }\ntype Pane = Obj & { geometry?: { boundingBox: { min: { y: number }; max: { y: number } } | null; computeBoundingBox(): void } }\n\n/** A side window by where it sits: `front_left`, `rear_right`... */\nexport type WindowId = `${'front' | 'rear'}_${'left' | 'right'}`\n\nexport type BodyEvent = { type: 'sound'; key: string; part: string } | { type: 'refused'; part: string; reason: 'locked' | 'missing' }\n\nexport interface VehicleBodyOptions {\n THREE: BodyThree\n /** The open and close clips of the vehicle destructible (`animations()`): the open pose of each door, the hood and the lid. */\n clips: readonly AnimationClipSpec[]\n /** Seconds a door, the hood or the lid takes to open. Default 1.2 (the clips'). */\n swingSeconds?: number\n /** Seconds a window takes from shut to open. Default 3.5. */\n windowSeconds?: number\n /** Share of the pane's height that goes into the door. Default 0.92 (the top edge stays in the seal). */\n windowTravel?: number\n}\n\nexport interface VehicleBody {\n /** Part ids the body can open: `door_front_left`..., `hood`, `lid`. */\n readonly parts: readonly string[]\n readonly windows: readonly WindowId[]\n readonly hasSunroof: boolean\n readonly wipers: number\n readonly locked: boolean\n /** 0 shut to 1 open. */\n openness(part: string): number\n /** Opens a shut part or shuts an open one. Locked doors and lid refuse. */\n toggle(part: string): BodyEvent[]\n /** Window opening, 0 shut to 1 down. */\n window(id: WindowId): number\n toggleWindow(id: WindowId): void\n setWindow(id: WindowId, open: number): void\n toggleSunroof(): void\n /** Locks or unlocks the doors and the lid (the key or the remote). */\n lock(locked: boolean): BodyEvent[]\n /** Advances the moving parts; `wipe` is the wipers' sweeps per second (0 parked). */\n update(dt: number, wipe?: number): BodyEvent[]\n dispose(): void\n}\n\n/** The kit's own sounds (`VEHICLE_SOUND_BANK`): the latch opening any of them, and each one's slam shut. */\nconst OPEN_SOUND = 'car_door_open'\nconst SHUT_SOUND: Record<string, string> = { door: 'car_door_close', hood: 'car_hood_close', lid: 'car_trunk_close' }\nconst clamp = (x: number, a: number, b: number): number => Math.max(a, Math.min(b, x))\n\nexport function createVehicleBody(built: BuiltVehicle, options: VehicleBodyOptions): VehicleBody {\n const swing = options.swingSeconds ?? 1.2\n const windowSeconds = options.windowSeconds ?? 3.5\n const travel = options.windowTravel ?? 0.92\n const root = (built.context as { vehicle?: Obj } | null)?.vehicle ?? (built.group as Obj)\n // the open pose of each part, from the clips\n const poses = new Map<string, [number, number, number]>()\n for (const clip of options.clips) {\n if (!clip.id.startsWith('open_')) continue\n const last = clip.keys[clip.keys.length - 1]\n for (const [id, pose] of Object.entries(last?.parts ?? {})) if (pose.rotation) poses.set(id, pose.rotation as [number, number, number])\n }\n const hinges = new Map<string, { pivot: Obj; open: [number, number, number]; now: number; target: number }>()\n for (const [id, open] of poses) {\n const pivot = root.getObjectByName(id)\n if (pivot) hinges.set(id, { pivot, open, now: 0, target: 0 })\n }\n const kind = (part: string): string => (part.startsWith('door') ? 'door' : part === 'hood' ? 'hood' : 'lid')\n // side windows: the kit's panes keyed window_front / window_rear, side by the sign of z (left negative)\n const panes = new Map<WindowId, { pane: Pane; drop: number; now: number; target: number; applied: number }>()\n for (const glass of ((built.context as { glass?: Pane[] } | null)?.glass ?? [])) {\n const g = glass.userData.glass as { key?: string; side?: number } | undefined\n if (!g || (g.key !== 'window_front' && g.key !== 'window_rear')) continue\n const id = `${g.key === 'window_front' ? 'front' : 'rear'}_${(g.side ?? 1) < 0 ? 'left' : 'right'}` as WindowId\n if (panes.has(id) || !glass.geometry) continue\n glass.geometry.computeBoundingBox()\n const box = glass.geometry.boundingBox\n if (box) panes.set(id, { pane: glass, drop: (box.max.y - box.min.y) * travel, now: 0, target: 0, applied: 0 })\n }\n const sunroofs: Array<{ obj: Obj; slide: number; base: number }> = []\n // a wiper piece turns about its spindle on the windshield's normal; parked it is back exactly where the builder drew it\n const wipers: Array<{ obj: Obj; arm: number; sweep: number; spindle: Vec; axis: Vec; rest: Vec; restQ: Quat }> = []\n const T = options.THREE\n const turn = new T.Quaternion()\n root.traverse((o) => {\n const sun = o.userData.sunroof as { slide: number } | undefined\n if (sun) sunroofs.push({ obj: o, slide: sun.slide, base: o.position.x })\n })\n for (const { part, tag } of ((built.context as { wipers?: Array<{ part: Obj; tag: { arm: number; sweep: number; spindle: readonly number[]; axis: readonly number[] } }> } | null)?.wipers ?? []))\n wipers.push({ obj: part, arm: tag.arm, sweep: tag.sweep, spindle: new T.Vector3(...tag.spindle), axis: new T.Vector3(...tag.axis), rest: part.position.clone(), restQ: part.quaternion.clone() })\n let sunNow = 0\n let sunTarget = 0\n let wipePhase = 0\n let locked = false\n const placeWiper = (w: (typeof wipers)[number], angle: number): void => {\n if (angle === 0) {\n w.obj.position.copy(w.rest)\n w.obj.quaternion.copy(w.restQ)\n return\n }\n turn.setFromAxisAngle(w.axis, angle)\n w.obj.position.copy(w.rest).sub(w.spindle).applyQuaternion(turn).add(w.spindle)\n w.obj.quaternion.copy(turn).multiply(w.restQ)\n }\n const ease = (now: number, target: number, seconds: number, dt: number): number => now + clamp(target - now, -dt / seconds, dt / seconds)\n\n return {\n parts: [...hinges.keys()],\n windows: [...panes.keys()],\n hasSunroof: sunroofs.length > 0,\n wipers: new Set(wipers.map((w) => w.arm)).size,\n get locked() {\n return locked\n },\n openness: (part) => hinges.get(part)?.now ?? 0,\n toggle(part) {\n const h = hinges.get(part)\n if (!h) return [{ type: 'refused', part, reason: 'missing' }]\n if (locked && kind(part) !== 'hood' && h.target === 0) return [{ type: 'refused', part, reason: 'locked' }]\n h.target = h.target > 0 ? 0 : 1\n return h.target > 0 ? [{ type: 'sound', key: OPEN_SOUND, part }] : []\n },\n window: (id) => panes.get(id)?.now ?? 0,\n toggleWindow(id) {\n const w = panes.get(id)\n if (w) w.target = w.target > 0.5 ? 0 : 1\n },\n setWindow(id, open) {\n const w = panes.get(id)\n if (w) w.target = clamp(open, 0, 1)\n },\n toggleSunroof() {\n sunTarget = sunTarget > 0.5 ? 0 : 1\n },\n lock(on) {\n locked = on\n return [{ type: 'sound', key: 'blinker_tick', part: 'doors' }]\n },\n update(dt, wipe = 0) {\n const events: BodyEvent[] = []\n for (const [id, h] of hinges) {\n if (h.now === h.target) continue\n h.now = ease(h.now, h.target, swing, dt)\n h.pivot.rotation.set(h.open[0] * h.now, h.open[1] * h.now, h.open[2] * h.now)\n if (h.now === 0) events.push({ type: 'sound', key: SHUT_SOUND[kind(id)] ?? 'car_door_close', part: id })\n }\n // a window moves in its parent's frame: it may be the body or, once the door has swung, the door's hinge (both keep y up)\n for (const w of panes.values()) {\n if (w.now === w.target) continue\n w.now = ease(w.now, w.target, windowSeconds, dt)\n const offset = -w.drop * w.now\n w.pane.position.y += offset - w.applied\n w.applied = offset\n }\n if (sunNow !== sunTarget) {\n sunNow = ease(sunNow, sunTarget, 2.5, dt)\n for (const s of sunroofs) s.obj.position.x = s.base - s.slide * sunNow\n }\n // the blades sweep out and back; parked they come down to rest\n wipePhase = wipe > 0 ? (wipePhase + dt * wipe) % 1 : wipePhase > 0 ? Math.min(1, wipePhase + dt * 1.5) % 1 : 0\n const sweep = Math.sin(Math.PI * wipePhase)\n for (const w of wipers) placeWiper(w, w.sweep * sweep)\n return events\n },\n dispose() {\n for (const h of hinges.values()) h.pivot.rotation.set(0, 0, 0)\n for (const w of panes.values()) w.pane.position.y -= w.applied\n for (const s of sunroofs) s.obj.position.x = s.base\n for (const w of wipers) placeWiper(w, 0)\n },\n }\n}\n","/**\n * The instrument cluster of a built vehicle working: the two dials the kit draws in front of the driver (`kit.dashboard`, material `gauge`) get a\n * face that reads live, the speedometer and the rev counter with the gear, and the warning lights a driver looks for (indicators, high beam, fog,\n * handbrake, belt, battery and oil while the key is on and the engine is not, 4x4). The faces are canvases laid over the kit's dials, facing the\n * driver's eyes, and only while someone drives: `dispose` takes them away and frees them, the kit's drawing is never changed.\n */\nimport { discardObject3D } from '@adatechnology/game-shapes-three'\nimport type { CanvasTexture, CircleGeometry, Mesh, MeshBasicMaterial, Object3D, Vector3 } from 'three'\n\nimport type { BuiltVehicle } from './build'\n\n/** What the cluster shows this instant. */\nexport type DashboardReading = {\n kmh: number\n rpm: number\n /** -1 reverse, 0 neutral, 1.. forward. */\n gear: number\n ignition: boolean\n engineOn: boolean\n left: boolean\n right: boolean\n highBeam: boolean\n lowBeam: boolean\n fog: boolean\n parkingBrake: boolean\n seatbelt: boolean\n fourWheel: boolean\n /** Engine temperature, 0 (cold) to 1 (overheating); leave out while the engine has no heat model. */\n temperature?: number\n /** Fuel, 0 (empty) to 1 (full); leave out while the vehicle has no fuel model. */\n fuel?: number\n /** Cruise control holding a speed. */\n cruise?: boolean\n /** Drive profile shown by its letter (E economy, S sport; nothing for normal). */\n profile?: 'eco' | 'normal' | 'sport'\n /** The aids switched off light their amber lamps. */\n tractionOff?: boolean\n absOff?: boolean\n /** The alternator does not keep up (the battery drains with the engine running). */\n charging?: boolean\n}\n\n/** The scale of the dials and how often the faces are redrawn. */\nexport type DashboardOptions = {\n /** The kit's dial material (`kit.materials.gauge`): the dials are found by it. */\n gauge: unknown\n /** The kit's needle material (`kit.materials.amber`): the fixed needles drawn on the dials hide while the live face shows. */\n needle?: unknown\n /** Top of the speedometer, km/h. Default 220. */\n maxKmh?: number\n /** Red line of the rev counter. Default 6500. */\n redlineRpm?: number\n /** Redraws per second at most. Default 15. */\n fps?: number\n /** Where the canvases come from (tests pass a fake one). Default the page's. */\n document?: { createElement(tag: 'canvas'): HTMLCanvasElement }\n}\n\nexport interface VehicleDashboard {\n /** How many dials were found (0: a vehicle without a cluster drawn, nothing to show). */\n readonly dials: number\n update(reading: DashboardReading, dt: number): void\n dispose(): void\n}\n\ntype ThreeLib = {\n CanvasTexture: new (canvas: HTMLCanvasElement) => CanvasTexture\n CircleGeometry: new (radius: number, segments: number) => CircleGeometry\n MeshBasicMaterial: new (p: { map: CanvasTexture; transparent: boolean; toneMapped: boolean; depthWrite: boolean }) => MeshBasicMaterial\n Mesh: new (g: CircleGeometry, m: MeshBasicMaterial) => Mesh\n Vector3: new (x?: number, y?: number, z?: number) => Vector3\n}\n\n/** The colours of the cluster: the warning lights by the usual code (red stop, amber caution, green and blue information). */\nexport const DASHBOARD_LOOK = {\n face: '#0b1110',\n ring: '#2f3a36',\n marks: '#cfe8dc',\n needle: '#ff6a2a',\n red: '#e2402f',\n amber: '#f2a630',\n green: '#46d16f',\n blue: '#3f8cff',\n dim: 'rgba(207,232,220,0.12)',\n /** How far in front of the kit's dial the face sits, metres (the kit's needle sticks out 6 mm). */\n lift: 0.011,\n} as const\n\nconst SIZE = 256\n\nexport function createVehicleDashboard(THREE: ThreeLib, built: BuiltVehicle, options: DashboardOptions): VehicleDashboard {\n const maxKmh = options.maxKmh ?? 220\n const redline = options.redlineRpm ?? 6500\n const doc: { createElement(tag: 'canvas'): HTMLCanvasElement } | null = options.document ?? (typeof document !== 'undefined' ? document : null)\n const dials: Mesh[] = []\n built.group.traverse((o: Object3D) => {\n if ((o as Mesh).isMesh && (o as Mesh).material === options.gauge) dials.push(o as Mesh)\n })\n const eye = built.driverEye\n const hidden: Object3D[] = []\n const faces: Array<{ mesh: Mesh; canvas: HTMLCanvasElement; g: CanvasRenderingContext2D; texture: CanvasTexture; kind: 'speed' | 'rpm' }> = []\n if (doc && eye && dials.length) {\n built.group.updateMatrixWorld(true)\n const eyeWorld = built.group.localToWorld(new THREE.Vector3(eye[0], eye[1], eye[2]))\n // the two dials nearest the driver: speed on the left of the driver's view (+x is the driver's left), revs on the right\n const near = dials\n .map((d) => ({ d, at: d.getWorldPosition(new THREE.Vector3()) }))\n .sort((a, b) => a.at.distanceTo(eyeWorld) - b.at.distanceTo(eyeWorld))\n .slice(0, 2)\n .sort((a, b) => built.group.worldToLocal(b.at.clone()).x - built.group.worldToLocal(a.at.clone()).x)\n near.forEach(({ d, at }, i) => {\n const canvas = doc.createElement('canvas')\n canvas.width = canvas.height = SIZE\n const g = canvas.getContext('2d')\n if (!g) return\n const texture = new THREE.CanvasTexture(canvas)\n const radius = (d.geometry as { parameters?: { radiusTop?: number } }).parameters?.radiusTop ?? 0.055\n const mesh = new THREE.Mesh(new THREE.CircleGeometry(radius * 1.12, 40), new THREE.MeshBasicMaterial({ map: texture, transparent: true, toneMapped: false, depthWrite: false }))\n mesh.name = 'dashboard_face'\n // the face lies on the dial, along the dial's own axis (a cylinder's y), on the driver's side\n const axis = new THREE.Vector3(0, 1, 0).applyQuaternion(d.getWorldQuaternion(d.quaternion.clone())).normalize()\n if (axis.dot(eyeWorld.clone().sub(at)) < 0) axis.negate()\n const front = at.clone().addScaledVector(axis, DASHBOARD_LOOK.lift)\n mesh.position.copy(built.group.worldToLocal(front.clone()))\n built.group.add(mesh)\n mesh.updateMatrixWorld(true)\n mesh.lookAt(front.add(axis))\n // the kit's dial (its glowing side shows round the face at an angle) and its fixed needle step aside while the live face shows\n d.visible = false\n hidden.push(d)\n // the needle: the amber stick drawn on this dial\n if (options.needle)\n built.group.traverse((o: Object3D) => {\n if ((o as Mesh).isMesh && (o as Mesh).material === options.needle && o.visible && o.getWorldPosition(new THREE.Vector3()).distanceTo(at) < radius * 1.2) {\n o.visible = false\n hidden.push(o)\n }\n })\n faces.push({ mesh, canvas, g, texture, kind: near.length === 1 || i === 0 ? 'speed' : 'rpm' })\n })\n }\n\n const lamp = (g: CanvasRenderingContext2D, x: number, y: number, on: boolean, colour: string, draw: (g: CanvasRenderingContext2D) => void): void => {\n g.save()\n g.translate(x, y)\n g.fillStyle = g.strokeStyle = on ? colour : DASHBOARD_LOOK.dim\n g.lineWidth = 4\n draw(g)\n g.restore()\n }\n const arrow = (dir: 1 | -1) => (g: CanvasRenderingContext2D) => {\n g.beginPath()\n g.moveTo(dir * 14, 0)\n g.lineTo(-dir * 2, -12)\n g.lineTo(-dir * 2, -5)\n g.lineTo(-dir * 14, -5)\n g.lineTo(-dir * 14, 5)\n g.lineTo(-dir * 2, 5)\n g.lineTo(-dir * 2, 12)\n g.closePath()\n g.fill()\n }\n const beam = (g: CanvasRenderingContext2D) => {\n g.beginPath()\n g.arc(-4, 0, 10, Math.PI / 2, -Math.PI / 2, true)\n g.closePath()\n g.fill()\n for (let k = -1; k <= 1; k++) g.fillRect(8, k * 6 - 1.5, 10, 3)\n }\n // a seated person with the belt across the chest\n const belt = (g: CanvasRenderingContext2D) => {\n g.beginPath()\n g.arc(0, -10, 5, 0, Math.PI * 2)\n g.fill()\n g.fillRect(-6, -3, 12, 16)\n g.strokeStyle = DASHBOARD_LOOK.face\n g.lineWidth = 3\n g.beginPath()\n g.moveTo(-7, -3)\n g.lineTo(7, 12)\n g.stroke()\n }\n const letter = (text: string) => (g: CanvasRenderingContext2D) => {\n g.font = 'bold 22px sans-serif'\n g.textAlign = 'center'\n g.textBaseline = 'middle'\n g.fillText(text, 0, 1)\n }\n const ring = (text: string) => (g: CanvasRenderingContext2D) => {\n g.beginPath()\n g.arc(0, 0, 13, 0, Math.PI * 2)\n g.stroke()\n letter(text)(g)\n }\n const dial = (g: CanvasRenderingContext2D, value: number, top: number, step: number, redFrom: number | null, label: (v: number) => string): void => {\n const c = SIZE / 2\n g.clearRect(0, 0, SIZE, SIZE)\n g.fillStyle = DASHBOARD_LOOK.face\n g.beginPath()\n g.arc(c, c, c - 2, 0, Math.PI * 2)\n g.fill()\n g.strokeStyle = DASHBOARD_LOOK.ring\n g.lineWidth = 6\n g.stroke()\n // 240 degrees of sweep, from the lower left round to the lower right\n const angle = (v: number): number => Math.PI * 0.75 + (Math.max(0, Math.min(top, v)) / top) * Math.PI * 1.5\n for (let v = 0; v <= top + 1e-6; v += step) {\n const a = angle(v)\n g.strokeStyle = redFrom !== null && v >= redFrom ? DASHBOARD_LOOK.red : DASHBOARD_LOOK.marks\n g.lineWidth = 4\n g.beginPath()\n g.moveTo(c + Math.cos(a) * (c - 12), c + Math.sin(a) * (c - 12))\n g.lineTo(c + Math.cos(a) * (c - 30), c + Math.sin(a) * (c - 30))\n g.stroke()\n g.fillStyle = DASHBOARD_LOOK.marks\n g.font = '18px sans-serif'\n g.textAlign = 'center'\n g.textBaseline = 'middle'\n g.fillText(label(v), c + Math.cos(a) * (c - 48), c + Math.sin(a) * (c - 48))\n }\n const a = angle(value)\n g.strokeStyle = DASHBOARD_LOOK.needle\n g.lineWidth = 6\n g.beginPath()\n g.moveTo(c - Math.cos(a) * 14, c - Math.sin(a) * 14)\n g.lineTo(c + Math.cos(a) * (c - 22), c + Math.sin(a) * (c - 22))\n g.stroke()\n g.fillStyle = DASHBOARD_LOOK.ring\n g.beginPath()\n g.arc(c, c, 10, 0, Math.PI * 2)\n g.fill()\n }\n const bar = (g: CanvasRenderingContext2D, x: number, share: number | undefined, warnAbove: boolean, label: string): void => {\n if (share === undefined) return\n const h = 60\n g.strokeStyle = DASHBOARD_LOOK.marks\n g.lineWidth = 2\n g.strokeRect(x - 5, 150, 10, h)\n const s = Math.max(0, Math.min(1, share))\n g.fillStyle = (warnAbove ? s > 0.85 : s < 0.12) ? DASHBOARD_LOOK.red : DASHBOARD_LOOK.marks\n g.fillRect(x - 4, 150 + h * (1 - s), 8, h * s)\n g.font = '14px sans-serif'\n g.textAlign = 'center'\n g.fillText(label, x, 222)\n }\n\n const draw = (r: DashboardReading): void => {\n const warn = r.ignition && !r.engineOn\n for (const f of faces) {\n const g = f.g\n if (f.kind === 'speed') {\n dial(g, r.kmh, maxKmh, maxKmh > 160 ? 20 : 10, null, (v) => String(Math.round(v)))\n g.fillStyle = DASHBOARD_LOOK.marks\n g.font = 'bold 30px sans-serif'\n g.textAlign = 'center'\n g.fillText(String(Math.round(r.kmh)), SIZE / 2, SIZE / 2 + 52)\n lamp(g, 92, 178, r.left, DASHBOARD_LOOK.green, arrow(-1))\n lamp(g, 164, 178, r.right, DASHBOARD_LOOK.green, arrow(1))\n lamp(g, 104, 214, r.highBeam, DASHBOARD_LOOK.blue, beam)\n lamp(g, 152, 214, r.lowBeam || r.fog, r.fog ? DASHBOARD_LOOK.amber : DASHBOARD_LOOK.green, beam)\n bar(g, 40, r.fuel, false, 'F')\n lamp(g, 104, 244, !!r.cruise, DASHBOARD_LOOK.green, letter('CRZ'))\n if (r.profile && r.profile !== 'normal') lamp(g, 152, 244, true, r.profile === 'eco' ? DASHBOARD_LOOK.green : DASHBOARD_LOOK.amber, letter(r.profile === 'eco' ? 'E' : 'S'))\n } else {\n dial(g, r.rpm / 1000, Math.ceil(redline / 1000) + 1, 1, redline / 1000, (v) => String(Math.round(v)))\n g.fillStyle = DASHBOARD_LOOK.marks\n g.font = 'bold 34px sans-serif'\n g.textAlign = 'center'\n g.fillText(r.gear < 0 ? 'R' : r.gear === 0 ? 'N' : String(r.gear), SIZE / 2, SIZE / 2 + 54)\n lamp(g, 86, 178, r.parkingBrake, DASHBOARD_LOOK.red, ring('P'))\n lamp(g, 128, 214, r.ignition && !r.seatbelt, DASHBOARD_LOOK.red, belt)\n lamp(g, 170, 178, warn || (r.engineOn && r.charging === false), DASHBOARD_LOOK.red, letter('+−'))\n lamp(g, 104, 244, r.ignition && !!r.tractionOff, DASHBOARD_LOOK.amber, letter('TC'))\n lamp(g, 152, 244, r.ignition && !!r.absOff, DASHBOARD_LOOK.amber, letter('ABS'))\n lamp(g, 86, 214, warn, DASHBOARD_LOOK.red, letter('OIL'))\n lamp(g, 170, 214, r.fourWheel, DASHBOARD_LOOK.green, letter('4x4'))\n bar(g, SIZE - 40, r.temperature, true, 'T')\n }\n f.texture.needsUpdate = true\n }\n }\n\n let wait = 0\n let last = ''\n return {\n dials: faces.length,\n update(reading, dt) {\n if (!faces.length) return\n wait -= dt\n const key = JSON.stringify(reading)\n if (wait > 0 || key === last) return\n wait = 1 / (options.fps ?? 15)\n last = key\n draw(reading)\n },\n dispose() {\n for (const f of faces) {\n discardObject3D(f.mesh)\n f.texture.dispose()\n f.canvas.width = f.canvas.height = 0\n }\n faces.length = 0\n for (const o of hidden) o.visible = true\n hidden.length = 0\n },\n }\n}\n","/**\n * The lamps of a built vehicle switched on and off: position, low and high beam, fog lamps, the brake and reversing lamps and the cabin light. The glass of\n * each lamp the kit drew (`context.lights`) glows by the switch, its halo shows only when lit, and the beams that light the world are sources of the host's\n * light budget (`game-render-three`), never lights of their own. The beacon lamps of an emergency vehicle (meshes the fleet tags `userData.lamp = 'beacon'`\n * with their `beaconSide`, 0 or 1) flash one side and then the other. Everything it changes is put back by `dispose`.\n */\nimport { isLightBudget, LIGHT_PRIORITY } from '@adatechnology/game-render-three'\nimport type { LightBudget, SourceHandle } from '@adatechnology/game-render-three'\n\nimport { strayLampsOf } from '@adatechnology/game-vehicles'\nimport type { VehicleContext } from '@adatechnology/game-vehicles'\nimport type { Box3, Object3D, Vector3 } from 'three'\n\nimport type { BuiltVehicle } from './build'\n\nexport type LampSwitch = {\n mode: 'off' | 'position' | 'low' | 'high'\n fog: boolean\n interior: boolean\n brake: boolean\n reverse: boolean\n /** Indicator lamps lit this instant (the controls blink them). */\n left: boolean\n right: boolean\n /** The beacon: the side lit this instant (0 or 1), null with it off. Default off. */\n beacon?: 0 | 1 | null\n}\n\n/** Glow of the lamp glass by switch, as a share of what the kit drew (the kit draws them lit), and the beams. */\nexport const LAMP_RULES = {\n glow: { head: { off: 0.04, position: 0.3, low: 1, high: 1.35 }, tail: { off: 0.15, on: 0.7, brake: 1.6 }, fog: { off: 0.04, on: 1.1 }, amber: { off: 0.1, on: 2.2 }, beacon: { off: 0.35, dark: 0.12, lit: 2.8 } },\n low: { color: 0xfff1d0, intensity: 2.4, distance: 32, angle: 0.42, penumbra: 0.55, decay: 1.6, drop: 0.09 },\n high: { color: 0xfff6e2, intensity: 3.6, distance: 70, angle: 0.3, penumbra: 0.45, decay: 1.4, drop: 0.015 },\n fog: { color: 0xfff0c8, intensity: 1.6, distance: 16, angle: 0.75, penumbra: 0.7, decay: 1.8, drop: 0.12 },\n reverse: { color: 0xf4f6ff, intensity: 0.9, distance: 7, decay: 2 },\n interior: { color: 0xffe2b0, intensity: 0.5, distance: 2.4, decay: 2 },\n} as const\n\n/** A lamp this close to the vehicle's axis (one headlight of a motorcycle) lights both sides of the beam. */\nconst CENTRE_LAMP_X = 0.05\n\nexport interface VehicleLamps {\n /** What this vehicle has: fog lamps only when the kit drew them. */\n readonly has: { head: boolean; tail: boolean; fog: boolean; indicators: boolean; beacon: boolean }\n set(lamps: LampSwitch): void\n readonly state: LampSwitch\n dispose(): void\n}\n\n/** A lamp's glass material: the kit's are emissive standard materials (`MATERIALS.head`, `tail`, `led`, `amber`). */\ntype Glass = { clone(): Glass; dispose?(): void; emissiveIntensity?: number; color?: { r: number; g: number; b: number } }\ntype Glazed = { material: Glass | Glass[] | null }\ntype Lamp = { kind: string; fog?: boolean; aux?: boolean; broken?: unknown; dark?: boolean; inner: Glazed[]; halo?: Array<{ visible: boolean; scale: { x: number; y: number; set(x: number, y: number, z: number): void } }>; group?: { position?: { x: number }; getWorldPosition?(target: Vector3): Vector3 } }\n\nexport function createVehicleLamps(THREE: { Object3D: new () => Object3D; Vector3: new () => Vector3; Box3: new () => Box3 }, built: BuiltVehicle, options: { lights?: unknown; owner?: string } = {}): VehicleLamps {\n const budget: LightBudget | null = isLightBudget(options.lights) ? options.lights : null\n const owner = options.owner ?? 'vehicle-lamps'\n // the kit's lamps, a fog lamp drawn as a headlight marked `fog`, and the lamps the body drew outside them (`strayLampsOf`: each fog bulb, each lit\n // strip of a bumper), every one its own lamp so a shot puts out only the one it hit. A stray lamp that is not a fog lamp (`aux`, a running lamp)\n // keeps the glow it was drawn with until it is put out. Kept as views of the kit's lamps: `broken` and `dark` are read from the kit's own object.\n const context = built.context as (VehicleContext & { lights?: Lamp[] }) | null\n const view = (l: Lamp, kind: string): Lamp => (l.kind === kind ? l : (Object.create(l, { kind: { value: kind } }) as Lamp))\n const lamps: Lamp[] = (context?.lights ?? [])\n .filter((l) => l && Array.isArray(l.inner))\n .map((l) => (l.fog ? view(l, 'fog') : l))\n for (const l of (context ? strayLampsOf(context, THREE) : []) as unknown as Lamp[]) lamps.push(view(l, l.fog ? 'fog' : 'aux'))\n const beacons: Array<{ mesh: Glazed; side: 0 | 1 }> = []\n built.group.traverse((o: Object3D & Partial<Glazed>) => {\n if (o.userData?.lamp === 'beacon' && o.material) beacons.push({ mesh: o as Glazed, side: o.userData.beaconSide === 1 ? 1 : 0 })\n })\n const has = { head: lamps.some((l) => l.kind === 'headlight'), tail: lamps.some((l) => l.kind === 'taillight'), fog: lamps.some((l) => l.kind === 'fog'), indicators: false, beacon: beacons.length > 0 }\n // the kit's lamp materials are shared by every vehicle: this one gets its own copies, given back on dispose\n const originals = new Map<Glazed, Glass>()\n const copies = new Map<Glass, Glass>()\n const copyOf = new Map<Glazed, Glass>()\n const base = new Map<Glass, number>()\n const own = (mesh: Glazed): Glass | null => {\n const mat = mesh.material\n if (!mat || Array.isArray(mat)) return null\n if (copies.has(mat) || base.has(mat)) return mat\n const copy = mat.clone()\n originals.set(mesh, mat)\n copies.set(copy, mat)\n copyOf.set(mesh, copy)\n base.set(copy, mat.emissiveIntensity ?? 1)\n mesh.material = copy\n return copy\n }\n for (const b of beacons) own(b.mesh)\n const haloBase = new Map<object, number>()\n for (const l of lamps) {\n for (const m of l.inner) own(m)\n for (const h of l.halo ?? []) haloBase.set(h, h.scale.x)\n }\n // the amber parts of a lamp (indicators) blink on their own: told by the colour of the kit's amber, and by the side of the lamp (left is +x)\n const amber = new Set<Glazed>()\n const sideOf = new Map<Glazed, 'left' | 'right'>()\n for (const l of lamps) {\n if (l.kind === 'aux') continue\n const x = l.group?.position?.x ?? 0\n for (const m of l.inner) {\n const mat = Array.isArray(m.material) ? null : m.material\n const c = (mat && (copies.get(mat) ?? mat))?.color\n if (c && c.r > 0.5 && c.r - c.b > 0.35 && c.g < c.r * 0.8 && c.g > c.b) {\n amber.add(m)\n sideOf.set(m, x >= 0 ? 'left' : 'right')\n }\n }\n }\n has.indicators = amber.size > 0\n const glowMesh = (m: Glazed, share: number): void => {\n const mat = m.material\n if (mat && !Array.isArray(mat) && base.has(mat) && 'emissiveIntensity' in mat) mat.emissiveIntensity = (base.get(mat) as number) * share\n }\n /** A lamp the shots broke or put out gives no light: no glow, no halo, no beam from its side. */\n const isOut = (l: Lamp): boolean => !!l.broken || !!l.dark\n const glow = (l: Lamp, share: number): void => {\n if (isOut(l)) {\n for (const h of l.halo ?? []) h.visible = false\n return\n }\n for (const m of l.inner) {\n if (amber.has(m)) continue\n glowMesh(m, share)\n }\n for (const h of l.halo ?? []) {\n h.visible = share > 0.5\n const s = (haloBase.get(h) ?? 1) * Math.min(1.4, share)\n h.scale.set(s, s, 1)\n }\n }\n\n // anchors on the vehicle for the beams: its front is +z, a spot shines down its anchor's -z\n const L = built.length\n const W = built.width\n const H = built.height\n const anchors: Object3D[] = []\n const anchor = (x: number, y: number, z: number, yaw: number, drop: number): Object3D => {\n const a = new THREE.Object3D()\n a.position.set(x, y, z)\n a.rotation.set(-drop, yaw, 0, 'YXZ')\n built.group.add(a)\n anchors.push(a)\n return a\n }\n const front = [-1, 1].map((s) => anchor(s * W * 0.34, Math.min(0.9, H * 0.48), L / 2 - 0.05, Math.PI, 0))\n const fogAnchors = [-1, 1].map((s) => anchor(s * W * 0.38, Math.min(0.45, H * 0.25), L / 2 - 0.03, Math.PI, 0))\n const rear = anchor(0, Math.min(0.9, H * 0.45), -L / 2 - 0.3, 0, 0)\n const cabin = anchor(0, H * 0.85, 0, 0, 0)\n\n const sources = new Map<string, SourceHandle[]>()\n const beam = (id: string, on: boolean, make: () => SourceHandle[], count?: number): void => {\n let now = sources.get(id)\n if (on && now && count !== undefined && now.length !== count) {\n for (const s of now) s.remove()\n sources.delete(id)\n now = undefined\n }\n if (on && !now && budget) sources.set(id, make())\n if (!on && now) {\n for (const s of now) s.remove()\n sources.delete(id)\n }\n }\n const spots = (at: Object3D[], rule: { color: number; intensity: number; distance: number; angle: number; penumbra: number; decay: number; drop: number }): SourceHandle[] =>\n at.map((a) => {\n a.rotation.x = -rule.drop\n return (budget as LightBudget).addSource({ owner, kind: 'spot', priority: LIGHT_PRIORITY.headlight, color: rule.color, intensity: rule.intensity, distance: rule.distance, decay: rule.decay, angle: rule.angle, penumbra: rule.penumbra, position: [0, 0, 0], follow: a })\n })\n const point = (a: Object3D, rule: { color: number; intensity: number; distance: number; decay: number }): SourceHandle[] => [\n (budget as LightBudget).addSource({ owner, kind: 'point', priority: LIGHT_PRIORITY.lamp, color: rule.color, intensity: rule.intensity, distance: rule.distance, decay: rule.decay, position: [0, 0, 0], follow: a }),\n ]\n\n // a beam is lit by a working lamp: a side whose headlight is out stays dark, and with every lamp of a kind out its beams and lights go\n const working = (kind: string): Lamp[] => lamps.filter((l) => l.kind === kind && !isOut(l))\n // the side of each headlight across the vehicle (its left is +x), read once from where the lamp sits in the group\n const across = new Map<Lamp, number>()\n built.group.updateMatrixWorld(true)\n for (const l of lamps) {\n const anchorObject = (l.group ?? l.inner[0]) as { getWorldPosition?(target: Vector3): Vector3 } | undefined\n const at = anchorObject?.getWorldPosition?.(new THREE.Vector3())\n if (at) across.set(l, built.group.worldToLocal(at).x)\n }\n const litOn = (kind: string, sign: -1 | 1): boolean => working(kind).some((l) => (across.get(l) ?? 0) * sign > 0 || Math.abs(across.get(l) ?? 0) < CENTRE_LAMP_X)\n const beamSide = (sign: -1 | 1): boolean => !has.head || litOn('headlight', sign)\n const health = (): string => lamps.map((l) => (isOut(l) ? 1 : 0)).join('')\n let healthSeen = health()\n const state: LampSwitch = { mode: 'off', fog: false, interior: false, brake: false, reverse: false, left: false, right: false }\n const apply = (): void => {\n const g = LAMP_RULES.glow\n for (const l of lamps) {\n if (l.kind === 'headlight') glow(l, g.head[state.mode])\n else if (l.kind === 'taillight') glow(l, state.brake ? g.tail.brake : state.mode === 'off' ? g.tail.off : g.tail.on)\n else if (l.kind === 'fog') glow(l, state.fog ? g.fog.on : g.fog.off)\n }\n for (const m of amber) glowMesh(m, state[sideOf.get(m) ?? 'left'] ? g.amber.on : g.amber.off)\n const lit = state.beacon ?? null\n for (const b of beacons) glowMesh(b.mesh, lit === null ? g.beacon.off : lit === b.side ? g.beacon.lit : g.beacon.dark)\n // the low and the high beam are the same two spots, re-aimed: switching re-adds them with the other cone\n const beamId = state.mode === 'low' || state.mode === 'high' ? state.mode : null\n const sides = ([-1, 1] as const).map(beamSide)\n for (const id of ['low', 'high'] as const) {\n // the spots of a beam come and go with the lamps that carry them: a side that went out is taken off the lit set and the rest are added again\n const lit = beamId === id ? front.filter((_, i) => sides[i]) : []\n beam(id, lit.length > 0, () => spots(lit, LAMP_RULES[id]), lit.length)\n }\n // each fog spot is carried by the fog lamps of its side: one shot out puts out its side, both put out the beam\n const fogLit = state.fog && has.fog ? fogAnchors.filter((_, i) => litOn('fog', i === 0 ? -1 : 1)) : []\n beam('fog', fogLit.length > 0, () => spots(fogLit, LAMP_RULES.fog), fogLit.length)\n beam('reverse', state.reverse && (!has.tail || working('taillight').length > 0), () => point(rear, LAMP_RULES.reverse))\n beam('interior', state.interior, () => point(cabin, LAMP_RULES.interior))\n }\n apply()\n\n return {\n has,\n get state() {\n return { ...state }\n },\n set(next) {\n const seen = health()\n if (seen === healthSeen && next.mode === state.mode && next.fog === state.fog && next.interior === state.interior && next.brake === state.brake && next.reverse === state.reverse && next.left === state.left && next.right === state.right && (next.beacon ?? null) === (state.beacon ?? null)) return\n healthSeen = seen\n Object.assign(state, next)\n apply()\n },\n dispose() {\n for (const list of sources.values()) for (const s of list) s.remove()\n sources.clear()\n for (const a of anchors) a.removeFromParent()\n anchors.length = 0\n const giveBack = (m: Glazed): void => {\n const original = originals.get(m)\n if (!original) return\n originals.delete(m)\n // a bulb the shots put out wears the dark material by now: that stays, but the copy it shed is still ours to free\n if (copies.has(m.material as Glass)) m.material = original\n copyOf.get(m)?.dispose?.()\n copyOf.delete(m)\n }\n for (const b of beacons) giveBack(b.mesh)\n for (const l of lamps) {\n for (const m of l.inner) giveBack(m)\n for (const h of l.halo ?? []) {\n h.visible = true\n const s = haloBase.get(h) ?? 1\n h.scale.set(s, s, 1)\n }\n }\n originals.clear()\n copies.clear()\n copyOf.clear()\n base.clear()\n },\n }\n}\n","/**\n * The mist on the inside of a built vehicle's glass, drawn from the fog share of `createWindshieldFog` (`game-vehicles-driving`). Each pane the kit drew\n * (`context.glass`) gets a thin pale film that follows it (a side window going down, a door swinging), on the pane's own geometry; the windshield shows\n * the whole share and the other panes a little less, since the demister blows on the windshield first. The film is never hit by a shot (it has no\n * raycast) and never writes depth. `dispose` takes the films away and frees their materials; the geometry is the pane's and stays.\n */\nimport type { BufferGeometry, Material, Mesh, Object3D, Side } from 'three'\n\nimport type { BuiltVehicle } from './build'\n\n/** What the mist needs of three.js. */\nexport type MistThree = {\n Mesh: new (geometry: BufferGeometry, material: Material) => Mesh\n MeshBasicMaterial: new (parameters: { color: number; transparent: boolean; opacity: number; depthWrite: boolean; side: Side; polygonOffset: boolean; polygonOffsetFactor: number; polygonOffsetUnits: number }) => Material & { opacity: number }\n}\n\n/** How the mist looks: its colour, how opaque full fog is, and the share of it on the side and rear panes. */\nexport const MIST_RULES = { color: 0xe4e8ec, opacity: 0.72, others: 0.8 } as const\n\nexport interface WindshieldMist {\n /** Panes with a film. */\n readonly panes: number\n /** Shows `fog` (0 clear to 1 misted over). */\n set(fog: number): void\n readonly fog: number\n dispose(): void\n}\n\ntype Pane = Object3D & { geometry?: BufferGeometry; material?: { side?: number } | unknown[]; userData: { glass?: { key?: string } } }\n/** three.js `DoubleSide`: the kit draws its glass from both faces, and the film is seen from inside and out the same way. */\nconst DOUBLE_SIDE: Side = 2\n\nexport function createWindshieldMist(THREE: MistThree, built: BuiltVehicle): WindshieldMist {\n const glass = ((built.context as { glass?: Pane[] } | null)?.glass ?? []).filter((p) => p?.geometry)\n const films: Array<{ mesh: Mesh; material: Material & { opacity: number }; share: number }> = []\n for (const pane of glass) {\n const side = (!Array.isArray(pane.material) && (pane.material as { side?: Side } | undefined)?.side) || DOUBLE_SIDE\n const material = new THREE.MeshBasicMaterial({ color: MIST_RULES.color, transparent: true, opacity: 0, depthWrite: false, side, polygonOffset: true, polygonOffsetFactor: -1, polygonOffsetUnits: -1 })\n const mesh = new THREE.Mesh(pane.geometry as BufferGeometry, material)\n mesh.name = 'windshield_mist'\n // the film is a look of the pane, not a piece: shots, blows and the camera's picking pass to the glass under it\n mesh.raycast = () => {}\n mesh.userData.mist = true\n // drawn right after its pane (the kit sorts its glass with a render order of its own)\n mesh.renderOrder = pane.renderOrder + 1\n mesh.visible = false\n pane.add(mesh)\n films.push({ mesh, material, share: pane.userData.glass?.key === 'windshield' ? 1 : MIST_RULES.others })\n }\n let fog = 0\n return {\n panes: films.length,\n get fog() {\n return fog\n },\n set(next) {\n const share = Math.max(0, Math.min(1, next))\n if (Math.abs(share - fog) < 0.005 && (share > 0) === (fog > 0)) return\n fog = share\n for (const f of films) {\n f.material.opacity = MIST_RULES.opacity * fog * f.share\n f.mesh.visible = fog > 0.01\n }\n },\n dispose() {\n for (const f of films) {\n // the geometry is the pane's: only the film's own material goes\n f.mesh.removeFromParent()\n f.material.dispose()\n }\n films.length = 0\n },\n }\n}\n","import type { Vec3 } from '@adatechnology/game-contracts'\n\n/** How many vehicles are heard at once: the nearest `max` to the listener keep their loops, the others are silent until they come closer. */\nexport type EngineBudget = {\n /** Reports where a vehicle is this frame; true when it is among the nearest `max` (it may sound). */\n admit(vehicle: object, position: Vec3): boolean\n /** Forgets a vehicle (it left the scene). */\n release(vehicle: object): void\n /** Vehicles being tracked. */\n readonly size: number\n}\n\nexport type EngineBudgetOptions = {\n /** Default 6: a street of idling cars is a hum, not a wall of a hundred engines. */\n readonly max?: number\n /** Where the listener is (the camera or the player). */\n readonly listener: () => Vec3\n}\n\nconst distanceSq = (a: Vec3, b: Vec3): number => (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 + (a[2] - b[2]) ** 2\n\n/**\n * A level of detail for vehicle sound, shared by every `createVehicleSound` of a scene (`VehicleSoundOptions.budget`): each vehicle reports its\n * place every frame and only the nearest `max` keep their engine and tyre loops. A vehicle that falls out fades its loops to silence; its one-shots\n * (a crash, the starter) still play, since they are rare and the engine's voice limiter already ranks them.\n */\nexport function createEngineBudget(options: EngineBudgetOptions): EngineBudget {\n const max = Math.max(1, options.max ?? 6)\n const places = new Map<object, number>()\n return {\n admit(vehicle, position) {\n const own = distanceSq(position, options.listener())\n places.set(vehicle, own)\n if (places.size <= max) return true\n // its rank among the vehicles reported: how many are nearer (ties go to the one reported first)\n let nearer = 0\n for (const [other, d] of places) {\n if (other === vehicle) continue\n if (d < own) nearer++\n if (nearer >= max) return false\n }\n return true\n },\n release(vehicle) {\n places.delete(vehicle)\n },\n get size() {\n return places.size\n },\n }\n}\n","/**\n * The wheels of a built vehicle turning as it moves: each wheel the kit drew (`context.wheels`) rolls about its axle by the distance travelled over\n * its radius, and the front ones turn with the steering. The turn is applied over the wheel's own rest pose, so a mirrored or tilted wheel rolls the\n * right way, and `dispose` puts every wheel back exactly as it was drawn.\n */\nimport type { BuiltVehicle } from './build'\n\ntype Vec = { x: number; y: number; z: number }\ntype Quat = { copy(q: Quat): Quat; clone(): Quat; setFromAxisAngle(axis: Vec, angle: number): Quat; multiply(q: Quat): Quat; premultiply(q: Quat): Quat }\ntype Wheel = { position: Vec; quaternion: Quat; userData: Record<string, unknown> }\n\n/** What the wheels need of three.js. */\nexport type WheelRollThree = { Vector3: new (x?: number, y?: number, z?: number) => Vec; Quaternion: new () => Quat }\n\nexport interface WheelRoll {\n /** Wheels found on the vehicle. */\n readonly count: number\n /** The vehicle went `distance` metres forward (negative backwards) with the front wheels steered `steer` radians (positive to the left). */\n roll(distance: number, steer: number): void\n dispose(): void\n}\n\n/** A wheel's radius when the kit did not record one, metres. */\nconst DEFAULT_RADIUS = 0.32\n\nexport function createWheelRoll(THREE: WheelRollThree, built: BuiltVehicle): WheelRoll {\n const wheels = ((built.context as { wheels?: Wheel[] } | null)?.wheels ?? []).map((wheel) => ({\n wheel,\n rest: wheel.quaternion.clone(),\n radius: Number(wheel.userData.r) || DEFAULT_RADIUS,\n // in the kit's frame the front is +x: the wheels ahead of the middle steer\n front: wheel.position.x > 0,\n angle: 0,\n }))\n // the kit's frame: x forward, y up, z to the right; a wheel rolling forward turns about +z the negative way\n const axle = new THREE.Vector3(0, 0, 1)\n const up = new THREE.Vector3(0, 1, 0)\n const spin = new THREE.Quaternion()\n const steering = new THREE.Quaternion()\n return {\n count: wheels.length,\n roll(distance, steer) {\n for (const w of wheels) {\n w.angle = (w.angle - distance / w.radius) % (Math.PI * 2)\n spin.setFromAxisAngle(axle, w.angle)\n steering.setFromAxisAngle(up, w.front ? steer : 0)\n w.wheel.quaternion.copy(w.rest).premultiply(spin).premultiply(steering)\n }\n },\n dispose() {\n for (const w of wheels) w.wheel.quaternion.copy(w.rest)\n },\n }\n}\n","/**\n * The proving ground's crash against an immovable wall: the driven car stops dead, the pulse goes to `ejectionOf` of `game-vehicles-driving`, and an\n * occupant without a belt breaks the glass of the exit and flies out: a person of the host's catalogue thrown with `launchBody`, so the module that\n * animates it flies, lands, slides and lays it down as it does a body a blast knocked over. Everything it adds goes on `dispose`.\n */\nimport { launchBody } from '@adatechnology/game-contracts'\nimport type { ModuleHost, Vec3 } from '@adatechnology/game-contracts'\nimport { ejectionOf } from '@adatechnology/game-vehicles-driving'\nimport type { Ejection } from '@adatechnology/game-vehicles-driving'\nimport type { VehicleDestructible } from '@adatechnology/game-vehicles'\n\n/** Energy of the body against the glass, joules: enough to break a windshield or a side window. */\nconst GLASS_BLOW = 6000\n\ntype Root = { position: { x: number; y: number; z: number }; userData: Record<string, unknown> }\n\nexport interface ProvingCrash {\n /** Stops the car dead against a wall: answers the ejection, or null when the occupant stays in. */\n crash(params: { car: { position: Root['position']; rotationY: number }; u: number; w: number; belted: boolean; destructible: VehicleDestructible | null }): Ejection | null\n dispose(): void\n}\n\nexport function createProvingCrash(host: ModuleHost, occupant: string | undefined): ProvingCrash {\n const thrown: Array<() => void> = []\n const breakGlass = (destructible: VehicleDestructible | null, exit: Ejection['exit'], forward: Vec3): void => {\n if (!destructible) return\n const want = exit === 'windshield' ? 'windshield' : exit === 'rear_window' ? 'rear' : exit.startsWith('left') ? 'left' : 'right'\n const pane = destructible.describe().parts.find((p) => p.id.includes(exit === 'windshield' || exit === 'rear_window' ? want : 'window') && (exit === 'windshield' || exit === 'rear_window' || p.id.includes(want)))\n if (!pane) return\n destructible.hit({ type: 'blunt', partId: pane.id, point: destructible.partWorldCenter(pane.id), direction: forward, energy: GLASS_BLOW, radius: 0.35, source: 'occupant' } as never)\n }\n return {\n crash({ car, u, w, belted, destructible }) {\n const ejection = ejectionOf({ before: { u, w }, after: { u: 0, w: 0 } }, belted)\n if (!ejection) return null\n // the game frame: front +z, right −x, turned by the car's yaw\n const s = Math.sin(car.rotationY)\n const c = Math.cos(car.rotationY)\n const forward: Vec3 = [s, 0, c]\n const right: Vec3 = [-c, 0, s]\n breakGlass(destructible, ejection.exit, forward)\n const [vf, vr, vu] = ejection.velocity\n const start: Vec3 = [car.position.x + forward[0] * 1.2, 1.1, car.position.z + forward[2] * 1.2]\n const placed = occupant ? host.addObject?.(occupant, { position: start, rotationY: car.rotationY }) : null\n if (placed) {\n launchBody(placed.root as Root, [forward[0] * vf + right[0] * vr, vu, forward[2] * vf + right[2] * vr])\n thrown.push(placed.remove)\n }\n return ejection\n },\n dispose() {\n for (const remove of thrown.splice(0)) remove()\n },\n }\n}\n","/** The words of the car's systems and driver aids in the proving ground: the bench actions that test them and the log lines of what they report. */\nexport interface SystemsText {\n keys: string\n profile: string\n profiles: Record<'eco' | 'normal' | 'sport', string>\n traction: string\n abs: string\n cruise: string\n cruiseSet: string\n climate: string\n demist: string\n wiperModes: Record<'off' | 'intermittent' | 'slow' | 'fast', string>\n refused: Record<'battery_flat' | 'too_slow' | 'locked' | 'missing' | 'no_key' | 'no_siren', string>\n events: Record<'stall' | 'out_of_fuel' | 'bogged' | 'aquaplaning' | 'battery_flat' | 'overheating' | 'seized' | 'spare_fitted' | 'no_spare' | 'cruise_cancelled' | 'hotwire_started' | 'hotwire_joined', string>\n actions: Record<\n | 'puncture'\n | 'fit_spare'\n | 'refuel'\n | 'drain_battery'\n | 'jump_start'\n | 'break_radiator'\n | 'empty_tank'\n | 'remote_lock'\n | 'remote_unlock'\n | 'force_door'\n | 'crash_wall'\n | 'park_behind'\n | 'take_key'\n | 'cold_rain'\n | 'glovebox_contents'\n | 'trunk_contents'\n | 'take_from_trunk',\n string\n >\n /** The siren, the beacon and the glovebox switches as the log shows them. */\n siren: string\n sirenModes: Record<'off' | 'wail' | 'yelp', string>\n beacon: string\n glovebox: string\n lid: Record<'open' | 'shut', string>\n storage: { names: Record<'glovebox' | 'trunk', string>; empty: string; shut: string; list: string; none: string; taken: string; ground: string }\n fog: { misted: string; clear: string; weather: string; fair: string; metric: string }\n keyTaken: string\n keyBack: string\n parking: Record<'placed' | 'none', string>\n track: string\n adjust: Record<'seat_forward' | 'seat_height' | 'mirror_left' | 'mirror_right', string>\n crash: { mild: string; stayed: string; ejected: string; exits: Record<'windshield' | 'left_window' | 'right_window' | 'rear_window', string> }\n bodyKeys: string\n remote: Record<'locked' | 'unlocked' | 'forced', string>\n done: Record<'puncture' | 'refuel' | 'drain_battery' | 'jump_start' | 'break_radiator' | 'empty_tank', string>\n}\n\nexport const SYSTEMS_TEXT: Record<string, SystemsText> = {\n 'pt-BR': {\n keys: 'C embreagem (câmbio manual) · X lampejo do farol alto · Z esguicho do limpador · 7 modo econômico/normal/esporte · 8 controle de tração · 9 ABS · 0 piloto automático · - ar-condicionado · = desembaçador · ] troca a faixa do rádio ou da fita · ; sirene · \\' giroflex (veículo de emergência) · / porta-luvas · sem a chave, segure I: ligação direta',\n profile: 'Modo de condução',\n profiles: { eco: 'econômico', normal: 'normal', sport: 'esporte' },\n traction: 'Controle de tração',\n abs: 'ABS',\n cruise: 'Piloto automático',\n cruiseSet: 'Piloto automático: segurando {0} km/h',\n climate: 'Ar-condicionado',\n demist: 'Desembaçador',\n wiperModes: { off: 'desligado', intermittent: 'intermitente', slow: 'lento', fast: 'rápido' },\n refused: { battery_flat: 'Bateria descarregada: o motor de partida não gira', too_slow: 'Piloto automático só acima de 30 km/h', locked: 'Porta travada', missing: 'Este veículo não tem essa peça', no_key: 'Sem a chave: segure I para fazer a ligação direta', no_siren: 'Este veículo não tem sirene nem giroflex' },\n events: {\n stall: 'O motor morreu',\n out_of_fuel: 'Acabou o combustível',\n bogged: 'Atolou',\n aquaplaning: 'Aquaplanagem',\n battery_flat: 'A bateria descarregou',\n overheating: 'Motor superaquecendo: perdendo potência',\n seized: 'O motor fundiu de tanto esquentar',\n spare_fitted: 'Estepe colocado',\n no_spare: 'Não há estepe',\n cruise_cancelled: 'Piloto automático desligado',\n hotwire_started: 'Fios descascados sob a coluna: continue segurando I',\n hotwire_joined: 'Ligação direta feita: a ignição pegou e o motor de partida gira',\n },\n actions: { puncture: 'Furar pneu (dianteiro esquerdo)', fit_spare: 'Trocar pelo estepe', refuel: 'Abastecer', drain_battery: 'Descarregar bateria', jump_start: 'Chupeta (carregar bateria)', break_radiator: 'Furar o radiador', empty_tank: 'Deixar o tanque na reserva', remote_lock: 'Controle: travar (arma o alarme)', remote_unlock: 'Controle: destravar', force_door: 'Forçar a porta do motorista', crash_wall: 'Bater no muro (parada seca)', park_behind: 'Estacionar um carro atrás (sensor de ré)', take_key: 'Tirar a chave (ligação direta) / devolver', cold_rain: 'Tempo: frio e chuva / bom', glovebox_contents: 'Ver o porta-luvas', trunk_contents: 'Ver o porta-malas', take_from_trunk: 'Tirar um item do porta-malas para o chão' },\n siren: 'Sirene',\n sirenModes: { off: 'desligada', wail: 'contínua', yelp: 'rápida (cruzamento)' },\n beacon: 'Giroflex',\n glovebox: 'Porta-luvas',\n lid: { open: 'aberto', shut: 'fechado' },\n storage: { names: { glovebox: 'Porta-luvas', trunk: 'Porta-malas' }, empty: '{0}: vazio', shut: '{0} fechado: abra antes (porta-luvas com / sentado, porta-malas com 6)', list: '{0} ({1} kg): {2}', none: 'Este veículo não tem {0}', taken: '{0} tirado do porta-malas e posto no chão', ground: '{0} tirado do porta-malas (sem catálogo de itens nesta sala para pô-lo no chão)' },\n fog: { misted: 'O para-brisa embaçou por dentro: = desembaçador, ar-condicionado ou um vidro aberto', clear: 'Para-brisa desembaçado', weather: 'Lá fora: 8 °C e chuva', fair: 'Lá fora: 25 °C, sem chuva', metric: 'Vidro embaçado' },\n keyTaken: 'Sem a chave no contato: segure I para a ligação direta',\n keyBack: 'Chave de volta no contato',\n parking: { placed: 'Carro parado 3 m atrás: dê ré e escute o sensor', none: 'Sem catálogo de veículos nesta sala: o sensor não tem o que ver' },\n track: 'faixa {0}',\n adjust: { seat_forward: 'Banco: frente/trás (m)', seat_height: 'Banco: altura (m)', mirror_left: 'Retrovisor esquerdo: ângulo', mirror_right: 'Retrovisor direito: ângulo' },\n crash: { mild: 'Batida a {0} km/h: fraca demais para lançar quem está sem cinto', stayed: 'Batida a {0} km/h: o cinto segurou o motorista', ejected: 'Batida a {0} km/h sem cinto: o motorista saiu pelo {1}', exits: { windshield: 'para-brisa', left_window: 'vidro esquerdo', right_window: 'vidro direito', rear_window: 'vidro traseiro' } },\n bodyKeys: '1 a 4 portas · 5 capô · 6 porta-malas · Shift+1 a 4 vidros · Shift+5 teto solar · V trava as portas',\n remote: { locked: 'Travado pelo controle: alarme armado', unlocked: 'Destravado pelo controle', forced: 'Porta forçada' },\n done: { puncture: 'Pneu dianteiro esquerdo furado', refuel: 'Tanque cheio', drain_battery: 'Bateria quase sem carga', jump_start: 'Bateria carregada', break_radiator: 'Radiador furado: o motor vai esquentar', empty_tank: 'Tanque na reserva' },\n },\n en: {\n keys: \"C clutch (manual gearbox) · X flash the high beam · Z washer · 7 eco/normal/sport · 8 traction control · 9 ABS · 0 cruise control · - air conditioning · = demister · ] next radio or tape track · ; siren · ' beacon (emergency vehicle) · / glovebox · without the key, hold I: hotwire\",\n profile: 'Drive profile',\n profiles: { eco: 'eco', normal: 'normal', sport: 'sport' },\n traction: 'Traction control',\n abs: 'ABS',\n cruise: 'Cruise control',\n cruiseSet: 'Cruise control: holding {0} km/h',\n climate: 'Air conditioning',\n demist: 'Demister',\n wiperModes: { off: 'off', intermittent: 'intermittent', slow: 'slow', fast: 'fast' },\n refused: { battery_flat: 'Flat battery: the starter does not turn', too_slow: 'Cruise control only above 30 km/h', locked: 'The door is locked', missing: 'This vehicle has no such part', no_key: 'No key: hold I to hotwire it', no_siren: 'This vehicle has no siren or beacon' },\n events: {\n stall: 'The engine stalled',\n out_of_fuel: 'Out of fuel',\n bogged: 'Bogged down',\n aquaplaning: 'Aquaplaning',\n battery_flat: 'The battery went flat',\n overheating: 'Engine overheating: losing power',\n seized: 'The engine seized from the heat',\n spare_fitted: 'Spare tyre fitted',\n no_spare: 'No spare tyre left',\n cruise_cancelled: 'Cruise control off',\n hotwire_started: 'Wires stripped under the column: keep holding I',\n hotwire_joined: 'Hotwired: the ignition is live and the starter turns',\n },\n actions: { puncture: 'Puncture a tyre (front left)', fit_spare: 'Fit the spare', refuel: 'Refuel', drain_battery: 'Drain the battery', jump_start: 'Jump start (charge the battery)', break_radiator: 'Puncture the radiator', empty_tank: 'Leave the tank on reserve', remote_lock: 'Remote: lock (arms the alarm)', remote_unlock: 'Remote: unlock', force_door: \"Force the driver's door\", crash_wall: 'Hit a wall (dead stop)', park_behind: 'Park a car behind (rear sensor)', take_key: 'Take the key out (hotwire) / give it back', cold_rain: 'Weather: cold and rain / fair', glovebox_contents: 'Look in the glovebox', trunk_contents: 'Look in the trunk', take_from_trunk: 'Take an item out of the trunk to the ground' },\n siren: 'Siren',\n sirenModes: { off: 'off', wail: 'wail', yelp: 'yelp (junction)' },\n beacon: 'Beacon',\n glovebox: 'Glovebox',\n lid: { open: 'open', shut: 'shut' },\n storage: { names: { glovebox: 'Glovebox', trunk: 'Trunk' }, empty: '{0}: empty', shut: '{0} shut: open it first (glovebox with / while seated, trunk with 6)', list: '{0} ({1} kg): {2}', none: 'This vehicle has no {0}', taken: '{0} taken out of the trunk and put on the ground', ground: '{0} taken out of the trunk (no item catalogue in this room to put it on the ground)' },\n fog: { misted: 'The windshield misted up inside: = demister, air conditioning or a window down', clear: 'Windshield clear', weather: 'Outside: 8 °C and rain', fair: 'Outside: 25 °C, no rain', metric: 'Glass misted' },\n keyTaken: 'No key in the ignition: hold I to hotwire',\n keyBack: 'Key back in the ignition',\n parking: { placed: 'A car parked 3 m behind: reverse and listen to the sensor', none: 'No vehicle catalogue in this room: the sensor has nothing to see' },\n track: 'track {0}',\n adjust: { seat_forward: 'Seat: forward/back (m)', seat_height: 'Seat: height (m)', mirror_left: 'Left mirror: angle', mirror_right: 'Right mirror: angle' },\n crash: { mild: 'Crash at {0} km/h: too mild to throw an unbelted occupant out', stayed: 'Crash at {0} km/h: the belt held the driver', ejected: 'Crash at {0} km/h without a belt: the driver went out through the {1}', exits: { windshield: 'windshield', left_window: 'left window', right_window: 'right window', rear_window: 'rear window' } },\n bodyKeys: '1 to 4 doors · 5 hood · 6 trunk · Shift+1 to 4 windows · Shift+5 sunroof · V locks the doors',\n remote: { locked: 'Locked by the remote: alarm armed', unlocked: 'Unlocked by the remote', forced: 'Door forced' },\n done: { puncture: 'Front left tyre punctured', refuel: 'Tank full', drain_battery: 'Battery almost flat', jump_start: 'Battery charged', break_radiator: 'Radiator punctured: the engine will heat up', empty_tank: 'Tank on reserve' },\n },\n}\n","/** Texts of the proving ground, in Brazilian Portuguese and English. */\nexport type ProvingText = {\n name: string\n controls: Record<'vehicle' | 'test' | 'camera' | 'time_scale' | 'visual_check' | 'gearbox', string>\n hints: Record<'vehicle' | 'test' | 'camera' | 'time_scale' | 'visual_check' | 'gearbox', string>\n gearbox: Record<'automatic' | 'manual', string>\n actions: Record<'drive' | 'run_test' | 'run_all' | 'certify_now' | 'reverse_park' | 'sign_ok' | 'sign_fail' | 'reset', string>\n layers: Record<'mirrors' | 'reverse_camera' | 'scoreboard', string>\n metrics: Record<'gear' | 'rpm' | 'speed' | 'time' | 'value' | 'passed' | 'failed' | 'pending' | 'status', string>\n cameras: Record<'room' | 'chase' | 'cockpit' | 'hood', string>\n tests: Record<string, string>\n status: Record<'approved' | 'rejected' | 'pending', string>\n verdict: Record<'pass' | 'fail' | 'pending', string>\n board: { title: string; test: string; value: string; range: string; verdict: string; notRun: string; running: string; gear: string }\n log: { start: string; result: string; signed: string; certified: string; drive: string; leave: string; shift: string }\n cabin: {\n keys: string\n on: string\n off: string\n ignition: string\n gearbox: string\n gear: string\n parkingBrake: string\n driveMode: string\n modes: Record<'4x2' | '4x4' | 'auto', string>\n lights: string\n lampModes: Record<'off' | 'position' | 'low' | 'high', string>\n fog: string\n interior: string\n alarm: string\n alarmStates: Record<'off' | 'armed' | 'ringing', string>\n radio: string\n sources: Record<'radio' | 'tape', string>\n indicator: string\n indicators: Record<'off' | 'left' | 'right' | 'hazard', string>\n wipers: string\n wiperModes: Record<'off' | 'slow' | 'fast', string>\n seatbelt: string\n refused: Record<string, string>\n }\n}\n\nexport const PROVING_TEXT: Record<string, ProvingText> = {\n 'pt-BR': {\n name: 'Banco de provas',\n controls: { vehicle: 'Veículo', test: 'Prova', camera: 'Câmera', time_scale: 'Velocidade da simulação', visual_check: 'Checagem visual', gearbox: 'Câmbio' },\n gearbox: { automatic: 'Automático', manual: 'Manual' },\n hints: {\n gearbox: 'Automático troca sozinho. Manual: E sobe e Q desce a marcha (abaixo da 1ª vêm o neutro e a ré). M alterna dirigindo',\n vehicle: 'Veículo da frota que vai para a pista',\n test: 'Prova medida que o botão Rodar prova executa',\n camera: 'Sala: a câmera do jogador. Perseguição, cabine e capô seguem o veículo',\n time_scale: 'Quantas vezes mais rápido que o tempo real a prova roda',\n visual_check: 'O que você olhou e vai aprovar ou reprovar',\n },\n actions: { drive: 'Dirigir (entrar / sair)', run_test: 'Rodar prova', run_all: 'Rodar todas na pista', certify_now: 'Homologar agora (sem animação)', reverse_park: 'Dar ré (câmera de ré)', sign_ok: 'Aprovar checagem visual', sign_fail: 'Reprovar checagem visual', reset: 'Limpar ficha' },\n layers: { mirrors: 'Retrovisores', reverse_camera: 'Câmera de ré', scoreboard: 'Painel da ficha' },\n metrics: { gear: 'Marcha (-1 ré, 0 neutro)', rpm: 'Rotação', speed: 'Velocidade', time: 'Tempo da prova', value: 'Medição', passed: 'Aprovadas', failed: 'Reprovadas', pending: 'Pendentes', status: 'Situação (0 pend., 1 aprov., -1 reprov.)' },\n cameras: { room: 'Sala', chase: 'Perseguição (3ª pessoa)', cockpit: 'Cabine (1ª pessoa)', hood: 'Capô' },\n tests: {\n accel_0_100: '0 a 100 km/h',\n top_speed: 'Velocidade máxima',\n brake_100_0: 'Frenagem 100 a 0',\n turn_circle: 'Diâmetro de giro',\n wet_brake_80_0: 'Frenagem molhada 80 a 0',\n mud_traction: 'Tração na lama',\n cabin: 'Cabine e personagem',\n cameras: 'Câmeras',\n mirrors: 'Retrovisores e ré',\n terrain: 'Terrenos',\n wind_tunnel: 'Túnel de vento',\n crash_test: 'Crash test',\n pedestrian: 'Atropelamento',\n performance: 'Desempenho',\n buoyancy: 'Flutuação',\n flight: 'Voo',\n },\n status: { approved: 'APROVADO', rejected: 'REPROVADO', pending: 'PENDENTE' },\n verdict: { pass: 'ok', fail: 'falhou', pending: '…' },\n board: { title: 'Ficha de homologação', test: 'Prova', value: 'Medido', range: 'Faixa', verdict: 'Resultado', notRun: 'não rodada', running: 'rodando', gear: 'Marcha {0} · {1} rpm · {2} km/h' },\n log: { start: 'Prova {0}: {1}', result: '{0} · {1}: {2} {3} (faixa {4}) → {5}', signed: '{0} · {1}: {2} na sala', certified: '{0}: {1}', drive: 'Dirigindo {0}: I liga o motor, F sai do carro', leave: 'Saiu do volante', shift: 'Marcha {0} → {1} a {2} km/h' },\n cabin: {\n keys: 'W ou ↑ acelera · S ou ↓ freia (parado, dá ré) · A/D ou ←/→ vira · Espaço freio de mão · P puxa o freio de mão · I liga e desliga · M câmbio manual/automático · E sobe e Q desce marcha · G tração 4x2/4x4/4x4 automática · L luzes (posição, baixa) · K farol alto · N neblina · U luz interna · vírgula e ponto setas · B pisca-alerta · O limpador · J cinto · H buzina · Y alarme · R rádio · T rádio/fita · F sai do carro',\n on: 'ligado',\n off: 'desligado',\n ignition: 'Motor',\n gearbox: 'Câmbio',\n gear: 'Marcha',\n parkingBrake: 'Freio de mão',\n driveMode: 'Tração',\n modes: { '4x2': '4x2', '4x4': '4x4', auto: '4x4 automática' },\n lights: 'Luzes',\n lampModes: { off: 'apagadas', position: 'posição', low: 'farol baixo', high: 'farol alto' },\n fog: 'Neblina',\n interior: 'Luz interna',\n alarm: 'Alarme',\n alarmStates: { off: 'desligado', armed: 'armado', ringing: 'disparado' },\n radio: 'Som',\n sources: { radio: 'rádio', tape: 'toca-fitas' },\n indicator: 'Setas',\n indicators: { off: 'desligadas', left: 'esquerda', right: 'direita', hazard: 'pisca-alerta' },\n wipers: 'Limpador',\n wiperModes: { off: 'desligado', slow: 'lento', fast: 'rápido' },\n seatbelt: 'Cinto',\n refused: { no_four_wheel_drive: 'Este veículo não tem tração 4x4', no_fog_lamps: 'Este veículo não tem farol de neblina', ignition_off: 'Ligue o motor primeiro' },\n },\n },\n en: {\n name: 'Proving ground',\n controls: { vehicle: 'Vehicle', test: 'Test', camera: 'Camera', time_scale: 'Simulation speed', visual_check: 'Visual check', gearbox: 'Gearbox' },\n gearbox: { automatic: 'Automatic', manual: 'Manual' },\n hints: {\n gearbox: 'Automatic shifts by itself. Manual: E shifts up and Q down (below 1st come neutral and reverse). M switches while driving',\n vehicle: 'Fleet vehicle that goes on the track',\n test: 'Measured test the Run test button runs',\n camera: 'Room: the player camera. Chase, cockpit and hood follow the vehicle',\n time_scale: 'How many times faster than real time the test runs',\n visual_check: 'What you looked at and will approve or refuse',\n },\n actions: { drive: 'Drive (get in / out)', run_test: 'Run test', run_all: 'Run all on the track', certify_now: 'Certify now (no animation)', reverse_park: 'Reverse (reversing camera)', sign_ok: 'Approve visual check', sign_fail: 'Refuse visual check', reset: 'Clear certificate' },\n layers: { mirrors: 'Mirrors', reverse_camera: 'Reversing camera', scoreboard: 'Certificate board' },\n metrics: { gear: 'Gear (-1 reverse, 0 neutral)', rpm: 'Engine speed', speed: 'Speed', time: 'Test time', value: 'Measured', passed: 'Passed', failed: 'Failed', pending: 'Pending', status: 'Status (0 pending, 1 approved, -1 rejected)' },\n cameras: { room: 'Room', chase: 'Chase (third person)', cockpit: 'Cockpit (first person)', hood: 'Hood' },\n tests: {\n accel_0_100: '0 to 100 km/h',\n top_speed: 'Top speed',\n brake_100_0: 'Braking 100 to 0',\n turn_circle: 'Turning circle',\n wet_brake_80_0: 'Wet braking 80 to 0',\n mud_traction: 'Mud traction',\n cabin: 'Cabin and character',\n cameras: 'Cameras',\n mirrors: 'Mirrors and reversing',\n terrain: 'Terrain',\n wind_tunnel: 'Wind tunnel',\n crash_test: 'Crash test',\n pedestrian: 'Pedestrian impact',\n performance: 'Performance',\n buoyancy: 'Buoyancy',\n flight: 'Flight',\n },\n status: { approved: 'APPROVED', rejected: 'REJECTED', pending: 'PENDING' },\n verdict: { pass: 'ok', fail: 'failed', pending: '…' },\n board: { title: 'Certificate', test: 'Test', value: 'Measured', range: 'Range', verdict: 'Result', notRun: 'not run', running: 'running', gear: 'Gear {0} · {1} rpm · {2} km/h' },\n log: { start: 'Test {0}: {1}', result: '{0} · {1}: {2} {3} (range {4}) → {5}', signed: '{0} · {1}: {2} in the room', certified: '{0}: {1}', drive: 'Driving {0}: I starts the engine, F gets out', leave: 'Left the wheel', shift: 'Gear {0} → {1} at {2} km/h' },\n cabin: {\n keys: 'W or ↑ accelerates · S or ↓ brakes (stopped, reverses) · A/D or ←/→ steer · Space handbrake · P pulls the handbrake · I ignition · M manual/automatic gearbox · E shifts up, Q down · G drive 4x2/4x4/auto 4x4 · L lamps (position, low) · K high beam · N fog · U cabin light · comma and period indicators · B hazard · O wipers · J seat belt · H horn · Y alarm · R radio · T radio/tape · F gets out',\n on: 'on',\n off: 'off',\n ignition: 'Engine',\n gearbox: 'Gearbox',\n gear: 'Gear',\n parkingBrake: 'Handbrake',\n driveMode: 'Drive',\n modes: { '4x2': '4x2', '4x4': '4x4', auto: 'automatic 4x4' },\n lights: 'Lamps',\n lampModes: { off: 'off', position: 'position', low: 'low beam', high: 'high beam' },\n fog: 'Fog lamps',\n interior: 'Cabin light',\n alarm: 'Alarm',\n alarmStates: { off: 'off', armed: 'armed', ringing: 'ringing' },\n radio: 'Sound',\n sources: { radio: 'radio', tape: 'tape' },\n indicator: 'Indicators',\n indicators: { off: 'off', left: 'left', right: 'right', hazard: 'hazard' },\n wipers: 'Wipers',\n wiperModes: { off: 'off', slow: 'slow', fast: 'fast' },\n seatbelt: 'Seat belt',\n refused: { no_four_wheel_drive: 'This vehicle has no 4x4', no_fog_lamps: 'This vehicle has no fog lamps', ignition_off: 'Start the engine first' },\n },\n },\n}\n\nexport const fillText = (template: string, ...values: Array<string | number>): string => template.replace(/\\{(\\d+)\\}/g, (_, i) => String(values[Number(i)] ?? ''))\n"],"mappings":";AACA,SAAS,mBAAmB,qBAAAA,oBAAmB,wBAAwB;AACvE,SAAS,uBAAuB;AAEhC,SAAS,kBAAkB,sBAAsB,mBAAmB,6BAAAC,4BAA2B,wBAAwB;AAEvH,SAAS,qBAAqB;AAC9B,SAAS,sBAAAC,qBAAoB,uBAAAC,sBAAqB,kBAAAC,iBAAgB,kBAAAC,uBAAsB;AAExF,SAAS,eAAe,WAAW,oBAAoB,cAAc,eAAe,iBAAiB;;;ACTrG,SAAS,qBAAqB;AAK9B,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,qBAAa;AACb,kBAAU;AACV,oBAAY;AACZ,oBAAY;AACZ,iBAAS;AACT,aAAK,gBAAgB,IAAI;AACzB,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;AAKO,SAAS,kBAAgD,MAAY,SAA+D;AACzI,SAAO,KAAK,WAAW,oBAAoB,OAAO,CAAU;AAC9D;","names":["DEFERRED_QUEUE_ID","createVehicleDestructible","createArcadeDriver","createSemiSimDriver","createSurfaces","vehicleCorners","colorFromSeed","fleetDims","paintPalettes","paletteOf","count","CELL_BIAS","CELL_SPAN","isShown","known","markKitOrigin","geometry","markKitOrigin","crashVehicle","lever","count","crashVehicle","clamp01","layers","count","createVehicleDestructible","createSurfaces","createArcadeDriver","createSemiSimDriver","vehicleCorners","fx","count","DEFERRED_QUEUE_ID","markKitOrigin","LIBRARY_BANK","createSemiSimDriver","subjectSpec","discardObject3D","createSemiSimDriver","createVehicleDestructible","discardObject3D","draw","a","count","lit","createSemiSimDriver","createVehicleDestructible","pose","markKitOrigin","live","discardObject3D","createSemiSimDriver","subjectSpec","LIBRARY_BANK"]}
|