@bendyline/molen-tooling 0.0.1 → 0.0.3

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 (158) hide show
  1. package/README.md +22 -4
  2. package/dist/capture/harness.js +216 -216
  3. package/dist/capture/worldgen-preview.js +288 -288
  4. package/dist/cli.mjs +134 -12
  5. package/dist/docs-src/guide/3d-art-guidelines.md +2 -2
  6. package/dist/docs-src/guide/3d-model-assets.md +49 -13
  7. package/dist/docs-src/guide/adaptive-performance.md +4 -0
  8. package/dist/docs-src/guide/agent-loop.md +6 -6
  9. package/dist/docs-src/guide/aircraft.md +25 -17
  10. package/dist/docs-src/guide/audio.md +247 -0
  11. package/dist/docs-src/guide/browser-mount.md +17 -1
  12. package/dist/docs-src/guide/building-interiors.md +7 -5
  13. package/dist/docs-src/guide/determinism.md +27 -22
  14. package/dist/docs-src/guide/earth-view.md +444 -0
  15. package/dist/docs-src/guide/entities.md +17 -6
  16. package/dist/docs-src/guide/examples.md +39 -23
  17. package/dist/docs-src/guide/experience-playback.md +2 -3
  18. package/dist/docs-src/guide/game-samples.md +50 -21
  19. package/dist/docs-src/guide/graphics-performance.md +40 -8
  20. package/dist/docs-src/guide/input.md +9 -0
  21. package/dist/docs-src/guide/markers.md +52 -0
  22. package/dist/docs-src/guide/materials.md +10 -3
  23. package/dist/docs-src/guide/navigation.md +144 -0
  24. package/dist/docs-src/guide/project.md +23 -3
  25. package/dist/docs-src/guide/quickstart.md +39 -30
  26. package/dist/docs-src/guide/recognizable-places.md +24 -17
  27. package/dist/docs-src/guide/rendering-backends.md +5 -4
  28. package/dist/docs-src/guide/scripting.md +8 -4
  29. package/dist/docs-src/guide/sky.md +26 -9
  30. package/dist/docs-src/guide/source-bundles.md +0 -1
  31. package/dist/docs-src/guide/structure-library.md +20 -10
  32. package/dist/docs-src/guide/terrain.md +51 -6
  33. package/dist/docs-src/guide/vehicles.md +27 -14
  34. package/dist/docs-src/guide/worldgen.md +34 -24
  35. package/dist/docs-src/llms.txt +35 -18
  36. package/dist/docs-src/schemas/README.md +4 -1
  37. package/dist/docs-src/schemas/archive-set.md +175 -0
  38. package/dist/docs-src/schemas/components.md +1104 -1
  39. package/dist/docs-src/schemas/matgraph.md +6 -0
  40. package/dist/docs-src/schemas/soundbank.md +251 -0
  41. package/dist/docs-src/schemas/structure-placements.md +496 -0
  42. package/dist/docs-src/schemas/terrain-package.md +120 -0
  43. package/dist/index.d.mts +31 -3
  44. package/dist/index.mjs +2 -2
  45. package/dist/{mcp-BFnCWrg0.mjs → mcp-BTVwVKFb.mjs} +78 -4
  46. package/dist/{ops-BGxhSP6w.mjs → ops-BPdHodFR.mjs} +1181 -61
  47. package/dist/templates/city-courier/README.md +66 -0
  48. package/dist/templates/city-courier/checks.json +20 -0
  49. package/dist/templates/city-courier/commands.json +32 -0
  50. package/dist/templates/city-courier/delivery-run.replay.json +214 -0
  51. package/dist/templates/city-courier/gen/molen-types.ts +1016 -0
  52. package/dist/templates/city-courier/index.html +2 -0
  53. package/dist/templates/city-courier/package.json +26 -0
  54. package/dist/templates/city-courier/project.json +8 -0
  55. package/dist/templates/city-courier/scene.json +3474 -0
  56. package/dist/templates/city-courier/scripts/game.ts +131 -0
  57. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +1288 -0
  58. package/dist/templates/city-courier/scripts/tsconfig.json +16 -0
  59. package/dist/templates/city-courier/src/audio.ts +96 -0
  60. package/dist/templates/city-courier/src/game-shell.css +317 -0
  61. package/dist/templates/city-courier/src/main.ts +84 -0
  62. package/dist/templates/city-courier/src/scene.ts +17 -0
  63. package/dist/templates/city-courier/src/vite-env.d.ts +1 -0
  64. package/dist/templates/city-courier/src/worker.ts +5 -0
  65. package/dist/templates/city-courier/test/headless.test.ts +95 -0
  66. package/dist/templates/city-courier/test/playthrough.test.js +52 -0
  67. package/dist/templates/city-courier/test/replay.test.ts +22 -0
  68. package/dist/templates/city-courier/tsconfig.json +17 -0
  69. package/dist/templates/city-courier/vite.config.ts +19 -0
  70. package/dist/templates/cubes/README.md +51 -0
  71. package/dist/templates/cubes/index.html +16 -0
  72. package/dist/templates/cubes/package.json +24 -0
  73. package/dist/templates/cubes/scene.json +15 -0
  74. package/dist/templates/cubes/src/cubes.ts +100 -0
  75. package/dist/templates/cubes/src/main.ts +21 -0
  76. package/dist/templates/cubes/src/worker.ts +15 -0
  77. package/dist/templates/cubes/test/headless.test.ts +98 -0
  78. package/dist/templates/cubes/tsconfig.json +17 -0
  79. package/dist/templates/cubes/vite.config.ts +17 -0
  80. package/dist/templates/data-viz/README.md +47 -0
  81. package/dist/templates/data-viz/camera-track.json +12 -0
  82. package/dist/templates/data-viz/data.json +9 -0
  83. package/dist/templates/data-viz/index.html +16 -0
  84. package/dist/templates/data-viz/package.json +25 -0
  85. package/dist/templates/data-viz/scene.json +7 -0
  86. package/dist/templates/data-viz/src/main.ts +39 -0
  87. package/dist/templates/data-viz/src/viz.ts +91 -0
  88. package/dist/templates/data-viz/src/worker.ts +12 -0
  89. package/dist/templates/data-viz/test/headless.test.ts +75 -0
  90. package/dist/templates/data-viz/tsconfig.json +17 -0
  91. package/dist/templates/data-viz/vite.config.ts +16 -0
  92. package/dist/templates/figures-gallery/README.md +46 -0
  93. package/dist/templates/figures-gallery/index.html +16 -0
  94. package/dist/templates/figures-gallery/package.json +25 -0
  95. package/dist/templates/figures-gallery/scene.json +276 -0
  96. package/dist/templates/figures-gallery/src/main.ts +44 -0
  97. package/dist/templates/figures-gallery/src/worker.ts +17 -0
  98. package/dist/templates/figures-gallery/test/headless.test.ts +90 -0
  99. package/dist/templates/figures-gallery/tsconfig.json +17 -0
  100. package/dist/templates/figures-gallery/vite.config.ts +17 -0
  101. package/dist/templates/index.json +191 -0
  102. package/dist/templates/skybound/README.md +66 -0
  103. package/dist/templates/skybound/checks.json +24 -0
  104. package/dist/templates/skybound/commands.json +32 -0
  105. package/dist/templates/skybound/first-leap.replay.json +224 -0
  106. package/dist/templates/skybound/gen/molen-types.ts +1016 -0
  107. package/dist/templates/skybound/index.html +2 -0
  108. package/dist/templates/skybound/package.json +26 -0
  109. package/dist/templates/skybound/project.json +8 -0
  110. package/dist/templates/skybound/scene.json +1777 -0
  111. package/dist/templates/skybound/scripts/game.ts +122 -0
  112. package/dist/templates/skybound/scripts/molen-scripts.d.ts +1288 -0
  113. package/dist/templates/skybound/scripts/tsconfig.json +16 -0
  114. package/dist/templates/skybound/src/audio.ts +96 -0
  115. package/dist/templates/skybound/src/game-shell.css +317 -0
  116. package/dist/templates/skybound/src/main.ts +63 -0
  117. package/dist/templates/skybound/src/scene.ts +17 -0
  118. package/dist/templates/skybound/src/vite-env.d.ts +1 -0
  119. package/dist/templates/skybound/src/worker.ts +5 -0
  120. package/dist/templates/skybound/test/headless.test.ts +124 -0
  121. package/dist/templates/skybound/test/playthrough.test.js +38 -0
  122. package/dist/templates/skybound/test/replay.test.ts +22 -0
  123. package/dist/templates/skybound/tsconfig.json +17 -0
  124. package/dist/templates/skybound/vite.config.ts +19 -0
  125. package/dist/templates/terrain-flyover/README.md +46 -0
  126. package/dist/templates/terrain-flyover/index.html +16 -0
  127. package/dist/templates/terrain-flyover/package.json +26 -0
  128. package/dist/templates/terrain-flyover/src/flyover.ts +23 -0
  129. package/dist/templates/terrain-flyover/src/main.ts +93 -0
  130. package/dist/templates/terrain-flyover/terrain.json +15 -0
  131. package/dist/templates/terrain-flyover/test/headless.test.ts +72 -0
  132. package/dist/templates/terrain-flyover/tsconfig.json +17 -0
  133. package/dist/templates/terrain-flyover/vite.config.ts +15 -0
  134. package/dist/templates/top-down-arena/README.md +65 -0
  135. package/dist/templates/top-down-arena/arena-skirmish.replay.json +204 -0
  136. package/dist/templates/top-down-arena/index.html +16 -0
  137. package/dist/templates/top-down-arena/package.json +26 -0
  138. package/dist/templates/top-down-arena/project.json +10 -0
  139. package/dist/templates/top-down-arena/scene.json +182 -0
  140. package/dist/templates/top-down-arena/scripts/chase.ts +17 -0
  141. package/dist/templates/top-down-arena/scripts/combat.ts +13 -0
  142. package/dist/templates/top-down-arena/scripts/control.ts +8 -0
  143. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +1258 -0
  144. package/dist/templates/top-down-arena/scripts/spawner.ts +11 -0
  145. package/dist/templates/top-down-arena/scripts/tsconfig.json +16 -0
  146. package/dist/templates/top-down-arena/src/arena.ts +8 -0
  147. package/dist/templates/top-down-arena/src/audio.ts +96 -0
  148. package/dist/templates/top-down-arena/src/gen/molen-types.ts +1020 -0
  149. package/dist/templates/top-down-arena/src/main.ts +34 -0
  150. package/dist/templates/top-down-arena/src/scene.ts +24 -0
  151. package/dist/templates/top-down-arena/src/vite-env.d.ts +1 -0
  152. package/dist/templates/top-down-arena/src/worker.ts +7 -0
  153. package/dist/templates/top-down-arena/test/headless.test.ts +87 -0
  154. package/dist/templates/top-down-arena/test/replay.test.ts +22 -0
  155. package/dist/templates/top-down-arena/tsconfig.json +17 -0
  156. package/dist/templates/top-down-arena/types/arena.types.json +54 -0
  157. package/dist/templates/top-down-arena/vite.config.ts +21 -0
  158. package/package.json +14 -14
