@pinkaphant/kolmo 0.5.2 → 0.5.3

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.
Files changed (41) hide show
  1. package/README.md +92 -14
  2. package/dist/engine/actor.d.ts +1 -1
  3. package/dist/engine/index.d.ts +3 -0
  4. package/dist/engine/index.js +44 -34
  5. package/dist/engine/index.js.map +1 -1
  6. package/dist/engine/surface.d.ts +5 -6
  7. package/dist/engine/traits.d.ts +27 -0
  8. package/dist/engine/world.d.ts +5 -3
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +9 -5
  11. package/dist/physics/index.d.ts +2 -1
  12. package/dist/physics/index.js +3 -1
  13. package/dist/physics-KYWAXctg.js +233 -0
  14. package/dist/physics-KYWAXctg.js.map +1 -0
  15. package/dist/replay/index.d.ts +84 -0
  16. package/dist/replay/index.js +380 -0
  17. package/dist/replay/index.js.map +1 -0
  18. package/dist/terrain/index.d.ts +119 -0
  19. package/dist/terrain/index.js +495 -0
  20. package/dist/terrain/index.js.map +1 -0
  21. package/dist/toolgun/Toolgun.d.ts +11 -4
  22. package/dist/toolgun/index.d.ts +2 -2
  23. package/dist/toolgun/index.js +1 -1
  24. package/dist/{toolgun-CFCNO00q.js → toolgun-COu_5SxS.js} +202 -542
  25. package/dist/toolgun-COu_5SxS.js.map +1 -0
  26. package/dist/traits-Dp1ey_4w.js +267 -0
  27. package/dist/traits-Dp1ey_4w.js.map +1 -0
  28. package/dist/vite/index.js +1 -0
  29. package/dist/vite/index.js.map +1 -1
  30. package/dist/water/index.d.ts +71 -0
  31. package/dist/water/index.js +442 -0
  32. package/dist/water/index.js.map +1 -0
  33. package/dist/{world-BljtS6Fb.js → world-BDhBihjW.js} +114 -139
  34. package/dist/world-BDhBihjW.js.map +1 -0
  35. package/docs/api-reference.md +201 -0
  36. package/package.json +23 -6
  37. package/dist/physics-CA1abDCY.js +0 -476
  38. package/dist/physics-CA1abDCY.js.map +0 -1
  39. package/dist/toolgun/c12Outlets.d.ts +0 -36
  40. package/dist/toolgun-CFCNO00q.js.map +0 -1
  41. package/dist/world-BljtS6Fb.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"toolgun-CFCNO00q.js","names":["_jsx","_jsxs","_Fragment","_jsxs","_jsx","_Fragment"],"sources":["../src/toolgun/store.ts","../src/toolgun/c12Outlets.tsx","../src/toolgun/Toolgun.tsx"],"sourcesContent":["import * as THREE from \"three\";\nimport type RAPIER from \"@dimforge/rapier3d-compat\";\nimport { create, type StoreApi, type UseBoundStore } from \"zustand\";\nimport { isJointOpen, toggleDrivenJoint, type JointRuntime, type KhrAssetBundle } from \"@khr3/core\";\nimport {\n STEP_METRES,\n canPlace,\n latticePose,\n poseEq,\n poseToFloat,\n snapPose,\n socketFor,\n wrapYaw,\n worldSockets,\n type PieceKind,\n type PiecePose,\n type PlacedPiece,\n type Socket,\n} from \"@khr3/c12\";\n\nexport const TOOLGUN_MODES = [\"spawn\", \"weld\", \"hinge\", \"rig\", \"build\", \"delete\"] as const;\nexport type ToolgunMode = (typeof TOOLGUN_MODES)[number];\n\nexport const TOOLGUN_BUILD_KINDS = [\n \"FoundationSquare\",\n \"FoundationTriangle\",\n \"Wall\",\n \"Doorway\",\n \"Floor\",\n \"FloorTriangle\",\n \"Roof\",\n \"RoofTriangle\",\n \"Stairs\",\n] as const satisfies readonly PieceKind[];\nexport type ToolgunBuildKind = (typeof TOOLGUN_BUILD_KINDS)[number];\n\nexport interface ArmedToolgunAsset {\n readonly id: string;\n readonly name: string;\n readonly src?: string;\n readonly bundle?: KhrAssetBundle;\n readonly kind?: \"auto\" | \"vehicle\" | \"prop\";\n readonly fixed?: boolean;\n}\n\nexport interface SpawnedToolgunEntity {\n readonly id: string;\n readonly name: string;\n readonly kind: \"vehicle\" | \"prop\";\n readonly src?: string;\n readonly bundle?: KhrAssetBundle;\n readonly fixed: boolean;\n readonly position: [number, number, number];\n readonly quaternion: [number, number, number, number];\n}\n\nexport interface CreatedToolgunJoint {\n readonly id: string;\n readonly kind: \"weld\" | \"hinge\";\n readonly world: RAPIER.World;\n readonly handle: number;\n readonly joint: RAPIER.ImpulseJoint;\n readonly anchorWorld: [number, number, number];\n}\n\nexport interface ToolgunRaycastResult {\n point: [number, number, number];\n normal: [number, number, number];\n toi: number;\n collider: RAPIER.Collider;\n body: RAPIER.RigidBody | null;\n}\n\nexport interface PendingJointAnchor {\n readonly world: RAPIER.World;\n readonly body: RAPIER.RigidBody;\n readonly worldPoint: [number, number, number];\n readonly worldNormal: [number, number, number];\n readonly label: string;\n}\n\nexport interface BuildSnapCandidate {\n readonly kind: ToolgunBuildKind;\n readonly pose: PiecePose;\n readonly position: [number, number, number];\n readonly quaternion: [number, number, number, number];\n readonly snappedSocket: boolean;\n readonly valid: boolean;\n readonly reason: string;\n}\n\nexport type ToolgunHistoryEntry =\n | { readonly type: \"spawn\"; readonly id: string }\n | { readonly type: \"piece\"; readonly id: string }\n | { readonly type: \"joint\"; readonly id: string };\n\nexport interface ToolgunActionOutcome {\n readonly ok: boolean;\n readonly status: string;\n readonly beamEnd: [number, number, number];\n}\n\ntype Vec3Input = { readonly x: number; readonly y: number; readonly z: number } | readonly [number, number, number];\n\nconst _upDefault = new THREE.Vector3(0, 1, 0);\nconst _nrmVec = new THREE.Vector3();\nconst _alignQuat = new THREE.Quaternion();\nconst _yawQuat = new THREE.Quaternion();\nconst _qA = new THREE.Quaternion();\nconst _qB = new THREE.Quaternion();\nconst _qInvA = new THREE.Quaternion();\nconst _qInvB = new THREE.Quaternion();\nconst _qRel = new THREE.Quaternion();\nconst _vA = new THREE.Vector3();\nconst _vB = new THREE.Vector3();\nconst _axLocal = new THREE.Vector3();\nconst _axWorldB = new THREE.Vector3();\n\nlet _sharedRay: RAPIER.Ray | null = null;\n\nfunction readVecX(v: Vec3Input): number {\n return Array.isArray(v) ? v[0] : (v as { readonly x: number }).x;\n}\nfunction readVecY(v: Vec3Input): number {\n return Array.isArray(v) ? v[1] : (v as { readonly y: number }).y;\n}\nfunction readVecZ(v: Vec3Input): number {\n return Array.isArray(v) ? v[2] : (v as { readonly z: number }).z;\n}\n\n/**\n * Casts a solid ray against Rapier WASM colliders using `QueryFilterFlags.EXCLUDE_SENSORS`,\n * ignoring the optional actor `RigidBody`. Pass `out` on hot `useFrame` paths for zero heap allocations.\n */\nexport function castToolgunRay(\n rapier: typeof RAPIER,\n world: RAPIER.World,\n origin: Vec3Input,\n direction: Vec3Input,\n maxRange = 80,\n excludeBody?: RAPIER.RigidBody | null,\n out?: ToolgunRaycastResult,\n): ToolgunRaycastResult | null {\n const ox = readVecX(origin), oy = readVecY(origin), oz = readVecZ(origin);\n const rx = readVecX(direction), ry = readVecY(direction), rz = readVecZ(direction);\n const dirLen = Math.hypot(rx, ry, rz);\n if (dirLen < 1e-8 || maxRange <= 0)\n return null;\n const dx = rx / dirLen;\n const dy = ry / dirLen;\n const dz = rz / dirLen;\n\n if (!_sharedRay) {\n _sharedRay = new rapier.Ray({ x: ox, y: oy, z: oz }, { x: dx, y: dy, z: dz });\n }\n else {\n _sharedRay.origin.x = ox;\n _sharedRay.origin.y = oy;\n _sharedRay.origin.z = oz;\n _sharedRay.dir.x = dx;\n _sharedRay.dir.y = dy;\n _sharedRay.dir.z = dz;\n }\n\n const hit = world.castRayAndGetNormal(\n _sharedRay,\n maxRange,\n true,\n rapier.QueryFilterFlags.EXCLUDE_SENSORS,\n undefined,\n undefined,\n excludeBody ?? undefined,\n );\n if (!hit)\n return null;\n\n const nLen = Math.hypot(hit.normal.x, hit.normal.y, hit.normal.z);\n const nx = nLen > 1e-6 ? hit.normal.x / nLen : 0;\n const ny = nLen > 1e-6 ? hit.normal.y / nLen : 1;\n const nz = nLen > 1e-6 ? hit.normal.z / nLen : 0;\n const px = ox + dx * hit.timeOfImpact;\n const py = oy + dy * hit.timeOfImpact;\n const pz = oz + dz * hit.timeOfImpact;\n\n if (out) {\n out.point[0] = px;\n out.point[1] = py;\n out.point[2] = pz;\n out.normal[0] = nx;\n out.normal[1] = ny;\n out.normal[2] = nz;\n out.toi = hit.timeOfImpact;\n out.collider = hit.collider;\n out.body = hit.collider.parent();\n return out;\n }\n\n return {\n point: [px, py, pz],\n normal: [nx, ny, nz],\n toi: hit.timeOfImpact,\n collider: hit.collider,\n body: hit.collider.parent(),\n };\n}\n\n/**\n * Aligns a spawned asset's +Y axis to `surfaceNormal` (when sloped <= 55°) composed with exact 30° `yaw12` turn.\n */\nexport function computeAlignedSpawnPose(\n point: readonly [number, number, number],\n yaw12: number,\n surfaceNormal: readonly [number, number, number] = [0, 1, 0],\n clearanceM = 0.04,\n): { position: [number, number, number]; quaternion: [number, number, number, number] } {\n _nrmVec.set(surfaceNormal[0], surfaceNormal[1], surfaceNormal[2]);\n if (_nrmVec.lengthSq() < 1e-6)\n _nrmVec.set(0, 1, 0);\n else\n _nrmVec.normalize();\n if (_nrmVec.y < 0.57)\n _nrmVec.set(0, 1, 0);\n _alignQuat.setFromUnitVectors(_upDefault, _nrmVec);\n const yawRad = (wrapYaw(yaw12) * Math.PI) / 6;\n _yawQuat.setFromAxisAngle(_upDefault, yawRad);\n _alignQuat.multiply(_yawQuat).normalize();\n return {\n position: [\n point[0] + _nrmVec.x * clearanceM,\n point[1] + _nrmVec.y * clearanceM,\n point[2] + _nrmVec.z * clearanceM,\n ],\n quaternion: [_alignQuat.x, _alignQuat.y, _alignQuat.z, _alignQuat.w],\n };\n}\n\n/**\n * Creates a real Rapier WASM Fixed `ImpulseJoint` locking `bodyA` and `bodyB` at their current relative 6-DOF pose.\n */\nexport function createWeldImpulseJoint(\n rapier: typeof RAPIER,\n world: RAPIER.World,\n bodyA: RAPIER.RigidBody,\n bodyB: RAPIER.RigidBody,\n worldAnchor: readonly [number, number, number],\n): RAPIER.ImpulseJoint {\n const tA = bodyA.translation();\n const rA = bodyA.rotation();\n const tB = bodyB.translation();\n const rB = bodyB.rotation();\n\n _qA.set(rA.x, rA.y, rA.z, rA.w).normalize();\n _qB.set(rB.x, rB.y, rB.z, rB.w).normalize();\n _qInvA.copy(_qA).invert();\n _qInvB.copy(_qB).invert();\n\n _vA.set(worldAnchor[0] - tA.x, worldAnchor[1] - tA.y, worldAnchor[2] - tA.z).applyQuaternion(_qInvA);\n _vB.set(worldAnchor[0] - tB.x, worldAnchor[1] - tB.y, worldAnchor[2] - tB.z).applyQuaternion(_qInvB);\n _qRel.copy(_qInvA).multiply(_qB).normalize();\n\n const data = rapier.JointData.fixed(\n { x: _vA.x, y: _vA.y, z: _vA.z },\n { x: _qRel.x, y: _qRel.y, z: _qRel.z, w: _qRel.w },\n { x: _vB.x, y: _vB.y, z: _vB.z },\n { x: 0, y: 0, z: 0, w: 1 },\n );\n const imp = world.createImpulseJoint(data, bodyA, bodyB, true);\n imp.setContactsEnabled(false);\n if (bodyA.isDynamic())\n bodyA.wakeUp();\n if (bodyB.isDynamic())\n bodyB.wakeUp();\n return imp;\n}\n\n/**\n * Creates a real Rapier WASM Revolute `ImpulseJoint` around `worldAxis` through `worldAnchor`.\n * Aligns `bodyB`'s hinge shaft to `worldAxis` about `worldAnchor` when `bodyB` is tilted off-axis so `t=0` has zero snap error.\n */\nexport function createHingeImpulseJoint(\n rapier: typeof RAPIER,\n world: RAPIER.World,\n bodyA: RAPIER.RigidBody,\n bodyB: RAPIER.RigidBody,\n worldAnchor: readonly [number, number, number],\n worldAxis: readonly [number, number, number] = [0, 1, 0],\n): RAPIER.ImpulseJoint {\n _nrmVec.set(worldAxis[0], worldAxis[1], worldAxis[2]);\n if (_nrmVec.lengthSq() < 1e-8)\n _nrmVec.set(0, 1, 0);\n else\n _nrmVec.normalize();\n\n const tA = bodyA.translation();\n const rA = bodyA.rotation();\n const tB = bodyB.translation();\n const rB = bodyB.rotation();\n\n _qA.set(rA.x, rA.y, rA.z, rA.w).normalize();\n _qB.set(rB.x, rB.y, rB.z, rB.w).normalize();\n _qInvA.copy(_qA).invert();\n _qInvB.copy(_qB).invert();\n\n _vA.set(worldAnchor[0] - tA.x, worldAnchor[1] - tA.y, worldAnchor[2] - tA.z).applyQuaternion(_qInvA);\n _vB.set(worldAnchor[0] - tB.x, worldAnchor[1] - tB.y, worldAnchor[2] - tB.z).applyQuaternion(_qInvB);\n _axLocal.copy(_nrmVec).applyQuaternion(_qInvA).normalize();\n\n _axWorldB.copy(_axLocal).applyQuaternion(_qB).normalize();\n if (_axWorldB.dot(_nrmVec) < 1 - 1e-5 && bodyB.isDynamic()) {\n _alignQuat.setFromUnitVectors(_axWorldB, _nrmVec).multiply(_qB).normalize();\n const worldOffsetB = _axWorldB.copy(_vB).applyQuaternion(_alignQuat);\n bodyB.setRotation({ x: _alignQuat.x, y: _alignQuat.y, z: _alignQuat.z, w: _alignQuat.w }, true);\n bodyB.setTranslation(\n {\n x: worldAnchor[0] - worldOffsetB.x,\n y: worldAnchor[1] - worldOffsetB.y,\n z: worldAnchor[2] - worldOffsetB.z,\n },\n true,\n );\n }\n\n const data = rapier.JointData.revolute(\n { x: _vA.x, y: _vA.y, z: _vA.z },\n { x: _vB.x, y: _vB.y, z: _vB.z },\n { x: _axLocal.x, y: _axLocal.y, z: _axLocal.z },\n );\n const imp = world.createImpulseJoint(data, bodyA, bodyB, true);\n imp.setContactsEnabled(false);\n if (bodyA.isDynamic())\n bodyA.wakeUp();\n if (bodyB.isDynamic())\n bodyB.wakeUp();\n return imp;\n}\n\n/**\n * Toggles or breaks an articulated `@khr3/core` `JointRuntime`.\n */\nexport function rigJointRuntime(rt: JointRuntime, severBreakaway = false): string {\n if (rt.detached)\n return `${rt.nodeName} already detached`;\n if (severBreakaway) {\n const res = rt.applyImpactImpulse(Number.POSITIVE_INFINITY);\n if (res === \"detached\")\n return `Detached ${rt.nodeName}`;\n }\n const wasOpen = isJointOpen(rt);\n if (toggleDrivenJoint(rt))\n return `${wasOpen ? \"Closed\" : \"Opened\"} ${rt.nodeName}`;\n const res = rt.applyImpactImpulse(Number.POSITIVE_INFINITY);\n return res === \"detached\" ? `Detached ${rt.nodeName}` : `Joint ${rt.nodeName} (${rt.kind})`;\n}\n\n/**\n * Exact equality check for `BuildSnapCandidate` using `@khr3/c12`'s `poseEq`\n * (avoiding float quaternion sign collisions such as 60° vs 300° where `qy === 0.5`).\n */\nexport function isSameBuildPreview(a: BuildSnapCandidate | null, b: BuildSnapCandidate): boolean {\n if (!a)\n return false;\n return (\n a.kind === b.kind &&\n a.valid === b.valid &&\n a.snappedSocket === b.snappedSocket &&\n a.reason === b.reason &&\n poseEq(a.pose, b.pose)\n );\n}\n\n/**\n * Computes the nearest exact `@khr3/c12` socket-snapped or ground-lattice `BuildSnapCandidate` for `kind`.\n */\nexport function computeBuildCandidate(\n placedPieces: readonly PlacedPiece[],\n aimPoint: readonly [number, number, number],\n kind: ToolgunBuildKind,\n yaw12: number,\n snapRadiusM = 2.6,\n): BuildSnapCandidate {\n const wantedSocketKind = socketFor(kind);\n const maxDistSq = snapRadiusM * snapRadiusM;\n let bestSocket: Socket | null = null;\n let bestDistSq = maxDistSq;\n\n for (const placed of placedPieces) {\n const socks = worldSockets(placed.kind, placed.pose);\n for (const s of socks) {\n if (kind === \"FoundationSquare\" || kind === \"FoundationTriangle\") {\n if (s.kind !== \"edge\")\n continue;\n }\n else if (s.kind !== wantedSocketKind) {\n continue;\n }\n const flt = poseToFloat({ pos: s.mid, yaw: s.yaw });\n const dx = flt.position[0] - aimPoint[0];\n const dy = flt.position[1] - aimPoint[1];\n const dz = flt.position[2] - aimPoint[2];\n const dSq = dx * dx + dy * dy + dz * dz;\n if (dSq < bestDistSq) {\n const testOwn = kind === \"Stairs\" ? Math.floor(wrapYaw(yaw12) / 3) : wrapYaw(yaw12);\n const candidatePose = snapPose(kind, s, testOwn);\n if (canPlace(placedPieces, kind, candidatePose).ok) {\n bestDistSq = dSq;\n bestSocket = s;\n }\n }\n }\n }\n\n let pose: PiecePose;\n let snappedSocket = false;\n if (bestSocket) {\n const own = kind === \"Stairs\" ? Math.floor(wrapYaw(yaw12) / 3) : wrapYaw(yaw12);\n pose = snapPose(kind, bestSocket, own);\n snappedSocket = true;\n }\n else {\n const xSteps = Math.round(aimPoint[0] / STEP_METRES);\n const ySteps = Math.max(0, Math.round(aimPoint[1] / STEP_METRES));\n const zSteps = Math.round(aimPoint[2] / STEP_METRES);\n pose = latticePose(xSteps, zSteps, wrapYaw(yaw12), ySteps);\n }\n\n const check = canPlace(placedPieces, kind, pose);\n const flt = poseToFloat(pose);\n return {\n kind,\n pose,\n position: flt.position,\n quaternion: flt.quaternion,\n snappedSocket,\n valid: check.ok,\n reason: check.reason,\n };\n}\n\nfunction bodyMatchesSpawnedId(body: RAPIER.RigidBody | null | undefined, spawnedId: string): boolean {\n if (!body)\n return false;\n const ud = body.userData as { kolmoSpawnedId?: string } | undefined;\n return ud?.kolmoSpawnedId === spawnedId;\n}\n\nexport interface ToolgunStoreState {\n readonly mode: ToolgunMode;\n readonly yaw12: number;\n readonly buildKind: ToolgunBuildKind;\n readonly zoomed: boolean;\n readonly armedAsset: ArmedToolgunAsset | null;\n readonly buildPreview: BuildSnapCandidate | null;\n readonly pendingAnchor: PendingJointAnchor | null;\n readonly spawnedEntities: readonly SpawnedToolgunEntity[];\n readonly placedPieces: readonly PlacedPiece[];\n readonly createdJoints: readonly CreatedToolgunJoint[];\n readonly history: readonly ToolgunHistoryEntry[];\n readonly statusText: string;\n readonly fireCount: number;\n\n setMode: (mode: ToolgunMode) => void;\n cycleMode: (delta?: number) => void;\n rotateYaw12: (stepsDelta?: number) => void;\n setBuildKind: (kind: ToolgunBuildKind) => void;\n cycleBuildKind: (delta?: number) => void;\n setZoomed: (zoomed: boolean) => void;\n armAsset: (asset: ArmedToolgunAsset | null) => void;\n setBuildPreview: (candidate: BuildSnapCandidate | null) => void;\n setPendingAnchor: (anchor: PendingJointAnchor | null) => void;\n recordSpawn: (entry: SpawnedToolgunEntity) => void;\n placeBuildPiece: (candidate: BuildSnapCandidate) => PlacedPiece | null;\n recordJoint: (entry: CreatedToolgunJoint) => void;\n removeEntityById: (id: string, world?: RAPIER.World | null) => boolean;\n removePieceById: (id: string) => boolean;\n removeJointByBody: (world: RAPIER.World, body: RAPIER.RigidBody) => number;\n clearWorldHandles: (world: RAPIER.World) => void;\n undoLast: (world?: RAPIER.World | null) => string;\n bumpFire: (status: string) => void;\n resetAll: (world?: RAPIER.World | null) => void;\n}\n\nlet nextSeq = 1;\n\nexport function createToolgunStore(): UseBoundStore<StoreApi<ToolgunStoreState>> {\n return create<ToolgunStoreState>((set, get) => ({\n mode: \"spawn\",\n yaw12: 0,\n buildKind: \"FoundationSquare\",\n zoomed: false,\n armedAsset: null,\n buildPreview: null,\n pendingAnchor: null,\n spawnedEntities: [],\n placedPieces: [],\n createdJoints: [],\n history: [],\n statusText: \"READY\",\n fireCount: 0,\n\n setMode: (mode) => set({ mode, pendingAnchor: null, statusText: `MODE: ${mode.toUpperCase()}` }),\n cycleMode: (delta = 1) => {\n const idx = TOOLGUN_MODES.indexOf(get().mode);\n const next = TOOLGUN_MODES[((idx + delta) % TOOLGUN_MODES.length + TOOLGUN_MODES.length) % TOOLGUN_MODES.length];\n set({ mode: next, pendingAnchor: null, statusText: `MODE: ${next.toUpperCase()}` });\n },\n rotateYaw12: (stepsDelta = 1) => {\n const nextYaw = wrapYaw(get().yaw12 + stepsDelta);\n set({ yaw12: nextYaw, statusText: `YAW: ${nextYaw * 30}°` });\n },\n setBuildKind: (buildKind) => set({ buildKind, mode: \"build\", statusText: `BUILD: ${buildKind}` }),\n cycleBuildKind: (delta = 1) => {\n const idx = TOOLGUN_BUILD_KINDS.indexOf(get().buildKind);\n const next = TOOLGUN_BUILD_KINDS[((idx + delta) % TOOLGUN_BUILD_KINDS.length + TOOLGUN_BUILD_KINDS.length) % TOOLGUN_BUILD_KINDS.length];\n set({ buildKind: next, statusText: `BUILD: ${next}` });\n },\n setZoomed: (zoomed) => set({ zoomed }),\n armAsset: (armedAsset) => set({\n armedAsset,\n ...(armedAsset ? { statusText: `ARMED: ${armedAsset.name}` } : {}),\n }),\n setBuildPreview: (buildPreview) => set({ buildPreview }),\n setPendingAnchor: (pendingAnchor) => set({ pendingAnchor }),\n\n recordSpawn: (entry) => set((s) => ({\n spawnedEntities: [...s.spawnedEntities, entry],\n history: [...s.history, { type: \"spawn\", id: entry.id }],\n statusText: `SPAWNED ${entry.name}`,\n fireCount: s.fireCount + 1,\n })),\n\n placeBuildPiece: (candidate) => {\n const st = get();\n const check = canPlace(st.placedPieces, candidate.kind, candidate.pose);\n if (!check.ok) {\n set({ statusText: check.reason.toUpperCase(), fireCount: st.fireCount + 1 });\n return null;\n }\n const piece: PlacedPiece = {\n id: `c12_${nextSeq++}`,\n kind: candidate.kind,\n pose: candidate.pose,\n };\n set((s) => ({\n placedPieces: [...s.placedPieces, piece],\n history: [...s.history, { type: \"piece\", id: piece.id }],\n statusText: `PLACED ${piece.kind}`,\n fireCount: s.fireCount + 1,\n }));\n return piece;\n },\n\n recordJoint: (entry) => set((s) => ({\n createdJoints: [...s.createdJoints, entry],\n history: [...s.history, { type: \"joint\", id: entry.id }],\n pendingAnchor: null,\n statusText: `${entry.kind === \"weld\" ? \"WELDED\" : \"HINGED\"} #${entry.handle}`,\n fireCount: s.fireCount + 1,\n })),\n\n removeEntityById: (id, world) => {\n const st = get();\n if (!st.spawnedEntities.some((e) => e.id === id))\n return false;\n const removedJointIds = new Set<string>();\n const keptJoints: CreatedToolgunJoint[] = [];\n for (const cj of st.createdJoints) {\n if (!world || cj.world !== world) {\n if (!world || cj.world !== world)\n keptJoints.push(cj);\n continue;\n }\n const live = world.getImpulseJoint(cj.joint.handle);\n if (!live) {\n removedJointIds.add(cj.id);\n continue;\n }\n if (bodyMatchesSpawnedId(live.body1(), id) || bodyMatchesSpawnedId(live.body2(), id)) {\n world.removeImpulseJoint(live, true);\n removedJointIds.add(cj.id);\n }\n else {\n keptJoints.push(cj);\n }\n }\n const clearPending = st.pendingAnchor && (!world || st.pendingAnchor.world === world)\n ? bodyMatchesSpawnedId(st.pendingAnchor.body, id)\n : false;\n set((s) => ({\n spawnedEntities: s.spawnedEntities.filter((e) => e.id !== id),\n createdJoints: keptJoints,\n ...(clearPending ? { pendingAnchor: null } : {}),\n history: s.history.filter((h) => !(h.type === \"spawn\" && h.id === id) && !(h.type === \"joint\" && removedJointIds.has(h.id))),\n statusText: `DELETED ${id}`,\n fireCount: s.fireCount + 1,\n }));\n return true;\n },\n\n removePieceById: (id) => {\n const before = get().placedPieces;\n if (!before.some((p) => p.id === id))\n return false;\n set((s) => ({\n placedPieces: s.placedPieces.filter((p) => p.id !== id),\n history: s.history.filter((h) => !(h.type === \"piece\" && h.id === id)),\n statusText: `REMOVED ${id}`,\n fireCount: s.fireCount + 1,\n }));\n return true;\n },\n\n removeJointByBody: (world, body) => {\n const keep: CreatedToolgunJoint[] = [];\n const removedIds = new Set<string>();\n for (const cj of get().createdJoints) {\n if (cj.world !== world) {\n keep.push(cj);\n continue;\n }\n const live = world.getImpulseJoint(cj.joint.handle);\n if (!live) {\n removedIds.add(cj.id);\n continue;\n }\n if (live.body1().handle === body.handle || live.body2().handle === body.handle) {\n world.removeImpulseJoint(live, true);\n removedIds.add(cj.id);\n }\n else {\n keep.push(cj);\n }\n }\n if (removedIds.size > 0) {\n set((s) => ({\n createdJoints: keep,\n history: s.history.filter((h) => !(h.type === \"joint\" && removedIds.has(h.id))),\n statusText: `UNWELDED (${removedIds.size})`,\n fireCount: s.fireCount + 1,\n }));\n }\n return removedIds.size;\n },\n\n clearWorldHandles: (world) => {\n const st = get();\n const clearPending = st.pendingAnchor?.world === world;\n const hasWorldJoints = st.createdJoints.some((cj) => cj.world === world);\n if (!clearPending && !hasWorldJoints)\n return;\n const removedIds = new Set(st.createdJoints.filter((cj) => cj.world === world).map((cj) => cj.id));\n set((s) => ({\n ...(clearPending ? { pendingAnchor: null } : {}),\n createdJoints: s.createdJoints.filter((cj) => cj.world !== world),\n history: s.history.filter((h) => !(h.type === \"joint\" && removedIds.has(h.id))),\n }));\n },\n\n undoLast: (world) => {\n const st = get();\n const last = st.history[st.history.length - 1];\n if (!last)\n return \"NOTHING TO UNDO\";\n if (last.type === \"spawn\") {\n get().removeEntityById(last.id, world);\n set({ statusText: `UNDO SPAWN ${last.id}` });\n return `UNDO SPAWN ${last.id}`;\n }\n const nextHistory = st.history.slice(0, -1);\n if (last.type === \"piece\") {\n set({\n placedPieces: st.placedPieces.filter((p) => p.id !== last.id),\n history: nextHistory,\n statusText: `UNDO PIECE ${last.id}`,\n });\n return `UNDO PIECE ${last.id}`;\n }\n const jEntry = st.createdJoints.find((j) => j.id === last.id);\n if (jEntry && world && jEntry.world === world) {\n const liveJoint = world.getImpulseJoint(jEntry.joint.handle);\n if (liveJoint)\n world.removeImpulseJoint(liveJoint, true);\n }\n set({\n createdJoints: st.createdJoints.filter((j) => j.id !== last.id),\n history: nextHistory,\n statusText: `UNDO JOINT ${last.id}`,\n });\n return `UNDO JOINT ${last.id}`;\n },\n\n bumpFire: (statusText) => set((s) => ({ statusText, fireCount: s.fireCount + 1 })),\n\n resetAll: (world) => {\n if (world) {\n for (const cj of get().createdJoints) {\n if (cj.world !== world)\n continue;\n const liveJoint = world.getImpulseJoint(cj.joint.handle);\n if (liveJoint)\n world.removeImpulseJoint(liveJoint, true);\n }\n }\n set({\n pendingAnchor: null,\n spawnedEntities: [],\n placedPieces: [],\n createdJoints: [],\n history: [],\n statusText: \"CLEARED\",\n });\n },\n }));\n}\n\nexport const useToolgunStore = createToolgunStore();\n","import React, { useMemo } from \"react\";\nimport * as THREE from \"three\";\nimport { ConvexHullCollider, CuboidCollider, RigidBody } from \"@react-three/rapier\";\nimport {\n DOOR_HINGE_SPEC,\n SIDE_METRES,\n STOREY_METRES,\n poseToFloat,\n triangleCorners,\n type PieceKind,\n type PlacedPiece,\n} from \"@khr3/c12\";\nimport type { BuildSnapCandidate } from \"./store.js\";\n\nexport const WALL_THICK = 0.2;\nexport const SLAB_THICK = 0.2;\n\nconst OPEN_W = DOOR_HINGE_SPEC.openingWidthM;\nconst OPEN_H = DOOR_HINGE_SPEC.openingHeightM;\nconst JAMB_W = (SIDE_METRES - OPEN_W) * 0.5;\nconst LINTEL_H = STOREY_METRES - OPEN_H;\nconst JAMB_X = OPEN_W * 0.5 + JAMB_W * 0.5;\nconst RAMP_LEN = Math.hypot(SIDE_METRES, STOREY_METRES);\nconst RAMP_PITCH = -Math.atan2(STOREY_METRES, SIDE_METRES);\n\nfunction createTriangleSlabGeometry(yMin: number, yMax: number): THREE.BufferGeometry {\n const corners = triangleCorners();\n const positions: number[] = [];\n const pushTri = (a: [number, number, number], b: [number, number, number], c: [number, number, number]) => {\n positions.push(a[0], a[1], a[2], b[0], b[1], b[2], c[0], c[1], c[2]);\n };\n const bot: [number, number, number][] = corners.map(([x, , z]) => [x, yMin, z]);\n const top: [number, number, number][] = corners.map(([x, , z]) => [x, yMax, z]);\n pushTri(top[0], top[1], top[2]);\n pushTri(bot[0], bot[2], bot[1]);\n for (let i = 0; i < 3; i++) {\n const j = (i + 1) % 3;\n pushTri(bot[i], bot[j], top[j]);\n pushTri(bot[i], top[j], top[i]);\n }\n const geo = new THREE.BufferGeometry();\n geo.setAttribute(\"position\", new THREE.Float32BufferAttribute(positions, 3));\n geo.computeVertexNormals();\n return geo;\n}\n\nfunction buildTriangleHullVertices(yMin: number, yMax: number): Float32Array {\n const corners = triangleCorners();\n const verts: number[] = [];\n for (const [x, , z] of corners)\n verts.push(x, yMin, z, x, yMax, z);\n return new Float32Array(verts);\n}\n\ninterface SharedC12Resources {\n readonly slabGeo: THREE.BoxGeometry;\n readonly wallGeo: THREE.BoxGeometry;\n readonly jambGeo: THREE.BoxGeometry;\n readonly lintelGeo: THREE.BoxGeometry;\n readonly rampGeo: THREE.BoxGeometry;\n readonly triGroundGeo: THREE.BufferGeometry;\n readonly triUpperGeo: THREE.BufferGeometry;\n readonly triGroundVerts: Float32Array;\n readonly triUpperVerts: Float32Array;\n readonly slabMat: THREE.MeshStandardMaterial;\n readonly roofMat: THREE.MeshStandardMaterial;\n readonly streetMat: THREE.MeshStandardMaterial;\n readonly wallMat: THREE.MeshStandardMaterial;\n readonly stairMat: THREE.MeshStandardMaterial;\n readonly ghostValidMat: THREE.MeshBasicMaterial;\n readonly ghostInvalidMat: THREE.MeshBasicMaterial;\n}\n\nlet _c12Resources: SharedC12Resources | null = null;\n\nexport function getSharedC12Resources(): SharedC12Resources {\n if (_c12Resources)\n return _c12Resources;\n _c12Resources = {\n slabGeo: new THREE.BoxGeometry(SIDE_METRES, SLAB_THICK, SIDE_METRES),\n wallGeo: new THREE.BoxGeometry(SIDE_METRES, STOREY_METRES, WALL_THICK),\n jambGeo: new THREE.BoxGeometry(JAMB_W, OPEN_H, WALL_THICK),\n lintelGeo: new THREE.BoxGeometry(SIDE_METRES, LINTEL_H, WALL_THICK),\n rampGeo: new THREE.BoxGeometry(SIDE_METRES * 0.9, SLAB_THICK, RAMP_LEN),\n triGroundGeo: createTriangleSlabGeometry(0, SLAB_THICK),\n triUpperGeo: createTriangleSlabGeometry(-SLAB_THICK, 0),\n triGroundVerts: buildTriangleHullVertices(0, SLAB_THICK),\n triUpperVerts: buildTriangleHullVertices(-SLAB_THICK, 0),\n slabMat: new THREE.MeshStandardMaterial({ color: \"#64748b\", roughness: 0.82, metalness: 0.08 }),\n roofMat: new THREE.MeshStandardMaterial({ color: \"#475569\", roughness: 0.82, metalness: 0.08 }),\n streetMat: new THREE.MeshStandardMaterial({ color: \"#334155\", roughness: 0.88, metalness: 0.04 }),\n wallMat: new THREE.MeshStandardMaterial({ color: \"#94a3b8\", roughness: 0.78, metalness: 0.06 }),\n stairMat: new THREE.MeshStandardMaterial({ color: \"#cbd5e1\", roughness: 0.75, metalness: 0.06 }),\n ghostValidMat: new THREE.MeshBasicMaterial({ color: \"#34d399\", transparent: true, opacity: 0.36, depthWrite: false }),\n ghostInvalidMat: new THREE.MeshBasicMaterial({ color: \"#ef4444\", transparent: true, opacity: 0.36, depthWrite: false }),\n };\n return _c12Resources;\n}\n\nexport function C12PieceMeshes({\n kind,\n overrideMaterial,\n}: {\n kind: PieceKind;\n overrideMaterial?: THREE.Material;\n}): React.JSX.Element {\n const res = getSharedC12Resources();\n const cast = !overrideMaterial;\n\n if (kind === \"FoundationSquare\" || kind === \"Floor\" || kind === \"Roof\" || kind === \"Street\") {\n const yOff = kind === \"FoundationSquare\" || kind === \"Street\" ? SLAB_THICK * 0.5 : -SLAB_THICK * 0.5;\n const mat = overrideMaterial ?? (kind === \"Roof\" ? res.roofMat : kind === \"Street\" ? res.streetMat : res.slabMat);\n return <mesh position={[0, yOff, 0]} geometry={res.slabGeo} material={mat} castShadow={cast} receiveShadow={cast} />;\n }\n\n if (kind === \"FoundationTriangle\" || kind === \"FloorTriangle\" || kind === \"RoofTriangle\") {\n const geo = kind === \"FoundationTriangle\" ? res.triGroundGeo : res.triUpperGeo;\n const mat = overrideMaterial ?? (kind === \"RoofTriangle\" ? res.roofMat : res.slabMat);\n return <mesh geometry={geo} material={mat} castShadow={cast} receiveShadow={cast} />;\n }\n\n if (kind === \"Wall\") {\n return (\n <mesh\n position={[0, STOREY_METRES * 0.5, 0]}\n geometry={res.wallGeo}\n material={overrideMaterial ?? res.wallMat}\n castShadow={cast}\n receiveShadow={cast}\n />\n );\n }\n\n if (kind === \"Doorway\") {\n const mat = overrideMaterial ?? res.wallMat;\n return (\n <>\n <mesh position={[-JAMB_X, OPEN_H * 0.5, 0]} geometry={res.jambGeo} material={mat} castShadow={cast} receiveShadow={cast} />\n <mesh position={[JAMB_X, OPEN_H * 0.5, 0]} geometry={res.jambGeo} material={mat} castShadow={cast} receiveShadow={cast} />\n <mesh position={[0, OPEN_H + LINTEL_H * 0.5, 0]} geometry={res.lintelGeo} material={mat} castShadow={cast} receiveShadow={cast} />\n </>\n );\n }\n\n return (\n <mesh\n position={[0, STOREY_METRES * 0.5, 0]}\n rotation={[RAMP_PITCH, 0, 0]}\n geometry={res.rampGeo}\n material={overrideMaterial ?? res.stairMat}\n castShadow={cast}\n receiveShadow={cast}\n />\n );\n}\n\nexport function C12PieceColliderAndMesh({ piece }: { piece: PlacedPiece }): React.JSX.Element {\n const flt = useMemo(() => poseToFloat(piece.pose), [piece.pose]);\n const userData = useMemo(() => ({ kolmoPlacedPieceId: piece.id, name: piece.kind }), [piece.id, piece.kind]);\n const res = getSharedC12Resources();\n\n if (piece.kind === \"FoundationSquare\" || piece.kind === \"Floor\" || piece.kind === \"Roof\" || piece.kind === \"Street\") {\n const yOff = piece.kind === \"FoundationSquare\" || piece.kind === \"Street\" ? SLAB_THICK * 0.5 : -SLAB_THICK * 0.5;\n return (\n <RigidBody type=\"fixed\" colliders={false} position={flt.position} quaternion={flt.quaternion} friction={0.6} restitution={0.1} userData={userData}>\n <CuboidCollider args={[SIDE_METRES * 0.5, SLAB_THICK * 0.5, SIDE_METRES * 0.5]} position={[0, yOff, 0]} />\n <C12PieceMeshes kind={piece.kind} />\n </RigidBody>\n );\n }\n\n if (piece.kind === \"FoundationTriangle\" || piece.kind === \"FloorTriangle\" || piece.kind === \"RoofTriangle\") {\n const hullVerts = piece.kind === \"FoundationTriangle\" ? res.triGroundVerts : res.triUpperVerts;\n return (\n <RigidBody type=\"fixed\" colliders={false} position={flt.position} quaternion={flt.quaternion} friction={0.6} restitution={0.1} userData={userData}>\n <ConvexHullCollider args={[hullVerts]} />\n <C12PieceMeshes kind={piece.kind} />\n </RigidBody>\n );\n }\n\n if (piece.kind === \"Wall\") {\n return (\n <RigidBody type=\"fixed\" colliders={false} position={flt.position} quaternion={flt.quaternion} friction={0.6} restitution={0.1} userData={userData}>\n <CuboidCollider args={[SIDE_METRES * 0.5, STOREY_METRES * 0.5, WALL_THICK * 0.5]} position={[0, STOREY_METRES * 0.5, 0]} />\n <C12PieceMeshes kind=\"Wall\" />\n </RigidBody>\n );\n }\n\n if (piece.kind === \"Doorway\") {\n return (\n <RigidBody type=\"fixed\" colliders={false} position={flt.position} quaternion={flt.quaternion} friction={0.6} restitution={0.1} userData={userData}>\n <CuboidCollider args={[JAMB_W * 0.5, OPEN_H * 0.5, WALL_THICK * 0.5]} position={[-JAMB_X, OPEN_H * 0.5, 0]} />\n <CuboidCollider args={[JAMB_W * 0.5, OPEN_H * 0.5, WALL_THICK * 0.5]} position={[JAMB_X, OPEN_H * 0.5, 0]} />\n <CuboidCollider args={[SIDE_METRES * 0.5, LINTEL_H * 0.5, WALL_THICK * 0.5]} position={[0, OPEN_H + LINTEL_H * 0.5, 0]} />\n <C12PieceMeshes kind=\"Doorway\" />\n </RigidBody>\n );\n }\n\n return (\n <RigidBody type=\"fixed\" colliders={false} position={flt.position} quaternion={flt.quaternion} friction={0.85} restitution={0.05} userData={userData}>\n <CuboidCollider\n args={[SIDE_METRES * 0.45, SLAB_THICK * 0.5, RAMP_LEN * 0.5]}\n position={[0, STOREY_METRES * 0.5, 0]}\n rotation={[RAMP_PITCH, 0, 0]}\n />\n <C12PieceMeshes kind=\"Stairs\" />\n </RigidBody>\n );\n}\n\nexport function BuildGhostPreview({ candidate }: { candidate: BuildSnapCandidate }): React.JSX.Element {\n const res = getSharedC12Resources();\n return (\n <group position={candidate.position} quaternion={candidate.quaternion}>\n <C12PieceMeshes kind={candidate.kind} overrideMaterial={candidate.valid ? res.ghostValidMat : res.ghostInvalidMat} />\n </group>\n );\n}\n","import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef } from \"react\";\nimport * as THREE from \"three\";\nimport { createPortal, useFrame, useThree } from \"@react-three/fiber\";\nimport { useRapier } from \"@react-three/rapier\";\nimport type RAPIER from \"@dimforge/rapier3d-compat\";\nimport { easing } from \"maath\";\nimport type { EcctrlHandle } from \"@pinkaphant/ecctrl\";\nimport { JointRegistryContext, cloneKhrBundle, useKhrGlb, type JointRuntime, type KhrAssetBundle } from \"@khr3/core\";\nimport { ActorTrait, pilotedVehicleQuery, useActiveKolmoWorld } from \"../engine/traits.js\";\nimport { KolmoProp } from \"../engine/surface.js\";\nimport { KolmoVehicle } from \"../engine/vehicle.js\";\nimport { useKolmoGame } from \"../engine/world.js\";\nimport { BuildGhostPreview, C12PieceColliderAndMesh } from \"./c12Outlets.js\";\nimport {\n TOOLGUN_MODES,\n castToolgunRay,\n computeAlignedSpawnPose,\n computeBuildCandidate,\n createHingeImpulseJoint,\n createWeldImpulseJoint,\n isSameBuildPreview,\n rigJointRuntime,\n useToolgunStore,\n type ArmedToolgunAsset,\n type SpawnedToolgunEntity,\n type ToolgunActionOutcome,\n type ToolgunMode,\n type ToolgunRaycastResult,\n} from \"./store.js\";\n\nconst LCD_W = 256;\nconst LCD_H = 192;\nconst DEFAULT_ACCENT_HEX = \"#38bdf8\";\n\nexport interface MeasuredToolgunViewmodel {\n readonly scene: THREE.Object3D;\n readonly gripOffset: [number, number, number];\n readonly muzzleLocal: [number, number, number];\n readonly screenPos: [number, number, number];\n readonly screenQuat: [number, number, number, number];\n readonly screenSize: [number, number];\n}\n\n/**\n * Measures grip, muzzle, and LCD bezel sockets on an already-cloned viewmodel scene without duplicating it.\n * Offsets the LCD quad 1mm along `screen_rect`'s local +Z normal in root space so arbitrary bezel orientations never z-fight.\n */\nexport function measureToolgunViewmodel(clonedScene: THREE.Object3D): MeasuredToolgunViewmodel {\n clonedScene.updateMatrixWorld(true);\n const invRoot = clonedScene.matrixWorld.clone().invert();\n const invRootQuat = clonedScene.getWorldQuaternion(new THREE.Quaternion()).invert();\n const rootScale = clonedScene.getWorldScale(new THREE.Vector3());\n let grip: [number, number, number] = [0, 0, 0];\n let muzzle: [number, number, number] = [0, 0.04, -0.24];\n let screenPos: [number, number, number] = [0, 0.068, 0.095];\n let screenQuat: [number, number, number, number] = [0, 0, 0, 1];\n let screenSize: [number, number] = [0.068, 0.051];\n const tmpPos = new THREE.Vector3();\n const tmpQuat = new THREE.Quaternion();\n const tmpPlaneRot = new THREE.Quaternion();\n const tmpNormal = new THREE.Vector3();\n const tmpSize = new THREE.Vector3();\n const tmpScale = new THREE.Vector3();\n\n clonedScene.traverse((node) => {\n const low = node.name.toLowerCase();\n if (low === \"ik_palm_primary\" || low === \"grip\" || low === \"socket_grip\") {\n node.getWorldPosition(tmpPos).applyMatrix4(invRoot);\n grip = [-tmpPos.x, -tmpPos.y, -tmpPos.z];\n }\n else if (low === \"socket_muzzle\" || low === \"muzzle\") {\n node.getWorldPosition(tmpPos).applyMatrix4(invRoot);\n muzzle = [tmpPos.x, tmpPos.y, tmpPos.z];\n }\n else if (low === \"screen_rect\" || low === \"lcd_screen\") {\n node.getWorldPosition(tmpPos).applyMatrix4(invRoot);\n node.getWorldQuaternion(tmpQuat).premultiply(invRootQuat).normalize();\n node.getWorldScale(tmpScale);\n const sx = Math.abs(rootScale.x) > 1e-6 ? Math.abs(tmpScale.x / rootScale.x) : 1;\n const sy = Math.abs(rootScale.y) > 1e-6 ? Math.abs(tmpScale.y / rootScale.y) : 1;\n const sz = Math.abs(rootScale.z) > 1e-6 ? Math.abs(tmpScale.z / rootScale.z) : 1;\n const mesh = node as THREE.Mesh;\n tmpPlaneRot.identity();\n if (mesh.isMesh && mesh.geometry) {\n mesh.geometry.computeBoundingBox();\n const bb = mesh.geometry.boundingBox;\n if (bb) {\n bb.getSize(tmpSize);\n const ex = tmpSize.x * sx;\n const ey = tmpSize.y * sy;\n const ez = tmpSize.z * sz;\n if (ez <= ex && ez <= ey) {\n screenSize = [Math.max(0.025, ex), Math.max(0.02, ey)];\n }\n else if (ey <= ex && ey <= ez) {\n tmpPlaneRot.setFromAxisAngle(new THREE.Vector3(1, 0, 0), -Math.PI / 2);\n screenSize = [Math.max(0.025, ex), Math.max(0.02, ez)];\n }\n else {\n tmpPlaneRot.setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI / 2);\n screenSize = [Math.max(0.025, ez), Math.max(0.02, ey)];\n }\n }\n mesh.visible = false;\n }\n tmpQuat.multiply(tmpPlaneRot).normalize();\n tmpNormal.set(0, 0, 1).applyQuaternion(tmpQuat);\n screenPos = [tmpPos.x + tmpNormal.x * 0.001, tmpPos.y + tmpNormal.y * 0.001, tmpPos.z + tmpNormal.z * 0.001];\n screenQuat = [tmpQuat.x, tmpQuat.y, tmpQuat.z, tmpQuat.w];\n }\n });\n\n return { scene: clonedScene, gripOffset: grip, muzzleLocal: muzzle, screenPos, screenQuat, screenSize };\n}\n\ninterface LcdSurface {\n readonly texture: THREE.CanvasTexture | null;\n draw: (state: {\n mode: ToolgunMode;\n yawDeg: number;\n detail: string;\n targetLabel: string;\n status: string;\n accentColor: string;\n }) => void;\n dispose: () => void;\n}\n\nfunction createLcdSurface(): LcdSurface {\n if (typeof document === \"undefined\") {\n return { texture: null, draw: () => {}, dispose: () => {} };\n }\n const canvas = document.createElement(\"canvas\");\n canvas.width = LCD_W;\n canvas.height = LCD_H;\n const ctx = canvas.getContext(\"2d\");\n const texture = new THREE.CanvasTexture(canvas);\n texture.colorSpace = THREE.SRGBColorSpace;\n texture.minFilter = THREE.LinearFilter;\n texture.magFilter = THREE.LinearFilter;\n texture.generateMipmaps = false;\n\n let prevSig = \"\";\n return {\n texture,\n draw: ({ mode, yawDeg, detail, targetLabel, status, accentColor }) => {\n if (!ctx)\n return;\n const sig = `${mode}|${yawDeg}|${detail}|${targetLabel}|${status}|${accentColor}`;\n if (sig === prevSig)\n return;\n prevSig = sig;\n\n ctx.fillStyle = \"#070d19\";\n ctx.fillRect(0, 0, LCD_W, LCD_H);\n\n ctx.strokeStyle = accentColor;\n ctx.lineWidth = 3;\n ctx.strokeRect(4, 4, LCD_W - 8, LCD_H - 8);\n\n ctx.fillStyle = accentColor;\n ctx.fillRect(4, 4, LCD_W - 8, 28);\n ctx.fillStyle = \"#040812\";\n ctx.font = \"bold 15px ui-monospace, SFMono-Regular, Menlo, monospace\";\n ctx.fillText(`KOLMO // ${mode.toUpperCase()}`, 12, 23);\n ctx.textAlign = \"right\";\n ctx.fillText(`${yawDeg}°`, LCD_W - 12, 23);\n ctx.textAlign = \"left\";\n\n ctx.fillStyle = \"#e2e8f0\";\n ctx.font = \"bold 13px ui-monospace, SFMono-Regular, Menlo, monospace\";\n ctx.fillText(detail.slice(0, 26), 12, 58);\n\n ctx.fillStyle = \"#7dd3fc\";\n ctx.font = \"12px ui-monospace, SFMono-Regular, Menlo, monospace\";\n ctx.fillText(targetLabel.slice(0, 28), 12, 86);\n\n ctx.strokeStyle = \"rgba(148, 163, 184, 0.28)\";\n ctx.lineWidth = 1;\n ctx.beginPath();\n ctx.moveTo(12, 106);\n ctx.lineTo(LCD_W - 12, 106);\n ctx.stroke();\n\n ctx.fillStyle = \"#34d399\";\n ctx.font = \"bold 12px ui-monospace, SFMono-Regular, Menlo, monospace\";\n ctx.fillText(status.slice(0, 28), 12, 130);\n\n ctx.fillStyle = \"#94a3b8\";\n ctx.font = \"10px ui-monospace, SFMono-Regular, Menlo, monospace\";\n ctx.fillText(\"[1-6/Q] MODE [R] +30° [Z] UNDO\", 12, 160);\n ctx.fillText(\"[LMB] FIRE [RMB] ZOOM [[/]] C12\", 12, 176);\n\n texture.needsUpdate = true;\n },\n dispose: () => {\n texture.dispose();\n },\n };\n}\n\nfunction DefaultToolgunMesh({\n accentColor,\n lcdTexture,\n}: {\n accentColor: string;\n lcdTexture: THREE.CanvasTexture | null;\n}): React.JSX.Element {\n return (\n <group>\n <mesh position={[0, 0.032, -0.04]} castShadow>\n <boxGeometry args={[0.056, 0.062, 0.22]} />\n <meshStandardMaterial color=\"#1e293b\" metalness={0.65} roughness={0.32} />\n </mesh>\n <mesh position={[0, 0.038, -0.2]} rotation={[Math.PI / 2, 0, 0]} castShadow>\n <cylinderGeometry args={[0.014, 0.018, 0.14, 12]} />\n <meshStandardMaterial color={accentColor} emissive={accentColor} emissiveIntensity={0.45} metalness={0.8} roughness={0.2} />\n </mesh>\n <mesh position={[0, -0.042, 0.03]} rotation={[0.24, 0, 0]} castShadow>\n <boxGeometry args={[0.042, 0.11, 0.048]} />\n <meshStandardMaterial color=\"#0f172a\" roughness={0.75} metalness={0.2} />\n </mesh>\n <mesh position={[0, 0.052, 0.072]}>\n <planeGeometry args={[0.064, 0.048]} />\n <meshBasicMaterial {...(lcdTexture ? { map: lcdTexture } : { color: accentColor })} toneMapped={false} />\n </mesh>\n </group>\n );\n}\n\nexport interface KolmoToolgunHandle {\n fire: (shiftKey?: boolean) => ToolgunActionOutcome;\n undo: () => string;\n}\n\nexport interface KolmoToolgunProps {\n readonly ref?: React.Ref<KolmoToolgunHandle>;\n readonly src?: string;\n readonly bundle?: KhrAssetBundle | null;\n readonly actorRef?: React.RefObject<EcctrlHandle | null>;\n readonly accentColor?: string;\n readonly defaultArmedAsset?: ArmedToolgunAsset | null;\n readonly maxRangeM?: number;\n readonly hipOffset?: readonly [number, number, number];\n readonly zoomOffset?: readonly [number, number, number];\n readonly enableShortcuts?: boolean;\n readonly mountWorldOutlets?: boolean;\n readonly enable?: boolean;\n}\n\nconst SpawnedToolgunOutlet = React.memo(function SpawnedToolgunOutlet({\n entry,\n}: {\n entry: SpawnedToolgunEntity;\n}): React.JSX.Element {\n const userData = useMemo(() => ({ kolmoSpawnedId: entry.id, name: entry.name }), [entry.id, entry.name]);\n const rigidBodyProps = useMemo(() => ({ userData }), [userData]);\n if (entry.kind === \"vehicle\") {\n return (\n <KolmoVehicle\n id={entry.id}\n {...(entry.bundle ? { bundle: entry.bundle } : {})}\n {...(entry.src ? { src: entry.src } : {})}\n position={entry.position}\n quaternion={entry.quaternion}\n userData={userData}\n />\n );\n }\n return (\n <KolmoProp\n {...(entry.bundle ? { bundle: entry.bundle } : {})}\n {...(entry.src ? { src: entry.src } : {})}\n fixed={entry.fixed}\n position={entry.position}\n quaternion={entry.quaternion}\n rigidBodyProps={rigidBodyProps}\n />\n );\n});\n\nconst _camPos = new THREE.Vector3();\nconst _camDir = new THREE.Vector3();\nconst _muzzleWorld = new THREE.Vector3();\nconst _beamEndVec = new THREE.Vector3();\nconst _targetOffset = new THREE.Vector3();\n\nfunction ToolgunCore({\n ref,\n viewmodelBundle,\n actorRef,\n accentColor = DEFAULT_ACCENT_HEX,\n defaultArmedAsset,\n maxRangeM = 75,\n hipOffset = [0.24, -0.21, -0.42],\n zoomOffset = [0, -0.055, -0.22],\n enableShortcuts = true,\n mountWorldOutlets = true,\n enable = true,\n}: Omit<KolmoToolgunProps, \"src\" | \"bundle\"> & { viewmodelBundle: KhrAssetBundle | null }): React.JSX.Element | null {\n const { rapier, world: rapierWorld } = useRapier();\n const camera = useThree((s) => s.camera);\n const gl = useThree((s) => s.gl);\n const kootaWorld = useActiveKolmoWorld();\n const { mode: controlMode } = useKolmoGame(kootaWorld);\n const isPiloted = controlMode !== \"foot\";\n const jointRegistry = useContext(JointRegistryContext);\n\n const mode = useToolgunStore((s) => s.mode);\n const buildPreview = useToolgunStore((s) => s.buildPreview);\n const spawnedEntities = useToolgunStore((s) => s.spawnedEntities);\n const placedPieces = useToolgunStore((s) => s.placedPieces);\n\n useEffect(() => {\n if (defaultArmedAsset && !useToolgunStore.getState().armedAsset) {\n useToolgunStore.getState().armAsset(defaultArmedAsset);\n }\n }, [defaultArmedAsset]);\n\n useEffect(() => () => {\n useToolgunStore.getState().clearWorldHandles(rapierWorld);\n }, [rapierWorld]);\n\n const measured = useMemo(\n () => (viewmodelBundle ? measureToolgunViewmodel(viewmodelBundle.scene) : null),\n [viewmodelBundle],\n );\n const lcd = useMemo(createLcdSurface, []);\n useEffect(() => () => lcd.dispose(), [lcd]);\n\n const holderRef = useRef<THREE.Group | null>(null);\n const recoilRef = useRef(0);\n const beamTimerRef = useRef(0);\n const beamMatRef = useRef<THREE.LineBasicMaterial | null>(null);\n const rayScratchRef = useRef<ToolgunRaycastResult | null>(null);\n const fallbackPtRef = useRef<[number, number, number]>([0, 0, 0]);\n\n const beamGeo = useMemo(() => {\n const g = new THREE.BufferGeometry();\n g.setAttribute(\"position\", new THREE.Float32BufferAttribute([0, 0, 0, 0, 0, -1], 3));\n return g;\n }, []);\n const beamLine = useMemo(() => {\n const mat = new THREE.LineBasicMaterial({ color: accentColor, transparent: true, opacity: 0, depthTest: false });\n beamMatRef.current = mat;\n const line = new THREE.Line(beamGeo, mat);\n line.frustumCulled = false;\n line.visible = false;\n return line;\n }, [beamGeo, accentColor]);\n useEffect(() => () => {\n beamMatRef.current?.dispose();\n }, [beamLine]);\n useEffect(() => () => beamGeo.dispose(), [beamGeo]);\n\n const resolvePlayerBody = useCallback((): RAPIER.RigidBody | null => {\n if (actorRef?.current?.body)\n return actorRef.current.body;\n const pilot = kootaWorld.queryFirst(ActorTrait);\n return pilot?.get(ActorTrait)?.handle?.body ?? null;\n }, [actorRef, kootaWorld]);\n\n const findJointForBody = useCallback((body: RAPIER.RigidBody | null): JointRuntime | null => {\n if (!body || !jointRegistry)\n return null;\n for (const rt of jointRegistry) {\n if (!rt.detached && rt.childBody?.handle === body.handle)\n return rt;\n }\n return null;\n }, [jointRegistry]);\n\n const fire = useCallback((shiftKey = false): ToolgunActionOutcome => {\n camera.getWorldPosition(_camPos);\n camera.getWorldDirection(_camDir);\n const st = useToolgunStore.getState();\n const playerBody = resolvePlayerBody();\n const rawHit = castToolgunRay(rapier, rapierWorld, _camPos, _camDir, maxRangeM, playerBody);\n\n let fallbackPoint: [number, number, number] = [\n _camPos.x + _camDir.x * 5,\n Math.max(0, _camPos.y + _camDir.y * 5),\n _camPos.z + _camDir.z * 5,\n ];\n if (_camDir.y < -0.02 && _camPos.y > 0) {\n const tGround = -_camPos.y / _camDir.y;\n if (tGround > 0.1 && tGround <= maxRangeM) {\n fallbackPoint = [_camPos.x + _camDir.x * tGround, 0, _camPos.z + _camDir.z * tGround];\n }\n }\n const aimPoint = rawHit ? rawHit.point : fallbackPoint;\n const aimNormal: [number, number, number] = rawHit ? rawHit.normal : [0, 1, 0];\n\n recoilRef.current = 1;\n beamTimerRef.current = 0.09;\n _beamEndVec.set(aimPoint[0], aimPoint[1], aimPoint[2]);\n\n if (holderRef.current) {\n const mLocal = measured?.muzzleLocal ?? [0, 0.038, -0.26];\n const gOff = measured?.gripOffset ?? [0, 0, 0];\n _muzzleWorld.set(mLocal[0] + gOff[0], mLocal[1] + gOff[1], mLocal[2] + gOff[2]).applyMatrix4(holderRef.current.matrixWorld);\n }\n else {\n _muzzleWorld.copy(_camPos).addScaledVector(_camDir, 0.35);\n }\n const posAttr = beamGeo.getAttribute(\"position\") as THREE.BufferAttribute;\n posAttr.setXYZ(0, _muzzleWorld.x, _muzzleWorld.y, _muzzleWorld.z);\n posAttr.setXYZ(1, _beamEndVec.x, _beamEndVec.y, _beamEndVec.z);\n posAttr.needsUpdate = true;\n beamLine.visible = true;\n\n if (st.mode === \"spawn\") {\n const asset = st.armedAsset;\n if (!asset || (!asset.bundle && !asset.src)) {\n st.bumpFire(\"NO ASSET ARMED\");\n return { ok: false, status: \"NO ASSET ARMED\", beamEnd: aimPoint };\n }\n const pose = computeAlignedSpawnPose(aimPoint, st.yaw12, aimNormal, 0.08);\n const isVehicle = asset.kind === \"vehicle\" || (\n asset.kind !== \"prop\" &&\n Boolean(asset.bundle && (asset.bundle.wheels.length > 0 || asset.bundle.propellers.length > 0))\n );\n const id = `tg_ent_${Date.now().toString(36)}_${st.fireCount}`;\n st.recordSpawn({\n id,\n name: asset.name,\n kind: isVehicle ? \"vehicle\" : \"prop\",\n ...(asset.src ? { src: asset.src } : {}),\n ...(asset.bundle ? { bundle: asset.bundle } : {}),\n fixed: Boolean(asset.fixed),\n position: pose.position,\n quaternion: pose.quaternion,\n });\n return { ok: true, status: `SPAWNED ${asset.name}`, beamEnd: aimPoint };\n }\n\n if (st.mode === \"build\") {\n const candidate = computeBuildCandidate(st.placedPieces, aimPoint, st.buildKind, st.yaw12);\n const placed = st.placeBuildPiece(candidate);\n return {\n ok: placed !== null,\n status: placed ? `PLACED ${placed.kind}` : candidate.reason.toUpperCase(),\n beamEnd: candidate.position,\n };\n }\n\n if (st.mode === \"rig\") {\n const hitJoint = findJointForBody(rawHit?.body ?? null);\n if (!hitJoint) {\n st.bumpFire(\"NO KHR JOINT HIT\");\n return { ok: false, status: \"NO KHR JOINT HIT\", beamEnd: aimPoint };\n }\n const status = rigJointRuntime(hitJoint, shiftKey);\n st.bumpFire(status.toUpperCase());\n return { ok: true, status, beamEnd: aimPoint };\n }\n\n if (st.mode === \"weld\" || st.mode === \"hinge\") {\n if (!rawHit?.body) {\n st.setPendingAnchor(null);\n st.bumpFire(\"MISS — CLEARED ANCHOR\");\n return { ok: false, status: \"MISS — CLEARED ANCHOR\", beamEnd: aimPoint };\n }\n const pending = st.pendingAnchor;\n const liveBodyA = pending && pending.world === rapierWorld\n ? rapierWorld.getRigidBody(pending.body.handle)\n : null;\n if (!pending || !liveBodyA) {\n const ud = rawHit.body.userData as { name?: string } | undefined;\n const label = ud?.name ?? `body_${rawHit.body.handle}`;\n st.setPendingAnchor({\n world: rapierWorld,\n body: rawHit.body,\n worldPoint: rawHit.point,\n worldNormal: rawHit.normal,\n label,\n });\n st.bumpFire(`LOCKED A: ${label}`);\n return { ok: true, status: `LOCKED A: ${label}`, beamEnd: aimPoint };\n }\n if (liveBodyA.handle === rawHit.body.handle) {\n st.setPendingAnchor(null);\n st.bumpFire(\"SAME BODY — CANCELLED\");\n return { ok: false, status: \"SAME BODY — CANCELLED\", beamEnd: aimPoint };\n }\n const anchorMid: [number, number, number] = [\n 0.5 * (pending.worldPoint[0] + rawHit.point[0]),\n 0.5 * (pending.worldPoint[1] + rawHit.point[1]),\n 0.5 * (pending.worldPoint[2] + rawHit.point[2]),\n ];\n const imp = st.mode === \"weld\"\n ? createWeldImpulseJoint(rapier, rapierWorld, liveBodyA, rawHit.body, anchorMid)\n : createHingeImpulseJoint(rapier, rapierWorld, liveBodyA, rawHit.body, anchorMid, pending.worldNormal);\n const id = `tg_${st.mode}_${imp.handle}`;\n st.recordJoint({\n id,\n kind: st.mode,\n world: rapierWorld,\n handle: imp.handle,\n joint: imp,\n anchorWorld: anchorMid,\n });\n return { ok: true, status: `${st.mode.toUpperCase()} CREATED`, beamEnd: anchorMid };\n }\n\n // delete mode\n if (!rawHit) {\n st.bumpFire(\"NOTHING HIT\");\n return { ok: false, status: \"NOTHING HIT\", beamEnd: aimPoint };\n }\n const ud = (rawHit.body?.userData ?? {}) as { kolmoSpawnedId?: string; kolmoPlacedPieceId?: string };\n if (ud.kolmoPlacedPieceId && st.removePieceById(ud.kolmoPlacedPieceId)) {\n return { ok: true, status: `REMOVED ${ud.kolmoPlacedPieceId}`, beamEnd: aimPoint };\n }\n if (ud.kolmoSpawnedId && st.removeEntityById(ud.kolmoSpawnedId, rapierWorld)) {\n return { ok: true, status: `DELETED ${ud.kolmoSpawnedId}`, beamEnd: aimPoint };\n }\n if (rawHit.body) {\n const removedJoints = st.removeJointByBody(rapierWorld, rawHit.body);\n if (removedJoints > 0)\n return { ok: true, status: `REMOVED ${removedJoints} JOINT(S)`, beamEnd: aimPoint };\n }\n st.bumpFire(\"STATIC WORLD TARGET\");\n return { ok: false, status: \"STATIC WORLD TARGET\", beamEnd: aimPoint };\n }, [camera, rapier, rapierWorld, maxRangeM, resolvePlayerBody, findJointForBody, measured, beamGeo, beamLine]);\n\n useImperativeHandle(ref, () => ({\n fire,\n undo: () => useToolgunStore.getState().undoLast(rapierWorld),\n }), [fire, rapierWorld]);\n\n useEffect(() => {\n if (!enable || !enableShortcuts || typeof window === \"undefined\")\n return;\n const isEditable = (el: Element | null): boolean => {\n if (!el)\n return false;\n const tag = (el as HTMLElement).tagName;\n return tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\" || Boolean((el as HTMLElement).isContentEditable);\n };\n\n const onKeyDown = (e: KeyboardEvent): void => {\n if (isEditable(document.activeElement) || kootaWorld.queryFirst(pilotedVehicleQuery))\n return;\n const st = useToolgunStore.getState();\n if (e.code >= \"Digit1\" && e.code <= \"Digit6\") {\n const idx = Number(e.code.slice(5)) - 1;\n if (TOOLGUN_MODES[idx])\n st.setMode(TOOLGUN_MODES[idx]);\n return;\n }\n if (e.code === \"KeyQ\" && !e.metaKey && !e.ctrlKey) {\n st.cycleMode(e.shiftKey ? -1 : 1);\n }\n else if (e.code === \"KeyR\" && !e.metaKey && !e.ctrlKey) {\n st.rotateYaw12(e.shiftKey ? -1 : 1);\n }\n else if (e.code === \"BracketLeft\") {\n st.cycleBuildKind(-1);\n }\n else if (e.code === \"BracketRight\") {\n st.cycleBuildKind(1);\n }\n else if (e.code === \"KeyZ\" && !e.metaKey && !e.ctrlKey) {\n st.undoLast(rapierWorld);\n }\n else if (e.code === \"Tab\") {\n e.preventDefault();\n st.setZoomed(!st.zoomed);\n }\n };\n\n const dom = gl?.domElement;\n let downPos: [number, number] | null = null;\n const onPointerDown = (e: PointerEvent): void => {\n if (kootaWorld.queryFirst(pilotedVehicleQuery))\n return;\n if (e.button === 2) {\n useToolgunStore.getState().setZoomed(true);\n }\n else if (e.button === 0) {\n downPos = [e.clientX, e.clientY];\n }\n };\n const onPointerUp = (e: PointerEvent): void => {\n if (e.button === 2) {\n useToolgunStore.getState().setZoomed(false);\n return;\n }\n if (e.button === 0 && downPos && !kootaWorld.queryFirst(pilotedVehicleQuery)) {\n const moved = Math.hypot(e.clientX - downPos[0], e.clientY - downPos[1]);\n downPos = null;\n if (moved <= 6)\n fire(e.shiftKey);\n }\n };\n const onContextMenu = (e: MouseEvent): void => {\n if (!kootaWorld.queryFirst(pilotedVehicleQuery))\n e.preventDefault();\n };\n\n window.addEventListener(\"keydown\", onKeyDown);\n dom?.addEventListener(\"pointerdown\", onPointerDown);\n window.addEventListener(\"pointerup\", onPointerUp);\n dom?.addEventListener(\"contextmenu\", onContextMenu);\n return () => {\n window.removeEventListener(\"keydown\", onKeyDown);\n dom?.removeEventListener(\"pointerdown\", onPointerDown);\n window.removeEventListener(\"pointerup\", onPointerUp);\n dom?.removeEventListener(\"contextmenu\", onContextMenu);\n };\n }, [enable, enableShortcuts, gl, kootaWorld, rapierWorld, fire]);\n\n useFrame((_, delta) => {\n const dt = Math.min(Math.max(delta, 1e-4), 1 / 20);\n const piloted = Boolean(kootaWorld.queryFirst(pilotedVehicleQuery));\n const holder = holderRef.current;\n if (holder)\n holder.visible = enable && !piloted;\n if (!enable || piloted) {\n beamLine.visible = false;\n return;\n }\n\n const st = useToolgunStore.getState();\n if (recoilRef.current > 0)\n recoilRef.current = Math.max(0, recoilRef.current - dt * 7.5);\n if (beamTimerRef.current > 0) {\n beamTimerRef.current = Math.max(0, beamTimerRef.current - dt);\n if (beamMatRef.current)\n beamMatRef.current.opacity = Math.min(1, beamTimerRef.current * 12);\n if (beamTimerRef.current <= 0)\n beamLine.visible = false;\n }\n\n if (holder) {\n const goal = st.zoomed ? zoomOffset : hipOffset;\n _targetOffset.set(goal[0], goal[1] - recoilRef.current * 0.012, goal[2] + recoilRef.current * 0.038);\n easing.damp3(holder.position, _targetOffset, 0.09, dt);\n holder.rotation.set(recoilRef.current * 0.14, 0, 0);\n }\n\n camera.getWorldPosition(_camPos);\n camera.getWorldDirection(_camDir);\n const playerBody = resolvePlayerBody();\n const hit = castToolgunRay(rapier, rapierWorld, _camPos, _camDir, maxRangeM, playerBody, rayScratchRef.current ?? undefined);\n if (hit && !rayScratchRef.current)\n rayScratchRef.current = hit;\n else if (!hit && rayScratchRef.current)\n rayScratchRef.current.body = null;\n\n let targetLabel = \"NO TARGET\";\n if (hit) {\n const jRt = findJointForBody(hit.body);\n const ud = (hit.body?.userData ?? {}) as { name?: string; kolmoPlacedPieceId?: string; kolmoSpawnedId?: string };\n const name = jRt ? `JOINT:${jRt.nodeName}` : (ud.name ?? ud.kolmoPlacedPieceId ?? ud.kolmoSpawnedId ?? \"SURFACE\");\n targetLabel = `${name} (${hit.toi.toFixed(1)}m)`;\n }\n\n if (st.mode === \"build\") {\n const fb = fallbackPtRef.current;\n fb[0] = _camPos.x + _camDir.x * 5;\n fb[1] = Math.max(0, _camPos.y + _camDir.y * 5);\n fb[2] = _camPos.z + _camDir.z * 5;\n if (!hit && _camDir.y < -0.02 && _camPos.y > 0) {\n const tFloor = -_camPos.y / _camDir.y;\n if (tFloor > 0.1 && tFloor <= maxRangeM) {\n fb[0] = _camPos.x + _camDir.x * tFloor;\n fb[1] = 0;\n fb[2] = _camPos.z + _camDir.z * tFloor;\n }\n }\n const cand = computeBuildCandidate(st.placedPieces, hit ? hit.point : fb, st.buildKind, st.yaw12);\n if (!isSameBuildPreview(st.buildPreview, cand))\n st.setBuildPreview(cand);\n }\n else if (st.buildPreview !== null) {\n st.setBuildPreview(null);\n }\n\n const detail = st.mode === \"build\"\n ? st.buildKind\n : st.mode === \"spawn\"\n ? (st.armedAsset?.name ?? \"UNARMED\")\n : st.pendingAnchor\n ? `A: ${st.pendingAnchor.label}`\n : `${st.mode.toUpperCase()} READY`;\n\n lcd.draw({\n mode: st.mode,\n yawDeg: st.yaw12 * 30,\n detail,\n targetLabel,\n status: st.statusText,\n accentColor,\n });\n });\n\n return (\n <>\n {createPortal(\n <group ref={holderRef} position={[hipOffset[0], hipOffset[1], hipOffset[2]]}>\n {measured ? (\n <group position={measured.gripOffset}>\n <primitive object={measured.scene} />\n <mesh position={measured.screenPos} quaternion={measured.screenQuat}>\n <planeGeometry args={measured.screenSize} />\n <meshBasicMaterial\n {...(lcd.texture ? { map: lcd.texture } : { color: accentColor })}\n toneMapped={false}\n />\n </mesh>\n </group>\n ) : (\n <DefaultToolgunMesh accentColor={accentColor} lcdTexture={lcd.texture} />\n )}\n </group>,\n camera,\n )}\n <primitive object={beamLine} />\n {enable && !isPiloted && mode === \"build\" && buildPreview && (\n <BuildGhostPreview candidate={buildPreview} />\n )}\n {mountWorldOutlets && (\n <group name=\"kolmo_toolgun_outlets\">\n {spawnedEntities.map((entry) => (\n <SpawnedToolgunOutlet key={entry.id} entry={entry} />\n ))}\n {placedPieces.map((piece) => (\n <C12PieceColliderAndMesh key={piece.id} piece={piece} />\n ))}\n </group>\n )}\n </>\n );\n}\n\nfunction ToolgunFromUrl({ src, ...rest }: Omit<KolmoToolgunProps, \"src\" | \"bundle\"> & { src: string }): React.JSX.Element | null {\n const bundle = useKhrGlb(src);\n return <ToolgunCore {...rest} viewmodelBundle={bundle} />;\n}\n\nexport function KolmoToolgun({ src, bundle, ...rest }: KolmoToolgunProps): React.JSX.Element | null {\n const cloned = useMemo(() => (bundle ? cloneKhrBundle(bundle) : null), [bundle]);\n if (src)\n return <ToolgunFromUrl src={src} {...rest} />;\n return <ToolgunCore {...rest} viewmodelBundle={cloned} />;\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAa,gBAAgB;CAAC;CAAS;CAAQ;CAAS;CAAO;CAAS;AAAQ;AAGhF,IAAa,sBAAsB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AAuEA,IAAM,aAAa,IAAI,MAAM,QAAQ,GAAG,GAAG,CAAC;AAC5C,IAAM,UAAU,IAAI,MAAM,QAAQ;AAClC,IAAM,aAAa,IAAI,MAAM,WAAW;AACxC,IAAM,WAAW,IAAI,MAAM,WAAW;AACtC,IAAM,MAAM,IAAI,MAAM,WAAW;AACjC,IAAM,MAAM,IAAI,MAAM,WAAW;AACjC,IAAM,SAAS,IAAI,MAAM,WAAW;AACpC,IAAM,SAAS,IAAI,MAAM,WAAW;AACpC,IAAM,QAAQ,IAAI,MAAM,WAAW;AACnC,IAAM,MAAM,IAAI,MAAM,QAAQ;AAC9B,IAAM,MAAM,IAAI,MAAM,QAAQ;AAC9B,IAAM,WAAW,IAAI,MAAM,QAAQ;AACnC,IAAM,YAAY,IAAI,MAAM,QAAQ;AAEpC,IAAI,aAAgC;AAEpC,SAAS,SAAS,GAAsB;CACpC,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,KAAM,EAA6B;AACnE;AACA,SAAS,SAAS,GAAsB;CACpC,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,KAAM,EAA6B;AACnE;AACA,SAAS,SAAS,GAAsB;CACpC,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,KAAM,EAA6B;AACnE;;;;;AAMA,SAAgB,eACZ,QACA,OACA,QACA,WACA,WAAW,IACX,aACA,KAC2B;CAC3B,MAAM,KAAK,SAAS,MAAM,GAAG,KAAK,SAAS,MAAM,GAAG,KAAK,SAAS,MAAM;CACxE,MAAM,KAAK,SAAS,SAA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BAAD;EAAqB;EAAK,GAAI;CAAO,CAAA;CAChD,OAAOA,oBAAC,aAAD;EAAa,GAAI;EAAM,iBAAiB;CAAS,CAAA;AAC5D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"world-BljtS6Fb.js","names":["_jsx","_jsxs","_jsx","_jsxs","_jsx","_Fragment","createPortal"],"sources":["../src/engine/input.ts","../src/engine/vehicle.tsx","../src/engine/surface.tsx","../src/engine/world.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useRef, type ReactNode } from \"react\";\nimport { useKeyboardControls, type KeyboardControlsEntry } from \"@react-three/drei\";\nimport { useButtonStore, useJoystickStore } from \"@pinkaphant/ecctrl/input\";\n\nexport const KolmoKeyboardContext = createContext<(() => Record<string, boolean>) | null>(null);\n\nexport function KolmoKeyboardBridge({ children }: { readonly children: ReactNode }): React.JSX.Element {\n const [, getKeys] = useKeyboardControls();\n return React.createElement(KolmoKeyboardContext.Provider, { value: getKeys }, children);\n}\n\nexport type KolmoKeyAction =\n | \"forward\"\n | \"backward\"\n | \"left\"\n | \"right\"\n | \"brake\"\n | \"boost\"\n | \"interact\"\n | \"turnLeft\"\n | \"turnRight\"\n | \"descend\"\n | \"cameraView\"\n | \"reset\"\n | \"modeToggle\";\n\nexport interface KolmoInputState extends Record<KolmoKeyAction, boolean> {\n stickX: number;\n stickY: number;\n}\n\nexport type KolmoInputGetter = () => Partial<KolmoInputState>;\n\nexport const KOLMO_STICK_DEADZONE = 0.08;\n\nconst EMPTY_KEYS: Readonly<Record<KolmoKeyAction, boolean>> = Object.freeze({\n forward: false,\n backward: false,\n left: false,\n right: false,\n brake: false,\n boost: false,\n interact: false,\n turnLeft: false,\n turnRight: false,\n descend: false,\n cameraView: false,\n reset: false,\n modeToggle: false,\n});\n\nexport const EMPTY_KOLMO_INPUT: Readonly<KolmoInputState> = Object.freeze({\n ...EMPTY_KEYS,\n stickX: 0,\n stickY: 0,\n});\n\nexport const KOLMO_KEY_MAP: KeyboardControlsEntry<string>[] = [\n { name: \"forward\", keys: [\"KeyW\", \"ArrowUp\"] },\n { name: \"backward\", keys: [\"KeyS\", \"ArrowDown\"] },\n { name: \"left\", keys: [\"KeyA\", \"ArrowLeft\"] },\n { name: \"right\", keys: [\"KeyD\", \"ArrowRight\"] },\n { name: \"brake\", keys: [\"Space\"] },\n { name: \"boost\", keys: [\"ShiftLeft\", \"ShiftRight\"] },\n { name: \"interact\", keys: [\"KeyF\"] },\n { name: \"turnLeft\", keys: [\"KeyQ\"] },\n { name: \"turnRight\", keys: [\"KeyC\"] },\n { name: \"descend\", keys: [\"KeyX\", \"ControlLeft\"] },\n { name: \"cameraView\", keys: [\"KeyV\"] },\n { name: \"reset\", keys: [\"KeyR\"] },\n { name: \"modeToggle\", keys: [\"KeyG\"] },\n];\n\n/**\n * Input reader merging Drei `<KeyboardControls>`, `@pinkaphant/ecctrl/input`\n * Zustand stores (`useJoystickStore` + `useButtonStore`), and optional `getInput()` overrides.\n * Analog thumbstick values stay analog (`stickX`, `stickY`) rather than slamming digital WASD booleans.\n */\nexport function useKolmoInput(getInput?: KolmoInputGetter): () => Readonly<KolmoInputState> {\n const getKeyboard = useContext(KolmoKeyboardContext);\n const getterRef = useRef(getInput);\n getterRef.current = getInput;\n const outRef = useRef<KolmoInputState>({ ...EMPTY_KOLMO_INPUT });\n\n return useCallback(() => {\n const custom = getterRef.current?.();\n const k = getKeyboard ? getKeyboard() : EMPTY_KEYS;\n const rawStick = useJoystickStore.getState().joysticks.default;\n const btns = useButtonStore.getState().buttons;\n const rx = rawStick?.x ?? 0;\n const ry = rawStick?.y ?? 0;\n const mag = Math.hypot(rx, ry);\n const scaled = mag > KOLMO_STICK_DEADZONE ? (Math.min(1, mag) - KOLMO_STICK_DEADZONE) / ((1 - KOLMO_STICK_DEADZONE) * mag) : 0;\n\n const out = outRef.current;\n out.stickX = custom?.stickX ?? rx * scaled;\n out.stickY = custom?.stickY ?? ry * scaled;\n out.forward = Boolean(custom?.forward ?? k.forward);\n out.backward = Boolean(custom?.backward ?? k.backward);\n out.left = Boolean(custom?.left ?? k.left);\n out.right = Boolean(custom?.right ?? k.right);\n out.brake = Boolean(custom?.brake ?? (k.brake || btns.brake || btns.jump));\n out.boost = Boolean(custom?.boost ?? (k.boost || btns.boost || btns.run));\n out.interact = Boolean(custom?.interact ?? (k.interact || btns.interact));\n out.turnLeft = Boolean(custom?.turnLeft ?? (k.turnLeft || btns.turnLeft));\n out.turnRight = Boolean(custom?.turnRight ?? (k.turnRight || btns.turnRight));\n out.descend = Boolean(custom?.descend ?? (k.descend || btns.descend));\n out.cameraView = Boolean(custom?.cameraView ?? (k.cameraView || btns.cameraView));\n out.reset = Boolean(custom?.reset ?? (k.reset || btns.reset));\n out.modeToggle = Boolean(custom?.modeToggle ?? (k.modeToggle || btns.modeToggle));\n return out;\n }, [getKeyboard]);\n}\n","import React, { useCallback, useContext, useId, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport * as THREE from \"three\";\nimport { useFrame, type RootState } from \"@react-three/fiber\";\nimport { useRapier } from \"@react-three/rapier\";\nimport { easing } from \"maath\";\nimport type { Entity } from \"koota\";\nimport { useHas } from \"koota/react\";\nimport { assignRef, cloneKhrBundle, useKhrGlb, type KhrAssetBundle } from \"@khr3/core\";\nimport { KhrVehicle, type KhrVehicleJointsHandle, type KhrVehicleProps } from \"@khr3/core/vehicle\";\nimport type { EcctrlVehicleHandle, VehicleInput } from \"@pinkaphant/ecctrl/vehicle\";\nimport { KolmoGravityContext } from \"../physics/index.js\";\nimport { useKolmoInput, type KolmoInputGetter } from \"./input.js\";\nimport {\n InteractableTrait,\n PilotedTag,\n TransformTrait,\n VehicleTelemetryTrait,\n VehicleTrait,\n VelocityTrait,\n createEmptyVehicleCmd,\n ensureWorldSession,\n flipVehicleBodyUpright,\n kolmoActions,\n pilotedVehicleQuery,\n useActiveKolmoWorld,\n writeEntityKinematics,\n writeVehicleTelemetry,\n} from \"./traits.js\";\n\nfunction hasActiveCmd(c: Readonly<VehicleInput>): boolean {\n return Boolean(\n c.forward || c.backward || c.steerLeft || c.steerRight || c.brake ||\n c.throttleUp || c.throttleDown || c.yawLeft || c.yawRight ||\n c.pitchForward || c.pitchBackward || c.rollLeft || c.rollRight ||\n (c.joystickL && (c.joystickL.x !== 0 || c.joystickL.y !== 0)) ||\n (c.joystickR && (c.joystickR.x !== 0 || c.joystickR.y !== 0)),\n );\n}\n\nfunction clearCmdInPlace(cmd: VehicleInput, stickL: { x: number; y: number }, stickR: { x: number; y: number }): void {\n cmd.forward = false;\n cmd.backward = false;\n cmd.steerLeft = false;\n cmd.steerRight = false;\n cmd.brake = false;\n cmd.throttleUp = false;\n cmd.throttleDown = false;\n cmd.yawLeft = false;\n cmd.yawRight = false;\n cmd.pitchForward = false;\n cmd.pitchBackward = false;\n cmd.rollLeft = false;\n cmd.rollRight = false;\n stickL.x = 0;\n stickL.y = 0;\n stickR.x = 0;\n stickR.y = 0;\n cmd.joystickL = stickL;\n cmd.joystickR = stickR;\n}\n\nconst _up = new THREE.Vector3();\nconst _fwd = new THREE.Vector3();\nconst _camGoal = new THREE.Vector3();\nconst _lookGoal = new THREE.Vector3();\n\nexport interface KolmoVehicleProps extends Omit<KhrVehicleProps, \"ref\" | \"bundle\"> {\n readonly ref?: React.Ref<EcctrlVehicleHandle>;\n readonly id?: string;\n readonly src?: string;\n readonly bundle?: KhrAssetBundle;\n readonly piloted?: boolean;\n readonly flightMode?: boolean;\n readonly vehicleMode?: \"drive\" | \"rocket\";\n readonly interactRadius?: number;\n readonly getInput?: KolmoInputGetter;\n readonly driver?: (veh: EcctrlVehicleHandle, dt: number, state: RootState) => void;\n readonly cameraController?: (veh: EcctrlVehicleHandle, dt: number, state: RootState) => void;\n}\n\nfunction KolmoVehicleMount({\n ref,\n vehicleRef,\n jointsRef: outerJointsRef,\n id,\n sourceBundle,\n alreadyCloned = false,\n piloted = false,\n flightMode = false,\n vehicleMode,\n interactRadius = 4.2,\n enable = true,\n enableCustomGravity,\n carConfig,\n wheelConfig,\n propellerConfig,\n droneConfig,\n getInput,\n driver,\n cameraController,\n children,\n ...khrRest\n}: Omit<KolmoVehicleProps, \"src\" | \"bundle\" | \"id\"> & {\n id: string;\n sourceBundle: KhrAssetBundle;\n alreadyCloned?: boolean;\n}): React.JSX.Element {\n const ctxCustomGravity = useContext(KolmoGravityContext);\n const activeWorld = useActiveKolmoWorld();\n useLayoutEffect(() => {\n ensureWorldSession(activeWorld);\n }, [activeWorld]);\n\n const readInput = useKolmoInput(getInput);\n const bundle = useMemo(\n () => (alreadyCloned ? sourceBundle : cloneKhrBundle(sourceBundle)),\n [sourceBundle, alreadyCloned],\n );\n const jointsRef = useRef<KhrVehicleJointsHandle | null>(null);\n const innerRef = useRef<EcctrlVehicleHandle | null>(null);\n\n const canHybridToggle = vehicleMode === undefined && bundle.wheels.length > 0 && bundle.propellers.length > 0;\n const [hybridFlight, setHybridFlight] = useState(flightMode);\n useLayoutEffect(() => {\n setHybridFlight(flightMode);\n }, [flightMode]);\n const [boostThrustActive, setBoostThrustActive] = useState(false);\n const boostThrustRef = useRef(false);\n\n const isFlight = Boolean(\n vehicleMode === \"rocket\" ||\n (canHybridToggle ? hybridFlight : flightMode) ||\n (vehicleMode !== \"drive\" && bundle.propellers.length > 0 && bundle.wheels.length === 0),\n );\n const isManualTrans = (carConfig?.transmissionMode ?? bundle.tune?.transmissionMode) === \"manual\";\n\n const seatOffset = useMemo<[number, number, number]>(() => {\n const dot = bundle.sockets.IK_Seat ?? bundle.sockets.seat ?? bundle.sockets.driver_butt ?? bundle.sockets.butt;\n return dot ? [dot[0], dot[1], dot[2]] : [0, 0.65, 0];\n }, [bundle.sockets]);\n\n const exitOffset = useMemo<[number, number, number]>(() => {\n const dot = bundle.sockets.Socket_Exit ?? bundle.sockets.exit;\n return dot ? [dot[0], dot[1], dot[2]] : [-1.55, 0.45, 0];\n }, [bundle.sockets]);\n\n const propActive = bundle.propellers.length > 0 && (isFlight || (vehicleMode !== \"drive\" && boostThrustActive));\n const mergedWheelConfig = useMemo<KhrVehicleProps[\"wheelConfig\"]>(() => {\n const wheelOverride = bundle.wheels.length > 0 && vehicleMode === \"rocket\" ? { enable: false } : undefined;\n return !wheelConfig && !wheelOverride ? undefined : { ...wheelOverride, ...(wheelConfig ?? {}) };\n }, [bundle.wheels.length, vehicleMode, wheelConfig]);\n\n const mergedPropellerConfig = useMemo<KhrVehicleProps[\"propellerConfig\"]>(() => {\n const propOverride = bundle.propellers.length > 0 && !propActive ? { enable: false } : undefined;\n return !propellerConfig && !propOverride ? undefined : { ...propOverride, ...(propellerConfig ?? {}) };\n }, [bundle.propellers.length, propActive, propellerConfig]);\n\n const [vehEnt, setVehEnt] = useState<Entity | null>(null);\n const vehEntRef = useRef<Entity | null>(null);\n const camTargetRef = useRef(new THREE.Vector3());\n const stickLRef = useRef({ x: 0, y: 0 });\n const stickRRef = useRef({ x: 0, y: 0 });\n const cmdRef = useRef(createEmptyVehicleCmd(false));\n const stRef = useRef({ camInit: false, cockpit: false, prevCam: false, prevReset: false, prevMode: false, wasPiloted: false });\n\n useLayoutEffect(() => {\n const ent = activeWorld.spawn(\n VehicleTrait({ id, handle: innerRef.current, jointsHandle: jointsRef.current, seatOffset, exitOffset, isFlight }),\n InteractableTrait({ id, radius: interactRadius, kind: \"vehicle\" }),\n TransformTrait,\n VelocityTrait,\n VehicleTelemetryTrait,\n );\n vehEntRef.current = ent;\n setVehEnt(ent);\n if (piloted && !activeWorld.queryFirst(pilotedVehicleQuery)) {\n kolmoActions(activeWorld).boardVehicle(id);\n }\n return () => {\n if (ent.isAlive() && ent.has(PilotedTag))\n kolmoActions(activeWorld).exitVehicle();\n vehEntRef.current = null;\n ent.destroy();\n };\n }, [activeWorld, id]);\n\n useLayoutEffect(() => {\n const ent = vehEntRef.current;\n if (!ent?.isAlive())\n return;\n const v = ent.get(VehicleTrait);\n if (v)\n ent.set(VehicleTrait, { ...v, seatOffset, exitOffset, isFlight });\n ent.set(InteractableTrait, { id, radius: interactRadius, kind: \"vehicle\" });\n }, [id, seatOffset, exitOffset, interactRadius, isFlight]);\n\n const assignVehicleRef = useCallback((handle: EcctrlVehicleHandle | null) => {\n innerRef.current = handle;\n assignRef(vehicleRef, handle);\n assignRef(ref, handle);\n const ent = vehEntRef.current;\n if (ent?.isAlive()) {\n const v = ent.get(VehicleTrait);\n if (v)\n ent.set(VehicleTrait, { ...v, handle });\n }\n }, [ref, vehicleRef]);\n\n const assignJointsRef = useCallback((jh: KhrVehicleJointsHandle | null) => {\n jointsRef.current = jh;\n assignRef(outerJointsRef, jh);\n const ent = vehEntRef.current;\n if (ent?.isAlive()) {\n const v = ent.get(VehicleTrait);\n if (v)\n ent.set(VehicleTrait, { ...v, jointsHandle: jh });\n }\n }, [outerJointsRef]);\n\n const { world: rapierWorld } = useRapier();\n const hasPilotedTag = useHas(vehEnt, PilotedTag);\n const isPiloted = hasPilotedTag || (piloted && vehEnt === null);\n\n const recordKinematicsAndTelemetry = (veh: EcctrlVehicleHandle, throttle: number, boost: number): void => {\n if (!vehEntRef.current?.isAlive())\n return;\n let maxSlip = 0;\n for (const w of veh.wheelsInfo.values()) {\n if (w.current.rayHit && w.current.slipStrength > maxSlip)\n maxSlip = w.current.slipStrength;\n }\n writeEntityKinematics(activeWorld, vehEntRef.current, veh.currPos, veh.currQuat, veh.currLinVel, veh.currLinVel.length() * 3.6);\n writeVehicleTelemetry(activeWorld, vehEntRef.current, Math.round(veh.engineRPM), veh.gearIndex + 1, throttle, boost, Math.min(1, maxSlip));\n };\n\n useFrame((state, delta) => {\n const dt = rapierWorld.timestep > 0 ? rapierWorld.timestep : Math.min(Math.max(delta, 1e-4), 1 / 30);\n const veh = innerRef.current;\n if (!veh?.body)\n return;\n\n if (driver) {\n driver(veh, dt, state);\n recordKinematicsAndTelemetry(veh, 0, 0);\n cameraController?.(veh, dt, state);\n return;\n }\n\n const keys = readInput();\n const st = stRef.current;\n const cmd = cmdRef.current;\n const stickL = stickLRef.current;\n const stickR = stickRRef.current;\n\n const wantBoostProp = isPiloted && !isFlight && vehicleMode !== \"drive\" && bundle.propellers.length > 0 && keys.boost && (keys.forward || keys.brake);\n if (wantBoostProp !== boostThrustRef.current) {\n boostThrustRef.current = wantBoostProp;\n setBoostThrustActive(wantBoostProp);\n }\n\n if (isPiloted) {\n st.wasPiloted = true;\n if (keys.cameraView && !st.prevCam)\n st.cockpit = !st.cockpit;\n st.prevCam = keys.cameraView;\n if (keys.reset && !st.prevReset) {\n flipVehicleBodyUpright(veh, jointsRef.current);\n }\n st.prevReset = keys.reset;\n if (keys.modeToggle && !st.prevMode && canHybridToggle)\n setHybridFlight((f) => !f);\n st.prevMode = keys.modeToggle;\n\n let anyGrounded = false;\n for (const w of veh.wheelsInfo.values()) {\n if (w.current.rayHit) {\n anyGrounded = true;\n break;\n }\n }\n\n if (isFlight) {\n cmd.pitchForward = keys.forward;\n cmd.pitchBackward = keys.backward;\n cmd.yawLeft = keys.left;\n cmd.yawRight = keys.right;\n cmd.rollLeft = keys.turnLeft;\n cmd.rollRight = keys.turnRight;\n cmd.throttleUp = keys.brake;\n cmd.throttleDown = keys.descend;\n cmd.forward = anyGrounded && keys.forward;\n cmd.backward = anyGrounded && keys.backward;\n cmd.steerLeft = anyGrounded && keys.left;\n cmd.steerRight = anyGrounded && keys.right;\n cmd.brake = false;\n stickL.x = 0;\n stickL.y = 0;\n stickR.x = keys.stickX;\n stickR.y = keys.stickY;\n cmd.joystickL = stickL;\n cmd.joystickR = stickR;\n veh.setMovement(cmd);\n }\n else {\n const fwdVel = veh.currLinVel.dot(veh.bodyZAxis);\n const effForward = keys.forward || keys.stickY > 0.15;\n const effBackward = keys.backward || keys.stickY < -0.15;\n const revBraking = effBackward && !effForward && fwdVel > 1.0;\n const fwdBraking = effForward && !effBackward && fwdVel < -1.0;\n if (!isManualTrans && ((effBackward && !revBraking) || (effForward && Math.abs(fwdVel) < 2.5)) && veh.gearIndex !== 0) {\n veh.setGear(0);\n }\n const boostProp = keys.boost && (bundle.propellers.length > 0 || veh.propellersInfo.size > 0) && veh.gravityMag > 1e-4;\n cmd.forward = effForward && !fwdBraking;\n cmd.backward = effBackward && !revBraking;\n cmd.steerLeft = keys.left;\n cmd.steerRight = keys.right;\n cmd.brake = keys.brake || revBraking || fwdBraking;\n cmd.pitchForward = boostProp && effForward;\n cmd.pitchBackward = false;\n cmd.throttleUp = boostProp && !effForward && keys.brake;\n cmd.throttleDown = false;\n cmd.yawLeft = boostProp && keys.left;\n cmd.yawRight = boostProp && keys.right;\n cmd.rollLeft = false;\n cmd.rollRight = false;\n stickL.x = keys.stickX;\n stickL.y = 0;\n stickR.x = 0;\n stickR.y = 0;\n cmd.joystickL = stickL;\n cmd.joystickR = stickR;\n veh.setMovement(cmd);\n }\n }\n else {\n st.prevCam = st.prevReset = st.prevMode = false;\n if (st.wasPiloted || hasActiveCmd(cmd)) {\n st.wasPiloted = false;\n clearCmdInPlace(cmd, stickL, stickR);\n veh.setMovement(cmd);\n }\n }\n\n const throttle = isPiloted ? +(keys.forward || keys.stickY > 0.15 || (isFlight && keys.brake)) : 0;\n const boost = isPiloted && keys.boost && throttle > 0 ? 1 : 0;\n recordKinematicsAndTelemetry(veh, throttle, boost);\n\n if (!isPiloted)\n return;\n if (cameraController) {\n cameraController(veh, dt, state);\n return;\n }\n\n _up.copy(veh.upAxis);\n if (_up.lengthSq() < 1e-6)\n _up.copy(veh.bodyYAxis);\n\n if (st.cockpit) {\n _camGoal.set(seatOffset[0], seatOffset[1] + 0.32, seatOffset[2]).applyQuaternion(veh.currQuat).add(veh.currPos);\n _lookGoal.copy(_camGoal).addScaledVector(veh.bodyZAxis, 24);\n easing.damp3(state.camera.position, _camGoal, 0.04, dt);\n easing.damp3(state.camera.up, veh.bodyYAxis, 0.08, dt);\n state.camera.lookAt(_lookGoal);\n return;\n }\n\n _fwd.copy(veh.bodyZAxis);\n if (!isFlight)\n _fwd.projectOnPlane(_up).normalize();\n if (_fwd.lengthSq() < 1e-6)\n _fwd.copy(veh.bodyZAxis);\n\n _camGoal.copy(veh.currPos).addScaledVector(_fwd, isFlight ? -11.2 : -6.8).addScaledVector(_up, isFlight ? 3.1 : 2.15);\n _lookGoal.copy(veh.currPos).addScaledVector(_fwd, isFlight ? 7.5 : 3.6).addScaledVector(_up, 0.65);\n\n if (!st.camInit) {\n state.camera.position.copy(_camGoal);\n camTargetRef.current.copy(_lookGoal);\n st.camInit = true;\n }\n easing.damp3(state.camera.position, _camGoal, 0.14, dt);\n easing.damp3(camTargetRef.current, _lookGoal, 0.08, dt);\n easing.damp3(state.camera.up, _up, 0.16, dt);\n state.camera.lookAt(camTargetRef.current);\n });\n\n return (\n <KhrVehicle\n ref={assignVehicleRef}\n jointsRef={assignJointsRef}\n bundle={bundle}\n enable={enable}\n enableCustomGravity={enableCustomGravity ?? ctxCustomGravity}\n {...(carConfig === undefined ? {} : { carConfig })}\n {...(mergedWheelConfig === undefined ? {} : { wheelConfig: mergedWheelConfig })}\n {...(mergedPropellerConfig === undefined ? {} : { propellerConfig: mergedPropellerConfig })}\n {...(droneConfig === undefined ? {} : { droneConfig })}\n {...khrRest}\n >\n {children}\n </KhrVehicle>\n );\n}\n\nfunction KolmoVehicleFromUrl(props: Omit<KolmoVehicleProps, \"src\" | \"bundle\" | \"id\"> & { id: string; src: string }): React.JSX.Element {\n const { src, ...rest } = props;\n const bundle = useKhrGlb(src);\n return <KolmoVehicleMount {...rest} sourceBundle={bundle} alreadyCloned />;\n}\n\nexport function KolmoVehicle(props: KolmoVehicleProps): React.JSX.Element | null {\n const reactId = useId();\n const id = props.id ?? `vehicle_${reactId.replace(/:/g, \"\")}`;\n const { src, bundle, ...rest } = props;\n if (bundle)\n return <KolmoVehicleMount {...rest} id={id} sourceBundle={bundle} />;\n if (src)\n return <KolmoVehicleFromUrl {...rest} id={id} src={src} />;\n return null;\n}\n","import React, { useCallback, useContext, useEffect, useMemo, useRef } from \"react\";\nimport * as THREE from \"three\";\nimport type { ThreeEvent } from \"@react-three/fiber\";\nimport { CuboidCollider, RigidBody } from \"@react-three/rapier\";\nimport {\n KhrAssembly,\n assignRef,\n cloneKhrBundle,\n useKhrGlb,\n type KhrAssemblyHandle,\n type KhrAssemblyProps,\n type KhrAssetBundle,\n} from \"@khr3/core\";\nimport { KolmoGravityContext } from \"../physics/index.js\";\n\nfunction ArenaSlab({\n size,\n position,\n color = \"#252b36\",\n}: {\n size: number;\n position: [number, number, number];\n color?: string;\n}): React.JSX.Element {\n const res = useMemo(\n () => ({\n geo: new THREE.BoxGeometry(size, 1, size),\n mat: new THREE.MeshStandardMaterial({ color, roughness: 0.9, metalness: 0.05 }),\n }),\n [size, color],\n );\n useEffect(\n () => () => {\n res.geo.dispose();\n res.mat.dispose();\n },\n [res],\n );\n\n return (\n <RigidBody type=\"fixed\" colliders={false} position={[position[0], position[1] - 0.5, position[2]]} friction={0.9}>\n <CuboidCollider args={[size * 0.5, 0.5, size * 0.5]} restitution={0.04} />\n <mesh geometry={res.geo} material={res.mat} receiveShadow />\n </RigidBody>\n );\n}\n\nfunction BundleSurface({\n ref,\n bundle,\n alreadyCloned = false,\n position,\n enableCustomGravity,\n ...rest\n}: Omit<KhrAssemblyProps, \"bundle\"> & { bundle: KhrAssetBundle; alreadyCloned?: boolean }): React.JSX.Element {\n const ctxCustomGravity = useContext(KolmoGravityContext);\n const cloned = useMemo(() => (alreadyCloned ? bundle : cloneKhrBundle(bundle)), [bundle, alreadyCloned]);\n return (\n <KhrAssembly\n ref={ref}\n bundle={cloned}\n position={position}\n fixedRoot\n enableCustomGravity={enableCustomGravity ?? ctxCustomGravity}\n {...rest}\n />\n );\n}\n\nfunction UrlSurface({\n src,\n ...rest\n}: Omit<KhrAssemblyProps, \"bundle\"> & { src: string }): React.JSX.Element {\n const bundle = useKhrGlb(src);\n return <BundleSurface bundle={bundle} alreadyCloned {...rest} />;\n}\n\nexport interface KolmoSurfaceProps extends Omit<KhrAssemblyProps, \"bundle\"> {\n readonly src?: string;\n readonly bundle?: KhrAssetBundle;\n readonly size?: number;\n readonly color?: string;\n}\n\nexport function KolmoSurface({\n ref,\n src,\n bundle,\n size = 200,\n color,\n position = [0, 0, 0],\n ...rest\n}: KolmoSurfaceProps): React.JSX.Element {\n if (bundle)\n return <BundleSurface ref={ref} bundle={bundle} position={position} {...rest} />;\n if (src)\n return <UrlSurface ref={ref} src={src} position={position} {...rest} />;\n return <ArenaSlab size={size} position={position} color={color} />;\n}\n\nfunction BundleProp({\n ref,\n bundle,\n alreadyCloned = false,\n fixed = false,\n enableCustomGravity,\n onClick: userOnClick,\n ...rest\n}: Omit<KhrAssemblyProps, \"bundle\" | \"onClick\"> & {\n bundle: KhrAssetBundle;\n alreadyCloned?: boolean;\n fixed?: boolean;\n onClick?: (e: ThreeEvent<MouseEvent>) => void;\n}): React.JSX.Element {\n const ctxCustomGravity = useContext(KolmoGravityContext);\n const asmRef = useRef<KhrAssemblyHandle | null>(null);\n const cloned = useMemo(() => (alreadyCloned ? bundle : cloneKhrBundle(bundle)), [bundle, alreadyCloned]);\n\n const assignAsmRef = useCallback((h: KhrAssemblyHandle | null) => {\n asmRef.current = h;\n assignRef(ref, h);\n }, [ref]);\n\n const onClick = useCallback(\n (e: ThreeEvent<MouseEvent>) => {\n if (e.delta <= 5 && asmRef.current?.toggleHitObject(e.object)) {\n e.stopPropagation();\n }\n userOnClick?.(e);\n },\n [userOnClick],\n );\n\n return (\n <KhrAssembly\n ref={assignAsmRef}\n bundle={cloned}\n fixedRoot={fixed}\n enableCustomGravity={enableCustomGravity ?? ctxCustomGravity}\n onClick={onClick}\n {...rest}\n />\n );\n}\n\nfunction UrlProp({\n src,\n ...rest\n}: Omit<KhrAssemblyProps, \"bundle\" | \"onClick\"> & {\n src: string;\n fixed?: boolean;\n onClick?: (e: ThreeEvent<MouseEvent>) => void;\n}): React.JSX.Element {\n const bundle = useKhrGlb(src);\n return <BundleProp bundle={bundle} alreadyCloned {...rest} />;\n}\n\nexport interface KolmoPropProps extends Omit<KhrAssemblyProps, \"bundle\" | \"onClick\"> {\n readonly src?: string;\n readonly bundle?: KhrAssetBundle;\n readonly fixed?: boolean;\n readonly onClick?: (e: ThreeEvent<MouseEvent>) => void;\n}\n\nexport function KolmoProp({ src, bundle, ...rest }: KolmoPropProps): React.JSX.Element | null {\n if (bundle)\n return <BundleProp bundle={bundle} {...rest} />;\n if (src)\n return <UrlProp src={src} {...rest} />;\n return null;\n}\n","import React, {\n createContext,\n useContext,\n useEffect,\n useLayoutEffect,\n useReducer,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport * as THREE from \"three\";\nimport { Canvas, addEffect, useFrame, useThree } from \"@react-three/fiber\";\nimport { KeyboardControls, type KeyboardControlsEntry } from \"@react-three/drei\";\nimport { RoomEnvironment } from \"three/examples/jsm/environments/RoomEnvironment.js\";\nimport { type World } from \"koota\";\nimport { WorldProvider } from \"koota/react\";\nimport { Joystick, VirtualButton } from \"@pinkaphant/ecctrl/input\";\nimport {\n KolmoPhysics,\n type KolmoGravitySpec,\n type KolmoTimeControlValue,\n} from \"../physics/index.js\";\nimport { KOLMO_KEY_MAP, KolmoKeyboardBridge, KolmoKeyboardContext } from \"./input.js\";\nimport {\n ActorTrait,\n KolmoWorldContext,\n PilotLink,\n PilotedTag,\n VehicleTelemetryTrait,\n VehicleTrait,\n VelocityTrait,\n WorldSessionTrait,\n ensureWorldSession,\n kolmoActions,\n kolmoWorld,\n pilotedVehicleQuery,\n useActiveKolmoWorld,\n useOptionalKootaWorld,\n type KolmoControlMode,\n} from \"./traits.js\";\n\nexport const KolmoInCanvasContext = createContext<boolean>(false);\nexport const KolmoOverlayPortalContext = createContext<HTMLElement | null>(null);\n\nexport interface RoomEnvRigProps {\n readonly intensity?: number;\n}\n\nexport function RoomEnvRig({ intensity = 0.65 }: RoomEnvRigProps): null {\n const { gl, scene } = useThree();\n useEffect(() => {\n const pmrem = new THREE.PMREMGenerator(gl);\n const room = new RoomEnvironment();\n const rt = pmrem.fromScene(room, 0.04);\n const prevEnv = scene.environment;\n const prevInt = scene.environmentIntensity;\n scene.environment = rt.texture;\n scene.environmentIntensity = intensity;\n room.dispose();\n pmrem.dispose();\n return () => {\n scene.environment = prevEnv;\n scene.environmentIntensity = prevInt;\n rt.dispose();\n };\n }, [gl, scene, intensity]);\n return null;\n}\n\nexport interface KolmoCanvasProps {\n readonly children: ReactNode;\n readonly className?: string;\n readonly style?: CSSProperties;\n readonly fov?: number;\n readonly near?: number;\n readonly far?: number;\n readonly cameraPosition?: [number, number, number];\n readonly dpr?: number | [number, number];\n readonly frameloop?: \"always\" | \"demand\" | \"never\";\n readonly shadows?: boolean | \"basic\" | \"percentage\" | \"soft\" | \"variance\";\n readonly antialias?: boolean;\n readonly toneMapping?: THREE.ToneMapping;\n readonly roomEnv?: boolean | number;\n}\n\nexport function KolmoCanvas({\n children,\n className,\n style,\n fov = 56,\n near = 0.15,\n far = 4000,\n cameraPosition = [0, 3.2, -8.5],\n dpr = [1, 1.5],\n frameloop = \"always\",\n shadows = true,\n antialias = true,\n toneMapping,\n roomEnv = 0.65,\n}: KolmoCanvasProps): React.JSX.Element {\n return (\n <Canvas\n className={className}\n style={{ width: \"100%\", height: \"100%\", display: \"block\", touchAction: \"none\", userSelect: \"none\", ...style }}\n shadows={shadows}\n dpr={dpr}\n frameloop={frameloop}\n gl={{\n antialias,\n powerPreference: \"high-performance\",\n ...(toneMapping === undefined ? {} : { toneMapping }),\n }}\n camera={{ fov, near, far, position: cameraPosition }}\n onCreated={({ gl }) => {\n gl.outputColorSpace = THREE.SRGBColorSpace;\n }}\n >\n {roomEnv !== false && <RoomEnvRig intensity={typeof roomEnv === \"number\" ? roomEnv : 0.65} />}\n {children}\n </Canvas>\n );\n}\n\nexport interface KolmoWorldProps {\n readonly gravity?: KolmoGravitySpec;\n readonly paused?: boolean;\n readonly timeScale?: KolmoTimeControlValue;\n readonly maxDelta?: KolmoTimeControlValue;\n readonly physicsDebug?: boolean;\n readonly skybox?: \"day\" | \"night\" | \"none\";\n readonly lighting?: \"default\" | \"none\";\n readonly fogExp2?: [color: string, density: number] | null;\n readonly sunLightRef?: React.RefObject<THREE.DirectionalLight | null>;\n readonly world?: World | null;\n readonly keyboardMap?: KeyboardControlsEntry<string>[] | null;\n readonly children: ReactNode;\n}\n\nexport function KolmoWorld({\n gravity = \"planar\",\n paused = false,\n timeScale = 1,\n maxDelta,\n physicsDebug = false,\n skybox = \"day\",\n lighting = \"default\",\n fogExp2,\n sunLightRef,\n world = kolmoWorld,\n keyboardMap = KOLMO_KEY_MAP,\n children,\n}: KolmoWorldProps): React.JSX.Element {\n const outerWorld = useOptionalKootaWorld();\n const effectiveWorld = world ?? outerWorld ?? kolmoWorld;\n useLayoutEffect(() => {\n ensureWorldSession(effectiveWorld);\n }, [effectiveWorld]);\n\n const inner = (\n <KolmoInCanvasContext.Provider value={true}>\n {skybox === \"day\" && (\n <>\n <color attach=\"background\" args={[\"#6ba6d6\"]} />\n {!fogExp2 && <fog attach=\"fog\" args={[\"#9dc4e2\", 110, 520]} />}\n </>\n )}\n {skybox === \"night\" && <color attach=\"background\" args={[\"#090d16\"]} />}\n {fogExp2 && <fogExp2 attach=\"fog\" args={fogExp2} />}\n {lighting === \"default\" && (\n <>\n <hemisphereLight args={[\"#b8dcff\", \"#241d30\", 0.8]} />\n <directionalLight\n ref={sunLightRef}\n position={[48, 76, 36]}\n intensity={1.85}\n color=\"#fff3dc\"\n castShadow\n shadow-mapSize={[2048, 2048]}\n shadow-bias={-0.0004}\n shadow-camera-left={-55}\n shadow-camera-right={55}\n shadow-camera-top={55}\n shadow-camera-bottom={-55}\n shadow-camera-near={1}\n shadow-camera-far={220}\n />\n </>\n )}\n <KolmoPhysics\n gravity={gravity}\n paused={paused}\n timeScale={timeScale}\n maxDelta={maxDelta}\n physicsDebug={physicsDebug}\n world={effectiveWorld}\n >\n {children}\n </KolmoPhysics>\n </KolmoInCanvasContext.Provider>\n );\n\n const withKeyboard = keyboardMap ? (\n <KeyboardControls map={keyboardMap}>\n <KolmoKeyboardBridge>{inner}</KolmoKeyboardBridge>\n </KeyboardControls>\n ) : (\n <KolmoKeyboardContext.Provider value={null}>{inner}</KolmoKeyboardContext.Provider>\n );\n\n return effectiveWorld !== outerWorld ? (\n <KolmoWorldContext.Provider value={effectiveWorld}>\n <WorldProvider world={effectiveWorld}>{withKeyboard}</WorldProvider>\n </KolmoWorldContext.Provider>\n ) : (\n withKeyboard\n );\n}\n\nexport interface KolmoGameHookState {\n readonly world: World;\n readonly mode: KolmoControlMode;\n readonly activeVehicleId: string;\n readonly nearVehicleId: string | null;\n readonly boardVehicle: (id: string) => void;\n readonly exitVehicle: () => void;\n readonly resetVehicle: (id?: string) => void;\n}\n\nexport function useKolmoGame(explicitWorld?: World | null): KolmoGameHookState {\n const active = useActiveKolmoWorld();\n const targetWorld = explicitWorld ?? active;\n const [, bump] = useReducer((x: number) => x + 1, 0);\n\n useEffect(() => {\n ensureWorldSession(targetWorld);\n const onChange = () => bump();\n const u1 = targetWorld.onChange(WorldSessionTrait, onChange);\n const u2 = targetWorld.onAdd(PilotedTag, onChange);\n const u3 = targetWorld.onRemove(PilotedTag, onChange);\n const u4 = targetWorld.onAdd(PilotLink, onChange);\n const u5 = targetWorld.onRemove(PilotLink, onChange);\n const u6 = targetWorld.onChange(VehicleTrait, onChange);\n return () => {\n u1(); u2(); u3(); u4(); u5(); u6();\n };\n }, [targetWorld]);\n\n const session = targetWorld.has(WorldSessionTrait) ? targetWorld.get(WorldSessionTrait) : undefined;\n const pilotedEnt = targetWorld.queryFirst(ActorTrait)?.targetFor(PilotLink) ?? targetWorld.queryFirst(pilotedVehicleQuery);\n const pilotedData = pilotedEnt?.get(VehicleTrait);\n const actions = kolmoActions(targetWorld);\n\n return {\n world: targetWorld,\n mode: pilotedData ? (pilotedData.isFlight ? \"flight\" : \"car\") : \"foot\",\n activeVehicleId: pilotedData?.id ?? \"\",\n nearVehicleId: session?.nearVehicleId || null,\n boardVehicle: actions.boardVehicle,\n exitVehicle: actions.exitVehicle,\n resetVehicle: actions.resetVehicle,\n };\n}\n\nfunction detectTouchDevice(): boolean {\n if (typeof window === \"undefined\")\n return false;\n return navigator.maxTouchPoints > 0 || window.matchMedia?.(\"(pointer: coarse)\")?.matches === true;\n}\n\nfunction formatHudStrings(world: World): { line: string; prompt: string } {\n const actor = world.queryFirst(ActorTrait);\n const vehEnt = actor?.targetFor(PilotLink) ?? world.queryFirst(pilotedVehicleQuery);\n if (vehEnt) {\n const vd = vehEnt.get(VehicleTrait);\n const vel = vehEnt.get(VelocityTrait);\n const tel = vehEnt.get(VehicleTelemetryTrait);\n const kmh = Math.round(vel?.speedKmh ?? 0);\n const rpm = Math.round(tel?.rpm ?? 0);\n const gear = tel?.gear ?? 1;\n return {\n line: `${vd?.isFlight ? \"Flight\" : \"Car\"} · ${kmh} km/h · G${gear} · ${rpm} rpm`,\n prompt: vd?.isFlight\n ? \"[WASD] Fly · [Space/X] Rise/Dive · [Shift] Boost · [G] Mode · [V] Cam · [F] Exit\"\n : \"[WASD] Drive · [Shift] Boost · [Space] Brake · [V] Cam · [R] Flip · [F] Exit\",\n };\n }\n const vel = actor?.get(VelocityTrait);\n const near = world.has(WorldSessionTrait) ? world.get(WorldSessionTrait)?.nearVehicleId : \"\";\n return {\n line: `On foot · ${Math.round(vel?.speedKmh ?? 0)} km/h`,\n prompt: near\n ? \"[F] Board vehicle · [WASD] Walk · [Shift] Sprint · [Space] Jump\"\n : \"[WASD] Walk · [Shift] Sprint · [Space] Jump\",\n };\n}\n\nexport interface KolmoHudProps {\n readonly showTouchControls?: boolean;\n readonly extraPrompt?: string;\n readonly style?: CSSProperties;\n}\n\nfunction KolmoHudView({\n telemetryRef,\n promptRef,\n touchEnabled,\n style,\n}: {\n telemetryRef: React.RefObject<HTMLDivElement | null>;\n promptRef: React.RefObject<HTMLDivElement | null>;\n touchEnabled: boolean;\n style?: CSSProperties;\n}): React.JSX.Element {\n return (\n <div\n style={{\n position: \"fixed\", inset: 0, pointerEvents: \"none\", zIndex: 30,\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, monospace\", color: \"#e6edf3\", ...style,\n }}\n >\n <div\n ref={telemetryRef}\n style={{\n position: \"absolute\", top: \"max(10px, env(safe-area-inset-top))\", left: \"max(12px, env(safe-area-inset-left))\",\n padding: \"6px 10px\", background: \"rgba(9, 13, 22, 0.82)\", border: \"1px solid #38bdf8\",\n borderRadius: 4, fontSize: 12, fontWeight: 700,\n }}\n >\n On foot · 0 km/h\n </div>\n {!touchEnabled ? (\n <div\n ref={promptRef}\n style={{\n position: \"absolute\", bottom: \"max(12px, env(safe-area-inset-bottom))\", left: \"50%\", transform: \"translateX(-50%)\",\n padding: \"5px 10px\", background: \"rgba(9, 13, 22, 0.78)\", border: \"1px solid rgba(255,255,255,0.16)\",\n borderRadius: 4, fontSize: 11, whiteSpace: \"nowrap\",\n }}\n >\n [WASD] Walk · [Shift] Sprint · [Space] Jump\n </div>\n ) : (\n <div style={{ pointerEvents: \"auto\" }}>\n <Joystick />\n <VirtualButton id=\"jump\" label=\"JMP\" buttonWrapperStyle={{ position: \"fixed\", right: 20, bottom: 24 }} />\n <VirtualButton id=\"boost\" label=\"BST\" buttonWrapperStyle={{ position: \"fixed\", right: 88, bottom: 24 }} />\n <VirtualButton id=\"interact\" label=\"USE\" buttonWrapperStyle={{ position: \"fixed\", right: 20, bottom: 92 }} />\n </div>\n )}\n </div>\n );\n}\n\nfunction KolmoHudInCanvas({ showTouchControls, extraPrompt, style }: KolmoHudProps): React.JSX.Element | null {\n const portalTarget = useContext(KolmoOverlayPortalContext);\n const world = useActiveKolmoWorld();\n const telemetryRef = useRef<HTMLDivElement | null>(null);\n const promptRef = useRef<HTMLDivElement | null>(null);\n const elapsedRef = useRef(0);\n const [isTouch, setIsTouch] = useState(detectTouchDevice);\n useEffect(() => {\n setIsTouch(detectTouchDevice());\n }, []);\n const touchEnabled = showTouchControls ?? isTouch;\n\n useFrame((_, delta) => {\n elapsedRef.current += delta;\n if (elapsedRef.current < 0.05)\n return;\n elapsedRef.current = 0;\n const { line, prompt } = formatHudStrings(world);\n const fullPrompt = extraPrompt ? `${prompt} · ${extraPrompt}` : prompt;\n if (telemetryRef.current && telemetryRef.current.textContent !== line)\n telemetryRef.current.textContent = line;\n if (promptRef.current && promptRef.current.textContent !== fullPrompt)\n promptRef.current.textContent = fullPrompt;\n });\n\n const target = portalTarget ?? (typeof document !== \"undefined\" ? document.body : null);\n if (!target)\n return null;\n return createPortal(\n <KolmoHudView telemetryRef={telemetryRef} promptRef={promptRef} touchEnabled={touchEnabled} style={style} />,\n target,\n );\n}\n\nfunction KolmoHudOutsideCanvas({ showTouchControls, extraPrompt, style }: KolmoHudProps): React.JSX.Element {\n const world = useActiveKolmoWorld();\n const telemetryRef = useRef<HTMLDivElement | null>(null);\n const promptRef = useRef<HTMLDivElement | null>(null);\n const lastMsRef = useRef(-Infinity);\n const [isTouch, setIsTouch] = useState(detectTouchDevice);\n useEffect(() => {\n setIsTouch(detectTouchDevice());\n }, []);\n const touchEnabled = showTouchControls ?? isTouch;\n\n useEffect(() => {\n ensureWorldSession(world);\n const sync = (): void => {\n const { line, prompt } = formatHudStrings(world);\n const fullPrompt = extraPrompt ? `${prompt} · ${extraPrompt}` : prompt;\n if (telemetryRef.current && telemetryRef.current.textContent !== line)\n telemetryRef.current.textContent = line;\n if (promptRef.current && promptRef.current.textContent !== fullPrompt)\n promptRef.current.textContent = fullPrompt;\n };\n sync();\n const u1 = world.onChange(WorldSessionTrait, sync);\n const u2 = world.onAdd(PilotedTag, sync);\n const u3 = world.onRemove(PilotedTag, sync);\n const u4 = world.onAdd(PilotLink, sync);\n const u5 = world.onRemove(PilotLink, sync);\n const u6 = world.onChange(VehicleTrait, sync);\n const unsubFrame = addEffect((now) => {\n if (Math.abs(now - lastMsRef.current) < 50)\n return;\n lastMsRef.current = now;\n sync();\n });\n return () => {\n u1(); u2(); u3(); u4(); u5(); u6();\n unsubFrame();\n };\n }, [world, extraPrompt, touchEnabled]);\n\n return <KolmoHudView telemetryRef={telemetryRef} promptRef={promptRef} touchEnabled={touchEnabled} style={style} />;\n}\n\nexport function KolmoHud(props: KolmoHudProps): React.JSX.Element | null {\n const inCanvas = useContext(KolmoInCanvasContext);\n return inCanvas ? <KolmoHudInCanvas {...props} /> : <KolmoHudOutsideCanvas {...props} />;\n}\n\nexport interface KolmoGameProps {\n readonly gravity?: KolmoGravitySpec;\n readonly skybox?: \"day\" | \"night\" | \"none\";\n readonly lighting?: \"default\" | \"none\";\n readonly fogExp2?: [color: string, density: number] | null;\n readonly paused?: boolean;\n readonly timeScale?: KolmoTimeControlValue;\n readonly maxDelta?: KolmoTimeControlValue;\n readonly physicsDebug?: boolean;\n readonly dpr?: number | [number, number];\n readonly roomEnv?: boolean | number;\n readonly kootaWorld?: World;\n readonly style?: CSSProperties;\n readonly className?: string;\n readonly children?: ReactNode;\n}\n\nexport function KolmoGame({\n gravity = \"planar\",\n skybox = \"day\",\n lighting = \"default\",\n fogExp2,\n paused = false,\n timeScale = 1,\n maxDelta,\n physicsDebug = false,\n dpr,\n roomEnv = 0.65,\n kootaWorld = kolmoWorld,\n style,\n className,\n children,\n}: KolmoGameProps): React.JSX.Element {\n const outerWorld = useOptionalKootaWorld();\n const [overlayEl, setOverlayEl] = useState<HTMLDivElement | null>(null);\n\n const shell = (\n <KolmoOverlayPortalContext.Provider value={overlayEl}>\n <div\n className={className}\n style={{\n position: \"relative\", width: \"100vw\", height: \"100dvh\", overflow: \"hidden\",\n touchAction: \"none\", userSelect: \"none\", ...style,\n }}\n >\n <KolmoCanvas dpr={dpr} roomEnv={roomEnv}>\n <KolmoWorld\n gravity={gravity}\n paused={paused}\n timeScale={timeScale}\n maxDelta={maxDelta}\n skybox={skybox}\n lighting={lighting}\n fogExp2={fogExp2}\n physicsDebug={physicsDebug}\n world={kootaWorld}\n >\n {children}\n </KolmoWorld>\n </KolmoCanvas>\n <div ref={setOverlayEl} style={{ position: \"absolute\", inset: 0, pointerEvents: \"none\" }} />\n </div>\n </KolmoOverlayPortalContext.Provider>\n );\n\n return kootaWorld !== outerWorld ? (\n <KolmoWorldContext.Provider value={kootaWorld}>\n <WorldProvider world={kootaWorld}>{shell}</WorldProvider>\n </KolmoWorldContext.Provider>\n ) : (\n shell\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAIA,IAAa,uBAAuB,cAAsD,IAAI;AAE9F,SAAgB,oBAAoB,EAAE,YAAiE;CACnG,MAAM,GAAG,WAAW,oBAAoB;CACxC,OAAO,MAAM,cAAc,qBAAqB,UAAU,EAAE,OAAO,QAAQ,GAAG,QAAQ;AAC1F;AAwBA,IAAa,uBAAuB;AAEpC,IAAM,aAAwD,OAAO,OAAO;CACxE,SAAS;CACT,UAAU;CACV,MAAM;CACN,OAAO;CACP,OAAO;CACP,OAAO;CACP,UAAU;CACV,UAAU;CACV,WAAW;CACX,SAAS;CACT,YAAY;CACZ,OAAO;CACP,YAAY;AAChB,CAAC;AAED,IAAa,oBAA+C,OAAO,OAAO;CACtE,GAAG;CACH,QAAQ;CACR,QAAQ;AACZ,CAAC;AAED,IAAa,gBAAiD;CAC1D;EAAE,MAAM;EAAW,MAAM,CAAC,QAAQ,SAAS;CAAE;CAC7C;EAAE,MAAM;EAAY,MAAM,CAAC,QAAQ,WAAW;CAAE;CAChD;EAAE,MAAM;EAAQ,MAAM,CAAC,QAAQ,WAAW;CAAE;CAC5C;EAAE,MAAM;EAAS,MAAM,CAAC,QAAQ,YAAY;CAAE;CAC9C;EAAE,MAAM;EAAS,MAAM,CAAC,OAAO;CAAE;CACjC;EAAE,MAAM;EAAS,MAAM,CAAC,aAAa,YAAY;CAAE;CACnD;EAAE,MAAM;EAAY,MAAM,CAAC,MAAM;CAAE;CACnC;EAAE,MAAM;EAAY,MAAM,CAAC,MAAM;CAAE;CACnC;EAAE,MAAM;EAAa,MAAM,CAAC,MAAM;CAAE;CACpC;EAAE,MAAM;EAAW,MAAM,CAAC,QAAQ,aAAa;CAAE;CACjD;EAAE,MAAM;EAAc,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