@pinkaphant/kolmo 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -23
- package/dist/engine/actor.d.ts +1 -1
- package/dist/engine/gltfLoader.d.ts +6 -7
- package/dist/engine/index.js +181 -784
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/input.d.ts +2 -1
- package/dist/engine/surface.d.ts +1 -3
- package/dist/engine/traits.d.ts +7 -2
- package/dist/engine/world.d.ts +2 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +7 -5
- package/dist/physics/index.d.ts +3 -3
- package/dist/physics/index.js +1 -1
- package/dist/physics/nBodyGravity.d.ts +14 -7
- package/dist/{physics-FhWvTBfH.js → physics-ZDFXaCli.js} +122 -71
- package/dist/physics-ZDFXaCli.js.map +1 -0
- package/dist/surface-DUol_5ml.js +610 -0
- package/dist/surface-DUol_5ml.js.map +1 -0
- package/dist/toolgun/Toolgun.d.ts +33 -0
- package/dist/toolgun/index.d.ts +2 -0
- package/dist/toolgun/index.js +1 -0
- package/dist/toolgun/store.d.ts +198 -0
- package/dist/toolgun-BfcCIAQx.js +1582 -0
- package/dist/toolgun-BfcCIAQx.js.map +1 -0
- package/dist/vite/index.d.ts +0 -4
- package/dist/vite/index.js +1 -9
- package/dist/vite/index.js.map +1 -1
- package/package.json +12 -15
- package/dist/physics-FhWvTBfH.js.map +0 -1
package/dist/engine/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["assignRefValue","_jsxs","_Fragment","_jsx","assignRefValue","_jsx","_jsxs","_jsx","_jsxs","_jsx","_Fragment"],"sources":["../../src/engine/input.ts","../../src/engine/actor.tsx","../../src/engine/vehicle.tsx","../../src/engine/surface.tsx","../../src/engine/world.tsx","../../src/engine/gltfLoader.ts"],"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\nexport const EMPTY_KOLMO_INPUT: Readonly<KolmoInputState> = 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 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\", \"KeyE\"] },\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 * Zero-allocation input reader merging Drei `<KeyboardControls>`, `@pinkaphant/ecctrl/input`\n * Zustand stores (`useJoystickStore` + `useButtonStore`), and optional `getInput()` overrides.\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_KOLMO_INPUT as unknown as Record<string, boolean>);\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 sx = custom?.stickX ?? (mag > KOLMO_STICK_DEADZONE ? rx : 0);\n const sy = custom?.stickY ?? (mag > KOLMO_STICK_DEADZONE ? ry : 0);\n\n const out = outRef.current;\n out.stickX = sx;\n out.stickY = sy;\n out.forward = Boolean(custom?.forward ?? (k.forward || sy > 0.2));\n out.backward = Boolean(custom?.backward ?? (k.backward || sy < -0.2));\n out.left = Boolean(custom?.left ?? (k.left || sx < -0.2));\n out.right = Boolean(custom?.right ?? (k.right || sx > 0.2));\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, useLayoutEffect, useMemo, useRef, type ComponentProps } from \"react\";\nimport * as THREE from \"three\";\nimport { useFrame, useThree } from \"@react-three/fiber\";\nimport { useRapier } from \"@react-three/rapier\";\nimport { useQueryFirst } from \"koota/react\";\nimport { Ecctrl, type EcctrlHandle, type EcctrlProps, type MovementInput } from \"@pinkaphant/ecctrl\";\nimport { EcctrlCameraControls, type EcctrlCameraControlsHandle } from \"@pinkaphant/ecctrl/camera\";\nimport type { KhrAssetBundle } from \"@khr3/core\";\nimport { KolmoGravityContext } from \"../physics/index.js\";\nimport { useKolmoInput, type KolmoInputGetter } from \"./input.js\";\nimport {\n ActorTrait,\n InteractableTrait,\n PilotLink,\n PilotedTag,\n TransformTrait,\n VehicleTrait,\n VelocityTrait,\n WorldSessionTrait,\n ensureWorldSession,\n kolmoActions,\n pilotedVehicleQuery,\n useActiveKolmoWorld,\n writeEntityKinematics,\n} from \"./traits.js\";\n\nfunction assignRefValue<T>(ref: React.Ref<T> | undefined, value: T | null): void {\n if (typeof ref === \"function\") ref(value);\n else if (ref && typeof ref === \"object\") (ref as React.MutableRefObject<T | null>).current = value;\n}\n\nconst _seatVec = new THREE.Vector3();\nconst _camFwd = new THREE.Vector3();\n\nfunction findNearestInteractableVehicleId(world: ReturnType<typeof useActiveKolmoWorld>, actorPos: THREE.Vector3): string | null {\n let nearestId: string | null = null;\n let bestDistSq = Infinity;\n for (const ent of world.query(VehicleTrait, InteractableTrait)) {\n const v = ent.get(VehicleTrait);\n const it = ent.get(InteractableTrait);\n if (!v?.handle || !it) continue;\n _seatVec.set(v.seatOffset[0], v.seatOffset[1], v.seatOffset[2]).applyQuaternion(v.handle.currQuat).add(v.handle.currPos);\n const dSq = actorPos.distanceToSquared(_seatVec);\n if (dSq <= it.radius * it.radius && dSq < bestDistSq) {\n bestDistSq = dSq;\n nearestId = v.id;\n }\n }\n return nearestId;\n}\n\nexport interface KolmoActorProps extends Omit<EcctrlProps, \"ref\"> {\n readonly ref?: React.Ref<EcctrlHandle>;\n readonly cameraRef?: React.Ref<EcctrlCameraControlsHandle>;\n readonly cameraProps?: Omit<ComponentProps<typeof EcctrlCameraControls>, \"ref\"> | null | false;\n readonly getInput?: KolmoInputGetter;\n readonly bundle?: KhrAssetBundle | null;\n}\n\nexport function KolmoActor({\n ref,\n cameraRef,\n cameraProps,\n getInput,\n bundle,\n enable = true,\n enableCustomGravity,\n position = [0, 1.4, 0],\n rotation,\n userData,\n children,\n ...ecctrlRest\n}: KolmoActorProps): React.JSX.Element | null {\n const ctxCustomGravity = useContext(KolmoGravityContext);\n const activeWorld = useActiveKolmoWorld();\n useLayoutEffect(() => {\n ensureWorldSession(activeWorld);\n }, [activeWorld]);\n\n const pilotedVehEnt = useQueryFirst(VehicleTrait, PilotedTag);\n const readInput = useKolmoInput(getInput);\n const hasDom = useThree((s) => typeof s.gl?.domElement?.setAttribute === \"function\");\n const { world: rapierWorld } = useRapier();\n\n const actorEntRef = useRef<ReturnType<typeof activeWorld.spawn> | null>(null);\n const ecctrlRef = useRef<EcctrlHandle | null>(null);\n const camCtrlRef = useRef<EcctrlCameraControlsHandle | null>(null);\n const followPos = useRef(new THREE.Vector3());\n const followUp = useRef(new THREE.Vector3(0, 1, 0));\n const camSyncedRef = useRef(false);\n const prevInteractRef = useRef(false);\n const prevNearIdRef = useRef(\"\");\n const cooldownRef = useRef(0);\n const stickRef = useRef({ x: 0, y: 0 });\n const moveCmdRef = useRef<MovementInput>({\n forward: false,\n backward: false,\n leftward: false,\n rightward: false,\n joystick: stickRef.current,\n run: false,\n jump: false,\n });\n const exitOverrideRef = useRef<{ pos: [number, number, number] | null; yaw: number }>({ pos: null, yaw: 0 });\n\n useLayoutEffect(() => {\n const ent = activeWorld.spawn(\n ActorTrait({ id: \"pilot\", handle: ecctrlRef.current, exitSpawnPos: null, exitSpawnYaw: 0, exitLinVel: null }),\n TransformTrait,\n VelocityTrait,\n );\n actorEntRef.current = ent;\n const prePiloted = activeWorld.queryFirst(pilotedVehicleQuery);\n if (prePiloted) ent.add(PilotLink(prePiloted));\n const unsub = activeWorld.onChange(ActorTrait, (changed) => {\n if (changed !== ent) return;\n const d = ent.get(ActorTrait);\n if (d) exitOverrideRef.current = { pos: d.exitSpawnPos, yaw: d.exitSpawnYaw };\n });\n return () => {\n unsub();\n actorEntRef.current = null;\n ent.destroy();\n };\n }, [activeWorld]);\n\n useLayoutEffect(() => {\n const ent = actorEntRef.current;\n if (ent && pilotedVehEnt && !ent.has(PilotLink(pilotedVehEnt))) ent.add(PilotLink(pilotedVehEnt));\n }, [pilotedVehEnt]);\n\n const assignEcctrlRef = useCallback((handle: EcctrlHandle | null) => {\n ecctrlRef.current = handle;\n assignRefValue(ref, handle);\n const ent = actorEntRef.current;\n if (!ent?.isAlive()) return;\n const cur = ent.get(ActorTrait);\n if (handle?.body && cur?.exitLinVel) {\n handle.body.setLinvel({ x: cur.exitLinVel[0], y: cur.exitLinVel[1], z: cur.exitLinVel[2] }, true);\n }\n if (handle?.body) exitOverrideRef.current.pos = null;\n ent.set(ActorTrait, {\n id: cur?.id ?? \"pilot\",\n handle,\n exitSpawnPos: handle?.body ? null : cur?.exitSpawnPos ?? null,\n exitSpawnYaw: cur?.exitSpawnYaw ?? 0,\n exitLinVel: handle?.body ? null : cur?.exitLinVel ?? null,\n });\n }, [ref]);\n\n const assignCamRef = useCallback((ctrl: EcctrlCameraControlsHandle | null) => {\n camCtrlRef.current = ctrl;\n assignRefValue(cameraRef, ctrl);\n }, [cameraRef]);\n\n const mergedUserData = useMemo(() => {\n const base = (userData ?? {}) as Record<string, unknown>;\n const ecctrlMeta = (base.ecctrl ?? {}) as Record<string, unknown>;\n return { ...base, ecctrl: { excludeVehicleRay: true, ...ecctrlMeta } };\n }, [userData]);\n\n const clonedScene = useMemo(() => (bundle ? bundle.scene.clone(true) : null), [bundle]);\n const onFoot = enable && !pilotedVehEnt;\n if (!onFoot) camSyncedRef.current = false;\n\n useFrame((state, delta) => {\n if (!enable) return;\n const dt = rapierWorld.timestep > 0 ? rapierWorld.timestep : Math.min(Math.max(delta, 1e-4), 1 / 30);\n if (cooldownRef.current > 0) cooldownRef.current = Math.max(0, cooldownRef.current - dt);\n\n const inp = readInput();\n const interactEdge = inp.interact && !prevInteractRef.current;\n prevInteractRef.current = inp.interact;\n\n if (activeWorld.queryFirst(pilotedVehicleQuery)) {\n if (interactEdge && cooldownRef.current === 0) {\n cooldownRef.current = 0.25;\n kolmoActions(activeWorld).exitVehicle();\n }\n return;\n }\n\n const handle = ecctrlRef.current;\n if (!handle?.body) return;\n\n stickRef.current.x = inp.stickX;\n stickRef.current.y = inp.stickY;\n const cmd = moveCmdRef.current;\n cmd.forward = inp.forward;\n cmd.backward = inp.backward;\n cmd.leftward = inp.left;\n cmd.rightward = inp.right;\n cmd.joystick = stickRef.current;\n cmd.run = inp.boost;\n cmd.jump = inp.brake;\n handle.setMovement(cmd);\n\n if (actorEntRef.current?.isAlive()) {\n writeEntityKinematics(activeWorld, actorEntRef.current, handle.currPos, handle.currQuat, handle.currLinVel, handle.moveSpeed * 3.6);\n }\n\n const nearId = findNearestInteractableVehicleId(activeWorld, handle.currPos) ?? \"\";\n if (nearId !== prevNearIdRef.current) {\n prevNearIdRef.current = nearId;\n activeWorld.set(WorldSessionTrait, { nearVehicleId: nearId });\n }\n\n if (interactEdge && nearId && cooldownRef.current === 0) {\n cooldownRef.current = 0.25;\n kolmoActions(activeWorld).boardVehicle(nearId);\n return;\n }\n\n const cam = camCtrlRef.current;\n if (cam && handle.currPos.lengthSq() > 0) {\n const hasValidUp = handle.upAxis.lengthSq() > 0.25;\n if (hasValidUp) followUp.current.copy(handle.upAxis).normalize();\n followPos.current.copy(handle.currPos).addScaledVector(followUp.current, 0.55);\n\n if (!camSyncedRef.current) {\n camSyncedRef.current = true;\n if (hasValidUp) {\n state.camera.up.copy(followUp.current);\n cam.setUp(followUp.current);\n }\n _camFwd.copy(handle.bodyZAxis).projectOnPlane(followUp.current);\n if (_camFwd.lengthSq() < 1e-4) _camFwd.set(0, 0, -1).projectOnPlane(followUp.current);\n _camFwd.normalize();\n cam.setLookAt(\n followPos.current.x - _camFwd.x * 7.5 + followUp.current.x * 2.4,\n followPos.current.y - _camFwd.y * 7.5 + followUp.current.y * 2.4,\n followPos.current.z - _camFwd.z * 7.5 + followUp.current.z * 2.4,\n followPos.current.x,\n followPos.current.y,\n followPos.current.z,\n false,\n );\n } else {\n cam.moveTo(followPos.current.x, followPos.current.y, followPos.current.z, true);\n if (hasValidUp) {\n state.camera.up.lerp(followUp.current, 1 - Math.exp(-8 * dt)).normalize();\n cam.setUp(state.camera.up);\n }\n }\n }\n });\n\n if (!onFoot) return null;\n\n const spawnPos = exitOverrideRef.current.pos ?? position;\n const spawnRot = rotation ?? (exitOverrideRef.current.pos ? ([0, exitOverrideRef.current.yaw, 0] as [number, number, number]) : undefined);\n\n return (\n <>\n {hasDom && cameraProps !== false && cameraProps !== null && (\n <EcctrlCameraControls\n ref={assignCamRef}\n makeDefault\n minPolarAngle={0.12}\n maxPolarAngle={Math.PI - 0.12}\n smoothTime={0.08}\n {...(cameraProps ?? {})}\n />\n )}\n <Ecctrl\n ref={assignEcctrlRef}\n enable={enable}\n enableCustomGravity={enableCustomGravity ?? ctxCustomGravity}\n position={spawnPos}\n {...(spawnRot === undefined ? {} : { rotation: spawnRot })}\n userData={mergedUserData}\n {...ecctrlRest}\n >\n {children ?? (clonedScene ? <primitive object={clonedScene} /> : null)}\n </Ecctrl>\n </>\n );\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 { 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 ensureWorldSession,\n flipVehicleBodyUpright,\n kolmoActions,\n pilotedVehicleQuery,\n useActiveKolmoWorld,\n writeEntityKinematics,\n writeVehicleTelemetry,\n} from \"./traits.js\";\n\nfunction assignRefValue<T>(ref: React.Ref<T> | undefined, value: T | null): void {\n if (typeof ref === \"function\") ref(value);\n else if (ref && typeof ref === \"object\") (ref as React.MutableRefObject<T | null>).current = value;\n}\n\nfunction createEmptyVehicleCmd(): VehicleInput {\n return {\n forward: false,\n backward: false,\n steerLeft: false,\n steerRight: false,\n brake: false,\n throttleUp: false,\n throttleDown: false,\n yawLeft: false,\n yawRight: false,\n pitchForward: false,\n pitchBackward: false,\n rollLeft: false,\n rollRight: false,\n joystickL: { x: 0, y: 0 },\n joystickR: { x: 0, y: 0 },\n };\n}\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\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 piloted = false,\n flightMode = false,\n vehicleMode,\n interactRadius = 4.2,\n enable = true,\n enableCustomGravity,\n wheelConfig,\n propellerConfig,\n droneConfig,\n getInput,\n driver,\n cameraController,\n children,\n ...khrRest\n}: Omit<KolmoVehicleProps, \"src\" | \"bundle\" | \"id\"> & { id: string; sourceBundle: KhrAssetBundle }): 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(() => cloneKhrBundle(sourceBundle), [sourceBundle]);\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\n const seatOffset = useMemo<[number, number, number]>(() => {\n const dot = bundle.sockets.butt ?? bundle.sockets.driver_butt ?? bundle.sockets.seat ?? bundle.sockets.IK_Seat;\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.exit ?? bundle.sockets.Socket_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 cmdRef = useRef(createEmptyVehicleCmd());\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, 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)) kolmoActions(activeWorld).exitVehicle();\n vehEntRef.current = null;\n ent.destroy();\n };\n }, [activeWorld, id, seatOffset, exitOffset, interactRadius, piloted]);\n\n useLayoutEffect(() => {\n const ent = vehEntRef.current;\n if (!ent?.isAlive()) return;\n const v = ent.get(VehicleTrait);\n if (v && v.isFlight !== isFlight) ent.set(VehicleTrait, { ...v, isFlight });\n }, [isFlight]);\n\n const assignVehicleRef = useCallback((handle: EcctrlVehicleHandle | null) => {\n innerRef.current = handle;\n assignRefValue(vehicleRef, handle);\n assignRefValue(ref, handle);\n const ent = vehEntRef.current;\n if (ent?.isAlive()) {\n const v = ent.get(VehicleTrait);\n if (v) ent.set(VehicleTrait, { ...v, handle });\n }\n }, [ref, vehicleRef]);\n\n const assignJointsRef = useCallback((jh: KhrVehicleJointsHandle | null) => {\n jointsRef.current = jh;\n assignRefValue(outerJointsRef, jh);\n }, [outerJointsRef]);\n\n const { world: rapierWorld } = useRapier();\n const hasPilotedTag = useHas(vehEnt, PilotedTag);\n const isPiloted = hasPilotedTag || (piloted && vehEnt === null);\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) return;\n\n if (driver) {\n driver(veh, dt, state);\n cameraController?.(veh, dt, state);\n return;\n }\n\n const keys = readInput();\n const st = stRef.current;\n const cmd = cmdRef.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) st.cockpit = !st.cockpit;\n st.prevCam = keys.cameraView;\n if (keys.reset && !st.prevReset) {\n flipVehicleBodyUpright(veh);\n jointsRef.current?.syncBodiesToParent();\n }\n st.prevReset = keys.reset;\n if (keys.modeToggle && !st.prevMode && canHybridToggle) 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 cmd.joystickL = { x: 0, y: 0 };\n cmd.joystickR = { x: keys.stickX, y: keys.stickY };\n veh.setMovement(cmd);\n } else {\n const fwdVel = veh.currLinVel.dot(veh.bodyZAxis);\n const revBraking = keys.backward && !keys.forward && fwdVel > 1.0;\n const fwdBraking = keys.forward && !keys.backward && fwdVel < -1.0;\n if (((keys.backward && !revBraking) || (keys.forward && 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 = keys.forward && !fwdBraking;\n cmd.backward = keys.backward && !revBraking;\n cmd.steerLeft = keys.left;\n cmd.steerRight = keys.right;\n cmd.brake = keys.brake || revBraking || fwdBraking;\n cmd.pitchForward = boostProp && keys.forward;\n cmd.pitchBackward = false;\n cmd.throttleUp = boostProp && !keys.forward && keys.brake;\n cmd.throttleDown = false;\n cmd.yawLeft = boostProp && keys.left;\n cmd.yawRight = boostProp && keys.right;\n cmd.rollLeft = cmd.rollRight = false;\n cmd.joystickL = { x: keys.stickX, y: 0 };\n cmd.joystickR = { x: 0, y: 0 };\n veh.setMovement(cmd);\n }\n } else {\n st.prevCam = st.prevReset = st.prevMode = false;\n if (st.wasPiloted || hasActiveCmd(cmd)) {\n st.wasPiloted = false;\n Object.assign(cmd, createEmptyVehicleCmd());\n veh.setMovement(cmd);\n }\n }\n\n let maxSlip = 0;\n for (const w of veh.wheelsInfo.values()) {\n if (w.current.rayHit && w.current.slipStrength > maxSlip) maxSlip = w.current.slipStrength;\n }\n const speedKmh = veh.currLinVel.length() * 3.6;\n const throttle = isPiloted ? +(keys.forward || (isFlight && keys.brake)) : 0;\n const boost = isPiloted && keys.boost && throttle > 0 ? 1 : 0;\n const rpm = Math.round(veh.engineRPM);\n const gear = veh.gearIndex + 1;\n\n if (vehEntRef.current?.isAlive()) {\n writeEntityKinematics(activeWorld, vehEntRef.current, veh.currPos, veh.currQuat, veh.currLinVel, speedKmh);\n writeVehicleTelemetry(activeWorld, vehEntRef.current, rpm, gear, throttle, boost, Math.min(1, maxSlip));\n }\n\n if (!isPiloted) return;\n if (cameraController) {\n cameraController(veh, dt, state);\n return;\n }\n\n _up.copy(veh.upAxis);\n if (_up.lengthSq() < 1e-6) _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) _fwd.projectOnPlane(_up).normalize();\n if (_fwd.lengthSq() < 1e-6) _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 <group onClick={(e) => { if (e.delta <= 5 && jointsRef.current?.toggleHitObject(e.object)) e.stopPropagation(); }}>\n <KhrVehicle\n ref={assignVehicleRef}\n jointsRef={assignJointsRef}\n bundle={bundle}\n enable={enable}\n enableCustomGravity={enableCustomGravity ?? ctxCustomGravity}\n {...(mergedWheelConfig === undefined ? {} : { wheelConfig: mergedWheelConfig })}\n {...(mergedPropellerConfig === undefined ? {} : { propellerConfig: mergedPropellerConfig })}\n {...(droneConfig === undefined ? {} : { droneConfig })}\n {...khrRest}\n >\n {children}\n </KhrVehicle>\n </group>\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} />;\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) return <KolmoVehicleMount {...rest} id={id} sourceBundle={bundle} />;\n if (src) return <KolmoVehicleFromUrl {...rest} id={id} src={src} />;\n return null;\n}\n","import React, { useCallback, 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 cloneKhrBundle,\n useKhrGlb,\n type KhrAssemblyHandle,\n type KhrAssemblyProps,\n type KhrAssetBundle,\n} from \"@khr3/core\";\n\nfunction assignRefValue<T>(ref: React.Ref<T> | undefined, value: T | null): void {\n if (typeof ref === \"function\") ref(value);\n else if (ref && typeof ref === \"object\") (ref as React.MutableRefObject<T | null>).current = value;\n}\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 position,\n ...rest\n}: Omit<KhrAssemblyProps, \"bundle\"> & { bundle: KhrAssetBundle }): React.JSX.Element {\n const cloned = useMemo(() => cloneKhrBundle(bundle), [bundle]);\n return <KhrAssembly ref={ref} bundle={cloned} position={position} fixedRoot {...rest} />;\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} {...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) return <BundleSurface ref={ref} bundle={bundle} position={position} {...rest} />;\n if (src) return <UrlSurface ref={ref} src={src} position={position} {...rest} />;\n return <ArenaSlab size={size} position={position} color={color} />;\n}\n\nfunction resolveJointTargets(limits: [number, number] | null): { open: number; closed: number } {\n if (!limits) return { open: Math.PI / 2, closed: 0 };\n const [lo, hi] = limits;\n return {\n open: Math.abs(hi) >= Math.abs(lo) ? hi : lo,\n closed: Math.min(hi, Math.max(lo, 0)),\n };\n}\n\nexport function togglePropJoint(\n handle: KhrAssemblyHandle | null,\n bundle: KhrAssetBundle,\n openState: boolean,\n clickedObj?: THREE.Object3D | null,\n perBodyOpen?: Map<string, boolean>,\n): boolean {\n if (!handle) return openState;\n if (clickedObj && perBodyOpen) {\n let cur: THREE.Object3D | null = clickedObj;\n while (cur) {\n const hit = bundle.bodies.find((b) => b.object === cur && b.joint?.drive?.stiffness !== undefined);\n if (hit) {\n const nextOpen = !(perBodyOpen.get(hit.nodeName) ?? false);\n perBodyOpen.set(hit.nodeName, nextOpen);\n const { open, closed } = resolveJointTargets(hit.joint?.limits ?? null);\n handle.setJointTarget(hit.nodeName, nextOpen ? open : closed);\n return nextOpen;\n }\n cur = cur.parent;\n }\n }\n const nextAll = !openState;\n for (const b of bundle.bodies) {\n if (!b.joint?.drive || b.joint.drive.stiffness === undefined) continue;\n const { open, closed } = resolveJointTargets(b.joint.limits);\n perBodyOpen?.set(b.nodeName, nextAll);\n handle.setJointTarget(b.nodeName, nextAll ? open : closed);\n }\n return nextAll;\n}\n\nfunction BundleProp({\n ref,\n bundle,\n fixed = false,\n onClick: userOnClick,\n ...rest\n}: Omit<KhrAssemblyProps, \"bundle\" | \"onClick\"> & {\n bundle: KhrAssetBundle;\n fixed?: boolean;\n onClick?: (e: ThreeEvent<MouseEvent>) => void;\n}): React.JSX.Element {\n const asmRef = useRef<KhrAssemblyHandle | null>(null);\n const openRef = useRef(false);\n const perBodyRef = useRef(new Map<string, boolean>());\n const cloned = useMemo(() => cloneKhrBundle(bundle), [bundle]);\n\n const assignAsmRef = useCallback((h: KhrAssemblyHandle | null) => {\n asmRef.current = h;\n assignRefValue(ref, h);\n }, [ref]);\n\n const onClick = useCallback(\n (e: ThreeEvent<MouseEvent>) => {\n e.stopPropagation();\n openRef.current = togglePropJoint(asmRef.current, cloned, openRef.current, e.object, perBodyRef.current);\n userOnClick?.(e);\n },\n [cloned, userOnClick],\n );\n\n return <KhrAssembly ref={assignAsmRef} bundle={cloned} fixedRoot={fixed} onClick={onClick} {...rest} />;\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} {...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) return <BundleProp bundle={bundle} {...rest} />;\n if (src) return <UrlProp src={src} {...rest} />;\n return null;\n}\n","import React, {\n createContext,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n useSyncExternalStore,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport * as THREE from \"three\";\nimport { Canvas, 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 useOptionalKootaWorld,\n type KolmoGravitySpec,\n type KolmoTimeControlValue,\n} from \"../physics/index.js\";\nimport { KOLMO_KEY_MAP, KolmoKeyboardBridge, KolmoKeyboardContext } from \"./input.js\";\nimport {\n ActorTrait,\n PilotLink,\n PilotedTag,\n VehicleTelemetryTrait,\n VehicleTrait,\n VelocityTrait,\n WorldSessionTrait,\n ensureWorldSession,\n kolmoActions,\n kolmoWorld,\n pilotedVehicleQuery,\n useActiveKolmoWorld,\n type KolmoControlMode,\n} from \"./traits.js\";\n\nexport const KolmoInCanvasContext = createContext<boolean>(false);\nexport type KolmoOverlayRegister = (id: string, node: ReactNode | null) => void;\nexport const KolmoOverlayContext = createContext<KolmoOverlayRegister | 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={[1024, 1024]}\n />\n </>\n )}\n <KolmoPhysics\n gravity={gravity}\n paused={paused}\n timeScale={timeScale}\n maxDelta={maxDelta}\n physicsDebug={physicsDebug}\n world={null}\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 ? <WorldProvider world={effectiveWorld}>{withKeyboard}</WorldProvider> : withKeyboard;\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\") return false;\n return navigator.maxTouchPoints > 0 || window.matchMedia?.(\"(pointer: coarse)\")?.matches === true;\n}\n\nexport interface KolmoHudProps {\n readonly showTouchControls?: boolean;\n readonly style?: CSSProperties;\n}\n\nfunction KolmoHudDom({ showTouchControls, 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 [isTouch, setIsTouch] = useState(detectTouchDevice);\n useEffect(() => {\n setIsTouch(detectTouchDevice());\n }, []);\n const touchEnabled = showTouchControls ?? isTouch;\n\n useEffect(() => {\n let raf = 0;\n let lastLine = \"\";\n let lastPrompt = \"\";\n const tick = (): void => {\n const actor = world.queryFirst(ActorTrait);\n const vehEnt = actor?.targetFor(PilotLink) ?? world.queryFirst(pilotedVehicleQuery);\n let line: string;\n let prompt: string;\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 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 } else {\n const vel = actor?.get(VelocityTrait);\n const near = world.has(WorldSessionTrait) ? world.get(WorldSessionTrait)?.nearVehicleId : \"\";\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 if (line !== lastLine && telemetryRef.current) {\n telemetryRef.current.textContent = line;\n lastLine = line;\n }\n if (prompt !== lastPrompt && promptRef.current) {\n promptRef.current.textContent = prompt;\n lastPrompt = prompt;\n }\n raf = requestAnimationFrame(tick);\n };\n raf = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(raf);\n }, [world]);\n\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\nexport function KolmoHud(props: KolmoHudProps): React.JSX.Element | null {\n const inCanvas = useContext(KolmoInCanvasContext);\n const registerOverlay = useContext(KolmoOverlayContext);\n const outerWorld = useOptionalKootaWorld();\n const id = useId();\n\n useLayoutEffect(() => {\n if (!inCanvas || !registerOverlay) return;\n const node = outerWorld ? (\n <WorldProvider world={outerWorld}><KolmoHudDom {...props} /></WorldProvider>\n ) : (\n <KolmoHudDom {...props} />\n );\n registerOverlay(id, node);\n return () => registerOverlay(id, null);\n }, [inCanvas, registerOverlay, outerWorld, id, props.showTouchControls, props.style]);\n\n return inCanvas ? null : <KolmoHudDom {...props} />;\n}\n\nfunction createOverlayStore() {\n const map = new Map<string, ReactNode>();\n const listeners = new Set<() => void>();\n let snap: ReadonlyArray<[string, ReactNode]> = [];\n return {\n set(id: string, node: ReactNode | null) {\n if (node === null) {\n if (!map.delete(id)) return;\n } else {\n map.set(id, node);\n }\n snap = [...map.entries()];\n for (const l of listeners) l();\n },\n subscribe(listener: () => void) {\n listeners.add(listener);\n return () => { listeners.delete(listener); };\n },\n getSnapshot: () => snap,\n };\n}\n\nfunction KolmoOverlayHost({ store }: { store: ReturnType<typeof createOverlayStore> }): React.JSX.Element | null {\n const entries = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n if (entries.length === 0) return null;\n return <>{entries.map(([id, node]) => <React.Fragment key={id}>{node}</React.Fragment>)}</>;\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 store = useMemo(createOverlayStore, []);\n\n const shell = (\n <KolmoOverlayContext.Provider value={store.set}>\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 <KolmoOverlayHost store={store} />\n </div>\n </KolmoOverlayContext.Provider>\n );\n\n return kootaWorld !== outerWorld ? <WorldProvider world={kootaWorld}>{shell}</WorldProvider> : shell;\n}\n","import * as THREE from \"three\";\nimport { GLTFLoader } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { KTX2Loader } from \"three/examples/jsm/loaders/KTX2Loader.js\";\nimport { MeshoptDecoder } from \"three/examples/jsm/libs/meshopt_decoder.module.js\";\nimport { createKhrGltfPlugin, type KhrPluginOptions } from \"@khr3/core\";\n\nexport interface KolmoGltfLoaderOptions {\n /** Optional WebGLRenderer so KTX2 (`KHR_texture_basisu`) detects hardware ASTC/BC7/ETC2 support. */\n readonly renderer?: THREE.WebGLRenderer | null;\n /** Optional path hosting Basis Universal transcoder `.js`/`.wasm` files (defaults to `\"/basis/\"`). */\n readonly basisTranscoderPath?: string;\n /** Optional `@khr3/core` plugin options. */\n readonly khrOptions?: KhrPluginOptions;\n}\n\nlet sharedKtx2Loader: KTX2Loader | null = null;\nlet sharedKtx2Path = \"\";\n\nfunction getOrCreateKtx2Loader(renderer: THREE.WebGLRenderer, transcoderPath: string): KTX2Loader {\n if (!sharedKtx2Loader || sharedKtx2Path !== transcoderPath) {\n sharedKtx2Loader?.dispose();\n sharedKtx2Loader = new KTX2Loader();\n sharedKtx2Loader.setTranscoderPath(transcoderPath);\n sharedKtx2Path = transcoderPath;\n }\n sharedKtx2Loader.detectSupport(renderer);\n return sharedKtx2Loader;\n}\n\n/**\n * Khronos-compliant `GLTFLoader` configured with `EXT_meshopt_compression` (`MeshoptDecoder`),\n * `KHR_texture_basisu` (`KTX2Loader` when a renderer is supplied), and `@khr3/core` physics plugin.\n * Never mounts legacy `DRACOLoader`.\n */\nexport function createKolmoGltfLoader(options?: KolmoGltfLoaderOptions): GLTFLoader {\n const loader = new GLTFLoader();\n loader.setMeshoptDecoder(MeshoptDecoder);\n loader.register(createKhrGltfPlugin(options?.khrOptions));\n if (options?.renderer) {\n loader.setKTX2Loader(getOrCreateKtx2Loader(options.renderer, options.basisTranscoderPath ?? \"/basis/\"));\n }\n return loader;\n}\n\nexport async function parseKolmoGlbBuffer(\n buffer: ArrayBuffer,\n options?: KolmoGltfLoaderOptions,\n): Promise<THREE.Group> {\n if (buffer.byteLength < 12) {\n throw new Error(\"Invalid binary .glb buffer: truncated header (< 12 bytes).\");\n }\n const view = new DataView(buffer);\n if (view.getUint32(0, true) !== 0x46546c67 || view.getUint32(4, true) !== 2) {\n throw new Error(\"Invalid binary .glb magic or glTF version (expected glTF 2.0).\");\n }\n if (typeof (MeshoptDecoder as { ready?: Promise<void> }).ready?.then === \"function\") {\n await (MeshoptDecoder as { ready: Promise<void> }).ready;\n }\n const loader = createKolmoGltfLoader(options);\n const gltf = await loader.parseAsync(buffer, \"\");\n return gltf.scene;\n}\n\nexport async function loadKolmoGlbUrl(\n url: string,\n options?: KolmoGltfLoaderOptions,\n): Promise<THREE.Group> {\n const res = await fetch(url);\n if (!res.ok) throw new Error(`Failed to fetch GLB (${res.status}): ${url}`);\n return parseKolmoGlbBuffer(await res.arrayBuffer(), options);\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,IAAa,oBAA+C,OAAO,OAAO;CACtE,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;CACZ,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,QAAQ,MAAM;CAAE;CAC3C;EAAE,MAAM;EAAY,MAAM,CAAC,MAAM;CAAE;CACnC;EAAE,MAAM;EAAa,MAAM,CAAC,MAAM;CAAE;CACpC;EAA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W;EAClC,iBAAiB,kBAAkB,cAAc;EACjD,iBAAiB;CACrB;CACA,iBAAiB,cAAc,QAAQ;CACvC,OAAO;AACX;;;;;;AAOA,SAAgB,sBAAsB,SAA8C;CAChF,MAAM,SAAS,IAAI,WAAW;CAC9B,OAAO,kBAAkB,cAAc;CACvC,OAAO,SAAS,oBAAoB,SAAS,UAAU,CAAC;CACxD,IAAI,SAAS,UACT,OAAO,cAAc,sBAAsB,QAAQ,UAAU,QAAQ,uBAAuB,SAAS,CAAC;CAE1G,OAAO;AACX;AAEA,eAAsB,oBAClB,QACA,SACoB;CACpB,IAAI,OAAO,aAAa,IACpB,MAAM,IAAI,MAAM,4DAA4D;CAEhF,MAAM,OAAO,IAAI,SAAS,MAAM;CAChC,IAAI,KAAK,UAAU,GAAG,IAAI,MAAM,cAAc,KAAK,UAAU,GAAG,IAAI,MAAM,GACtE,MAAM,IAAI,MAAM,gEAAgE;CAEpF,IAAI,OAAQ,eAA6C,OAAO,SAAS,YACrE,MAAO,eAA4C;CAIvD,QAAO,MAFQ,sBAAsB,OAClB,CAAA,CAAO,WAAW,QAAQ,EAAE,EAAA,CACnC;AAChB;AAEA,eAAsB,gBAClB,KACA,SACoB;CACpB,MAAM,MAAM,MAAM,MAAM,GAAG;CAC3B,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,wBAAwB,IAAI,OAAO,KAAK,KAAK;CAC1E,OAAO,oBAAoB,MAAM,IAAI,YAAY,GAAG,OAAO;AAC/D"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["cloneSkinned","_jsxs","_Fragment","_jsx","_jsxs","_jsx","_Fragment","createPortal"],"sources":["../../src/engine/actor.tsx","../../src/engine/world.tsx","../../src/engine/gltfLoader.ts"],"sourcesContent":["import React, { useCallback, useContext, useLayoutEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport * as THREE from \"three\";\nimport { clone as cloneSkinned } from \"three/examples/jsm/utils/SkeletonUtils.js\";\nimport { useFrame, useThree } from \"@react-three/fiber\";\nimport { useRapier } from \"@react-three/rapier\";\nimport { useQueryFirst } from \"koota/react\";\nimport { Ecctrl, type EcctrlHandle, type EcctrlProps, type MovementInput } from \"@pinkaphant/ecctrl\";\nimport { EcctrlCameraControls, type EcctrlCameraControlsHandle } from \"@pinkaphant/ecctrl/camera\";\nimport { assignRef, type KhrAssetBundle } from \"@khr3/core\";\nimport { KolmoGravityContext } from \"../physics/index.js\";\nimport { useKolmoInput, type KolmoInputGetter } from \"./input.js\";\nimport {\n ActorTrait,\n InteractableTrait,\n PilotLink,\n PilotedTag,\n TransformTrait,\n VehicleTrait,\n VelocityTrait,\n WorldSessionTrait,\n ensureWorldSession,\n kolmoActions,\n pilotedVehicleQuery,\n useActiveKolmoWorld,\n writeEntityKinematics,\n} from \"./traits.js\";\n\nconst _seatVec = new THREE.Vector3();\nconst _camFwd = new THREE.Vector3();\nconst _worldUp = new THREE.Vector3(0, 1, 0);\n\nfunction findNearestInteractableVehicleId(world: ReturnType<typeof useActiveKolmoWorld>, actorPos: THREE.Vector3): string | null {\n let nearestId: string | null = null;\n let bestDistSq = Infinity;\n for (const ent of world.query(VehicleTrait, InteractableTrait)) {\n const v = ent.get(VehicleTrait);\n const it = ent.get(InteractableTrait);\n if (!v?.handle || !it)\n continue;\n _seatVec.set(v.seatOffset[0], v.seatOffset[1], v.seatOffset[2]).applyQuaternion(v.handle.currQuat).add(v.handle.currPos);\n const dSq = actorPos.distanceToSquared(_seatVec);\n if (dSq <= it.radius * it.radius && dSq < bestDistSq) {\n bestDistSq = dSq;\n nearestId = v.id;\n }\n }\n return nearestId;\n}\n\nexport interface KolmoActorProps extends Omit<EcctrlProps, \"ref\"> {\n readonly ref?: React.Ref<EcctrlHandle>;\n readonly cameraRef?: React.Ref<EcctrlCameraControlsHandle>;\n readonly cameraProps?: Omit<ComponentProps<typeof EcctrlCameraControls>, \"ref\"> | null | false;\n readonly getInput?: KolmoInputGetter;\n readonly bundle?: KhrAssetBundle | null;\n}\n\nexport function KolmoActor({\n ref,\n cameraRef,\n cameraProps,\n getInput,\n bundle,\n enable = true,\n enableCustomGravity,\n position = [0, 1.4, 0],\n rotation,\n userData,\n children,\n ...ecctrlRest\n}: KolmoActorProps): React.JSX.Element | null {\n const ctxCustomGravity = useContext(KolmoGravityContext);\n const effCustomGravity = enableCustomGravity ?? ctxCustomGravity;\n const activeWorld = useActiveKolmoWorld();\n useLayoutEffect(() => {\n ensureWorldSession(activeWorld);\n }, [activeWorld]);\n\n const pilotedVehEnt = useQueryFirst(VehicleTrait, PilotedTag);\n const readInput = useKolmoInput(getInput);\n const domElement = useThree((s) => s.gl?.domElement);\n const hasDom = Boolean(domElement && typeof domElement.addEventListener === \"function\");\n const { world: rapierWorld } = useRapier();\n\n const actorEntRef = useRef<ReturnType<typeof activeWorld.spawn> | null>(null);\n const ecctrlRef = useRef<EcctrlHandle | null>(null);\n const camCtrlRef = useRef<EcctrlCameraControlsHandle | null>(null);\n const followPos = useRef(new THREE.Vector3());\n const followUp = useRef(new THREE.Vector3(0, 1, 0));\n const camSyncedRef = useRef(false);\n const prevInteractRef = useRef(false);\n const prevNearIdRef = useRef(\"\");\n const cooldownRef = useRef(0);\n const stickRef = useRef({ x: 0, y: 0 });\n const moveCmdRef = useRef<MovementInput>({\n forward: false,\n backward: false,\n leftward: false,\n rightward: false,\n joystick: stickRef.current,\n run: false,\n jump: false,\n });\n const [latchedExit, setLatchedExit] = useState<{ pos: [number, number, number]; yaw: number } | null>(null);\n\n useLayoutEffect(() => {\n const ent = activeWorld.spawn(\n ActorTrait({ id: \"pilot\", handle: ecctrlRef.current, exitSpawnPos: null, exitSpawnYaw: 0, exitLinVel: null }),\n TransformTrait,\n VelocityTrait,\n );\n actorEntRef.current = ent;\n const prePiloted = activeWorld.queryFirst(pilotedVehicleQuery);\n if (prePiloted)\n ent.add(PilotLink(prePiloted));\n const unsub = activeWorld.onChange(ActorTrait, (changed) => {\n if (changed !== ent)\n return;\n const d = ent.get(ActorTrait);\n if (d?.exitSpawnPos) {\n setLatchedExit({ pos: d.exitSpawnPos, yaw: d.exitSpawnYaw });\n }\n });\n return () => {\n unsub();\n actorEntRef.current = null;\n ent.destroy();\n };\n }, [activeWorld]);\n\n const onFoot = enable && !pilotedVehEnt;\n useLayoutEffect(() => {\n if (!onFoot)\n camSyncedRef.current = false;\n }, [onFoot]);\n\n useLayoutEffect(() => {\n const ent = actorEntRef.current;\n if (ent && pilotedVehEnt && !ent.has(PilotLink(pilotedVehEnt)))\n ent.add(PilotLink(pilotedVehEnt));\n }, [pilotedVehEnt]);\n\n const assignEcctrlRef = useCallback((handle: EcctrlHandle | null) => {\n ecctrlRef.current = handle;\n assignRef(ref, handle);\n const ent = actorEntRef.current;\n if (!ent?.isAlive())\n return;\n const cur = ent.get(ActorTrait);\n if (handle?.body && cur?.exitLinVel) {\n handle.body.setLinvel({ x: cur.exitLinVel[0], y: cur.exitLinVel[1], z: cur.exitLinVel[2] }, true);\n }\n ent.set(ActorTrait, {\n id: cur?.id ?? \"pilot\",\n handle,\n exitSpawnPos: cur?.exitSpawnPos ?? null,\n exitSpawnYaw: cur?.exitSpawnYaw ?? 0,\n exitLinVel: handle?.body ? null : (cur?.exitLinVel ?? null),\n });\n }, [ref]);\n\n const assignCamRef = useCallback((ctrl: EcctrlCameraControlsHandle | null) => {\n camCtrlRef.current = ctrl;\n assignRef(cameraRef, ctrl);\n }, [cameraRef]);\n\n const mergedUserData = useMemo(() => {\n const base = (userData ?? {}) as Record<string, unknown>;\n const ecctrlMeta = (base.ecctrl ?? {}) as Record<string, unknown>;\n return { ...base, ecctrl: { excludeVehicleRay: true, ...ecctrlMeta } };\n }, [userData]);\n\n const clonedScene = useMemo(() => (bundle ? cloneSkinned(bundle.scene) : null), [bundle]);\n\n useFrame((state, delta) => {\n if (!enable)\n return;\n const dt = rapierWorld.timestep > 0 ? rapierWorld.timestep : Math.min(Math.max(delta, 1e-4), 1 / 30);\n if (cooldownRef.current > 0)\n cooldownRef.current = Math.max(0, cooldownRef.current - dt);\n\n const inp = readInput();\n const interactEdge = inp.interact && !prevInteractRef.current;\n prevInteractRef.current = inp.interact;\n\n if (activeWorld.queryFirst(pilotedVehicleQuery)) {\n if (interactEdge && cooldownRef.current === 0) {\n cooldownRef.current = 0.25;\n kolmoActions(activeWorld).exitVehicle();\n }\n return;\n }\n\n const handle = ecctrlRef.current;\n if (!handle?.body)\n return;\n\n stickRef.current.x = inp.stickX;\n stickRef.current.y = inp.stickY;\n const cmd = moveCmdRef.current;\n cmd.forward = inp.forward;\n cmd.backward = inp.backward;\n cmd.leftward = inp.left;\n cmd.rightward = inp.right;\n cmd.joystick = stickRef.current;\n cmd.run = inp.boost;\n cmd.jump = inp.brake;\n handle.setMovement(cmd);\n\n if (actorEntRef.current?.isAlive()) {\n writeEntityKinematics(activeWorld, actorEntRef.current, handle.currPos, handle.currQuat, handle.currLinVel, handle.moveSpeed * 3.6);\n }\n\n const nearId = findNearestInteractableVehicleId(activeWorld, handle.currPos) ?? \"\";\n if (nearId !== prevNearIdRef.current) {\n prevNearIdRef.current = nearId;\n activeWorld.set(WorldSessionTrait, { nearVehicleId: nearId });\n }\n\n if (interactEdge && nearId && cooldownRef.current === 0) {\n cooldownRef.current = 0.25;\n kolmoActions(activeWorld).boardVehicle(nearId);\n return;\n }\n\n const cam = camCtrlRef.current;\n if (cam && handle.currPos.lengthSq() > 0) {\n const hasValidUp = handle.upAxis.lengthSq() > 0.25;\n if (hasValidUp)\n followUp.current.copy(handle.upAxis).normalize();\n else\n followUp.current.copy(_worldUp);\n followPos.current.copy(handle.currPos).addScaledVector(followUp.current, 0.55);\n\n if (!camSyncedRef.current) {\n camSyncedRef.current = true;\n state.camera.up.copy(followUp.current);\n cam.setUp(followUp.current);\n _camFwd.copy(handle.bodyZAxis).projectOnPlane(followUp.current);\n if (_camFwd.lengthSq() < 1e-4)\n _camFwd.set(0, 0, -1).projectOnPlane(followUp.current);\n _camFwd.normalize();\n cam.setLookAt(\n followPos.current.x - _camFwd.x * 7.5 + followUp.current.x * 2.4,\n followPos.current.y - _camFwd.y * 7.5 + followUp.current.y * 2.4,\n followPos.current.z - _camFwd.z * 7.5 + followUp.current.z * 2.4,\n followPos.current.x,\n followPos.current.y,\n followPos.current.z,\n false,\n );\n }\n else {\n cam.moveTo(followPos.current.x, followPos.current.y, followPos.current.z, true);\n if (effCustomGravity && state.camera.up.distanceToSquared(followUp.current) > 1e-6) {\n state.camera.up.lerp(followUp.current, 1 - Math.exp(-8 * dt)).normalize();\n cam.setUp(state.camera.up);\n }\n }\n }\n });\n\n if (!onFoot)\n return null;\n\n const spawnPos = latchedExit?.pos ?? position;\n const spawnRot = rotation ?? (latchedExit ? ([0, latchedExit.yaw, 0] as [number, number, number]) : undefined);\n\n return (\n <>\n {hasDom && cameraProps !== false && cameraProps !== null && (\n <EcctrlCameraControls\n ref={assignCamRef}\n makeDefault\n minPolarAngle={0.12}\n maxPolarAngle={Math.PI - 0.12}\n smoothTime={0.08}\n {...(cameraProps ?? {})}\n />\n )}\n <Ecctrl\n ref={assignEcctrlRef}\n enable={enable}\n enableCustomGravity={effCustomGravity}\n position={spawnPos}\n {...(spawnRot === undefined ? {} : { rotation: spawnRot })}\n userData={mergedUserData}\n {...ecctrlRest}\n >\n {children ?? (clonedScene ? <primitive object={clonedScene} /> : null)}\n </Ecctrl>\n </>\n );\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, 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 return () => {\n u1(); u2(); u3(); u4(); u5();\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 lastRef = useRef({ line: \"\", prompt: \"\", elapsed: 0 });\n const [isTouch, setIsTouch] = useState(detectTouchDevice);\n useEffect(() => {\n setIsTouch(detectTouchDevice());\n }, []);\n const touchEnabled = showTouchControls ?? isTouch;\n\n useFrame((_, delta) => {\n const st = lastRef.current;\n st.elapsed += delta;\n if (st.elapsed < 0.05)\n return;\n st.elapsed = 0;\n const { line, prompt } = formatHudStrings(world);\n const fullPrompt = extraPrompt ? `${prompt} · ${extraPrompt}` : prompt;\n if (line !== st.line && telemetryRef.current) {\n telemetryRef.current.textContent = line;\n st.line = line;\n }\n if (fullPrompt !== st.prompt && promptRef.current) {\n promptRef.current.textContent = fullPrompt;\n st.prompt = fullPrompt;\n }\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 [isTouch, setIsTouch] = useState(detectTouchDevice);\n useEffect(() => {\n setIsTouch(detectTouchDevice());\n }, []);\n const touchEnabled = showTouchControls ?? isTouch;\n\n useEffect(() => {\n const sync = (): void => {\n const { line, prompt } = formatHudStrings(world);\n const fullPrompt = extraPrompt ? `${prompt} · ${extraPrompt}` : prompt;\n if (telemetryRef.current)\n telemetryRef.current.textContent = line;\n if (promptRef.current)\n promptRef.current.textContent = fullPrompt;\n };\n sync();\n const id = window.setInterval(sync, 66);\n return () => window.clearInterval(id);\n }, [world, extraPrompt]);\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","import type * as THREE from \"three\";\nimport { GLTFLoader } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { KTX2Loader } from \"three/examples/jsm/loaders/KTX2Loader.js\";\nimport { MeshoptDecoder } from \"three/examples/jsm/libs/meshopt_decoder.module.js\";\nimport { loadKhrGlb, type KhrAssetBundle, type KhrPluginOptions } from \"@khr3/core\";\n\nexport interface KolmoGltfLoaderOptions {\n /** Optional WebGLRenderer so KTX2 (`KHR_texture_basisu`) detects hardware ASTC/BC7/ETC2 support. */\n readonly renderer?: THREE.WebGLRenderer | null;\n /** Optional path hosting Basis Universal transcoder `.js`/`.wasm` files (defaults to `\"/basis/\"`). */\n readonly basisTranscoderPath?: string;\n /** Optional `@khr3/core` plugin options. */\n readonly khrOptions?: KhrPluginOptions;\n}\n\nconst ktx2ByRenderer = new WeakMap<THREE.WebGLRenderer, Map<string, KTX2Loader>>();\n\nfunction getScopedKtx2Loader(renderer: THREE.WebGLRenderer, transcoderPath: string): KTX2Loader {\n let byPath = ktx2ByRenderer.get(renderer);\n if (!byPath) {\n byPath = new Map();\n ktx2ByRenderer.set(renderer, byPath);\n }\n let ktx2 = byPath.get(transcoderPath);\n if (!ktx2) {\n ktx2 = new KTX2Loader();\n ktx2.setTranscoderPath(transcoderPath);\n ktx2.detectSupport(renderer);\n byPath.set(transcoderPath, ktx2);\n }\n return ktx2;\n}\n\n/**\n * Khronos-compliant `GLTFLoader` configured with `EXT_meshopt_compression` (`MeshoptDecoder`)\n * and `KHR_texture_basisu` (`KTX2Loader` when a renderer is supplied).\n */\nexport function createKolmoGltfLoader(options?: KolmoGltfLoaderOptions): GLTFLoader {\n const loader = new GLTFLoader();\n loader.setMeshoptDecoder(MeshoptDecoder);\n if (options?.renderer) {\n loader.setKTX2Loader(getScopedKtx2Loader(options.renderer, options.basisTranscoderPath ?? \"/basis/\"));\n }\n return loader;\n}\n\nexport async function parseKolmoGlbBuffer(\n buffer: ArrayBuffer | Uint8Array,\n options?: KolmoGltfLoaderOptions,\n): Promise<KhrAssetBundle> {\n await MeshoptDecoder.ready;\n const loader = createKolmoGltfLoader(options);\n return loadKhrGlb(buffer, { ...options?.khrOptions, loader });\n}\n\nexport async function loadKolmoGlbUrl(\n url: string,\n options?: KolmoGltfLoaderOptions,\n): Promise<KhrAssetBundle> {\n const res = await fetch(url);\n if (!res.ok)\n throw new Error(`Failed to fetch GLB (${res.status}): ${url}`);\n return parseKolmoGlbBuffer(await res.arrayBuffer(), options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,IAAM,WAAW,IAAI,MAAM,QAAQ;AACnC,IAAM,UAAU,IAAI,MAAM,QAAQ;AAClC,IAAM,WAAW,IAAI,MAAM,QAAQ,GAAG,GAAG,CAAC;AAE1C,SAAS,iCAAiC,OAA+C,UAAwC;CAC7H,IAAI,YAA2B;CAC/B,IAAI,aAAa;CACjB,KAAK,MAAM,OAAO,MAAM,MAAM,cAAc,iBAAiB,GAAG;EAC5D,MAAM,IAAI,IAAI,IAAI,YAAY;EAC9B,MAAM,KAAK,IAAI,IAAI,iBAAiB;EACpC,IAAI,CAAC,GAAG,UAAU,CAAC,IACf;EACJ,SAAS,IAAI,EAAE,WAAW,IAAI,EAAE,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,gBAAgB,EAAE,OAAO,QAA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AAW,QAAQ;EAAE,GAAG,SAAS;EAAY;CAAO,CAAC;AAChE;AAEA,eAAsB,gBAClB,KACA,SACuB;CACvB,MAAM,MAAM,MAAM,MAAM,GAAG;CAC3B,IAAI,CAAC,IAAI,IACL,MAAM,IAAI,MAAM,wBAAwB,IAAI,OAAO,KAAK,KAAK;CACjE,OAAO,oBAAoB,MAAM,IAAI,YAAY,GAAG,OAAO;AAC/D"}
|
package/dist/engine/input.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export declare const KOLMO_STICK_DEADZONE = 0.08;
|
|
|
14
14
|
export declare const EMPTY_KOLMO_INPUT: Readonly<KolmoInputState>;
|
|
15
15
|
export declare const KOLMO_KEY_MAP: KeyboardControlsEntry<string>[];
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Input reader merging Drei `<KeyboardControls>`, `@pinkaphant/ecctrl/input`
|
|
18
18
|
* Zustand stores (`useJoystickStore` + `useButtonStore`), and optional `getInput()` overrides.
|
|
19
|
+
* Analog thumbstick values stay analog (`stickX`, `stickY`) rather than slamming digital WASD booleans.
|
|
19
20
|
*/
|
|
20
21
|
export declare function useKolmoInput(getInput?: KolmoInputGetter): () => Readonly<KolmoInputState>;
|
package/dist/engine/surface.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as THREE from "three";
|
|
3
2
|
import type { ThreeEvent } from "@react-three/fiber";
|
|
4
|
-
import { type
|
|
3
|
+
import { type KhrAssemblyProps, type KhrAssetBundle } from "@khr3/core";
|
|
5
4
|
export interface KolmoSurfaceProps extends Omit<KhrAssemblyProps, "bundle"> {
|
|
6
5
|
readonly src?: string;
|
|
7
6
|
readonly bundle?: KhrAssetBundle;
|
|
@@ -9,7 +8,6 @@ export interface KolmoSurfaceProps extends Omit<KhrAssemblyProps, "bundle"> {
|
|
|
9
8
|
readonly color?: string;
|
|
10
9
|
}
|
|
11
10
|
export declare function KolmoSurface({ ref, src, bundle, size, color, position, ...rest }: KolmoSurfaceProps): React.JSX.Element;
|
|
12
|
-
export declare function togglePropJoint(handle: KhrAssemblyHandle | null, bundle: KhrAssetBundle, openState: boolean, clickedObj?: THREE.Object3D | null, perBodyOpen?: Map<string, boolean>): boolean;
|
|
13
11
|
export interface KolmoPropProps extends Omit<KhrAssemblyProps, "bundle" | "onClick"> {
|
|
14
12
|
readonly src?: string;
|
|
15
13
|
readonly bundle?: KhrAssetBundle;
|
package/dist/engine/traits.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type Entity, type World } from "koota";
|
|
2
2
|
import type { EcctrlHandle } from "@pinkaphant/ecctrl";
|
|
3
|
-
import type { EcctrlVehicleHandle } from "@pinkaphant/ecctrl/vehicle";
|
|
3
|
+
import type { EcctrlVehicleHandle, VehicleInput } from "@pinkaphant/ecctrl/vehicle";
|
|
4
|
+
import type { KhrVehicleJointsHandle } from "@khr3/core/vehicle";
|
|
4
5
|
export type KolmoControlMode = "foot" | "car" | "flight";
|
|
5
6
|
export interface VehicleTraitData {
|
|
6
7
|
id: string;
|
|
7
8
|
handle: EcctrlVehicleHandle | null;
|
|
9
|
+
jointsHandle?: KhrVehicleJointsHandle | null;
|
|
8
10
|
seatOffset: [number, number, number];
|
|
9
11
|
exitOffset: [number, number, number];
|
|
10
12
|
isFlight: boolean;
|
|
@@ -72,8 +74,11 @@ export declare const vehicleSimQuery: import("koota").Query<[import("koota").Tra
|
|
|
72
74
|
}>]>;
|
|
73
75
|
export declare const pilotedVehicleQuery: import("koota").Query<[import("koota").Trait<() => VehicleTraitData>, import("koota").TagTrait]>;
|
|
74
76
|
export declare const kolmoWorld: World;
|
|
77
|
+
export declare const KolmoWorldContext: import("react").Context<World | null>;
|
|
78
|
+
export declare function useOptionalKootaWorld(): World | null;
|
|
75
79
|
export declare function useActiveKolmoWorld(): World;
|
|
76
80
|
export declare function ensureWorldSession(w: World): void;
|
|
81
|
+
export declare function createEmptyVehicleCmd(brake?: boolean): VehicleInput;
|
|
77
82
|
/** Zero-allocation SoA typed-array writer using Koota's public `unpackEntity` + `getStore`. */
|
|
78
83
|
export declare function writeEntityKinematics(world: World, entity: Entity, pos: {
|
|
79
84
|
readonly x: number;
|
|
@@ -91,7 +96,7 @@ export declare function writeEntityKinematics(world: World, entity: Entity, pos:
|
|
|
91
96
|
}, speedKmh: number): void;
|
|
92
97
|
/** Zero-allocation SoA typed-array writer for `VehicleTelemetryTrait` inside `useFrame`. */
|
|
93
98
|
export declare function writeVehicleTelemetry(world: World, entity: Entity, rpm: number, gear: number, throttle: number, boost: number, slip: number): void;
|
|
94
|
-
export declare function flipVehicleBodyUpright(veh: EcctrlVehicleHandle): void;
|
|
99
|
+
export declare function flipVehicleBodyUpright(veh: EcctrlVehicleHandle, joints?: KhrVehicleJointsHandle | null): void;
|
|
95
100
|
export declare const kolmoActions: import("koota").Actions<{
|
|
96
101
|
boardVehicle: (vehicleId: string) => void;
|
|
97
102
|
exitVehicle: () => void;
|
package/dist/engine/world.d.ts
CHANGED
|
@@ -5,8 +5,7 @@ import { type World } from "koota";
|
|
|
5
5
|
import { type KolmoGravitySpec, type KolmoTimeControlValue } from "../physics/index.js";
|
|
6
6
|
import { type KolmoControlMode } from "./traits.js";
|
|
7
7
|
export declare const KolmoInCanvasContext: React.Context<boolean>;
|
|
8
|
-
export
|
|
9
|
-
export declare const KolmoOverlayContext: React.Context<KolmoOverlayRegister | null>;
|
|
8
|
+
export declare const KolmoOverlayPortalContext: React.Context<HTMLElement | null>;
|
|
10
9
|
export interface RoomEnvRigProps {
|
|
11
10
|
readonly intensity?: number;
|
|
12
11
|
}
|
|
@@ -54,6 +53,7 @@ export interface KolmoGameHookState {
|
|
|
54
53
|
export declare function useKolmoGame(explicitWorld?: World | null): KolmoGameHookState;
|
|
55
54
|
export interface KolmoHudProps {
|
|
56
55
|
readonly showTouchControls?: boolean;
|
|
56
|
+
readonly extraPrompt?: string;
|
|
57
57
|
readonly style?: CSSProperties;
|
|
58
58
|
}
|
|
59
59
|
export declare function KolmoHud(props: KolmoHudProps): React.JSX.Element | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export * from "./engine/index.js";
|
|
2
2
|
export { KolmoCanvas as Canvas, KolmoPhysics as Physics, KolmoWorld as World, KolmoGame as Game, KolmoHud as Hud, KolmoVehicle as Vehicle, KolmoActor as Actor, KolmoSurface as Surface, KolmoProp as Prop, } from "./engine/index.js";
|
|
3
|
+
export * from "./toolgun/index.js";
|
|
4
|
+
export { KolmoToolgun as Toolgun } from "./toolgun/index.js";
|
|
3
5
|
export { Ecctrl, type EcctrlHandle, type EcctrlProps, type MovementInput } from "@pinkaphant/ecctrl";
|
|
4
6
|
export { EcctrlVehicle, ShapeCastWheel, ThrustPropeller, type CarConfigType, type DroneConfigType, type EcctrlVehicleHandle, type EcctrlVehicleProps, type VehicleInput, } from "@pinkaphant/ecctrl/vehicle";
|
|
5
7
|
export { Joystick, VirtualButton, useButtonStore, useJoystickStore } from "@pinkaphant/ecctrl/input";
|
|
6
8
|
export { EcctrlCameraControls, type EcctrlCameraControlsHandle } from "@pinkaphant/ecctrl/camera";
|
|
7
9
|
export { EcctrlAnimationStateController, useEcctrlAnimationStore, type EcctrlAnimationState, } from "@pinkaphant/ecctrl/animation";
|
|
8
10
|
export { useCustomGravity, type CustomGravityState } from "@pinkaphant/ecctrl/gravity";
|
|
9
|
-
export { KhrAssembly, PhysicsWorld, cloneKhrBundle, createKhrGltfPlugin, disposeKhrBundle, exportKhrGlb, loadKhrGlb, useKhrGlb, type KhrAssemblyHandle, type KhrAssemblyProps, type KhrAssetBundle, type KhrExportNodeSpec, } from "@khr3/core";
|
|
11
|
+
export { JointRegistryContext, KhrAssembly, PhysicsWorld, cloneKhrBundle, createKhrGltfPlugin, disposeKhrBundle, exportKhrGlb, loadKhrGlb, useKhrGlb, type JointRegistry, type JointRuntime, type KhrAssemblyHandle, type KhrAssemblyProps, type KhrAssetBundle, type KhrExportNodeSpec, } from "@khr3/core";
|
|
10
12
|
export { KhrVehicle, type KhrVehicleJointsHandle, type KhrVehicleProps } from "@khr3/core/vehicle";
|
|
11
|
-
export { DOOR_HINGE_SPEC, Ex, ROOT3, SIDE_METRES, STOREY_METRES, buildFootprint, canPlace, instanceBatches, latticePose, planSettlement, poseEq, poseFromJSON, poseToFloat, poseToJSON, snapPose, socketFor, triangleCorners, vToFloat, worldSockets, } from "@khr3/c12";
|
|
13
|
+
export { DOOR_HINGE_SPEC, Ex, PIECE_KINDS, ROOT3, SIDE_METRES, STOREY_METRES, buildFootprint, canPlace, instanceBatches, latticePose, planSettlement, poseEq, poseFromJSON, poseToFloat, poseToJSON, snapPose, socketFor, triangleCorners, vToFloat, worldSockets, type PieceKind, type PiecePose, type PlacedPiece, } from "@khr3/c12";
|
|
12
14
|
export { createActions, createQuery, createWorld, getStore, relation, trait, unpackEntity, type Entity, type World as KootaWorld, } from "koota";
|
|
13
15
|
export { WorldProvider, useHas, useQuery, useQueryFirst, useTrait, useWorld } from "koota/react";
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as
|
|
1
|
+
import { KolmoActor, KolmoCanvas, KolmoGame, KolmoHud, KolmoInCanvasContext, KolmoOverlayPortalContext, KolmoWorld, RoomEnvRig, createKolmoGltfLoader, loadKolmoGlbUrl, parseKolmoGlbBuffer, useKolmoGame } from "./engine/index.js";
|
|
2
|
+
import { A as writeEntityKinematics, C as flipVehicleBodyUpright, D as useActiveKolmoWorld, E as pilotedVehicleQuery, O as useOptionalKootaWorld, S as ensureWorldSession, T as kolmoWorld, _ as VehicleTelemetryTrait, a as computeCircularOrbitSpeed, b as WorldSessionTrait, c as evaluatePreparedNBodyGravity, d as ActorTrait, f as InteractableTrait, g as TransformTrait, h as PilotedTag, i as G_SI, j as writeVehicleTelemetry, k as vehicleSimQuery, l as prepareAttractors, m as PilotLink, n as KolmoPhysics, o as createNBodyGravityField, p as KolmoWorldContext, r as useIsKolmoCustomGravity, s as evaluateNBodyGravity, t as KolmoGravityContext, u as resolveAttractorMu, v as VehicleTrait, w as kolmoActions, x as createEmptyVehicleCmd, y as VelocityTrait } from "./physics-ZDFXaCli.js";
|
|
3
|
+
import { a as KOLMO_KEY_MAP, c as KolmoKeyboardContext, i as EMPTY_KOLMO_INPUT, l as useKolmoInput, n as KolmoSurface, o as KOLMO_STICK_DEADZONE, r as KolmoVehicle, s as KolmoKeyboardBridge, t as KolmoProp } from "./surface-DUol_5ml.js";
|
|
4
|
+
import { a as TOOLGUN_SKIN_PRESETS, c as computeBuildCandidate, d as createWeldImpulseJoint, f as rigJointRuntime, i as TOOLGUN_MODES, l as createHingeImpulseJoint, n as measureToolgunViewmodel, o as castToolgunRay, p as useToolgunStore, r as TOOLGUN_BUILD_KINDS, s as computeAlignedSpawnPose, t as KolmoToolgun, u as createToolgunStore } from "./toolgun-BfcCIAQx.js";
|
|
3
5
|
import { Ecctrl } from "@pinkaphant/ecctrl";
|
|
4
6
|
import { EcctrlVehicle, ShapeCastWheel, ThrustPropeller } from "@pinkaphant/ecctrl/vehicle";
|
|
5
7
|
import { Joystick, VirtualButton, useButtonStore, useJoystickStore } from "@pinkaphant/ecctrl/input";
|
|
6
8
|
import { EcctrlCameraControls } from "@pinkaphant/ecctrl/camera";
|
|
7
9
|
import { EcctrlAnimationStateController, useEcctrlAnimationStore } from "@pinkaphant/ecctrl/animation";
|
|
8
10
|
import { useCustomGravity } from "@pinkaphant/ecctrl/gravity";
|
|
9
|
-
import { KhrAssembly, PhysicsWorld, cloneKhrBundle, createKhrGltfPlugin, disposeKhrBundle, exportKhrGlb, loadKhrGlb, useKhrGlb } from "@khr3/core";
|
|
11
|
+
import { JointRegistryContext, KhrAssembly, PhysicsWorld, cloneKhrBundle, createKhrGltfPlugin, disposeKhrBundle, exportKhrGlb, loadKhrGlb, useKhrGlb } from "@khr3/core";
|
|
10
12
|
import { KhrVehicle } from "@khr3/core/vehicle";
|
|
11
|
-
import { DOOR_HINGE_SPEC, Ex, ROOT3, SIDE_METRES, STOREY_METRES, buildFootprint, canPlace, instanceBatches, latticePose, planSettlement, poseEq, poseFromJSON, poseToFloat, poseToJSON, snapPose, socketFor, triangleCorners, vToFloat, worldSockets } from "@khr3/c12";
|
|
13
|
+
import { DOOR_HINGE_SPEC, Ex, PIECE_KINDS, ROOT3, SIDE_METRES, STOREY_METRES, buildFootprint, canPlace, instanceBatches, latticePose, planSettlement, poseEq, poseFromJSON, poseToFloat, poseToJSON, snapPose, socketFor, triangleCorners, vToFloat, worldSockets } from "@khr3/c12";
|
|
12
14
|
import { createActions, createQuery, createWorld, getStore, relation, trait, unpackEntity } from "koota";
|
|
13
15
|
import { WorldProvider, useHas, useQuery, useQueryFirst, useTrait, useWorld } from "koota/react";
|
|
14
|
-
export { KolmoActor as Actor, KolmoActor, ActorTrait, KolmoCanvas as Canvas, KolmoCanvas, DOOR_HINGE_SPEC, EMPTY_KOLMO_INPUT, Ecctrl, EcctrlAnimationStateController, EcctrlCameraControls, EcctrlVehicle, Ex, G_SI, KolmoGame as Game, KolmoGame, KolmoHud as Hud, KolmoHud, InteractableTrait, Joystick, KOLMO_KEY_MAP, KOLMO_STICK_DEADZONE, KhrAssembly, KhrVehicle, KolmoGravityContext, KolmoInCanvasContext, KolmoKeyboardBridge, KolmoKeyboardContext,
|
|
16
|
+
export { KolmoActor as Actor, KolmoActor, ActorTrait, KolmoCanvas as Canvas, KolmoCanvas, DOOR_HINGE_SPEC, EMPTY_KOLMO_INPUT, Ecctrl, EcctrlAnimationStateController, EcctrlCameraControls, EcctrlVehicle, Ex, G_SI, KolmoGame as Game, KolmoGame, KolmoHud as Hud, KolmoHud, InteractableTrait, JointRegistryContext, Joystick, KOLMO_KEY_MAP, KOLMO_STICK_DEADZONE, KhrAssembly, KhrVehicle, KolmoGravityContext, KolmoInCanvasContext, KolmoKeyboardBridge, KolmoKeyboardContext, KolmoOverlayPortalContext, KolmoPhysics, KolmoPhysics as Physics, KolmoProp, KolmoProp as Prop, KolmoSurface, KolmoSurface as Surface, KolmoToolgun, KolmoToolgun as Toolgun, KolmoVehicle, KolmoVehicle as Vehicle, KolmoWorld, KolmoWorld as World, KolmoWorldContext, PIECE_KINDS, PhysicsWorld, PilotLink, PilotedTag, ROOT3, RoomEnvRig, SIDE_METRES, STOREY_METRES, ShapeCastWheel, TOOLGUN_BUILD_KINDS, TOOLGUN_MODES, TOOLGUN_SKIN_PRESETS, ThrustPropeller, TransformTrait, VehicleTelemetryTrait, VehicleTrait, VelocityTrait, VirtualButton, WorldProvider, WorldSessionTrait, buildFootprint, canPlace, castToolgunRay, cloneKhrBundle, computeAlignedSpawnPose, computeBuildCandidate, computeCircularOrbitSpeed, createActions, createEmptyVehicleCmd, createHingeImpulseJoint, createKhrGltfPlugin, createKolmoGltfLoader, createNBodyGravityField, createQuery, createToolgunStore, createWeldImpulseJoint, createWorld, disposeKhrBundle, ensureWorldSession, evaluateNBodyGravity, evaluatePreparedNBodyGravity, exportKhrGlb, flipVehicleBodyUpright, getStore, instanceBatches, kolmoActions, kolmoWorld, latticePose, loadKhrGlb, loadKolmoGlbUrl, measureToolgunViewmodel, parseKolmoGlbBuffer, pilotedVehicleQuery, planSettlement, poseEq, poseFromJSON, poseToFloat, poseToJSON, prepareAttractors, relation, resolveAttractorMu, rigJointRuntime, snapPose, socketFor, trait, triangleCorners, unpackEntity, useActiveKolmoWorld, useButtonStore, useCustomGravity, useEcctrlAnimationStore, useHas, useIsKolmoCustomGravity, useJoystickStore, useKhrGlb, useKolmoGame, useKolmoInput, useOptionalKootaWorld, useQuery, useQueryFirst, useToolgunStore, useTrait, useWorld, vToFloat, vehicleSimQuery, worldSockets, writeEntityKinematics, writeVehicleTelemetry };
|
package/dist/physics/index.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import React, { type ReactNode, type RefObject } from "react";
|
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
import { type PhysicsWorldProps } from "@khr3/core";
|
|
4
4
|
import { type World } from "koota";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import { useOptionalKootaWorld } from "../engine/traits.js";
|
|
6
|
+
import { G_SI, computeCircularOrbitSpeed, createNBodyGravityField, evaluateNBodyGravity, evaluatePreparedNBodyGravity, prepareAttractors, resolveAttractorMu, type KolmoGravityAttractor, type KolmoNBodyGravity, type PreparedGravityAttractor } from "./nBodyGravity.js";
|
|
7
|
+
export { G_SI, computeCircularOrbitSpeed, createNBodyGravityField, evaluateNBodyGravity, evaluatePreparedNBodyGravity, prepareAttractors, resolveAttractorMu, useOptionalKootaWorld, type KolmoGravityAttractor, type KolmoNBodyGravity, type PreparedGravityAttractor, };
|
|
7
8
|
export type KolmoTimeControlValue = number | RefObject<number>;
|
|
8
9
|
export type KolmoPointGravity = {
|
|
9
10
|
readonly kind: "point";
|
|
@@ -15,7 +16,6 @@ export type KolmoPointGravity = {
|
|
|
15
16
|
export type KolmoGravityCallback = (pos: THREE.Vector3, out: THREE.Vector3) => THREE.Vector3;
|
|
16
17
|
export type KolmoGravitySpec = "planar" | "zero" | "custom" | readonly [number, number, number] | KolmoPointGravity | KolmoNBodyGravity | KolmoGravityCallback;
|
|
17
18
|
export declare const KolmoGravityContext: React.Context<boolean>;
|
|
18
|
-
export declare function useOptionalKootaWorld(): World | null;
|
|
19
19
|
export interface KolmoPhysicsProps extends Omit<PhysicsWorldProps, "gravity" | "debug" | "timeScale" | "maxDelta" | "children"> {
|
|
20
20
|
readonly gravity?: KolmoGravitySpec;
|
|
21
21
|
readonly paused?: boolean;
|
package/dist/physics/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { i as G_SI, t as KolmoGravityContext, n as KolmoPhysics, a as computeCircularOrbitSpeed, o as createNBodyGravityField, s as evaluateNBodyGravity, c as evaluatePreparedNBodyGravity, l as prepareAttractors, u as resolveAttractorMu, r as useIsKolmoCustomGravity, O as useOptionalKootaWorld } from "../physics-ZDFXaCli.js";
|
|
@@ -19,24 +19,31 @@ export interface KolmoNBodyGravity {
|
|
|
19
19
|
readonly attractors: readonly KolmoGravityAttractor[];
|
|
20
20
|
readonly gravitationalConstant?: number;
|
|
21
21
|
}
|
|
22
|
+
export interface PreparedGravityAttractor {
|
|
23
|
+
readonly px: number;
|
|
24
|
+
readonly py: number;
|
|
25
|
+
readonly pz: number;
|
|
26
|
+
readonly mu: number;
|
|
27
|
+
readonly epsSq: number;
|
|
28
|
+
}
|
|
22
29
|
export declare function resolveAttractorMu(attractor: KolmoGravityAttractor, gravitationalConstant?: number): {
|
|
23
30
|
mu: number;
|
|
24
31
|
epsSq: number;
|
|
25
32
|
};
|
|
33
|
+
export declare function prepareAttractors(attractors: readonly KolmoGravityAttractor[], gravitationalConstant?: number): PreparedGravityAttractor[];
|
|
34
|
+
export declare function evaluatePreparedNBodyGravity(pos: {
|
|
35
|
+
readonly x: number;
|
|
36
|
+
readonly y: number;
|
|
37
|
+
readonly z: number;
|
|
38
|
+
}, prepared: readonly PreparedGravityAttractor[], out: THREE.Vector3): THREE.Vector3;
|
|
26
39
|
/**
|
|
27
40
|
* Evaluates softened Newtonian multi-attractor gravitational acceleration (m/s^2):
|
|
28
41
|
* g(x) = sum_i mu_i * (p_i - x) / (|p_i - x|^2 + eps_i^2)^(3/2)
|
|
29
|
-
* Zero artificial floor clamps and zero boundary fences.
|
|
30
42
|
*/
|
|
31
43
|
export declare function evaluateNBodyGravity(pos: {
|
|
32
44
|
readonly x: number;
|
|
33
45
|
readonly y: number;
|
|
34
46
|
readonly z: number;
|
|
35
47
|
}, attractors: readonly KolmoGravityAttractor[], out: THREE.Vector3, gravitationalConstant?: number): THREE.Vector3;
|
|
36
|
-
export declare function createNBodyGravityField(attractors: readonly KolmoGravityAttractor[], gravitationalConstant?: number): (pos: THREE.Vector3, out
|
|
37
|
-
/**
|
|
38
|
-
* Exact tangential speed v_circ (m/s) for a circular orbit of radius `orbitRadiusM`
|
|
39
|
-
* around a softened point/spherical attractor:
|
|
40
|
-
* v^2 / r = mu * r / (r^2 + eps^2)^(3/2) => v = r * sqrt(mu / (r^2 + eps^2)^(3/2))
|
|
41
|
-
*/
|
|
48
|
+
export declare function createNBodyGravityField(attractors: readonly KolmoGravityAttractor[], gravitationalConstant?: number): (pos: THREE.Vector3, out?: THREE.Vector3) => THREE.Vector3;
|
|
42
49
|
export declare function computeCircularOrbitSpeed(attractor: KolmoGravityAttractor, orbitRadiusM: number, gravitationalConstant?: number): number;
|