@bendyline/molen-tooling 0.0.8 → 0.0.10

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.
Files changed (88) hide show
  1. package/dist/capture/harness.js +276 -228
  2. package/dist/capture/worldgen-preview.js +215 -215
  3. package/dist/cli.mjs +6 -5
  4. package/dist/docs-src/guide/3d-art-guidelines.md +15 -11
  5. package/dist/docs-src/guide/adaptive-performance.md +18 -2
  6. package/dist/docs-src/guide/aircraft.md +113 -40
  7. package/dist/docs-src/guide/ambient-life.md +100 -11
  8. package/dist/docs-src/guide/audio.md +1 -1
  9. package/dist/docs-src/guide/boats.md +99 -0
  10. package/dist/docs-src/guide/determinism.md +1 -1
  11. package/dist/docs-src/guide/dioramas.md +167 -0
  12. package/dist/docs-src/guide/earth-view.md +265 -10
  13. package/dist/docs-src/guide/entities.md +32 -1
  14. package/dist/docs-src/guide/figures.md +7 -1
  15. package/dist/docs-src/guide/graphics-performance.md +16 -3
  16. package/dist/docs-src/guide/medium-fi.md +337 -0
  17. package/dist/docs-src/guide/project.md +8 -0
  18. package/dist/docs-src/guide/sky.md +4 -1
  19. package/dist/docs-src/guide/surface-rendering.md +4 -1
  20. package/dist/docs-src/guide/vehicle-interiors.md +40 -2
  21. package/dist/docs-src/guide/vehicles.md +121 -19
  22. package/dist/docs-src/guide/weather.md +45 -3
  23. package/dist/docs-src/guide/worldgen.md +22 -1
  24. package/dist/docs-src/llms.txt +7 -4
  25. package/dist/docs-src/schemas/archstyle.md +114 -0
  26. package/dist/docs-src/schemas/components.md +1592 -139
  27. package/dist/docs-src/schemas/scatter.md +9 -0
  28. package/dist/docs-src/schemas/scene.md +6 -3
  29. package/dist/docs-src/schemas/transport-network.md +4 -2
  30. package/dist/index.mjs +1 -1
  31. package/dist/{mcp-BbHk4ibu.mjs → mcp-BbxqqnD1.mjs} +3 -2
  32. package/dist/{ops-CErtZh2t.mjs → ops-b4Pag8U-.mjs} +7 -5
  33. package/dist/templates/city-courier/README.md +18 -0
  34. package/dist/templates/city-courier/gen/molen-types.ts +218 -16
  35. package/dist/templates/city-courier/index.html +1 -1
  36. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +220 -18
  37. package/dist/templates/city-courier/src/audio.ts +26 -4
  38. package/dist/templates/city-courier/src/game-shell.css +7 -3
  39. package/dist/templates/city-courier/src/main.ts +25 -3
  40. package/dist/templates/city-courier/src/shared/accessibility.css +325 -0
  41. package/dist/templates/city-courier/src/shared/game-controls.ts +406 -0
  42. package/dist/templates/city-courier/src/shared/game-descriptions.ts +143 -0
  43. package/dist/templates/city-courier/src/shared/playback.ts +146 -0
  44. package/dist/templates/city-courier/src/worker.ts +5 -1
  45. package/dist/templates/cubes/index.html +6 -1
  46. package/dist/templates/cubes/src/main.ts +25 -2
  47. package/dist/templates/cubes/src/shared/accessibility.css +325 -0
  48. package/dist/templates/cubes/src/shared/playback.ts +146 -0
  49. package/dist/templates/cubes/src/vite-env.d.ts +1 -0
  50. package/dist/templates/cubes/src/worker.ts +1 -0
  51. package/dist/templates/data-viz/README.md +4 -0
  52. package/dist/templates/data-viz/index.html +6 -1
  53. package/dist/templates/data-viz/src/main.ts +53 -11
  54. package/dist/templates/data-viz/src/shared/accessibility.css +325 -0
  55. package/dist/templates/data-viz/src/shared/playback.ts +146 -0
  56. package/dist/templates/data-viz/src/vite-env.d.ts +1 -0
  57. package/dist/templates/data-viz/src/worker.ts +1 -0
  58. package/dist/templates/figures-gallery/index.html +6 -1
  59. package/dist/templates/figures-gallery/src/main.ts +21 -2
  60. package/dist/templates/figures-gallery/src/shared/accessibility.css +325 -0
  61. package/dist/templates/figures-gallery/src/shared/playback.ts +146 -0
  62. package/dist/templates/figures-gallery/src/vite-env.d.ts +1 -0
  63. package/dist/templates/figures-gallery/src/worker.ts +1 -0
  64. package/dist/templates/index.json +36 -16
  65. package/dist/templates/skybound/README.md +18 -0
  66. package/dist/templates/skybound/gen/molen-types.ts +218 -16
  67. package/dist/templates/skybound/index.html +1 -1
  68. package/dist/templates/skybound/scripts/molen-scripts.d.ts +220 -18
  69. package/dist/templates/skybound/src/audio.ts +26 -4
  70. package/dist/templates/skybound/src/game-shell.css +7 -3
  71. package/dist/templates/skybound/src/main.ts +25 -3
  72. package/dist/templates/skybound/src/shared/accessibility.css +325 -0
  73. package/dist/templates/skybound/src/shared/game-controls.ts +406 -0
  74. package/dist/templates/skybound/src/shared/game-descriptions.ts +143 -0
  75. package/dist/templates/skybound/src/shared/playback.ts +146 -0
  76. package/dist/templates/skybound/src/worker.ts +1 -1
  77. package/dist/templates/terrain-flyover/README.md +5 -1
  78. package/dist/templates/terrain-flyover/index.html +4 -1
  79. package/dist/templates/terrain-flyover/src/main.ts +40 -39
  80. package/dist/templates/top-down-arena/index.html +6 -1
  81. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +220 -18
  82. package/dist/templates/top-down-arena/src/audio.ts +26 -4
  83. package/dist/templates/top-down-arena/src/gen/molen-types.ts +218 -16
  84. package/dist/templates/top-down-arena/src/main.ts +31 -5
  85. package/dist/templates/top-down-arena/src/shared/accessibility.css +325 -0
  86. package/dist/templates/top-down-arena/src/shared/playback.ts +146 -0
  87. package/dist/templates/top-down-arena/src/worker.ts +1 -1
  88. package/package.json +12 -12