@@ -0,0 +1,11 @@
1
+ // Spawn a chaser on a random arena edge every `config.interval` ticks. The component map
2
+ // matches the arena.enemy registry type (types/arena.types.json).
3
+ molen.on('tick', () => {
4
+ if ((molen.tick + 1) % config.interval !== 0) return;
5
+ const half = config.size / 2 - 1;
6
+ const onX = molen.rng() < 0.5;
7
+ const a = (molen.rng() - 0.5) * 2 * half;
8
+ const b = molen.rng() < 0.5 ? -half : half;
9
+ const pos: [number, number, number] = onX ? [a, 0, b] : [b, 0, a];
10
+ molen.spawnType('arena.enemy', { transform: { pos } });
11
+ });
@@ -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,8 @@
1
+ // A small complete top-down arena game built only on the engine's data layers. The world,
2
+ // the `move` command, the input rules, and the game logic (control / spawner / chaser / combat)
3
+ // all live in scene.json + scripts/*.ts; this module only holds the tunables the tests read.
4
+
5
+ /** Tunables the tests reference; the live values are the scripts' `config` in scene.json. */
6
+ export const ARENA = { size: 20, spawnInterval: 12, enemySpeed: 5, playerSpeed: 9 };
7
+
8
+ export { arenaProject, arenaScene } from './scene';
@@ -0,0 +1,96 @@
1
+ import type { MolenClient } from '@bendyline/molen-client';
2
+ import {
3
+ attachAutoplayUnlock,
4
+ createAudioLayer,
5
+ loadPackSoundbanks,
6
+ } from '@bendyline/molen-client/audio';
7
+ import { createPackSet, openPack, type PackIndex } from '@bendyline/molen-pack';
8
+
9
+ // Sound for this sample. The rules live in scene.json (the `audioEnvironment` entity and the
10
+ // `audioSource` components) and in the scripts (`molen.audio.play`); this file only loads the
11
+ // `molen.sounds` content pack and plays what the rules ask for. Without the pack the game is
12
+ // silent: fetch it with `npx molen pack fetch https://molen.dev/packs/index.json molen.sounds
13
+ // --out-dir public/packs`.
14
+
15
+ const SOUND_PACK = 'molen.sounds';
16
+ const MUTED_KEY = 'molen.samples.muted';
17
+
18
+ /** This app's packs/index.json first, then the site-wide one (molen.dev hosts it at /packs/). */
19
+ async function openSoundPack() {
20
+ const candidates = [new URL(`${import.meta.env.BASE_URL}packs/index.json`, location.href)];
21
+ const site = new URL('/packs/index.json', location.href);
22
+ if (site.href !== candidates[0]?.href) candidates.push(site);
23
+ for (const indexUrl of candidates) {
24
+ const response = await fetch(indexUrl).catch(() => undefined);
25
+ if (!response?.ok) continue;
26
+ const index = (await response.json().catch(() => undefined)) as PackIndex | undefined;
27
+ const entry = index?.packs?.[SOUND_PACK];
28
+ if (!entry) continue;
29
+ return openPack(new URL(entry.file, indexUrl).href, {
30
+ sizeHint: entry.size,
31
+ expect: { contentHash: entry.contentHash },
32
+ });
33
+ }
34
+ return undefined;
35
+ }
36
+
37
+ function readMuted(): boolean {
38
+ try {
39
+ return localStorage.getItem(MUTED_KEY) === '1';
40
+ } catch {
41
+ return false;
42
+ }
43
+ }
44
+
45
+ /** Start the sample's audio; resolves to a stop function (a no-op when there is no sound pack). */
46
+ export async function startAudio(client: MolenClient, tickRate: number): Promise<() => void> {
47
+ const pack = await openSoundPack().catch((error: unknown) => {
48
+ console.warn('audio unavailable', error);
49
+ return undefined;
50
+ });
51
+ if (!pack) return () => {};
52
+ const packs = createPackSet([pack]);
53
+ const layer = createAudioLayer({
54
+ banks: await loadPackSoundbanks(packs),
55
+ provider: packs.assetProvider(),
56
+ renderer: client.renderer,
57
+ muted: readMuted(),
58
+ onWarning: (message) => console.warn(`audio: ${message}`),
59
+ });
60
+ const detachClient = layer.attachClient(client, { tickRate });
61
+ const detachUnlock = attachAutoplayUnlock(layer);
62
+
63
+ const toggle = document.createElement('button');
64
+ toggle.type = 'button';
65
+ toggle.className = 'sound-toggle';
66
+ toggle.textContent = 'Sound';
67
+ toggle.setAttribute('aria-pressed', String(!layer.muted));
68
+ toggle.addEventListener('click', () => {
69
+ layer.setMuted(!layer.muted);
70
+ toggle.setAttribute('aria-pressed', String(!layer.muted));
71
+ try {
72
+ localStorage.setItem(MUTED_KEY, layer.muted ? '1' : '0');
73
+ } catch {
74
+ // Storage can be unavailable (private windows); the choice just is not remembered.
75
+ }
76
+ });
77
+ const shell = document.getElementById('interface');
78
+ if (shell) shell.append(toggle);
79
+ else {
80
+ // Pages without the shared game shell get a plain corner button.
81
+ toggle.style.cssText = 'position:fixed;right:12px;bottom:10px;font:13px system-ui';
82
+ document.body.append(toggle);
83
+ }
84
+
85
+ let frame = requestAnimationFrame(function loop(now) {
86
+ layer.update(now);
87
+ frame = requestAnimationFrame(loop);
88
+ });
89
+ return () => {
90
+ cancelAnimationFrame(frame);
91
+ toggle.remove();
92
+ detachUnlock();
93
+ detachClient();
94
+ layer.dispose();
95
+ };
96
+ }