@bendyline/molen-tooling 0.0.2 → 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.
- package/dist/capture/harness.js +216 -216
- package/dist/capture/worldgen-preview.js +288 -288
- package/dist/cli.mjs +110 -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 +16 -7
- package/dist/docs-src/guide/audio.md +247 -0
- package/dist/docs-src/guide/browser-mount.md +3 -1
- package/dist/docs-src/guide/building-interiors.md +5 -4
- package/dist/docs-src/guide/determinism.md +12 -12
- package/dist/docs-src/guide/earth-view.md +444 -0
- package/dist/docs-src/guide/entities.md +1 -1
- package/dist/docs-src/guide/examples.md +2 -1
- package/dist/docs-src/guide/game-samples.md +21 -4
- 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 +52 -0
- package/dist/docs-src/guide/materials.md +10 -3
- package/dist/docs-src/guide/navigation.md +144 -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/terrain.md +45 -2
- package/dist/docs-src/guide/vehicles.md +18 -9
- package/dist/docs-src/guide/worldgen.md +3 -3
- package/dist/docs-src/llms.txt +10 -4
- package/dist/docs-src/schemas/README.md +3 -0
- package/dist/docs-src/schemas/archive-set.md +175 -0
- package/dist/docs-src/schemas/components.md +1104 -1
- package/dist/docs-src/schemas/matgraph.md +6 -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/index.d.mts +5 -1
- package/dist/index.mjs +1 -1
- package/dist/{mcp-AOfIp89b.mjs → mcp-BTVwVKFb.mjs} +67 -3
- package/dist/{ops-C4BvDgP-.mjs → ops-BPdHodFR.mjs} +915 -29
- package/dist/templates/city-courier/README.md +13 -0
- package/dist/templates/city-courier/delivery-run.replay.json +151 -151
- package/dist/templates/city-courier/gen/molen-types.ts +142 -4
- package/dist/templates/city-courier/package.json +1 -0
- package/dist/templates/city-courier/scene.json +79 -0
- package/dist/templates/city-courier/scripts/game.ts +5 -1
- package/dist/templates/city-courier/scripts/molen-scripts.d.ts +167 -4
- 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/test/headless.test.ts +1 -1
- package/dist/templates/index.json +3 -0
- 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 +142 -4
- 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 +167 -4
- 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/top-down-arena/README.md +14 -1
- 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 +167 -4
- package/dist/templates/top-down-arena/src/audio.ts +96 -0
- package/dist/templates/top-down-arena/src/gen/molen-types.ts +142 -4
- 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 +11 -11
|
@@ -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
|
|
@@ -126,13 +126,13 @@ runs as ordinary code, and nothing lints it.
|
|
|
126
126
|
|
|
127
127
|
## Upgrades and save files
|
|
128
128
|
|
|
129
|
-
**Upgrading
|
|
129
|
+
**Upgrading Molen does not invalidate your saves unless the state format changed.**
|
|
130
130
|
|
|
131
131
|
Two constants live in `packages/kernel/src/version.ts` and they do different jobs:
|
|
132
132
|
|
|
133
133
|
| Constant | Today | Role |
|
|
134
134
|
|---|---|---|
|
|
135
|
-
| `ENGINE_VERSION` | `0.0.
|
|
135
|
+
| `ENGINE_VERSION` | `0.0.3` | metadata. Written into a keyframe's `engine` field so a save says which build wrote it. **Never compared on load, never hashed.** |
|
|
136
136
|
| `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
137
|
|
|
138
138
|
So a release — even one that moves every package on the fixed version line — keeps your keyframes
|
|
@@ -142,13 +142,13 @@ before the key existed is read as format 1, the layout in use when it was introd
|
|
|
142
142
|
|
|
143
143
|
**What a mismatch looks like.** Loading a keyframe whose format does not match throws:
|
|
144
144
|
|
|
145
|
-
```
|
|
145
|
+
```text
|
|
146
146
|
keyframe state format 7 does not match 1 (written by engine 0.0.1)
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
`molen replay` checks the same thing before it runs anything, and tells you the fix:
|
|
150
150
|
|
|
151
|
-
```
|
|
151
|
+
```text
|
|
152
152
|
replay was recorded with state format 99; this build reads 1. Re-record it with: molen replay <fixture> --record
|
|
153
153
|
```
|
|
154
154
|
|
|
@@ -176,7 +176,7 @@ hashes in as well would make a hash depend on content no tick read.
|
|
|
176
176
|
What the identity buys is a named error instead of a divergence at tick 0. Loading a keyframe into
|
|
177
177
|
a world built from different content throws before any state changes:
|
|
178
178
|
|
|
179
|
-
```
|
|
179
|
+
```text
|
|
180
180
|
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
181
|
```
|
|
182
182
|
|
|
@@ -193,11 +193,11 @@ The commands below run in a copy of the Skybound sample, made from the npm packa
|
|
|
193
193
|
|
|
194
194
|
**One run, one hash.**
|
|
195
195
|
|
|
196
|
-
```
|
|
196
|
+
```sh
|
|
197
197
|
npx molen sim run scene.json --ticks 30 --hash
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
-
```
|
|
200
|
+
```text
|
|
201
201
|
tick: 30
|
|
202
202
|
hash: sha256:ba22126aec5915b2de74b445cce75077e859ed5f1837cc3f13d4508c7222ccb9
|
|
203
203
|
events: 30
|
|
@@ -212,11 +212,11 @@ same-JS-engine overall. Use the table above for the whole scene.
|
|
|
212
212
|
**A recorded run, localized on failure.** A `*.replay.json` fixture holds the scene reference, the
|
|
213
213
|
command log, and `expected.stateHash` plus `expected.tickHashes`.
|
|
214
214
|
|
|
215
|
-
```
|
|
215
|
+
```sh
|
|
216
216
|
npx molen replay first-leap.replay.json
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
-
```
|
|
219
|
+
```text
|
|
220
220
|
✓ replay matches (150 ticks, hash sha256:ede1d58b…, 128 events)
|
|
221
221
|
```
|
|
222
222
|
|
|
@@ -229,7 +229,7 @@ classifies what it finds:
|
|
|
229
229
|
- **`behavior-drift`** — the build is deterministic but no longer matches the recording. If the
|
|
230
230
|
per-tick hashes are recorded, you get the first tick that differs:
|
|
231
231
|
|
|
232
|
-
```
|
|
232
|
+
```text
|
|
233
233
|
✖ replay diverged from the recording (the build is deterministic):
|
|
234
234
|
expected: sha256:deadbeef
|
|
235
235
|
actual: sha256:ede1d58b…
|
|
@@ -271,7 +271,7 @@ Read this list before you build something that depends on a guarantee it does no
|
|
|
271
271
|
polynomial approximations is a one-file change. Today its transcendentals are thin re-exports of
|
|
272
272
|
native `Math`, so every "same JS engine" row above stays same-JS-engine until that swap happens.
|
|
273
273
|
Routing through `dmath` buys you the swap point, not the result.
|
|
274
|
-
- **There is no cross-JS-engine CI.** Every environment
|
|
274
|
+
- **There is no cross-JS-engine CI.** Every environment Molen tests in — Node, headless Chromium,
|
|
275
275
|
the browser goldens, the materials cross-environment test — runs V8. No claim in this repo has
|
|
276
276
|
been checked against JavaScriptCore or SpiderMonkey.
|
|
277
277
|
- **Worldgen's content hashes are same-engine.** They are cache keys and regression signals, and
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
# Earth view
|
|
2
|
+
|
|
3
|
+
`@bendyline/molen-earth` turns a canvas into an explorable real-world 3D view with one call. It
|
|
4
|
+
composes:
|
|
5
|
+
|
|
6
|
+
- streamed terrain from a `molen/terrain-package@1`;
|
|
7
|
+
- worldgen buildings, street surfaces, trees and parked cars from content packs;
|
|
8
|
+
- orbit, walk and drive navigation;
|
|
9
|
+
- markers placed by latitude/longitude;
|
|
10
|
+
- sky, haze and adaptive quality.
|
|
11
|
+
|
|
12
|
+
You speak latitude and longitude; the view keeps its metric world frame internally.
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import {
|
|
16
|
+
loadEarthContent,
|
|
17
|
+
mountEarthView,
|
|
18
|
+
openPacksFromIndex,
|
|
19
|
+
} from '@bendyline/molen-earth/client';
|
|
20
|
+
|
|
21
|
+
const manifestUrl = new URL('/terrain/terrain-package.json', location.href);
|
|
22
|
+
const terrain = await (await fetch(manifestUrl)).json();
|
|
23
|
+
const content = await loadEarthContent(await openPacksFromIndex('/packs/index.json'));
|
|
24
|
+
|
|
25
|
+
canvas.tabIndex = 0;
|
|
26
|
+
const view = await mountEarthView({
|
|
27
|
+
canvas,
|
|
28
|
+
terrain,
|
|
29
|
+
baseUrl: manifestUrl,
|
|
30
|
+
content,
|
|
31
|
+
camera: { latitude: 47.6205, longitude: -122.3493, range: 1500, heading: 0.8, pitch: 0.55 },
|
|
32
|
+
workers: {
|
|
33
|
+
elevation: () => new Worker(new URL('./elevation.worker.ts', import.meta.url), { type: 'module' }),
|
|
34
|
+
worldgen: () => new Worker(new URL('./worldgen.worker.ts', import.meta.url), { type: 'module' }),
|
|
35
|
+
},
|
|
36
|
+
touchJoystickContainer: canvas.parentElement ?? undefined,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
view.setMarkers([{ id: 'needle', latitude: 47.6205, longitude: -122.3493, image: pinCanvas }]);
|
|
40
|
+
view.on('markerclick', ({ id }) => openArticle(id));
|
|
41
|
+
view.on('camerachange', (camera) => syncMap(camera.latitude, camera.longitude));
|
|
42
|
+
creditsElement.textContent = view.credits.map((credit) => credit.label).join(' · ');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Each worker file is one line, for example `import '@bendyline/molen-earth/workers/elevation';`.
|
|
46
|
+
There are entries for `elevation`, `landcover`, `surface`, `worldgen` and `material`. Any worker
|
|
47
|
+
you omit does its work on the main thread instead.
|
|
48
|
+
|
|
49
|
+
Buildings appear with vertex colors while shared material textures bake in the background.
|
|
50
|
+
Completed textures update the existing materials without regenerating buildings. Terrain detail
|
|
51
|
+
refines in small groups, retaining visible detail during camera turns while replacements load.
|
|
52
|
+
|
|
53
|
+
Metal and glass use a shared procedural sky/ground reflection environment by default. The viewer
|
|
54
|
+
reuses its filtered texture until lighting changes; camera movement does not regenerate it.
|
|
55
|
+
Pass `reflections: false` for the legacy light-only appearance. A host-assigned
|
|
56
|
+
`view.viewer.renderer.scene.environment` takes precedence if you supply your own HDR environment.
|
|
57
|
+
|
|
58
|
+
`touchJoystickContainer` adds an on-screen movement stick while walking or driving. By default it
|
|
59
|
+
appears only on touch devices; pass `touchJoystick: 'always'` to show it everywhere.
|
|
60
|
+
|
|
61
|
+
## Modes
|
|
62
|
+
|
|
63
|
+
- **orbit** (default): the map camera from [camera navigation](navigation.md). `flyTo(target)`
|
|
64
|
+
animates and `jumpTo(target)` moves at once. The target takes `latitude`, `longitude`, and
|
|
65
|
+
optionally `range` in meters, `heading` (a compass bearing in radians) and `pitch` (radians of
|
|
66
|
+
tilt below the horizon).
|
|
67
|
+
- **walk**: `setMode('walk')` drops a walker at the view center. It has capsule collision against
|
|
68
|
+
terrain, buildings and props, WASD or the touch stick to move, mouse-look with pointer lock, and
|
|
69
|
+
Space to jump.
|
|
70
|
+
- **drive**: while walking, press E (or `setMode('drive')`) next to a parked car to get in. W/S
|
|
71
|
+
drive, A/D steer, Space brakes, V switches between cockpit and chase views, and E gets out. Cars
|
|
72
|
+
come from the entities content pack. `message` events explain when entering or leaving is
|
|
73
|
+
blocked, for example "Move closer to the door".
|
|
74
|
+
|
|
75
|
+
Listen for `modechange`. The input profile, clip planes and touch stick follow the mode
|
|
76
|
+
automatically.
|
|
77
|
+
|
|
78
|
+
## Frames and long trips
|
|
79
|
+
|
|
80
|
+
Heights stay in meters. Horizontal distances are exact at the frame latitude and drift by about
|
|
81
|
+
1–1.5% per degree away from it (see [terrain](terrain.md)). The view anchors its frame at the
|
|
82
|
+
starting latitude. After a `flyTo` of more than about a degree north or south, or after panning
|
|
83
|
+
that far, it re-anchors: it rebuilds the terrain stack in a new frame at the destination while
|
|
84
|
+
keeping the viewer, input and markers. With `terrainSource`, a longitude-only trip also checks
|
|
85
|
+
the destination's terrain region. `stats().frameLatitude` reports the current anchor.
|
|
86
|
+
|
|
87
|
+
## Content and packages
|
|
88
|
+
|
|
89
|
+
Without `content` the view still draws terrain, water, roads and extruded buildings. Content packs
|
|
90
|
+
add styled architecture, recognizable businesses, street furniture, trees and drivable cars:
|
|
91
|
+
|
|
92
|
+
- `openPacksFromIndex(indexUrl)` opens `molen.entities`, `molen.worldgen.default`, `molen.earth`,
|
|
93
|
+
`molen.sky` and `molen.sounds` from a pack index you host.
|
|
94
|
+
- `loadEarthContent(packs)` reads them. A missing pack turns its feature off instead of failing.
|
|
95
|
+
|
|
96
|
+
`openPacksFromIndex(indexUrl, ids, fetchImpl)` accepts a host fetch implementation for the index,
|
|
97
|
+
archive opening and subsequent asset requests. Landmark model bytes are loaded as nearby
|
|
98
|
+
placements need them. Large packs require HTTP Range support to retrieve those bytes selectively:
|
|
99
|
+
serve range requests with `206 Partial Content` and a correct `Content-Range` header (expose that
|
|
100
|
+
header through CORS when hosting across origins). A server returning `200 OK` for a range request
|
|
101
|
+
uses the compatible whole-file fallback, which downloads the entire archive before models can
|
|
102
|
+
load. Packs below the small-pack threshold are intentionally fetched in one request.
|
|
103
|
+
|
|
104
|
+
The world-explorer sample builds the worldgen collection as a small style core plus regional
|
|
105
|
+
model archives. All material graphs, style documents, asset sidecars and catalogs remain in
|
|
106
|
+
`molen.worldgen.default`. Its `model-archives` document routes the existing model paths to
|
|
107
|
+
deterministic geohash2 archives, split at a256MiB source-byte budget. Larger individual models
|
|
108
|
+
use isolated archives with a hard512MiB limit. Generic models without a geographic anchor use
|
|
109
|
+
separate shared archives. The public documentation site uses the same builder and route format.
|
|
110
|
+
The build reads and compresses one shard at a time, avoiding the ZIP32 size limit and the
|
|
111
|
+
memory cost of assembling the whole world's models in one archive.
|
|
112
|
+
|
|
113
|
+
`openPacksFromIndex` recognizes the routing document automatically. It opens no regional archive
|
|
114
|
+
until a model is requested, sends its range requests through the same host `fetchImpl`, and
|
|
115
|
+
checks the archive identity and content hash plus each model's SHA-256. Seattle placements
|
|
116
|
+
therefore do not open Chicago's archives. Archive opens are deduplicated; failed opens can be
|
|
117
|
+
retried; idle archive handles and their byte caches are evicted after four open archives.
|
|
118
|
+
Active reads remain pinned. `content.packs.close()` aborts reads and closes all regional handles.
|
|
119
|
+
This is independent of the viewer's GPU model residency and tile unloading.
|
|
120
|
+
|
|
121
|
+
Existing monolithic packs work unchanged. Hosts opening cores from offline storage can call
|
|
122
|
+
`withModelArchives(core, async (id, contentHash, signal) => openYourPack(id, contentHash, signal))`
|
|
123
|
+
before `loadEarthContent`; its optional `maxOpenArchives` controls the idle cache. The wrapper's
|
|
124
|
+
manifest describes the physical core, while `has`, `paths` and reads also expose explicitly
|
|
125
|
+
routed model paths. Ordinary `pack:molen.worldgen.default/...` references continue to resolve.
|
|
126
|
+
The builder publishes the index after all shards and keeps old hash-named archives for viewers
|
|
127
|
+
already using them; deployment storage may retire those versions after its cache lifetime.
|
|
128
|
+
|
|
129
|
+
The terrain package can reference split archive families (`pmtiles-set` sources), or you can pass
|
|
130
|
+
your own transports as `archives.elevation`, `archives.landcover` and `archives.features`. That is
|
|
131
|
+
how a host routes tiles through offline packs or a retrying reader.
|
|
132
|
+
|
|
133
|
+
For a viewer that can travel between separately hosted regions, provide `terrainSource` instead
|
|
134
|
+
of a fixed `terrain`. Molen calls it for the initial camera and after geographic travel. The host
|
|
135
|
+
returns a package manifest plus URLs or archive transports; Molen replaces the terrain stream,
|
|
136
|
+
semantic layers, and local frame while keeping the viewer and navigation alive. A stable `key`
|
|
137
|
+
identifies a region, so returning the same key for a nearby move keeps its resident tiles.
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
const view = await mountEarthView({
|
|
141
|
+
canvas,
|
|
142
|
+
content,
|
|
143
|
+
camera: { latitude: 47.6205, longitude: -122.3493, range: 1500 },
|
|
144
|
+
terrainSource: async ({ latitude, longitude }, signal) => {
|
|
145
|
+
const region = chooseRegion(latitude, longitude);
|
|
146
|
+
const url = new URL(`/terrain/${region}/terrain-package.json`, location.href);
|
|
147
|
+
const response = await fetch(url, { signal });
|
|
148
|
+
if (!response.ok) throw new Error(`Terrain ${region}: HTTP ${response.status}`);
|
|
149
|
+
return { key: region, terrain: await response.json(), baseUrl: url };
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The host can return `archives` in the result to fetch tiles from its own PMTiles service. Keep
|
|
155
|
+
pack attribution visible through `view.credits`, which follows the active terrain source. Listen
|
|
156
|
+
for `terrainchange` to refresh an attribution panel when the package changes. Direct jumps and
|
|
157
|
+
completed flights resolve the destination immediately; manual panning rechecks the host source
|
|
158
|
+
after about five kilometers. A second jump while a region is loading follows the latest target.
|
|
159
|
+
|
|
160
|
+
## Geographic structures and regional styles
|
|
161
|
+
|
|
162
|
+
The Earth pack may provide a `molen/structure-placements@1` document. Each record binds a
|
|
163
|
+
WGS84 `[longitude, latitude]` anchor to an asset ID from the style pack, with an optional
|
|
164
|
+
heading, scale, terrain or sea-level datum, and minimum tile level. The Earth viewer loads the
|
|
165
|
+
catalog with the packs, indexes it by three-character geohash, and draws each `preview` model
|
|
166
|
+
in the terrain tile containing its anchor. `draft` records remain queryable but are not drawn.
|
|
167
|
+
Long structures may supply `bounds: [west, south, east, north]`. Their extent is indexed across
|
|
168
|
+
geohash cells and geometry is clipped to each resident tile, so a bridge end stays visible when
|
|
169
|
+
its center is outside the view. Extended structures use either `datum: 'sea-level'` with an
|
|
170
|
+
absolute `elevation`, or a `terrainReference` with the host sampler described below. Every
|
|
171
|
+
tile must resolve the same model origin, avoiding inconsistent ground samples between tiles.
|
|
172
|
+
`replaceRoads: { length, width, deckHeight?, deckHeights? }` describes a model-local rectangle along +X:
|
|
173
|
+
mapped parallel bridge lines inside it are replaced only after the model loads successfully.
|
|
174
|
+
Outside approach fragments remain procedural. `deckHeight` joins those approaches to the
|
|
175
|
+
model's deck height above its origin, blending back over 100 m; include that margin in `bounds`.
|
|
176
|
+
For sloped decks, use `deckHeights: [negativeXEnd, positiveXEnd]` instead of `deckHeight`.
|
|
177
|
+
Both heights are native model Y and follow the model's Y scale, resolved origin and heading.
|
|
178
|
+
These joins apply to remaining bridge-tagged road fragments, not unrelated ground roads.
|
|
179
|
+
Skewed or curved structures may add `replaceRoads.outline: [[x, z], ...]`, a simple native
|
|
180
|
+
footprint polygon. It replaces the rectangle for suppression, including concave bends;
|
|
181
|
+
parallel road segments outside it remain intact. `length` still locates the two connection
|
|
182
|
+
stations at native X=-length/2 and X=+length/2, Z=0, and `deckHeights` keeps that endpoint order.
|
|
183
|
+
Sunken structures can declare `groundCutout: { outline: [[x, z], ...], basis: 'source evidence' }` on a placement. The simple polygon uses native model metres and follows the same heading and scale as the model. It should bound the ground opening covered by the authored concourse or rim. The terrain pyramid subtracts the polygon from actual elevation and draped ground triangles across tile and LOD boundaries, preserving interpolated heights and surface attributes along its edge. The cutout becomes active only when its successfully loaded structure is visible, and the original ground returns on layer hiding or eviction. Failed or cancelled models leave the ground intact. Heights remain available for anchoring; an opening does not itself author walkable floors or collision.
|
|
184
|
+
|
|
185
|
+
### Bridge elevations and terrain fit
|
|
186
|
+
|
|
187
|
+
With the default `datum: 'terrain'`, a placement's origin Y is the sampled terrain height at
|
|
188
|
+
`anchor` plus `elevation` (default zero). That works for a model authored with its ground contact
|
|
189
|
+
at Y=0. A bridge authored from a riverbed or buried foundation needs a corresponding reference:
|
|
190
|
+
a coarse elevation grid may contain the road surface or smooth the gorge across several pixels.
|
|
191
|
+
Increasing tile zoom cannot recover relief absent from the source elevation data.
|
|
192
|
+
|
|
193
|
+
For a measured model origin, use `datum: 'sea-level'` and set `elevation` to its absolute height
|
|
194
|
+
in the same vertical reference as the host terrain. This bypasses terrain sampling and gives every
|
|
195
|
+
clipped portion of a long bridge the same vertical position. The name `sea-level` selects the
|
|
196
|
+
world's absolute Y frame; it does not convert between EGM96, EGM2008, a local survey datum or an
|
|
197
|
+
ellipsoidal height. The host must perform that conversion before providing the value.
|
|
198
|
+
|
|
199
|
+
For a terrain placement referenced to another point, add
|
|
200
|
+
`terrainReference: { anchor: [longitude, latitude], modelHeight, basis }`. For example, a bank
|
|
201
|
+
at native Y=8 uses `modelHeight: 8`; the model origin becomes the reference elevation minus
|
|
202
|
+
`modelHeight * scaleY`, plus `elevation`. Record the source and meaning of that point in `basis`.
|
|
203
|
+
This field is incompatible with `datum: 'sea-level'`.
|
|
204
|
+
|
|
205
|
+
Hosts can supply `sampleStructureTerrain(coordinate, { entry, signal })` to `mountEarthView`,
|
|
206
|
+
`createEarthWorldgen`, or `createWorldgenSemanticRenderers`. It may return a height or a promise
|
|
207
|
+
and must use the same world height reference as the rendered terrain. Resolve the coordinate
|
|
208
|
+
from its own terrain tile or a surveyed source; honor `signal` when fetching. Returning
|
|
209
|
+
`undefined` means coverage is unavailable: the model remains unloaded and procedural map
|
|
210
|
+
features remain visible. Absolute placements bypass this callback. Without a host callback,
|
|
211
|
+
the renderer samples only a reference inside the current tile, never its clamped edge.
|
|
212
|
+
An extended terrain structure (`bounds` plus `terrainReference`) requires this host callback;
|
|
213
|
+
without it, all its model pieces remain deferred and their procedural fallback stays visible.
|
|
214
|
+
The callback must resolve the same reference height for every clipped tile. A bank reference
|
|
215
|
+
therefore also works when the landmark anchor lies over unknown river elevation cells.
|
|
216
|
+
For loaded terrain, the pyramid stream's `sampleHeight` searches covering resident tiles
|
|
217
|
+
and returns `undefined` when none covers the point. A host that requires guaranteed cross-tile
|
|
218
|
+
references should retrieve those source tiles independently of the current visible tile set.
|
|
219
|
+
|
|
220
|
+
Check the approaches and channel in addition to the model origin. A bridge may have the correct
|
|
221
|
+
height while a host's elevation data still fails to represent its banks. Supply better local
|
|
222
|
+
elevation data through the terrain archives for that case. The reference hook changes model
|
|
223
|
+
placement; it does not modify a smoothed river channel. A `groundCutout` removes covered terrain
|
|
224
|
+
but does not reconstruct riverbanks, water levels, or a riverbed. The source repository includes a
|
|
225
|
+
repeatable real-terrain review: `build-bridge-terrain-evidence.mjs` preserves original Terrarium
|
|
226
|
+
samples, and `test/visual/capture-bridge-terrain.mjs` in the world-explorer example uses the
|
|
227
|
+
production terrain mesher and structure renderer, records approach ray measurements, and checks
|
|
228
|
+
model eviction. `build-copernicus-bridge-evidence.py` and the capture runner's
|
|
229
|
+
`--terrain-set=copernicus` option preserve a separate comparison with Copernicus elevations;
|
|
230
|
+
neither capture set substitutes altered heights to make a bridge fit. These reports are research
|
|
231
|
+
evidence and are excluded from the Earth runtime pack.
|
|
232
|
+
|
|
233
|
+
If `replaceFootprint` is set, a nongeneralized mapped building is suppressed only when the
|
|
234
|
+
anchor falls inside its polygon and the replacement model has loaded. Failed models keep the
|
|
235
|
+
procedural building. An Earth pack without a placement document still loads.
|
|
236
|
+
|
|
237
|
+
For unsurveyed orientation, `orientation: 'mapped'` requires an explicit
|
|
238
|
+
`mapIdentity: { wikidata: 'Q…', maxDistance: 150 }`. The viewer admits that model only after a
|
|
239
|
+
nearby matching building, directed POI, or bridge supplies an orientation. Exact name aliases
|
|
240
|
+
are supported only when the catalog supplies no Wikidata ID. A footprint's longest edge gives
|
|
241
|
+
an undirected axis, not proof of the entrance direction. `lengthAxis: 'x' | 'z'` identifies the
|
|
242
|
+
authored longitudinal axis. Entries with surveyed catalog headings use `orientation: 'fixed'`
|
|
243
|
+
(the default). No matching geometry means no speculative placement for a mapped entry.
|
|
244
|
+
|
|
245
|
+
### Reusable mapped categories
|
|
246
|
+
|
|
247
|
+
An Earth pack can list multiple `provides.structures` documents. Alongside geographic `entries`,
|
|
248
|
+
each document may contain `rules` for deliberately generic assets. The shipped
|
|
249
|
+
`structures/map-rules.json` recognizes windmills and wind turbines from class, subclass, or
|
|
250
|
+
explicit map tags. Unique named landmarks never become arbitrary category replacements.
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"id": "generic.windmill",
|
|
255
|
+
"title": "Smock windmill",
|
|
256
|
+
"asset": "molen.worldgen.structure.map_smock_windmill",
|
|
257
|
+
"match": { "classes": ["windmill"] },
|
|
258
|
+
"dimensions": [23.3, 30.6, 16.5],
|
|
259
|
+
"orientation": "direction",
|
|
260
|
+
"fit": "native",
|
|
261
|
+
"minLevel": 14,
|
|
262
|
+
"maxPerTile": 16,
|
|
263
|
+
"source": "https://wiki.openstreetmap.org/wiki/Tag:man_made%3Dwindmill"
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Match fields are AND conditions; the values within a field are alternatives. Put separate
|
|
268
|
+
rules in priority order for alternative source schemas. `dimensions` are authored X/Y/Z meters
|
|
269
|
+
with the base at Y=0 and front along +Z. `fit: 'footprint'` fits horizontal dimensions to a
|
|
270
|
+
confirmed nongeneralized building; `native` retains authored proportions. Measured heights
|
|
271
|
+
uniformly scale native models, bounded from 0.2 to 5 times native dimensions; footprint fitting
|
|
272
|
+
adjusts the three dimensions independently. Explicit source `direction`
|
|
273
|
+
or compass bearings take priority; otherwise footprints use their longest axis and points
|
|
274
|
+
default north. This default is an estimate, especially for rotatable turbine nacelles.
|
|
275
|
+
Rules with `replaceFootprint: true` can also replace a nongeneralized footprint containing a
|
|
276
|
+
matching POI, after the asset loads. This is useful when a windmill is a POI plus an unclassified
|
|
277
|
+
building outline; the default leaves point features independent of building shells.
|
|
278
|
+
|
|
279
|
+
The renderer admits at most 64 category models per tile and obeys each rule's smaller budget.
|
|
280
|
+
It owns points with half-open tile bounds, deduplicates building/POI pairs and nearby named
|
|
281
|
+
landmarks, samples terrain at each model base, and releases shared model resources on tile
|
|
282
|
+
eviction. Rules require source classification evidence: a cafe with “Windmill” in its name is
|
|
283
|
+
not a windmill. Providers that omit POIs, classifications, or structure tags cannot imply that
|
|
284
|
+
object. The semantic decoder preserves public structure tags and Wikidata IDs when supplied.
|
|
285
|
+
|
|
286
|
+
`content.worldgen.structures.query([west, south, east, north])` returns preview placements in a
|
|
287
|
+
geographic rectangle. Pass `true` as the second argument to include drafts. The default
|
|
288
|
+
catalog and its source notes live in `content/earth/structures/placements.json` in the engine
|
|
289
|
+
repository. Named model sources and previews live in
|
|
290
|
+
`content/worldgen/source/places/<gh2>/<gh3>/<source-key>/`; imported runtime bundles mirror
|
|
291
|
+
that organization under `content/worldgen/assets/places/<gh2>/<gh3>/<source-key>/`.
|
|
292
|
+
Each runtime bundle contains `asset.json`, `model.glb`, and any collision data. Reusable models
|
|
293
|
+
use `assets/reusable/urban/<source-key>/`, `assets/reusable/infrastructure/<source-key>/`, or
|
|
294
|
+
`assets/reusable/map-structures/<source-key>/`. The two geographic folders are geohashes of
|
|
295
|
+
length two and three. New named entries without an organizational anchor start in `places/unlocated/`.
|
|
296
|
+
|
|
297
|
+
`content/worldgen/source/structure-index.json` resolves source keys to authoring directories.
|
|
298
|
+
The runtime mappings are separate: `content/worldgen/project.json` registers stable asset IDs
|
|
299
|
+
to sidecars for tooling, and `content/worldgen/stylepack.json` registers the same IDs for pack
|
|
300
|
+
resolution through `stylePackAssetIndex`. Asset IDs remain unchanged when folders move;
|
|
301
|
+
hosts resolve these mappings instead of deriving a model URL from the dotted ID. Folder
|
|
302
|
+
reference coordinates organize files and do not approve or activate geographic placement.
|
|
303
|
+
The terrain stream queries only cells intersecting resident tiles. Chicago models are not fetched
|
|
304
|
+
while viewing Seattle; a structure model is released from CPU and GPU memory when the last tile
|
|
305
|
+
using it leaves view. Returning to the area loads it again. Draft entries never fetch models.
|
|
306
|
+
|
|
307
|
+
Historical reconstructions use `status: 'historical'` and an `appearance` record:
|
|
308
|
+
|
|
309
|
+
```json
|
|
310
|
+
{
|
|
311
|
+
"kind": "historical",
|
|
312
|
+
"currentWorldEligible": false,
|
|
313
|
+
"representedDate": "1930",
|
|
314
|
+
"validFrom": "1926-01-06",
|
|
315
|
+
"validUntil": "1934-04-01"
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
They remain unloaded in the default view. A host explicitly passes `viewingDate: '1930-01-01'`
|
|
320
|
+
to `mountEarthView`, `createEarthWorldgen`, or `createWorldgenSemanticRenderers` to include
|
|
321
|
+
historical assets for that day. The lower-level index accepts
|
|
322
|
+
`query(bounds, { viewingDate: '1930-01-01' })`. Dates must be valid `YYYY-MM-DD` calendar dates;
|
|
323
|
+
the first bound is inclusive and the last is exclusive. Date selection is independent of the
|
|
324
|
+
system clock and sky simulation. Remount the viewer to change it. Historical assets retain
|
|
325
|
+
geographic tile filtering, deferred loading, fallback on failed loads, and eviction cleanup.
|
|
326
|
+
|
|
327
|
+
This option selects dated landmark appearances. Hosts supply matching historical PMTiles and
|
|
328
|
+
terrain when needed; undated present-day map features and preview landmarks have no inferred
|
|
329
|
+
historical lifetime. For source authoring, combine `appearance` with a
|
|
330
|
+
`geographicProposal.status: 'historical-proposal'` and the usual reviewed ground contact and
|
|
331
|
+
placement evidence. Older historical sources without a complete supported date interval remain
|
|
332
|
+
drafts. Shared placement QA uses `capture-landmark-library.mjs --viewing-date=1930-01-01` and
|
|
333
|
+
records the explicit date in its hash-bound report.
|
|
334
|
+
|
|
335
|
+
Geographic and category models use `StructureModelLibrary`, preserving the authored mesh
|
|
336
|
+
hierarchy, UV coordinates, texture maps, material assignments and PBR parameters. Instances
|
|
337
|
+
share those resources until the last reference is released. Long static models retain their
|
|
338
|
+
UVs, vertex attributes and material groups when clipped at tile edges; textures do not restart
|
|
339
|
+
at each seam. The library accepts static assets: skinned or animated structures require a host
|
|
340
|
+
animation implementation. Procedural scatter continues to use the separate instanced prop path.
|
|
341
|
+
|
|
342
|
+
### Shared architectural surfaces
|
|
343
|
+
|
|
344
|
+
Authored GLB materials can opt into the same texture library as procedural buildings. Set
|
|
345
|
+
the material's glTF `extras.molenSurface` (available as Three.js material `userData.molenSurface`):
|
|
346
|
+
|
|
347
|
+
```json
|
|
348
|
+
{
|
|
349
|
+
"ref": "matgraph:molen.worldgen.material.wood_painted_lap",
|
|
350
|
+
"slot": "wall",
|
|
351
|
+
"uv": "repeats"
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
`encodeGlb` exposes this as `GlbMaterialMeta.sharedSurface`. Author UV0 in texture repeats:
|
|
356
|
+
divide local surface coordinates in meters by the material's `repeatMeters` once during
|
|
357
|
+
authoring. Wood grain must follow the timber; masonry courses remain horizontal. Put color
|
|
358
|
+
variants in vertex colors with a white base-color factor, so white painted wood and green
|
|
359
|
+
painted wood share the same maps and material. Model-specific artwork and special PBR effects
|
|
360
|
+
keep their original unbound materials. GLBs retain portable fallback PBR materials for other
|
|
361
|
+
viewers and ordinary asset previews; the Earth viewer applies shared surfaces explicitly.
|
|
362
|
+
|
|
363
|
+
The default library has 65 procedural surfaces, including brick bonds, stone, timber, painted
|
|
364
|
+
wood, shingles, concrete, metal, plaster, glass and canvas. Its authoring catalog, physical
|
|
365
|
+
repeat sizes, tint variants, swatches and texture audit live in
|
|
366
|
+
`content/worldgen/source/material-library/` in the engine repository. Color variants do not
|
|
367
|
+
duplicate texture images. The current Earth viewer prepares the registered library after the
|
|
368
|
+
first frame and retains it until viewer disposal. Structure eviction releases model geometry
|
|
369
|
+
and private materials while preserving shared surfaces used by other structures. A separate
|
|
370
|
+
on-demand material eviction policy is not yet implemented.
|
|
371
|
+
|
|
372
|
+
Constant roughness and metalness channels use exact numeric factors instead of textures;
|
|
373
|
+
other maps retain their authored pixels. Across the full library this removes 58 texture
|
|
374
|
+
allocations, reducing estimated base-level RGBA8 texel storage from 45.75 to 31.25 MiB.
|
|
375
|
+
These are storage estimates, not measured driver allocations. Alpha-cutout surfaces retain
|
|
376
|
+
linear sampling without mip averaging so small perforations remain open.
|
|
377
|
+
|
|
378
|
+
Hosts composing their own renderer can supply `StructureModelLibrary` with
|
|
379
|
+
`resolveSurface: ({ ref, slot }) => materials.materialFor(slot, ref)` using a
|
|
380
|
+
`createResolvedMaterialSet` instance. Restrict references to the host's registered material
|
|
381
|
+
library and keep it alive until all structure libraries have been disposed. Missing bindings
|
|
382
|
+
or UVs preserve the GLB fallback. A new bake upgrades progressive materials in place without
|
|
383
|
+
rebuilding model geometry.
|
|
384
|
+
|
|
385
|
+
`StructureModelLibrary` preserves host ownership of decoded ImageBitmaps by default. Its
|
|
386
|
+
`ownsImageBitmaps: true` option explicitly transfers ownership, allowing unused
|
|
387
|
+
fallback images to close after shared-material replacement and remaining images to close
|
|
388
|
+
after their last scene is released. A per-scene predicate can transfer ownership selectively.
|
|
389
|
+
The built-in Earth loader opts in only when every image uses an embedded bufferView: these
|
|
390
|
+
decode through fresh blob URLs excluded from Three's cache. Scenes with URI/data-URI images
|
|
391
|
+
retain host ownership, including mixed scenes. A fresh parse alone does not establish ownership
|
|
392
|
+
of images that may come from an external cache.
|
|
393
|
+
|
|
394
|
+
Mapped roads with `bridge: true` receive solid decks, edge barriers and regularly spaced
|
|
395
|
+
supports in the shared terrain surface renderer, including its worker path. Road, rail and
|
|
396
|
+
pedestrian spans follow mapped centerlines and widths; tunnels are omitted. Complete spans
|
|
397
|
+
interpolate between bank heights and connect to adjoining ground roads. Clipped spans use
|
|
398
|
+
estimated terrain clearance (6 m for roads/rail, 3 m for paths); a semantic provider can set
|
|
399
|
+
`deckElevation` to an absolute surveyed height. These are visual approximations: tile data
|
|
400
|
+
does not establish bridge engineering type, navigation clearance, foundations or collision.
|
|
401
|
+
The SR-520 preview replaces the floating section; its approaches use this same fallback.
|
|
402
|
+
|
|
403
|
+
Regional procedural styles are separate from exact structures. The atlas's ordered rules use
|
|
404
|
+
mapped building class, footprint size, context, and known height to choose a style. A rule can
|
|
405
|
+
give weighted variants, sampled from a stable building identity, so a neighborhood has a
|
|
406
|
+
repeatable mix. `suggestStructureStyles(atlas, longitude, latitude, metrics)` from
|
|
407
|
+
`@bendyline/molen-worldgen-earth/kernel` exposes the matching weights and normalized shares for
|
|
408
|
+
inspection. The Pacific Northwest's unmeasured low-rise mix includes wood-sided PNW houses,
|
|
409
|
+
Craftsman, brick Prairie, and Ranch forms; Japan and broader regions have their own rules.
|
|
410
|
+
These regional forms are visual priors, not surveyed attributes of individual buildings.
|
|
411
|
+
|
|
412
|
+
## Credits, quality, lifecycle
|
|
413
|
+
|
|
414
|
+
- `view.credits` holds the package's required attributions, OpenStreetMap first with its link.
|
|
415
|
+
Keep them visible whenever the view is.
|
|
416
|
+
- `quality: 'auto'` adapts terrain budgets, building detail and pixel ratio to measured frame
|
|
417
|
+
times (`stats().qualityLevel`, 0-5). A preset pins the quality.
|
|
418
|
+
- `setPaused(true)` stops rendering while the view is hidden, and `dispose()` releases the GPU
|
|
419
|
+
context, workers and listeners. Mounting is abortable through `signal`.
|
|
420
|
+
|
|
421
|
+
## Sound
|
|
422
|
+
|
|
423
|
+
With the `molen.sounds` pack in `content`, the view plays the Earth soundscape: rain and wind
|
|
424
|
+
from the weather, birds by day and crickets at night, traffic near streets, footsteps while
|
|
425
|
+
walking, and an engine on the car or aircraft you board. Birds, crickets and traffic come from
|
|
426
|
+
the ground, so they fade as the view rises above the terrain and are gone a few hundred meters
|
|
427
|
+
up. Traffic also fades with distance from the nearest street. Sound starts on the first click or
|
|
428
|
+
key press. The `audioready` event fires once it has loaded, and then `view.audio` sets volume,
|
|
429
|
+
mute and bus gains (`view.audio.setBusGain('music', 0)` turns music off).
|
|
430
|
+
|
|
431
|
+
```ts
|
|
432
|
+
const view = await mountEarthView({ canvas, content, terrain, audio: { volume: 0.6, music: false } });
|
|
433
|
+
view.on('audioready', () => view.audio?.setMuted(localStorage.getItem('muted') === '1'));
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Pass `audio: false` to keep the view silent, or `audio: { environment }` to replace the rules.
|
|
437
|
+
The default rules are exported as `EARTH_AUDIO_ENVIRONMENT`, and `createEarthAudio` builds the
|
|
438
|
+
same soundscape for a host that composes its own view. See [Sound and music](audio.md) for the
|
|
439
|
+
rule format.
|
|
440
|
+
|
|
441
|
+
The composing pieces are exported too, for hosts that build their own view: `createEarthWorldgen`,
|
|
442
|
+
`EarthVehicles`, `createEarthSky`/`createEarthFog`, `createEarthAudio`, `earthPerformanceTier` and
|
|
443
|
+
`earthCredits`.
|
|
444
|
+
The [World Explorer](https://molen.dev/play/world-explorer/) sample is built from them.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Reusable entities
|
|
2
2
|
|
|
3
|
-
The `molen.entities` content pack is
|
|
3
|
+
The `molen.entities` content pack is Molen's curated entity collection. It builds on the existing
|
|
4
4
|
`renderable.kind: "gltf"`, `molen/asset@1`, `molen/types@1`, and `molen/project@1` contracts;
|
|
5
5
|
there is no second entity or asset runtime.
|
|
6
6
|
|
|
@@ -7,7 +7,7 @@ meant to be copied. Three ways in, none of which needs a clone of the engine rep
|
|
|
7
7
|
- **Copy** a sample into your own npm project with `--template`. The templates ship inside
|
|
8
8
|
`@bendyline/molen-tooling`, locked to the engine version you install, so they work offline:
|
|
9
9
|
|
|
10
|
-
```
|
|
10
|
+
```sh
|
|
11
11
|
npx @bendyline/molen-tooling new my-game --template skybound
|
|
12
12
|
cd my-game && npm install && npm run dev
|
|
13
13
|
```
|
|
@@ -24,6 +24,7 @@ meant to be copied. Three ways in, none of which needs a clone of the engine rep
|
|
|
24
24
|
| Top-down arena | a complete small game as **pure data**: `scene.json` declares kinematics, the `move` command + WASD input, and four scripts (control/spawner/chaser/combat); no setup module | [play](https://molen.dev/play/top-down-arena/) | `top-down-arena` |
|
|
25
25
|
| Terrain flyover | chunked LOD terrain from a descriptor + deterministic 16-bit heightmap | [play](https://molen.dev/play/terrain-flyover/) | `terrain-flyover` |
|
|
26
26
|
| Figures gallery | a lineup of every figure preset, a body-type sweep, a hat on a head socket and a rider on a horse; `?walk=1` (or the `set_gait` command) animates the gaits in place | [play](https://molen.dev/play/figures-gallery/) | `figures-gallery` |
|
|
27
|
+
| Earth view | the [`mountEarthView`](earth-view.md) facade in one page: real Sammamish terrain, styled buildings, orbit / walk / drive with parked cars, a photo-pin marker and credits (`?mode=walk`, `?lat=&lon=&range=`) | [play](https://molen.dev/play/earth-view/) | [source](https://github.com/bendyline/molen/tree/main/examples/earth-view) |
|
|
27
28
|
| World explorer | streamed Web Mercator terrain with adaptive package LOD, bare / land-classification / human-feature modes, and styled buildings from the default worldgen pack (`?style=`, `?synthetic=1&lineup=1`) | [play](https://molen.dev/play/world-explorer/) | [source](https://github.com/bendyline/molen/tree/main/examples/world-explorer) |
|
|
28
29
|
|
|
29
30
|
## Playable game samples
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# Three complete games, one authoring path
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
CLI. Each is JSON data + scene scripts,
|
|
5
|
-
bindings, semantic prefabs, durable state, a HUD,
|
|
3
|
+
City Courier, The Lantern Vault and Skybound are complete games that exercise the same scene →
|
|
4
|
+
`buildWorld` → Worker → `mountExperience` path as the CLI. Each is JSON data + scene scripts,
|
|
5
|
+
with declared command/component schemas, input bindings, semantic prefabs, durable state, a HUD,
|
|
6
|
+
restart, and a tested win condition.
|
|
6
7
|
|
|
7
8
|
| Sample | Play | Loop | Engine services |
|
|
8
9
|
|---|---|---|---|
|
|
@@ -12,7 +13,7 @@ bindings, semantic prefabs, durable state, a HUD, restart, and a tested win cond
|
|
|
12
13
|
|
|
13
14
|
To take one apart, copy it into your own npm project:
|
|
14
15
|
|
|
15
|
-
```
|
|
16
|
+
```sh
|
|
16
17
|
npx @bendyline/molen-tooling new my-courier --template city-courier # or skybound
|
|
17
18
|
cd my-courier && npm install
|
|
18
19
|
npx molen sim run scene.json --ticks 90 --commands commands.json --assert checks.json --hash
|
|
@@ -89,6 +90,22 @@ simulation. Validation, headless play, replay/checkpoints, browser play, and scr
|
|
|
89
90
|
the same scene and scripts. The new camera and platform services remove duplicated host logic
|
|
90
91
|
and sample-specific collision solvers from ordinary game authoring.
|
|
91
92
|
|
|
93
|
+
## Sound
|
|
94
|
+
|
|
95
|
+
Each game annotates its scene for sound, and `src/audio.ts` plays it from the `molen.sounds` pack:
|
|
96
|
+
|
|
97
|
+
| Sample | Scene data | Script calls |
|
|
98
|
+
| --- | --- | --- |
|
|
99
|
+
| City Courier | City traffic ambience, racing music; an engine on the player pitched by `self.speed` and quieter engines on the traffic cars; `crash` and `delivery` events mapped to sounds | `molen.audio.play('sting.win')` when the route is complete, `'ui.error'` on a loss |
|
|
100
|
+
| The Lantern Vault | Dungeon ambience and music, stone footsteps, a draft `audioZone` by the vault; `strike`, `hurt`, `heal`, `key-found`, `gate-opened` and `victory` mapped to sounds | `molen.audio.play('weapon.slash')` on every swing |
|
|
101
|
+
| Skybound | Wind that rises with the camera (`listener.y`), heroic music; pickups, stomps, checkpoint, respawn and victory mapped to sounds | `molen.audio.play('game.jump')` on a jump that can happen |
|
|
102
|
+
| Top-down arena | Arena music; `player-hit` mapped to a hit sound | `molen.emit('player-hit', …)` on contact |
|
|
103
|
+
|
|
104
|
+
`npx molen audio plan scene.json --ticks 300 --commands commands.json` prints what each one plays.
|
|
105
|
+
In a copy made with `--template`, fetch the sounds first with
|
|
106
|
+
`npx molen pack fetch https://molen.dev/packs/index.json molen.sounds --out-dir public/packs`.
|
|
107
|
+
See [Sound and music](audio.md).
|
|
108
|
+
|
|
92
109
|
These are compact single-player examples, not demonstrations of authoritative remote servers,
|
|
93
110
|
network prediction, vehicle suspension, full tabletop rules, or large-world streaming. The
|
|
94
111
|
world-explorer and terrain-flyover samples remain the terrain starting points.
|