@pinkaphant/create-kolmo 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,15 +2,31 @@
2
2
 
3
3
  Scaffold a playable Kolmo game with React, TypeScript, Vite, and Rapier.
4
4
 
5
- ## Nautical towing game
5
+ ## Longline, the tugboat
6
6
 
7
7
  ```bash
8
- npx @pinkaphant/create-kolmo@latest my-longline-game --template longline
8
+ npm create @pinkaphant/kolmo@latest my-longline-game -- --template longline
9
9
  cd my-longline-game
10
10
  npm run dev
11
11
  ```
12
12
 
13
- Longline includes the complete deterministic sea simulation, boat controls, tow line, collectible crates, radar, camera modes, and HUD. **WASD** or the **arrow keys** steer the boat.
13
+ Longline is the water demo: sea, boat, tow line, crates, radar, HUD. **WASD** or the arrow keys steer the boat. It stays that game.
14
+
15
+ ## Lonedrive
16
+
17
+ ```bash
18
+ npm create @pinkaphant/kolmo@latest my-drive -- --template lonedrive
19
+ ```
20
+
21
+ A long seeded road and one car. Respectful spoof of The Long Drive. Not the tugboat.
22
+
23
+ ## Dust
24
+
25
+ ```bash
26
+ npm create @pinkaphant/kolmo@latest my-dust -- --template dust
27
+ ```
28
+
29
+ An island, a body, and a scrap car. Facepunch Rust in spirit. **WASD** walks. **E** or **F** boards.
14
30
 
15
31
  ## Road and vehicle sandbox
16
32
 
@@ -18,8 +18,8 @@ for (let i = 0; i < args.length; i++) {
18
18
  template = a.slice("--template=".length);
19
19
  } else if (a === "-h" || a === "--help") {
20
20
  console.log(
21
- "Usage: npm create @pinkaphant/kolmo@latest <project-dir> [--template road|longline] [--no-install]\n" +
22
- " or: npx @pinkaphant/create-kolmo@latest <project-dir> [--template road|longline] [--no-install]",
21
+ "Usage: npm create @pinkaphant/kolmo@latest <project-dir> [--template road|longline|lonedrive|dust] [--no-install]\n" +
22
+ " or: npx @pinkaphant/create-kolmo@latest <project-dir> [--template road|longline|lonedrive|dust] [--no-install]",
23
23
  );
24
24
  process.exit(0);
25
25
  } else if (!a.startsWith("-") && !targetArg) {
@@ -30,8 +30,15 @@ for (let i = 0; i < args.length; i++) {
30
30
  }
31
31
  }
32
32
 