@@ -0,0 +1,325 @@
1
+ .access-toolbar,
2
+ .demo-playback {
3
+ position: fixed;
4
+ z-index: 6;
5
+ top: calc(var(--game-header-height, 124px) + 8px);
6
+ left: 16px;
7
+ right: 16px;
8
+ display: flex;
9
+ flex-wrap: wrap;
10
+ gap: 8px;
11
+ align-items: center;
12
+ pointer-events: none;
13
+ }
14
+ .demo-playback {
15
+ top: 12px;
16
+ }
17
+ .access-toolbar button,
18
+ .demo-playback button,
19
+ .touch-controls button,
20
+ .text-play-panel button {
21
+ pointer-events: auto;
22
+ min-height: 44px;
23
+ padding: 9px 14px;
24
+ border: 1px solid #b7c9cc;
25
+ border-radius: 8px;
26
+ color: #f5f7fa;
27
+ background: #19343e;
28
+ font: 14px / 1.4 system-ui;
29
+ cursor: pointer;
30
+ }
31
+ .access-toolbar button:focus-visible,
32
+ .demo-playback button:focus-visible,
33
+ .touch-controls button:focus-visible,
34
+ .text-play-panel button:focus-visible {
35
+ outline: 3px solid #ffd68e;
36
+ outline-offset: 2px;
37
+ }
38
+ .touch-controls button[data-held] {
39
+ background: #466979;
40
+ }
41
+ .access-toolbar button:disabled,
42
+ .touch-controls:disabled {
43
+ opacity: 0.65;
44
+ }
45
+ .touch-controls {
46
+ position: fixed;
47
+ z-index: 5;
48
+ bottom: 12px;
49
+ left: 12px;
50
+ right: 12px;
51
+ margin: 0;
52
+ display: flex;
53
+ flex-wrap: wrap;
54
+ justify-content: center;
55
+ gap: 8px;
56
+ padding: 8px;
57
+ border: 0;
58
+ border-radius: 10px;
59
+ background: #122b36ed;
60
+ color: white;
61
+ font: 12px / 1.5 system-ui;
62
+ max-width: 650px;
63
+ margin-inline: auto;
64
+ }
65
+ .touch-controls button {
66
+ touch-action: none;
67
+ user-select: none;
68
+ min-width: 60px;
69
+ }
70
+ .touch-controls legend {
71
+ background: #122b36;
72
+ padding: 3px 8px;
73
+ border-radius: 6px;
74
+ }
75
+ .touch-controls[hidden],
76
+ .text-play-panel[hidden] {
77
+ display: none;
78
+ }
79
+ body:has(.touch-controls:not([hidden])) .bottom {
80
+ bottom: 150px;
81
+ }
82
+ body:has(.touch-controls:not([hidden])) .sound-toggle {
83
+ bottom: 154px;
84
+ }
85
+ .access-sr-only {
86
+ position: absolute;
87
+ width: 1px;
88
+ height: 1px;
89
+ overflow: hidden;
90
+ clip-path: inset(50%);
91
+ white-space: nowrap;
92
+ }
93
+ body.text-play {
94
+ overflow: auto;
95
+ height: auto;
96
+ background: #102530;
97
+ }
98
+ .text-play canvas#view {
99
+ position: fixed;
100
+ visibility: hidden;
101
+ }
102
+ .text-play #interface,
103
+ .text-play .touch-controls {
104
+ display: none;
105
+ }
106
+ .text-play .access-toolbar {
107
+ position: sticky;
108
+ top: 0;
109
+ left: auto;
110
+ padding: 12px;
111
+ background: #102530;
112
+ }
113
+ .text-play-panel {
114
+ max-width: 900px;
115
+ margin: auto;
116
+ padding: 16px 24px 40px;
117
+ color: #f5f7fa;
118
+ background: #102530;
119
+ font: 16px / 1.65 system-ui;
120
+ }
121
+ .text-play-panel h1 {
122
+ font-size: 28px;
123
+ }
124
+ .text-play-panel li {
125
+ margin-bottom: 10px;
126
+ }
127
+ .text-actions {
128
+ display: flex;
129
+ flex-wrap: wrap;
130
+ gap: 10px;
131
+ }
132
+ .text-actions button[aria-disabled] {
133
+ opacity: 0.65;
134
+ }
135
+ @media (max-width: 720px) {
136
+ .access-toolbar {
137
+ left: 10px;
138
+ right: 10px;
139
+ gap: 6px;
140
+ }
141
+ .access-toolbar button {
142
+ padding-inline: 10px;
143
+ font-size: 12px;
144
+ }
145
+ body:has(.touch-controls:not([hidden])) .bottom {
146
+ bottom: 230px;
147
+ }
148
+ body:has(.touch-controls:not([hidden])) .bottom > :not(:first-child) {
149
+ display: none;
150
+ }
151
+ body:has(.touch-controls:not([hidden])) .brief {
152
+ max-width: none;
153
+ padding: 8px 12px;
154
+ }
155
+ body:has(.touch-controls:not([hidden])) .brief .controls {
156
+ display: none;
157
+ }
158
+ body:has(.touch-controls:not([hidden])) .sound-toggle {
159
+ bottom: 200px;
160
+ right: 12px;
161
+ }
162
+ }
163
+ @media (prefers-reduced-motion: reduce) {
164
+ *,
165
+ *::before,
166
+ *::after {
167
+ scroll-behavior: auto;
168
+ transition: none;
169
+ animation: none;
170
+ }
171
+ }
172
+
173
+ .demo-playback {
174
+ display: flex;
175
+ gap: 8px;
176
+ flex-wrap: wrap;
177
+ position: fixed;
178
+ z-index: 5;
179
+ top: 12px;
180
+ right: 12px;
181
+ left: auto;
182
+ }
183
+ .data-values {
184
+ position: fixed;
185
+ top: 68px;
186
+ right: 12px;
187
+ padding: 10px;
188
+ color: #f5f7fa;
189
+ background: #102530;
190
+ font: 14px / 1.6 system-ui;
191
+ }
192
+ .data-values table {
193
+ border-collapse: collapse;
194
+ }
195
+ .data-values td,
196
+ .data-values th {
197
+ padding: 3px 14px;
198
+ text-align: left;
199
+ }
200
+
201
+ html:has(body.text-play),
202
+ body.text-play > main {
203
+ height: auto;
204
+ overflow: visible;
205
+ }
206
+ .text-play-panel h1 {
207
+ line-height: 1.25;
208
+ letter-spacing: -0.5px;
209
+ }
210
+
211
+ .fine-actions {
212
+ display: flex;
213
+ align-items: center;
214
+ gap: 8px;
215
+ min-height: 44px;
216
+ margin-bottom: 12px;
217
+ }
218
+ .fine-actions input {
219
+ width: 20px;
220
+ height: 20px;
221
+ }
222
+
223
+ .face-direction {
224
+ display: flex;
225
+ gap: 8px;
226
+ align-items: center;
227
+ flex-wrap: wrap;
228
+ }
229
+ .face-direction select {
230
+ min-height: 44px;
231
+ font: inherit;
232
+ border: 1px solid #b7c9cc;
233
+ border-radius: 6px;
234
+ padding: 6px;
235
+ color: #f5f7fa;
236
+ background: #19343e;
237
+ }
238
+
239
+ @media (max-width: 720px) {
240
+ body:has(.access-toolbar) .topbar {
241
+ flex-direction: column;
242
+ gap: 8px;
243
+ padding: 12px 18px;
244
+ }
245
+ body:has(.access-toolbar) .eyebrow {
246
+ letter-spacing: 2px;
247
+ font-size: 9px;
248
+ margin-bottom: 6px;
249
+ }
250
+ body:has(.access-toolbar) .stats {
251
+ width: 100%;
252
+ justify-content: space-between;
253
+ padding: 8px 12px;
254
+ }
255
+ body:has(.access-toolbar) .topbar h1 {
256
+ margin-bottom: 0;
257
+ }
258
+ .access-toolbar button {
259
+ padding-inline: 8px;
260
+ }
261
+ }
262
+
263
+ @media (min-width: 600px) and (max-height: 500px) {
264
+ body:has(.access-toolbar) .topbar {
265
+ flex-direction: row;
266
+ align-items: center;
267
+ gap: 12px;
268
+ padding: 8px 16px;
269
+ }
270
+ body:has(.access-toolbar) .topbar h1 {
271
+ font-size: 22px;
272
+ margin: 0;
273
+ }
274
+ body:has(.access-toolbar) .topbar .eyebrow,
275
+ body:has(.access-toolbar) .subtitle {
276
+ display: none;
277
+ }
278
+ body:has(.access-toolbar) .stats {
279
+ width: auto;
280
+ padding: 4px 12px;
281
+ gap: 20px;
282
+ }
283
+ body:has(.access-toolbar) .stat strong {
284
+ font-size: 16px;
285
+ }
286
+ body:has(.touch-controls:not([hidden])) .bottom {
287
+ bottom: 12px;
288
+ left: 12px;
289
+ right: 380px;
290
+ }
291
+ body:has(.touch-controls:not([hidden])) .bottom > :not(:first-child),
292
+ body:has(.touch-controls:not([hidden])) .brief .controls,
293
+ body:has(.touch-controls:not([hidden])) .brief .label {
294
+ display: none;
295
+ }
296
+ body:has(.touch-controls:not([hidden])) .brief {
297
+ padding: 8px 12px;
298
+ max-width: 100%;
299
+ }
300
+ body:has(.touch-controls:not([hidden])) #message {
301
+ margin: 0;
302
+ font-size: 12px;
303
+ }
304
+ body:has(.touch-controls:not([hidden])) .sound-toggle {
305
+ top: 64px;
306
+ bottom: auto;
307
+ right: 12px;
308
+ }
309
+ .touch-controls {
310
+ left: auto;
311
+ right: 8px;
312
+ bottom: 8px;
313
+ width: 360px;
314
+ gap: 4px;
315
+ padding: 6px;
316
+ }
317
+ .touch-controls button {
318
+ min-width: 54px;
319
+ padding: 6px 10px;
320
+ font-size: 12px;
321
+ }
322
+ .touch-controls legend {
323
+ font-size: 11px;
324
+ }
325
+ }
@@ -0,0 +1,146 @@
1
+ /** Browser presentation helpers shared by the examples and copied into standalone templates. */
2
+ export interface PlaybackClient {
3
+ readonly tick: number | undefined;
4
+ control(
5
+ action: { action: 'pause' | 'resume' | 'request-keyframe' } | { action: 'step'; ticks: number },
6
+ ): void;
7
+ renderFrame(now?: number): void;
8
+ }
9
+ export interface PlaybackInput {
10
+ setEnabled(enabled: boolean): void;
11
+ reset(): void;
12
+ setVirtual(source: string, action: string, value: number): void;
13
+ clearVirtual(source?: string): void;
14
+ }
15
+ export interface Playback {
16
+ readonly paused: boolean;
17
+ readonly button: HTMLButtonElement;
18
+ setPaused(paused: boolean): void;
19
+ setVisible(visible: boolean): void;
20
+ draw(): void;
21
+ onChange(listener: () => void): () => void;
22
+ dispose(): void;
23
+ }
24
+
25
+ /** The worker must boot paused and the client must use frameLoop: 'manual'. */
26
+ export function createPlayback(options: {
27
+ client: PlaybackClient;
28
+ input?: PlaybackInput | undefined;
29
+ canvas: HTMLCanvasElement;
30
+ container: HTMLElement;
31
+ render?: (elapsedMs: number, now: number) => void;
32
+ }): Playback {
33
+ const { client, input, canvas } = options;
34
+ const motion = matchMedia('(prefers-reduced-motion: reduce)');
35
+ const button = document.createElement('button');
36
+ button.type = 'button';
37
+ button.id = 'pause-playback';
38
+ button.className = 'playback-button';
39
+ options.container.append(button);
40
+ const listeners = new Set<() => void>();
41
+ let paused =
42
+ motion.matches || document.hidden || new URLSearchParams(location.search).get('text') === '1';
43
+ let visible = true;
44
+ let disposed = false;
45
+ let handle = 0;
46
+ let elapsed = 0;
47
+ let previous = performance.now();
48
+ let frames = 0;
49
+ let resizeFrame = 0;
50
+ function render(now: number): void {
51
+ if (!visible || disposed) return;
52
+ if (options.render) options.render(elapsed, now);
53
+ else client.renderFrame(now);
54
+ canvas.dataset.renderFrames = String(++frames);
55
+ }
56
+ function draw(): void {
57
+ // Let the interpolation buffer reach its last simulation sample while frozen.
58
+ render(performance.now() + 100);
59
+ }
60
+ function loop(now: number): void {
61
+ handle = 0;
62
+ if (paused || disposed || !visible) return;
63
+ elapsed += Math.min(100, Math.max(0, now - previous));
64
+ previous = now;
65
+ render(now);
66
+ handle = requestAnimationFrame(loop);
67
+ }
68
+ function sync(): void {
69
+ cancelAnimationFrame(handle);
70
+ handle = 0;
71
+ input?.setEnabled(!paused);
72
+ client.control({ action: paused ? 'pause' : 'resume' });
73
+ button.textContent = paused ? 'Resume animation' : 'Pause animation';
74
+ canvas.dataset.paused = String(paused);
75
+ canvas.dispatchEvent(new Event('playbackchange'));
76
+ if (paused && document.pointerLockElement === canvas) document.exitPointerLock();
77
+ previous = performance.now();
78
+ draw();
79
+ if (!paused && visible) handle = requestAnimationFrame(loop);
80
+ for (const listener of listeners) listener();
81
+ }
82
+ function setPaused(value: boolean): void {
83
+ if (disposed || value === paused) return;
84
+ paused = value;
85
+ sync();
86
+ }
87
+ const toggle = (): void => setPaused(!paused);
88
+ const reduce = (): void => {
89
+ if (motion.matches) setPaused(true);
90
+ };
91
+ const hide = (): void => {
92
+ if (document.hidden) setPaused(true);
93
+ };
94
+ button.addEventListener('click', toggle);
95
+ motion.addEventListener('change', reduce);
96
+ document.addEventListener('visibilitychange', hide);
97
+ // A mount's ResizeObserver resets the drawing buffer after window.resize. Draw on the
98
+ // following frame so a paused canvas is not cleared after its one still image was drawn.
99
+ const resizeObserver = new ResizeObserver(() => {
100
+ cancelAnimationFrame(resizeFrame);
101
+ resizeFrame = requestAnimationFrame(draw);
102
+ });
103
+ resizeObserver.observe(canvas);
104
+ sync();
105
+ return {
106
+ get paused() {
107
+ return paused;
108
+ },
109
+ button,
110
+ setPaused,
111
+ setVisible(value): void {
112
+ visible = value;
113
+ sync();
114
+ },
115
+ draw,
116
+ onChange(listener) {
117
+ listeners.add(listener);
118
+ return () => {
119
+ listeners.delete(listener);
120
+ };
121
+ },
122
+ dispose(): void {
123
+ disposed = true;
124
+ cancelAnimationFrame(handle);
125
+ input?.reset();
126
+ motion.removeEventListener('change', reduce);
127
+ document.removeEventListener('visibilitychange', hide);
128
+ resizeObserver.disconnect();
129
+ cancelAnimationFrame(resizeFrame);
130
+ button.remove();
131
+ listeners.clear();
132
+ },
133
+ };
134
+ }
135
+
136
+ /** Asset readiness alone can resolve before the first Worker keyframe has arrived. */
137
+ export async function readyToPlay(
138
+ client: PlaybackClient & { ready(): Promise<void> },
139
+ ): Promise<void> {
140
+ const deadline = performance.now() + 60000;
141
+ while (client.tick === undefined) {
142
+ if (performance.now() > deadline) throw new Error('The world did not load. Reload to retry.');
143
+ await new Promise((resolve) => setTimeout(resolve, 16));
144
+ }
145
+ await client.ready();
146
+ }
@@ -4,4 +4,4 @@ import { arenaProject } from './arena';
4
4
 
