@pinkaphant/kolmo 0.4.4 → 0.4.6
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/AGENTS.md +29 -0
- package/CLAUDE.md +8 -0
- package/README.md +67 -8
- package/bin/kolmo.mjs +456 -16
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/index.js +7 -5
- package/dist/engine/kolmoActions.js +24 -9
- package/dist/engine/kolmoActions.js.map +1 -1
- package/dist/engine/kolmoActor.js +19 -31
- package/dist/engine/kolmoActor.js.map +1 -1
- package/dist/engine/kolmoActorHelpers.d.ts +24 -0
- package/dist/engine/kolmoActorHelpers.js +64 -0
- package/dist/engine/kolmoActorHelpers.js.map +1 -0
- package/dist/engine/kolmoGame.js +4 -1
- package/dist/engine/kolmoGame.js.map +1 -1
- package/dist/engine/kolmoHud.js +34 -15
- package/dist/engine/kolmoHud.js.map +1 -1
- package/dist/engine/kolmoInput.d.ts +2 -0
- package/dist/engine/kolmoInput.js +12 -12
- package/dist/engine/kolmoInput.js.map +1 -1
- package/dist/engine/kolmoLongDrive.d.ts +1 -1
- package/dist/engine/kolmoLongDrive.js +10 -8
- package/dist/engine/kolmoLongDrive.js.map +1 -1
- package/dist/engine/kolmoPilotMesh.js +189 -48
- package/dist/engine/kolmoPilotMesh.js.map +1 -1
- package/dist/engine/kolmoTouchOverlay.d.ts +21 -0
- package/dist/engine/kolmoTouchOverlay.js +326 -0
- package/dist/engine/kolmoTouchOverlay.js.map +1 -0
- package/dist/engine/kolmoTouchState.d.ts +50 -0
- package/dist/engine/kolmoTouchState.js +210 -0
- package/dist/engine/kolmoTouchState.js.map +1 -0
- package/dist/engine/kolmoVehicleConfig.d.ts +2 -0
- package/dist/engine/kolmoVehicleConfig.js +8 -4
- package/dist/engine/kolmoVehicleConfig.js.map +1 -1
- package/dist/engine/kolmoVehicleDriver.d.ts +1 -0
- package/dist/engine/kolmoVehicleDriver.js +26 -50
- package/dist/engine/kolmoVehicleDriver.js.map +1 -1
- package/dist/engine/kolmoVehicleInner.js +31 -19
- package/dist/engine/kolmoVehicleInner.js.map +1 -1
- package/dist/engine/kolmoWorld.js +6 -2
- package/dist/engine/kolmoWorld.js.map +1 -1
- package/dist/engine/longDriveKit.d.ts +6 -1
- package/dist/engine/longDriveKit.js +8 -5
- package/dist/engine/longDriveKit.js.map +1 -1
- package/dist/engine/macroCellBuilder.d.ts +10 -0
- package/dist/engine/macroCellBuilder.js +101 -18
- package/dist/engine/macroCellBuilder.js.map +1 -1
- package/dist/engine/mainlandMacroCell.js +18 -9
- package/dist/engine/mainlandMacroCell.js.map +1 -1
- package/dist/importer/DomainWorkshopPanel.d.ts +3 -3
- package/dist/importer/DomainWorkshopPanel.js +148 -44
- package/dist/importer/DomainWorkshopPanel.js.map +1 -1
- package/dist/importer/GateHudBar.d.ts +2 -0
- package/dist/importer/GateHudBar.js +113 -35
- package/dist/importer/GateHudBar.js.map +1 -1
- package/dist/importer/GlbImportGate.js +16 -3
- package/dist/importer/GlbImportGate.js.map +1 -1
- package/dist/importer/LiveDrivePads.js +5 -3
- package/dist/importer/LiveDrivePads.js.map +1 -1
- package/dist/importer/Step1CalibrationPlinth.js +2 -2
- package/dist/importer/WheelRingHandles3D.js +2 -1
- package/dist/importer/WheelRingHandles3D.js.map +1 -1
- package/dist/importer/chopShopActions.js +20 -16
- package/dist/importer/chopShopActions.js.map +1 -1
- package/dist/importer/chopShopHandlers.js +16 -9
- package/dist/importer/chopShopHandlers.js.map +1 -1
- package/dist/importer/chopShopIoActions.d.ts +2 -0
- package/dist/importer/chopShopIoActions.js +33 -2
- package/dist/importer/chopShopIoActions.js.map +1 -1
- package/dist/importer/cylinderBooleanSlice.js.map +1 -1
- package/dist/importer/fusedWheelDetect.d.ts +2 -2
- package/dist/importer/fusedWheelDetect.js +227 -106
- package/dist/importer/fusedWheelDetect.js.map +1 -1
- package/dist/importer/fusedWheelFit.d.ts +6 -0
- package/dist/importer/fusedWheelFit.js +82 -1
- package/dist/importer/fusedWheelFit.js.map +1 -1
- package/dist/importer/gateStore.d.ts +2 -2
- package/dist/importer/gateStore.js +4 -3
- package/dist/importer/gateStore.js.map +1 -1
- package/dist/importer/glbNormalizer.js +5 -0
- package/dist/importer/glbNormalizer.js.map +1 -1
- package/dist/importer/importerWebMcpTools.js +3 -2
- package/dist/importer/importerWebMcpTools.js.map +1 -1
- package/dist/importer/index.d.ts +4 -2
- package/dist/importer/index.js +7 -3
- package/dist/importer/khrCarGeometryMass.d.ts +20 -0
- package/dist/importer/khrCarGeometryMass.js +125 -0
- package/dist/importer/khrCarGeometryMass.js.map +1 -0
- package/dist/importer/khrCarPlanHelpers.js +12 -22
- package/dist/importer/khrCarPlanHelpers.js.map +1 -1
- package/dist/importer/khrCarPlanner.js +52 -85
- package/dist/importer/khrCarPlanner.js.map +1 -1
- package/dist/importer/proceduralC12AndCraft.d.ts +18 -0
- package/dist/importer/proceduralC12AndCraft.js +302 -0
- package/dist/importer/proceduralC12AndCraft.js.map +1 -0
- package/dist/importer/proceduralDomainBuilders.d.ts +10 -0
- package/dist/importer/proceduralDomainBuilders.js +346 -0
- package/dist/importer/proceduralDomainBuilders.js.map +1 -0
- package/dist/importer/proceduralPersonAndProp.d.ts +8 -0
- package/dist/importer/proceduralPersonAndProp.js +303 -0
- package/dist/importer/proceduralPersonAndProp.js.map +1 -0
- package/dist/importer/starterScene.d.ts +3 -1
- package/dist/importer/starterScene.js +69 -13
- package/dist/importer/starterScene.js.map +1 -1
- package/dist/importer/universalGateBake.js +43 -11
- package/dist/importer/universalGateBake.js.map +1 -1
- package/dist/importer/useChopShopController.d.ts +3 -1
- package/dist/importer/useChopShopController.js +33 -18
- package/dist/importer/useChopShopController.js.map +1 -1
- package/dist/importer/useChopShopState.d.ts +1 -1
- package/dist/importer/useChopShopState.js +35 -9
- package/dist/importer/useChopShopState.js.map +1 -1
- package/dist/importer/wheelCutterHelpers.d.ts +7 -4
- package/dist/importer/wheelCutterHelpers.js +58 -28
- package/dist/importer/wheelCutterHelpers.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -7
- package/dist/junk/DestructibleTarget.js +9 -3
- package/dist/junk/DestructibleTarget.js.map +1 -1
- package/dist/junk/ShardPieces.js +10 -2
- package/dist/junk/ShardPieces.js.map +1 -1
- package/dist/junk/index.d.ts +1 -0
- package/dist/junk/index.js +2 -1
- package/dist/junk/junkProceduralScenes.d.ts +12 -0
- package/dist/junk/junkProceduralScenes.js +220 -0
- package/dist/junk/junkProceduralScenes.js.map +1 -0
- package/dist/sand3d/KolmoSand3D.d.ts +19 -0
- package/dist/sand3d/KolmoSand3D.js +92 -0
- package/dist/sand3d/KolmoSand3D.js.map +1 -0
- package/dist/sand3d/Sand3dWorkshopSection.d.ts +8 -0
- package/dist/sand3d/Sand3dWorkshopSection.js +117 -0
- package/dist/sand3d/Sand3dWorkshopSection.js.map +1 -0
- package/dist/sand3d/gateBakeHelpers.d.ts +21 -0
- package/dist/sand3d/gateBakeHelpers.js +225 -0
- package/dist/sand3d/gateBakeHelpers.js.map +1 -0
- package/dist/sand3d/gateDoorwayBake.d.ts +12 -0
- package/dist/sand3d/gateDoorwayBake.js +203 -0
- package/dist/sand3d/gateDoorwayBake.js.map +1 -0
- package/dist/sand3d/index.d.ts +3 -0
- package/dist/sand3d/index.js +4 -0
- package/dist/sand3d/index.js.map +1 -0
- package/dist/sand3d/sand3dAssetLoader.d.ts +28 -0
- package/dist/sand3d/sand3dAssetLoader.js +177 -0
- package/dist/sand3d/sand3dAssetLoader.js.map +1 -0
- package/dist/suika/KolmoSuikaOrb.d.ts +33 -0
- package/dist/suika/KolmoSuikaOrb.js +375 -0
- package/dist/suika/KolmoSuikaOrb.js.map +1 -0
- package/dist/suika/index.d.ts +4 -0
- package/dist/suika/index.js +5 -0
- package/dist/suika/index.js.map +1 -0
- package/dist/suika/suikaArbiter.d.ts +60 -0
- package/dist/suika/suikaArbiter.js +265 -0
- package/dist/suika/suikaArbiter.js.map +1 -0
- package/dist/suika/suikaGeometry.d.ts +10 -0
- package/dist/suika/suikaGeometry.js +251 -0
- package/dist/suika/suikaGeometry.js.map +1 -0
- package/dist/suika/suikaTypes.d.ts +74 -0
- package/dist/suika/suikaTypes.js +196 -0
- package/dist/suika/suikaTypes.js.map +1 -0
- package/dist/world/index.d.ts +1 -1
- package/dist/world/index.js +2 -2
- package/dist/world/worldTypes.d.ts +4 -0
- package/dist/world/worldTypes.js +21 -1
- package/dist/world/worldTypes.js.map +1 -1
- package/docs/api-reference.md +82 -125
- package/package.json +22 -11
- package/skills/kolmo-engine/SKILL.md +111 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kolmoInput.js","names":[],"sources":["../../src/engine/kolmoInput.ts"],"sourcesContent":["import React, { createContext, useCallback, useContext, useRef, type ReactNode } from \"react\";\nimport { useKeyboardControls, type KeyboardControlsEntry } from \"@react-three/drei\";\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 type KolmoInputState = Record<KolmoKeyAction, boolean>;\nexport type KolmoInputGetter = () => Partial<KolmoInputState>;\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});\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 { name: \"W\", keys: [\"KeyW\"] },\n { name: \"S\", keys: [\"KeyS\"] },\n { name: \"A\", keys: [\"KeyA\"] },\n { name: \"D\", keys: [\"KeyD\"] },\n { name: \"Space\", keys: [\"Space\"] },\n { name: \"Shift\", keys: [\"ShiftLeft\", \"ShiftRight\", \"Shift\"] },\n { name: \"F\", keys: [\"KeyF\"] },\n { name: \"R\", keys: [\"KeyR\"] },\n { name: \"Up\", keys: [\"ArrowUp\"] },\n { name: \"Down\", keys: [\"ArrowDown\"] },\n { name: \"Left\", keys: [\"ArrowLeft\"] },\n { name: \"Right\", keys: [\"ArrowRight\"] },\n];\n\n/**\n * Safe zero-allocation input reader that falls back cleanly to `EMPTY_KOLMO_INPUT`\n * when `<KeyboardControls>` is omitted (`keyboardMap={null}` or `<KolmoPhysics>`),\n * and merges optional caller `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
|
|
1
|
+
{"version":3,"file":"kolmoInput.js","names":[],"sources":["../../src/engine/kolmoInput.ts"],"sourcesContent":["import React, { createContext, useCallback, useContext, useRef, type ReactNode } from \"react\";\nimport { useKeyboardControls, type KeyboardControlsEntry } from \"@react-three/drei\";\nimport { applyKolmoTouchLook, kolmoTouchInput } from \"./kolmoTouchState.js\";\n\nexport { applyKolmoTouchLook };\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 type KolmoInputState = Record<KolmoKeyAction, boolean>;\nexport type KolmoInputGetter = () => Partial<KolmoInputState>;\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});\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 { name: \"W\", keys: [\"KeyW\"] },\n { name: \"S\", keys: [\"KeyS\"] },\n { name: \"A\", keys: [\"KeyA\"] },\n { name: \"D\", keys: [\"KeyD\"] },\n { name: \"Space\", keys: [\"Space\"] },\n { name: \"Shift\", keys: [\"ShiftLeft\", \"ShiftRight\", \"Shift\"] },\n { name: \"F\", keys: [\"KeyF\"] },\n { name: \"R\", keys: [\"KeyR\"] },\n { name: \"Up\", keys: [\"ArrowUp\"] },\n { name: \"Down\", keys: [\"ArrowDown\"] },\n { name: \"Left\", keys: [\"ArrowLeft\"] },\n { name: \"Right\", keys: [\"ArrowRight\"] },\n];\n\n/**\n * Safe zero-allocation input reader that falls back cleanly to `EMPTY_KOLMO_INPUT`\n * when `<KeyboardControls>` is omitted (`keyboardMap={null}` or `<KolmoPhysics>`),\n * and merges optional caller `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 Record<string, boolean>);\n const out = outRef.current;\n out.forward = Boolean(custom?.forward ?? (k.forward || k.W || k.Up || kolmoTouchInput.forward));\n out.backward = Boolean(custom?.backward ?? (k.backward || k.S || k.Down || kolmoTouchInput.backward));\n out.left = Boolean(custom?.left ?? (k.left || k.A || k.Left || kolmoTouchInput.left));\n out.right = Boolean(custom?.right ?? (k.right || k.D || k.Right || kolmoTouchInput.right));\n out.brake = Boolean(custom?.brake ?? (k.brake || k.Space || kolmoTouchInput.brake));\n out.boost = Boolean(custom?.boost ?? (k.boost || k.Shift || kolmoTouchInput.boost));\n out.interact = Boolean(custom?.interact ?? (k.interact || k.F || kolmoTouchInput.interact));\n out.turnLeft = Boolean(custom?.turnLeft ?? k.turnLeft);\n out.turnRight = Boolean(custom?.turnRight ?? k.turnRight);\n out.descend = Boolean(custom?.descend ?? (k.descend || kolmoTouchInput.descend));\n out.cameraView = Boolean(custom?.cameraView ?? (k.cameraView || kolmoTouchInput.cameraView));\n out.reset = Boolean(custom?.reset ?? (k.reset || k.R || kolmoTouchInput.reset));\n out.modeToggle = Boolean(custom?.modeToggle ?? (k.modeToggle || kolmoTouchInput.modeToggle));\n return out;\n }, [getKeyboard]);\n}\n"],"mappings":";;;;AAMA,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;AAoBA,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;AAChB,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;CA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F,IAAI,WAAW,QAAQ,QAAQ,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,gBAAgB,SAAS;EACpG,IAAI,OAAO,QAAQ,QAAQ,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,gBAAgB,KAAK;EACpF,IAAI,QAAQ,QAAQ,QAAQ,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,gBAAgB,MAAM;EACzF,IAAI,QAAQ,QAAQ,QAAQ,UAAU,EAAE,SAAS,EAAE,SAAS,gBAAgB,MAAM;EAClF,IAAI,QAAQ,QAAQ,QAAQ,UAAU,EAAE,SAAS,EAAE,SAAS,gBAAgB,MAAM;EAClF,IAAI,WAAW,QAAQ,QAAQ,aAAa,EAAE,YAAY,EAAE,KAAK,gBAAgB,SAAS;EAC1F,IAAI,WAAW,QAAQ,QAAQ,YAAY,EAAE,QAAQ;EACrD,IAAI,YAAY,QAAQ,QAAQ,aAAa,EAAE,SAAS;EACxD,IAAI,UAAU,QAAQ,QAAQ,YAAY,EAAE,WAAW,gBAAgB,QAAQ;EAC/E,IAAI,aAAa,QAAQ,QAAQ,eAAe,EAAE,cAAc,gBAAgB,WAAW;EAC3F,IAAI,QAAQ,QAAQ,QAAQ,UAAU,EAAE,SAAS,EAAE,KAAK,gBAAgB,MAAM;EAC9E,IAAI,aAAa,QAAQ,QAAQ,eAAe,EAAE,cAAc,gBAAgB,WAAW;EAC3F,OAAO;CACX,GAAG,CAAC,WAAW,CAAC;AACpB"}
|
|
@@ -3,7 +3,7 @@ import { InfiniteLongDrivePlanner } from "../world/infiniteWorld2D.js";
|
|
|
3
3
|
import { computeLongDriveBridgeheadSpawn, computeLongDriveMainlandSpawn } from "./causewayBridge.js";
|
|
4
4
|
export { computeLongDriveBridgeheadSpawn, computeLongDriveMainlandSpawn };
|
|
5
5
|
export interface KolmoLongDriveProps {
|
|
6
|
-
readonly seed?: number;
|
|
6
|
+
readonly seed?: string | number;
|
|
7
7
|
readonly pureMainland?: boolean;
|
|
8
8
|
readonly initialOrigin?: readonly [number, number];
|
|
9
9
|
readonly onOriginRebase?: (originX: number, originZ: number, dx: number, dz: number) => void;
|
|
@@ -2,7 +2,7 @@ import { createPS2RoadMaterialWebGL } from "../shaders/ps2RoadWebGL.js";
|
|
|
2
2
|
import { createPS2WorldTextures } from "../shaders/ps2Textures.js";
|
|
3
3
|
import { InfiniteLongDrivePlanner } from "../world/infiniteWorld2D.js";
|
|
4
4
|
import { MACRO_SIZE_M, quantizeFloatingOrigin192 } from "../world/macroCellSchema.js";
|
|
5
|
-
import { bakeWorldSplatMaps } from "../world/worldTypes.js";
|
|
5
|
+
import { bakeWorldSplatMaps, hashSeed } from "../world/worldTypes.js";
|
|
6
6
|
import { CausewayBridge, computeLongDriveBridgeheadSpawn, computeLongDriveMainlandSpawn } from "./causewayBridge.js";
|
|
7
7
|
import { getCachedIslandPlan } from "./islandSettlementMesh.js";
|
|
8
8
|
import { KolmoIsland } from "./kolmoIsland.js";
|
|
@@ -18,20 +18,22 @@ function KolmoLongDrive({ seed = 77, pureMainland = false, initialOrigin = [0, 0
|
|
|
18
18
|
const activeWorld = useActiveKolmoWorld();
|
|
19
19
|
const camera = useThree((s) => s.camera);
|
|
20
20
|
const rapier = useRapier();
|
|
21
|
+
const numericSeed = useMemo(() => hashSeed(seed), [seed]);
|
|
21
22
|
const planner = useMemo(() => {
|
|
22
23
|
const p = new InfiniteLongDrivePlanner(seed);
|
|
23
|
-
if (!activeWorld.has(WorldSpawnTrait)) publishWorldSpawn(activeWorld, pureMainland ? computeLongDriveMainlandSpawn(
|
|
24
|
+
if (!activeWorld.has(WorldSpawnTrait)) publishWorldSpawn(activeWorld, pureMainland ? computeLongDriveMainlandSpawn(numericSeed, 1, 0) : computeLongDriveBridgeheadSpawn(numericSeed, 960));
|
|
24
25
|
return p;
|
|
25
26
|
}, [
|
|
26
27
|
seed,
|
|
28
|
+
numericSeed,
|
|
27
29
|
pureMainland,
|
|
28
30
|
activeWorld
|
|
29
31
|
]);
|
|
30
32
|
useEffect(() => {
|
|
31
|
-
publishWorldSpawn(activeWorld, pureMainland ? computeLongDriveMainlandSpawn(
|
|
33
|
+
publishWorldSpawn(activeWorld, pureMainland ? computeLongDriveMainlandSpawn(numericSeed, 1, 0) : computeLongDriveBridgeheadSpawn(numericSeed, 960));
|
|
32
34
|
}, [
|
|
33
35
|
activeWorld,
|
|
34
|
-
|
|
36
|
+
numericSeed,
|
|
35
37
|
pureMainland
|
|
36
38
|
]);
|
|
37
39
|
const [origin, setOrigin] = useState(initialOrigin);
|
|
@@ -52,13 +54,13 @@ function KolmoLongDrive({ seed = 77, pureMainland = false, initialOrigin = [0, 0
|
|
|
52
54
|
] : [[1, 0]];
|
|
53
55
|
});
|
|
54
56
|
const roadRes = useMemo(() => {
|
|
55
|
-
const island = getCachedIslandPlan(
|
|
57
|
+
const island = getCachedIslandPlan(numericSeed, 960);
|
|
56
58
|
const tex = createPS2WorldTextures(bakeWorldSplatMaps(island, 64));
|
|
57
59
|
return {
|
|
58
60
|
tex,
|
|
59
61
|
roadMat: createPS2RoadMaterialWebGL(tex, { preset: "ASPHALT" }).material
|
|
60
62
|
};
|
|
61
|
-
}, [
|
|
63
|
+
}, [numericSeed]);
|
|
62
64
|
useEffect(() => () => {
|
|
63
65
|
roadRes.roadMat.dispose();
|
|
64
66
|
roadRes.tex.dispose();
|
|
@@ -126,7 +128,7 @@ function KolmoLongDrive({ seed = 77, pureMainland = false, initialOrigin = [0, 0
|
|
|
126
128
|
const offX = -origin[0], offZ = -origin[1];
|
|
127
129
|
return /* @__PURE__ */ jsxs("group", { children: [
|
|
128
130
|
!pureMainland && focusCell[0] <= 1 && Math.abs(focusCell[1]) <= 1 && /* @__PURE__ */ jsx(KolmoIsland, {
|
|
129
|
-
seed,
|
|
131
|
+
seed: numericSeed,
|
|
130
132
|
size: 960,
|
|
131
133
|
segments: 144,
|
|
132
134
|
settlementTier: "town",
|
|
@@ -135,7 +137,7 @@ function KolmoLongDrive({ seed = 77, pureMainland = false, initialOrigin = [0, 0
|
|
|
135
137
|
autoSpawn: false
|
|
136
138
|
}),
|
|
137
139
|
!pureMainland && focusCell[0] <= 2 && Math.abs(focusCell[1]) <= 1 && /* @__PURE__ */ jsx(CausewayBridge, {
|
|
138
|
-
seed,
|
|
140
|
+
seed: numericSeed,
|
|
139
141
|
islandSize: 960,
|
|
140
142
|
planner,
|
|
141
143
|
roadMat: roadRes.roadMat,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kolmoLongDrive.js","names":[],"sources":["../../src/engine/kolmoLongDrive.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useFrame, useThree } from \"@react-three/fiber\";\nimport { useRapier } from \"@react-three/rapier\";\nimport { createPS2RoadMaterialWebGL } from \"../shaders/ps2RoadWebGL.js\";\nimport { createPS2WorldTextures } from \"../shaders/ps2Textures.js\";\nimport { InfiniteLongDrivePlanner } from \"../world/infiniteWorld2D.js\";\nimport { MACRO_SIZE_M, quantizeFloatingOrigin192 } from \"../world/macroCellSchema.js\";\nimport { bakeWorldSplatMaps } from \"../world/worldTypes.js\";\nimport {\n CausewayBridge,\n computeLongDriveBridgeheadSpawn,\n computeLongDriveMainlandSpawn,\n} from \"./causewayBridge.js\";\nimport { KolmoIsland, getCachedIslandPlan } from \"./kolmoIsland.js\";\nimport { WorldSpawnTrait, publishWorldSpawn, readFloatingOriginAnchorXZ, shiftFloatingOriginEntities, useActiveKolmoWorld } from \"./kolmoStore.js\";\nimport { MainlandMacroCell } from \"./mainlandMacroCell.js\";\n\nexport { computeLongDriveBridgeheadSpawn, computeLongDriveMainlandSpawn };\n\nexport interface KolmoLongDriveProps {\n readonly seed?: number;\n readonly pureMainland?: boolean;\n readonly initialOrigin?: readonly [number, number];\n readonly onOriginRebase?: (originX: number, originZ: number, dx: number, dz: number) => void;\n readonly renderCellExtra?: (\n mx: number,\n mz: number,\n plan: ReturnType<InfiniteLongDrivePlanner[\"generateMacroCell2D\"]>,\n offX: number,\n offZ: number,\n ) => React.ReactNode;\n}\n\nexport function KolmoLongDrive({\n seed = 77,\n pureMainland = false,\n initialOrigin = [0, 0],\n onOriginRebase,\n renderCellExtra,\n}: KolmoLongDriveProps): React.JSX.Element {\n const activeWorld = useActiveKolmoWorld();\n const camera = useThree((s) => s.camera);\n const rapier = useRapier();\n const planner = useMemo(() => {\n const p = new InfiniteLongDrivePlanner(seed);\n if (!activeWorld.has(WorldSpawnTrait)) {\n publishWorldSpawn(\n activeWorld,\n pureMainland ? computeLongDriveMainlandSpawn(seed, 1, 0) : computeLongDriveBridgeheadSpawn(seed, 960),\n );\n }\n return p;\n }, [seed, pureMainland, activeWorld]);\n\n useEffect(() => {\n publishWorldSpawn(\n activeWorld,\n pureMainland ? computeLongDriveMainlandSpawn(seed, 1, 0) : computeLongDriveBridgeheadSpawn(seed, 960),\n );\n }, [activeWorld, seed, pureMainland]);\n\n const [origin, setOrigin] = useState<readonly [number, number]>(initialOrigin);\n const appliedRef = useRef<[number, number]>([initialOrigin[0], initialOrigin[1]]);\n const targetRef = useRef<[number, number]>([initialOrigin[0], initialOrigin[1]]);\n const anchorRef = useRef<[number, number]>([0, 0]);\n const initFx = Math.max(+pureMainland, Math.round(initialOrigin[0] / MACRO_SIZE_M));\n const initFz = Math.round(initialOrigin[1] / MACRO_SIZE_M);\n const [focusCell, setFocusCell] = useState<[number, number]>([initFx, initFz]);\n const focusCellRef = useRef<[number, number]>([initFx, initFz]);\n const [mountedCells, setMountedCells] = useState<Array<[number, number]>>(() => {\n const cx = Math.max(1, initFx);\n return pureMainland ? [[cx, initFz], [cx, initFz - 1], [cx, initFz + 1], [cx + 1, initFz]] : [[1, 0]];\n });\n\n const roadRes = useMemo(() => {\n const island = getCachedIslandPlan(seed, 960);\n const tex = createPS2WorldTextures(bakeWorldSplatMaps(island, 64));\n return { tex, roadMat: createPS2RoadMaterialWebGL(tex, { preset: \"ASPHALT\" }).material };\n }, [seed]);\n\n useEffect(() => () => { roadRes.roadMat.dispose(); roadRes.tex.dispose(); }, [roadRes]);\n\n const desiredCells = useMemo(() => {\n const [fx, fz] = focusCell, cells: Array<[number, number]> = [];\n for (let dx = -1; dx <= 1; dx++) {\n for (let dz = -1; dz <= 1; dz++) {\n const mx = fx + dx, mz = fz + dz;\n if (mx >= 1) cells.push([mx, mz]);\n }\n }\n cells.sort((a, b) => Math.hypot(a[0] - fx, a[1] - fz) - Math.hypot(b[0] - fx, b[1] - fz));\n return cells;\n }, [focusCell]);\n\n useEffect(() => {\n if (typeof requestAnimationFrame !== \"function\") {\n setMountedCells(desiredCells);\n return;\n }\n let raf = 0;\n const stepStream = (): void => {\n let needsMore = false;\n setMountedCells((prev) => {\n const kept = prev.filter(([mx, mz]) => desiredCells.some(([dx, dz]) => dx === mx && dz === mz));\n const nextAdd = desiredCells.find(([dx, dz]) => !kept.some(([kx, kz]) => kx === dx && kz === dz));\n if (!nextAdd && kept.length === prev.length) return prev;\n const next = nextAdd ? [...kept, nextAdd] : kept;\n needsMore = next.length < desiredCells.length;\n return next;\n });\n if (needsMore) raf = requestAnimationFrame(stepStream);\n };\n raf = requestAnimationFrame(stepStream);\n return () => cancelAnimationFrame(raf);\n }, [desiredCells]);\n\n useEffect(() => {\n const dx = origin[0] - appliedRef.current[0], dz = origin[1] - appliedRef.current[1];\n if (dx !== 0 || dz !== 0) {\n appliedRef.current = [origin[0], origin[1]];\n targetRef.current = [origin[0], origin[1]];\n shiftFloatingOriginEntities(activeWorld, camera, dx, dz, rapier as never);\n onOriginRebase?.(origin[0], origin[1], dx, dz);\n }\n }, [origin, activeWorld, camera, rapier, onOriginRebase]);\n\n useFrame(() => {\n const [ox, oz] = appliedRef.current;\n const anchor = readFloatingOriginAnchorXZ(activeWorld, camera, anchorRef.current);\n const worldX = ox + anchor[0], worldZ = oz + anchor[1];\n const q = quantizeFloatingOrigin192(worldX, worldZ);\n if (\n (Math.abs(q.chunkOriginX - ox) >= 192 || Math.abs(q.chunkOriginZ - oz) >= 192) &&\n (q.chunkOriginX !== targetRef.current[0] || q.chunkOriginZ !== targetRef.current[1])\n ) {\n targetRef.current = [q.chunkOriginX, q.chunkOriginZ];\n setOrigin([q.chunkOriginX, q.chunkOriginZ]);\n }\n const fx = Math.max(+pureMainland, Math.round(worldX / MACRO_SIZE_M)), fz = Math.round(worldZ / MACRO_SIZE_M);\n if (fx !== focusCellRef.current[0] || fz !== focusCellRef.current[1]) {\n focusCellRef.current = [fx, fz];\n setFocusCell([fx, fz]);\n }\n });\n\n const offX = -origin[0], offZ = -origin[1];\n\n return (\n <group>\n {!pureMainland && focusCell[0] <= 1 && Math.abs(focusCell[1]) <= 1 && (\n <KolmoIsland seed={seed} size={960} segments={144} settlementTier=\"town\" offX={offX} offZ={offZ} autoSpawn={false} />\n )}\n {!pureMainland && focusCell[0] <= 2 && Math.abs(focusCell[1]) <= 1 && (\n <CausewayBridge seed={seed} islandSize={960} planner={planner} roadMat={roadRes.roadMat} offX={offX} offZ={offZ} />\n )}\n {mountedCells.map(([mx, mz]) => (\n <MainlandMacroCell\n key={`mc_${mx}_${mz}`} mx={mx} mz={mz} planner={planner} roadMat={roadRes.roadMat}\n offX={offX} offZ={offZ} renderExtra={renderCellExtra}\n />\n ))}\n </group>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiCA,SAAgB,eAAe,EAC3B,OAAO,IACP,eAAe,OACf,gBAAgB,CAAC,GAAG,CAAC,GACrB,gBACA,mBACuC;CACvC,MAAM,cAAc,oBAAoB;CACxC,MAAM,SAAS,UAAU,MAAM,EAAE,MAAM;CACvC,MAAM,SAAS,UAAU;CACzB,MAAM,UAAU,cAAc;EAC1B,MAAM,IAAI,IAAI,yBAAyB,IAAI;EAC3C,IAAI,CAAC,YAAY,IAAI,eAAe,GAChC,kBACI,aACA,eAAe,8BAA8B,MAAM,GAAG,CAAC,IAAI,gCAAgC,MAAM,GAAG,CACxG;EAEJ,OAAO;CACX,GAAG;EAAC;EAAM;EAAc;CAA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GAAM,WAAW;EAAQ,CAAA;EAEvH,CAAC,gBAAgB,UAAU,MAAM,KAAK,KAAK,IAAI,UAAU,EAAE,KAAK,KAC7D,oBAAC,gBAAD;GAAsB;GAAM,YAAY;GAAc;GAAS,SAAS,QAAQ;GAAe;GAAY;EAAO,CAAA;EAErH,aAAa,KAAK,CAAC,IAAI,QACpB,oBAAC,mBAAD;GAC+B;GAAQ;GAAa;GAAS,SAAS,QAAQ;GACpE;GAAY;GAAM,aAAa;EACxC,GAFQ,MAAM,GAAG,GAAG,IAEpB,CACJ;CACE,EAAA,CAAA;AAEf"}
|
|
1
|
+
{"version":3,"file":"kolmoLongDrive.js","names":[],"sources":["../../src/engine/kolmoLongDrive.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useFrame, useThree } from \"@react-three/fiber\";\nimport { useRapier } from \"@react-three/rapier\";\nimport { createPS2RoadMaterialWebGL } from \"../shaders/ps2RoadWebGL.js\";\nimport { createPS2WorldTextures } from \"../shaders/ps2Textures.js\";\nimport { InfiniteLongDrivePlanner } from \"../world/infiniteWorld2D.js\";\nimport { MACRO_SIZE_M, quantizeFloatingOrigin192 } from \"../world/macroCellSchema.js\";\nimport { bakeWorldSplatMaps, hashSeed } from \"../world/worldTypes.js\";\nimport {\n CausewayBridge,\n computeLongDriveBridgeheadSpawn,\n computeLongDriveMainlandSpawn,\n} from \"./causewayBridge.js\";\nimport { KolmoIsland, getCachedIslandPlan } from \"./kolmoIsland.js\";\nimport { WorldSpawnTrait, publishWorldSpawn, readFloatingOriginAnchorXZ, shiftFloatingOriginEntities, useActiveKolmoWorld } from \"./kolmoStore.js\";\nimport { MainlandMacroCell } from \"./mainlandMacroCell.js\";\n\nexport { computeLongDriveBridgeheadSpawn, computeLongDriveMainlandSpawn };\n\nexport interface KolmoLongDriveProps {\n readonly seed?: string | number;\n readonly pureMainland?: boolean;\n readonly initialOrigin?: readonly [number, number];\n readonly onOriginRebase?: (originX: number, originZ: number, dx: number, dz: number) => void;\n readonly renderCellExtra?: (\n mx: number,\n mz: number,\n plan: ReturnType<InfiniteLongDrivePlanner[\"generateMacroCell2D\"]>,\n offX: number,\n offZ: number,\n ) => React.ReactNode;\n}\n\nexport function KolmoLongDrive({\n seed = 77,\n pureMainland = false,\n initialOrigin = [0, 0],\n onOriginRebase,\n renderCellExtra,\n}: KolmoLongDriveProps): React.JSX.Element {\n const activeWorld = useActiveKolmoWorld();\n const camera = useThree((s) => s.camera);\n const rapier = useRapier();\n const numericSeed = useMemo(() => hashSeed(seed), [seed]);\n const planner = useMemo(() => {\n const p = new InfiniteLongDrivePlanner(seed);\n if (!activeWorld.has(WorldSpawnTrait)) {\n publishWorldSpawn(\n activeWorld,\n pureMainland ? computeLongDriveMainlandSpawn(numericSeed, 1, 0) : computeLongDriveBridgeheadSpawn(numericSeed, 960),\n );\n }\n return p;\n }, [seed, numericSeed, pureMainland, activeWorld]);\n\n useEffect(() => {\n publishWorldSpawn(\n activeWorld,\n pureMainland ? computeLongDriveMainlandSpawn(numericSeed, 1, 0) : computeLongDriveBridgeheadSpawn(numericSeed, 960),\n );\n }, [activeWorld, numericSeed, pureMainland]);\n\n const [origin, setOrigin] = useState<readonly [number, number]>(initialOrigin);\n const appliedRef = useRef<[number, number]>([initialOrigin[0], initialOrigin[1]]);\n const targetRef = useRef<[number, number]>([initialOrigin[0], initialOrigin[1]]);\n const anchorRef = useRef<[number, number]>([0, 0]);\n const initFx = Math.max(+pureMainland, Math.round(initialOrigin[0] / MACRO_SIZE_M));\n const initFz = Math.round(initialOrigin[1] / MACRO_SIZE_M);\n const [focusCell, setFocusCell] = useState<[number, number]>([initFx, initFz]);\n const focusCellRef = useRef<[number, number]>([initFx, initFz]);\n const [mountedCells, setMountedCells] = useState<Array<[number, number]>>(() => {\n const cx = Math.max(1, initFx);\n return pureMainland ? [[cx, initFz], [cx, initFz - 1], [cx, initFz + 1], [cx + 1, initFz]] : [[1, 0]];\n });\n\n const roadRes = useMemo(() => {\n const island = getCachedIslandPlan(numericSeed, 960);\n const tex = createPS2WorldTextures(bakeWorldSplatMaps(island, 64));\n return { tex, roadMat: createPS2RoadMaterialWebGL(tex, { preset: \"ASPHALT\" }).material };\n }, [numericSeed]);\n\n useEffect(() => () => { roadRes.roadMat.dispose(); roadRes.tex.dispose(); }, [roadRes]);\n\n const desiredCells = useMemo(() => {\n const [fx, fz] = focusCell, cells: Array<[number, number]> = [];\n for (let dx = -1; dx <= 1; dx++) {\n for (let dz = -1; dz <= 1; dz++) {\n const mx = fx + dx, mz = fz + dz;\n if (mx >= 1) cells.push([mx, mz]);\n }\n }\n cells.sort((a, b) => Math.hypot(a[0] - fx, a[1] - fz) - Math.hypot(b[0] - fx, b[1] - fz));\n return cells;\n }, [focusCell]);\n\n useEffect(() => {\n if (typeof requestAnimationFrame !== \"function\") {\n setMountedCells(desiredCells);\n return;\n }\n let raf = 0;\n const stepStream = (): void => {\n let needsMore = false;\n setMountedCells((prev) => {\n const kept = prev.filter(([mx, mz]) => desiredCells.some(([dx, dz]) => dx === mx && dz === mz));\n const nextAdd = desiredCells.find(([dx, dz]) => !kept.some(([kx, kz]) => kx === dx && kz === dz));\n if (!nextAdd && kept.length === prev.length) return prev;\n const next = nextAdd ? [...kept, nextAdd] : kept;\n needsMore = next.length < desiredCells.length;\n return next;\n });\n if (needsMore) raf = requestAnimationFrame(stepStream);\n };\n raf = requestAnimationFrame(stepStream);\n return () => cancelAnimationFrame(raf);\n }, [desiredCells]);\n\n useEffect(() => {\n const dx = origin[0] - appliedRef.current[0], dz = origin[1] - appliedRef.current[1];\n if (dx !== 0 || dz !== 0) {\n appliedRef.current = [origin[0], origin[1]];\n targetRef.current = [origin[0], origin[1]];\n shiftFloatingOriginEntities(activeWorld, camera, dx, dz, rapier as never);\n onOriginRebase?.(origin[0], origin[1], dx, dz);\n }\n }, [origin, activeWorld, camera, rapier, onOriginRebase]);\n\n useFrame(() => {\n const [ox, oz] = appliedRef.current;\n const anchor = readFloatingOriginAnchorXZ(activeWorld, camera, anchorRef.current);\n const worldX = ox + anchor[0], worldZ = oz + anchor[1];\n const q = quantizeFloatingOrigin192(worldX, worldZ);\n if (\n (Math.abs(q.chunkOriginX - ox) >= 192 || Math.abs(q.chunkOriginZ - oz) >= 192) &&\n (q.chunkOriginX !== targetRef.current[0] || q.chunkOriginZ !== targetRef.current[1])\n ) {\n targetRef.current = [q.chunkOriginX, q.chunkOriginZ];\n setOrigin([q.chunkOriginX, q.chunkOriginZ]);\n }\n const fx = Math.max(+pureMainland, Math.round(worldX / MACRO_SIZE_M)), fz = Math.round(worldZ / MACRO_SIZE_M);\n if (fx !== focusCellRef.current[0] || fz !== focusCellRef.current[1]) {\n focusCellRef.current = [fx, fz];\n setFocusCell([fx, fz]);\n }\n });\n\n const offX = -origin[0], offZ = -origin[1];\n\n return (\n <group>\n {!pureMainland && focusCell[0] <= 1 && Math.abs(focusCell[1]) <= 1 && (\n <KolmoIsland seed={numericSeed} size={960} segments={144} settlementTier=\"town\" offX={offX} offZ={offZ} autoSpawn={false} />\n )}\n {!pureMainland && focusCell[0] <= 2 && Math.abs(focusCell[1]) <= 1 && (\n <CausewayBridge seed={numericSeed} islandSize={960} planner={planner} roadMat={roadRes.roadMat} offX={offX} offZ={offZ} />\n )}\n {mountedCells.map(([mx, mz]) => (\n <MainlandMacroCell\n key={`mc_${mx}_${mz}`} mx={mx} mz={mz} planner={planner} roadMat={roadRes.roadMat}\n offX={offX} offZ={offZ} renderExtra={renderCellExtra}\n />\n ))}\n </group>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiCA,SAAgB,eAAe,EAC3B,OAAO,IACP,eAAe,OACf,gBAAgB,CAAC,GAAG,CAAC,GACrB,gBACA,mBACuC;CACvC,MAAM,cAAc,oBAAoB;CACxC,MAAM,SAAS,UAAU,MAAM,EAAE,MAAM;CACvC,MAAM,SAAS,UAAU;CACzB,MAAM,cAAc,cAAc,SAAS,IAAI,GAAG,CAAC,IAAI,CAAC;CACxD,MAAM,U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OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO;CAExC,OACI,qBAAC,SAAD,EAAA,UAAA;EACK,CAAC,gBAAgB,UAAU,MAAM,KAAK,KAAK,IAAI,UAAU,EAAE,KAAK,KAC7D,oBAAC,aAAD;GAAa,MAAM;GAAa,MAAM;GAAK,UAAU;GAAK,gBAAe;GAAa;GAAY;GAAM,WAAW;EAAQ,CAAA;EAE9H,CAAC,gBAAgB,UAAU,MAAM,KAAK,KAAK,IAAI,UAAU,EAAE,KAAK,KAC7D,oBAAC,gBAAD;GAAgB,MAAM;GAAa,YAAY;GAAc;GAAS,SAAS,QAAQ;GAAe;GAAY;EAAO,CAAA;EAE5H,aAAa,KAAK,CAAC,IAAI,QACpB,oBAAC,mBAAD;GAC+B;GAAQ;GAAa;GAAS,SAAS,QAAQ;GACpE;GAAY;GAAM,aAAa;EACxC,GAFQ,MAAM,GAAG,GAAG,IAEpB,CACJ;CACE,EAAA,CAAA;AAEf"}
|
|
@@ -4,60 +4,201 @@ import * as THREE from "three";
|
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
// src/engine/kolmoPilotMesh.tsx
|
|
6
6
|
function DefaultPilotMesh() {
|
|
7
|
-
const res = useMemo(() =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
const res = useMemo(() => {
|
|
8
|
+
return {
|
|
9
|
+
limbGeo: new THREE.CylinderGeometry(.068, .056, .34, 8),
|
|
10
|
+
legGeo: new THREE.CylinderGeometry(.082, .068, .38, 8),
|
|
11
|
+
bootGeo: new THREE.BoxGeometry(.14, .1, .22),
|
|
12
|
+
torsoGeo: new THREE.BoxGeometry(.36, .38, .22),
|
|
13
|
+
hipGeo: new THREE.BoxGeometry(.3, .13, .19),
|
|
14
|
+
shoulderGeo: new THREE.BoxGeometry(.13, .1, .16),
|
|
15
|
+
helmGeo: new THREE.CylinderGeometry(.135, .145, .22, 8),
|
|
16
|
+
visorGeo: new THREE.BoxGeometry(.21, .085, .06),
|
|
17
|
+
packGeo: new THREE.BoxGeometry(.24, .3, .12),
|
|
18
|
+
suitMat: applyRetroMaterial(new THREE.MeshStandardMaterial({
|
|
19
|
+
color: "#cbd5e1",
|
|
20
|
+
roughness: .62,
|
|
21
|
+
metalness: .12,
|
|
22
|
+
flatShading: true
|
|
23
|
+
}), { flatShading: true }),
|
|
24
|
+
trimMat: applyRetroMaterial(new THREE.MeshStandardMaterial({
|
|
25
|
+
color: "#334155",
|
|
26
|
+
roughness: .72,
|
|
27
|
+
metalness: .2,
|
|
28
|
+
flatShading: true
|
|
29
|
+
}), { flatShading: true }),
|
|
30
|
+
visorMat: applyRetroMaterial(new THREE.MeshStandardMaterial({
|
|
31
|
+
color: "#38bdf8",
|
|
32
|
+
emissive: "#0284c7",
|
|
33
|
+
emissiveIntensity: .55,
|
|
34
|
+
roughness: .22
|
|
35
|
+
})),
|
|
36
|
+
bootMat: applyRetroMaterial(new THREE.MeshStandardMaterial({
|
|
37
|
+
color: "#1e293b",
|
|
38
|
+
roughness: .8,
|
|
39
|
+
flatShading: true
|
|
40
|
+
}), { flatShading: true })
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
27
43
|
useLayoutEffect(() => () => {
|
|
28
|
-
res.
|
|
44
|
+
res.limbGeo.dispose();
|
|
45
|
+
res.legGeo.dispose();
|
|
46
|
+
res.bootGeo.dispose();
|
|
47
|
+
res.torsoGeo.dispose();
|
|
48
|
+
res.hipGeo.dispose();
|
|
49
|
+
res.shoulderGeo.dispose();
|
|
50
|
+
res.helmGeo.dispose();
|
|
29
51
|
res.visorGeo.dispose();
|
|
30
52
|
res.packGeo.dispose();
|
|
31
53
|
res.suitMat.dispose();
|
|
54
|
+
res.trimMat.dispose();
|
|
32
55
|
res.visorMat.dispose();
|
|
33
|
-
res.
|
|
56
|
+
res.bootMat.dispose();
|
|
34
57
|
}, [res]);
|
|
35
|
-
return /* @__PURE__ */ jsxs("group", {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
return /* @__PURE__ */ jsxs("group", {
|
|
59
|
+
name: "KolmoPilotRig",
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
62
|
+
position: [
|
|
63
|
+
0,
|
|
64
|
+
.44,
|
|
65
|
+
0
|
|
66
|
+
],
|
|
67
|
+
castShadow: true,
|
|
68
|
+
geometry: res.helmGeo,
|
|
69
|
+
material: res.suitMat
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
72
|
+
position: [
|
|
73
|
+
0,
|
|
74
|
+
.45,
|
|
75
|
+
.125
|
|
76
|
+
],
|
|
77
|
+
geometry: res.visorGeo,
|
|
78
|
+
material: res.visorMat
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
81
|
+
position: [
|
|
82
|
+
0,
|
|
83
|
+
.15,
|
|
84
|
+
0
|
|
85
|
+
],
|
|
86
|
+
castShadow: true,
|
|
87
|
+
geometry: res.torsoGeo,
|
|
88
|
+
material: res.suitMat
|
|
89
|
+
}),
|
|
90
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
91
|
+
position: [
|
|
92
|
+
0,
|
|
93
|
+
-.07,
|
|
94
|
+
0
|
|
95
|
+
],
|
|
96
|
+
castShadow: true,
|
|
97
|
+
geometry: res.hipGeo,
|
|
98
|
+
material: res.trimMat
|
|
99
|
+
}),
|
|
100
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
101
|
+
position: [
|
|
102
|
+
0,
|
|
103
|
+
.16,
|
|
104
|
+
-.15
|
|
105
|
+
],
|
|
106
|
+
castShadow: true,
|
|
107
|
+
geometry: res.packGeo,
|
|
108
|
+
material: res.trimMat
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
111
|
+
position: [
|
|
112
|
+
-.24,
|
|
113
|
+
.28,
|
|
114
|
+
0
|
|
115
|
+
],
|
|
116
|
+
castShadow: true,
|
|
117
|
+
geometry: res.shoulderGeo,
|
|
118
|
+
material: res.trimMat
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
121
|
+
position: [
|
|
122
|
+
.24,
|
|
123
|
+
.28,
|
|
124
|
+
0
|
|
125
|
+
],
|
|
126
|
+
castShadow: true,
|
|
127
|
+
geometry: res.shoulderGeo,
|
|
128
|
+
material: res.trimMat
|
|
129
|
+
}),
|
|
130
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
131
|
+
position: [
|
|
132
|
+
-.25,
|
|
133
|
+
.08,
|
|
134
|
+
.02
|
|
135
|
+
],
|
|
136
|
+
rotation: [
|
|
137
|
+
.1,
|
|
138
|
+
0,
|
|
139
|
+
.08
|
|
140
|
+
],
|
|
141
|
+
castShadow: true,
|
|
142
|
+
geometry: res.limbGeo,
|
|
143
|
+
material: res.suitMat
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
146
|
+
position: [
|
|
147
|
+
.25,
|
|
148
|
+
.08,
|
|
149
|
+
.02
|
|
150
|
+
],
|
|
151
|
+
rotation: [
|
|
152
|
+
.1,
|
|
153
|
+
0,
|
|
154
|
+
-.08
|
|
155
|
+
],
|
|
156
|
+
castShadow: true,
|
|
157
|
+
geometry: res.limbGeo,
|
|
158
|
+
material: res.suitMat
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
161
|
+
position: [
|
|
162
|
+
-.1,
|
|
163
|
+
-.32,
|
|
164
|
+
0
|
|
165
|
+
],
|
|
166
|
+
castShadow: true,
|
|
167
|
+
geometry: res.legGeo,
|
|
168
|
+
material: res.suitMat
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
171
|
+
position: [
|
|
172
|
+
.1,
|
|
173
|
+
-.32,
|
|
174
|
+
0
|
|
175
|
+
],
|
|
176
|
+
castShadow: true,
|
|
177
|
+
geometry: res.legGeo,
|
|
178
|
+
material: res.suitMat
|
|
179
|
+
}),
|
|
180
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
181
|
+
position: [
|
|
182
|
+
-.1,
|
|
183
|
+
-.53,
|
|
184
|
+
.03
|
|
185
|
+
],
|
|
186
|
+
castShadow: true,
|
|
187
|
+
geometry: res.bootGeo,
|
|
188
|
+
material: res.bootMat
|
|
189
|
+
}),
|
|
190
|
+
/* @__PURE__ */ jsx("mesh", {
|
|
191
|
+
position: [
|
|
192
|
+
.1,
|
|
193
|
+
-.53,
|
|
194
|
+
.03
|
|
195
|
+
],
|
|
196
|
+
castShadow: true,
|
|
197
|
+
geometry: res.bootGeo,
|
|
198
|
+
material: res.bootMat
|
|
199
|
+
})
|
|
200
|
+
]
|
|
201
|
+
});
|
|
61
202
|
}
|
|
62
203
|
export { DefaultPilotMesh };
|
|
63
204
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kolmoPilotMesh.js","names":[],"sources":["../../src/engine/kolmoPilotMesh.tsx"],"sourcesContent":["import React, { useLayoutEffect, useMemo } from \"react\";\nimport * as THREE from \"three\";\nimport { applyRetroMaterial } from \"../shaders/retroShader.js\";\n\nexport function DefaultPilotMesh(): React.JSX.Element {\n const res = useMemo(() =>
|
|
1
|
+
{"version":3,"file":"kolmoPilotMesh.js","names":[],"sources":["../../src/engine/kolmoPilotMesh.tsx"],"sourcesContent":["import React, { useLayoutEffect, useMemo } from \"react\";\nimport * as THREE from \"three\";\nimport { applyRetroMaterial } from \"../shaders/retroShader.js\";\n\nexport function DefaultPilotMesh(): React.JSX.Element {\n const res = useMemo(() => {\n const limbGeo = new THREE.CylinderGeometry(0.068, 0.056, 0.34, 8);\n const legGeo = new THREE.CylinderGeometry(0.082, 0.068, 0.38, 8);\n const bootGeo = new THREE.BoxGeometry(0.14, 0.10, 0.22);\n const torsoGeo = new THREE.BoxGeometry(0.36, 0.38, 0.22);\n const hipGeo = new THREE.BoxGeometry(0.30, 0.13, 0.19);\n const shoulderGeo = new THREE.BoxGeometry(0.13, 0.10, 0.16);\n const helmGeo = new THREE.CylinderGeometry(0.135, 0.145, 0.22, 8);\n const visorGeo = new THREE.BoxGeometry(0.21, 0.085, 0.06);\n const packGeo = new THREE.BoxGeometry(0.24, 0.30, 0.12);\n return {\n limbGeo, legGeo, bootGeo, torsoGeo, hipGeo, shoulderGeo, helmGeo, visorGeo, packGeo,\n suitMat: applyRetroMaterial(new THREE.MeshStandardMaterial({ color: \"#cbd5e1\", roughness: 0.62, metalness: 0.12, flatShading: true }), { flatShading: true }),\n trimMat: applyRetroMaterial(new THREE.MeshStandardMaterial({ color: \"#334155\", roughness: 0.72, metalness: 0.2, flatShading: true }), { flatShading: true }),\n visorMat: applyRetroMaterial(new THREE.MeshStandardMaterial({ color: \"#38bdf8\", emissive: \"#0284c7\", emissiveIntensity: 0.55, roughness: 0.22 })),\n bootMat: applyRetroMaterial(new THREE.MeshStandardMaterial({ color: \"#1e293b\", roughness: 0.8, flatShading: true }), { flatShading: true }),\n };\n }, []);\n\n useLayoutEffect(() => () => {\n res.limbGeo.dispose(); res.legGeo.dispose(); res.bootGeo.dispose();\n res.torsoGeo.dispose(); res.hipGeo.dispose(); res.shoulderGeo.dispose();\n res.helmGeo.dispose(); res.visorGeo.dispose(); res.packGeo.dispose();\n res.suitMat.dispose(); res.trimMat.dispose(); res.visorMat.dispose(); res.bootMat.dispose();\n }, [res]);\n\n return (\n <group name=\"KolmoPilotRig\">\n <mesh position={[0, 0.44, 0]} castShadow geometry={res.helmGeo} material={res.suitMat} />\n <mesh position={[0, 0.45, 0.125]} geometry={res.visorGeo} material={res.visorMat} />\n <mesh position={[0, 0.15, 0]} castShadow geometry={res.torsoGeo} material={res.suitMat} />\n <mesh position={[0, -0.07, 0]} castShadow geometry={res.hipGeo} material={res.trimMat} />\n <mesh position={[0, 0.16, -0.15]} castShadow geometry={res.packGeo} material={res.trimMat} />\n <mesh position={[-0.24, 0.28, 0]} castShadow geometry={res.shoulderGeo} material={res.trimMat} />\n <mesh position={[0.24, 0.28, 0]} castShadow geometry={res.shoulderGeo} material={res.trimMat} />\n <mesh position={[-0.25, 0.08, 0.02]} rotation={[0.1, 0, 0.08]} castShadow geometry={res.limbGeo} material={res.suitMat} />\n <mesh position={[0.25, 0.08, 0.02]} rotation={[0.1, 0, -0.08]} castShadow geometry={res.limbGeo} material={res.suitMat} />\n <mesh position={[-0.10, -0.32, 0]} castShadow geometry={res.legGeo} material={res.suitMat} />\n <mesh position={[0.10, -0.32, 0]} castShadow geometry={res.legGeo} material={res.suitMat} />\n <mesh position={[-0.10, -0.53, 0.03]} castShadow geometry={res.bootGeo} material={res.bootMat} />\n <mesh position={[0.10, -0.53, 0.03]} castShadow geometry={res.bootGeo} material={res.bootMat} />\n </group>\n );\n}\n"],"mappings":";;;;;AAIA,SAAgB,mBAAsC;CAClD,MAAM,MAAM,cAAc;EAUtB,OAAO;GACH,SAAA,IAVgB,MAAM,iBAAiB,MAAO,MAAO,KAAM,CAU3D;GAAS,QAAA,IATM,MAAM,iBAAiB,MAAO,MAAO,KAAM,CASjD;GAAQ,SAAA,IARD,MAAM,YAAY,KAAM,IAAM,GAQ7B;GAAS,UAAA,IAPT,MAAM,YAAY,KAAM,KAAM,GAOrB;GA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AAC;KAAM;KAAO;IAAC;IAAG,YAAA;IAAW,UAAU,IAAI;IAAQ,UAAU,IAAI;GAAU,CAAA;GAC3F,oBAAC,QAAD;IAAM,UAAU;KAAC;KAAO;KAAO;IAAI;IAAG,YAAA;IAAW,UAAU,IAAI;IAAS,UAAU,IAAI;GAAU,CAAA;GAChG,oBAAC,QAAD;IAAM,UAAU;KAAC;KAAM;KAAO;IAAI;IAAG,YAAA;IAAW,UAAU,IAAI;IAAS,UAAU,IAAI;GAAU,CAAA;EAC5F;;AAEf"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { type CSSProperties } from "react";
|
|
2
|
+
import type { KolmoInputState } from "./kolmoInput.js";
|
|
3
|
+
import { type KolmoTouchActionButton } from "./kolmoTouchState.js";
|
|
4
|
+
export type { KolmoTouchActionButton };
|
|
5
|
+
export interface MobileTouchOverlayProps {
|
|
6
|
+
readonly enabled?: boolean | "auto";
|
|
7
|
+
readonly deadzone?: number;
|
|
8
|
+
readonly stickThreshold?: number;
|
|
9
|
+
readonly boostThreshold?: number;
|
|
10
|
+
readonly enableLook?: boolean;
|
|
11
|
+
readonly actions?: readonly KolmoTouchActionButton[];
|
|
12
|
+
readonly onStickChange?: (nx: number, ny: number, active: boolean) => void;
|
|
13
|
+
readonly onLookDelta?: (dx: number, dy: number) => void;
|
|
14
|
+
readonly onInputChange?: (next: Partial<KolmoInputState>) => void;
|
|
15
|
+
readonly style?: CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Reusable mobile-landscape touch overlay (virtual stick with 8% deadzone, right-half drag-to-look, >=44x44px buttons).
|
|
19
|
+
* Note: `<canvas>` does not inherit `touch-action: none` from CSS ancestors; ensure host apps include `canvas { touch-action: none; }`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function MobileTouchOverlay(props: MobileTouchOverlayProps): React.JSX.Element | null;
|