@pinkaphant/kolmo 0.4.5 → 0.4.7
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 +11 -13
- package/bin/kolmo.mjs +7 -6
- package/dist/engine/index.d.ts +5 -1
- package/dist/engine/index.js +11 -6
- package/dist/engine/kolmoActor.d.ts +9 -1
- package/dist/engine/kolmoActor.js +12 -2
- package/dist/engine/kolmoActor.js.map +1 -1
- package/dist/engine/kolmoBotControl.d.ts +44 -0
- package/dist/engine/kolmoBotControl.js +194 -0
- package/dist/engine/kolmoBotControl.js.map +1 -0
- package/dist/engine/kolmoBotJournal.d.ts +23 -0
- package/dist/engine/kolmoBotJournal.js +138 -0
- package/dist/engine/kolmoBotJournal.js.map +1 -0
- package/dist/engine/kolmoFloatingOrigin.js +1 -8
- package/dist/engine/kolmoFloatingOrigin.js.map +1 -1
- package/dist/engine/kolmoGltfLoader.d.ts +16 -0
- package/dist/engine/kolmoGltfLoader.js +46 -0
- package/dist/engine/kolmoGltfLoader.js.map +1 -0
- package/dist/engine/kolmoHud.js +85 -80
- package/dist/engine/kolmoHud.js.map +1 -1
- package/dist/engine/kolmoInput.js +9 -7
- package/dist/engine/kolmoInput.js.map +1 -1
- package/dist/engine/kolmoLongDrive.js +32 -14
- package/dist/engine/kolmoLongDrive.js.map +1 -1
- package/dist/engine/kolmoPilotMesh.d.ts +4 -0
- package/dist/engine/kolmoPilotMesh.js +174 -2
- package/dist/engine/kolmoPilotMesh.js.map +1 -1
- package/dist/engine/kolmoVehicleAutoCompile.d.ts +1 -0
- package/dist/engine/kolmoVehicleAutoCompile.js +21 -5
- package/dist/engine/kolmoVehicleAutoCompile.js.map +1 -1
- package/dist/engine/kolmoVehicleDriver.d.ts +1 -0
- package/dist/engine/kolmoVehicleDriver.js +20 -12
- package/dist/engine/kolmoVehicleDriver.js.map +1 -1
- package/dist/engine/kolmoVehicleInner.js +25 -9
- package/dist/engine/kolmoVehicleInner.js.map +1 -1
- package/dist/engine/kolmoWardrobeRig.d.ts +22 -0
- package/dist/engine/kolmoWardrobeRig.js +146 -0
- package/dist/engine/kolmoWardrobeRig.js.map +1 -0
- package/dist/engine/kolmoWorld.d.ts +2 -2
- package/dist/engine/kolmoWorld.js +4 -1
- package/dist/engine/kolmoWorld.js.map +1 -1
- package/dist/importer/DomainWorkshopPanel.d.ts +3 -1
- package/dist/importer/DomainWorkshopPanel.js +15 -48
- package/dist/importer/DomainWorkshopPanel.js.map +1 -1
- package/dist/importer/GateHudBar.js.map +1 -1
- package/dist/importer/GlbImportGate.js +219 -210
- package/dist/importer/GlbImportGate.js.map +1 -1
- package/dist/importer/ImperativeVehicleRig.js +7 -6
- package/dist/importer/ImperativeVehicleRig.js.map +1 -1
- package/dist/importer/LiveDrivePads.js +41 -17
- package/dist/importer/LiveDrivePads.js.map +1 -1
- package/dist/importer/WardrobeWorkshopPanel.d.ts +15 -0
- package/dist/importer/WardrobeWorkshopPanel.js +529 -0
- package/dist/importer/WardrobeWorkshopPanel.js.map +1 -0
- package/dist/importer/importerWebMcp.d.ts +2 -0
- package/dist/importer/importerWebMcp.js +5 -3
- package/dist/importer/importerWebMcp.js.map +1 -1
- package/dist/importer/importerWebMcpTools.js +36 -9
- package/dist/importer/importerWebMcpTools.js.map +1 -1
- package/dist/importer/index.d.ts +6 -0
- package/dist/importer/index.js +10 -4
- package/dist/importer/khrCarGeometryMass.js +14 -8
- package/dist/importer/khrCarGeometryMass.js.map +1 -1
- package/dist/importer/khrCarPlanner.js +50 -44
- package/dist/importer/khrCarPlanner.js.map +1 -1
- package/dist/importer/useChopShopController.d.ts +2 -0
- package/dist/importer/useChopShopController.js +18 -0
- package/dist/importer/useChopShopController.js.map +1 -1
- package/dist/importer/wardrobeAutoFit.d.ts +16 -0
- package/dist/importer/wardrobeAutoFit.js +410 -0
- package/dist/importer/wardrobeAutoFit.js.map +1 -0
- package/dist/importer/wardrobeCatalog.d.ts +16 -0
- package/dist/importer/wardrobeCatalog.js +409 -0
- package/dist/importer/wardrobeCatalog.js.map +1 -0
- package/dist/importer/wardrobeController.d.ts +49 -0
- package/dist/importer/wardrobeController.js +181 -0
- package/dist/importer/wardrobeController.js.map +1 -0
- package/dist/importer/wardrobeFitter.d.ts +27 -0
- package/dist/importer/wardrobeFitter.js +269 -0
- package/dist/importer/wardrobeFitter.js.map +1 -0
- package/dist/importer/wardrobeWebMcpTools.d.ts +2 -0
- package/dist/importer/wardrobeWebMcpTools.js +198 -0
- package/dist/importer/wardrobeWebMcpTools.js.map +1 -0
- package/dist/index.js +15 -3
- package/dist/junk/DestructibleTarget.js +2 -2
- package/dist/junk/DestructibleTarget.js.map +1 -1
- package/dist/junk/ShardPieces.js +2 -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/junkImporter.js +2 -2
- package/dist/junk/junkImporter.js.map +1 -1
- package/dist/junk/junkSheetSplitter.d.ts +38 -0
- package/dist/junk/junkSheetSplitter.js +104 -0
- package/dist/junk/junkSheetSplitter.js.map +1 -0
- package/dist/physics/index.d.ts +4 -1
- package/dist/physics/index.js +34 -8
- package/dist/physics/index.js.map +1 -1
- package/dist/physics/nBodyGravity.d.ts +42 -0
- package/dist/physics/nBodyGravity.js +70 -0
- package/dist/physics/nBodyGravity.js.map +1 -0
- package/dist/vite/index.d.ts +2 -12
- package/dist/vite/index.js +8 -77
- package/dist/vite/index.js.map +1 -1
- package/docs/api-reference.md +671 -91
- package/package.json +14 -11
- package/skills/kolmo-engine/SKILL.md +109 -0
package/docs/api-reference.md
CHANGED
|
@@ -1,148 +1,728 @@
|
|
|
1
1
|
# `@pinkaphant/kolmo` API Reference
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This document specifies the public `@pinkaphant/kolmo` subpaths, React Three Fiber components, hooks, functions, TypeScript interfaces, default option values, and runtime stores/handles.
|
|
4
|
+
|
|
5
|
+
For installation, CLI project scaffolding, and repository source layout, see [README.md](../README.md).
|
|
6
|
+
|
|
7
|
+
## Peer Dependencies & Runtime Layering
|
|
8
|
+
|
|
9
|
+
`@pinkaphant/kolmo` composes four peer layers. Pin `@dimforge/rapier3d-compat` and `@pinkaphant/ecctrl` in `dependencies` and `overrides` so Rapier WASM handles and controller contexts share a single module instance:
|
|
10
|
+
|
|
11
|
+
| Package | Version / Range | Role in `@pinkaphant/kolmo` |
|
|
12
|
+
| :--- | :--- | :--- |
|
|
13
|
+
| `@react-three/fiber` / `three` / `@react-three/drei` | `^9.0.0` / `>=0.180.0` / `^10.7.7` | Scene graph, render loop (`useFrame`), WebGL/WebGPU materials, and keyboard input bridge. |
|
|
14
|
+
| `@react-three/rapier` + `@dimforge/rapier3d-compat` | `^2.2.0` + `0.19.2` (pinned) | Rigid-body solver, shape/ray queries, and `ImpulseJoint` constraints. |
|
|
15
|
+
| `@pinkaphant/ecctrl` | `2.0.4-beta.5` (pinned) | Character capsule controller (`<Ecctrl>`), wheeled/propeller vehicle controller (`<EcctrlVehicle>`, `<ShapeCastWheel>`, `<ThrustPropeller>`), orbit camera (`<EcctrlCameraControls>`), fixed-bound step scheduler (`<TimeControl>`), and spatial gravity store (`useCustomGravity`). |
|
|
16
|
+
| `@khr3/core`, `@khr3/assets`, `@khr3/c12`, `@khr3/vehicles`, `@khr3/launchers` | `^0.2.7` / `^0.2.8` / `^0.3.8` / `^0.2.4` / `^0.2.8` | Bundled dependencies implementing `KHR_physics_rigid_bodies`, `KHR_implicit_shapes`, and `OMI_vehicle_wheel` `.glb` serialization, `<KhrAssembly>`, `<KhrVehicle>`, `solveWheelLoads`, Pacejka curves, 3.0 m `Z[1/2, sqrt(3)]` `C12` modular tiles, procedural `PaperShell` car presets, and `Sand3D` Code-CAD compilation. |
|
|
17
|
+
| `koota` / `zustand` / `react` / `react-dom` | `^0.6.5` / `^5.0.0` / `^19.0.0` | Structure-of-Arrays (SoA) entity traits (`kolmoWorld`) and transient UI/calibration stores (`useGateStore`, `useSuikaStore`). |
|
|
18
|
+
|
|
19
|
+
### Coordinate & Scaling Conventions
|
|
20
|
+
|
|
21
|
+
- **World & Vehicle Frame**: Right-handed SI meters (`1 unit = 1 m`), `+Y` up, `+Z` vehicle forward (`+X` port/left, `-X` starboard/right), enforced `[1, 1, 1]` node scale on KHR rigid-body hierarchies.
|
|
22
|
+
- **Emitter & Socket Frame**: `KOLMO_emitter` nozzles emit along local `-Z`.
|
|
23
|
+
- **Custom & N-Body Gravity**: When `KolmoPhysics` receives `"custom"`, `KolmoPointGravity`, `KolmoNBodyGravity`, or a `KolmoGravityCallback`, Rapier's uniform world gravity is set to `[0, 0, 0]`, `KolmoGravityContext` becomes `true`, and spatial acceleration is registered on `@pinkaphant/ecctrl/gravity`'s `useCustomGravity.getState().setGravityField`. `<KolmoActor>` (`<Ecctrl enableCustomGravity>`) and `<KolmoVehicle>` (`<KhrVehicle enableCustomGravity>`) consume `useCustomGravity` automatically; standalone dynamic props (`<DestructibleTarget>`, `<ShardPieces>`, `<KolmoSuikaOrb>`) apply `applyGravityField(body, timestep)` each step.
|
|
24
|
+
|
|
25
|
+
## Package Exports
|
|
26
|
+
|
|
27
|
+
| Path | Main exports |
|
|
28
|
+
| :--- | :--- |
|
|
29
|
+
| `@pinkaphant/kolmo` (`.` & `./all`) | Root barrel re-exporting `./engine`, `./shaders`, `./schema`, `./world`, `./importer`, `./junk`, `./suika`, `./sand3d`, short JSX aliases (`Game`, `Hud`, `Canvas`, `World`, `Physics`, `Vehicle`, `Actor`, `Surface`, `Prop`, `Island`, `LongDrive`, `Skybox`, `Exoplanet`, `EmitterRig`, `Junk`, `SuikaOrb`, `SuikaSystem`, `Sand3D`), and selected `@khr3/*` helpers. |
|
|
30
|
+
| `@pinkaphant/kolmo/engine` (`./engine`) | `<KolmoGame>`, `<KolmoCanvas>`, `<KolmoWorld>`, `<KolmoHud>`, `<MobileTouchOverlay>`, `<KolmoVehicle>`, `<KolmoActor>`, `<KolmoWardrobeRig>`, `<KolmoSurface>`, `<KolmoProp>`, `<KolmoIsland>`, `<KolmoLongDrive>`, `<ShiftedFixedBody>`, Koota traits/actions/floating-origin helpers, Khronos GLB loader (`MeshoptDecoder` + `KTX2Loader`), touch state, and `kolmo_drive` / `kolmo_telemetry` WebMCP tools. |
|
|
31
|
+
| `@pinkaphant/kolmo/physics` (`./physics`) | `<KolmoPhysics>`, `KolmoGravityContext`, `useIsKolmoCustomGravity`, `useOptionalKootaWorld`, `G_SI`, `resolveAttractorMu`, `evaluateNBodyGravity`, `createNBodyGravityField`, `computeCircularOrbitSpeed`, and gravity spec types. |
|
|
32
|
+
| `@pinkaphant/kolmo/vite` (`./vite`) | `KOLMO_SINGLETON_DEDUPE`, `externalizeRapierWasm`, `KOLMO_ROLLDOWN_BUILD`. |
|
|
33
|
+
| `@pinkaphant/kolmo/world` (`./world`) | Procedural terrain, road splines, splat maps, `Seed8` PRNGs, `planIslandWorld`, `InfiniteLongDrivePlanner`, `routeMacroKnightAStar`, `quantizeFloatingOrigin192`, `buildCarvedTerrainGeometry`, `buildRoadRibbonGeometry`. |
|
|
34
|
+
| `@pinkaphant/kolmo/shaders` (`./shaders`) | PS1/Dreamcast/PS2 material patcher (`applyRetroMaterial`), palette LUTs, shared uniforms (`RETRO_UNIFORMS`), `<KolmoSkybox>`, `<KolmoExoplanet>`, `<KolmoEmitterRig>`, and WebGL PS2 splat terrain/road materials. |
|
|
35
|
+
| `@pinkaphant/kolmo/shaders/tsl` (`./shaders/tsl`) | Three.js WebGPU TSL node materials: `createPS2TerrainMaterialTSL`, `createPS2RoadMaterialTSL`. |
|
|
36
|
+
| `@pinkaphant/kolmo/importer` (`./importer`) | `<GlbImportGate>` (`ImporterWorkbench`), `<WheelRingHandles3D>`, `useChopShopController`, `detectFusedCarWheels`, `sliceCarWheelCylinders`, surface loop cutter, SI normalizer, KHR/USD/launcher compilers, modular character wardrobe fitter, and 15 `navigator.modelContext` WebMCP tools. |
|
|
37
|
+
| `@pinkaphant/kolmo/sand3d` (`./sand3d`) | `<KolmoSand3D>` (`Sand3D`), `ingestSand3dOrGlb`, `compileSand3dRecipeGlb`, `SAND3D_RECIPES`, `s3d` Code-CAD re-exports, `<Sand3dWorkshopSection>`. |
|
|
38
|
+
| `@pinkaphant/kolmo/junk` (`./junk`) | `<KolmoJunk>`, `<DestructibleTarget>`, `<ShardPieces>`, `<TargetDecals>`, `splitObjectIntoShards`, `splitSheetSceneIntoJunkIslands`, `SUBSTRATE_DENSITY_KG_M3`, procedural bottle/can LOD geometry, and GLB segment importers. |
|
|
39
|
+
| `@pinkaphant/kolmo/suika` (`./suika`) | `<KolmoSuikaOrb>` (`SuikaOrb`), `<KolmoSuikaSystem>` (`SuikaSystem`), `ORB_TIERS`, `GOLDEN_RATIO`, `SuikaMergeArbiter`, `spawnSuikaOrb`, `useSuikaStore`, and hull/tier geometry helpers. |
|
|
40
|
+
| `@pinkaphant/kolmo/schema` (`./schema`) | `KOLMO_EXTENSION_NAME` (`"KOLMO_emitter"`), `decodeKolmoRig`, `stampKolmoNodesIntoGlb`, `inferKolmoSocketRole`, `createDefaultSignals`, and patch disambiguation helpers. |
|
|
41
|
+
| `@pinkaphant/kolmo/package.json` (`./package.json`) | Package manifest JSON. |
|
|
4
42
|
|
|
5
|
-
|
|
43
|
+
---
|
|
6
44
|
|
|
7
|
-
|
|
45
|
+
## CLI (`kolmo`)
|
|
8
46
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
| `@pinkaphant/kolmo/schema` | `./schema` | [src/schema/kolmoSchema.ts](../src/schema/kolmoSchema.ts) | `KOLMO_emitter` extension schema: `KOLMO_EXTENSION_NAME`, `stampKolmoNodesIntoGlb`, `StampKolmoOptions`, `disambiguatePatchName`, `disambiguateExplicitPatches`, `decodeKolmoRig`, `inferKolmoSocketRole`, `createDefaultSignals` |
|
|
47
|
+
Executable binary (`bin/kolmo.mjs`):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx @pinkaphant/kolmo create [project-dir] [--template game|longline|dust|garage]
|
|
51
|
+
npx @pinkaphant/kolmo init [project-dir] [--template game|longline|dust|garage]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- `project-dir` defaults to `"my-kolmo-game"` when omitted.
|
|
55
|
+
- Fails with exit code `1` if `project-dir` already contains files other than `.git`, `.gitattributes`, `.gitignore`, `LICENSE`, `README.md`, or `.DS_Store`.
|
|
56
|
+
- Generates `package.json` (with pinned `@dimforge/rapier3d-compat@0.19.2` and `@pinkaphant/ecctrl@2.0.4-beta.5` overrides), `vite.config.ts`, `tsconfig.json`, `wrangler.jsonc`, `index.html`, `src/main.tsx`, `src/App.tsx`, and `src/App.test.ts`:
|
|
57
|
+
- `game` (default): `<Game>` with `<Island>`, `<Vehicle piloted>`, `<Actor>`, `<Hud>`, and `<MobileTouchOverlay />`.
|
|
58
|
+
- `longline`: `<LongDrive pureMainland>` with `Seed8` highway streaming, `192 m` floating-origin rebasing, fuel pickups, `<SuikaSystem>`, and 3.0 m `C12` wall placement.
|
|
59
|
+
- `dust`: `<Island>` with resource harvesting, `<Junk>` targets, and 3.0 m `C12` wall construction.
|
|
60
|
+
- `garage`: Standalone `<GlbImportGate />` calibration and live-drive workbench.
|
|
24
61
|
|
|
25
62
|
---
|
|
26
63
|
|
|
27
64
|
## Root Barrel (`@pinkaphant/kolmo` & `@pinkaphant/kolmo/all`)
|
|
28
65
|
|
|
29
|
-
Defined in [src/index.ts](../src/index.ts). Re-exports `@pinkaphant/kolmo/engine` (including `MobileTouchOverlay` and `kolmoTouchState.ts` helpers), `@pinkaphant/kolmo/shaders`, `@pinkaphant/kolmo/schema`, `@pinkaphant/kolmo/world`, `@pinkaphant/kolmo/importer`, `@pinkaphant/kolmo/junk`, `@pinkaphant/kolmo/suika`, and `@pinkaphant/kolmo/sand3d`, short JSX aliases (`Canvas`, `Physics`, `World`, `Game`, `Hud`, `Vehicle`, `Actor`, `Surface`, `Prop`, `Island`, `LongDrive`, `Skybox`, `Exoplanet`, `EmitterRig`, `Junk`, `SuikaOrb`, `SuikaSystem`, `Sand3D`), and curated helpers from `@khr3/core`, `@khr3/assets`, `@khr3/c12`, `@khr3/vehicles`, and `@khr3/launchers`.
|
|
30
|
-
|
|
31
66
|
```tsx
|
|
32
67
|
import { Actor, Game, Hud, Island, MobileTouchOverlay, Sand3D, Vehicle } from "@pinkaphant/kolmo";
|
|
33
68
|
|
|
34
69
|
export function App() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
70
|
+
return (
|
|
71
|
+
<Game>
|
|
72
|
+
<Island />
|
|
73
|
+
<Vehicle piloted />
|
|
74
|
+
<Sand3D recipe="hinged_ammo_chest" position={[4, 1, 6]} />
|
|
75
|
+
<Actor />
|
|
76
|
+
<Hud />
|
|
77
|
+
<MobileTouchOverlay />
|
|
78
|
+
</Game>
|
|
79
|
+
);
|
|
45
80
|
}
|
|
46
81
|
```
|
|
47
82
|
|
|
48
|
-
###
|
|
83
|
+
### Root JSX Aliases
|
|
84
|
+
|
|
85
|
+
Short component aliases are defined on `@pinkaphant/kolmo` and `@pinkaphant/kolmo/all`. Only `ImporterWorkbench`, `Sand3D`, `SuikaOrb`, and `SuikaSystem` are also exported under their short names from their respective subpaths; import the `Kolmo*` symbol when importing directly from `./engine`, `./physics`, `./shaders`, or `./junk`.
|
|
86
|
+
|
|
87
|
+
| Root Alias | Underlying Component | Subpath Origin |
|
|
88
|
+
| :--- | :--- | :--- |
|
|
89
|
+
| `Game` | `KolmoGame` | `@pinkaphant/kolmo/engine` |
|
|
90
|
+
| `Hud` | `KolmoHud` | `@pinkaphant/kolmo/engine` |
|
|
91
|
+
| `Canvas` | `KolmoCanvas` | `@pinkaphant/kolmo/engine` |
|
|
92
|
+
| `World` | `KolmoWorld` | `@pinkaphant/kolmo/engine` |
|
|
93
|
+
| `Physics` | `KolmoPhysics` | `@pinkaphant/kolmo/physics` (and `./engine`) |
|
|
94
|
+
| `Vehicle` | `KolmoVehicle` | `@pinkaphant/kolmo/engine` |
|
|
95
|
+
| `Actor` | `KolmoActor` | `@pinkaphant/kolmo/engine` |
|
|
96
|
+
| `Surface` | `KolmoSurface` | `@pinkaphant/kolmo/engine` |
|
|
97
|
+
| `Prop` | `KolmoProp` | `@pinkaphant/kolmo/engine` |
|
|
98
|
+
| `Island` | `KolmoIsland` | `@pinkaphant/kolmo/engine` |
|
|
99
|
+
| `LongDrive` | `KolmoLongDrive` | `@pinkaphant/kolmo/engine` |
|
|
100
|
+
| `Skybox` | `KolmoSkybox` | `@pinkaphant/kolmo/shaders` |
|
|
101
|
+
| `Exoplanet` | `KolmoExoplanet` | `@pinkaphant/kolmo/shaders` |
|
|
102
|
+
| `EmitterRig` | `KolmoEmitterRig` | `@pinkaphant/kolmo/shaders` |
|
|
103
|
+
| `ImporterWorkbench` | `GlbImportGate` | `@pinkaphant/kolmo/importer` |
|
|
104
|
+
| `Junk` | `KolmoJunk` | `@pinkaphant/kolmo/junk` |
|
|
105
|
+
| `SuikaOrb` / `SuikaSystem` | `KolmoSuikaOrb` / `KolmoSuikaSystem` | `@pinkaphant/kolmo/suika` |
|
|
106
|
+
| `Sand3D` | `KolmoSand3D` | `@pinkaphant/kolmo/sand3d` |
|
|
107
|
+
|
|
108
|
+
### Root `@khr3/*` Re-Exports
|
|
109
|
+
|
|
110
|
+
`@pinkaphant/kolmo` (`.` and `./all`) also re-exports:
|
|
111
|
+
|
|
112
|
+
- `@khr3/core`: `type KhrAssetBundle`.
|
|
113
|
+
- `@khr3/assets`: `DEFAULT_VAULT_URL`, `KOLMO_ASSETS_URL`, `VAULT_CARS`, `VAULT_CATALOG`, `VAULT_CITY`, `VAULT_WEAPONS`, `createAssetVault`, `inspectGlbBuffer`, `normalizeGlbBuffer`, `vaultAssetUrl`.
|
|
114
|
+
- `@khr3/c12`: `DOOR_HINGE_SPEC`, `Ex`, `ROOT3`, `buildFootprint`, `canPlace`, `instanceBatches`, `latticePose`, `planSettlement`, `poseEq`, `poseFromJSON`, `poseToFloat`, `poseToJSON`, `snapPose`, `socketFor`, `triangleCorners`, `vToFloat`, `worldSockets`.
|
|
115
|
+
- `@khr3/vehicles`: `CARS_R2_PREFIX`, `COUPE_2DOOR`, `FLEET`, `SEDAN_4DOOR`, `carUrl`, `findCar`, `planCar`.
|
|
116
|
+
- `@khr3/vehicles/paper-shell`: `PAPER_SHELL_PRESETS`, `type PaperShellPreset`, `type PaperShellPresetId`.
|
|
117
|
+
- `@khr3/launchers`: `CARBINE_556`, `LAUNCHER_RECIPES`, `PISTOL_9MM`, `SHOTGUN_12G`, `attachModule`, `createLauncherState`, `detachModule`, `findLauncherRecipe`, `planLauncher`, `stepLauncher`.
|
|
49
118
|
|
|
50
|
-
|
|
51
|
-
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## `@pinkaphant/kolmo/engine`
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import {
|
|
125
|
+
KolmoGame,
|
|
126
|
+
KolmoCanvas,
|
|
127
|
+
KolmoWorld,
|
|
128
|
+
KolmoHud,
|
|
129
|
+
MobileTouchOverlay,
|
|
130
|
+
KolmoVehicle,
|
|
131
|
+
KolmoActor,
|
|
132
|
+
KolmoWardrobeRig,
|
|
133
|
+
KolmoSurface,
|
|
134
|
+
KolmoProp,
|
|
135
|
+
KolmoIsland,
|
|
136
|
+
KolmoLongDrive,
|
|
137
|
+
ShiftedFixedBody,
|
|
138
|
+
useKolmoGame,
|
|
139
|
+
useKolmoInput,
|
|
140
|
+
kolmoWorld,
|
|
141
|
+
kolmoActions,
|
|
142
|
+
kolmoTelemetry,
|
|
143
|
+
flipVehicleBodyUpright,
|
|
144
|
+
createKolmoGltfLoader,
|
|
145
|
+
loadOrAutoCompileVehicleGlb,
|
|
146
|
+
buildProceduralCarGlb,
|
|
147
|
+
useKolmoDriveWebMcp,
|
|
148
|
+
KolmoBotJournalFeed,
|
|
149
|
+
} from "@pinkaphant/kolmo/engine";
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Spawn & Boarding Coordination (`WorldSpawnTrait` & `PilotLink`)
|
|
153
|
+
|
|
154
|
+
- `<KolmoIsland autoSpawn>` and `<KolmoLongDrive>` publish `{ vehiclePos, vehicleRot, actorPos }` onto `WorldSpawnTrait` on the active Koota `World`. `<KolmoVehicle>` and `<KolmoActor>` without explicit `position` props snap to those poses automatically.
|
|
155
|
+
- When `<KolmoVehicle piloted />` and `<KolmoActor />` are mounted together, `<KolmoActor>` links itself to the piloted vehicle via `PilotLink = relation({ exclusive: true })` and suppresses its on-foot `<Ecctrl>` capsule until the player presses `[F]` (`interact`) or calls `kolmoActions(world).exitVehicle()`. Pressing `[F]` near an unpiloted `<KolmoVehicle>` calls `boardVehicle(id)`.
|
|
156
|
+
|
|
157
|
+
### `<KolmoGame>`, `<KolmoCanvas>`, and `<KolmoWorld>`
|
|
158
|
+
|
|
159
|
+
`<KolmoGame>` mounts a `100vw × 100dvh` container (`touchAction: "none"`), `<WorldProvider>`, `<KolmoCanvas>`, `<KolmoWorld>`, and `KolmoOverlayContext` so `<KolmoHud>` and `<MobileTouchOverlay>` render outside the WebGL `<Canvas>` even when declared as JSX children inside `<KolmoGame>`. Note that `<KolmoGame>` defaults `skybox` to `"day"`, whereas standalone `<KolmoWorld>` defaults `skybox` to `"nebula"`.
|
|
160
|
+
|
|
161
|
+
| Prop (`KolmoGameProps`) | Type | Default | Description |
|
|
162
|
+
| :--- | :--- | :--- | :--- |
|
|
163
|
+
| `retro` | `RetroPreset \| RetroPresetId` | `RETRO_DREAMCAST` | Active retro shader preset synced to `RETRO_UNIFORMS`. |
|
|
164
|
+
| `gravity` | `KolmoGravitySpec` | `"planar"` | Gravity configuration forwarded to `<KolmoPhysics>`. |
|
|
165
|
+
| `skybox` | `"nebula" \| "day" \| "none"` | `"day"` | Background skybox and default linear fog (`"day"`). |
|
|
166
|
+
| `lighting` | `"default" \| "none"` | `"default"` | Mounts default hemisphere + key/fill directional lights when `"default"`. |
|
|
167
|
+
| `fogExp2` | `[color: string, density: number] \| null` | `undefined` | Optional exponential fog override. |
|
|
168
|
+
| `paused` | `boolean` | `false` | Pauses Rapier simulation stepping. |
|
|
169
|
+
| `timeScale` | `number \| RefObject<number>` | `1` | Simulation step multiplier forwarded to `<TimeControl>`. |
|
|
170
|
+
| `maxDelta` | `number \| RefObject<number>` | `1 / 30` | Frame delta cap forwarded to `<PhysicsWorld>`. |
|
|
171
|
+
| `physicsDebug` | `boolean` | `false` | Enables `@react-three/rapier` debug wireframes. |
|
|
172
|
+
| `dpr` | `number \| [number, number]` | `[1, 1.5]` | Device pixel ratio forwarded to `<KolmoCanvas>`. |
|
|
173
|
+
| `kootaWorld` | `World` | `kolmoWorld` | Koota ECS world instance. |
|
|
174
|
+
| `style` / `className` | `CSSProperties` / `string` | `undefined` | Container styling overrides. |
|
|
175
|
+
| `children` | `ReactNode` | `undefined` | Scene entities and tunneled HUD overlays. |
|
|
176
|
+
|
|
177
|
+
| Prop (`KolmoCanvasProps`) | Type | Default | Description |
|
|
178
|
+
| :--- | :--- | :--- | :--- |
|
|
179
|
+
| `fov` / `near` / `far` | `number` | `56` / `0.15` / `6500` | Perspective camera frustum parameters. |
|
|
180
|
+
| `cameraPosition` | `[number, number, number]` | `[0, 3.2, -8.5]` | Initial camera position in meters. |
|
|
181
|
+
| `dpr` | `number \| [number, number]` | `[1, 1.5]` | Canvas device pixel ratio. |
|
|
182
|
+
| `frameloop` | `"always" \| "demand" \| "never"` | `"always"` | R3F frame loop mode. |
|
|
183
|
+
| `shadows` | `boolean \| "basic" \| "percentage" \| "soft" \| "variance"` | `"basic"` | Shadow map configuration. |
|
|
184
|
+
| `toneMapping` | `THREE.ToneMapping` | `undefined` | Optional WebGL tone-mapping override (`SRGBColorSpace` output is always set). |
|
|
185
|
+
| `roomEnv` | `boolean \| number` | `false` | Mounts `<RoomEnvRig intensity={typeof roomEnv === "number" ? roomEnv : 0.65} />` when truthy. |
|
|
186
|
+
| `onCanvasReady` | `(canvas: HTMLCanvasElement \| null) => void` | `undefined` | Invoked with `gl.domElement` on WebGL creation. |
|
|
187
|
+
| `onContextLost` | `(lost: boolean) => void` | `undefined` | Invoked on `webglcontextlost` (`true`) and `webglcontextrestored` (`false`). |
|
|
188
|
+
|
|
189
|
+
`<KolmoWorld>` accepts `KolmoWorldProps`: `{ gravity = "planar", paused = false, timeScale = 1, maxDelta, physicsDebug = false, retro, retroPreset, skybox = "nebula", lighting = "default", fogExp2, sunLightRef, shadowSnap = false, world = kolmoWorld, keyboardMap = KOLMO_KEY_MAP, children }` and automatically registers `useKolmoDriveWebMcp(effectiveWorld, true)`. Scene helper rigs `RetroViewportSync` (`RetroViewportSyncProps`), `RoomEnvRig` (`RoomEnvRigProps`), and `ShadowSnapRig` are also exported.
|
|
190
|
+
|
|
191
|
+
### `<KolmoHud>` and `<MobileTouchOverlay>`
|
|
192
|
+
|
|
193
|
+
- **`<KolmoHud>`** (`KolmoHudProps: { showPresets?: boolean; style?: CSSProperties }`, `showPresets = true`): Updates speed (`km/h`), gear, and RPM at 60 Hz via DOM refs, shows mode-aware `Drive` / `Fly` / `Walk` & `[F]` board/exit prompts (hidden on touch devices), mounts `<KolmoBotJournalFeed topOffset={12} />`, and provides preset-cycling and `Flip` buttons with `env(safe-area-inset-*)` padding.
|
|
194
|
+
- **`<MobileTouchOverlay>`** (`MobileTouchOverlayProps`): `{ enabled = "auto", deadzone = KOLMO_STICK_DEADZONE (0.08), stickThreshold = 0.25, boostThreshold = 0, enableLook = true, actions?, onStickChange?, onLookDelta?, onInputChange?, style? }`. Left-half virtual thumbstick (`+nx` right, `+ny` forward), independent `pointerId` right-half drag-to-look, and `>= 44×44 px` action buttons. `<KolmoCanvas>` already applies inline `touchAction: "none"`; when mounting `<MobileTouchOverlay>` over a raw standalone `<canvas>`, add `canvas { touch-action: none; }` in CSS.
|
|
195
|
+
|
|
196
|
+
### `<KolmoVehicle>`
|
|
197
|
+
|
|
198
|
+
Mounts a KHR rigid-body vehicle through `@khr3/core/vehicle` `<KhrVehicle>` onto `@pinkaphant/ecctrl/vehicle` `<EcctrlVehicle>` (`<ShapeCastWheel>` + `<ThrustPropeller>`), binding `KOLMO_emitter` plumes and Koota `VehicleTrait` / `VehicleTelemetryTrait`.
|
|
199
|
+
|
|
200
|
+
| Prop (`KolmoVehicleProps`) | Type | Default | Description |
|
|
201
|
+
| :--- | :--- | :--- | :--- |
|
|
202
|
+
| `id` | `string` | auto-generated | Stable vehicle entity ID used by `boardVehicle(id)` and telemetry. |
|
|
203
|
+
| `bundle` | `KhrAssetBundle` | `undefined` | Pre-loaded KHR bundle (mounted at unit `[1, 1, 1]` scale). |
|
|
204
|
+
| `src` | `string` | `undefined` | `.glb` URL passed to `loadOrAutoCompileVehicleGlb` (auto-normalizes and cores wheels on uncalibrated single-mesh cars). |
|
|
205
|
+
| `rawGlbBytes` | `Uint8Array` | `undefined` | Binary `.glb` bytes passed to `loadOrAutoCompileVehicleGlb`. |
|
|
206
|
+
| `preset` | `PaperShellPreset \| PaperShellPresetId` | `undefined` (`"coupe_86"` fallback) | Procedural `@khr3/vehicles/paper-shell` preset. When `src`, `bundle`, and `rawGlbBytes` are all omitted, defaults to `"coupe_86"`. Setting `preset` explicitly takes precedence over `src` and `rawGlbBytes`. |
|
|
207
|
+
| `shadingMode` | `ShadingMode` | `"dc-smooth"` | Procedural car shading mode. |
|
|
208
|
+
| `horsepower` | `number` | `undefined` | Engine horsepower override during procedural/auto-compile build. |
|
|
209
|
+
| `position` / `rotation` | `[number, number, number]` | `WorldSpawnTrait` or `[0, 1.2, 0]` / `[0, 0, 0]` | Spawn translation (m) and Euler rotation (rad). |
|
|
210
|
+
| `piloted` | `boolean` | `false` | Starts piloted (`PilotedTag`), mounting an internal seated pilot mesh at `bundle.sockets.butt ?? bundle.sockets.driver_butt ?? Socket_seat_*`. |
|
|
211
|
+
| `flightMode` | `boolean` | `false` | Enables `ThrustPropeller` flight control (`DroneConfigType` `"VELOCITY"` mode in `@pinkaphant/ecctrl@2.0.4-beta.5`). |
|
|
212
|
+
| `vehicleMode` | `"drive" \| "rocket"` | `undefined` | Hybrid rig selector: `"rocket"` disables `ShapeCastWheel`s (`{ enable: false }`); `"drive"` disables `ThrustPropeller`s unless `flightMode` is active. |
|
|
213
|
+
| `enable` / `ccd` | `boolean` | `true` / `undefined` | Enables `<EcctrlVehicle>` update loop / Rapier continuous collision detection. |
|
|
214
|
+
| `linearDamping` / `angularDamping` | `number` | `undefined` | Rapier rigid-body damping overrides. |
|
|
215
|
+
| `userData` | `Record<string, unknown>` | `undefined` | Forwarded to the chassis `RigidBody`. |
|
|
216
|
+
| `onCollisionEnter` | `(payload: CollisionEnterPayload) => void` | `undefined` | Rapier collision enter callback. |
|
|
217
|
+
| `wheelConfig` / `propellerConfig` | `KhrVehicleProps["wheelConfig"]` / `["propellerConfig"]` | `undefined` | Per-wheel `ShapeCastWheelProps` and per-propeller `ThrustPropellerProps` overrides. |
|
|
218
|
+
| `carConfig` / `droneConfig` | `KhrVehicleProps["carConfig"]` / `Partial<DroneConfigType>` | `bundle.tune` / `bundle.droneTune` | `@pinkaphant/ecctrl/vehicle` `CarConfigType` and `DroneConfigType` (`"VELOCITY" \| "POSITION"`) overrides. |
|
|
219
|
+
| `vehicleRef` | `RefObject<EcctrlVehicleHandle \| null>` | `undefined` | Live `EcctrlVehicleHandle` ref (`body`, `wheelsInfo`, `propellersInfo`, `setMovement`, `setGear`). |
|
|
220
|
+
| `getInput` | `KolmoInputGetter` | `undefined` | Custom input reader overriding keyboard/touch/bot input. |
|
|
221
|
+
| `driver` | `(veh: EcctrlVehicleHandle, dt: number, state: RootState) => void` | `undefined` | Custom per-frame driver callback replacing default `stepKolmoVehicleFrame` control. |
|
|
222
|
+
| `cameraController` | `(veh: EcctrlVehicleHandle, dt: number, state: RootState) => void` | `undefined` | Custom chase/cockpit camera callback. |
|
|
223
|
+
| `children` | `ReactNode` | `undefined` | Additional visual children mounted inside the vehicle body. |
|
|
224
|
+
|
|
225
|
+
### `<KolmoActor>` and `<KolmoWardrobeRig>`
|
|
226
|
+
|
|
227
|
+
`<KolmoActor>` wraps `@pinkaphant/ecctrl` `<Ecctrl>` (`maxWalkVel = 3.2`, `maxRunVel = 7.2`, `jumpVel = 5.8`, `enableCustomGravity` from `KolmoGravityContext`, and `userData.ecctrl.excludeVehicleRay = true`) plus `<EcctrlCameraControls makeDefault minPolarAngle={0.12} maxPolarAngle={Math.PI - 0.12} smoothTime={0.08} />`.
|
|
228
|
+
|
|
229
|
+
| Prop (`KolmoActorProps`) | Type | Default | Description |
|
|
230
|
+
| :--- | :--- | :--- | :--- |
|
|
231
|
+
| `position` | `[number, number, number]` | `WorldSpawnTrait.actorPos ?? [0, 1.4, 0]` | Initial spawn position when on foot. |
|
|
232
|
+
| `enabled` | `boolean` | `true` | Enables actor input, vehicle boarding/exiting, and `<Ecctrl>` stepping. |
|
|
233
|
+
| `getInput` | `KolmoInputGetter` | `undefined` | Custom input getter. |
|
|
234
|
+
| `ecctrlProps` | `Omit<EcctrlProps, "ref">` | `undefined` | Overrides forwarded to `@pinkaphant/ecctrl` `<Ecctrl>`. |
|
|
235
|
+
| `cameraProps` | `Omit<ComponentProps<typeof EcctrlCameraControls>, "ref"> \| null \| false` | `undefined` | Overrides `<EcctrlCameraControls>`, or disables it when `null` or `false`. |
|
|
236
|
+
| `bundle` / `rawGlbBytes` / `modelUrl` | `KhrAssetBundle \| null` / `Uint8Array \| ArrayBuffer \| null` / `string \| null` | `undefined` | Character asset mounted via `<KolmoWardrobeRig>` instead of the procedural fallback pilot mesh. |
|
|
237
|
+
| `heightMeters` | `number` | `1.75` | Normalized SI character height in meters for `<KolmoWardrobeRig>`. |
|
|
238
|
+
| `buildScale` | `readonly [number, number, number]` | `undefined` | Non-uniform `[x, y, z]` scale (clamped `>= 0.2`) applied by `applyActorWardrobeMutations`. |
|
|
239
|
+
| `hiddenLayers` | `readonly string[]` | `undefined` | Case-insensitive mesh name tokens hidden on the character rig. |
|
|
240
|
+
| `paletteOverrides` | `Readonly<Record<string, string>>` | `undefined` | Mesh-name substring to CSS hex color overrides. |
|
|
241
|
+
| `children` | `ReactNode` | `undefined` | Custom child mesh overriding both `<KolmoWardrobeRig>` and the default mesh. |
|
|
242
|
+
|
|
243
|
+
`<KolmoWardrobeRig>` (`KolmoWardrobeRigProps`) accepts `{ bundle?, rawGlbBytes?, modelUrl?, scene?, heightMeters = 1.75, buildScale?, hiddenLayers?, paletteOverrides?, ecctrlRef?, footBaseY = -0.58 }` and is paired with `applyActorWardrobeMutations(root, { hiddenLayers?, paletteOverrides?, buildScale? }): void`.
|
|
244
|
+
|
|
245
|
+
### `<KolmoSurface>`, `<KolmoProp>`, `<KolmoIsland>`, `<KolmoLongDrive>`, and `<ShiftedFixedBody>`
|
|
246
|
+
|
|
247
|
+
- **`<KolmoSurface>`** (`KolmoSurfaceProps: { src?: string; bundle?: KhrAssetBundle; size?: number; position?: [number, number, number] }`): Mounts `bundle` or `src` as a fixed `<KhrAssembly fixedRoot />`; when both are omitted, renders a `size × 1 × size` m gridded arena slab (`size = 200`, `position = [0, 0, 0]`).
|
|
248
|
+
- **`<KolmoProp>`** (`KolmoPropProps: { src?: string; bundle?: KhrAssetBundle; position?: [number, number, number]; fixed?: boolean }`, `position = [0, 0, 0]`, `fixed = false`): Mounts an interactive `<KhrAssembly>` whose motorized joints toggle open/closed on click via `togglePropJoint(handle, bundle, openState, clickedObj?, perBodyOpen?): boolean`. Returns `null` when both `src` and `bundle` are omitted.
|
|
249
|
+
- **`<KolmoIsland>`** (`KolmoIslandProps: { seed?: number; size?: number; segments?: number; settlementTier?: SettlementTier; offX?: number; offZ?: number; autoSpawn?: boolean }`): Defaults `{ seed = 77, size = 960, segments = 160, settlementTier = "town", offX = 0, offZ = 0, autoSpawn = true }`. Helpers: `getCachedIslandPlan(seed, size): IslandWorldPlan` and `computeIslandSpawnPose(seed, size): IslandSpawnPose`.
|
|
250
|
+
- **`<KolmoLongDrive>`** (`KolmoLongDriveProps: { seed?: string | number; pureMainland?: boolean; initialOrigin?: readonly [number, number]; onOriginRebase?: (originX: number, originZ: number, dx: number, dz: number) => void; renderCellExtra?: (mx: number, mz: number, plan: MacroCellPlan2D, offX: number, offZ: number) => ReactNode }`): Defaults `{ seed = 77, pureMainland = false, initialOrigin = [0, 0] }`. Streams macro-cells and rebases floating-origin entities every `192 m`. Helpers: `computeLongDriveBridgeheadSpawn(seed, islandSize?)` and `computeLongDriveMainlandSpawn(seed, mx?, mz?)`.
|
|
251
|
+
- **`<ShiftedFixedBody>`** (`ShiftedFixedBodyProps`): Fixed Rapier rigid body registered with `FloatingBodyTrait` so `shiftFloatingOriginEntities` translates it cleanly during `192 m` origin rebases.
|
|
252
|
+
|
|
253
|
+
### Engine Hooks, Koota Store, Khronos GLB Loader, Touch & Bot WebMCP
|
|
254
|
+
|
|
255
|
+
- **Session Hook & Actions**:
|
|
256
|
+
- `useKolmoGame(explicitWorld?: World | null): KolmoGameHookState` — returns `{ world, mode, activeVehicleId, nearVehicleId, retroPreset, boardVehicle, exitVehicle, setRetroPreset, resetVehicle }`.
|
|
257
|
+
- `kolmoActions(world = kolmoWorld)` — `{ boardVehicle(vehicleId), exitVehicle(), setRetroPreset(preset), setSpawn(spawn), resetVehicle(vehicleId?) }`.
|
|
258
|
+
- `flipVehicleBodyUpright(veh: EcctrlVehicleHandle): void` — lifts `veh.body` `+1.2 m`, zeroes linear/angular velocity, and resets roll/pitch while preserving heading yaw.
|
|
259
|
+
- **Koota World, Traits & Floating Origin**:
|
|
260
|
+
- Singleton & telemetry: `kolmoWorld`, `useActiveKolmoWorld()`, `kolmoTelemetry` (`KolmoTelemetryState`: `{ mode: KolmoControlMode, speedKmh, rpm, gear, throttle, boost, activeVehicleId, nearVehicleId }`), `ensureWorldSession(world)`, `publishWorldSpawn(world, spawn: WorldSpawnData)`.
|
|
261
|
+
- Traits & queries: `ActorTrait`, `VehicleTrait`, `VehicleTelemetryTrait`, `TransformTrait`, `VelocityTrait`, `FloatingBodyTrait`, `InteractableTrait`, `WorldSessionTrait`, `WorldSpawnTrait`, `PilotedTag`, `PilotLink`, `vehicleSimQuery`, `pilotedVehicleQuery`, `writeEntityKinematics`, `writeVehicleTelemetry`.
|
|
262
|
+
- Floating origin: `readFloatingOriginAnchorXZ(world, camera, out): [number, number]`, `shiftFloatingOriginEntities(world, dx, dz, rapierSync?: FloatingOriginRapierSync): void`.
|
|
263
|
+
- **Khronos GLB Loader (`MeshoptDecoder` + `KTX2Loader`)**:
|
|
264
|
+
- `createKolmoGltfLoader(options?: KolmoGltfLoaderOptions): GLTFLoader` — attaches `MeshoptDecoder` (`EXT_meshopt_compression`) and, when `options.renderer` is provided, a shared `KTX2Loader` (`KHR_texture_basisu`, default `basisTranscoderPath = "/basis/"`). Does not mount `DRACOLoader`.
|
|
265
|
+
- `parseKolmoGlbBuffer(buffer: ArrayBuffer, options?: KolmoGltfLoaderOptions): Promise<THREE.Group>` — validates binary glTF 2.0 magic (`0x46546c67`, version `2`, `>= 12` bytes), awaits `MeshoptDecoder.ready`, and parses `buffer`.
|
|
266
|
+
- `loadKolmoGlbUrl(url: string, options?: KolmoGltfLoaderOptions): Promise<THREE.Group>` — fetches `url` and delegates to `parseKolmoGlbBuffer`.
|
|
267
|
+
- **Procedural & Auto-Compiled Vehicles**:
|
|
268
|
+
- `buildProceduralCarGlb(presetOrId?: PaperShellPreset | PaperShellPresetId, shadingMode?: ShadingMode, options?: ProceduralCarOptions): Promise<Uint8Array>` (defaults: `"coupe_86"`, `"dc-smooth"`).
|
|
269
|
+
- `loadOrAutoCompileVehicleGlb(source: string | Uint8Array | ArrayBuffer, opts?: AutoCompileVehicleOptions): Promise<{ bundle: KhrAssetBundle; bytes: Uint8Array }>` (`opts?: { horsepower?, targetLengthM?, massKg?, driveType? }`).
|
|
270
|
+
- **Keyboard, Touch & Live Bot WebMCP**:
|
|
271
|
+
- Keyboard: `useKolmoInput(getInput?: KolmoInputGetter): () => KolmoInputState`, `KOLMO_KEY_MAP`, `EMPTY_KOLMO_INPUT`, `type KolmoKeyAction`.
|
|
272
|
+
- Touch: `KOLMO_STICK_DEADZONE` (`0.08`), `kolmoTouchInput` (`KolmoTouchInputState`), `detectTouchDevice()`, `computeVirtualStick(dx, dy, maxRadius, deadzone?): VirtualStickSample`, `applyKolmoTouchLook(controls: KolmoLookControls, sensitivity?)`, `resetKolmoTouchInput()`, `resetKolmoTouchStick()`, `defaultTouchActionsForMode(mode, nearVehicleId): KolmoTouchActionButton[]`, `snapshotKolmoTouchInput()`, `writeKolmoTouchAction(action, down)`.
|
|
273
|
+
- Bot Drive & Co-Watch Journal: `useKolmoDriveWebMcp(world?, enabled?, onExternalReset?)`, `createKolmoDriveWebMcpTools(getWorld?, onExternalReset?): readonly DriveWebMcpToolDef[]` (registers `kolmo_drive` and `kolmo_telemetry` on `navigator.modelContext`), `kolmoBotInput` (`KolmoBotDriveState`), `setKolmoBotDriveInput`, `clearKolmoBotDriveInput`, `readActiveKolmoBotInput`, `snapshotKolmoLiveTelemetry(world?): KolmoLiveTelemetrySnapshot`, `registerKolmoExternalTelemetry(reader: KolmoExternalTelemetryReader | null)`, `<KolmoBotJournalFeed>` (`KolmoBotJournalFeedProps`), `getKolmoBotJournal()`, `recordKolmoBotAction(entry: KolmoBotActionEntry)`, `clearKolmoBotJournal()`, `subscribeKolmoBotJournal(listener)`, `summarizeBotToolCall(tool, input, result, ok)`, `wrapWebMcpToolWithJournal(tool)`.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## `@pinkaphant/kolmo/physics`
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
import {
|
|
281
|
+
KolmoPhysics,
|
|
282
|
+
KolmoGravityContext,
|
|
283
|
+
useIsKolmoCustomGravity,
|
|
284
|
+
useOptionalKootaWorld,
|
|
285
|
+
G_SI,
|
|
286
|
+
resolveAttractorMu,
|
|
287
|
+
evaluateNBodyGravity,
|
|
288
|
+
createNBodyGravityField,
|
|
289
|
+
computeCircularOrbitSpeed,
|
|
290
|
+
type KolmoPhysicsProps,
|
|
291
|
+
type KolmoGravitySpec,
|
|
292
|
+
type KolmoPointGravity,
|
|
293
|
+
type KolmoNBodyGravity,
|
|
294
|
+
type KolmoGravityAttractor,
|
|
295
|
+
type KolmoGravityCallback,
|
|
296
|
+
type KolmoTimeControlValue,
|
|
297
|
+
} from "@pinkaphant/kolmo/physics";
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Note: `KolmoPhysics`, `KolmoGravityContext`, `useIsKolmoCustomGravity`, `useOptionalKootaWorld`, `evaluateNBodyGravity`, `createNBodyGravityField`, `computeCircularOrbitSpeed`, and the gravity types are also re-exported from `@pinkaphant/kolmo/engine` and `@pinkaphant/kolmo`. `G_SI` and `resolveAttractorMu` are exported exclusively from `@pinkaphant/kolmo/physics`.
|
|
301
|
+
|
|
302
|
+
### `<KolmoPhysics>` and `KolmoGravitySpec`
|
|
303
|
+
|
|
304
|
+
Wraps `@khr3/core` `<PhysicsWorld>` (`<Physics paused timeStep="vary">` + `@pinkaphant/ecctrl/time` `<TimeControl>`) inside a Koota `<WorldProvider>` and `KolmoGravityContext`.
|
|
305
|
+
|
|
306
|
+
| Prop (`KolmoPhysicsProps`) | Type | Default | Description |
|
|
307
|
+
| :--- | :--- | :--- | :--- |
|
|
308
|
+
| `gravity` | `KolmoGravitySpec` | `"planar"` | `"planar"` (`[0, -9.81, 0]`), `"zero"` (`[0, 0, 0]`), `"custom"` (leaves caller-managed `useCustomGravity` active with `[0, 0, 0]` Rapier gravity), `[gx, gy, gz]`, `KolmoPointGravity`, `KolmoNBodyGravity`, or `KolmoGravityCallback`. |
|
|
309
|
+
| `paused` | `boolean` | `false` | Holds simulation state stationary while `true`. |
|
|
310
|
+
| `timeScale` | `KolmoTimeControlValue` (`number \| RefObject<number>`) | `1` | Step delta multiplier. |
|
|
311
|
+
| `maxDelta` | `KolmoTimeControlValue` | `1 / 30` | Maximum step delta before `timeScale`. |
|
|
312
|
+
| `physicsDebug` | `boolean` | `false` | Enables Rapier debug rendering. |
|
|
313
|
+
| `world` | `World \| null` | `outerWorld ?? kolmoWorld` | Koota ECS world bound to `<WorldProvider>`. |
|
|
314
|
+
| `children` | `ReactNode` | required | Scene rigid bodies and controllers (wrapped in `<Suspense fallback={null}>`). |
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
export type KolmoPointGravity = {
|
|
318
|
+
readonly kind: "point";
|
|
319
|
+
readonly center: readonly [number, number, number];
|
|
320
|
+
readonly surfaceG: number;
|
|
321
|
+
readonly radius: number;
|
|
322
|
+
readonly inverseSquare?: boolean; // false = constant radial surfaceG; true = softened 1/r^2 via evaluateNBodyGravity
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
export interface KolmoGravityAttractor {
|
|
326
|
+
readonly id?: string;
|
|
327
|
+
readonly position: readonly [number, number, number];
|
|
328
|
+
readonly mu?: number; // Direct gravitational parameter G * M (m^3 / s^2)
|
|
329
|
+
readonly massKg?: number; // Mass in kg (mu = massKg * gravitationalConstant)
|
|
330
|
+
readonly surfaceG?: number; // Surface acceleration (m/s^2) at `radius`
|
|
331
|
+
readonly radius?: number; // Reference radius R (m)
|
|
332
|
+
readonly softeningM?: number;// Softening length eps (m); defaults to max(1e-4, radius > 0 ? radius * 0.05 : 0.5)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface KolmoNBodyGravity {
|
|
336
|
+
readonly kind: "nbody";
|
|
337
|
+
readonly attractors: readonly KolmoGravityAttractor[];
|
|
338
|
+
readonly gravitationalConstant?: number; // Defaults to G_SI
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export type KolmoGravityCallback = (pos: THREE.Vector3, out: THREE.Vector3) => THREE.Vector3;
|
|
52
342
|
```
|
|
53
343
|
|
|
344
|
+
### N-Body & Orbital Functions
|
|
345
|
+
|
|
346
|
+
- `G_SI = 6.6743e-11` — CODATA Newtonian gravitational constant ($\text{m}^3\,\text{kg}^{-1}\,\text{s}^{-2}$).
|
|
347
|
+
- `resolveAttractorMu(attractor: KolmoGravityAttractor, gravitationalConstant = G_SI): { mu: number; epsSq: number }` — resolves `mu` by precedence `attractor.mu` $\to$ `surfaceG * (R^2 + eps^2)^(3/2) / R` (so $|\mathbf{g}(R)| = \text{surfaceG}$ is exact) $\to$ `massKg * gravitationalConstant`.
|
|
348
|
+
- `evaluateNBodyGravity(pos: { readonly x: number; readonly y: number; readonly z: number }, attractors: readonly KolmoGravityAttractor[], out: THREE.Vector3, gravitationalConstant = G_SI): THREE.Vector3` — writes $\sum_i \mu_i (\mathbf{p}_i - \mathbf{x}) / (r_i^2 + \epsilon_i^2)^{3/2}$ into `out` (skipping $r_i^2 < 10^{-12}$).
|
|
349
|
+
- `createNBodyGravityField(attractors: readonly KolmoGravityAttractor[], gravitationalConstant = G_SI): KolmoGravityCallback`.
|
|
350
|
+
- `computeCircularOrbitSpeed(attractor: KolmoGravityAttractor, orbitRadiusM: number, gravitationalConstant = G_SI): number` — returns $v_{\text{circ}} = r \sqrt{\mu / (r^2 + \epsilon^2)^{3/2}}$ in $\text{m/s}$.
|
|
351
|
+
- `useIsKolmoCustomGravity(): boolean` & `useOptionalKootaWorld(): World | null`.
|
|
352
|
+
|
|
54
353
|
---
|
|
55
354
|
|
|
56
|
-
##
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- `
|
|
67
|
-
- `
|
|
68
|
-
- `
|
|
69
|
-
- `KolmoIsland` (`Island`, [kolmoIsland.tsx](../src/engine/kolmoIsland.tsx), [islandSettlementMesh.tsx](../src/engine/islandSettlementMesh.tsx), [causewayBridge.tsx](../src/engine/causewayBridge.tsx)) — `{ seed = 77, size = 960, segments = 160, settlementTier = "town", offX = 0, offZ = 0, autoSpawn = true }` + `getCachedIslandPlan`, `computeIslandSpawnPose`.
|
|
70
|
-
- `KolmoLongDrive` (`LongDrive`, [kolmoLongDrive.tsx](../src/engine/kolmoLongDrive.tsx), [longDriveKit.tsx](../src/engine/longDriveKit.tsx), [longDriveRoadside.tsx](../src/engine/longDriveRoadside.tsx), [macroCellBuilder.ts](../src/engine/macroCellBuilder.ts), [mainlandMacroCell.tsx](../src/engine/mainlandMacroCell.tsx)) — `{ seed = 77, pureMainland = false, initialOrigin = [0, 0], onOriginRebase, renderCellExtra }` (`seed?: string | number`) + `computeLongDriveBridgeheadSpawn`, `computeLongDriveMainlandSpawn`.
|
|
71
|
-
- Scene Rigs ([kolmoRigs.tsx](../src/engine/kolmoRigs.tsx), [shiftedFixedBody.tsx](../src/engine/shiftedFixedBody.tsx)) — `RetroViewportSync`, `RoomEnvRig`, `ShadowSnapRig`, `ShiftedFixedBody`.
|
|
72
|
-
|
|
73
|
-
### Hooks, Input, Store & Procedural Builders
|
|
74
|
-
- `useKolmoGame(explicitWorld?)` (implemented in [kolmoHud.tsx](../src/engine/kolmoHud.tsx), re-exported through [kolmoGame.tsx](../src/engine/kolmoGame.tsx) and [src/engine/index.ts](../src/engine/index.ts)), `useKolmoInput(getInput?)`, `KOLMO_KEY_MAP`, `EMPTY_KOLMO_INPUT` ([kolmoInput.ts](../src/engine/kolmoInput.ts)).
|
|
75
|
-
- Touch Input State ([kolmoTouchState.ts](../src/engine/kolmoTouchState.ts)) — `KOLMO_STICK_DEADZONE` (`0.08`), `kolmoTouchInput`, `detectTouchDevice()`, `computeVirtualStick(dx, dy, maxRadius, deadzone?)`, `applyKolmoTouchLook(controls, sensitivity?)`, `resetKolmoTouchInput()`, `resetKolmoTouchStick()`, `defaultTouchActionsForMode(mode, nearVehicleId)`, `snapshotKolmoTouchInput()`, `writeKolmoTouchAction(action, down)`, plus `KolmoTouchInputState`, `KolmoTouchActionButton`, `KolmoLookControls`, `VirtualStickSample`, `MobileTouchOverlayProps`.
|
|
76
|
-
- `buildProceduralCarGlb(presetOrId = "coupe_86", shadingMode = "dc-smooth", options?)` ([kolmoProcedural.ts](../src/engine/kolmoProcedural.ts)) & `loadOrAutoCompileVehicleGlb(source, opts?)` ([kolmoVehicleAutoCompile.ts](../src/engine/kolmoVehicleAutoCompile.ts)).
|
|
77
|
-
- Koota Store, Actions & Floating Origin ([kolmoStore.ts](../src/engine/kolmoStore.ts), [kolmoTraits.ts](../src/engine/kolmoTraits.ts), [kolmoActions.ts](../src/engine/kolmoActions.ts), [kolmoFloatingOrigin.ts](../src/engine/kolmoFloatingOrigin.ts)) — `kolmoWorld`, `kolmoActions(world)`, `kolmoTelemetry`, `flipVehicleBodyUpright(veh)`, `ActorTrait`, `FloatingBodyTrait`, `InteractableTrait`, `PilotLink`, `PilotedTag`, `TransformTrait`, `VelocityTrait`, `VehicleTelemetryTrait`, `VehicleTrait`, `WorldSessionTrait`, `WorldSpawnTrait`, `vehicleSimQuery`, `pilotedVehicleQuery`, `writeEntityKinematics`, `writeVehicleTelemetry`, `ensureWorldSession`, `publishWorldSpawn`, `useActiveKolmoWorld`, `readFloatingOriginAnchorXZ`, `shiftFloatingOriginEntities`.
|
|
355
|
+
## `@pinkaphant/kolmo/vite`
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
import {
|
|
359
|
+
KOLMO_SINGLETON_DEDUPE,
|
|
360
|
+
KOLMO_ROLLDOWN_BUILD,
|
|
361
|
+
externalizeRapierWasm,
|
|
362
|
+
} from "@pinkaphant/kolmo/vite";
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
- `KOLMO_SINGLETON_DEDUPE: string[]` — `["react", "react-dom", "three", "@react-three/fiber", "@react-three/drei", "@react-three/rapier", "@dimforge/rapier3d-compat", "@pinkaphant/ecctrl", "@khr3/core", "@khr3/c12", "koota", "maath", "zustand"]` for Vite `resolve.dedupe`.
|
|
366
|
+
- `externalizeRapierWasm(): Plugin` — no-op build compatibility plugin (`{ name: "kolmo-rapier-compat", apply: "build" }`; `@dimforge/rapier3d-compat` loads directly in standard Vite).
|
|
367
|
+
- `KOLMO_ROLLDOWN_BUILD: NonNullable<UserConfig["build"]>` — `{}` compatibility export.
|
|
78
368
|
|
|
79
369
|
---
|
|
80
370
|
|
|
81
|
-
##
|
|
371
|
+
## `@pinkaphant/kolmo/world`
|
|
372
|
+
|
|
373
|
+
Procedural island, road-spline, splat-map, `Seed8`, and macro-cell highway planning in SI meters (`C12` = 3.0 m modular tile unit from `@khr3/c12`; floating-origin chunks step in `192 m` increments).
|
|
374
|
+
|
|
375
|
+
```ts
|
|
376
|
+
import {
|
|
377
|
+
planIslandWorld,
|
|
378
|
+
makeIslandHeightfn,
|
|
379
|
+
makeTerrain,
|
|
380
|
+
sampleHeightfield,
|
|
381
|
+
SHOULDER_K,
|
|
382
|
+
roadFromPoints,
|
|
383
|
+
closedRoadFromPoints,
|
|
384
|
+
growRoad,
|
|
385
|
+
maxGrade,
|
|
386
|
+
frontage,
|
|
387
|
+
buildRoadRibbonGeometry,
|
|
388
|
+
buildCarvedTerrainGeometry,
|
|
389
|
+
planDirtSpurs,
|
|
390
|
+
buildHighwayAsphaltTexture,
|
|
391
|
+
bakeWorldSplatMaps,
|
|
392
|
+
InfiniteLongDrivePlanner,
|
|
393
|
+
MACRO_SIZE_M,
|
|
394
|
+
FLOATING_ORIGIN_STEP_M,
|
|
395
|
+
C12_TILE_M,
|
|
396
|
+
TILES_PER_MACRO,
|
|
397
|
+
C12TileKind,
|
|
398
|
+
quantizeFloatingOrigin192,
|
|
399
|
+
routeMacroKnightAStar,
|
|
400
|
+
buildDodecagonalCivicHub,
|
|
401
|
+
SEED8_ALPHABET,
|
|
402
|
+
generateSeed8,
|
|
403
|
+
isValidSeed8,
|
|
404
|
+
normalizeSeed8,
|
|
405
|
+
hashSeed,
|
|
406
|
+
SeededSimplex2D,
|
|
407
|
+
SplitMix32,
|
|
408
|
+
mulberry32,
|
|
409
|
+
seedFrom,
|
|
410
|
+
childSeed,
|
|
411
|
+
valueNoise2,
|
|
412
|
+
fbm2,
|
|
413
|
+
} from "@pinkaphant/kolmo/world";
|
|
414
|
+
```
|
|
82
415
|
|
|
83
|
-
-
|
|
84
|
-
-
|
|
416
|
+
- **Island, Terrain & Roads**:
|
|
417
|
+
- `planIslandWorld(seed?: number, options?: IslandOptions): IslandWorldPlan` & `makeIslandHeightfn(seed: number, size: number): (x: number, z: number) => number`.
|
|
418
|
+
- `makeTerrain(heightfn: (x: number, z: number) => number, options?: TerrainOptions): Terrain`, `sampleHeightfield`, `SHOULDER_K` (types: `NearestOnRoad`, `RoadSplatSample`).
|
|
419
|
+
- `roadFromPoints(pts: readonly V3[], halfWidth?: number, sampleStep?: number, closed?: boolean): Road`, `closedRoadFromPoints`, `growRoad(options: GrowRoadOptions): Road`, `maxGrade(road: Road): number`, `frontage(road: Road, options?: FrontageOptions): FrontageLot[]` (type: `RoadSample`).
|
|
420
|
+
- `buildCarvedTerrainGeometry(terrain: Terrain, size: number, segments: number, uvDomain?: CarvedTerrainUvDomain): BuiltCarvedTerrain`, `buildRoadRibbonGeometry(road: Road, options?: RoadRibbonOptions): BuiltRoadRibbon`, `planDirtSpurs(plan: IslandWorldPlan, count?: number): { spurs: Road[]; junctions: TJunctionSpec[] }`, `buildHighwayAsphaltTexture(): THREE.DataTexture`.
|
|
421
|
+
- **Macro-Cell Highway & Floating Origin**:
|
|
422
|
+
- Constants: `C12_TILE_M = 3`, `FLOATING_ORIGIN_STEP_M = 192`, `MACRO_SIZE_M`, `TILES_PER_MACRO`, `C12TileKind`.
|
|
423
|
+
- `new InfiniteLongDrivePlanner(seed: string | number)` — `.generateMacroCell2D(mx: number, mz: number): MacroCellPlan2D` (types: `MacroSettlementTier`, `RoadsideStop2D`, `RoadsideStopKind`, `SharedBorderPortal`, `ZonedParcel2D`).
|
|
424
|
+
- `quantizeFloatingOrigin192(worldX: number, worldZ: number): FloatingOriginFrame` — snaps world $(X, Z)$ onto `192 m` chunk origins.
|
|
425
|
+
- `routeMacroKnightAStar` & `buildDodecagonalCivicHub`.
|
|
426
|
+
- **Splat Maps, `Seed8` & Deterministic PRNG**:
|
|
427
|
+
- `bakeWorldSplatMaps(plan: IslandWorldPlan, gridCells?: number, dirtSpurs?: readonly Road[])` (types: `WorldGenConfig`, `WorldGenResult`).
|
|
428
|
+
- `SEED8_ALPHABET` (8-character uppercase alphanumeric shareable seed alphabet omitting `0`), `generateSeed8(): string`, `isValidSeed8(s: string): boolean`, `normalizeSeed8(s: string): string`, `hashSeed(seed: string | number): number`.
|
|
429
|
+
- `SeededSimplex2D`, `SplitMix32`, `mulberry32(seed): Rng`, `seedFrom`, `childSeed`, `valueNoise2`, `fbm2(x, z, opts?: FbmOptions)`.
|
|
85
430
|
|
|
86
431
|
---
|
|
87
432
|
|
|
88
|
-
##
|
|
433
|
+
## `@pinkaphant/kolmo/shaders`
|
|
434
|
+
|
|
435
|
+
```ts
|
|
436
|
+
import {
|
|
437
|
+
RETRO_PRESETS,
|
|
438
|
+
RETRO_DREAMCAST,
|
|
439
|
+
RETRO_PSX_PLUS,
|
|
440
|
+
RETRO_PS2_SHINOBI,
|
|
441
|
+
RETRO_CLEAN_HD,
|
|
442
|
+
RETRO_COLOR_MODES,
|
|
443
|
+
RETRO_UNIFORMS,
|
|
444
|
+
PS1_SNAP_RESOLUTION,
|
|
445
|
+
PALETTE_CRUNCHY_16,
|
|
446
|
+
PALETTE_CRUNCHY_64,
|
|
447
|
+
GLSL_BAYER_RGB555,
|
|
448
|
+
GLSL_RETRO_QUANTIZE,
|
|
449
|
+
getRetroPreset,
|
|
450
|
+
getRetroShaderUniforms,
|
|
451
|
+
getColorQuantVector,
|
|
452
|
+
getPaletteLutTexture,
|
|
453
|
+
buildPaletteLutData,
|
|
454
|
+
syncRetroUniforms,
|
|
455
|
+
syncRetroViewport,
|
|
456
|
+
computeRetroDpr,
|
|
457
|
+
applyRetroTextureFiltering,
|
|
458
|
+
applyRetroFilteringToMaterial,
|
|
459
|
+
applyRetroMaterial,
|
|
460
|
+
applyPs1Material,
|
|
461
|
+
applySceneRetroMaterials,
|
|
462
|
+
KolmoSkybox,
|
|
463
|
+
KolmoExoplanet,
|
|
464
|
+
KolmoEmitterRig,
|
|
465
|
+
SPLAT_LAYER,
|
|
466
|
+
createPS2WorldTextures,
|
|
467
|
+
generatePS2DetailSlices,
|
|
468
|
+
createPS2TerrainMaterialWebGL,
|
|
469
|
+
createPS2RoadMaterialWebGL,
|
|
470
|
+
mountPS2WorldMeshes,
|
|
471
|
+
} from "@pinkaphant/kolmo/shaders";
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### Retro Presets, Uniforms & Material Patching
|
|
475
|
+
|
|
476
|
+
- **Presets & Color Quantization**: `RETRO_PRESETS` (`Record<RetroPresetId, RetroPreset>`), `RETRO_DREAMCAST`, `RETRO_PSX_PLUS`, `RETRO_PS2_SHINOBI`, `RETRO_CLEAN_HD`, `getRetroPreset(idOrPreset)`, `RETRO_COLOR_MODES` (`Record<RetroColorMode, RetroColorModeSpec>`), `PALETTE_CRUNCHY_16`, `PALETTE_CRUNCHY_64`, `buildPaletteLutData(hexPalette)`, `getPaletteLutTexture(mode)`, `getColorQuantVector(mode)`.
|
|
477
|
+
- **Viewport & Uniform Sync**: `RETRO_UNIFORMS` (shared `{ uPs1Grid, uSnapStrength, uAffineStrength, uGouraudStrength, uN64FilterStrength, uDitherMix, uDitherScale, uColorQuant, uPaletteLut }`), `PS1_SNAP_RESOLUTION`, `getRetroShaderUniforms()`, `syncRetroUniforms(preset)`, `syncRetroViewport(widthCss, heightCss, renderScale?)`, `computeRetroDpr(devicePixelRatio, renderScale?)`.
|
|
478
|
+
- **Material & Texture Patchers**:
|
|
479
|
+
- `applyRetroMaterial<T extends THREE.Material>(material: T, options?: RetroMaterialOptions): T` (aliased as `applyPs1Material`) — idempotently chains `onBeforeCompile` and `customProgramCacheKey` to inject vertex grid snapping (guarded past the near plane), affine UV / N64 3-point filtering, Gouraud lighting mix, and Bayer RGB555 / palette LUT quantization (`GLSL_BAYER_RGB555`, `GLSL_RETRO_QUANTIZE`).
|
|
480
|
+
- `applySceneRetroMaterials(root: THREE.Object3D, options?: RetroMaterialOptions): void`.
|
|
481
|
+
- `applyRetroTextureFiltering(tex: THREE.Texture, opts?: RetroTextureOptions): void` & `applyRetroFilteringToMaterial(mat: THREE.Material, opts?: RetroTextureOptions): void` (preserves `NoColorSpace` on normal/roughness/metalness/AO data maps).
|
|
89
482
|
|
|
90
|
-
|
|
483
|
+
### `<KolmoSkybox>`, `<KolmoExoplanet>`, `<KolmoEmitterRig>` & PS2 Materials
|
|
91
484
|
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
485
|
+
- **`<KolmoSkybox>`** (`KolmoSkyboxProps: { sunDirection?: THREE.Vector3 }`): Procedural sky/nebula dome (`KEY_SUN_DIRECTION`, `ATMO_VERT`, `ATMO_FRAG`).
|
|
486
|
+
- **`<KolmoExoplanet>`** (`KolmoExoplanetProps`): `{ position = [-420, 140, -980], radius = 180, ringInner = radius * 1.45, ringOuter = radius * 2.35, color = "#47d7ff", collider = false, moonlets = true, gravityWellActive = false }`. Exports `RING_MOONLET_COUNT` and `populateMoonletMatrices(instancedMesh, ringInner, ringOuter)`.
|
|
487
|
+
- **`<KolmoEmitterRig>`** (`KolmoEmitterRigProps: { emitters: readonly DecodedKolmoEmitter[]; signalsRef: { readonly current: KolmoSignalState | null }; comOffset?: readonly [number, number, number] }`, `comOffset = [0, 0, 0]`): Drives `plume`, `sparkle`, `fume`, `trail`, and `flare` shader emitters (`PLUME_VERT`, `PLUME_FRAG`, `PARTICLE_VERT`, `PARTICLE_FRAG`).
|
|
488
|
+
- **PS2 Terrain & Road Splat Materials**: `SPLAT_LAYER`, `createPS2WorldTextures(): PS2TextureBundle`, `generatePS2DetailSlices()`, `createPS2TerrainMaterialWebGL(textures: PS2TextureBundle, opts?: PS2TerrainMaterialOptions)`, `createPS2RoadMaterialWebGL(textures: PS2TextureBundle, opts?: PS2RoadMaterialOptions)`, `mountPS2WorldMeshes(...) => MountedPS2WorldScene`.
|
|
95
489
|
|
|
96
490
|
---
|
|
97
491
|
|
|
98
|
-
##
|
|
492
|
+
## `@pinkaphant/kolmo/shaders/tsl`
|
|
99
493
|
|
|
100
|
-
|
|
494
|
+
WebGPU / Three.js TSL (`three/webgpu` + `three/tsl`) node material counterparts:
|
|
101
495
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
496
|
+
```ts
|
|
497
|
+
import { createPS2TerrainMaterialTSL, createPS2RoadMaterialTSL } from "@pinkaphant/kolmo/shaders/tsl";
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
- `createPS2TerrainMaterialTSL(textures: PS2TextureBundle)` — returns `{ material, uniforms }` using Three.js TSL nodes.
|
|
501
|
+
- `createPS2RoadMaterialTSL(textures: PS2TextureBundle, preset?: "ASPHALT" | "DIRT")` (default `"ASPHALT"`).
|
|
105
502
|
|
|
106
503
|
---
|
|
107
504
|
|
|
108
|
-
##
|
|
505
|
+
## `@pinkaphant/kolmo/importer`
|
|
506
|
+
|
|
507
|
+
Two-stage 3D asset calibration, cylindrical wheel-coring, surface-peel joint authoring, modular character wardrobe fitting, and KHR/USD/Sand3D `.glb` compilation workbench across all 8 `GateDomain` values: `"vehicle" | "c12" | "launcher" | "person" | "prop" | "junk" | "suika" | "sand3d"`.
|
|
508
|
+
|
|
509
|
+
- **Step 1 (Calibration Plinth & Domain Workshops)**: Orients raw `.glb`, `.gltf`, OpenUSD (`.usd`, `.usda`, `.usdc`, `.usdz`), or `.sand3d`/`.s3d` inputs to `+Y` up / `+Z` forward at SI meter scale (`Y = 0` ground contact), cores fused wheels or peels hinged panels, fits character garments, and stamps `KOLMO_emitter` sockets.
|
|
510
|
+
- **Step 2 (Universal Live Pad)**: Compiles a `KHR_physics_rigid_bodies` `.glb` (`KhrAssetBundle`) and test-drives or articulates it live in Rapier before exporting `.glb` bytes or spawning into `<KolmoGame>`.
|
|
511
|
+
|
|
512
|
+
```ts
|
|
513
|
+
import {
|
|
514
|
+
GlbImportGate,
|
|
515
|
+
ImporterWorkbench,
|
|
516
|
+
WheelRingHandles3D,
|
|
517
|
+
useChopShopController,
|
|
518
|
+
useGateStore,
|
|
519
|
+
detectFusedCarWheels,
|
|
520
|
+
sliceCarWheelCylinders,
|
|
521
|
+
updateWheelCutter,
|
|
522
|
+
extractMeshIslands,
|
|
523
|
+
normalizeSceneToSi,
|
|
524
|
+
selectFacesByClick,
|
|
525
|
+
selectFacesByLoop,
|
|
526
|
+
peelIslandSelection,
|
|
527
|
+
compileKhrAssetGlb,
|
|
528
|
+
bakeUniversalGateGlb,
|
|
529
|
+
bakeArticulatedLauncherGlb,
|
|
530
|
+
convertUsdToGlb,
|
|
531
|
+
useImporterWebMcp,
|
|
532
|
+
buildImporterWebMcpTools,
|
|
533
|
+
WardrobeWorkshopSection,
|
|
534
|
+
listWardrobePieces,
|
|
535
|
+
applyWardrobePiecePatch,
|
|
536
|
+
bindWardrobeToHumanoidSkeleton,
|
|
537
|
+
} from "@pinkaphant/kolmo/importer";
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
### `<GlbImportGate>` (`ImporterWorkbench`) & Subcomponents
|
|
541
|
+
|
|
542
|
+
| Prop (`GlbImportGateProps`) | Type | Default | Description |
|
|
543
|
+
| :--- | :--- | :--- | :--- |
|
|
544
|
+
| `onSpawnInWorld` | `(asset: GateWorldPayload) => void` | `undefined` | Callback invoked when the user or `importer_export({ spawnInWorld: true })` spawns a calibrated `GateWorldPayload` (`{ id, label, kind, domain, glbBytes, bundle }`). |
|
|
545
|
+
| `enableWebMcp` | `boolean` | `true` | Registers all 15 importer + wardrobe tools and `kolmo_drive` / `kolmo_telemetry` on `navigator.modelContext`. |
|
|
546
|
+
| `headerAction` | `ReactNode` | `undefined` | Optional action node rendered in `<GateHudBar>`. |
|
|
547
|
+
|
|
548
|
+
Exported workbench subcomponents and store exports: `GateHudBar` (`GateHudBarProps`, `StampToolId`, `resolveVaultCarSelection`), `Step1CalibrationPlinth` (`Step1CalibrationPlinthProps`), `Step2UniversalPad` (`Step2UniversalPadProps`), `ImperativeVehicleRig` (`ImperativeVehicleRigProps`), `ChopShopPanel` (`ChopShopPanelProps`), `DomainWorkshopPanel` (`DomainWorkshopPanelProps`, `enforceRetroPersonMaterials`), `WardrobeWorkshopSection` (`WardrobeWorkshopSectionProps`), `VfxEmitterPool` (`VfxEmitterPoolProps`), `WheelRingHandles3D` (`WheelRingHandles3DProps`), `makeStarterDomainScene` (`StarterDomainKey`), `registerSand3dStarterFactory`, `buildProceduralDomainScene(domain, recipeId?)` (`C12_PROCEDURAL_RECIPES`, `CRAFT_PROCEDURAL_RECIPES`, `PERSON_PROCEDURAL_RECIPES`, `PROP_PROCEDURAL_RECIPES`, `buildProceduralC12Scene`, `buildProceduralCraftScene`, `buildProceduralPersonScene`, `buildProceduralPropScene`), and `useGateStore` (`gateTelemetry`, `isGateStep1Unlocked`, `FREQ_HZ`, `DAMP_ZETA`, `type GateDomain`, `type GateState`, `type GateStep`, `type VehicleSubArchetype`, `type EraMode`, `type WrenchMode`, `type CalibrationMetrics`, `type DetachedDebrisItem`, `type FreqBucket`, `type DampBucket`).
|
|
549
|
+
|
|
550
|
+
### Fused Wheel Detection, Cylindrical Coring & `<WheelRingHandles3D>`
|
|
551
|
+
|
|
552
|
+
Extracts independent steerable/spinning `Wheel_*` meshes from single-mesh vehicle scans whose tires are fused into the body geometry:
|
|
109
553
|
|
|
110
|
-
|
|
554
|
+
- `detectFusedCarWheels(root: THREE.Object3D, options?: DetectFusedWheelsOptions): WheelCutterSpec[]` — detects `2+` wheel cylinders across `front`, `middle`, and `rear` axles (`left`, `right`, or `center` slots for 3-wheel trikes/landing gear, 4-wheel cars, and 6-wheel 3-axle rigs; `options`: `{ mirrorX = true, minRadius?, maxRadius? }`).
|
|
555
|
+
- `sliceCarWheelCylinders(meshOrScene: THREE.Object3D, cutters: readonly WheelCutterSpec[], options?: SliceCarWheelOptions): SlicedCarWheelResult` — boolean-slices wheel cylinders out of `meshOrScene`, returning `{ wheels, chassis, liner, cutters }`. Default `options`: `{ sealArchLiner: true, mirrorX: true, mirrorOriginX? }`.
|
|
556
|
+
- Cutter & ring helpers: `updateWheelCutter(cutters, id, patch, options?)`, `enforceMirrorCutterSymmetry`, `snapCuttersAxles`, `inferMirrorOriginX`, `mirrorCutterId`, and `<WheelRingHandles3D>` (interactive 3D gizmos for `radius`, `width`, and `(Y, Z)` axle center adjustment).
|
|
557
|
+
- `useChopShopController(onSpawnInWorld?): ChopShopController` — stateful controller managing `st`, `workingScene`, `wardrobeHost`, `islands`, `axles`, `wheelCutters`, `mirrorX`, `snapAxles`, `sealArchLiner`, `isCored`, `patches`, `liveBundle`, `ingestFile`, `forgeScene`, `forgeProceduralCar`, `autoPopWheels`, `updateWheelCutter`, `commitWheelCutter`, `applyWheelCutters`, `toggleMirrorX`, `toggleSnapAxles`, `toggleSealArchLiner`, `cutPart`, `sealAndExport`, `uploadToVault`, and `handleUndoCut`.
|
|
111
558
|
|
|
112
|
-
###
|
|
113
|
-
- `GlbImportGate` (`ImporterWorkbench`, [GlbImportGate.tsx](../src/importer/GlbImportGate.tsx)) — `{ onSpawnInWorld?, enableWebMcp = true, headerAction? }`. Accepts `.glb`, `.gltf`, `.usd`, `.usda`, `.usdc`, `.usdz`, `.sand3d`, `.s3d`, `.py`, and `.json` across all 8 `GateDomain` values (`"vehicle" | "c12" | "launcher" | "person" | "prop" | "junk" | "suika" | "sand3d"`).
|
|
114
|
-
- Plinth, Pad & Panels ([Step1CalibrationPlinth.tsx](../src/importer/Step1CalibrationPlinth.tsx), [Step1ExplodedIslands.tsx](../src/importer/Step1ExplodedIslands.tsx), [Step2UniversalPad.tsx](../src/importer/Step2UniversalPad.tsx), [LiveDrivePads.tsx](../src/importer/LiveDrivePads.tsx), [ImperativeVehicleRig.tsx](../src/importer/ImperativeVehicleRig.tsx), [PaperShellDebrisRig.tsx](../src/importer/PaperShellDebrisRig.tsx), [ChopShopPanel.tsx](../src/importer/ChopShopPanel.tsx), [DomainWorkshopPanel.tsx](../src/importer/DomainWorkshopPanel.tsx), [GateHudBar.tsx](../src/importer/GateHudBar.tsx), [R2VaultDrawer.tsx](../src/importer/R2VaultDrawer.tsx), [VfxEmitterPool.tsx](../src/importer/VfxEmitterPool.tsx), [starterScene.ts](../src/importer/starterScene.ts)) — `Step1CalibrationPlinth`, `Step2UniversalPad`, `ImperativeVehicleRig`, `ChopShopPanel`, `DomainWorkshopPanel`, `GateHudBar` (`resolveVaultCarSelection`, `Car | Craft` toggle, `PAPER_SHELL_PRESETS` car forge), `VfxEmitterPool`, `makeStarterDomainScene`, `registerSand3dStarterFactory`, `enforceRetroPersonMaterials`.
|
|
115
|
-
- Procedural Domain Builders ([proceduralDomainBuilders.ts](../src/importer/proceduralDomainBuilders.ts), [proceduralC12AndCraft.ts](../src/importer/proceduralC12AndCraft.ts), [proceduralPersonAndProp.ts](../src/importer/proceduralPersonAndProp.ts)) — `C12_PROCEDURAL_RECIPES` (`buildProceduralC12Scene`), `CRAFT_PROCEDURAL_RECIPES` (`buildProceduralCraftScene`), `PERSON_PROCEDURAL_RECIPES` (`buildProceduralPersonScene`), `PROP_PROCEDURAL_RECIPES` (`buildProceduralPropScene`), `JUNK_PROCEDURAL_RECIPES` (`buildProceduralJunkScene`), and unified `buildProceduralDomainScene(domain, recipeId?)`.
|
|
116
|
-
- `WheelRingHandles3D` ([WheelRingHandles3D.tsx](../src/importer/WheelRingHandles3D.tsx), [wheelRingHandleMath.ts](../src/importer/wheelRingHandleMath.ts)) — Interactive 3D wheel-ring handles for `radius`, `width`, and `(Y, Z)` center adjustment (`WheelRingHandles3DProps`).
|
|
117
|
-
- `useChopShopController(onSpawnInWorld?)` ([useChopShopController.ts](../src/importer/useChopShopController.ts), [useChopShopState.ts](../src/importer/useChopShopState.ts), [useWasdKeyRef.ts](../src/importer/useWasdKeyRef.ts), [chopShopActions.ts](../src/importer/chopShopActions.ts), [chopShopHandlers.ts](../src/importer/chopShopHandlers.ts), [chopShopIoActions.ts](../src/importer/chopShopIoActions.ts), [chopShopMcpAction.ts](../src/importer/chopShopMcpAction.ts)) — Exposes `wheelCutters`, `mirrorX`, `snapAxles`, `sealArchLiner`, `isCored`, `updateWheelCutter`, `commitWheelCutter`, `applyWheelCutters`, `toggleMirrorX`, `toggleSnapAxles`, `toggleSealArchLiner`, `ingestFile`, `forgeScene`, `forgeProceduralCar`, `sealAndExport`, `handleUndoCut`.
|
|
118
|
-
- Store & SI Calibration ([gateStore.ts](../src/importer/gateStore.ts), [glbNormalizer.ts](../src/importer/glbNormalizer.ts)) — `useGateStore`, `gateTelemetry`, `isGateStep1Unlocked`, `FREQ_HZ`, `DAMP_ZETA`, `C12_TICK_M`, `UNIFIED_ANCHOR_NAMES`, `computeC12Metrics`, `defaultTargetMeters`, `detectSceneAnchors`, `khrBoxToRapierHalfExtents`, `measureAssemblyCalibration`, `measureNormalizedSceneCalibration`, `snapMetersToC12`, `wrapSingleMeshWithPaperShellProxy`.
|
|
559
|
+
### SI Normalization, Surface Peel & KHR / USD / Launcher Compilers
|
|
119
560
|
|
|
120
|
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
123
|
-
-
|
|
561
|
+
- **SI Normalization & C12 Metrics**: `normalizeSceneToSi(source, opts)` (`{ turns?, targetMeters, axis? }`), `C12_TICK_M`, `UNIFIED_ANCHOR_NAMES`, `computeC12Metrics`, `defaultTargetMeters`, `detectSceneAnchors`, `khrBoxToRapierHalfExtents`, `measureAssemblyCalibration`, `measureNormalizedSceneCalibration`, `snapMetersToC12`, `wrapSingleMeshWithPaperShellProxy`.
|
|
562
|
+
- **Mesh Islands & Geodesic Surface Cutter**: `extractMeshIslands(root)`, `measureSelection(islands, selectedIds)`, `toggleIslandSelection`, `separateVehicleMeshes`, `sliceMeshTriangles`, `suggestCarAxles`, `buildSurfaceTopology`, `getIslandTopology`, `selectFacesByClick`, `selectFacesByLoop`, `previewLoopPolyline`, `refineMeshAlongLoop`, `peelIslandSelection`, `floodFillByCrease`, `mirrorTriangles`, `findMirrorIslandId`, `remapIslandIds`, `buildSelectionOverlayGeometry`, `createFleet12GonWheelGroup`, `CHOP_ROLES` (`type ChopPartRole`).
|
|
563
|
+
- **KHR, Universal Gate, Launcher & OpenUSD Compilers**:
|
|
564
|
+
- `compileKhrAssetGlb(normalizedScene: THREE.Group, opts: KolmoCompileOptions): Promise<Uint8Array<ArrayBuffer>>` (helpers: `computeChopPartHinge`, `buildPatchPreviewEmitters`, `normalToMinusZQuaternion`, `type CarDriveMode`, `type ChopHingeSpec`, `type KolmoAssetArchetype`, `type WheelVisualSource`).
|
|
565
|
+
- `bakeUniversalGateGlb(input: UniversalBakeInput): Promise<GateWorldPayload>` — compiles any `GateDomain` into compliant `KHR_physics_rigid_bodies` + `KOLMO_emitter` `.glb` bytes and a loaded `KhrAssetBundle`.
|
|
566
|
+
- `bakeArticulatedLauncherGlb` & `buildLauncherSceneFromPlan(plan, visualOverlay?)`.
|
|
567
|
+
- `convertUsdToGlb(input, fileName?): Promise<Uint8Array>` & `isUsdFileName(name: string): boolean`.
|
|
568
|
+
|
|
569
|
+
### Modular Character Wardrobe Catalog, Auto-Fitter & Skeleton Binder
|
|
570
|
+
|
|
571
|
+
- **Catalog**: `TRIPO_WARDROBE_BASE_PATH` (`"/actors/tripo-street-outfit"`), `tripoWardrobeUrl(filename)`, `TRIPO_CHARACTER_BASES`, `TRIPO_WARDROBE_GARMENTS`, `inferWardrobeSlotFromName(nodeName): WardrobeSlot`, `type WardrobeSlot` (`"assembly" | "body" | "top" | "bottom" | "dress" | "shoes" | "belt" | "chain" | "pendant" | "earrings" | "accessory"`), `type TripoWardrobeCatalogItem`.
|
|
572
|
+
- **Piece Patching & Auto-Fit**: `listWardrobePieces(root): WardrobePieceState[]`, `applyWardrobePiecePatch(root, pieceName, patch: WardrobeFitPatch)` (supports `visible`, `offset`, `offsetDelta`, `scale`, `rotationDeg`, `shoeToeYawDeg`, `colorHex`), `resetWardrobePiece(root, pieceName?)`, `layerGarmentOntoCharacterScene(targetRoot, garmentScene, label, explicitSlot?)`, `autoFitWardrobeShoes(root)`, `tuckInnerBodyUnderClothing(root, clearanceMeters = 0.004)`, `bindWardrobeToHumanoidSkeleton(root)` (15-bone humanoid skinning).
|
|
573
|
+
- **Host Controllers**: `detectCharacterDefaultTurns`, `resolveWardrobeCatalogUrl`, `loadGlbSceneFromUrl`, `loadWardrobeBaseIntoHost`, `layerWardrobeGarmentIntoHost`, `removeWardrobePieceFromHost`, `executeWardrobeFitOnHost`, `type WardrobeActionHost`.
|
|
574
|
+
|
|
575
|
+
### WebMCP Tools (`navigator.modelContext`)
|
|
576
|
+
|
|
577
|
+
`useImporterWebMcp(host: ImporterWebMcpHost, enabled = true)`, `buildImporterWebMcpTools(host): readonly WebMcpTool[]`, `createWardrobeWebMcpTools(getHost): readonly WebMcpTool[]`, and `getNavigatorModelContext(): ModelContext | null` expose 15 tools:
|
|
578
|
+
|
|
579
|
+
- **Core Importer (12)**: `importer_state`, `importer_capture_view`, `importer_list_models`, `importer_set_stage`, `importer_load`, `importer_orient`, `importer_scale`, `importer_set_kind`, `importer_pop_wheels`, `importer_cut_part`, `importer_set_points` (valid socket roles: `seat | exit | grip_primary | grip_secondary | optic | muzzle | eject | hinge | mount | contact`), `importer_export`.
|
|
580
|
+
- **Wardrobe (3)**: `importer_wardrobe_list`, `importer_wardrobe_layer` (`load_base | add_garment | remove_piece | toggle_piece`), `importer_wardrobe_fit` (`patch | auto_tuck | auto_shoes | auto_all | bind_skeleton | reset`).
|
|
124
581
|
|
|
125
582
|
### Input Validation & Error Conditions
|
|
583
|
+
|
|
126
584
|
- `sliceCarWheelCylinders` throws `Error` when `cutters` is empty, `center` coordinates are `NaN` or infinite, `radius <= 0`, `width <= 0`, or `innerX`/`outerX` are `NaN` or infinite.
|
|
127
585
|
- `normalizeSceneToSi` throws `Error` when `targetMeters <= 0` or the rotated scene bounds are empty.
|
|
128
|
-
- `selectFacesByLoop` throws `Error` when fewer than 3 control dots are supplied, two dots snap to the same vertex, adjacent dots
|
|
586
|
+
- `selectFacesByLoop` throws `Error` when fewer than 3 control dots are supplied, two dots snap to the same vertex, no unblocked shortest path exists between adjacent dots (disconnected component or self-intersecting blocked loop), the loop follows an open mesh boundary, or flood-filling fails to isolate an enclosed patch (`"Loop didn't enclose an isolated patch — add another dot along the shutline."`).
|
|
129
587
|
- `peelIslandSelection` throws `Error` when the selected island mesh lacks a parent scene.
|
|
130
588
|
- `measureSelection` throws `Error` when called with an empty island ID set.
|
|
131
589
|
|
|
132
590
|
---
|
|
133
591
|
|
|
134
|
-
##
|
|
592
|
+
## `@pinkaphant/kolmo/sand3d`
|
|
593
|
+
|
|
594
|
+
Declarative `Sand3D` Code-CAD component and universal `.sand3d` / `.s3d` / OpenUSD / `.glb` loader built on `@khr3/core/sand3d`.
|
|
595
|
+
|
|
596
|
+
```ts
|
|
597
|
+
import {
|
|
598
|
+
KolmoSand3D,
|
|
599
|
+
Sand3D,
|
|
600
|
+
SAND3D_RECIPES,
|
|
601
|
+
SAND3D_RECIPE_MAP,
|
|
602
|
+
s3d,
|
|
603
|
+
ingestSand3dOrGlb,
|
|
604
|
+
compileSand3dRecipeGlb,
|
|
605
|
+
buildSand3dRecipe,
|
|
606
|
+
findSand3dRecipe,
|
|
607
|
+
parseSand3dSource,
|
|
608
|
+
compileSand3dAssembly,
|
|
609
|
+
exportSand3dGlb,
|
|
610
|
+
loadSand3dBundle,
|
|
611
|
+
Sand3dWorkshopSection,
|
|
612
|
+
} from "@pinkaphant/kolmo/sand3d";
|
|
613
|
+
```
|
|
135
614
|
|
|
136
|
-
|
|
615
|
+
| Prop (`KolmoSand3DProps`) | Type | Default | Description |
|
|
616
|
+
| :--- | :--- | :--- | :--- |
|
|
617
|
+
| `id` | `string` | `undefined` | Vehicle/entity identifier when mounted as `<KolmoVehicle>`. |
|
|
618
|
+
| `recipe` | `Sand3dRecipeId \| string` | `"cnc_mounting_bracket"` (when no source is passed) | Built-in `SAND3D_RECIPES` ID. |
|
|
619
|
+
| `program` | `string \| Sand3dAssembly` | `undefined` | Inline `.sand3d` Python-subset DSL source or `s3d.assembly(...)` object. |
|
|
620
|
+
| `glbUrl` / `glbBytes` | `string` / `Uint8Array \| ArrayBuffer` | `undefined` | URL or binary bytes for `.glb`, `.usd*`, or `.sand3d` inputs. |
|
|
621
|
+
| `fileName` | `string` | `undefined` | Filename hint for format detection (`isSupportedCadImportFileName`). |
|
|
622
|
+
| `position` / `rotation` | `[number, number, number]` | `[0, 0, 0]` / `undefined` | Spawn position (m) and Euler rotation (rad). |
|
|
623
|
+
| `fixed` | `boolean` | `false` | Forces `<KolmoProp fixed />` even if the compiled bundle has wheels or propellers. |
|
|
624
|
+
| `piloted` / `flightMode` | `boolean` | `false` / `undefined` | Forwarded to `<KolmoVehicle>` when `worldKind === "vehicle"` and `fixed === false`. |
|
|
625
|
+
| `shadingMode` | `ShadingMode` | `"dc-smooth"` | Forwarded to `<KolmoVehicle>`. |
|
|
626
|
+
| `onLoaded` | `(asset: IngestedSand3dAsset) => void` | `undefined` | Invoked once `{ name, format, glbBytes, bundle, worldKind }` resolves. |
|
|
627
|
+
|
|
628
|
+
Additional helpers: `ingestSand3dOrGlb(input, fileNameHint?): Promise<IngestedSand3dAsset>`, `compileSand3dRecipeGlb(programOrRecipe)`, `detectSand3dBytes`, `isSand3dFileName`, `isSupportedCadImportFileName`, `resolveSand3dAssembly`, `measureNaturalSceneSpanM`, `exportCompiledSand3dWithKolmo`, and `<Sand3dWorkshopSection>` (`Sand3dWorkshopSectionProps`).
|
|
137
629
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
630
|
+
---
|
|
631
|
+
|
|
632
|
+
## `@pinkaphant/kolmo/junk`
|
|
633
|
+
|
|
634
|
+
Destructible rigid-body props, BVH triangle shattering, ballistic decals, procedural bottle/can LOD meshes, and multi-island rock/shrapnel sheet splitting.
|
|
635
|
+
|
|
636
|
+
```ts
|
|
637
|
+
import {
|
|
638
|
+
KolmoJunk,
|
|
639
|
+
DestructibleTarget,
|
|
640
|
+
ShardPieces,
|
|
641
|
+
TargetDecals,
|
|
642
|
+
JUNK_PROCEDURAL_RECIPES,
|
|
643
|
+
buildProceduralJunkScene,
|
|
644
|
+
splitObjectIntoShards,
|
|
645
|
+
splitSheetSceneIntoJunkIslands,
|
|
646
|
+
SUBSTRATE_DENSITY_KG_M3,
|
|
647
|
+
loadImportedGlbUrl,
|
|
648
|
+
parseImportedGlbBuffer,
|
|
649
|
+
} from "@pinkaphant/kolmo/junk";
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
| Prop (`KolmoJunkProps`) | Type | Default | Description |
|
|
653
|
+
| :--- | :--- | :--- | :--- |
|
|
654
|
+
| `id` | `string` | required | Target identifier. |
|
|
655
|
+
| `kind` | `JunkKind` | `"glass-bottle"` | `"glass-bottle" \| "tin-can" \| "imported-glb"`. |
|
|
656
|
+
| `labelId` | `ProceduralLabelId` | `"tris-soda"` | Procedural label texture ID (`getProceduralLabelTexture`, `loadCustomLabelTexture`). |
|
|
657
|
+
| `position` | `[number, number, number]` | `[0, 0.4, 0]` | Spawn position in meters. |
|
|
658
|
+
| `hp` | `number` | `25` (`glass-bottle`) or `60` | Hit points before BVH shatter. |
|
|
659
|
+
| `fragile` | `boolean` | `kind === "glass-bottle"` | Shatters immediately on high-impulse impact when `true`. |
|
|
660
|
+
| `shatterPieceCount` | `number` | `7` | Number of dynamic `ShardPieces` spawned on destruction. |
|
|
661
|
+
| `canLodMode` | `CanLodMode` | `"auto"` | `"auto" \| "high" \| "low"` (`CAN_LOD_THRESHOLD_M`, `selectCanLod`). |
|
|
662
|
+
| `importedUrl` | `string \| null` | `null` | Custom `.glb` URL loaded via `loadImportedGlbUrl`. |
|
|
663
|
+
|
|
664
|
+
- **`<DestructibleTarget>`** (`DestructibleTargetProps: { spec: DestructibleTargetSpec; active?: boolean; importedAsset?: ImportedGlbAsset | null; onHit?; onShatter?; onStateChange?; registerTarget? }`, `ref: Ref<DestructibleTargetHandle>`): Imperative handle exposes `applyHit(hit: BallisticHitEvent): void` and `getSnapshot(): DestructibleTargetSnapshot`. Under `KolmoGravityContext`, both `<DestructibleTarget>` and `<ShardPieces>` use `linearDamping = 0`, `angularDamping = 0.05`, and integrate `useCustomGravity` per step.
|
|
665
|
+
- **Multi-Island Sheet Splitter**: `SUBSTRATE_DENSITY_KG_M3` (`{ silicateRock: 2700, waterIce: 917, ironNickel: 7800, aluminumAlloy: 2710 }`) and `splitSheetSceneIntoJunkIslands(root: THREE.Object3D, options?: { densityKgM3?: number; gravitationalConstant?: number; minTriangles?: number }): SplitJunkIsland[]` — extracts disconnected mesh islands, centers each island at its bounding-box origin, and computes signed tetrahedral volume, `massKg`, `mu`, and 96-point `hullVertices`.
|
|
666
|
+
- **Geometry, Shatter & Sanitization Helpers**: `splitObjectIntoShards`, `collectValidTris` (`type ShardTri`), `BOTTLE_HEIGHT`, `TIN_CAN_HEIGHT`, `TIN_CAN_RADIUS`, `CAN_LOD_THRESHOLD_M`, `buildGlassBottleGeometry`, `buildTinCanGeometry`, `countGeometryTriangles`, `createGlassBottleMaterial`, `createTinCanMaterials`, `getBulletHoleTexture`, `disposeImportedRoot`, `ensureMeshAttributes`, `applySegmentsToImportedRoot`, `parseImportedGlbBuffer` (types: `BallisticHitEvent`, `DecalRecord`, `ImportedJunkSegment`, `ShardSpec`, `SpawnedShardState`).
|
|
141
667
|
|
|
142
668
|
---
|
|
143
669
|
|
|
144
|
-
##
|
|
670
|
+
## `@pinkaphant/kolmo/suika`
|
|
671
|
+
|
|
672
|
+
Tiered polyhedral/spherical rigid bodies (`ORB_TIERS` `T00`–`T10`, geometric radius factor `GOLDEN_RATIO = 1.618`) and deterministic contact-merge arbitration (`SuikaMergeArbiter`).
|
|
673
|
+
|
|
674
|
+
```ts
|
|
675
|
+
import {
|
|
676
|
+
KolmoSuikaOrb,
|
|
677
|
+
SuikaOrb,
|
|
678
|
+
KolmoSuikaSystem,
|
|
679
|
+
SuikaSystem,
|
|
680
|
+
ORB_TIERS,
|
|
681
|
+
GOLDEN_RATIO,
|
|
682
|
+
getSuikaTier,
|
|
683
|
+
matchSuikaTierByRadius,
|
|
684
|
+
SuikaMergeArbiter,
|
|
685
|
+
defaultSuikaArbiter,
|
|
686
|
+
spawnSuikaOrb,
|
|
687
|
+
useSuikaStore,
|
|
688
|
+
} from "@pinkaphant/kolmo/suika";
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
- **`<KolmoSuikaOrb>` (`SuikaOrb`)** (`KolmoSuikaOrbProps`): `{ id?, tier = 0, position = [0, 1.5, 0], velocity?, linearDamping?, angularDamping = 0.4, importedUrl = null, arbiter = defaultSuikaArbiter, managedBySystem = false, minCoreRadius = 0 }`.
|
|
692
|
+
- **`<KolmoSuikaSystem>` (`SuikaSystem`)** (`KolmoSuikaSystemProps`): Renders active orbs, merge bursts (`<SuikaBurstMesh>`), and `<OrbShapeGeometry>` (`OrbShapeGeometryProps`) managed by `useSuikaStore` / `spawnSuikaOrb(input: SuikaSpawnInput)`.
|
|
693
|
+
- **Arbiter & Geometry Helpers**: `new SuikaMergeArbiter(options?: SuikaMergeArbiterOptions)` (`SuikaArbiterSnapshot`, `computeSuikaMergeMidpoint`), `getSuikaTier(tierOrCode)`, `matchSuikaTierByRadius(radiusM)`, `buildSuikaOrbGeometry`, `buildSuikaTierScene`, `getConvexHullVertices`, `extractSceneHullVertices`, `loadImportedSuikaGlbUrl`, `parseImportedSuikaGlbBuffer` (types: `OrbShape`, `OrbTier`, `ActiveOrb`, `ActiveSuikaOrb`, `ImportedSuikaGlbAsset`, `SuikaMergeEvent`, `SuikaBurstEffect`, `SuikaScorePopup`, `FloatingScore`, `ParticleBurst`).
|
|
694
|
+
|
|
695
|
+
---
|
|
696
|
+
|
|
697
|
+
## `@pinkaphant/kolmo/schema`
|
|
698
|
+
|
|
699
|
+
`KOLMO_emitter` glTF 2.0 node-level extension (`KOLMO_EXTENSION_NAME = "KOLMO_emitter"`, recorded in `extensionsUsed` without `extensionsRequired` so standard glTF viewers load stamped `.glb` files unmodified).
|
|
700
|
+
|
|
701
|
+
```ts
|
|
702
|
+
import {
|
|
703
|
+
KOLMO_EXTENSION_NAME,
|
|
704
|
+
decodeKolmoRig,
|
|
705
|
+
stampKolmoNodesIntoGlb,
|
|
706
|
+
inferKolmoSocketRole,
|
|
707
|
+
createDefaultSignals,
|
|
708
|
+
disambiguatePatchName,
|
|
709
|
+
disambiguateExplicitPatches,
|
|
710
|
+
type KolmoNodeExtension,
|
|
711
|
+
type KolmoEmitterKind,
|
|
712
|
+
type KolmoDriveChannel,
|
|
713
|
+
type KolmoSocketRole,
|
|
714
|
+
type KolmoSignalState,
|
|
715
|
+
type KolmoAuthoredNodePatch,
|
|
716
|
+
type KolmoRigMetadata,
|
|
717
|
+
type StampKolmoOptions,
|
|
718
|
+
} from "@pinkaphant/kolmo/schema";
|
|
719
|
+
```
|
|
145
720
|
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
-
|
|
721
|
+
- **Schema Unions**:
|
|
722
|
+
- `KolmoEmitterKind`: `"plume" | "sparkle" | "fume" | "trail" | "flare"` (`-Z` local emission axis).
|
|
723
|
+
- `KolmoDriveChannel`: `"throttle" | "boost" | "brake" | "reverse" | "slip" | "damage" | "turn_l" | "turn_r" | "headlight" | "horn" | "always"`.
|
|
724
|
+
- `KolmoSocketRole`: `"seat" | "exit" | "grip_primary" | "grip_secondary" | "optic" | "muzzle" | "eject" | "hinge" | "mount" | "contact"`.
|
|
725
|
+
- **Functions**:
|
|
726
|
+
- `decodeKolmoRig(scene: THREE.Group, glbBytes?: ArrayBuffer | Uint8Array): KolmoRigMetadata` — extracts `{ emitters: DecodedKolmoEmitter[], sockets: DecodedKolmoSocket[] }` in root-local coordinates and caches `node.userData.KOLMO_emitter`.
|
|
727
|
+
- `stampKolmoNodesIntoGlb(glbBytes: Uint8Array | ArrayBuffer, patches: readonly KolmoAuthoredNodePatch[], extraSceneTune?: Record<string, unknown>, options?: StampKolmoOptions): Uint8Array<ArrayBuffer>` — patches `KOLMO_emitter` nodes, optional `KHR_lights_punctual` headlight spotlights, and `scene.extras` into a 4-byte-aligned binary `.glb`.
|
|
728
|
+
- `inferKolmoSocketRole(nodeName: string, explicitRole?: KolmoSocketRole): KolmoSocketRole`, `createDefaultSignals(): KolmoSignalState`, `disambiguatePatchName`, `disambiguateExplicitPatches`.
|