5
5
  // The kernel Worker: kinematics from `physics`, the declared `move` command, and the scene's
6
6
  // scripts all install from data; startKernelWorker builds the world and hosts it on this port.
7
- startKernelWorker({ ...arenaProject() });
7
+ startKernelWorker({ ...arenaProject(), host: { startPaused: true } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/molen-tooling",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -63,17 +63,17 @@
63
63
  "quickhull3d": "3.1.1",
64
64
  "sharp": "0.35.5",
65
65
  "zod": "^4.6.5",
66
- "@bendyline/molen-ambient": "0.0.8",
67
- "@bendyline/molen-kernel": "0.0.5",
68
- "@bendyline/molen-client": "0.0.7",
69
- "@bendyline/molen-materials": "0.0.6",
70
- "@bendyline/molen-pack": "0.0.6",
71
- "@bendyline/molen-figures": "0.0.7",
72
- "@bendyline/molen-terrain": "0.0.8",
73
- "@bendyline/molen-worldgen": "0.0.7",
74
- "@bendyline/molen-worldgen-earth": "0.0.8",
75
- "@bendyline/molen-schema": "0.0.5",
76
- "@bendyline/molen-physics-rapier": "0.0.5"
66
+ "@bendyline/molen-ambient": "0.0.10",
67
+ "@bendyline/molen-client": "0.0.9",
68
+ "@bendyline/molen-figures": "0.0.9",
69
+ "@bendyline/molen-materials": "0.0.8",
70
+ "@bendyline/molen-pack": "0.0.8",
71
+ "@bendyline/molen-kernel": "0.0.7",
72
+ "@bendyline/molen-physics-rapier": "0.0.7",
73
+ "@bendyline/molen-schema": "0.0.7",
74
+ "@bendyline/molen-terrain": "0.0.10",
75
+ "@bendyline/molen-worldgen": "0.0.9",
76
+ "@bendyline/molen-worldgen-earth": "0.0.10"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@biomejs/biome": "^2.5.0",