@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
|
@@ -0,0 +1,492 @@
|
|
|
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
|
+
- traffic, pedestrians, trains and aircraft that come and go around the viewer;
|
|
9
|
+
- orbit, walk, drive and fly navigation, with cars and aircraft the host can put the viewer in;
|
|
10
|
+
- markers placed by latitude/longitude;
|
|
11
|
+
- sky, haze and adaptive quality.
|
|
12
|
+
|
|
13
|
+
You speak latitude and longitude; the view keeps its metric world frame internally.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import {
|
|
17
|
+
loadEarthContent,
|
|
18
|
+
mountEarthView,
|
|
19
|
+
openPacksFromIndex,
|
|
20
|
+
} from '@bendyline/molen-earth/client';
|
|
21
|
+
|
|
22
|
+
const manifestUrl = new URL('/terrain/terrain-package.json', location.href);
|
|
23
|
+
const terrain = await (await fetch(manifestUrl)).json();
|
|
24
|
+
const content = await loadEarthContent(await openPacksFromIndex('/packs/index.json'));
|
|
25
|
+
|
|
26
|
+
canvas.tabIndex = 0;
|
|
27
|
+
const view = await mountEarthView({
|
|
28
|
+
canvas,
|
|
29
|
+
terrain,
|
|
30
|
+
baseUrl: manifestUrl,
|
|
31
|
+
content,
|
|
32
|
+
camera: { latitude: 47.6205, longitude: -122.3493, range: 1500, heading: 0.8, pitch: 0.55 },
|
|
33
|
+
workers: {
|
|
34
|
+
elevation: () => new Worker(new URL('./elevation.worker.ts', import.meta.url), { type: 'module' }),
|
|
35
|
+
worldgen: () => new Worker(new URL('./worldgen.worker.ts', import.meta.url), { type: 'module' }),
|
|
36
|
+
},
|
|
37
|
+
touchJoystickContainer: canvas.parentElement ?? undefined,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
view.setMarkers([{ id: 'needle', latitude: 47.6205, longitude: -122.3493, image: pinCanvas }]);
|
|
41
|
+
view.on('markerclick', ({ id }) => openArticle(id));
|
|
42
|
+
view.on('camerachange', (camera) => syncMap(camera.latitude, camera.longitude));
|
|
43
|
+
creditsElement.textContent = view.credits.map((credit) => credit.label).join(' · ');
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Each worker file is one line, for example `import '@bendyline/molen-earth/workers/elevation';`.
|
|
47
|
+
There are entries for `elevation`, `landcover`, `surface`, `worldgen` and `material`. Any worker
|
|
48
|
+
you omit does its work on the main thread instead.
|
|
49
|
+
|
|
50
|
+
Buildings appear with vertex colors while shared material textures bake in the background.
|
|
51
|
+
Completed textures update the existing materials without regenerating buildings. Terrain detail
|
|
52
|
+
refines in small groups, retaining visible detail during camera turns while replacements load.
|
|
53
|
+
|
|
54
|
+
Metal and glass use a shared procedural sky/ground reflection environment by default. The viewer
|
|
55
|
+
reuses its filtered texture until lighting changes; camera movement does not regenerate it.
|
|
56
|
+
Pass `reflections: false` for the legacy light-only appearance. A host-assigned
|
|
57
|
+
`view.viewer.renderer.scene.environment` takes precedence if you supply your own HDR environment.
|
|
58
|
+
|
|
59
|
+
`style` sets the look: `sky.sunElevation` and `sky.sunAzimuth` (degrees; the azimuth is a
|
|
60
|
+
compass bearing, 0 north and clockwise) place the sun, and unless `environment.sun.direction` is
|
|
61
|
+
given the sunlight comes from the same point, so lit faces agree with the glow in the sky. `fog`,
|
|
62
|
+
`water`, `background` and the rest of `environment` (ambient light, tone mapping, exposure) follow.
|
|
63
|
+
|
|
64
|
+
`touchJoystickContainer` adds an on-screen movement stick while walking, driving or flying. By default it
|
|
65
|
+
appears only on touch devices; pass `touchJoystick: 'always'` to show it everywhere.
|
|
66
|
+
|
|
67
|
+
## Modes
|
|
68
|
+
|
|
69
|
+
- **orbit** (default): the map camera from [camera navigation](navigation.md). `flyTo(target)`
|
|
70
|
+
animates and `jumpTo(target)` moves at once. The target takes `latitude`, `longitude`, and
|
|
71
|
+
optionally `range` in meters, `heading` (a compass bearing in radians) and `pitch` (radians of
|
|
72
|
+
tilt below the horizon).
|
|
73
|
+
- **walk**: `setMode('walk')` drops a walker at the view center. It has capsule collision against
|
|
74
|
+
terrain, buildings and props, WASD or the touch stick to move, mouse-look with pointer lock, and
|
|
75
|
+
Space to jump.
|
|
76
|
+
- **drive**: while walking, press E (or `setMode('drive')`) next to a parked car to get in. W/S
|
|
77
|
+
drive, A/D steer, Space brakes, V switches between cockpit and chase views, and E gets out. A car
|
|
78
|
+
at rest with no throttle holds itself, even on a slope. Cars come from the entities content
|
|
79
|
+
pack. `message` events explain when entering or leaving is blocked, for example "Move closer to
|
|
80
|
+
the door". From any mode, `setMode('drive', { vehicle: true })` puts the viewer in a car in the
|
|
81
|
+
nearest mapped road lane (or `vehicle: '<entity type id>'` for a particular car).
|
|
82
|
+
- **fly**: `setMode('fly')` starts an aircraft from the entities pack (the P-51D, or
|
|
83
|
+
`{ aircraft: 'molen.entities.aircraft.oh6' }` for the helicopter) already flying: engine
|
|
84
|
+
running, gear up, heading the way the view faced. From orbit it starts a little behind the view,
|
|
85
|
+
flying toward it, at a height matched to the orbit camera; `airborne: { altitude, speed }`
|
|
86
|
+
chooses meters above the ground and m/s, and `airborne: false` parks it on the ground with the
|
|
87
|
+
engine off. The `pilot` input profile flies it (see [navigation](navigation.md)); V switches
|
|
88
|
+
cockpit and chase views, R recovers after an impact (`view.recover()`), and E leaves once it
|
|
89
|
+
has landed, stopped and shut down. See [aircraft](aircraft.md) for the flight model.
|
|
90
|
+
|
|
91
|
+
Drive and fly need the ground under their start, and drive a road lane, so `setMode` switches at
|
|
92
|
+
once and boards when that has streamed in, keeping the orbit camera on the spot meanwhile. With no
|
|
93
|
+
lane after a few seconds the car takes the nearest open ground, never a roof, deck or catalogued
|
|
94
|
+
landmark. Leaving follows the vehicle's rules (stop, land, shut down); a host control such as a
|
|
95
|
+
mode menu passes `{ force: true }` to step out at once, which also removes a vehicle `setMode`
|
|
96
|
+
added.
|
|
97
|
+
|
|
98
|
+
`view.vehicleStatus()` describes the car or aircraft the viewer is in for a HUD: speed and
|
|
99
|
+
heading for a car; airspeed, altitude and height above ground, vertical speed, attitude, power,
|
|
100
|
+
engine, gear, flaps and stall/impact flags for an aircraft (SI units, compass radians).
|
|
101
|
+
`view.setThrottle(power)` sets an aircraft's throttle or collective from an on-screen lever.
|
|
102
|
+
|
|
103
|
+
Listen for `modechange`. The input profile, clip planes and touch stick follow the mode
|
|
104
|
+
automatically.
|
|
105
|
+
|
|
106
|
+
## Frames and long trips
|
|
107
|
+
|
|
108
|
+
Heights stay in meters. Horizontal distances are exact at the frame latitude and drift away from it
|
|
109
|
+
by about 1.75% × tan(latitude) per degree: 1% at 30°, 1.5% at 40°, 2% at Seattle's 47.6°, 3% at 60°
|
|
110
|
+
(see [terrain](terrain.md)). The view anchors its frame at the starting latitude. After a `flyTo`
|
|
111
|
+
of more than about a degree north or south, or after panning that far, it re-anchors: it rebuilds
|
|
112
|
+
the terrain stack in a new frame at the destination while keeping the viewer, input and markers.
|
|
113
|
+
Walking, driving and flying keep their frame, so a long flight north or south slowly stretches
|
|
114
|
+
distances by the same rule; return to orbit to re-anchor. With `terrainSource`, a longitude-only trip also checks
|
|
115
|
+
the destination's terrain region. `stats().frameLatitude` reports the current anchor.
|
|
116
|
+
|
|
117
|
+
## Content and packages
|
|
118
|
+
|
|
119
|
+
Without `content` the view still draws terrain, water, roads and extruded buildings. Content packs
|
|
120
|
+
add styled architecture, recognizable businesses, street furniture, trees and drivable cars:
|
|
121
|
+
|
|
122
|
+
- `openPacksFromIndex(indexUrl)` opens `molen.entities`, `molen.worldgen.default`, `molen.earth`,
|
|
123
|
+
`molen.sky` and `molen.sounds` from a pack index you host.
|
|
124
|
+
- `loadEarthContent(packs)` reads them. A missing pack turns its feature off instead of failing.
|
|
125
|
+
|
|
126
|
+
`openPacksFromIndex(indexUrl, ids, fetchImpl)` accepts a host fetch implementation for the index,
|
|
127
|
+
archive opening and subsequent asset requests. Landmark model bytes are loaded as nearby
|
|
128
|
+
placements need them. Large packs require HTTP Range support to retrieve those bytes selectively:
|
|
129
|
+
serve range requests with `206 Partial Content` and a correct `Content-Range` header (expose that
|
|
130
|
+
header through CORS when hosting across origins). A server returning `200 OK` for a range request
|
|
131
|
+
uses the compatible whole-file fallback, which downloads the entire archive before models can
|
|
132
|
+
load. Packs below the small-pack threshold are intentionally fetched in one request.
|
|
133
|
+
|
|
134
|
+
The world-explorer sample builds the worldgen collection as a small style core plus regional
|
|
135
|
+
model archives. All material graphs, style documents, asset sidecars and catalogs remain in
|
|
136
|
+
`molen.worldgen.default`. Its `model-archives` document routes the existing model paths to
|
|
137
|
+
deterministic geohash2 archives, split at a256MiB source-byte budget. Larger individual models
|
|
138
|
+
use isolated archives with a hard512MiB limit. Generic models without a geographic anchor use
|
|
139
|
+
separate shared archives. The public documentation site uses the same builder and route format.
|
|
140
|
+
The build reads and compresses one shard at a time, avoiding the ZIP32 size limit and the
|
|
141
|
+
memory cost of assembling the whole world's models in one archive.
|
|
142
|
+
|
|
143
|
+
`openPacksFromIndex` recognizes the routing document automatically. It opens no regional archive
|
|
144
|
+
until a model is requested, sends its range requests through the same host `fetchImpl`, and
|
|
145
|
+
checks the archive identity and content hash plus each model's SHA-256. Seattle placements
|
|
146
|
+
therefore do not open Chicago's archives. Archive opens are deduplicated; failed opens can be
|
|
147
|
+
retried; idle archive handles and their byte caches are evicted after four open archives.
|
|
148
|
+
Active reads remain pinned. `content.packs.close()` aborts reads and closes all regional handles.
|
|
149
|
+
This is independent of the viewer's GPU model residency and tile unloading.
|
|
150
|
+
|
|
151
|
+
Existing monolithic packs work unchanged. Hosts opening cores from offline storage can call
|
|
152
|
+
`withModelArchives(core, async (id, contentHash, signal) => openYourPack(id, contentHash, signal))`
|
|
153
|
+
before `loadEarthContent`; its optional `maxOpenArchives` controls the idle cache. The wrapper's
|
|
154
|
+
manifest describes the physical core, while `has`, `paths` and reads also expose explicitly
|
|
155
|
+
routed model paths. Ordinary `pack:molen.worldgen.default/...` references continue to resolve.
|
|
156
|
+
The builder publishes the index after all shards and keeps old hash-named archives for viewers
|
|
157
|
+
already using them; deployment storage may retire those versions after its cache lifetime.
|
|
158
|
+
|
|
159
|
+
The terrain package can reference split archive families (`pmtiles-set` sources), or you can pass
|
|
160
|
+
your own transports as `archives.elevation`, `archives.landcover` and `archives.features`. That is
|
|
161
|
+
how a host routes tiles through offline packs or a retrying reader.
|
|
162
|
+
|
|
163
|
+
For a viewer that can travel between separately hosted regions, provide `terrainSource` instead
|
|
164
|
+
of a fixed `terrain`. Molen calls it for the initial camera and after geographic travel. The host
|
|
165
|
+
returns a package manifest plus URLs or archive transports; Molen replaces the terrain stream,
|
|
166
|
+
semantic layers, and local frame while keeping the viewer and navigation alive. A stable `key`
|
|
167
|
+
identifies a region, so returning the same key for a nearby move keeps its resident tiles.
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
const view = await mountEarthView({
|
|
171
|
+
canvas,
|
|
172
|
+
content,
|
|
173
|
+
camera: { latitude: 47.6205, longitude: -122.3493, range: 1500 },
|
|
174
|
+
terrainSource: async ({ latitude, longitude }, signal) => {
|
|
175
|
+
const region = chooseRegion(latitude, longitude);
|
|
176
|
+
const url = new URL(`/terrain/${region}/terrain-package.json`, location.href);
|
|
177
|
+
const response = await fetch(url, { signal });
|
|
178
|
+
if (!response.ok) throw new Error(`Terrain ${region}: HTTP ${response.status}`);
|
|
179
|
+
return { key: region, terrain: await response.json(), baseUrl: url };
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The host can return `archives` in the result to fetch tiles from its own PMTiles service. Keep
|
|
185
|
+
pack attribution visible through `view.credits`, which follows the active terrain source. Listen
|
|
186
|
+
for `terrainchange` to refresh an attribution panel when the package changes. Direct jumps and
|
|
187
|
+
completed flights resolve the destination immediately; manual panning rechecks the host source
|
|
188
|
+
after about five kilometers. A second jump while a region is loading follows the latest target.
|
|
189
|
+
|
|
190
|
+
## Ambient life
|
|
191
|
+
|
|
192
|
+
Cars drive the mapped roads, pedestrians walk the footways, trains run the railways and aircraft
|
|
193
|
+
pass overhead. They appear out of sight around the viewer and leave once it moves on. The layer is
|
|
194
|
+
on by default:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
const view = await mountEarthView({ canvas, terrain, content, camera, ambient: { density: 0.4 } });
|
|
198
|
+
view.setAmbientEnabled(false);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
`density` runs from 0 to 1 (default 0.6). `cars`, `pedestrians`, `rail` and `aircraft` switch a
|
|
202
|
+
class off, and `ambient: false` removes the layer. The quality tier caps how many agents run and
|
|
203
|
+
how many cars get full models. With the entities pack in `content`, vehicles use its car, bus,
|
|
204
|
+
light-rail and airliner models near the camera. The car you drive stops against ambient traffic,
|
|
205
|
+
and traffic waits for it. See [Ambient life](ambient-life.md) for the tier table and how the
|
|
206
|
+
simulation works.
|
|
207
|
+
|
|
208
|
+
## Geographic structures and regional styles
|
|
209
|
+
|
|
210
|
+
The Earth pack may provide a `molen/structure-placements@1` document. Each record binds a
|
|
211
|
+
WGS84 `[longitude, latitude]` anchor to an asset ID from the style pack, with an optional
|
|
212
|
+
heading, scale, terrain or sea-level datum, and minimum tile level. The Earth viewer loads the
|
|
213
|
+
catalog with the packs, indexes it by three-character geohash, and draws each `preview` model
|
|
214
|
+
in the terrain tile containing its anchor. `draft` records remain queryable but are not drawn.
|
|
215
|
+
Long structures may supply `bounds: [west, south, east, north]`. Their extent is indexed across
|
|
216
|
+
geohash cells and geometry is clipped to each resident tile, so a bridge end stays visible when
|
|
217
|
+
its center is outside the view. Extended structures use either `datum: 'sea-level'` with an
|
|
218
|
+
absolute `elevation`, or a `terrainReference` with the host sampler described below. Every
|
|
219
|
+
tile must resolve the same model origin, avoiding inconsistent ground samples between tiles.
|
|
220
|
+
`replaceRoads: { length, width, deckHeight?, deckHeights? }` describes a model-local rectangle along +X:
|
|
221
|
+
mapped parallel bridge lines inside it are replaced only after the model loads successfully.
|
|
222
|
+
Outside approach fragments remain procedural. `deckHeight` joins those approaches to the
|
|
223
|
+
model's deck height above its origin, blending back over 100 m; include that margin in `bounds`.
|
|
224
|
+
For sloped decks, use `deckHeights: [negativeXEnd, positiveXEnd]` instead of `deckHeight`.
|
|
225
|
+
Both heights are native model Y and follow the model's Y scale, resolved origin and heading.
|
|
226
|
+
These joins apply to remaining bridge-tagged road fragments, not unrelated ground roads.
|
|
227
|
+
Skewed or curved structures may add `replaceRoads.outline: [[x, z], ...]`, a simple native
|
|
228
|
+
footprint polygon. It replaces the rectangle for suppression, including concave bends;
|
|
229
|
+
parallel road segments outside it remain intact. `length` still locates the two connection
|
|
230
|
+
stations at native X=-length/2 and X=+length/2, Z=0, and `deckHeights` keeps that endpoint order.
|
|
231
|
+
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.
|
|
232
|
+
|
|
233
|
+
### Bridge elevations and terrain fit
|
|
234
|
+
|
|
235
|
+
With the default `datum: 'terrain'`, a placement's origin Y is the sampled terrain height at
|
|
236
|
+
`anchor` plus `elevation` (default zero). That works for a model authored with its ground contact
|
|
237
|
+
at Y=0. A bridge authored from a riverbed or buried foundation needs a corresponding reference:
|
|
238
|
+
a coarse elevation grid may contain the road surface or smooth the gorge across several pixels.
|
|
239
|
+
Increasing tile zoom cannot recover relief absent from the source elevation data.
|
|
240
|
+
|
|
241
|
+
For a measured model origin, use `datum: 'sea-level'` and set `elevation` to its absolute height
|
|
242
|
+
in the same vertical reference as the host terrain. This bypasses terrain sampling and gives every
|
|
243
|
+
clipped portion of a long bridge the same vertical position. The name `sea-level` selects the
|
|
244
|
+
world's absolute Y frame; it does not convert between EGM96, EGM2008, a local survey datum or an
|
|
245
|
+
ellipsoidal height. The host must perform that conversion before providing the value.
|
|
246
|
+
|
|
247
|
+
For a terrain placement referenced to another point, add
|
|
248
|
+
`terrainReference: { anchor: [longitude, latitude], modelHeight, basis }`. For example, a bank
|
|
249
|
+
at native Y=8 uses `modelHeight: 8`; the model origin becomes the reference elevation minus
|
|
250
|
+
`modelHeight * scaleY`, plus `elevation`. Record the source and meaning of that point in `basis`.
|
|
251
|
+
This field is incompatible with `datum: 'sea-level'`.
|
|
252
|
+
|
|
253
|
+
Hosts can supply `sampleStructureTerrain(coordinate, { entry, signal })` to `mountEarthView`,
|
|
254
|
+
`createEarthWorldgen`, or `createWorldgenSemanticRenderers`. It may return a height or a promise
|
|
255
|
+
and must use the same world height reference as the rendered terrain. Resolve the coordinate
|
|
256
|
+
from its own terrain tile or a surveyed source; honor `signal` when fetching. Returning
|
|
257
|
+
`undefined` means coverage is unavailable: the model remains unloaded and procedural map
|
|
258
|
+
features remain visible. Absolute placements bypass this callback. Without a host callback,
|
|
259
|
+
the renderer samples only a reference inside the current tile, never its clamped edge.
|
|
260
|
+
An extended terrain structure (`bounds` plus `terrainReference`) requires this host callback;
|
|
261
|
+
without it, all its model pieces remain deferred and their procedural fallback stays visible.
|
|
262
|
+
The callback must resolve the same reference height for every clipped tile. A bank reference
|
|
263
|
+
therefore also works when the landmark anchor lies over unknown river elevation cells.
|
|
264
|
+
For loaded terrain, the pyramid stream's `sampleHeight` searches covering resident tiles
|
|
265
|
+
and returns `undefined` when none covers the point. A host that requires guaranteed cross-tile
|
|
266
|
+
references should retrieve those source tiles independently of the current visible tile set.
|
|
267
|
+
|
|
268
|
+
Check the approaches and channel in addition to the model origin. A bridge may have the correct
|
|
269
|
+
height while a host's elevation data still fails to represent its banks. Supply better local
|
|
270
|
+
elevation data through the terrain archives for that case. The reference hook changes model
|
|
271
|
+
placement; it does not modify a smoothed river channel. A `groundCutout` removes covered terrain
|
|
272
|
+
but does not reconstruct riverbanks, water levels, or a riverbed. The source repository includes a
|
|
273
|
+
repeatable real-terrain review: `build-bridge-terrain-evidence.mjs` preserves original Terrarium
|
|
274
|
+
samples, and `test/visual/capture-bridge-terrain.mjs` in the world-explorer example uses the
|
|
275
|
+
production terrain mesher and structure renderer, records approach ray measurements, and checks
|
|
276
|
+
model eviction. `build-copernicus-bridge-evidence.py` and the capture runner's
|
|
277
|
+
`--terrain-set=copernicus` option preserve a separate comparison with Copernicus elevations;
|
|
278
|
+
neither capture set substitutes altered heights to make a bridge fit. These reports are research
|
|
279
|
+
evidence and are excluded from the Earth runtime pack.
|
|
280
|
+
|
|
281
|
+
If `replaceFootprint` is set, a nongeneralized mapped building is suppressed only when the
|
|
282
|
+
anchor falls inside its polygon and the replacement model has loaded. Failed models keep the
|
|
283
|
+
procedural building. An Earth pack without a placement document still loads.
|
|
284
|
+
|
|
285
|
+
For unsurveyed orientation, `orientation: 'mapped'` requires an explicit
|
|
286
|
+
`mapIdentity: { wikidata: 'Q…', maxDistance: 150 }`. The viewer admits that model only after a
|
|
287
|
+
nearby matching building, directed POI, or bridge supplies an orientation. Exact name aliases
|
|
288
|
+
are supported only when the catalog supplies no Wikidata ID. A footprint's longest edge gives
|
|
289
|
+
an undirected axis, not proof of the entrance direction. `lengthAxis: 'x' | 'z'` identifies the
|
|
290
|
+
authored longitudinal axis. Entries with surveyed catalog headings use `orientation: 'fixed'`
|
|
291
|
+
(the default). No matching geometry means no speculative placement for a mapped entry.
|
|
292
|
+
|
|
293
|
+
### Reusable mapped categories
|
|
294
|
+
|
|
295
|
+
An Earth pack can list multiple `provides.structures` documents. Alongside geographic `entries`,
|
|
296
|
+
each document may contain `rules` for deliberately generic assets. The shipped
|
|
297
|
+
`structures/map-rules.json` recognizes windmills and wind turbines from class, subclass, or
|
|
298
|
+
explicit map tags. Unique named landmarks never become arbitrary category replacements.
|
|
299
|
+
|
|
300
|
+
```json
|
|
301
|
+
{
|
|
302
|
+
"id": "generic.windmill",
|
|
303
|
+
"title": "Smock windmill",
|
|
304
|
+
"asset": "molen.worldgen.structure.map_smock_windmill",
|
|
305
|
+
"match": { "classes": ["windmill"] },
|
|
306
|
+
"dimensions": [23.3, 30.6, 16.5],
|
|
307
|
+
"orientation": "direction",
|
|
308
|
+
"fit": "native",
|
|
309
|
+
"minLevel": 14,
|
|
310
|
+
"maxPerTile": 16,
|
|
311
|
+
"source": "https://wiki.openstreetmap.org/wiki/Tag:man_made%3Dwindmill"
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Match fields are AND conditions; the values within a field are alternatives. Put separate
|
|
316
|
+
rules in priority order for alternative source schemas. `dimensions` are authored X/Y/Z meters
|
|
317
|
+
with the base at Y=0 and front along +Z. `fit: 'footprint'` fits horizontal dimensions to a
|
|
318
|
+
confirmed nongeneralized building; `native` retains authored proportions. Measured heights
|
|
319
|
+
uniformly scale native models, bounded from 0.2 to 5 times native dimensions; footprint fitting
|
|
320
|
+
adjusts the three dimensions independently. Explicit source `direction`
|
|
321
|
+
or compass bearings take priority; otherwise footprints use their longest axis and points
|
|
322
|
+
default north. This default is an estimate, especially for rotatable turbine nacelles.
|
|
323
|
+
Rules with `replaceFootprint: true` can also replace a nongeneralized footprint containing a
|
|
324
|
+
matching POI, after the asset loads. This is useful when a windmill is a POI plus an unclassified
|
|
325
|
+
building outline; the default leaves point features independent of building shells.
|
|
326
|
+
|
|
327
|
+
The renderer admits at most 64 category models per tile and obeys each rule's smaller budget.
|
|
328
|
+
It owns points with half-open tile bounds, deduplicates building/POI pairs and nearby named
|
|
329
|
+
landmarks, samples terrain at each model base, and releases shared model resources on tile
|
|
330
|
+
eviction. Rules require source classification evidence: a cafe with “Windmill” in its name is
|
|
331
|
+
not a windmill. Providers that omit POIs, classifications, or structure tags cannot imply that
|
|
332
|
+
object. The semantic decoder preserves public structure tags and Wikidata IDs when supplied.
|
|
333
|
+
|
|
334
|
+
`content.worldgen.structures.query([west, south, east, north])` returns preview placements in a
|
|
335
|
+
geographic rectangle. Pass `true` as the second argument to include drafts. The default
|
|
336
|
+
catalog and its source notes live in `content/earth/structures/placements.json` in the engine
|
|
337
|
+
repository. Named model sources and previews live in
|
|
338
|
+
`content/worldgen/source/places/<gh2>/<gh3>/<source-key>/`; imported runtime bundles mirror
|
|
339
|
+
that organization under `content/worldgen/assets/places/<gh2>/<gh3>/<source-key>/`.
|
|
340
|
+
Each runtime bundle contains `asset.json`, `model.glb`, and any collision data. Reusable models
|
|
341
|
+
use `assets/reusable/urban/<source-key>/`, `assets/reusable/infrastructure/<source-key>/`, or
|
|
342
|
+
`assets/reusable/map-structures/<source-key>/`. The two geographic folders are geohashes of
|
|
343
|
+
length two and three. New named entries without an organizational anchor start in `places/unlocated/`.
|
|
344
|
+
|
|
345
|
+
`content/worldgen/source/structure-index.json` resolves source keys to authoring directories.
|
|
346
|
+
The runtime mappings are separate: `content/worldgen/project.json` registers stable asset IDs
|
|
347
|
+
to sidecars for tooling, and `content/worldgen/stylepack.json` registers the same IDs for pack
|
|
348
|
+
resolution through `stylePackAssetIndex`. Asset IDs remain unchanged when folders move;
|
|
349
|
+
hosts resolve these mappings instead of deriving a model URL from the dotted ID. Folder
|
|
350
|
+
reference coordinates organize files and do not approve or activate geographic placement.
|
|
351
|
+
The terrain stream queries only cells intersecting resident tiles. Chicago models are not fetched
|
|
352
|
+
while viewing Seattle; a structure model is released from CPU and GPU memory when the last tile
|
|
353
|
+
using it leaves view. Returning to the area loads it again. Draft entries never fetch models.
|
|
354
|
+
|
|
355
|
+
Historical reconstructions use `status: 'historical'` and an `appearance` record:
|
|
356
|
+
|
|
357
|
+
```json
|
|
358
|
+
{
|
|
359
|
+
"kind": "historical",
|
|
360
|
+
"currentWorldEligible": false,
|
|
361
|
+
"representedDate": "1930",
|
|
362
|
+
"validFrom": "1926-01-06",
|
|
363
|
+
"validUntil": "1934-04-01"
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
They remain unloaded in the default view. A host explicitly passes `viewingDate: '1930-01-01'`
|
|
368
|
+
to `mountEarthView`, `createEarthWorldgen`, or `createWorldgenSemanticRenderers` to include
|
|
369
|
+
historical assets for that day. The lower-level index accepts
|
|
370
|
+
`query(bounds, { viewingDate: '1930-01-01' })`. Dates must be valid `YYYY-MM-DD` calendar dates;
|
|
371
|
+
the first bound is inclusive and the last is exclusive. Date selection is independent of the
|
|
372
|
+
system clock and sky simulation. Remount the viewer to change it. Historical assets retain
|
|
373
|
+
geographic tile filtering, deferred loading, fallback on failed loads, and eviction cleanup.
|
|
374
|
+
|
|
375
|
+
This option selects dated landmark appearances. Hosts supply matching historical PMTiles and
|
|
376
|
+
terrain when needed; undated present-day map features and preview landmarks have no inferred
|
|
377
|
+
historical lifetime. For source authoring, combine `appearance` with a
|
|
378
|
+
`geographicProposal.status: 'historical-proposal'` and the usual reviewed ground contact and
|
|
379
|
+
placement evidence. Older historical sources without a complete supported date interval remain
|
|
380
|
+
drafts. Shared placement QA uses `capture-landmark-library.mjs --viewing-date=1930-01-01` and
|
|
381
|
+
records the explicit date in its hash-bound report.
|
|
382
|
+
|
|
383
|
+
Geographic and category models use `StructureModelLibrary`, preserving the authored mesh
|
|
384
|
+
hierarchy, UV coordinates, texture maps, material assignments and PBR parameters. Instances
|
|
385
|
+
share those resources until the last reference is released. Long static models retain their
|
|
386
|
+
UVs, vertex attributes and material groups when clipped at tile edges; textures do not restart
|
|
387
|
+
at each seam. The library accepts static assets: skinned or animated structures require a host
|
|
388
|
+
animation implementation. Procedural scatter continues to use the separate instanced prop path.
|
|
389
|
+
|
|
390
|
+
### Shared architectural surfaces
|
|
391
|
+
|
|
392
|
+
Authored GLB materials can opt into the same texture library as procedural buildings. Set
|
|
393
|
+
the material's glTF `extras.molenSurface` (available as Three.js material `userData.molenSurface`):
|
|
394
|
+
|
|
395
|
+
```json
|
|
396
|
+
{
|
|
397
|
+
"ref": "matgraph:molen.worldgen.material.wood_painted_lap",
|
|
398
|
+
"slot": "wall",
|
|
399
|
+
"uv": "repeats"
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
`encodeGlb` exposes this as `GlbMaterialMeta.sharedSurface`. Author UV0 in texture repeats:
|
|
404
|
+
divide local surface coordinates in meters by the material's `repeatMeters` once during
|
|
405
|
+
authoring. Wood grain must follow the timber; masonry courses remain horizontal. Put color
|
|
406
|
+
variants in vertex colors with a white base-color factor, so white painted wood and green
|
|
407
|
+
painted wood share the same maps and material. Model-specific artwork and special PBR effects
|
|
408
|
+
keep their original unbound materials. GLBs retain portable fallback PBR materials for other
|
|
409
|
+
viewers and ordinary asset previews; the Earth viewer applies shared surfaces explicitly.
|
|
410
|
+
|
|
411
|
+
The default library has 65 procedural surfaces, including brick bonds, stone, timber, painted
|
|
412
|
+
wood, shingles, concrete, metal, plaster, glass and canvas. Its authoring catalog, physical
|
|
413
|
+
repeat sizes, tint variants, swatches and texture audit live in
|
|
414
|
+
`content/worldgen/source/material-library/` in the engine repository. Color variants do not
|
|
415
|
+
duplicate texture images. The current Earth viewer prepares the registered library after the
|
|
416
|
+
first frame and retains it until viewer disposal. Structure eviction releases model geometry
|
|
417
|
+
and private materials while preserving shared surfaces used by other structures. A separate
|
|
418
|
+
on-demand material eviction policy is not yet implemented.
|
|
419
|
+
|
|
420
|
+
Constant roughness and metalness channels use exact numeric factors instead of textures;
|
|
421
|
+
other maps retain their authored pixels. Across the full library this removes 58 texture
|
|
422
|
+
allocations, reducing estimated base-level RGBA8 texel storage from 45.75 to 31.25 MiB.
|
|
423
|
+
These are storage estimates, not measured driver allocations. Alpha-cutout surfaces retain
|
|
424
|
+
linear sampling without mip averaging so small perforations remain open.
|
|
425
|
+
|
|
426
|
+
Hosts composing their own renderer can supply `StructureModelLibrary` with
|
|
427
|
+
`resolveSurface: ({ ref, slot }) => materials.materialFor(slot, ref)` using a
|
|
428
|
+
`createResolvedMaterialSet` instance. Restrict references to the host's registered material
|
|
429
|
+
library and keep it alive until all structure libraries have been disposed. Missing bindings
|
|
430
|
+
or UVs preserve the GLB fallback. A new bake upgrades progressive materials in place without
|
|
431
|
+
rebuilding model geometry.
|
|
432
|
+
|
|
433
|
+
`StructureModelLibrary` preserves host ownership of decoded ImageBitmaps by default. Its
|
|
434
|
+
`ownsImageBitmaps: true` option explicitly transfers ownership, allowing unused
|
|
435
|
+
fallback images to close after shared-material replacement and remaining images to close
|
|
436
|
+
after their last scene is released. A per-scene predicate can transfer ownership selectively.
|
|
437
|
+
The built-in Earth loader opts in only when every image uses an embedded bufferView: these
|
|
438
|
+
decode through fresh blob URLs excluded from Three's cache. Scenes with URI/data-URI images
|
|
439
|
+
retain host ownership, including mixed scenes. A fresh parse alone does not establish ownership
|
|
440
|
+
of images that may come from an external cache.
|
|
441
|
+
|
|
442
|
+
Mapped roads with `bridge: true` receive solid decks, edge barriers and regularly spaced
|
|
443
|
+
supports in the shared terrain surface renderer, including its worker path. Road, rail and
|
|
444
|
+
pedestrian spans follow mapped centerlines and widths; tunnels are omitted. Complete spans
|
|
445
|
+
interpolate between bank heights and connect to adjoining ground roads. Clipped spans use
|
|
446
|
+
estimated terrain clearance (6 m for roads/rail, 3 m for paths); a semantic provider can set
|
|
447
|
+
`deckElevation` to an absolute surveyed height. These are visual approximations: tile data
|
|
448
|
+
does not establish bridge engineering type, navigation clearance, foundations or collision.
|
|
449
|
+
The SR-520 preview replaces the floating section; its approaches use this same fallback.
|
|
450
|
+
|
|
451
|
+
Regional procedural styles are separate from exact structures. The atlas's ordered rules use
|
|
452
|
+
mapped building class, footprint size, context, and known height to choose a style. A rule can
|
|
453
|
+
give weighted variants, sampled from a stable building identity, so a neighborhood has a
|
|
454
|
+
repeatable mix. `suggestStructureStyles(atlas, longitude, latitude, metrics)` from
|
|
455
|
+
`@bendyline/molen-worldgen-earth/kernel` exposes the matching weights and normalized shares for
|
|
456
|
+
inspection. The Pacific Northwest's unmeasured low-rise mix includes wood-sided PNW houses,
|
|
457
|
+
Craftsman, brick Prairie, and Ranch forms; Japan and broader regions have their own rules.
|
|
458
|
+
These regional forms are visual priors, not surveyed attributes of individual buildings.
|
|
459
|
+
|
|
460
|
+
## Credits, quality, lifecycle
|
|
461
|
+
|
|
462
|
+
- `view.credits` holds the package's required attributions, OpenStreetMap first with its link.
|
|
463
|
+
Keep them visible whenever the view is.
|
|
464
|
+
- `quality: 'auto'` adapts terrain budgets, building detail and pixel ratio to measured frame
|
|
465
|
+
times (`stats().qualityLevel`, 0-5). A preset pins the quality.
|
|
466
|
+
- `setPaused(true)` stops rendering while the view is hidden, and `dispose()` releases the GPU
|
|
467
|
+
context, workers and listeners. Mounting is abortable through `signal`.
|
|
468
|
+
|
|
469
|
+
## Sound
|
|
470
|
+
|
|
471
|
+
With the `molen.sounds` pack in `content`, the view plays the Earth soundscape: rain and wind
|
|
472
|
+
from the weather, birds by day and crickets at night, traffic near streets, footsteps while
|
|
473
|
+
walking, and an engine on the car or aircraft you board. Birds, crickets and traffic come from
|
|
474
|
+
the ground, so they fade as the view rises above the terrain and are gone a few hundred meters
|
|
475
|
+
up. Traffic also fades with distance from the nearest street. Sound starts on the first click or
|
|
476
|
+
key press. The `audioready` event fires once it has loaded, and then `view.audio` sets volume,
|
|
477
|
+
mute and bus gains (`view.audio.setBusGain('music', 0)` turns music off).
|
|
478
|
+
|
|
479
|
+
```ts
|
|
480
|
+
const view = await mountEarthView({ canvas, content, terrain, audio: { volume: 0.6, music: false } });
|
|
481
|
+
view.on('audioready', () => view.audio?.setMuted(localStorage.getItem('muted') === '1'));
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
Pass `audio: false` to keep the view silent, or `audio: { environment }` to replace the rules.
|
|
485
|
+
The default rules are exported as `EARTH_AUDIO_ENVIRONMENT`, and `createEarthAudio` builds the
|
|
486
|
+
same soundscape for a host that composes its own view. See [Sound and music](audio.md) for the
|
|
487
|
+
rule format.
|
|
488
|
+
|
|
489
|
+
The composing pieces are exported too, for hosts that build their own view: `createEarthWorldgen`,
|
|
490
|
+
`EarthVehicles`, `EarthAmbient` with `observeSemanticTiles`, `createEarthSky`/`createEarthFog`,
|
|
491
|
+
`createEarthAudio`, `earthPerformanceTier` and `earthCredits`.
|
|
492
|
+
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
|
|
|
@@ -56,3 +56,11 @@ sidecar, types document, project, or gallery scene is stale.
|
|
|
56
56
|
`molen.entities.aircraft.p51d` and `molen.entities.aircraft.oh6` add the Mustang and OH-6
|
|
57
57
|
helicopter, including GLBs, flight components and pilot seats. The pack's asset provider
|
|
58
58
|
serves them like any other model. See [Aircraft](aircraft.md) for world-view controls, physics and integration.
|
|
59
|
+
|
|
60
|
+
## Transit and background traffic
|
|
61
|
+
|
|
62
|
+
`molen.entities.transit.bus` is a 12 m city bus, `molen.entities.transit.lightrail` a 27 m
|
|
63
|
+
two-section light-rail car, and `molen.entities.aircraft.airliner` a narrow-body airliner. They are
|
|
64
|
+
models for background traffic, not mountable vehicles. [Ambient life](ambient-life.md) spawns them
|
|
65
|
+
through their `ambientRole` component, as it does the pack's five cars and the two aircraft above.
|
|
66
|
+
In the engine repository, `content/entities/scenes/transit.scene.json` shows them side by side.
|
|
@@ -5,9 +5,9 @@ meant to be copied. Three ways in, none of which needs a clone of the engine rep
|
|
|
5
5
|
|
|
6
6
|
- **Play** any sample in the browser at [molen.dev/play](https://molen.dev/play/).
|
|
7
7
|
- **Copy** a sample into your own npm project with `--template`. The templates ship inside
|
|
8
|
-
`@bendyline/molen-tooling`, locked to the
|
|
8
|
+
`@bendyline/molen-tooling`, locked to the package versions released with that CLI, 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
|
|
@@ -64,6 +65,9 @@ reference for streaming and for a glTF asset pipeline, so read them on GitHub.
|
|
|
64
65
|
adapter and region atlas; `/client` terrain tile renderers.
|
|
65
66
|
- **Figures** (`@bendyline/molen-figures`): `/kernel` descriptors, rigs, gaits, `figureState`,
|
|
66
67
|
sockets and attachments; `/client` the `figure` renderable kind (procedural skinned bodies).
|
|
68
|
+
- **Ambient life** (`@bendyline/molen-ambient`): `/kernel` transport networks, the spawn ring and
|
|
69
|
+
NPC cars, pedestrians, trains and aircraft; `/client` instanced vehicle proxies, pooled models
|
|
70
|
+
and pedestrian figures. See [ambient life](ambient-life.md).
|
|
67
71
|
|
|
68
72
|
## Start from scratch
|
|
69
73
|
|
|
@@ -111,6 +111,9 @@ State is written only when something changes: speed is quantized to 0.05 m/s, th
|
|
|
111
111
|
anchored to a tick, so a steadily walking figure sends no deltas. `figureIntent.mode` forces a
|
|
112
112
|
mode; `lookAt` aims the head at a point or an entity.
|
|
113
113
|
|
|
114
|
+
Pedestrians in [ambient life](ambient-life.md) are figures moved this way: the ambient kernel
|
|
115
|
+
writes their transform along footways and `speedSource: 'transform'` animates the gait.
|
|
116
|
+
|
|
114
117
|
## Sockets and attachments
|
|
115
118
|
|
|
116
119
|
Sockets are named points on the rig, evaluated under the current pose. An entity with
|
|
@@ -1,18 +1,19 @@
|
|
|
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
|
|---|---|---|---|
|
|
9
|
-
| City Courier | [molen.dev/play/city-courier](https://molen.dev/play/city-courier/) | Five deliveries, traffic, damage and a time limit | XZ kinematics, hierarchy, follow camera |
|
|
10
|
+
| City Courier | [molen.dev/play/city-courier](https://molen.dev/play/city-courier/) | Five deliveries, traffic, damage and a time limit | XZ kinematics, hierarchy, follow camera, ambient traffic |
|
|
10
11
|
| The Lantern Vault | [molen.dev/play/lantern-dungeon](https://molen.dev/play/lantern-dungeon/) | Key, melee combat, healing, gate and relic | XZ kinematics/raycast, seeded RNG, hierarchy, tween, local follow camera |
|
|
11
12
|
| Skybound | [molen.dev/play/skybound](https://molen.dev/play/skybound/) | Islands, seeds, stomps, hazards, checkpoint and finish | XY platform controller, hierarchy, world follow camera |
|
|
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.
|