33
- if (template !== "road" && template !== "longline") {
34
- console.error(`Error: Unknown template "${template}". Available templates: road, longline.`);
33
+ const TEMPLATE_DIR = {
34
+ road: "road",
35
+ longline: "longline",
36
+ lonedrive: "lonedrive",
37
+ dust: "dust",
38
+ };
39
+
40
+ if (!Object.hasOwn(TEMPLATE_DIR, template)) {
41
+ console.error(`Error: Unknown template "${template}". Available templates: ${Object.keys(TEMPLATE_DIR).join(", ")}.`);
35
42
  process.exit(1);
36
43
  }
37
44
 
@@ -48,224 +55,31 @@ if (fs.existsSync(root) && fs.readdirSync(root).length > 0) {
48
55
  process.exit(1);
49
56
  }
50
57
 
51
- function finishProject() {
52
- console.log(`\nScaffolded Kolmo ${template} project in ${root}`);
58
+ const templateRoot = path.resolve(import.meta.dirname, "../templates", TEMPLATE_DIR[template]);
59
+ fs.cpSync(templateRoot, root, { recursive: true });
53
60
 
54
- if (!skipInstall) {
55
- console.log("Installing dependencies with npm...");
56
- const res = spawnSync("npm", ["install"], { cwd: root, stdio: "inherit", shell: process.platform === "win32" });
57
- if (res.status !== 0) {
58
- console.error("\nnpm install exited with an error. Run `npm install` inside the project directory.");
59
- process.exit(res.status ?? 1);
60
- }
61
- }
62
-
63
- console.log(`\nReady! Next steps:\n cd ${dirName}\n npm run dev\n`);
64
- }
61
+ const templatePkgPath = path.join(root, "package.json");
62
+ const templatePkg = JSON.parse(fs.readFileSync(templatePkgPath, "utf8"));
63
+ templatePkg.name = pkgName;
64
+ fs.writeFileSync(templatePkgPath, JSON.stringify(templatePkg, null, 2) + "\n");
65
65
 
66
- if (template === "longline") {
67
- const templateRoot = path.resolve(import.meta.dirname, "../templates/longline");
68
- fs.cpSync(templateRoot, root, { recursive: true });
69
- const templatePkgPath = path.join(root, "package.json");
70
- const templatePkg = JSON.parse(fs.readFileSync(templatePkgPath, "utf8"));
71
- templatePkg.name = pkgName;
72
- fs.writeFileSync(templatePkgPath, JSON.stringify(templatePkg, null, 2) + "\n");
73
- fs.writeFileSync(path.join(root, ".gitignore"), "node_modules/\ndist/\n.DS_Store\n*.local\n");
74
- finishProject();
75
- process.exit(0);
66
+ const indexHtmlPath = path.join(root, "index.html");
67
+ if (fs.existsSync(indexHtmlPath)) {
68
+ const html = fs.readFileSync(indexHtmlPath, "utf8").replace(/<title>Kolmo Road<\/title>/, `<title>${pkgName}</title>`);
69
+ fs.writeFileSync(indexHtmlPath, html);
76
70
  }
77
71
 
78
- fs.mkdirSync(path.join(root, "src"), { recursive: true });
79
-
80
- const pkgJson = {
81
- name: pkgName,
82
- version: "0.1.0",
83
- private: true,
84
- type: "module",
85
- scripts: {
86
- dev: "vite",
87
- typecheck: "tsc --noEmit",
88
- build: "tsc --noEmit && vite build",
89
- preview: "vite preview",
90
- },
91
- dependencies: {
92
- "@dimforge/rapier3d-compat": "0.19.2",
93
- "@khr3/c12": "^0.3.12",
94
- "@khr3/core": "^0.2.15",
95
- "@khr3/roads": "^0.1.1",
96
- "@pinkaphant/ecctrl": "2.0.4-beta.6",
97
- "@pinkaphant/kolmo": "^0.5.6",
98
- "@react-three/drei": "^10.7.7",
99
- "@react-three/fiber": "^9.6.1",
100
- "@react-three/rapier": "^2.2.0",
101
- koota: "^0.6.6",
102
- maath: "^0.10.8",
103
- react: "^19.2.7",
104
- "react-dom": "^19.2.7",
105
- three: "^0.184.0",
106
- zustand: "^5.1.0",
107
- },
108
- devDependencies: {
109
- "@types/react": "^19.2.16",
110
- "@types/react-dom": "^19.2.3",
111
- "@types/three": "^0.184.0",
112
- "@vitejs/plugin-react": "^4.5.2",
113
- typescript: "^5.8.3",
114
- vite: "^6.3.5",
115
- },
116
- };
117
-
118
- fs.writeFileSync(path.join(root, "package.json"), JSON.stringify(pkgJson, null, 2) + "\n");
119
-
120
- fs.writeFileSync(
121
- path.join(root, ".gitignore"),
122
- "node_modules/\ndist/\n.DS_Store\n*.local\n",
123
- );
124
-
125
- fs.writeFileSync(
126
- path.join(root, "tsconfig.json"),
127
- JSON.stringify(
128
- {
129
- compilerOptions: {
130
- target: "ES2022",
131
- lib: ["ES2022", "DOM", "DOM.Iterable"],
132
- module: "ESNext",
133
- moduleResolution: "bundler",
134
- jsx: "react-jsx",
135
- strict: true,
136
- noUnusedLocals: true,
137
- noUnusedParameters: true,
138
- skipLibCheck: true,
139
- isolatedModules: true,
140
- },
141
- include: ["src", "vite.config.ts"],
142
- },
143
- null,
144
- 2,
145
- ) + "\n",
146
- );
72
+ fs.writeFileSync(path.join(root, ".gitignore"), "node_modules/\ndist/\n.DS_Store\n*.local\n");
147
73
 
148
- fs.writeFileSync(
149
- path.join(root, "vite.config.ts"),
150
- `import { defineConfig } from "vite";
151
- import react from "@vitejs/plugin-react";
152
- import { KOLMO_SINGLETON_DEDUPE } from "@pinkaphant/kolmo/vite";
74
+ console.log(`\nScaffolded Kolmo ${template} project in ${root}`);
153
75
 
154
- export default defineConfig({
155
- plugins: [react()],
156
- resolve: {
157
- dedupe: KOLMO_SINGLETON_DEDUPE,
158
- },
159
- });
160
- `,
161
- );
162
-
163
- fs.writeFileSync(
164
- path.join(root, "index.html"),
165
- `<!doctype html>
166
- <html lang="en">
167
- <head>
168
- <meta charset="UTF-8" />
169
- <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
170
- <title>${pkgName}</title>
171
- <style>
172
- html, body, #root { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #090d16; }
173
- </style>
174
- </head>
175
- <body>
176
- <div id="root"></div>
177
- <script type="module" src="/src/main.tsx"></script>
178
- </body>
179
- </html>
180
- `,
181
- );
182
-
183
- fs.writeFileSync(
184
- path.join(root, "src", "App.tsx"),
185
- `import { useMemo, useRef } from "react";
186
- import {
187
- Game,
188
- Terrain,
189
- Actor,
190
- Vehicle,
191
- Prop,
192
- Toolgun,
193
- Hud,
194
- type EcctrlHandle,
195
- } from "@pinkaphant/kolmo";
196
- import { growRoad, makeTerrain, sampleRapierHeightfield, frontage } from "@khr3/roads";
197
-
198
- const VAULT = "https://khr3.optimuspi.workers.dev/assets";
199
-
200
- export default function App() {
201
- const actorRef = useRef<EcctrlHandle>(null);
202
-
203
- const { heights, startPos, lotPos } = useMemo(() => {
204
- const road = growRoad(42, {
205
- length: 600,
206
- halfWidth: 4.5,
207
- controlSpacing: 35,
208
- maxTurn: 0.28,
209
- maxGrade: 0.06,
210
- hilliness: 18,
211
- start: [0, 0, -140],
212
- });
213
- const land = makeTerrain(42, road, {
214
- amplitude: 12,
215
- noise: { wavelength: 140, octaves: 4, gain: 0.5, lacunarity: 2 },
216
- maxSlope: 0.55,
217
- minShoulder: 6,
218
- verge: 2,
219
- });
220
- const heights = sampleRapierHeightfield(land, [-160, 0, -160], 320, 128);
221
- const s0 = road.at(25).pos;
222
- const lot = frontage(road, { spacing: 24, setback: 3 })[0];
223
- return {
224
- heights,
225
- startPos: [s0[0], s0[1] + 1.4, s0[2]] as [number, number, number],
226
- lotPos: lot
227
- ? ([lot.front[0], lot.groundY, lot.front[2]] as [number, number, number])
228
- : ([10, 0, 20] as [number, number, number]),
229
- };
230
- }, []);
231
-
232
- return (
233
- <>
234
- <Game skybox="day">
235
- <Terrain heights={heights} segments={128} size={[320, 320]} />
236
- <Vehicle id="r34" src={\`\${VAULT}/cars/nissan_skyline_r34.glb\`} position={startPos} />
237
- <Prop src={\`\${VAULT}/city/door_hinged_single_900x2100.glb\`} position={lotPos} fixed />
238
- <Actor ref={actorRef} position={[startPos[0] - 3.2, startPos[1] + 0.8, startPos[2]]} />
239
- <Toolgun
240
- src={\`\${VAULT}/weapons/kolmogorov_pistol.glb\`}
241
- actorRef={actorRef}
242
- defaultArmedAsset={{
243
- id: "supra",
244
- name: "Supra A80",
245
- src: \`\${VAULT}/cars/toyota_supra_a80.glb\`,
246
- kind: "vehicle",
247
- }}
248
- />
249
- </Game>
250
- <Hud />
251
- </>
252
- );
76
+ if (!skipInstall) {
77
+ console.log("Installing dependencies with npm...");
78
+ const res = spawnSync("npm", ["install"], { cwd: root, stdio: "inherit", shell: process.platform === "win32" });
79
+ if (res.status !== 0) {
80
+ console.error("\nnpm install exited with an error. Run `npm install` inside the project directory.");
81
+ process.exit(res.status ?? 1);
82
+ }
253
83
  }
254
- `,
255
- );
256
-
257
- fs.writeFileSync(
258
- path.join(root, "src", "main.tsx"),
259
- `import React from "react";
260
- import { createRoot } from "react-dom/client";
261
- import App from "./App.js";
262
-
263
- createRoot(document.getElementById("root")!).render(
264
- <React.StrictMode>
265
- <App />
266
- </React.StrictMode>,
267
- );
268
- `,
269
- );
270
84
 
271
- finishProject();
85
+ console.log(`\nReady! Next steps:\n cd ${dirName}\n npm run dev\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinkaphant/create-kolmo",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Scaffold a new @pinkaphant/kolmo + @khr3/core + @khr3/roads + @khr3/c12 3D physics game in one command",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,11 @@
1
+ # Dust
2
+
3
+ A coastal island surrounded by a Gerstner sea, an outpost fuel depot, a salvage terminal, a scrap car, and a toolgun. Facepunch Rust in spirit.
4
+
5
+ - **WASD** / **Arrows**: Walk or drive
6
+ - **E** / **F**: Board or exit the scrap hatchback
7
+ - **T** / **Right-Click**: Spawn armed vehicle
8
+
9
+ ```bash
10
+ npm create @pinkaphant/kolmo@latest my-dust -- --template dust
11
+ ```
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
+ <title>Dust</title>
7
+ <style>
8
+ html, body, #root { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #14110e; }
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <div id="root"></div>
13
+ <script type="module" src="/src/main.tsx"></script>
14
+ </body>
15
+ </html>
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "dust",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "description": "Dust: a coastal island, rolling Gerstner sea, outpost cache, and scrap car on @pinkaphant/kolmo.",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "typecheck": "tsc --noEmit",
10
+ "build": "tsc --noEmit && vite build",
11
+ "preview": "vite preview"
12
+ },
13
+ "dependencies": {
14
+ "@dimforge/rapier3d-compat": "0.19.2",
15
+ "@khr3/core": "^0.2.19",
16
+ "@pinkaphant/ecctrl": "2.0.4-beta.9",
17
+ "@pinkaphant/kolmo": "^0.10.0",
18
+ "@react-three/drei": "^10.7.7",
19
+ "@react-three/fiber": "^9.6.1",
20
+ "@react-three/rapier": "^2.2.0",
21
+ "koota": "^0.6.6",
22
+ "react": "^19.2.7",
23
+ "react-dom": "^19.2.7",
24
+ "three": "0.184.0"
25
+ },
26
+ "overrides": {
27
+ "@dimforge/rapier3d-compat": "0.19.2",
28
+ "@pinkaphant/ecctrl": "2.0.4-beta.9",
29
+ "three": "0.184.0"
30
+ },
31
+ "devDependencies": {
32
+ "@types/react": "^19.2.16",
33
+ "@types/react-dom": "^19.2.3",
34
+ "@types/three": "0.184.0",
35
+ "@vitejs/plugin-react": "^6.1.1",
36
+ "typescript": "^7.0.2",
37
+ "vite": "^8.3.0"
38
+ }
39
+ }
@@ -0,0 +1,163 @@
1
+ import { useEffect, useMemo, useRef } from "react";
2
+ import * as THREE from "three";
3
+ import { useFrame } from "@react-three/fiber";
4
+ import {
5
+ ACTOR_GROUND_CLEARANCE,
6
+ Actor,
7
+ Game,
8
+ Hud,
9
+ Prop,
10
+ Terrain,
11
+ Toolgun,
12
+ Vehicle,
13
+ type EcctrlHandle,
14
+ } from "@pinkaphant/kolmo";
15
+ import { WaveField, createWaveSpectrum } from "@pinkaphant/kolmo/water";
16
+ import { usePhysicsClock } from "@pinkaphant/kolmo/water/react";
17
+ import { sampleRapierHeightfield } from "@khr3/core";
18
+
19
+ const VAULT = "https://khr3.optimuspi.workers.dev/assets";
20
+ const SEA_SIZE = 576;
21
+ const SEA_SEGMENTS = 96;
22
+ const SUN = new THREE.Vector3(40, 60, 24).normalize();
23
+
24
+ const SEA_VERT = /* glsl */ `
25
+ uniform float uTime;
26
+ uniform vec2 uOrigin;
27
+ uniform float uLevel;
28
+ uniform vec4 uDirKW[6];
29
+ uniform vec4 uAmp[6];
30
+ varying vec3 vWorld;
31
+
32
+ void main() {
33
+ vec2 rest = position.xz + uOrigin;
34
+ vec3 p = vec3(rest.x, uLevel, rest.y);
35
+ for (int i = 0; i < 6; i++) {
36
+ vec4 d = uDirKW[i];
37
+ vec4 w = uAmp[i];
38
+ float theta = d.z * (d.x * rest.x + d.y * rest.y) - d.w * uTime + w.z;
39
+ p.x += w.w * d.x * cos(theta);
40
+ p.z += w.w * d.y * cos(theta);
41
+ p.y += w.x * sin(theta);
42
+ }
43
+ vWorld = p;
44
+ gl_Position = projectionMatrix * viewMatrix * vec4(p, 1.0);
45
+ }
46
+ `;
47
+
48
+ const SEA_FRAG = /* glsl */ `
49
+ uniform vec3 uSun;
50
+ uniform float uLevel;
51
+ uniform float uCrest;
52
+ varying vec3 vWorld;
53
+
54
+ void main() {
55
+ vec3 n = normalize(cross(dFdx(vWorld), dFdy(vWorld)));
56
+ if (n.y < 0.0) n = -n;
57
+ float lift = clamp((vWorld.y - uLevel) / max(uCrest, 0.05) * 0.5 + 0.5, 0.0, 1.0);
58
+ float diffuse = max(dot(n, uSun), 0.0);
59
+ vec3 col = mix(vec3(0.03, 0.20, 0.31), vec3(0.09, 0.54, 0.61), clamp(lift * 0.65 + diffuse * 0.28, 0.0, 1.0));
60
+ float foam = smoothstep(0.82, 0.96, lift) * smoothstep(0.25, 0.55, diffuse) * 0.65;
61
+ col = mix(col, vec3(0.93, 0.97, 0.99), foam);
62
+ gl_FragColor = vec4(col, 0.92);
63
+ #include <colorspace_fragment>
64
+ }
65
+ `;
66
+
67
+ function islandHeight(x: number, z: number): number {
68
+ const r = Math.hypot(x, z);
69
+ const ridge = 14 - r * 0.14 + 1.6 * Math.sin(x * 0.045) * Math.cos(z * 0.04);
70
+ return Math.max(-5, ridge);
71
+ }
72
+
73
+ function IslandSea() {
74
+ const clock = usePhysicsClock();
75
+ const { geometry, material } = useMemo(() => {
76
+ const field = new WaveField({
77
+ level: 0,
78
+ waves: createWaveSpectrum({ seed: 11, count: 6, wavelength: 20, amplitude: 0.38, steepness: 0.75 }),
79
+ });
80
+ const u = field.toUniforms();
81
+ const geo = new THREE.PlaneGeometry(SEA_SIZE, SEA_SIZE, SEA_SEGMENTS, SEA_SEGMENTS);
82
+ geo.rotateX(-Math.PI / 2);
83
+ const mat = new THREE.ShaderMaterial({
84
+ vertexShader: SEA_VERT,
85
+ fragmentShader: SEA_FRAG,
86
+ transparent: true,
87
+ uniforms: {
88
+ uTime: { value: 0 },
89
+ uOrigin: { value: new THREE.Vector2(0, 0) },
90
+ uLevel: { value: u.level },
91
+ uDirKW: { value: u.dirKW },
92
+ uAmp: { value: u.ampSteepPhase },
93
+ uCrest: { value: field.maxCrest },
94
+ uSun: { value: SUN },
95
+ },
96
+ });
97
+ return { geometry: geo, material: mat };
98
+ }, []);
99
+
100
+ const mountsRef = useRef(0);
101
+ useEffect(() => {
102
+ mountsRef.current += 1;
103
+ return () => {
104
+ mountsRef.current -= 1;
105
+ queueMicrotask(() => {
106
+ if (mountsRef.current === 0) {
107
+ geometry.dispose();
108
+ material.dispose();
109
+ }
110
+ });
111
+ };
112
+ }, [geometry, material]);
113
+
114
+ useFrame((state) => {
115
+ const cell = SEA_SIZE / SEA_SEGMENTS;
116
+ const cam = state.camera.position;
117
+ (material.uniforms.uOrigin!.value as THREE.Vector2).set(
118
+ Math.round(cam.x / cell) * cell,
119
+ Math.round(cam.z / cell) * cell,
120
+ );
121
+ material.uniforms.uTime!.value = clock.time;
122
+ });
123
+
124
+ return <mesh geometry={geometry} material={material} frustumCulled={false} />;
125
+ }
126
+
127
+ export default function App() {
128
+ const actorRef = useRef<EcctrlHandle>(null);
129
+ const world = useMemo(() => {
130
+ const heights = sampleRapierHeightfield(islandHeight, -192, -192, 384, 384, 128);
131
+ const actor: [number, number, number] = [0, islandHeight(0, 9) + ACTOR_GROUND_CLEARANCE, 9];
132
+ const car: [number, number, number] = [9, islandHeight(9, -6), -6];
133
+ const outpost: [number, number, number] = [-12, islandHeight(-12, 6), 6];
134
+ const pump: [number, number, number] = [-12, islandHeight(-12, 0), 0];
135
+ const cache: [number, number, number] = [15, islandHeight(15, 18), 18];
136
+ return { heights, actor, car, outpost, pump, cache };
137
+ }, []);
138
+
139
+ return (
140
+ <>
141
+ <Game skybox="day">
142
+ <Terrain heights={world.heights} segments={128} size={[384, 384]} />
143
+ <IslandSea />
144
+ <Actor ref={actorRef} position={world.actor} />
145
+ <Vehicle id="scrap" label="Scrap Hatchback" src={`${VAULT}/cars/kolmogorov_hatchback.glb`} position={world.car} />
146
+ <Prop id="outpost" src={`${VAULT}/city/gas-canopy-roof.glb`} position={world.outpost} fixed />
147
+ <Prop id="pump" src={`${VAULT}/city/gas-pump-twin.glb`} position={world.pump} fixed />
148
+ <Prop id="cache" src={`${VAULT}/city/prop_arcade_cabinet.glb`} position={world.cache} fixed />
149
+ <Toolgun
150
+ src={`${VAULT}/weapons/kolmogorov_pistol.glb`}
151
+ actorRef={actorRef}
152
+ defaultArmedAsset={{
153
+ id: "s15",
154
+ name: "Silvia S15",
155
+ src: `${VAULT}/cars/nissan_silvia_s15.glb`,
156
+ kind: "vehicle",
157
+ }}
158
+ />
159
+ </Game>
160
+ <Hud />
161
+ </>
162
+ );
163
+ }
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import App from "./App.js";
4
+
5
+ createRoot(document.getElementById("root")!).render(
6
+ <React.StrictMode>
7
+ <App />
8
+ </React.StrictMode>,
9
+ );
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "jsx": "react-jsx",
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "isolatedModules": true,
11
+ "noEmit": true
12
+ },
13
+ "include": ["src", "vite.config.ts"]
14
+ }
@@ -0,0 +1,8 @@
1
+ import react from "@vitejs/plugin-react";
2
+ import { defineConfig } from "vite";
3
+ import { KOLMO_SINGLETON_DEDUPE } from "@pinkaphant/kolmo/vite";
4
+
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ resolve: { dedupe: KOLMO_SINGLETON_DEDUPE },
8
+ });
@@ -0,0 +1,11 @@
1
+ # Lonedrive
2
+
3
+ An 8.1 km seeded desert highway streamed in seamless 288 m (96 × 3 m) heightfield sectors, roadside gas stops, and one beater car. Respectful spoof of The Long Drive (not Longline, the tugboat).
4
+
5
+ - **E** / **F**: Board or exit the car
6
+ - **WASD** / **Arrows**: Drive or walk
7
+ - **R**: Flip upright
8
+
9
+ ```bash
10
+ npm create @pinkaphant/kolmo@latest my-drive -- --template lonedrive
11
+ ```
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
+ <title>Lonedrive</title>
7
+ <style>
8
+ html, body, #root { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #1a120c; }
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <div id="root"></div>
13
+ <script type="module" src="/src/main.tsx"></script>
14
+ </body>
15
+ </html>
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "lonedrive",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "description": "Lonedrive: an 8.1 km streamed desert highway on a 3 m grid, roadside gas stops, and one car on @pinkaphant/kolmo.",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "typecheck": "tsc --noEmit",
10
+ "build": "tsc --noEmit && vite build",
11
+ "preview": "vite preview"
12
+ },
13
+ "dependencies": {
14
+ "@dimforge/rapier3d-compat": "0.19.2",
15
+ "@khr3/core": "^0.2.19",
16
+ "@khr3/roads": "^0.1.1",
17
+ "@pinkaphant/ecctrl": "2.0.4-beta.9",
18
+ "@pinkaphant/kolmo": "^0.10.0",
19
+ "@react-three/drei": "^10.7.7",
20
+ "@react-three/fiber": "^9.6.1",
21
+ "@react-three/rapier": "^2.2.0",
22
+ "koota": "^0.6.6",
23
+ "react": "^19.2.7",
24
+ "react-dom": "^19.2.7",
25
+ "three": "0.184.0"
26
+ },
27
+ "overrides": {
28
+ "@dimforge/rapier3d-compat": "0.19.2",
29
+ "@pinkaphant/ecctrl": "2.0.4-beta.9",
30
+ "three": "0.184.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/react": "^19.2.16",
34
+ "@types/react-dom": "^19.2.3",
35
+ "@types/three": "0.184.0",
36
+ "@vitejs/plugin-react": "^6.1.1",
37
+ "typescript": "^7.0.2",
38
+ "vite": "^8.3.0"
39
+ }
40
+ }
@@ -0,0 +1,127 @@
1
+ import { useMemo, useRef, useState } from "react";
2
+ import { useFrame } from "@react-three/fiber";
3
+ import {
4
+ ACTOR_GROUND_CLEARANCE,
5
+ Actor,
6
+ Game,
7
+ Hud,
8
+ Prop,
9
+ Terrain,
10
+ Vehicle,
11
+ type EcctrlHandle,
12
+ } from "@pinkaphant/kolmo";
13
+ import {
14
+ frontage,
15
+ growRoad,
16
+ makeTerrain,
17
+ sampleRapierHeightfield,
18
+ type Terrain as RoadTerrain,
19
+ } from "@khr3/roads";
20
+
21
+ const VAULT = "https://khr3.optimuspi.workers.dev/assets";
22
+ const CHUNK_SIZE = 288;
23
+ const CHUNK_SEGMENTS = 96;
24
+
25
+ function StreamedHighwayTerrain({ land, initialPos }: { land: RoadTerrain; initialPos: [number, number, number] }) {
26
+ const cacheRef = useRef<Map<string, Float32Array>>(new Map());
27
+ const [sector, setSector] = useState<[number, number]>(() => [
28
+ Math.floor(initialPos[0] / CHUNK_SIZE),
29
+ Math.floor(initialPos[2] / CHUNK_SIZE),
30
+ ]);
31
+ const sectorRef = useRef(sector);
32
+
33
+ useFrame((state) => {
34
+ const cx = Math.floor(state.camera.position.x / CHUNK_SIZE);
35
+ const cz = Math.floor(state.camera.position.z / CHUNK_SIZE);
36
+ if (cx !== sectorRef.current[0] || cz !== sectorRef.current[1]) {
37
+ sectorRef.current = [cx, cz];
38
+ setSector([cx, cz]);
39
+ }
40
+ });
41
+
42
+ const chunks = useMemo(() => {
43
+ const list: Array<{ key: string; heights: Float32Array; position: [number, number, number] }> = [];
44
+ for (let dz = -1; dz <= 1; dz++) {
45
+ for (let dx = -1; dx <= 1; dx++) {
46
+ const cx = sector[0] + dx;
47
+ const cz = sector[1] + dz;
48
+ const key = `${cx},${cz}`;
49
+ let heights = cacheRef.current.get(key);
50
+ if (!heights) {
51
+ heights = sampleRapierHeightfield(land, [cx * CHUNK_SIZE, 0, cz * CHUNK_SIZE], CHUNK_SIZE, CHUNK_SEGMENTS);
52
+ cacheRef.current.set(key, heights);
53
+ }
54
+ list.push({
55
+ key,
56
+ heights,
57
+ position: [(cx + 0.5) * CHUNK_SIZE, 0, (cz + 0.5) * CHUNK_SIZE],
58
+ });
59
+ }
60
+ }
61
+ return list;
62
+ }, [land, sector]);
63
+
64
+ return (
65
+ <>
66
+ {chunks.map((chunk) => (
67
+ <Terrain
68
+ key={chunk.key}
69
+ heights={chunk.heights}
70
+ segments={CHUNK_SEGMENTS}
71
+ size={[CHUNK_SIZE, CHUNK_SIZE]}
72
+ position={chunk.position}
73
+ />
74
+ ))}
75
+ </>
76
+ );
77
+ }
78
+
79
+ export default function App() {
80
+ const actorRef = useRef<EcctrlHandle>(null);
81
+ const world = useMemo(() => {
82
+ const road = growRoad(14, {
83
+ length: 8100,
84
+ halfWidth: 4.5,
85
+ controlSpacing: 78,
86
+ maxTurn: 0.16,
87
+ maxGrade: 0.05,
88
+ hilliness: 21,
89
+ start: [0, 3, 0],
90
+ });
91
+ const land = makeTerrain(14, road, {
92
+ amplitude: 15,
93
+ noise: { wavelength: 216, octaves: 4, gain: 0.5, lacunarity: 2 },
94
+ maxSlope: 0.45,
95
+ minShoulder: 9,
96
+ verge: 3,
97
+ });
98
+ const at = road.at(36).pos;
99
+ const stops = frontage(road, { spacing: 1080, setback: 9 }).slice(0, 6);
100
+ return {
101
+ land,
102
+ car: [at[0], at[1], at[2]] as [number, number, number],
103
+ stops: stops.map((lot, idx) => ({
104
+ key: `stop-${idx}`,
105
+ canopy: [lot.front[0], lot.groundY, lot.front[2]] as [number, number, number],
106
+ sign: [lot.front[0] + lot.facing[0] * 3, lot.groundY, lot.front[2] + lot.facing[2] * 3] as [number, number, number],
107
+ })),
108
+ };
109
+ }, []);
110
+
111
+ return (
112
+ <>
113
+ <Game skybox="dusk">
114
+ <StreamedHighwayTerrain land={world.land} initialPos={world.car} />
115
+ {world.stops.map((stop) => (
116
+ <Prop key={stop.key} id={stop.key} src={`${VAULT}/city/gas-canopy-roof.glb`} position={stop.canopy} fixed />
117
+ ))}
118
+ {world.stops.map((stop) => (
119
+ <Prop key={`${stop.key}-sign`} id={`${stop.key}-sign`} src={`${VAULT}/city/neon-petro-sign.glb`} position={stop.sign} fixed />
120
+ ))}
121
+ <Vehicle id="beater" label="Beater" src={`${VAULT}/cars/kolmogorov_hatchback.glb`} position={world.car} />
122
+ <Actor ref={actorRef} position={[world.car[0] + 3, world.car[1] + ACTOR_GROUND_CLEARANCE, world.car[2]]} />
123
+ </Game>
124
+ <Hud />
125
+ </>
126
+ );
127
+ }
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import App from "./App.js";
4
+
5
+ createRoot(document.getElementById("root")!).render(
6
+ <React.StrictMode>
7
+ <App />
8
+ </React.StrictMode>,
9
+ );
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "jsx": "react-jsx",
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "isolatedModules": true,
11
+ "noEmit": true
12
+ },
13
+ "include": ["src", "vite.config.ts"]
14
+ }
@@ -0,0 +1,8 @@
1
+ import react from "@vitejs/plugin-react";
2
+ import { defineConfig } from "vite";
3
+ import { KOLMO_SINGLETON_DEDUPE } from "@pinkaphant/kolmo/vite";
4
+
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ resolve: { dedupe: KOLMO_SINGLETON_DEDUPE },
8
+ });
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@dimforge/rapier3d-compat": "0.19.2",
15
- "@pinkaphant/ecctrl": "2.0.4-beta.6",
15
+ "@pinkaphant/ecctrl": "2.0.4-beta.9",
16
16
  "@pinkaphant/kolmo": "^0.10.0",
17
17
  "@react-three/fiber": "^9.6.1",
18
18
  "@react-three/rapier": "^2.2.0",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "overrides": {
24
24
  "@dimforge/rapier3d-compat": "0.19.2",
25
- "@pinkaphant/ecctrl": "2.0.4-beta.6",
25
+ "@pinkaphant/ecctrl": "2.0.4-beta.9",
26
26
  "three": "0.184.0"
27
27
  },
28
28
  "devDependencies": {
@@ -0,0 +1,13 @@
1
+ # Kolmo Road Sandbox
2
+
3
+ Seeded road heightfield, Skyline R34, on-foot pilot controller, and Kolmogorov toolgun.
4
+
5
+ - **WASD** / **Arrows**: Move or drive
6
+ - **Shift**: Sprint / boost
7
+ - **E** / **F**: Board or exit vehicle
8
+ - **R**: Flip vehicle upright
9
+ - **T** / **Right-Click**: Spawn armed vehicle
10
+
11
+ ```bash
12
+ npm create @pinkaphant/kolmo@latest my-road-game
13
+ ```
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
+ <title>Kolmo Road</title>
7
+ <style>
8
+ html, body, #root { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #090d16; }
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <div id="root"></div>
13
+ <script type="module" src="/src/main.tsx"></script>
14
+ </body>
15
+ </html>
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "kolmo-road",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "description": "Kolmo road and vehicle sandbox on @pinkaphant/kolmo, @khr3/core, @khr3/roads, and @khr3/c12.",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "typecheck": "tsc --noEmit",
10
+ "build": "tsc --noEmit && vite build",
11
+ "preview": "vite preview"
12
+ },
13
+ "dependencies": {
14
+ "@dimforge/rapier3d-compat": "0.19.2",
15
+ "@khr3/c12": "^0.3.12",
16
+ "@khr3/core": "^0.2.19",
17
+ "@khr3/roads": "^0.1.1",
18
+ "@pinkaphant/ecctrl": "2.0.4-beta.9",
19
+ "@pinkaphant/kolmo": "^0.10.0",
20
+ "@react-three/drei": "^10.7.7",
21
+ "@react-three/fiber": "^9.6.1",
22
+ "@react-three/rapier": "^2.2.0",
23
+ "koota": "^0.6.6",
24
+ "react": "^19.2.7",
25
+ "react-dom": "^19.2.7",
26
+ "three": "0.184.0"
27
+ },
28
+ "overrides": {
29
+ "@dimforge/rapier3d-compat": "0.19.2",
30
+ "@pinkaphant/ecctrl": "2.0.4-beta.9",
31
+ "three": "0.184.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/react": "^19.2.16",
35
+ "@types/react-dom": "^19.2.3",
36
+ "@types/three": "0.184.0",
37
+ "@vitejs/plugin-react": "^6.1.1",
38
+ "typescript": "^7.0.2",
39
+ "vite": "^8.3.0"
40
+ }
41
+ }
@@ -0,0 +1,76 @@
1
+ import { useMemo, useRef } from "react";
2
+ import {
3
+ ACTOR_GROUND_CLEARANCE,
4
+ Actor,
5
+ Game,
6
+ Hud,
7
+ Prop,
8
+ Terrain,
9
+ Toolgun,
10
+ Vehicle,
11
+ type EcctrlHandle,
12
+ } from "@pinkaphant/kolmo";
13
+ import { frontage, growRoad, makeTerrain, sampleRapierHeightfield } from "@khr3/roads";
14
+
15
+ const VAULT = "https://khr3.optimuspi.workers.dev/assets";
16
+
17
+ export default function App() {
18
+ const actorRef = useRef<EcctrlHandle>(null);
19
+
20
+ const { heights, startPos, canopyPos, pumpPos } = useMemo(() => {
21
+ const road = growRoad(42, {
22
+ length: 600,
23
+ halfWidth: 4.5,
24
+ controlSpacing: 36,
25
+ maxTurn: 0.28,
26
+ maxGrade: 0.06,
27
+ hilliness: 18,
28
+ start: [0, 0, -150],
29
+ });
30
+ const land = makeTerrain(42, road, {
31
+ amplitude: 12,
32
+ noise: { wavelength: 144, octaves: 4, gain: 0.5, lacunarity: 2 },
33
+ maxSlope: 0.55,
34
+ minShoulder: 6,
35
+ verge: 3,
36
+ });
37
+ const heights = sampleRapierHeightfield(land, [-192, 0, -192], 384, 128);
38
+ const s0 = road.at(24).pos;
39
+ const lots = frontage(road, { spacing: 24, setback: 6 });
40
+ const lotA = lots[0];
41
+ const lotB = lots[1];
42
+ return {
43
+ heights,
44
+ startPos: [s0[0], s0[1], s0[2]] as [number, number, number],
45
+ canopyPos: lotA
46
+ ? ([lotA.front[0], lotA.groundY, lotA.front[2]] as [number, number, number])
47
+ : ([12, 0, -114] as [number, number, number]),
48
+ pumpPos: lotB
49
+ ? ([lotB.front[0], lotB.groundY, lotB.front[2]] as [number, number, number])
50
+ : ([12, 0, -90] as [number, number, number]),
51
+ };
52
+ }, []);
53
+
54
+ return (
55
+ <>
56
+ <Game skybox="day">
57
+ <Terrain heights={heights} segments={128} size={[384, 384]} />
58
+ <Vehicle id="r34" label="Skyline R34" src={`${VAULT}/cars/nissan_skyline_r34.glb`} position={startPos} />
59
+ <Prop id="canopy" src={`${VAULT}/city/gas-canopy-roof.glb`} position={canopyPos} fixed />
60
+ <Prop id="pump" src={`${VAULT}/city/gas-pump-twin.glb`} position={pumpPos} fixed />
61
+ <Actor ref={actorRef} position={[startPos[0] - 3, startPos[1] + ACTOR_GROUND_CLEARANCE, startPos[2]]} />
62
+ <Toolgun
63
+ src={`${VAULT}/weapons/kolmogorov_pistol.glb`}
64
+ actorRef={actorRef}
65
+ defaultArmedAsset={{
66
+ id: "supra",
67
+ name: "Supra A80",
68
+ src: `${VAULT}/cars/toyota_supra_a80.glb`,
69
+ kind: "vehicle",
70
+ }}
71
+ />
72
+ </Game>
73
+ <Hud />
74
+ </>
75
+ );
76
+ }
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import App from "./App.js";
4
+
5
+ createRoot(document.getElementById("root")!).render(
6
+ <React.StrictMode>
7
+ <App />
8
+ </React.StrictMode>,
9
+ );
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "jsx": "react-jsx",
8
+ "strict": true,
9
+ "noUnusedLocals": true,
10
+ "noUnusedParameters": true,
11
+ "skipLibCheck": true,
12
+ "isolatedModules": true
13
+ },
14
+ "include": ["src", "vite.config.ts"]
15
+ }
@@ -0,0 +1,10 @@
1
+ import react from "@vitejs/plugin-react";
2
+ import { defineConfig } from "vite";
3
+ import { KOLMO_SINGLETON_DEDUPE } from "@pinkaphant/kolmo/vite";
4
+
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ resolve: {
8
+ dedupe: KOLMO_SINGLETON_DEDUPE,
9
+ },
10
+ });