@bendyline/molen-tooling 0.0.2 → 0.0.4
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 +4 -4
- package/dist/capture/harness.js +222 -222
- package/dist/capture/worldgen-preview.js +288 -288
- package/dist/cli.mjs +162 -10
- package/dist/docs-src/guide/3d-model-assets.md +35 -3
- package/dist/docs-src/guide/adaptive-performance.md +4 -0
- package/dist/docs-src/guide/agent-loop.md +6 -6
- package/dist/docs-src/guide/aircraft.md +28 -7
- package/dist/docs-src/guide/ambient-life.md +389 -0
- package/dist/docs-src/guide/audio.md +247 -0
- package/dist/docs-src/guide/browser-mount.md +8 -1
- package/dist/docs-src/guide/building-interiors.md +5 -4
- package/dist/docs-src/guide/capability-authoring.md +5 -0
- package/dist/docs-src/guide/determinism.md +35 -27
- package/dist/docs-src/guide/earth-view.md +492 -0
- package/dist/docs-src/guide/entities.md +9 -1
- package/dist/docs-src/guide/examples.md +6 -2
- package/dist/docs-src/guide/figures.md +3 -0
- package/dist/docs-src/guide/game-samples.md +22 -5
- package/dist/docs-src/guide/graphics-performance.md +40 -8
- package/dist/docs-src/guide/input.md +9 -0
- package/dist/docs-src/guide/markers.md +55 -0
- package/dist/docs-src/guide/materials.md +10 -3
- package/dist/docs-src/guide/navigation.md +150 -0
- package/dist/docs-src/guide/project.md +1 -1
- package/dist/docs-src/guide/quickstart.md +2 -2
- package/dist/docs-src/guide/recognizable-places.md +3 -2
- package/dist/docs-src/guide/scripting.md +4 -2
- package/dist/docs-src/guide/sky.md +16 -0
- package/dist/docs-src/guide/source-bundles.md +0 -1
- package/dist/docs-src/guide/structure-library.md +2 -2
- package/dist/docs-src/guide/surface-rendering.md +4 -3
- package/dist/docs-src/guide/terrain.md +52 -2
- package/dist/docs-src/guide/vehicles.md +32 -10
- package/dist/docs-src/guide/worldgen.md +3 -3
- package/dist/docs-src/llms.txt +14 -5
- package/dist/docs-src/schemas/README.md +4 -0
- package/dist/docs-src/schemas/archive-set.md +175 -0
- package/dist/docs-src/schemas/components.md +1634 -2
- package/dist/docs-src/schemas/matgraph.md +6 -0
- package/dist/docs-src/schemas/scene.md +105 -0
- package/dist/docs-src/schemas/soundbank.md +251 -0
- package/dist/docs-src/schemas/structure-placements.md +496 -0
- package/dist/docs-src/schemas/terrain-package.md +120 -0
- package/dist/docs-src/schemas/transport-network.md +351 -0
- package/dist/index.d.mts +49 -2
- package/dist/index.mjs +81 -4
- package/dist/{mcp-AOfIp89b.mjs → mcp-BtuworIW.mjs} +88 -3
- package/dist/{ops-C4BvDgP-.mjs → ops-DMGcWoL2.mjs} +1204 -93
- package/dist/templates/city-courier/README.md +14 -1
- package/dist/templates/city-courier/delivery-run.replay.json +151 -151
- package/dist/templates/city-courier/gen/molen-types.ts +223 -5
- package/dist/templates/city-courier/package.json +2 -0
- package/dist/templates/city-courier/scene.json +142 -246
- package/dist/templates/city-courier/scripts/game.ts +7 -15
- package/dist/templates/city-courier/scripts/molen-scripts.d.ts +252 -16
- package/dist/templates/city-courier/src/audio.ts +96 -0
- package/dist/templates/city-courier/src/game-shell.css +8 -0
- package/dist/templates/city-courier/src/main.ts +3 -0
- package/dist/templates/city-courier/src/worker.ts +3 -1
- package/dist/templates/city-courier/test/headless.test.ts +3 -2
- package/dist/templates/data-viz/README.md +1 -1
- package/dist/templates/index.json +22 -1
- package/dist/templates/skybound/README.md +13 -0
- package/dist/templates/skybound/first-leap.replay.json +152 -152
- package/dist/templates/skybound/gen/molen-types.ts +223 -5
- package/dist/templates/skybound/package.json +1 -0
- package/dist/templates/skybound/scene.json +40 -0
- package/dist/templates/skybound/scripts/game.ts +8 -5
- package/dist/templates/skybound/scripts/molen-scripts.d.ts +248 -5
- package/dist/templates/skybound/src/audio.ts +96 -0
- package/dist/templates/skybound/src/game-shell.css +8 -0
- package/dist/templates/skybound/src/main.ts +3 -0
- package/dist/templates/skybound/test/headless.test.ts +1 -1
- package/dist/templates/terrain-flyover/README.md +2 -2
- package/dist/templates/top-down-arena/README.md +15 -2
- package/dist/templates/top-down-arena/arena-skirmish.replay.json +152 -152
- package/dist/templates/top-down-arena/package.json +1 -0
- package/dist/templates/top-down-arena/scene.json +20 -0
- package/dist/templates/top-down-arena/scripts/combat.ts +1 -0
- package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +248 -5
- package/dist/templates/top-down-arena/src/audio.ts +96 -0
- package/dist/templates/top-down-arena/src/gen/molen-types.ts +223 -5
- package/dist/templates/top-down-arena/src/main.ts +3 -0
- package/dist/templates/top-down-arena/test/headless.test.ts +1 -1
- package/package.json +13 -12
|
@@ -51,6 +51,11 @@ templates:
|
|
|
51
51
|
Tooling wires the built-in capabilities in `prepareSceneBuilder`; your own host does the same
|
|
52
52
|
with `buildWorld(manifest, setup, { scriptExtensions: { mine: myScriptApi(handle) } })`.
|
|
53
53
|
|
|
54
|
+
A capability that a scene opts into through its own manifest block is a `capabilities` hook,
|
|
55
|
+
`(world, manifest) => ({ mine: api })`, that returns `undefined` when the block is absent, so
|
|
56
|
+
scenes without it pay nothing. `ambientCapability()` from `@bendyline/molen-ambient/kernel`
|
|
57
|
+
is one: it reads the scene's `ambient` block (see [ambient life](ambient-life.md)).
|
|
58
|
+
|
|
54
59
|
7. **Ground and reads.** A capability that owns a height source registers it with
|
|
55
60
|
`installTerrain(world, field)` (any object with `sampleHeight` + `normalAt`) so the character
|
|
56
61
|
controller and kinematics find it. Component reads are frozen stored objects: compare
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Determinism: what is guaranteed
|
|
2
2
|
|
|
3
|
-
Determinism is
|
|
3
|
+
Determinism is Molen's headline guarantee. This page is the contract: what reproduces, how
|
|
4
4
|
exactly, what breaks it, and what happens to your save files when you upgrade.
|
|
5
5
|
|
|
6
6
|
## The short version
|
|
@@ -47,6 +47,7 @@ subsystem's contribution to the state hash reproduces.
|
|
|
47
47
|
| Quaternion helpers that use angles — `quatSlerp`, `lookRotation`, `quatFromYaw`, `quatFromEuler`, `yawOf` | Same JS engine | `kernel/src/math3d.ts` routes these through `dmath.sin/cos/acos/atan2`, and `dmath` is currently a thin re-export of native `Math` |
|
|
48
48
|
| Vehicles and aircraft | Same JS engine | `kernel/src/vehicles.ts` and `aircraft.ts` use `dmath.sin/cos/tan/atan2/exp` |
|
|
49
49
|
| Figures (`@bendyline/molen-figures/kernel`) | Same JS engine | its locomotion system writes `figureState` and `transform.rot` into the world and registers a `figures` snapshot provider, so it **is** hashed; it reaches `dmath.atan2` and `quatFromYaw`, and `gait.ts` reaches `dmath.pow`/`sin`/`cos` |
|
|
50
|
+
| Ambient life (`@bendyline/molen-ambient/kernel`) | Same JS engine | agent state (`ambientAgent`, the `$ambient` bookkeeping entity) and transforms are written into the world, so it **is** hashed; occupancy, junction grants and signal phases are rebuilt from components every tick, so a keyframe restores exactly into a world whose transport network was built from the same inputs. It reaches `dmath.acos/sin/cos` and `lookRotation`. The network itself is a `WeakMap` side channel like worldgen's |
|
|
50
51
|
| `physics.engine: "rapier"` (3D rigid bodies) | Same build + platform | `@dimforge/rapier3d-compat` WASM; the plugin hashes an opaque `takeSnapshot()` blob plus its id→handle maps |
|
|
51
52
|
| Worldgen geometry and prop placement | Not hashed | `installWorldgen` registers the index on a `WeakMap` side channel with no snapshot provider; a test asserts installing it leaves `stateHash` unchanged. Its own content hashes (`hashWorldgenOutput`) are **same JS engine**: its kernel half calls `Math.hypot` in ~33 places, which `dmath.hypot` deliberately avoids because `Math.hypot`'s intermediate scaling is engine-defined |
|
|
52
53
|
| Terrain **streaming, projection, surface rendering** | Not hashed | outside `check-dmath`'s two guarded files on purpose; `geospatial.ts` reaches `Math.cos/log/tan/atan/exp` |
|
|
@@ -93,9 +94,11 @@ The script Compartment enforces the first three. The rest are yours to keep.
|
|
|
93
94
|
and its hash.
|
|
94
95
|
- **Kernel and capability code uses `dmath`, never transcendental `Math.*`.** `scripts/check-dmath.mjs`
|
|
95
96
|
enforces it. It takes explicit roots, so coverage is per-package and deliberate: `kernel` guards
|
|
96
|
-
all of `src`; `figures`, `worldgen` and `worldgen-earth` guard `src/kernel`; `terrain`
|
|
97
|
-
|
|
98
|
-
`GroundField
|
|
97
|
+
all of `src`; `figures`, `ambient`, `worldgen` and `worldgen-earth` guard `src/kernel`; `terrain`
|
|
98
|
+
guards `src/heightfield.ts` and `src/gen.ts`, because a `Heightfield` is the kernel's structural
|
|
99
|
+
`GroundField`, plus the three-free line-path, transport-feature, bridge-profile and
|
|
100
|
+
rendered-ground modules the ambient transport graph builds on. The rest of that package is
|
|
101
|
+
projection and streaming. The lint is lexical — it
|
|
99
102
|
cannot see a transcendental reached through an import, which is why
|
|
100
103
|
`worldgen-earth` carries its own `dmath`-based `projection.ts` instead of importing terrain's.
|
|
101
104
|
- **Systems never read a content library at tick time.** Entity types, landmark models and
|
|
@@ -126,29 +129,29 @@ runs as ordinary code, and nothing lints it.
|
|
|
126
129
|
|
|
127
130
|
## Upgrades and save files
|
|
128
131
|
|
|
129
|
-
**Upgrading
|
|
132
|
+
**Upgrading Molen does not invalidate your saves unless the state format changed.**
|
|
130
133
|
|
|
131
134
|
Two constants live in `packages/kernel/src/version.ts` and they do different jobs:
|
|
132
135
|
|
|
133
136
|
| Constant | Today | Role |
|
|
134
137
|
|---|---|---|
|
|
135
|
-
| `ENGINE_VERSION` | `0.0.
|
|
138
|
+
| `ENGINE_VERSION` | `0.0.4` | metadata. Written into a keyframe's `engine` field so a save says which build wrote it. **Never compared on load, never hashed.** |
|
|
136
139
|
| `STATE_FORMAT` | `1` | the gate. Written into a keyframe under the reserved `plugins.$format` key, compared by `applyKeyframeTo`, and folded into `stateHash` as `stateFormat`. |
|
|
137
140
|
|
|
138
|
-
So a release — even one that moves every package
|
|
141
|
+
So a release — even one that moves every package — keeps your keyframes
|
|
139
142
|
loadable and your recorded `*.replay.json` fixtures valid, as long as it did not change simulation
|
|
140
143
|
semantics or the snapshot layout. `STATE_FORMAT` is bumped only when it did. A keyframe written
|
|
141
144
|
before the key existed is read as format 1, the layout in use when it was introduced.
|
|
142
145
|
|
|
143
146
|
**What a mismatch looks like.** Loading a keyframe whose format does not match throws:
|
|
144
147
|
|
|
145
|
-
```
|
|
148
|
+
```text
|
|
146
149
|
keyframe state format 7 does not match 1 (written by engine 0.0.1)
|
|
147
150
|
```
|
|
148
151
|
|
|
149
152
|
`molen replay` checks the same thing before it runs anything, and tells you the fix:
|
|
150
153
|
|
|
151
|
-
```
|
|
154
|
+
```text
|
|
152
155
|
replay was recorded with state format 99; this build reads 1. Re-record it with: molen replay <fixture> --record
|
|
153
156
|
```
|
|
154
157
|
|
|
@@ -176,7 +179,7 @@ hashes in as well would make a hash depend on content no tick read.
|
|
|
176
179
|
What the identity buys is a named error instead of a divergence at tick 0. Loading a keyframe into
|
|
177
180
|
a world built from different content throws before any state changes:
|
|
178
181
|
|
|
179
|
-
```
|
|
182
|
+
```text
|
|
180
183
|
keyframe was saved with different content: content "types" was sha256:ab… (molen.entities@0.0.1) but the loaded content is sha256:cd… (molen.entities@0.0.2)
|
|
181
184
|
```
|
|
182
185
|
|
|
@@ -193,11 +196,11 @@ The commands below run in a copy of the Skybound sample, made from the npm packa
|
|
|
193
196
|
|
|
194
197
|
**One run, one hash.**
|
|
195
198
|
|
|
196
|
-
```
|
|
199
|
+
```sh
|
|
197
200
|
npx molen sim run scene.json --ticks 30 --hash
|
|
198
201
|
```
|
|
199
202
|
|
|
200
|
-
```
|
|
203
|
+
```text
|
|
201
204
|
tick: 30
|
|
202
205
|
hash: sha256:ba22126aec5915b2de74b445cce75077e859ed5f1837cc3f13d4508c7222ccb9
|
|
203
206
|
events: 30
|
|
@@ -212,11 +215,11 @@ same-JS-engine overall. Use the table above for the whole scene.
|
|
|
212
215
|
**A recorded run, localized on failure.** A `*.replay.json` fixture holds the scene reference, the
|
|
213
216
|
command log, and `expected.stateHash` plus `expected.tickHashes`.
|
|
214
217
|
|
|
215
|
-
```
|
|
218
|
+
```sh
|
|
216
219
|
npx molen replay first-leap.replay.json
|
|
217
220
|
```
|
|
218
221
|
|
|
219
|
-
```
|
|
222
|
+
```text
|
|
220
223
|
✓ replay matches (150 ticks, hash sha256:ede1d58b…, 128 events)
|
|
221
224
|
```
|
|
222
225
|
|
|
@@ -229,7 +232,7 @@ classifies what it finds:
|
|
|
229
232
|
- **`behavior-drift`** — the build is deterministic but no longer matches the recording. If the
|
|
230
233
|
per-tick hashes are recorded, you get the first tick that differs:
|
|
231
234
|
|
|
232
|
-
```
|
|
235
|
+
```text
|
|
233
236
|
✖ replay diverged from the recording (the build is deterministic):
|
|
234
237
|
expected: sha256:deadbeef
|
|
235
238
|
actual: sha256:ede1d58b…
|
|
@@ -248,14 +251,18 @@ two snapshots, including continuation differences under the reserved `$world` ps
|
|
|
248
251
|
`molen sim watch scene.json --ticks N` reruns on every file change and reports hash flips, event
|
|
249
252
|
deltas and assertion transitions.
|
|
250
253
|
|
|
251
|
-
**
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
**Render tests** are a different mechanism with a different guarantee. A render (from
|
|
255
|
+
`molen shot`, or `screenshotScene` in a test) is deterministic for one Chromium build on one
|
|
256
|
+
machine, so the engine's own render suites (`pnpm -r test:golden` in the engine repository)
|
|
257
|
+
compare no committed reference images. They check what holds on any machine: the same input
|
|
258
|
+
renders the same frame twice (`diffImages` with a zero tolerance), a different input renders a
|
|
259
|
+
different frame, and `frameStats` from `@bendyline/molen-tooling` measures a frame or a region of
|
|
260
|
+
it — coverage against the backdrop, distinct colors, mean color — so a test can say the model
|
|
261
|
+
covers the middle of the view or the sky is above the island. `compareGolden` remains for a test
|
|
262
|
+
that needs a reference image: it compares against a committed PNG with a perceptual tolerance
|
|
263
|
+
(per-pixel threshold 0.1, at most 0.3% differing pixels by default), fails when the reference is
|
|
264
|
+
missing rather than adopting the candidate, and records with `UPDATE_GOLDENS=1`. Record and
|
|
265
|
+
compare on the same pinned machine.
|
|
259
266
|
|
|
260
267
|
## What is not promised
|
|
261
268
|
|
|
@@ -263,16 +270,17 @@ Read this list before you build something that depends on a guarantee it does no
|
|
|
263
270
|
|
|
264
271
|
- **Golden images are deterministic per build, not across machines.** The software rasterizer
|
|
265
272
|
agrees with itself for a given Chromium build; it does not agree across Chromium versions or
|
|
266
|
-
operating systems. That is why
|
|
267
|
-
|
|
273
|
+
operating systems. That is why the engine's render tests compare a frame with itself and
|
|
274
|
+
measure it rather than matching a committed reference, and why DOM text overlays are kept out
|
|
275
|
+
of captured frames.
|
|
268
276
|
- **Rapier is not cross-platform.** Same build, same platform. Measured run-to-run in its own
|
|
269
277
|
tests; not claimed beyond that.
|
|
270
278
|
- **Transcendentals are not proven across JS engines.** `dmath` exists so that the swap to
|
|
271
279
|
polynomial approximations is a one-file change. Today its transcendentals are thin re-exports of
|
|
272
280
|
native `Math`, so every "same JS engine" row above stays same-JS-engine until that swap happens.
|
|
273
281
|
Routing through `dmath` buys you the swap point, not the result.
|
|
274
|
-
- **There is no cross-JS-engine CI.** Every environment
|
|
275
|
-
the browser
|
|
282
|
+
- **There is no cross-JS-engine CI.** Every environment Molen tests in — Node, headless Chromium,
|
|
283
|
+
the browser render tests, the materials cross-environment test — runs V8. No claim in this repo has
|
|
276
284
|
been checked against JavaScriptCore or SpiderMonkey.
|
|
277
285
|
- **Worldgen's content hashes are same-engine.** They are cache keys and regression signals, and
|
|
278
286
|
its kernel half reaches `Math.hypot`, whose intermediate scaling is engine-defined.
|