@pinkaphant/create-kolmo 0.4.2 → 0.5.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 +56 -17
- package/bin/create-kolmo.mjs +20 -12
- package/package.json +1 -1
- package/templates/demolition/README.md +17 -0
- package/templates/demolition/index.html +29 -0
- package/templates/demolition/package.json +39 -0
- package/templates/demolition/src/App.tsx +599 -0
- package/templates/{lonedrive → demolition}/tsconfig.json +4 -2
- package/templates/{lonedrive → demolition}/vite.config.ts +3 -1
- package/templates/dust/README.md +9 -1
- package/templates/dust/index.html +15 -1
- package/templates/dust/package.json +8 -6
- package/templates/dust/src/App.tsx +106 -122
- package/templates/dust/tsconfig.json +4 -2
- package/templates/evolution/README.md +15 -0
- package/templates/evolution/index.html +29 -0
- package/templates/{lonedrive → evolution}/package.json +8 -7
- package/templates/evolution/src/App.tsx +619 -0
- package/templates/evolution/src/main.tsx +10 -0
- package/templates/evolution/src/styles.css +237 -0
- package/templates/evolution/tsconfig.json +16 -0
- package/templates/evolution/vite.config.ts +10 -0
- package/templates/longline/README.md +16 -9
- package/templates/longline/index.html +26 -12
- package/templates/longline/package.json +11 -9
- package/templates/longline/src/App.tsx +191 -42
- package/templates/longline/src/highway.ts +222 -0
- package/templates/longline/src/main.tsx +7 -6
- package/templates/longline/tsconfig.json +14 -16
- package/templates/longline/vite.config.ts +5 -23
- package/templates/road/README.md +8 -4
- package/templates/road/index.html +15 -1
- package/templates/road/package.json +5 -5
- package/templates/road/src/App.tsx +21 -6
- package/templates/road/tsconfig.json +1 -0
- package/templates/tugline/README.md +16 -0
- package/templates/tugline/index.html +31 -0
- package/templates/tugline/package.json +41 -0
- package/templates/tugline/src/App.tsx +48 -0
- package/templates/{longline → tugline}/src/components/Boat.tsx +1 -2
- package/templates/{longline → tugline}/src/components/Crates.tsx +2 -2
- package/templates/tugline/src/components/Hud.tsx +281 -0
- package/templates/{longline → tugline}/src/components/Longline.tsx +2 -2
- package/templates/{longline → tugline}/src/components/Ocean.tsx +14 -3
- package/templates/{longline → tugline}/src/components/Radar.tsx +15 -14
- package/templates/{longline → tugline}/src/components/Referee.tsx +6 -4
- package/templates/{longline → tugline}/src/components/Scene.tsx +10 -9
- package/templates/{longline → tugline}/src/components/Sky.tsx +14 -8
- package/templates/{longline → tugline}/src/game/store.test.ts +2 -2
- package/templates/{longline → tugline}/src/game/store.ts +38 -19
- package/templates/tugline/src/main.tsx +13 -0
- package/templates/tugline/src/styles.css +495 -0
- package/templates/tugline/tsconfig.json +18 -0
- package/templates/tugline/vite.config.ts +16 -0
- package/templates/lonedrive/README.md +0 -11
- package/templates/lonedrive/index.html +0 -15
- package/templates/lonedrive/src/App.tsx +0 -149
- package/templates/longline/src/components/Hud.tsx +0 -197
- package/templates/longline/src/styles.css +0 -367
- /package/templates/{lonedrive → demolition}/src/main.tsx +0 -0
- /package/templates/{longline → tugline}/src/components/CameraRig.tsx +0 -0
- /package/templates/{longline → tugline}/src/components/ocean-material.ts +0 -0
- /package/templates/{longline → tugline}/src/components/round-context.ts +0 -0
- /package/templates/{longline → tugline}/src/game/boat-control.ts +0 -0
- /package/templates/{longline → tugline}/src/game/constants.ts +0 -0
- /package/templates/{longline → tugline}/src/game/input.test.ts +0 -0
- /package/templates/{longline → tugline}/src/game/input.ts +0 -0
- /package/templates/{longline → tugline}/src/game/logic.test.ts +0 -0
- /package/templates/{longline → tugline}/src/game/logic.ts +0 -0
- /package/templates/{longline → tugline}/src/game/physics.test.ts +0 -0
- /package/templates/{longline → tugline}/src/game/radar.ts +0 -0
- /package/templates/{longline → tugline}/src/game/registry.ts +0 -0
- /package/templates/{longline → tugline}/src/game/sea.ts +0 -0
- /package/templates/{longline → tugline}/src/game/session.ts +0 -0
- /package/templates/{longline → tugline}/src/game/simulation.test.ts +0 -0
- /package/templates/{longline → tugline}/src/game/simulation.ts +0 -0
- /package/templates/{longline → tugline}/src/game/test-world.ts +0 -0
- /package/templates/{longline → tugline}/src/sfx.ts +0 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--surface-canvas: oklch(13.5% 0.007 265);
|
|
3
|
+
--surface-dock: oklch(16.5% 0.008 265);
|
|
4
|
+
--surface-control: oklch(21% 0.009 265);
|
|
5
|
+
--surface-hover: oklch(25% 0.01 265);
|
|
6
|
+
--border-hairline: oklch(27% 0.01 265);
|
|
7
|
+
--ink-primary: oklch(94% 0.008 85);
|
|
8
|
+
--ink-muted: oklch(66% 0.01 265);
|
|
9
|
+
--accent-signal: oklch(80% 0.165 78);
|
|
10
|
+
--accent-gizmo: oklch(78% 0.135 205);
|
|
11
|
+
--accent-valid: oklch(79% 0.15 158);
|
|
12
|
+
--accent-alert: oklch(68% 0.19 28);
|
|
13
|
+
--font-sans: "Space Grotesk", system-ui, sans-serif;
|
|
14
|
+
--font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
15
|
+
color-scheme: dark;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
* {
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
html,
|
|
23
|
+
body,
|
|
24
|
+
#root {
|
|
25
|
+
margin: 0;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
background: var(--surface-canvas);
|
|
30
|
+
color: var(--ink-primary);
|
|
31
|
+
font-family: var(--font-sans);
|
|
32
|
+
font-variant-numeric: tabular-nums;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.evo-stage {
|
|
36
|
+
position: fixed;
|
|
37
|
+
inset: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.evo-topbar {
|
|
41
|
+
position: fixed;
|
|
42
|
+
top: 10px;
|
|
43
|
+
left: 12px;
|
|
44
|
+
z-index: 10;
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-wrap: wrap;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: 8px;
|
|
49
|
+
min-height: 36px;
|
|
50
|
+
padding: 4px 10px;
|
|
51
|
+
background: var(--surface-dock);
|
|
52
|
+
border: 1px solid var(--border-hairline);
|
|
53
|
+
border-radius: 3px;
|
|
54
|
+
font: 600 11px/1.3 var(--font-mono);
|
|
55
|
+
font-variant-numeric: tabular-nums;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.evo-label {
|
|
59
|
+
color: var(--ink-muted);
|
|
60
|
+
letter-spacing: 0.06em;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.evo-val {
|
|
64
|
+
color: var(--accent-signal);
|
|
65
|
+
min-width: 34px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.evo-cyan {
|
|
69
|
+
color: var(--accent-gizmo);
|
|
70
|
+
min-width: 58px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.evo-sep {
|
|
74
|
+
width: 1px;
|
|
75
|
+
height: 14px;
|
|
76
|
+
background: var(--border-hairline);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.evo-dock {
|
|
80
|
+
position: fixed;
|
|
81
|
+
top: 10px;
|
|
82
|
+
right: 12px;
|
|
83
|
+
width: min(352px, calc(100vw - 24px));
|
|
84
|
+
z-index: 10;
|
|
85
|
+
background: var(--surface-dock);
|
|
86
|
+
border: 1px solid var(--border-hairline);
|
|
87
|
+
border-radius: 3px;
|
|
88
|
+
font: 500 11px/1.35 var(--font-mono);
|
|
89
|
+
font-variant-numeric: tabular-nums;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.evo-dock-section {
|
|
93
|
+
padding: 8px 10px;
|
|
94
|
+
border-bottom: 1px solid var(--border-hairline);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.evo-dock-section:last-child {
|
|
98
|
+
border-bottom: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.evo-controls {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-wrap: wrap;
|
|
104
|
+
gap: 5px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.evo-btn {
|
|
108
|
+
min-height: 28px;
|
|
109
|
+
padding: 4px 8px;
|
|
110
|
+
border: 1px solid var(--border-hairline);
|
|
111
|
+
border-radius: 2px;
|
|
112
|
+
background: var(--surface-control);
|
|
113
|
+
color: var(--ink-primary);
|
|
114
|
+
font: 600 11px/1.2 var(--font-mono);
|
|
115
|
+
font-variant-numeric: tabular-nums;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.evo-btn:hover {
|
|
120
|
+
background: var(--surface-hover);
|
|
121
|
+
border-color: var(--ink-muted);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.evo-btn:focus-visible,
|
|
125
|
+
.evo-input:focus-visible,
|
|
126
|
+
.evo-row:focus-visible {
|
|
127
|
+
outline: 1px solid var(--accent-signal);
|
|
128
|
+
outline-offset: 1px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.evo-btn.active {
|
|
132
|
+
border-color: var(--accent-signal);
|
|
133
|
+
color: var(--accent-signal);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.evo-btn.primary {
|
|
137
|
+
background: var(--accent-signal);
|
|
138
|
+
border-color: var(--accent-signal);
|
|
139
|
+
color: var(--surface-canvas);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.evo-standings {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-direction: column;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.evo-row {
|
|
148
|
+
display: grid;
|
|
149
|
+
grid-template-columns: 24px 90px 1fr 66px;
|
|
150
|
+
align-items: center;
|
|
151
|
+
gap: 6px;
|
|
152
|
+
width: 100%;
|
|
153
|
+
min-height: 28px;
|
|
154
|
+
padding: 3px 6px;
|
|
155
|
+
border: 0;
|
|
156
|
+
border-bottom: 1px solid var(--border-hairline);
|
|
157
|
+
background: transparent;
|
|
158
|
+
color: var(--ink-primary);
|
|
159
|
+
font: 600 11px/1.25 var(--font-mono);
|
|
160
|
+
font-variant-numeric: tabular-nums;
|
|
161
|
+
text-align: left;
|
|
162
|
+
cursor: pointer;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.evo-row:last-child {
|
|
166
|
+
border-bottom: 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.evo-row:hover {
|
|
170
|
+
background: var(--surface-control);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.evo-row.selected {
|
|
174
|
+
background: var(--surface-control);
|
|
175
|
+
color: var(--accent-signal);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.evo-slot {
|
|
179
|
+
color: var(--ink-muted);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.evo-gene {
|
|
183
|
+
color: var(--accent-valid);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.evo-row.selected .evo-gene {
|
|
187
|
+
color: var(--accent-signal);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.evo-dist {
|
|
191
|
+
color: var(--ink-primary);
|
|
192
|
+
text-align: right;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.evo-fit {
|
|
196
|
+
color: var(--accent-gizmo);
|
|
197
|
+
text-align: right;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.evo-spec {
|
|
201
|
+
color: var(--ink-muted);
|
|
202
|
+
font-size: 10px;
|
|
203
|
+
line-height: 1.4;
|
|
204
|
+
min-height: 28px;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.evo-inject {
|
|
208
|
+
display: grid;
|
|
209
|
+
grid-template-columns: 1fr auto auto;
|
|
210
|
+
gap: 5px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.evo-input {
|
|
214
|
+
min-width: 0;
|
|
215
|
+
min-height: 28px;
|
|
216
|
+
padding: 4px 7px;
|
|
217
|
+
border: 1px solid var(--border-hairline);
|
|
218
|
+
border-radius: 2px;
|
|
219
|
+
background: var(--surface-control);
|
|
220
|
+
color: var(--ink-primary);
|
|
221
|
+
font: 600 11px/1.2 var(--font-mono);
|
|
222
|
+
font-variant-numeric: tabular-nums;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.evo-error {
|
|
226
|
+
margin-top: 5px;
|
|
227
|
+
color: var(--accent-alert);
|
|
228
|
+
font-size: 10px;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@media (pointer: coarse) {
|
|
232
|
+
.evo-btn,
|
|
233
|
+
.evo-input,
|
|
234
|
+
.evo-row {
|
|
235
|
+
min-height: 44px;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
"noEmit": true,
|
|
10
|
+
"noUnusedLocals": true,
|
|
11
|
+
"noUnusedParameters": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"isolatedModules": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["src", "vite.config.ts"]
|
|
16
|
+
}
|
|
@@ -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
|
+
});
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
# Longline
|
|
1
|
+
# Kolmo Longline
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Endless `+Z` procedural desert highway inspired by *The Long Drive*, built on `@pinkaphant/kolmo` and `@khr3/roads` ([`./src/highway.ts`](./src/highway.ts), [`./src/App.tsx`](./src/App.tsx)).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
npm run dev
|
|
7
|
-
```
|
|
5
|
+
Streams `288 m` road splines and Rapier heightfield sectors infinitely along `+Z` with a bounded 9-chunk LRU cache, places periodic roadside gas stations (`gas-canopy-roof.glb`, `gas-pump-twin.glb`, `neon-petro-sign.glb`) with swap vehicles, and updates a `tabular-nums` top odometer (`000.0 km`) directly via DOM ref.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
- **WASD** / **Arrows**: Walk or drive
|
|
8
|
+
- **Shift**: Sprint (on foot) / boost (vehicle)
|
|
9
|
+
- **Space**: Jump (on foot) / brake (vehicle)
|
|
10
|
+
- **C**: Brake
|
|
11
|
+
- **E** / **F**: Board or exit any vehicle
|
|
12
|
+
- **R**: Flip vehicle upright
|
|
13
|
+
- **V**: Toggle FPS / TPS camera
|
|
14
|
+
- **L**: Toggle vehicle headlights
|
|
15
|
+
- **N**: Cycle day / dusk / night sky
|
|
16
|
+
- **O** or **Drag & Drop `.glb`**: Auto-rig, spawn, and board any car `.glb`
|
|
17
|
+
- **T** / **Right-Click**: Spawn armed vehicle
|
|
10
18
|
|
|
11
|
-
```
|
|
12
|
-
npm
|
|
13
|
-
npm run build
|
|
19
|
+
```bash
|
|
20
|
+
npm create @pinkaphant/kolmo@latest my-longline -- --template longline
|
|
14
21
|
```
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 Longline</title>
|
|
7
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
|
+
<link
|
|
10
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@500;600&family=Space+Grotesk:wght@500;600;700&display=swap"
|
|
11
|
+
rel="stylesheet"
|
|
12
|
+
/>
|
|
13
|
+
<style>
|
|
14
|
+
html, body, #root {
|
|
15
|
+
margin: 0;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
background: oklch(13.5% 0.007 265);
|
|
20
|
+
font-family: "Space Grotesk", system-ui, sans-serif;
|
|
21
|
+
font-variant-numeric: tabular-nums;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
24
|
+
</head>
|
|
25
|
+
<body>
|
|
26
|
+
<div id="root"></div>
|
|
27
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
28
|
+
</body>
|
|
15
29
|
</html>
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "longline
|
|
2
|
+
"name": "kolmo-longline",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"private": true,
|
|
5
|
+
"description": "Longline: endless +Z procedural desert highway, streamed 288 m chunks, and roadside salvage stops on @pinkaphant/kolmo.",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"dev": "vite",
|
|
8
9
|
"typecheck": "tsc --noEmit",
|
|
9
10
|
"build": "tsc --noEmit && vite build",
|
|
10
|
-
"preview": "vite preview"
|
|
11
|
-
"test": "node --import tsx --test \"src/**/*.test.ts\""
|
|
11
|
+
"preview": "vite preview"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@dimforge/rapier3d-compat": "0.19.2",
|
|
15
|
+
"@khr3/core": "^0.2.21",
|
|
16
|
+
"@khr3/roads": "^0.1.2",
|
|
15
17
|
"@pinkaphant/ecctrl": "2.0.4-beta.9",
|
|
16
|
-
"@pinkaphant/kolmo": "^0.
|
|
18
|
+
"@pinkaphant/kolmo": "^0.15.0",
|
|
19
|
+
"@react-three/drei": "^10.7.7",
|
|
17
20
|
"@react-three/fiber": "^9.6.1",
|
|
18
21
|
"@react-three/rapier": "^2.2.0",
|
|
22
|
+
"koota": "^0.6.6",
|
|
19
23
|
"react": "^19.2.7",
|
|
20
24
|
"react-dom": "^19.2.7",
|
|
21
25
|
"three": "0.184.0"
|
|
@@ -26,13 +30,11 @@
|
|
|
26
30
|
"three": "0.184.0"
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|
|
29
|
-
"@types/node": "^26.6.11",
|
|
30
33
|
"@types/react": "^19.2.16",
|
|
31
34
|
"@types/react-dom": "^19.2.3",
|
|
32
35
|
"@types/three": "0.184.0",
|
|
33
|
-
"@vitejs/plugin-react": "^6.
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"vite": "^8.3.0"
|
|
36
|
+
"@vitejs/plugin-react": "^6.3.1",
|
|
37
|
+
"typescript": "^5.8.3",
|
|
38
|
+
"vite": "^8.4.1"
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -1,48 +1,197 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { Fragment, useEffect, 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
|
+
Radar,
|
|
10
|
+
RoadRibbon,
|
|
11
|
+
Terrain,
|
|
12
|
+
Toolgun,
|
|
13
|
+
Vehicle,
|
|
14
|
+
computeSplineSpawnPose,
|
|
15
|
+
radarRoadFromSpline,
|
|
16
|
+
type EcctrlHandle,
|
|
17
|
+
} from "@pinkaphant/kolmo";
|
|
18
|
+
import {
|
|
19
|
+
CHUNK_SEGMENTS,
|
|
20
|
+
CHUNK_SIZE,
|
|
21
|
+
HighwayChunkCache,
|
|
22
|
+
VAULT,
|
|
23
|
+
buildActiveHighwayWindow,
|
|
24
|
+
buildSectorRoad,
|
|
25
|
+
} from "./highway.js";
|
|
26
|
+
|
|
27
|
+
function SectorStreamer({
|
|
28
|
+
startZ,
|
|
29
|
+
sectorZRef,
|
|
30
|
+
cameraZRef,
|
|
31
|
+
odometerRef,
|
|
32
|
+
}: {
|
|
33
|
+
startZ: number;
|
|
34
|
+
sectorZRef: React.RefObject<number>;
|
|
35
|
+
cameraZRef: React.RefObject<number>;
|
|
36
|
+
odometerRef: React.RefObject<HTMLSpanElement | null>;
|
|
37
|
+
}) {
|
|
38
|
+
const lastKmTenthsRef = useRef(-1);
|
|
39
|
+
|
|
40
|
+
useFrame((state) => {
|
|
41
|
+
const z = state.camera.position.z;
|
|
42
|
+
cameraZRef.current = z;
|
|
43
|
+
const nextSectorZ = Math.floor(z / CHUNK_SIZE);
|
|
44
|
+
if (nextSectorZ !== sectorZRef.current) {
|
|
45
|
+
sectorZRef.current = nextSectorZ;
|
|
46
|
+
window.dispatchEvent(new CustomEvent("kolmo:highway-sector", { detail: nextSectorZ }));
|
|
15
47
|
}
|
|
16
48
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
49
|
+
const distKm = Math.max(0, (z - startZ) * 0.001);
|
|
50
|
+
const tenths = Math.round(distKm * 10);
|
|
51
|
+
if (tenths !== lastKmTenthsRef.current) {
|
|
52
|
+
lastKmTenthsRef.current = tenths;
|
|
53
|
+
const el = odometerRef.current;
|
|
54
|
+
if (el !== null) {
|
|
55
|
+
const whole = Math.floor(tenths / 10);
|
|
56
|
+
const frac = tenths % 10;
|
|
57
|
+
el.textContent = `${String(whole).padStart(3, "0")}.${frac} km`;
|
|
58
|
+
}
|
|
27
59
|
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return null;
|
|
28
63
|
}
|
|
29
64
|
|
|
30
|
-
export function App(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
65
|
+
export default function App() {
|
|
66
|
+
const actorRef = useRef<EcctrlHandle>(null);
|
|
67
|
+
const odometerRef = useRef<HTMLSpanElement>(null);
|
|
68
|
+
const cacheRef = useRef<HighwayChunkCache | null>(null);
|
|
69
|
+
if (cacheRef.current === null) {
|
|
70
|
+
cacheRef.current = new HighwayChunkCache(9);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const starter = useMemo(() => {
|
|
74
|
+
const startRoad = buildSectorRoad(0, 1);
|
|
75
|
+
const carPose = computeSplineSpawnPose(startRoad, 36, 0, -0.64, 0.04);
|
|
76
|
+
const s0 = startRoad.at(36);
|
|
77
|
+
const actorPos: [number, number, number] = [
|
|
78
|
+
s0.pos[0] + s0.left[0] * 3.2,
|
|
79
|
+
s0.pos[1] + ACTOR_GROUND_CLEARANCE,
|
|
80
|
+
s0.pos[2] + s0.left[2] * 3.2,
|
|
81
|
+
];
|
|
82
|
+
const startSectorZ = Math.floor(carPose.position[2] / CHUNK_SIZE);
|
|
83
|
+
return { carPose, actorPos, startZ: carPose.position[2], startSectorZ };
|
|
84
|
+
}, []);
|
|
85
|
+
|
|
86
|
+
const [sectorZ, setSectorZ] = useState(starter.startSectorZ);
|
|
87
|
+
const sectorZRef = useRef(sectorZ);
|
|
88
|
+
const cameraZRef = useRef(starter.startZ);
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const onSector = (event: Event) => {
|
|
92
|
+
const next = (event as CustomEvent<number>).detail;
|
|
93
|
+
if (typeof next === "number") {
|
|
94
|
+
setSectorZ(next);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
window.addEventListener("kolmo:highway-sector", onSector);
|
|
98
|
+
return () => window.removeEventListener("kolmo:highway-sector", onSector);
|
|
99
|
+
}, []);
|
|
100
|
+
|
|
101
|
+
const activeWindow = useMemo(
|
|
102
|
+
() => buildActiveHighwayWindow(sectorZ, cacheRef.current!),
|
|
103
|
+
[sectorZ],
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const radarSpec = useMemo(
|
|
107
|
+
() => ({
|
|
108
|
+
range: 180,
|
|
109
|
+
headingUp: true,
|
|
110
|
+
roads: [radarRoadFromSpline(activeWindow.corridorRoad, { id: `highway-z-${sectorZ}`, maxStep: 12 })],
|
|
111
|
+
}),
|
|
112
|
+
[activeWindow.corridorRoad, sectorZ],
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<>
|
|
117
|
+
<Game skybox="dusk" dropSpawn>
|
|
118
|
+
<SectorStreamer
|
|
119
|
+
startZ={starter.startZ}
|
|
120
|
+
sectorZRef={sectorZRef}
|
|
121
|
+
cameraZRef={cameraZRef}
|
|
122
|
+
odometerRef={odometerRef}
|
|
123
|
+
/>
|
|
124
|
+
{activeWindow.chunks.map((chunk) => (
|
|
125
|
+
<Terrain
|
|
126
|
+
key={chunk.key}
|
|
127
|
+
heights={chunk.heights}
|
|
128
|
+
segments={CHUNK_SEGMENTS}
|
|
129
|
+
size={[CHUNK_SIZE, CHUNK_SIZE]}
|
|
130
|
+
position={chunk.position}
|
|
131
|
+
color="#6e5842"
|
|
132
|
+
/>
|
|
133
|
+
))}
|
|
134
|
+
<RoadRibbon road={activeWindow.corridorRoad} />
|
|
135
|
+
{activeWindow.stops.map((stop) => (
|
|
136
|
+
<Fragment key={stop.key}>
|
|
137
|
+
<Prop id={`${stop.key}-canopy`} src={`${VAULT}/city/gas-canopy-roof.glb`} position={stop.canopyPos} fixed />
|
|
138
|
+
<Prop id={`${stop.key}-pump`} src={`${VAULT}/city/gas-pump-twin.glb`} position={stop.pumpPos} fixed />
|
|
139
|
+
<Prop id={`${stop.key}-sign`} src={`${VAULT}/city/neon-petro-sign.glb`} position={stop.signPos} fixed />
|
|
140
|
+
<Vehicle
|
|
141
|
+
id={stop.swapVehicle.id}
|
|
142
|
+
label={stop.swapVehicle.label}
|
|
143
|
+
src={stop.swapVehicle.src}
|
|
144
|
+
position={stop.swapVehicle.pose.position}
|
|
145
|
+
quaternion={stop.swapVehicle.pose.quaternion}
|
|
146
|
+
/>
|
|
147
|
+
</Fragment>
|
|
148
|
+
))}
|
|
149
|
+
<Vehicle
|
|
150
|
+
id="gt"
|
|
151
|
+
label="Long-Haul Coupe"
|
|
152
|
+
src={`${VAULT}/cars/toyota_supra_a80.glb`}
|
|
153
|
+
position={starter.carPose.position}
|
|
154
|
+
quaternion={starter.carPose.quaternion}
|
|
155
|
+
/>
|
|
156
|
+
<Actor ref={actorRef} position={starter.actorPos} />
|
|
157
|
+
<Toolgun
|
|
158
|
+
src={`${VAULT}/weapons/kolmogorov_pistol.glb`}
|
|
159
|
+
actorRef={actorRef}
|
|
160
|
+
defaultArmedAsset={{
|
|
161
|
+
id: "hatchback",
|
|
162
|
+
name: "Kolmo Hatchback",
|
|
163
|
+
src: `${VAULT}/cars/kolmogorov_hatchback.glb`,
|
|
164
|
+
kind: "vehicle",
|
|
165
|
+
}}
|
|
166
|
+
/>
|
|
167
|
+
</Game>
|
|
168
|
+
<div
|
|
169
|
+
style={{
|
|
170
|
+
position: "fixed",
|
|
171
|
+
top: 12,
|
|
172
|
+
right: 12,
|
|
173
|
+
zIndex: 10,
|
|
174
|
+
display: "flex",
|
|
175
|
+
alignItems: "center",
|
|
176
|
+
gap: 8,
|
|
177
|
+
padding: "7px 11px",
|
|
178
|
+
borderRadius: 3,
|
|
179
|
+
border: "1px solid oklch(27% 0.010 265)",
|
|
180
|
+
background: "oklch(16.5% 0.008 265)",
|
|
181
|
+
color: "oklch(94% 0.008 85)",
|
|
182
|
+
font: '600 12px/1.35 "IBM Plex Mono", ui-monospace, monospace',
|
|
183
|
+
fontVariantNumeric: "tabular-nums",
|
|
184
|
+
pointerEvents: "none",
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
<span style={{ color: "oklch(66% 0.010 265)", fontSize: 11, letterSpacing: "0.06em" }}>HIGHWAY +Z</span>
|
|
188
|
+
<span style={{ width: 1, height: 13, background: "oklch(27% 0.010 265)" }} />
|
|
189
|
+
<span ref={odometerRef} style={{ color: "oklch(80% 0.165 78)", minWidth: 68 }}>
|
|
190
|
+
000.0 km
|
|
191
|
+
</span>
|
|
192
|
+
</div>
|
|
193
|
+
<Hud />
|
|
194
|
+
<Radar spec={radarSpec} />
|
|
195
|
+
</>
|
|
196
|
+
);
|
|
48
197
|
}
|