@pinkaphant/create-kolmo 0.3.3 → 0.4.0

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
@@ -36,6 +36,6 @@ cd my-road-game
36
36
  npm run dev
37
37
  ```
38
38
 
39
- The default road template includes a road heightfield, vehicle, on-foot controller, and toolgun. **WASD** moves, **Shift** runs, **F** boards, and **Space** jumps.
39
+ The default road template generates a seeded `@khr3/roads` continuous spline (`<RoadRibbon>`), grades a `384 m` terrain pad, places a cyclotomic `@khr3/c12` `planSettlement` village (`<Settlement>` with Rapier revolute-hinged doors), and mounts a vehicle, on-foot controller, toolgun, HUD, and `<Radar>`. **WASD** moves, **Shift** runs, **E** or **F** boards, **R** uprights, **T** or right-click spawns from the toolgun, and **Space** jumps.
40
40
 
41
41
  Add `--no-install` to either command to skip dependency installation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinkaphant/create-kolmo",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
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",
@@ -21,7 +21,7 @@
21
21
  "pack:dry": "npm pack --dry-run"
22
22
  },
23
23
  "engines": {
24
- "node": ">=20"
24
+ "node": ">=24"
25
25
  },
26
26
  "repository": {
27
27
  "type": "git",
@@ -12,9 +12,9 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@dimforge/rapier3d-compat": "0.19.2",
15
- "@khr3/core": "^0.2.19",
15
+ "@khr3/core": "^0.2.20",
16
16
  "@pinkaphant/ecctrl": "2.0.4-beta.9",
17
- "@pinkaphant/kolmo": "^0.10.0",
17
+ "@pinkaphant/kolmo": "^0.11.0",
18
18
  "@react-three/drei": "^10.7.7",
19
19
  "@react-three/fiber": "^9.6.1",
20
20
  "@react-three/rapier": "^2.2.0",
@@ -7,6 +7,7 @@ import {
7
7
  Game,
8
8
  Hud,
9
9
  Prop,
10
+ Radar,
10
11
  Terrain,
11
12
  Toolgun,
12
13
  Vehicle,
@@ -159,6 +160,7 @@ export default function App() {
159
160
  />
160
161
  </Game>
161
162
  <Hud />
163
+ <Radar spec={{ range: 96, headingUp: true }} />
162
164
  </>
163
165
  );
164
166
  }
@@ -12,10 +12,10 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@dimforge/rapier3d-compat": "0.19.2",
15
- "@khr3/core": "^0.2.19",
16
- "@khr3/roads": "^0.1.1",
15
+ "@khr3/core": "^0.2.20",
16
+ "@khr3/roads": "^0.1.2",
17
17
  "@pinkaphant/ecctrl": "2.0.4-beta.9",
18
- "@pinkaphant/kolmo": "^0.10.0",
18
+ "@pinkaphant/kolmo": "^0.11.0",
19
19
  "@react-three/drei": "^10.7.7",
20
20
  "@react-three/fiber": "^9.6.1",
21
21
  "@react-three/rapier": "^2.2.0",
@@ -1,4 +1,4 @@
1
- import { useMemo, useRef, useState } from "react";
1
+ import { useEffect, useMemo, useRef, useState } from "react";
2
2
  import { useFrame } from "@react-three/fiber";
3
3
  import {
4
4
  ACTOR_GROUND_CLEARANCE,
@@ -6,8 +6,11 @@ import {
6
6
  Game,
7
7
  Hud,
8
8
  Prop,
9
+ Radar,
10
+ RoadRibbon,
9
11
  Terrain,
10
12
  Vehicle,
13
+ radarRoadFromSpline,
11
14
  type EcctrlHandle,
12
15
  } from "@pinkaphant/kolmo";
13
16
  import {
@@ -24,6 +27,7 @@ const CHUNK_SEGMENTS = 96;
24
27
 
25
28
  function StreamedHighwayTerrain({ land, initialPos }: { land: RoadTerrain; initialPos: [number, number, number] }) {
26
29
  const cacheRef = useRef<Map<string, Float32Array>>(new Map());
30
+ const camXZRef = useRef<[number, number]>([initialPos[0], initialPos[2]]);
27
31
  const [sector, setSector] = useState<[number, number]>(() => [
28
32
  Math.floor(initialPos[0] / CHUNK_SIZE),
29
33
  Math.floor(initialPos[2] / CHUNK_SIZE),
@@ -31,14 +35,22 @@ function StreamedHighwayTerrain({ land, initialPos }: { land: RoadTerrain; initi
31
35
  const sectorRef = useRef(sector);
32
36
 
33
37
  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
- }
38
+ camXZRef.current[0] = state.camera.position.x;
39
+ camXZRef.current[1] = state.camera.position.z;
40
40
  });
41
41
 
42
+ useEffect(() => {
43
+ const timer = window.setInterval(() => {
44
+ const cx = Math.floor(camXZRef.current[0] / CHUNK_SIZE);
45
+ const cz = Math.floor(camXZRef.current[1] / CHUNK_SIZE);
46
+ if (cx !== sectorRef.current[0] || cz !== sectorRef.current[1]) {
47
+ sectorRef.current = [cx, cz];
48
+ setSector([cx, cz]);
49
+ }
50
+ }, 150);
51
+ return () => window.clearInterval(timer);
52
+ }, []);
53
+
42
54
  const chunks = useMemo(() => {
43
55
  const list: Array<{ key: string; heights: Float32Array; position: [number, number, number] }> = [];
44
56
  for (let dz = -1; dz <= 1; dz++) {
@@ -70,6 +82,7 @@ function StreamedHighwayTerrain({ land, initialPos }: { land: RoadTerrain; initi
70
82
  segments={CHUNK_SEGMENTS}
71
83
  size={[CHUNK_SIZE, CHUNK_SIZE]}
72
84
  position={chunk.position}
85
+ color="#6e5842"
73
86
  />
74
87
  ))}
75
88
  </>
@@ -97,8 +110,15 @@ export default function App() {
97
110
  });
98
111
  const at = road.at(36).pos;
99
112
  const stops = frontage(road, { spacing: 1080, setback: 9 }).slice(0, 6);
113
+ const radarSpec = {
114
+ range: 180,
115
+ headingUp: true,
116
+ roads: [radarRoadFromSpline(road, { id: "highway-14", maxStep: 18 })],
117
+ };
100
118
  return {
119
+ road,
101
120
  land,
121
+ radarSpec,
102
122
  car: [at[0], at[1], at[2]] as [number, number, number],
103
123
  stops: stops.map((lot, idx) => ({
104
124
  key: `stop-${idx}`,
@@ -112,16 +132,18 @@ export default function App() {
112
132
  <>
113
133
  <Game skybox="dusk">
114
134
  <StreamedHighwayTerrain land={world.land} initialPos={world.car} />
135
+ <RoadRibbon road={world.road} />
115
136
  {world.stops.map((stop) => (
116
137
  <Prop key={stop.key} id={stop.key} src={`${VAULT}/city/gas-canopy-roof.glb`} position={stop.canopy} fixed />
117
138
  ))}
118
139
  {world.stops.map((stop) => (
119
140
  <Prop key={`${stop.key}-sign`} id={`${stop.key}-sign`} src={`${VAULT}/city/neon-petro-sign.glb`} position={stop.sign} fixed />
120
141
  ))}
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]]} />
142
+ <Vehicle id="gt" label="Long-Haul Coupe" src={`${VAULT}/cars/toyota_supra_a80.glb`} position={world.car} />
143
+ <Actor ref={actorRef} position={[world.car[0] - 3, world.car[1] + ACTOR_GROUND_CLEARANCE, world.car[2]]} />
123
144
  </Game>
124
145
  <Hud />
146
+ <Radar spec={world.radarSpec} />
125
147
  </>
126
148
  );
127
149
  }
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "@dimforge/rapier3d-compat": "0.19.2",
15
15
  "@pinkaphant/ecctrl": "2.0.4-beta.9",
16
- "@pinkaphant/kolmo": "^0.10.0",
16
+ "@pinkaphant/kolmo": "^0.11.0",
17
17
  "@react-three/fiber": "^9.6.1",
18
18
  "@react-three/rapier": "^2.2.0",
19
19
  "react": "^19.2.7",
@@ -26,7 +26,7 @@
26
26
  "three": "0.184.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/node": "^22.14.0",
29
+ "@types/node": "^26.6.11",
30
30
  "@types/react": "^19.2.16",
31
31
  "@types/react-dom": "^19.2.3",
32
32
  "@types/three": "0.184.0",
@@ -18,7 +18,7 @@ body,
18
18
  margin: 0;
19
19
  overflow: hidden;
20
20
  background: #b9dbea;
21
- font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
21
+ font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
22
22
  -webkit-tap-highlight-color: transparent;
23
23
  overscroll-behavior: none;
24
24
  }
@@ -365,10 +365,3 @@ kbd {
365
365
  font-size: 0.8rem;
366
366
  }
367
367
  }
368
-
369
- @media (prefers-reduced-motion: reduce) {
370
- .toast,
371
- .clock.low {
372
- animation: none;
373
- }
374
- }
@@ -12,11 +12,11 @@
12
12
  },
13
13
  "dependencies": {
14
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",
15
+ "@khr3/c12": "^0.4.0",
16
+ "@khr3/core": "^0.2.20",
17
+ "@khr3/roads": "^0.1.2",
18
18
  "@pinkaphant/ecctrl": "2.0.4-beta.9",
19
- "@pinkaphant/kolmo": "^0.10.0",
19
+ "@pinkaphant/kolmo": "^0.11.0",
20
20
  "@react-three/drei": "^10.7.7",
21
21
  "@react-three/fiber": "^9.6.1",
22
22
  "@react-three/rapier": "^2.2.0",
@@ -5,11 +5,18 @@ import {
5
5
  Game,
6
6
  Hud,
7
7
  Prop,
8
+ Radar,
9
+ RoadRibbon,
10
+ Settlement,
8
11
  Terrain,
9
12
  Toolgun,
10
13
  Vehicle,
14
+ radarFootprintsFromBatches,
15
+ radarRoadFromSpline,
16
+ settlementShoulderWidth,
11
17
  type EcctrlHandle,
12
18
  } from "@pinkaphant/kolmo";
19
+ import { instanceBatches, planSettlement } from "@khr3/c12";
13
20
  import { frontage, growRoad, makeTerrain, sampleRapierHeightfield } from "@khr3/roads";
14
21
 
15
22
  const VAULT = "https://khr3.optimuspi.workers.dev/assets";
@@ -17,37 +24,49 @@ const VAULT = "https://khr3.optimuspi.workers.dev/assets";
17
24
  export default function App() {
18
25
  const actorRef = useRef<EcctrlHandle>(null);
19
26
 
20
- const { heights, startPos, canopyPos, pumpPos } = useMemo(() => {
21
- const road = growRoad(42, {
22
- length: 600,
27
+ const { road, heights, batches, radarSpec, startPos, canopyPos, pumpPos } = useMemo(() => {
28
+ const builtRoad = growRoad(42, {
29
+ length: 540,
23
30
  halfWidth: 4.5,
24
31
  controlSpacing: 36,
25
- maxTurn: 0.28,
26
- maxGrade: 0.06,
27
- hilliness: 18,
28
- start: [0, 0, -150],
32
+ maxTurn: 0.24,
33
+ maxGrade: 0.05,
34
+ hilliness: 14,
35
+ start: [0, 0, -168],
29
36
  });
30
- const land = makeTerrain(42, road, {
37
+ const settlement = planSettlement(builtRoad, "village", 42, { centerS: 210, setback: 2 });
38
+ const c12Batches = instanceBatches(settlement.pieces);
39
+ const shoulder = settlementShoulderWidth("village", 2);
40
+ const land = makeTerrain(42, builtRoad, {
31
41
  amplitude: 12,
32
42
  noise: { wavelength: 144, octaves: 4, gain: 0.5, lacunarity: 2 },
33
43
  maxSlope: 0.55,
34
- minShoulder: 6,
35
- verge: 3,
44
+ minShoulder: shoulder,
45
+ verge: 4,
36
46
  });
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 });
47
+ const hf = sampleRapierHeightfield(land, [-192, 0, -192], 384, 128);
48
+ const s0 = builtRoad.at(36).pos;
49
+ const lots = frontage(builtRoad, { spacing: 24, setback: 7 });
40
50
  const lotA = lots[0];
41
51
  const lotB = lots[1];
52
+ const spec = {
53
+ range: 108,
54
+ headingUp: true,
55
+ roads: [radarRoadFromSpline(builtRoad, { id: "main", maxStep: 6 })],
56
+ footprints: radarFootprintsFromBatches(c12Batches),
57
+ };
42
58
  return {
43
- heights,
59
+ road: builtRoad,
60
+ heights: hf,
61
+ batches: c12Batches,
62
+ radarSpec: spec,
44
63
  startPos: [s0[0], s0[1], s0[2]] as [number, number, number],
45
64
  canopyPos: lotA
46
65
  ? ([lotA.front[0], lotA.groundY, lotA.front[2]] as [number, number, number])
47
- : ([12, 0, -114] as [number, number, number]),
66
+ : ([12, 0, -120] as [number, number, number]),
48
67
  pumpPos: lotB
49
68
  ? ([lotB.front[0], lotB.groundY, lotB.front[2]] as [number, number, number])
50
- : ([12, 0, -90] as [number, number, number]),
69
+ : ([12, 0, -96] as [number, number, number]),
51
70
  };
52
71
  }, []);
53
72
 
@@ -55,6 +74,8 @@ export default function App() {
55
74
  <>
56
75
  <Game skybox="day">
57
76
  <Terrain heights={heights} segments={128} size={[384, 384]} />
77
+ <RoadRibbon road={road} />
78
+ <Settlement batches={batches} />
58
79
  <Vehicle id="r34" label="Skyline R34" src={`${VAULT}/cars/nissan_skyline_r34.glb`} position={startPos} />
59
80
  <Prop id="canopy" src={`${VAULT}/city/gas-canopy-roof.glb`} position={canopyPos} fixed />
60
81
  <Prop id="pump" src={`${VAULT}/city/gas-pump-twin.glb`} position={pumpPos} fixed />
@@ -71,6 +92,7 @@ export default function App() {
71
92
  />
72
93
  </Game>
73
94
  <Hud />
95
+ <Radar spec={radarSpec} />
74
96
  </>
75
97
  );
76
98
  }