@bendyline/molen-tooling 0.0.1 → 0.0.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 +22 -4
- package/dist/cli.mjs +26 -4
- package/dist/docs-src/guide/3d-art-guidelines.md +2 -2
- package/dist/docs-src/guide/3d-model-assets.md +15 -11
- package/dist/docs-src/guide/aircraft.md +9 -10
- package/dist/docs-src/guide/browser-mount.md +14 -0
- package/dist/docs-src/guide/building-interiors.md +2 -1
- package/dist/docs-src/guide/determinism.md +16 -11
- package/dist/docs-src/guide/entities.md +16 -5
- package/dist/docs-src/guide/examples.md +38 -23
- package/dist/docs-src/guide/experience-playback.md +2 -3
- package/dist/docs-src/guide/game-samples.md +30 -18
- package/dist/docs-src/guide/project.md +22 -2
- package/dist/docs-src/guide/quickstart.md +37 -28
- package/dist/docs-src/guide/recognizable-places.md +21 -15
- package/dist/docs-src/guide/rendering-backends.md +5 -4
- package/dist/docs-src/guide/scripting.md +4 -2
- package/dist/docs-src/guide/sky.md +10 -9
- package/dist/docs-src/guide/structure-library.md +18 -8
- package/dist/docs-src/guide/terrain.md +6 -4
- package/dist/docs-src/guide/vehicles.md +9 -5
- package/dist/docs-src/guide/worldgen.md +31 -21
- package/dist/docs-src/llms.txt +26 -15
- package/dist/docs-src/schemas/README.md +1 -1
- package/dist/index.d.mts +26 -2
- package/dist/index.mjs +2 -2
- package/dist/{mcp-BFnCWrg0.mjs → mcp-AOfIp89b.mjs} +12 -2
- package/dist/{ops-BGxhSP6w.mjs → ops-C4BvDgP-.mjs} +267 -33
- package/dist/templates/city-courier/README.md +53 -0
- package/dist/templates/city-courier/checks.json +20 -0
- package/dist/templates/city-courier/commands.json +32 -0
- package/dist/templates/city-courier/delivery-run.replay.json +214 -0
- package/dist/templates/city-courier/gen/molen-types.ts +878 -0
- package/dist/templates/city-courier/index.html +2 -0
- package/dist/templates/city-courier/package.json +25 -0
- package/dist/templates/city-courier/project.json +8 -0
- package/dist/templates/city-courier/scene.json +3395 -0
- package/dist/templates/city-courier/scripts/game.ts +127 -0
- package/dist/templates/city-courier/scripts/molen-scripts.d.ts +1125 -0
- package/dist/templates/city-courier/scripts/tsconfig.json +16 -0
- package/dist/templates/city-courier/src/game-shell.css +309 -0
- package/dist/templates/city-courier/src/main.ts +81 -0
- package/dist/templates/city-courier/src/scene.ts +17 -0
- package/dist/templates/city-courier/src/vite-env.d.ts +1 -0
- package/dist/templates/city-courier/src/worker.ts +5 -0
- package/dist/templates/city-courier/test/headless.test.ts +95 -0
- package/dist/templates/city-courier/test/playthrough.test.js +52 -0
- package/dist/templates/city-courier/test/replay.test.ts +22 -0
- package/dist/templates/city-courier/tsconfig.json +17 -0
- package/dist/templates/city-courier/vite.config.ts +19 -0
- package/dist/templates/cubes/README.md +51 -0
- package/dist/templates/cubes/index.html +16 -0
- package/dist/templates/cubes/package.json +24 -0
- package/dist/templates/cubes/scene.json +15 -0
- package/dist/templates/cubes/src/cubes.ts +100 -0
- package/dist/templates/cubes/src/main.ts +21 -0
- package/dist/templates/cubes/src/worker.ts +15 -0
- package/dist/templates/cubes/test/headless.test.ts +98 -0
- package/dist/templates/cubes/tsconfig.json +17 -0
- package/dist/templates/cubes/vite.config.ts +17 -0
- package/dist/templates/data-viz/README.md +47 -0
- package/dist/templates/data-viz/camera-track.json +12 -0
- package/dist/templates/data-viz/data.json +9 -0
- package/dist/templates/data-viz/index.html +16 -0
- package/dist/templates/data-viz/package.json +25 -0
- package/dist/templates/data-viz/scene.json +7 -0
- package/dist/templates/data-viz/src/main.ts +39 -0
- package/dist/templates/data-viz/src/viz.ts +91 -0
- package/dist/templates/data-viz/src/worker.ts +12 -0
- package/dist/templates/data-viz/test/headless.test.ts +75 -0
- package/dist/templates/data-viz/tsconfig.json +17 -0
- package/dist/templates/data-viz/vite.config.ts +16 -0
- package/dist/templates/figures-gallery/README.md +46 -0
- package/dist/templates/figures-gallery/index.html +16 -0
- package/dist/templates/figures-gallery/package.json +25 -0
- package/dist/templates/figures-gallery/scene.json +276 -0
- package/dist/templates/figures-gallery/src/main.ts +44 -0
- package/dist/templates/figures-gallery/src/worker.ts +17 -0
- package/dist/templates/figures-gallery/test/headless.test.ts +90 -0
- package/dist/templates/figures-gallery/tsconfig.json +17 -0
- package/dist/templates/figures-gallery/vite.config.ts +17 -0
- package/dist/templates/index.json +188 -0
- package/dist/templates/skybound/README.md +53 -0
- package/dist/templates/skybound/checks.json +24 -0
- package/dist/templates/skybound/commands.json +32 -0
- package/dist/templates/skybound/first-leap.replay.json +224 -0
- package/dist/templates/skybound/gen/molen-types.ts +878 -0
- package/dist/templates/skybound/index.html +2 -0
- package/dist/templates/skybound/package.json +25 -0
- package/dist/templates/skybound/project.json +8 -0
- package/dist/templates/skybound/scene.json +1737 -0
- package/dist/templates/skybound/scripts/game.ts +119 -0
- package/dist/templates/skybound/scripts/molen-scripts.d.ts +1125 -0
- package/dist/templates/skybound/scripts/tsconfig.json +16 -0
- package/dist/templates/skybound/src/game-shell.css +309 -0
- package/dist/templates/skybound/src/main.ts +60 -0
- package/dist/templates/skybound/src/scene.ts +17 -0
- package/dist/templates/skybound/src/vite-env.d.ts +1 -0
- package/dist/templates/skybound/src/worker.ts +5 -0
- package/dist/templates/skybound/test/headless.test.ts +124 -0
- package/dist/templates/skybound/test/playthrough.test.js +38 -0
- package/dist/templates/skybound/test/replay.test.ts +22 -0
- package/dist/templates/skybound/tsconfig.json +17 -0
- package/dist/templates/skybound/vite.config.ts +19 -0
- package/dist/templates/terrain-flyover/README.md +46 -0
- package/dist/templates/terrain-flyover/index.html +16 -0
- package/dist/templates/terrain-flyover/package.json +26 -0
- package/dist/templates/terrain-flyover/src/flyover.ts +23 -0
- package/dist/templates/terrain-flyover/src/main.ts +93 -0
- package/dist/templates/terrain-flyover/terrain.json +15 -0
- package/dist/templates/terrain-flyover/test/headless.test.ts +72 -0
- package/dist/templates/terrain-flyover/tsconfig.json +17 -0
- package/dist/templates/terrain-flyover/vite.config.ts +15 -0
- package/dist/templates/top-down-arena/README.md +52 -0
- package/dist/templates/top-down-arena/arena-skirmish.replay.json +204 -0
- package/dist/templates/top-down-arena/index.html +16 -0
- package/dist/templates/top-down-arena/package.json +25 -0
- package/dist/templates/top-down-arena/project.json +10 -0
- package/dist/templates/top-down-arena/scene.json +162 -0
- package/dist/templates/top-down-arena/scripts/chase.ts +17 -0
- package/dist/templates/top-down-arena/scripts/combat.ts +12 -0
- package/dist/templates/top-down-arena/scripts/control.ts +8 -0
- package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +1095 -0
- package/dist/templates/top-down-arena/scripts/spawner.ts +11 -0
- package/dist/templates/top-down-arena/scripts/tsconfig.json +16 -0
- package/dist/templates/top-down-arena/src/arena.ts +8 -0
- package/dist/templates/top-down-arena/src/gen/molen-types.ts +882 -0
- package/dist/templates/top-down-arena/src/main.ts +31 -0
- package/dist/templates/top-down-arena/src/scene.ts +24 -0
- package/dist/templates/top-down-arena/src/vite-env.d.ts +1 -0
- package/dist/templates/top-down-arena/src/worker.ts +7 -0
- package/dist/templates/top-down-arena/test/headless.test.ts +87 -0
- package/dist/templates/top-down-arena/test/replay.test.ts +22 -0
- package/dist/templates/top-down-arena/tsconfig.json +17 -0
- package/dist/templates/top-down-arena/types/arena.types.json +54 -0
- package/dist/templates/top-down-arena/vite.config.ts +21 -0
- package/package.json +14 -14
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"checkJs": true,
|
|
5
|
+
"noEmit": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"erasableSyntaxOnly": true,
|
|
8
|
+
"target": "ES2023",
|
|
9
|
+
"module": "preserve",
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"lib": ["ES2023"],
|
|
12
|
+
"types": [],
|
|
13
|
+
"skipLibCheck": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["*.ts", "*.js"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
* {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
4
|
+
html,
|
|
5
|
+
body {
|
|
6
|
+
margin: 0;
|
|
7
|
+
height: 100%;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
}
|
|
10
|
+
body {
|
|
11
|
+
--ink: #ecf1e8;
|
|
12
|
+
--muted: #aab9bf;
|
|
13
|
+
--accent: #f9bc60;
|
|
14
|
+
--panel: rgba(18, 32, 43, 0.91);
|
|
15
|
+
font-family: Inter, "Segoe UI", sans-serif;
|
|
16
|
+
color: var(--ink);
|
|
17
|
+
background: #182733;
|
|
18
|
+
}
|
|
19
|
+
canvas#view {
|
|
20
|
+
display: block;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
outline: none;
|
|
24
|
+
}
|
|
25
|
+
#interface {
|
|
26
|
+
position: fixed;
|
|
27
|
+
inset: 0;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
}
|
|
30
|
+
.topbar {
|
|
31
|
+
position: absolute;
|
|
32
|
+
inset: 0 0 auto;
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: space-between;
|
|
35
|
+
align-items: flex-start;
|
|
36
|
+
padding: 28px 34px;
|
|
37
|
+
background: linear-gradient(#132331d9, transparent);
|
|
38
|
+
gap: 24px;
|
|
39
|
+
}
|
|
40
|
+
.eyebrow {
|
|
41
|
+
font-size: 10px;
|
|
42
|
+
text-transform: uppercase;
|
|
43
|
+
letter-spacing: 3px;
|
|
44
|
+
font-weight: 700;
|
|
45
|
+
color: var(--accent);
|
|
46
|
+
margin-bottom: 9px;
|
|
47
|
+
}
|
|
48
|
+
h1 {
|
|
49
|
+
font-size: 32px;
|
|
50
|
+
line-height: 1;
|
|
51
|
+
letter-spacing: -1.3px;
|
|
52
|
+
margin: 0 0 9px;
|
|
53
|
+
font-weight: 750;
|
|
54
|
+
}
|
|
55
|
+
.subtitle {
|
|
56
|
+
font-size: 12px;
|
|
57
|
+
color: var(--muted);
|
|
58
|
+
}
|
|
59
|
+
.stats {
|
|
60
|
+
display: flex;
|
|
61
|
+
gap: 24px;
|
|
62
|
+
padding: 15px 24px;
|
|
63
|
+
border: 1px solid #ffffff20;
|
|
64
|
+
border-radius: 14px;
|
|
65
|
+
background: var(--panel);
|
|
66
|
+
backdrop-filter: blur(12px);
|
|
67
|
+
}
|
|
68
|
+
.stat {
|
|
69
|
+
min-width: 65px;
|
|
70
|
+
}
|
|
71
|
+
.stat label {
|
|
72
|
+
display: block;
|
|
73
|
+
text-transform: uppercase;
|
|
74
|
+
font-size: 9px;
|
|
75
|
+
letter-spacing: 1.7px;
|
|
76
|
+
color: var(--muted);
|
|
77
|
+
margin-bottom: 4px;
|
|
78
|
+
}
|
|
79
|
+
.stat strong {
|
|
80
|
+
font-size: 23px;
|
|
81
|
+
font-variant-numeric: tabular-nums;
|
|
82
|
+
font-weight: 650;
|
|
83
|
+
}
|
|
84
|
+
.stat small {
|
|
85
|
+
font-size: 11px;
|
|
86
|
+
color: var(--muted);
|
|
87
|
+
margin-left: 4px;
|
|
88
|
+
}
|
|
89
|
+
.bottom {
|
|
90
|
+
position: absolute;
|
|
91
|
+
bottom: 26px;
|
|
92
|
+
left: 34px;
|
|
93
|
+
right: 34px;
|
|
94
|
+
display: flex;
|
|
95
|
+
justify-content: space-between;
|
|
96
|
+
align-items: flex-end;
|
|
97
|
+
gap: 20px;
|
|
98
|
+
}
|
|
99
|
+
.brief {
|
|
100
|
+
max-width: 445px;
|
|
101
|
+
border-left: 3px solid var(--accent);
|
|
102
|
+
padding: 16px 20px;
|
|
103
|
+
background: var(--panel);
|
|
104
|
+
border-radius: 0 12px 12px 0;
|
|
105
|
+
}
|
|
106
|
+
.brief .label {
|
|
107
|
+
font-size: 10px;
|
|
108
|
+
letter-spacing: 2px;
|
|
109
|
+
text-transform: uppercase;
|
|
110
|
+
color: var(--accent);
|
|
111
|
+
}
|
|
112
|
+
#message {
|
|
113
|
+
font-size: 14px;
|
|
114
|
+
line-height: 1.5;
|
|
115
|
+
margin: 8px 0 12px;
|
|
116
|
+
min-height: 21px;
|
|
117
|
+
}
|
|
118
|
+
.controls {
|
|
119
|
+
font-size: 11px;
|
|
120
|
+
color: var(--muted);
|
|
121
|
+
line-height: 2;
|
|
122
|
+
}
|
|
123
|
+
kbd {
|
|
124
|
+
font-family: inherit;
|
|
125
|
+
font-size: 10px;
|
|
126
|
+
background: #ffffff13;
|
|
127
|
+
border: 1px solid #ffffff28;
|
|
128
|
+
border-bottom-width: 2px;
|
|
129
|
+
border-radius: 4px;
|
|
130
|
+
padding: 2px 5px;
|
|
131
|
+
color: var(--ink);
|
|
132
|
+
white-space: nowrap;
|
|
133
|
+
}
|
|
134
|
+
button {
|
|
135
|
+
pointer-events: auto;
|
|
136
|
+
border: 1px solid #ffffff30;
|
|
137
|
+
border-radius: 8px;
|
|
138
|
+
padding: 9px 13px;
|
|
139
|
+
background: #ffffff09;
|
|
140
|
+
color: var(--ink);
|
|
141
|
+
font: inherit;
|
|
142
|
+
font-size: 11px;
|
|
143
|
+
cursor: pointer;
|
|
144
|
+
}
|
|
145
|
+
button:hover {
|
|
146
|
+
background: #ffffff20;
|
|
147
|
+
}
|
|
148
|
+
button:focus-visible {
|
|
149
|
+
outline: 2px solid var(--accent);
|
|
150
|
+
}
|
|
151
|
+
.map {
|
|
152
|
+
width: 152px;
|
|
153
|
+
height: 152px;
|
|
154
|
+
padding: 12px;
|
|
155
|
+
background: var(--panel);
|
|
156
|
+
border: 1px solid #ffffff20;
|
|
157
|
+
border-radius: 14px;
|
|
158
|
+
}
|
|
159
|
+
.map svg {
|
|
160
|
+
width: 100%;
|
|
161
|
+
height: 100%;
|
|
162
|
+
}
|
|
163
|
+
.map-caption {
|
|
164
|
+
position: absolute;
|
|
165
|
+
right: 0;
|
|
166
|
+
bottom: 164px;
|
|
167
|
+
text-transform: uppercase;
|
|
168
|
+
letter-spacing: 2px;
|
|
169
|
+
font-size: 9px;
|
|
170
|
+
color: var(--muted);
|
|
171
|
+
}
|
|
172
|
+
#outcome {
|
|
173
|
+
position: absolute;
|
|
174
|
+
left: 50%;
|
|
175
|
+
top: 40%;
|
|
176
|
+
transform: translate(-50%, -50%);
|
|
177
|
+
background: var(--panel);
|
|
178
|
+
border: 1px solid var(--accent);
|
|
179
|
+
padding: 26px 40px;
|
|
180
|
+
border-radius: 16px;
|
|
181
|
+
text-align: center;
|
|
182
|
+
min-width: 290px;
|
|
183
|
+
box-shadow: 0 20px 80px #0005;
|
|
184
|
+
}
|
|
185
|
+
#outcome[hidden] {
|
|
186
|
+
display: none;
|
|
187
|
+
}
|
|
188
|
+
#outcome h2 {
|
|
189
|
+
font-size: 28px;
|
|
190
|
+
margin: 0 0 10px;
|
|
191
|
+
}
|
|
192
|
+
#outcome p {
|
|
193
|
+
font-size: 13px;
|
|
194
|
+
color: var(--muted);
|
|
195
|
+
}
|
|
196
|
+
.crosshair {
|
|
197
|
+
position: absolute;
|
|
198
|
+
left: 50%;
|
|
199
|
+
top: 50%;
|
|
200
|
+
width: 5px;
|
|
201
|
+
height: 5px;
|
|
202
|
+
border: 1px solid #f5d59b;
|
|
203
|
+
transform: translate(-50%, -50%);
|
|
204
|
+
border-radius: 50%;
|
|
205
|
+
box-shadow: 0 0 15px #ffdaac;
|
|
206
|
+
}
|
|
207
|
+
.sword {
|
|
208
|
+
position: absolute;
|
|
209
|
+
bottom: -90px;
|
|
210
|
+
right: 23%;
|
|
211
|
+
width: 34px;
|
|
212
|
+
height: 320px;
|
|
213
|
+
background: linear-gradient(90deg, #718897 0%, #e5ebdf 45%, #8a9eac 50%, #456276 100%);
|
|
214
|
+
clip-path: polygon(50% 0, 100% 15%, 100% 73%, 85% 76%, 85% 100%, 15% 100%, 15% 76%, 0 73%, 0 15%);
|
|
215
|
+
transform: rotate(22deg);
|
|
216
|
+
transform-origin: bottom;
|
|
217
|
+
transition: transform 0.11s;
|
|
218
|
+
filter: drop-shadow(0 0 12px #000);
|
|
219
|
+
}
|
|
220
|
+
.sword.swing {
|
|
221
|
+
transform: rotate(-40deg) translate(-120px, -35px);
|
|
222
|
+
}
|
|
223
|
+
body[data-game="lantern-dungeon"] {
|
|
224
|
+
--accent: #e8bb75;
|
|
225
|
+
--panel: rgba(15, 23, 34, 0.93);
|
|
226
|
+
}
|
|
227
|
+
body[data-game="lantern-dungeon"] h1 {
|
|
228
|
+
font-family: Georgia, serif;
|
|
229
|
+
font-weight: 400;
|
|
230
|
+
letter-spacing: 0.3px;
|
|
231
|
+
}
|
|
232
|
+
body[data-game="skybound"] {
|
|
233
|
+
--accent: #ffd68e;
|
|
234
|
+
--panel: rgba(28, 70, 77, 0.92);
|
|
235
|
+
}
|
|
236
|
+
body[data-game="skybound"] h1 {
|
|
237
|
+
font-size: 39px;
|
|
238
|
+
font-weight: 850;
|
|
239
|
+
letter-spacing: -2px;
|
|
240
|
+
}
|
|
241
|
+
.progress {
|
|
242
|
+
width: 150px;
|
|
243
|
+
height: 7px;
|
|
244
|
+
background: #ffffff25;
|
|
245
|
+
border-radius: 6px;
|
|
246
|
+
margin: 8px 0;
|
|
247
|
+
}
|
|
248
|
+
.progress span {
|
|
249
|
+
display: block;
|
|
250
|
+
height: 100%;
|
|
251
|
+
background: var(--accent);
|
|
252
|
+
border-radius: 6px;
|
|
253
|
+
width: 0;
|
|
254
|
+
}
|
|
255
|
+
#diagnostic {
|
|
256
|
+
position: absolute;
|
|
257
|
+
top: 105px;
|
|
258
|
+
left: 34px;
|
|
259
|
+
color: #ffb7a5;
|
|
260
|
+
font-size: 12px;
|
|
261
|
+
max-width: 600px;
|
|
262
|
+
white-space: pre-wrap;
|
|
263
|
+
}
|
|
264
|
+
@media (max-width: 720px) {
|
|
265
|
+
.topbar {
|
|
266
|
+
padding: 18px;
|
|
267
|
+
}
|
|
268
|
+
.stats {
|
|
269
|
+
gap: 12px;
|
|
270
|
+
padding: 12px;
|
|
271
|
+
}
|
|
272
|
+
.stat {
|
|
273
|
+
min-width: 38px;
|
|
274
|
+
}
|
|
275
|
+
.stat strong {
|
|
276
|
+
font-size: 19px;
|
|
277
|
+
}
|
|
278
|
+
h1 {
|
|
279
|
+
font-size: 25px;
|
|
280
|
+
}
|
|
281
|
+
.subtitle {
|
|
282
|
+
display: none;
|
|
283
|
+
}
|
|
284
|
+
.bottom {
|
|
285
|
+
left: 18px;
|
|
286
|
+
right: 18px;
|
|
287
|
+
bottom: 18px;
|
|
288
|
+
}
|
|
289
|
+
.brief {
|
|
290
|
+
padding: 12px;
|
|
291
|
+
max-width: 70vw;
|
|
292
|
+
}
|
|
293
|
+
.map {
|
|
294
|
+
width: 105px;
|
|
295
|
+
height: 105px;
|
|
296
|
+
}
|
|
297
|
+
.map-caption {
|
|
298
|
+
bottom: 116px;
|
|
299
|
+
}
|
|
300
|
+
.controls {
|
|
301
|
+
font-size: 10px;
|
|
302
|
+
}
|
|
303
|
+
.sword {
|
|
304
|
+
right: 13%;
|
|
305
|
+
}
|
|
306
|
+
body[data-game="skybound"] h1 {
|
|
307
|
+
font-size: 29px;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { mountExperience } from '@bendyline/molen-client';
|
|
2
|
+
import { scene } from './scene';
|
|
3
|
+
import './game-shell.css';
|
|
4
|
+
|
|
5
|
+
// Presentation only: all rules and durable state live in scene.json + scripts/game.js.
|
|
6
|
+
document.body.dataset.game = 'skybound';
|
|
7
|
+
element('interface').innerHTML =
|
|
8
|
+
`<header class="topbar"><div><div class="eyebrow">MOLEN / 03 / PLATFORM ADVENTURE</div><h1>Skybound</h1><div class="subtitle">A LITTLE LEAP GOES A LONG WAY</div></div><div class="stats"><div class="stat"><label>SEEDS</label><strong id="stat0">0 / 15</strong></div><div class="stat"><label>LIVES</label><strong id="stat1">3</strong></div><div class="stat"><label>CHECKPOINT</label><strong id="stat2">START</strong></div></div></header><div class="bottom"><div class="brief"><div class="label">Five islands. One lighthouse.</div><p id="message">Loading the experience...</p><div class="controls"><kbd>A D / ← →</kbd> run <kbd>Space</kbd> jump (hold for height)<br/>Stomp the purple creatures. Avoid pink thorns. <kbd>R</kbd> restart</div></div><div class="brief"><div class="label">TO THE LIGHTHOUSE</div><div class="progress"><span id="progress"></span></div><div class="controls">Eastbound · 75 meters</div></div></div><div id="outcome" hidden><h2 id="outcome-title"></h2><p id="outcome-detail"></p><button id="restart" type="button">Play again →</button></div><div id="diagnostic" role="alert"></div>`;
|
|
9
|
+
const canvas = document.getElementById('view') as HTMLCanvasElement;
|
|
10
|
+
const worker = new Worker(new URL('./worker.ts', import.meta.url), { type: 'module' });
|
|
11
|
+
const mounted = await mountExperience({ link: worker, scene: scene(), canvas, antialias: true });
|
|
12
|
+
const { client } = mounted;
|
|
13
|
+
function element(id: string): HTMLElement {
|
|
14
|
+
const node = document.getElementById(id);
|
|
15
|
+
if (node === null) throw new Error(`Missing UI element: ${id}`);
|
|
16
|
+
return node;
|
|
17
|
+
}
|
|
18
|
+
const diagnostic = (message: string): void => {
|
|
19
|
+
element('diagnostic').textContent = message;
|
|
20
|
+
};
|
|
21
|
+
worker.addEventListener('error', (event) => diagnostic(event.message));
|
|
22
|
+
client.onDiag((d) => {
|
|
23
|
+
if (d.code !== 'tick-overrun') diagnostic(`${d.code}: ${JSON.stringify(d.detail)}`);
|
|
24
|
+
});
|
|
25
|
+
client.onEvent('script-error', (e) => diagnostic(JSON.stringify(e.payload)));
|
|
26
|
+
element('restart').addEventListener('click', () => {
|
|
27
|
+
client.command('restart');
|
|
28
|
+
canvas.focus();
|
|
29
|
+
});
|
|
30
|
+
const timer = setInterval(() => {
|
|
31
|
+
const g = client.get('game', 'skyGame');
|
|
32
|
+
if (!g) return;
|
|
33
|
+
const p = client.get('player', 'transform');
|
|
34
|
+
const pos = p?.pos as number[] | undefined;
|
|
35
|
+
element('message').textContent = String(g.message);
|
|
36
|
+
const outcome = element('outcome');
|
|
37
|
+
outcome.hidden = g.status === 'playing';
|
|
38
|
+
element('outcome-title').textContent = g.status === 'won' ? 'You made it!' : 'Try again';
|
|
39
|
+
element('outcome-detail').textContent =
|
|
40
|
+
g.status === 'won'
|
|
41
|
+
? 'A complete adventure, powered by Molen.'
|
|
42
|
+
: 'A fresh start is one key away.';
|
|
43
|
+
// Read-only browser telemetry: useful to both automation and human inspectors.
|
|
44
|
+
canvas.dataset.tick = String(client.tick);
|
|
45
|
+
canvas.dataset.status = String(g.status);
|
|
46
|
+
canvas.dataset.x = String(pos?.[0] ?? 0);
|
|
47
|
+
canvas.dataset.y = String(pos?.[1] ?? 0);
|
|
48
|
+
canvas.dataset.z = String(pos?.[2] ?? 0);
|
|
49
|
+
element('stat0').textContent = `${g.coins} / ${g.total}`;
|
|
50
|
+
element('stat1').textContent = String(g.lives);
|
|
51
|
+
element('stat2').textContent = g.checkpoint ? 'SAVED' : 'START';
|
|
52
|
+
element('progress').style.width = `${Math.max(0, Math.min(100, ((pos?.[0] ?? 0) / 75) * 100))}%`;
|
|
53
|
+
}, 80);
|
|
54
|
+
function dispose(): void {
|
|
55
|
+
clearInterval(timer);
|
|
56
|
+
mounted.dispose();
|
|
57
|
+
worker.terminate();
|
|
58
|
+
}
|
|
59
|
+
window.addEventListener('pagehide', dispose, { once: true });
|
|
60
|
+
if (import.meta.hot) import.meta.hot.dispose(dispose);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { loadProject } from '@bendyline/molen-kernel';
|
|
2
|
+
import type { SceneManifest } from '@bendyline/molen-schema';
|
|
3
|
+
import document from '../scene.json';
|
|
4
|
+
|
|
5
|
+
// loadProject validates the document and inlines each script's source, matching the sources a
|
|
6
|
+
// bundler hands over to the `path` the scene declares — the browser and the tests end up with
|
|
7
|
+
// the identical manifest the CLI builds by reading those files from disk.
|
|
8
|
+
const scripts = import.meta.glob('../scripts/*.ts', {
|
|
9
|
+
query: '?raw',
|
|
10
|
+
import: 'default',
|
|
11
|
+
eager: true,
|
|
12
|
+
}) as Record<string, string>;
|
|
13
|
+
|
|
14
|
+
/** Browser and tests load the same scene + scripts that the CLI reads from disk. */
|
|
15
|
+
export function scene(): SceneManifest {
|
|
16
|
+
return loadProject({ scene: document, scripts }).scene;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyKeyframeTo,
|
|
3
|
+
buildWorld,
|
|
4
|
+
componentHandle,
|
|
5
|
+
stateHash,
|
|
6
|
+
Transform,
|
|
7
|
+
takeKeyframe,
|
|
8
|
+
type World,
|
|
9
|
+
} from '@bendyline/molen-kernel';
|
|
10
|
+
import type { JsonObject } from '@bendyline/molen-schema';
|
|
11
|
+
import { describe, expect, it } from 'vitest';
|
|
12
|
+
import { scene } from '../src/scene';
|
|
13
|
+
|
|
14
|
+
const build = (): World => buildWorld(scene());
|
|
15
|
+
function command(w: World, type: string, payload: JsonObject = {}): void {
|
|
16
|
+
const result = w.submitCommand({
|
|
17
|
+
kind: 'command',
|
|
18
|
+
source: type,
|
|
19
|
+
seq: w.tick * 10 + w.commandTypes().indexOf(type),
|
|
20
|
+
tick: w.tick,
|
|
21
|
+
type,
|
|
22
|
+
payload,
|
|
23
|
+
});
|
|
24
|
+
expect(result.accepted, result.reason).toBe(true);
|
|
25
|
+
}
|
|
26
|
+
function data(w: World, id: string, name: string): JsonObject {
|
|
27
|
+
const value = w.get(id, componentHandle(name));
|
|
28
|
+
if (value === undefined) throw new Error(`Missing ${id}.${name}`);
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('skybound: authored scene + scripts', () => {
|
|
33
|
+
// A pinned hash, not just run-to-run equality: two runs of the same build always agree, so
|
|
34
|
+
// that check cannot see a refactor that moved the whole simulation. This literal can only be
|
|
35
|
+
// updated on purpose, which is the point — it is the skybound run's behaviour, frozen.
|
|
36
|
+
it('matches the pinned state hash across engine versions', () => {
|
|
37
|
+
const w = build();
|
|
38
|
+
command(w, 'move', { dir: [1, 0] });
|
|
39
|
+
w.stepN(90);
|
|
40
|
+
expect(stateHash(w)).toBe(
|
|
41
|
+
'sha256:e0632b2ae9a5ba9d279e6706949f7adfa5295a5e54c63845f9cb00e7e94e2653',
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('runs the same world twice and continues from a checkpoint', () => {
|
|
46
|
+
const a = build();
|
|
47
|
+
const b = build();
|
|
48
|
+
command(a, 'move', { dir: [0, -1] });
|
|
49
|
+
command(b, 'move', { dir: [0, -1] });
|
|
50
|
+
a.stepN(20);
|
|
51
|
+
b.stepN(20);
|
|
52
|
+
expect(stateHash(a)).toBe(stateHash(b));
|
|
53
|
+
const c = build();
|
|
54
|
+
applyKeyframeTo(c, takeKeyframe(a));
|
|
55
|
+
a.stepN(30);
|
|
56
|
+
c.stepN(30);
|
|
57
|
+
expect(stateHash(a)).toBe(stateHash(c));
|
|
58
|
+
});
|
|
59
|
+
it('rejects malformed input and restarts through the declared command', () => {
|
|
60
|
+
const w = build();
|
|
61
|
+
expect(
|
|
62
|
+
w.submitCommand({
|
|
63
|
+
kind: 'command',
|
|
64
|
+
source: 'bad',
|
|
65
|
+
seq: 0,
|
|
66
|
+
tick: 0,
|
|
67
|
+
type: 'move',
|
|
68
|
+
payload: { dir: [20, 0] },
|
|
69
|
+
}).accepted,
|
|
70
|
+
).toBe(false);
|
|
71
|
+
w.stepN(30);
|
|
72
|
+
command(w, 'restart');
|
|
73
|
+
w.stepN(2);
|
|
74
|
+
expect(data(w, 'game', 'skyGame').status).toBe('playing');
|
|
75
|
+
});
|
|
76
|
+
it('jumps, collects seeds, falls, and respawns with one fewer life', () => {
|
|
77
|
+
const w = build();
|
|
78
|
+
w.step();
|
|
79
|
+
command(w, 'move', { dir: [1, 0] });
|
|
80
|
+
w.stepN(18);
|
|
81
|
+
expect(data(w, 'game', 'skyGame').coins).toBeGreaterThan(0);
|
|
82
|
+
command(w, 'jump', { held: true });
|
|
83
|
+
w.stepN(8);
|
|
84
|
+
expect(w.get('player', Transform)?.pos[1]).toBeGreaterThan(2);
|
|
85
|
+
w.patch('player', Transform, { pos: [9, -7, 0] });
|
|
86
|
+
w.step();
|
|
87
|
+
expect(data(w, 'game', 'skyGame').lives).toBe(2);
|
|
88
|
+
expect(w.get('player', Transform)?.pos[0]).toBe(0);
|
|
89
|
+
});
|
|
90
|
+
it('saves a checkpoint and restarts all collectibles and lives', () => {
|
|
91
|
+
const w = build();
|
|
92
|
+
w.patch('player', Transform, { pos: [38, 1.25, 0] });
|
|
93
|
+
w.step();
|
|
94
|
+
expect(data(w, 'game', 'skyGame').checkpoint).toBe(1);
|
|
95
|
+
w.patch('player', Transform, { pos: [42, -7, 0] });
|
|
96
|
+
w.step();
|
|
97
|
+
expect(w.get('player', Transform)?.pos[0]).toBe(38);
|
|
98
|
+
command(w, 'restart');
|
|
99
|
+
w.stepN(2);
|
|
100
|
+
expect(data(w, 'game', 'skyGame').lives).toBe(3);
|
|
101
|
+
expect(data(w, 'game', 'skyGame').checkpoint).toBe(0);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('keeps a fast jump tap when press and release arrive in the same simulation tick', () => {
|
|
106
|
+
const w = build();
|
|
107
|
+
w.step();
|
|
108
|
+
for (const [seq, held] of [
|
|
109
|
+
[0, true],
|
|
110
|
+
[1, false],
|
|
111
|
+
] as const) {
|
|
112
|
+
const result = w.submitCommand({
|
|
113
|
+
kind: 'command',
|
|
114
|
+
source: 'tap',
|
|
115
|
+
seq,
|
|
116
|
+
tick: w.tick + 1,
|
|
117
|
+
type: 'jump',
|
|
118
|
+
payload: { held },
|
|
119
|
+
});
|
|
120
|
+
expect(result.accepted).toBe(true);
|
|
121
|
+
}
|
|
122
|
+
w.stepN(4);
|
|
123
|
+
expect(w.get('player', Transform)?.pos[1]).toBeGreaterThan(1.6);
|
|
124
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { buildWorld, componentHandle, Transform } from '@bendyline/molen-kernel';
|
|
2
|
+
import { expect, it } from 'vitest';
|
|
3
|
+
import { scene } from '../src/scene';
|
|
4
|
+
|
|
5
|
+
const get = (w, id, c) => w.get(id, componentHandle(c));
|
|
6
|
+
const p = (w) => w.get('player', Transform).pos;
|
|
7
|
+
it('completes skybound using only player commands, then restarts', () => {
|
|
8
|
+
let seq = 0;
|
|
9
|
+
function send(w, type, payload = {}) {
|
|
10
|
+
const result = w.submitCommand({
|
|
11
|
+
kind: 'command',
|
|
12
|
+
source: 'proof',
|
|
13
|
+
seq: seq++,
|
|
14
|
+
tick: w.tick,
|
|
15
|
+
type,
|
|
16
|
+
payload,
|
|
17
|
+
});
|
|
18
|
+
expect(result.accepted, result.reason).toBe(true);
|
|
19
|
+
}
|
|
20
|
+
const w = buildWorld(scene());
|
|
21
|
+
let i = 0;
|
|
22
|
+
const jumps = [6, 16, 21.5, 27, 38.5, 44.5, 55.5, 65, 72];
|
|
23
|
+
for (let n = 0; n < 1600 && get(w, 'game', 'skyGame').status === 'playing'; n++) {
|
|
24
|
+
const [x] = p(w);
|
|
25
|
+
const b = get(w, 'player', 'platformBody');
|
|
26
|
+
send(w, 'move', { dir: [1, 0] });
|
|
27
|
+
if (x >= jumps[i] && b.grounded) {
|
|
28
|
+
send(w, 'jump', { held: true });
|
|
29
|
+
i++;
|
|
30
|
+
}
|
|
31
|
+
w.step();
|
|
32
|
+
}
|
|
33
|
+
expect(get(w, 'game', 'skyGame').status).toBe('won');
|
|
34
|
+
send(w, 'restart');
|
|
35
|
+
w.stepN(2);
|
|
36
|
+
expect(get(w, 'game', 'skyGame').status).toBe('playing');
|
|
37
|
+
expect(get(w, 'game', 'skyGame').coins).toBe(0);
|
|
38
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { runReplayFile } from '@bendyline/molen-tooling';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
|
|
6
|
+
// A committed replay fixture is the long-lived half of the determinism guarantee. The pinned hash
|
|
7
|
+
// in headless.test.ts freezes one run of the current build; this freezes a *recorded command log*
|
|
8
|
+
// plus per-tick reference hashes, so when behaviour drifts the harness reports the first tick that
|
|
9
|
+
// diverged instead of "the hash moved". It also distinguishes a non-deterministic build from an
|
|
10
|
+
// intentional behaviour change — refresh with `molen replay <fixture> --record`.
|
|
11
|
+
|
|
12
|
+
describe('skybound: recorded replay', () => {
|
|
13
|
+
it('reproduces the recorded run tick for tick', async () => {
|
|
14
|
+
const result = await runReplayFile({
|
|
15
|
+
path: join(process.cwd(), 'first-leap.replay.json'),
|
|
16
|
+
});
|
|
17
|
+
expect(result.error).toBeUndefined();
|
|
18
|
+
expect(result.ok, result.report).toBe(true);
|
|
19
|
+
expect(result.actualHash).toBe(result.expectedHash);
|
|
20
|
+
expect(result.firstDivergentTick).toBeUndefined();
|
|
21
|
+
}, 60_000);
|
|
22
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
7
|
+
"types": [],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noUncheckedIndexedAccess": true,
|
|
10
|
+
"verbatimModuleSyntax": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"resolveJsonModule": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src", "test"]
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { molenScripts } from '@bendyline/molen-client/vite';
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
// Scene scripts are authored in TypeScript; strip types when they are read as text.
|
|
6
|
+
plugins: [molenScripts()],
|
|
7
|
+
base: './',
|
|
8
|
+
// Vite gives worker bundles their own plugin pipeline, and the kernel runs in the Worker —
|
|
9
|
+
// without this the Worker would receive unstripped TypeScript.
|
|
10
|
+
worker: { format: 'es', plugins: () => [molenScripts()] },
|
|
11
|
+
build: {
|
|
12
|
+
target: 'es2022',
|
|
13
|
+
// main.ts mounts with a top-level `await`, and the client lazy-loads its WebGPU driver. By
|
|
14
|
+
// default Rollup puts three.js and the client in the entry chunk, so the lazy chunk imports
|
|
15
|
+
// the entry while the entry is still suspended at that `await`: the import never settles and
|
|
16
|
+
// the page stays blank in every browser with a WebGPU adapter. Their own chunk breaks the cycle.
|
|
17
|
+
rollupOptions: { output: { manualChunks: { vendor: ['three', '@bendyline/molen-client'] } } },
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Terrain flyover
|
|
2
|
+
|
|
3
|
+
A `molen/terrain@2` descriptor plus one deterministically generated 16-bit heightmap become a 4x4 grid of chunked, level-of-detail meshes you can fly over. This is the reference for the terrain capability in isolation: `@bendyline/molen-terrain/kernel` samples heights, `/client` meshes them, and the two agree — which is what keeps collision honest.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Run
|
|
8
|
+
|
|
9
|
+
Play it in the browser at [molen.dev/play/terrain-flyover](https://molen.dev/play/terrain-flyover/). To run and change
|
|
10
|
+
your own copy, make one from the npm packages (no clone of the engine repository needed):
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npx @bendyline/molen-tooling new my-terrain-flyover --template terrain-flyover
|
|
14
|
+
cd my-terrain-flyover
|
|
15
|
+
npm install
|
|
16
|
+
npm run dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
WASD: fly. Drag: look. Shift: boost. There is no scene manifest and no `input` block in this sample — the camera is a plain browser loop in `src/main.ts`, clamped to four metres above `hf.sampleHeight(x, z)` so you cannot fly through the island.
|
|
20
|
+
|
|
21
|
+
## Authoring map
|
|
22
|
+
|
|
23
|
+
- `terrain.json`: the descriptor — the whole terrain in fifteen lines of data. `chunkSize` 128 across a `gridSize` of [4, 4] gives a 512 m island at `tileResolution` 129, heights 0-120 m, three layers (`grass`, `rock` applied automatically above slope 0.45, `snow` above 85 m) and four LOD levels with skirts.
|
|
24
|
+
- `src/flyover.ts`: the config shared by the browser app and the golden test. It **validates** the descriptor instead of casting it, so schema defaults — `origin`, collision, layer and LOD fields — are applied; `buildChunkGeometry` reads `descriptor.origin`, which a bare cast leaves undefined. It also pins `HEIGHTMAP_SEED` 42 / `HEIGHTMAP_SIZE` 256 and the `FLYOVER_CAMERA` pose.
|
|
25
|
+
- `src/main.ts`: `generateHeightmapPng` to `heightfieldFromPng` to `createTerrainObject`, added to the world root of a kernel-less `createViewer`. No Worker, no ECS, no entities: here terrain is purely a client capability.
|
|
26
|
+
|
|
27
|
+
No heightmap image is checked in. It is generated from the fixed seed, so the demo and the tests build byte-identical terrain with no asset step.
|
|
28
|
+
|
|
29
|
+
## Verify
|
|
30
|
+
|
|
31
|
+
From this directory:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npx molen validate terrain.json
|
|
35
|
+
npm test
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`test/headless.test.ts` proves the seed is deterministic (identical heightmap twice), walks a 9x9 grid of `raycastDown` samples that must all sit inside the declared height range with the island centre above its edge, and meshes all sixteen chunks through `buildChunkGeometry` to more than 10,000 triangles.
|
|
39
|
+
|
|
40
|
+
In the engine repository, `test/golden/flyover.golden.test.ts` renders the island with `screenshotScene` and a `terrain: { descriptor, heightmapPng }` input — zero entities, 512x288, `FLYOVER_CAMERA`, more than 50,000 triangles after distance LOD — and compares it against the committed `test/golden/__goldens__/flyover.png`.
|
|
41
|
+
|
|
42
|
+
There is no pinned state hash and no replay fixture: nothing in this sample is simulated. `molen shot` can render it too, but it needs both a scene to hang the terrain on and a heightmap already on disk (`--terrain terrain.json --heightmap <png>`), which is why the golden test generates the PNG in process instead.
|
|
43
|
+
|
|
44
|
+
In the engine repository this sample lives in `examples/terrain-flyover/`. The same commands run from
|
|
45
|
+
that directory, and `pnpm --filter @bendyline/molen-examples-terrain-flyover test:unit` (or `test:golden`) runs its tests from the
|
|
46
|
+
root.
|