@bendyline/molen-tooling 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/capture/harness.js +239 -236
  2. package/dist/capture/worldgen-preview.js +215 -215
  3. package/dist/cli.mjs +6 -5
  4. package/dist/docs-src/guide/adaptive-performance.md +5 -2
  5. package/dist/docs-src/guide/aircraft.md +113 -40
  6. package/dist/docs-src/guide/ambient-life.md +100 -11
  7. package/dist/docs-src/guide/audio.md +1 -1
  8. package/dist/docs-src/guide/boats.md +99 -0
  9. package/dist/docs-src/guide/determinism.md +1 -1
  10. package/dist/docs-src/guide/dioramas.md +167 -0
  11. package/dist/docs-src/guide/earth-view.md +241 -3
  12. package/dist/docs-src/guide/entities.md +32 -1
  13. package/dist/docs-src/guide/figures.md +7 -1
  14. package/dist/docs-src/guide/graphics-performance.md +16 -3
  15. package/dist/docs-src/guide/medium-fi.md +15 -6
  16. package/dist/docs-src/guide/sky.md +3 -2
  17. package/dist/docs-src/guide/surface-rendering.md +4 -1
  18. package/dist/docs-src/guide/vehicle-interiors.md +40 -2
  19. package/dist/docs-src/guide/vehicles.md +121 -19
  20. package/dist/docs-src/guide/weather.md +45 -3
  21. package/dist/docs-src/guide/worldgen.md +8 -0
  22. package/dist/docs-src/llms.txt +6 -4
  23. package/dist/docs-src/schemas/archstyle.md +114 -0
  24. package/dist/docs-src/schemas/components.md +1589 -137
  25. package/dist/docs-src/schemas/scene.md +6 -3
  26. package/dist/docs-src/schemas/transport-network.md +4 -2
  27. package/dist/index.mjs +1 -1
  28. package/dist/{mcp-BbHk4ibu.mjs → mcp-BbxqqnD1.mjs} +3 -2
  29. package/dist/{ops-CErtZh2t.mjs → ops-b4Pag8U-.mjs} +7 -5
  30. package/dist/templates/city-courier/README.md +18 -0
  31. package/dist/templates/city-courier/gen/molen-types.ts +217 -15
  32. package/dist/templates/city-courier/index.html +1 -1
  33. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +219 -17
  34. package/dist/templates/city-courier/src/audio.ts +26 -4
  35. package/dist/templates/city-courier/src/game-shell.css +7 -3
  36. package/dist/templates/city-courier/src/main.ts +25 -3
  37. package/dist/templates/city-courier/src/shared/accessibility.css +325 -0
  38. package/dist/templates/city-courier/src/shared/game-controls.ts +406 -0
  39. package/dist/templates/city-courier/src/shared/game-descriptions.ts +143 -0
  40. package/dist/templates/city-courier/src/shared/playback.ts +146 -0
  41. package/dist/templates/city-courier/src/worker.ts +5 -1
  42. package/dist/templates/cubes/index.html +6 -1
  43. package/dist/templates/cubes/src/main.ts +25 -2
  44. package/dist/templates/cubes/src/shared/accessibility.css +325 -0
  45. package/dist/templates/cubes/src/shared/playback.ts +146 -0
  46. package/dist/templates/cubes/src/vite-env.d.ts +1 -0
  47. package/dist/templates/cubes/src/worker.ts +1 -0
  48. package/dist/templates/data-viz/README.md +4 -0
  49. package/dist/templates/data-viz/index.html +6 -1
  50. package/dist/templates/data-viz/src/main.ts +53 -11
  51. package/dist/templates/data-viz/src/shared/accessibility.css +325 -0
  52. package/dist/templates/data-viz/src/shared/playback.ts +146 -0
  53. package/dist/templates/data-viz/src/vite-env.d.ts +1 -0
  54. package/dist/templates/data-viz/src/worker.ts +1 -0
  55. package/dist/templates/figures-gallery/index.html +6 -1
  56. package/dist/templates/figures-gallery/src/main.ts +21 -2
  57. package/dist/templates/figures-gallery/src/shared/accessibility.css +325 -0
  58. package/dist/templates/figures-gallery/src/shared/playback.ts +146 -0
  59. package/dist/templates/figures-gallery/src/vite-env.d.ts +1 -0
  60. package/dist/templates/figures-gallery/src/worker.ts +1 -0
  61. package/dist/templates/index.json +36 -16
  62. package/dist/templates/skybound/README.md +18 -0
  63. package/dist/templates/skybound/gen/molen-types.ts +217 -15
  64. package/dist/templates/skybound/index.html +1 -1
  65. package/dist/templates/skybound/scripts/molen-scripts.d.ts +219 -17
  66. package/dist/templates/skybound/src/audio.ts +26 -4
  67. package/dist/templates/skybound/src/game-shell.css +7 -3
  68. package/dist/templates/skybound/src/main.ts +25 -3
  69. package/dist/templates/skybound/src/shared/accessibility.css +325 -0
  70. package/dist/templates/skybound/src/shared/game-controls.ts +406 -0
  71. package/dist/templates/skybound/src/shared/game-descriptions.ts +143 -0
  72. package/dist/templates/skybound/src/shared/playback.ts +146 -0
  73. package/dist/templates/skybound/src/worker.ts +1 -1
  74. package/dist/templates/terrain-flyover/README.md +5 -1
  75. package/dist/templates/terrain-flyover/index.html +4 -1
  76. package/dist/templates/terrain-flyover/src/main.ts +40 -39
  77. package/dist/templates/top-down-arena/index.html +6 -1
  78. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +219 -17
  79. package/dist/templates/top-down-arena/src/audio.ts +26 -4
  80. package/dist/templates/top-down-arena/src/gen/molen-types.ts +217 -15
  81. package/dist/templates/top-down-arena/src/main.ts +31 -5
  82. package/dist/templates/top-down-arena/src/shared/accessibility.css +325 -0
  83. package/dist/templates/top-down-arena/src/shared/playback.ts +146 -0
  84. package/dist/templates/top-down-arena/src/worker.ts +1 -1
  85. package/package.json +12 -12
@@ -0,0 +1,167 @@
1
+ # Dioramas: scripted set pieces
2
+
3
+ A diorama is an ordinary `molen/scene@3` scene played inside a bounded local space: figures,
4
+ props and script choreography that make a place look alive. `@bendyline/molen-dioramas/kernel`
5
+ runs it headlessly; `/client` selects nearby placements and draws them in an existing viewer.
6
+ There is no second scripting language or football simulator. Use normal `molen.on('tick')`,
7
+ transforms, figure descriptors, timers, state and events.
8
+
9
+ The content pack includes a high-school football stage: two uniform palettes, fourteen helmeted
10
+ players running a repeated play, sixty seated/standing spectators, stands, goalposts and a
11
+ scoreboard with changing digits and a pulsing light. Its 24-second cycle lines up, runs,
12
+ celebrates and returns. The scores are decorative choreography. Content lives in the separate
13
+ `molen.dioramas` content pack, outside the npm runtime. Five more scenes stage an airport ramp,
14
+ little league, fireworks, a fair and a Saturday market. Every scene is a self-contained source
15
+ bundle with a typed script, local bounds and fixed entity pools.
16
+
17
+ ## Definition and local simulation
18
+
19
+ ```ts
20
+ import { createDiorama } from '@bendyline/molen-dioramas/kernel';
21
+
22
+ const playback = createDiorama({
23
+ scene, // validated scene data; scripts[].path resolved to scripts[].code
24
+ bounds: { min: [-72, -8, -52], max: [72, 24, 52] },
25
+ maxEntities: 512,
26
+ });
27
+ const initial = playback.keyframe();
28
+ const delta = playback.advance(1 / 30);
29
+ playback.dispose();
30
+ ```
31
+
32
+ Each instance owns a separate seeded world, script state, entity ids, figures, timers and RNG.
33
+ Two stadiums can use identical entity ids. Moving or rotating the stage never changes its local
34
+ simulation. Fixed ticks make the same scene/seed/tick count reproducible. Mark checkpoint-safe
35
+ scripts with `checkpoint: 'state'`; store durable values in components or `molen.state`.
36
+
37
+ Bounds are an axis-aligned box in local meters, Y up. After initialization and each tick, origins
38
+ are clamped to this box. Mesh extents can cross it: include an appropriate margin and author
39
+ paths inside it. This is an authoring guard, not collision or a security boundary. Scripts follow
40
+ the normal [script trust](scripting.md#script-trust-a-script-runs-as-the-host-process) contract.
41
+ The prototype supports scripted and kinematic scenes with figures; terrain, ambient networks
42
+ and Rapier remain outside it. It does not share collisions, input commands or audio with the host.
43
+
44
+ ## Lazy playback in a viewer
45
+
46
+ ```ts
47
+ import {
48
+ createDioramaVisual, DioramaDirector, loadDioramaScene,
49
+ } from '@bendyline/molen-dioramas/client';
50
+
51
+ const director = new DioramaDirector({
52
+ maxActive: 2,
53
+ create: (definition, placement) => createDioramaVisual(definition, placement, {
54
+ root: viewer.renderer.worldRoot,
55
+ camera: viewer.renderer.camera,
56
+ // assets: a host-owned AssetCache, when the scene uses glTF refs
57
+ }),
58
+ onError: (error, id) => console.error(id, error),
59
+ });
60
+ director.add({
61
+ id: 'school-field',
62
+ position: [120, 4, 200],
63
+ yaw: 0.4,
64
+ enterDistance: 350,
65
+ exitDistance: 420,
66
+ load: (signal) => loadDioramaScene(new URL('./football/scene.json', contentBase), {
67
+ min: [-72, -8, -52], max: [72, 24, 52],
68
+ }, signal),
69
+ // Optional host-selected event window, in UTC epoch milliseconds:
70
+ active: (timeMs) => timeMs >= eventStartMs && timeMs < eventEndMs,
71
+ });
72
+
73
+ // In the existing frame loop (camera position uses absolute world coordinates):
74
+ director.update(cameraPosition, elapsedSeconds, Date.now());
75
+ // On teardown:
76
+ director.dispose();
77
+ ```
78
+
79
+ The loader is a host callback: use an allowlisted dynamic import, HTTP URL or your pack reader.
80
+ The runtime never chooses content hosts. `loadDioramaScene` fetches the scene and relative `.js`
81
+ scripts with the supplied AbortSignal. For `.ts`, use `molenScripts()` with a lazy `?raw` import
82
+ and `inlineScriptSources`, or erase types when publishing the content. The scripting runtime is
83
+ itself dynamically imported on first activation. On a page that mounts with a top-level `await`,
84
+ add `@bendyline/molen-dioramas/client` (or `@bendyline/molen-earth/client`, when the page uses
85
+ `mountEarthView`) to the `vendor` chunk beside three.js and the client, as in
86
+ [Production builds](browser-mount.md#production-builds); otherwise the lazy runtime's chunk
87
+ imports the entry and never settles.
88
+
89
+ The director defaults to two active or loading instances, each with a default 512-entity budget.
90
+ Existing instances retain their slot until leaving the exit radius; vacant slots choose nearest
91
+ eligible placements. Distance includes camera altitude. No work runs while out of range or
92
+ outside the supplied schedule. Schedule time is host policy and does not enter the state hash.
93
+ `status(id)` reports `idle`, `loading`, `playing` or `failed`; `retry(id)` explicitly retries a
94
+ failure. Failures release their slot and never retry every frame. Removal, disposal and leaving
95
+ range cancel pending requests; late results cannot resurrect removed instances.
96
+
97
+ Leaving range destroys the local simulation and visual resources. Re-entry restarts from the
98
+ seed. There is no offline catch-up, persistent game result or synchronization between stadiums.
99
+ Frame stalls advance at most 0.2 seconds per call. Passing zero holds playback. Normal entities,
100
+ static batching and figure distance tiers are reused; local scenes cannot replace the viewer's
101
+ lighting, weather or sky clock.
102
+
103
+ ## Earth placement
104
+
105
+ World Explorer enables the shipped placement catalog by default. Its **Living places** checkbox
106
+ controls playback; its place picker and **Visit** button open any of the six registered scenes.
107
+ Direct links accept `?diorama=football`, `airport`, `little-league`, `fireworks`, `fair` or `market`.
108
+ Visit framing adapts to the viewport and fits above the loaded terrain; explicit camera
109
+ parameters take precedence. `?dioramas=0` disables playback. Source locations and orientation are data in
110
+ `content/dioramas/placements.json`. Content and script text stay in a separate lazy chunk until
111
+ the camera approaches. The Earth view example uses the same catalog by default.
112
+
113
+ Hosts that compose their own terrain loop, as World Explorer does, can use the exported
114
+ `EarthDioramaDirector` directly: call `update` with the terrain root, camera, absolute observer
115
+ position, elapsed seconds, clock, geographic-to-world transform and ground-height sampler;
116
+ call `dispose` on teardown. It uses the same implementation as `mountEarthView`.
117
+
118
+ `mountEarthView` accepts `dioramas: { maxActive, placements }`. Its returned `view.dioramas`
119
+ also exposes `add`, `remove`, `list`, `status` and `retry`:
120
+
121
+ ```ts
122
+ view.dioramas.add({
123
+ id: 'school-game',
124
+ latitude: 47.61,
125
+ longitude: -122.03,
126
+ yaw: 0,
127
+ enterDistance: 350,
128
+ load: loadFootball, // (signal) => Promise<{ scene, bounds, maxEntities? }>
129
+ });
130
+ ```
131
+
132
+ Choose a suitable mapped location in your host. Omitted `altitude` waits for terrain height at
133
+ the anchor; a supplied altitude is absolute meters. `groundFootprint: [71, 51]` samples the
134
+ center, corners and edge centers of a rotated footprint and anchors just above its highest
135
+ sample. The anchor follows terrain LOD refinement without resetting playback. Author a buried
136
+ foundation deep enough to close the resulting edges; this is intended for nearly flat sites.
137
+ The local stage stays flat; the prototype
138
+ does not reshape the terrain, fit arbitrary polygons or remove existing stadium geometry.
139
+ Local axes are east/up/south, and positive yaw rotates +Z toward east. Geographic registrations
140
+ survive terrain re-anchoring; old instances are disposed and recreated in the new frame.
141
+ Automatic matching of map features to dioramas is a future host policy, not silently enabled.
142
+
143
+ ## Shipped performances
144
+
145
+ | Set piece | Geometry and roles | Choreography |
146
+ | --- | --- | --- |
147
+ | Airport apron | A bounded apron; tugs, baggage carts, service staff | A tug towing three baggage carts, a separate service van, a conveyor and walking crew |
148
+ | Little league | Diamond and spectator edge; two team palettes | Pitch/bat cues, a runner around bases, fielders out and back |
149
+ | Fireworks | Launch zone and audience zone | Three staggered launches, 96 reusable sparks, pulse lights and forty spectators |
150
+ | Fair | Booth strip and ride footprints | Rotating Ferris wheel with upright gondolas, bobbing carousel and circulating visitors |
151
+ | Saturday market | Stalls and pedestrian aisles | Eight produce stalls, browsing pauses, vendors and a moving handcart |
152
+
153
+ The performances do not claim to depict actual local events. Placement provenance is in the
154
+ catalog. The airport has elevation but sits outside the bundled detailed street extract.
155
+ Use the host time slider for dusk fireworks; scripts leave the host clock unchanged.
156
+
157
+ Keep motion and cue timing in scripts, uniforms/props in scene data, and geographic selection
158
+ and calendar policy in the host. Start with one convincing repeated vignette. Prefer a few
159
+ recognizable actions to full game rules, transport routing or crowd AI.
160
+
161
+ ## Headless authoring loop
162
+
163
+ Use the existing `molen validate`, `molen scripts check`, `molen sim run --hash`, `molen replay`
164
+ and `molen shot` operations on the scene before placing it. These operate on the same script and
165
+ figures as the viewer. The runtime's additional confinement/budget guard is exercised by
166
+ `createDiorama` tests. Check both a wide view and an eye-level view, multiple points in the loop,
167
+ and leaving/re-entering range. No new CLI operation is needed.
@@ -94,7 +94,8 @@ appears only on touch devices; pass `touchJoystick: 'always'` to show it everywh
94
94
  adaptive quality.
95
95
  - **walk**: `setMode('walk')` drops a walker at the view center. It has capsule collision against
96
96
  terrain, buildings and props, WASD or the touch stick to move, mouse-look with pointer lock, and
97
- Space to jump.
97
+ Space to jump. The camera is first person until the host gives the walker a body; then V
98
+ switches to a camera behind it (see [Walking](#walking-place-pose-avatar-and-third-person)).
98
99
  - **drive**: while walking, press E (or `setMode('drive')`) next to a parked car to get in. W/S
99
100
  drive, A/D steer, Space brakes, V switches between cockpit and chase views, and E gets out. A car
100
101
  at rest with no throttle holds itself, even on a slope. Cars come from the entities content
@@ -118,13 +119,191 @@ mode menu passes `{ force: true }` to step out at once, which also removes a veh
118
119
  added.
119
120
 
120
121
  `view.vehicleStatus()` describes the car or aircraft the viewer is in for a HUD: speed and
121
- heading for a car; airspeed, altitude and height above ground, vertical speed, attitude, power,
122
- engine, gear, flaps and stall/impact flags for an aircraft (SI units, compass radians).
122
+ heading for a car; airspeed, altitude and height above ground, vertical speed, attitude, load
123
+ factor (g), sideslip, power, engine, gear, flaps and stall/impact flags for an aircraft (SI units,
124
+ compass radians). An airplane started in flight is trimmed for level flight at its launch speed.
123
125
  `view.setThrottle(power)` sets an aircraft's throttle or collective from an on-screen lever.
124
126
 
125
127
  Listen for `modechange`. The input profile, clip planes and touch stick follow the mode
126
128
  automatically.
127
129
 
130
+ ## Hooks for game hosts
131
+
132
+ A game built on the view needs to know where the viewer is every frame, put the walker somewhere,
133
+ give it a body, keep a few vehicles and characters of its own, and hear the interact key. These are
134
+ the generic pieces; what they mean (missions, scores, dialogue) stays in the host.
135
+
136
+ ### Per-frame hook and coordinates
137
+
138
+ ```ts
139
+ view.on('frame', ({ dt, now, mode, viewer }) => {
140
+ // viewer: { latitude, longitude, altitude, heading, speed } — the walker's feet, the car, the
141
+ // aircraft, or the orbit target; altitude in meters above sea level, heading a compass bearing in
142
+ // radians, speed in m/s (0 in orbit).
143
+ needle.pointAt(bearing(viewer, destination));
144
+ });
145
+ const [x, z] = view.toWorld(47.6205, -122.3493); // world meters in the current frame
146
+ view.toGeo(x, z); // { latitude, longitude }
147
+ view.groundHeight(47.6205, -122.3493); // m ASL, or undefined until that ground has streamed
148
+ ```
149
+
150
+ `frame` fires once per rendered frame, after the world has stepped and before the camera is set,
151
+ so markers and objects placed from it appear in the frame being drawn. World meters are relative to
152
+ the metric frame: they stay valid until the next `terrainchange` (a re-anchor), while everything
153
+ geographic (`viewer`, poses, places) is stable across re-anchors.
154
+
155
+ ### Walking: place, pose, avatar and third person
156
+
157
+ ```ts
158
+ view.setMode('walk', { at: { latitude, longitude, heading } }); // start here, facing heading
159
+ view.walker.place({ latitude, longitude }); // teleport (enters walk mode if needed)
160
+ view.walker.pose(); // { latitude, longitude, altitude, heading, speed, grounded } | undefined
161
+ view.walker.ready; // standing on streamed ground
162
+ ```
163
+
164
+ A place inside the current frame drops the walker at once (it lands when the ground there has
165
+ streamed, as a walk start always does). A place more than about a degree of latitude away, or in
166
+ another terrain region with `terrainSource`, re-anchors first: the mode is `walk` immediately, the
167
+ orbit camera holds over the destination while the frame rebuilds, and the walker lands when it is
168
+ done.
169
+
170
+ ```ts
171
+ view.walker.setAvatar({ figure: { preset: 'human.adult', height: 1.7, palette: { top: '#2f5a3b' } } });
172
+ view.walker.setAvatar({ type: 'my.app.character.guide' }); // an entity type with a `figure`
173
+ view.walker.setView('third'); // or 'first'; V toggles while walking with an avatar
174
+ view.walker.view; // 'first' | 'third'
175
+ view.walker.setAvatar(undefined); // no body (the default)
176
+ ```
177
+
178
+ The walker has no body by default, and the view is first person. `setAvatar` gives it one: a
179
+ [figure](figures.md) descriptor, or `{ type }` naming an entity type from the content packs with a
180
+ `figure` component. In the third-person view a chase camera sits 4.5 m behind the feet, pulled in
181
+ front of any wall between it and the walker. Mouse-look turns the walker's heading and the camera
182
+ with it; vertical look tilts the camera and eases back. Movement stays relative to the camera, and
183
+ the body faces the way it walks (the camera's heading while standing). The avatar is drawn on foot
184
+ in the third-person view and seated at the wheel in a car's or aircraft's chase view; never in first
185
+ person or a cockpit.
186
+
187
+ ### Owned vehicles
188
+
189
+ ```ts
190
+ const car = view.vehicles.spawn({
191
+ id: 'car-1',
192
+ type: 'molen.entities.vehicle.sedan',
193
+ latitude, longitude, heading, color: '#b8362d',
194
+ });
195
+ await view.vehicles.whenPlaced(car); // the ground under it has streamed and the entity exists
196
+ view.vehicles.pose(car); // { kind, type, latitude, longitude, altitude, heading, speed, occupied, placed }
197
+ view.vehicles.board(car); // within reach of the door; { force: true } from anywhere
198
+ view.vehicles.release(); // step out at once; the car stays
199
+ view.vehicles.setColor(car, '#123456'); // cars only: the type's paintMaterial
200
+ view.vehicles.remove(car);
201
+ view.on('vehiclechange', ({ id, change }) => save(id, view.vehicles.pose(id)));
202
+ ```
203
+
204
+ Owned vehicles differ from the car `setMode('drive', { vehicle: true })` adds: they survive
205
+ stepping out, forced exits and re-anchors, and they are never removed by the view. The registry
206
+ is geographic: a vehicle whose ground has not streamed (parked out of view) is placed when the
207
+ viewer gets there, and after a long trip rebuilds the frame every owned vehicle is placed again
208
+ from its last known place. An aircraft spawned `airborne` flies once; after a re-anchor it is parked
209
+ where it was. `vehiclechange` reports `placed`, `boarded`, `left` (read `pose()` then to persist
210
+ where it was parked), `painted`, `removed` and `blocked` (no room within 30 m of the spot; the
211
+ view retries every few seconds). `type` must be a car (`vehicle`) or aircraft type from the content
212
+ packs; `spawn` throws otherwise, and when the id is already taken. `setMode('drive' | 'fly', {
213
+ board: id })` is the same boarding through the mode API. The entities pack's cars and the OH-6
214
+ carry a `passenger` seat and the P-51D a rear seat, so a companion can ride along (see
215
+ [Actors](#actors-companions-and-npcs)).
216
+
217
+ ### Actors: companions and NPCs
218
+
219
+ ```ts
220
+ const guide = view.actors.add({
221
+ id: 'guide',
222
+ figure: { preset: 'human.adult', height: 1.66, palette: { top: '#b0553a' } }, // or { type }
223
+ latitude, longitude, heading,
224
+ behaviour: { kind: 'follow', target: 'viewer' },
225
+ interactable: true,
226
+ });
227
+ view.actors.setBehaviour(guide, { kind: 'goTo', to: { latitude, longitude, heading } });
228
+ view.actors.lookAt(guide, 'viewer'); // a place, 'viewer', { actor: id }, or null
229
+ view.actors.pose(guide); // { latitude, longitude, altitude, heading, speed, mode, behaviour, mounted?, placed }
230
+ view.on('actorchange', ({ id, change, reason }) => {
231
+ // added | arrived | boarded | alighted | stuck | teleported | removed
232
+ });
233
+ ```
234
+
235
+ Actors are characters the host keeps: a companion who follows the viewer, a guide waiting at a
236
+ door, a passenger. Each is a [figure](figures.md), placed by latitude and longitude once the ground
237
+ there has streamed (`pose().placed`), and kept, like owned vehicles, through drives and re-anchors
238
+ until `remove(id)`. A behaviour decides what it does:
239
+
240
+ | Behaviour | What the actor does |
241
+ |---|---|
242
+ | `{ kind: 'idle' }` | Stands, turning toward its `lookAt` target when that is behind it. The default. |
243
+ | `{ kind: 'wander', around, radius? }` | Strolls the mapped footways within `radius` (default 20 m) of a place, pausing between walks. It stands when ambient life is off or no footway is near. |
244
+ | `{ kind: 'follow', target, distance?, jogBeyond?, teleportBeyond? }` | Keeps `distance` (2.5 m) behind the viewer on foot or another actor (`{ actor: id }`), jogs past `jogBeyond` (8 m), and teleports behind the target past `teleportBeyond` (60 m; `Infinity` never). |
245
+ | `{ kind: 'goTo', to, arriveWithin? }` | Walks to a place, emits `arrived` within `arriveWithin` (1 m), then idles facing `to.heading`. |
246
+ | `{ kind: 'board', vehicle, seat?, force? }` | Walks to the door nearest the seat and sits: `seat` names one, otherwise the first free `passenger` seat. `force` seats it at once, from anywhere and whatever the vehicle is doing. |
247
+ | `{ kind: 'alight' }` | Steps out by the vehicle's exits once it has stopped, then idles. |
248
+
249
+ `stuck` carries a reason: `blocked` (a goal and no progress for three seconds), `target-mounted`,
250
+ `no-vehicle`, `no-seat`, `moving` (the vehicle has not stopped) or `unreachable`. Each is reported
251
+ once when it starts; the actor keeps trying. A follower whose target climbs into a vehicle stands
252
+ still and reports `target-mounted`, which is the host's cue:
253
+
254
+ ```ts
255
+ view.on('actorchange', ({ id, change, reason }) => {
256
+ if (change === 'stuck' && reason === 'target-mounted') {
257
+ const vehicle = view.interactable().id; // aboard, the vehicle the viewer is in
258
+ if (vehicle) view.actors.setBehaviour(id, { kind: 'board', vehicle });
259
+ }
260
+ if (change === 'alighted') view.actors.setBehaviour(id, { kind: 'follow', target: 'viewer' });
261
+ });
262
+ view.on('modechange', ({ mode }) => {
263
+ if (mode === 'walk' && view.actors.pose('guide')?.mounted)
264
+ view.actors.setBehaviour('guide', { kind: 'alight' });
265
+ });
266
+ ```
267
+
268
+ A seated actor rides along in the vehicle's seat (`mode: 'sit'`, `mounted: { vehicle, seat }`) and
269
+ is drawn sitting there. It waits in its seat whatever its behaviour until `alight`; boarding another
270
+ vehicle needs an `alight` first. When the vehicle is removed it stands where the vehicle was
271
+ (`alighted` with reason `vehicle-gone`). An actor seated in an owned vehicle is seated again when a
272
+ re-anchor places that vehicle again. A passenger never drives and does not start an engine sound.
273
+
274
+ Actors walk straight at their goal; there is no pathfinding, so a building between an actor and
275
+ its goal leaves it `stuck`. The few nearest the viewer walk with the walker's capsule collision
276
+ against buildings and props; the rest move over the bare terrain, through walls, until they come
277
+ close. `mountEarthView({ actors: { activeRadius, maxActive } })` sets how many and how near (60 m,
278
+ 4). Actors do not collide with each other or the walker, and ambient cars stop for them like for the
279
+ walker. `actors.adopt(pedestrianId)` turns an ambient pedestrian into an actor (see
280
+ [Promoting a pedestrian](ambient-life.md#promoting-a-pedestrian)).
281
+
282
+ ### Interaction
283
+
284
+ ```ts
285
+ const view = await mountEarthView({ /* … */ interaction: { reach: 2.5, pedestrians: true } });
286
+ view.setInteraction({ pedestrians: false }); // change it later, e.g. only while a game runs
287
+ view.interactable(); // { kind: 'actor' | 'vehicle' | 'pedestrian' | 'none', id?, distance? }
288
+ view.on('interact', (interaction) => {
289
+ if (interaction.kind === 'actor') {
290
+ interaction.claim(); // the view does nothing else with this press
291
+ talkTo(interaction.id);
292
+ } else if (interaction.kind === 'pedestrian') {
293
+ const id = view.actors.adopt(interaction.id); // stop them and talk
294
+ if (id) talkTo(id);
295
+ }
296
+ });
297
+ ```
298
+
299
+ The interact key (E, or F, or the right mouse button) emits `interact` first with what it found. On
300
+ foot that is the nearest of: a car or aircraft within reach of its door (aircraft can be boarded on
301
+ foot too), an interactable actor within `interaction.reach` (2.5 m) of the walker's eyes and in
302
+ sight, and, with `interaction.pedestrians`, an ambient pedestrian. Aboard, it is the vehicle the
303
+ viewer is in; otherwise `none`. A handler that calls `claim()` synchronously takes the press, and
304
+ nothing else happens. Unclaimed, the view boards or leaves a vehicle as it always did (or explains
305
+ why there is nothing to board), and does nothing for an actor or a pedestrian.
306
+
128
307
  ## Frames and long trips
129
308
 
130
309
  Heights stay in meters. Horizontal distances are exact at the frame latitude and drift away from it
@@ -145,6 +324,11 @@ add styled architecture, recognizable businesses, street furniture, trees and dr
145
324
  `molen.sky` and `molen.sounds` from a pack index you host.
146
325
  - `loadEarthContent(packs)` reads them. A missing pack turns its feature off instead of failing.
147
326
 
327
+ Entity types come from every opened pack that provides `types` documents, merged into one
328
+ library with the entities pack first: pass your own pack's id in `ids` (for example
329
+ `[...Object.values(EARTH_PACK_IDS), 'my.app']`) and its figure or prop types sit beside the stock
330
+ cars and aircraft in `content.types`. A type id declared by two packs is an error that names both.
331
+
148
332
  `openPacksFromIndex(indexUrl, ids, fetchImpl)` accepts a host fetch implementation for the index,
149
333
  archive opening and subsequent asset requests. Landmark model bytes are loaded as nearby
150
334
  placements need them. Large packs require HTTP Range support to retrieve those bytes selectively:
@@ -281,6 +465,45 @@ light-rail and airliner models near the camera. The car you drive stops against
281
465
  and traffic waits for it. See [Ambient life](ambient-life.md) for the tier table and how the
282
466
  simulation works.
283
467
 
468
+ ## Airfields
469
+
470
+ `view.airfields` lists the runways the ambient layer's transport network holds and places things
471
+ on them. Everything it returns is latitude, longitude and a compass heading in radians, so a
472
+ result stays valid while the view re-anchors its metric frame as the camera travels; world
473
+ coordinates do not. A runway's id (`runway:<hash>` of its endpoints rounded to 1e-5°) is the same
474
+ each time its tile streams in.
475
+
476
+ ```ts
477
+ const [runway] = await view.airfields.whenNear(47.53, -122.3, { radiusM: 3_000 });
478
+ if (runway !== undefined) {
479
+ const start = view.airfields.placement(runway.id, 'threshold', { end: 'a' });
480
+ // start: { latitude, longitude, heading, elevation }, 60 m in from end a, facing down the runway
481
+ const parked = view.airfields.placement(runway.id, 'beside'); // 40 m to the right of the threshold
482
+ }
483
+ ```
484
+
485
+ - `near(latitude, longitude, radiusM)` returns the runways whose midpoint lies within the radius,
486
+ nearest first. Each has its `ends` (`a` then `b`), the `heading` from `a` to `b`, its geodesic
487
+ `length` in metres, its `elevation` above sea level, and the nearest `aerodrome` point of
488
+ interest within 3 km when one is mapped.
489
+ - `whenNear(latitude, longitude, { radiusM, timeoutMs, signal })` resolves as soon as `near` is
490
+ non-empty, with `[]` after the timeout (20 s by default), and rejects only when the signal
491
+ aborts.
492
+ - `placement(id, where, options)` gives a place with an `elevation`: `threshold` is 60 m in from
493
+ end `a` (or `options.end: 'b'`) facing down the runway toward the other end, `midpoint` is the
494
+ centre facing from `a` to `b`, and `beside` is the threshold moved `options.offsetM` (default
495
+ 40) metres to the right of the runway, facing parallel to it. It returns `undefined` once no
496
+ registered tile carries that runway.
497
+
498
+ Runways exist only for the tiles the ambient layer has registered: those within its activity
499
+ radius plus 250 m of the viewer. Move the camera to the airport first (`flyTo` or `jumpTo`) and
500
+ keep the layer on: `ambient: { cars: false, pedestrians: false, rail: false, aircraft: false }`
501
+ still registers runways, while `ambient: false` removes the network. The map data carries no
502
+ aprons or taxiways, so `beside` is a parking approximation. Hosts composing their own view use
503
+ the same `EarthAirfields` class from `@bendyline/molen-earth/client`, built on an
504
+ `EarthAirfieldsSource` of callbacks (the network's runways, aerodromes and version, and the
505
+ world/geographic conversion) and ticked on their sync.
506
+
284
507
  ## Geographic structures and regional styles
285
508
 
286
509
  The Earth pack may provide a `molen/structure-placements@1` document. Each record binds a
@@ -673,3 +896,18 @@ The composing pieces are exported too, for hosts that build their own view: `cre
673
896
  `EarthVehicles`, `EarthAmbient` with `observeSemanticTiles`, `createEarthSky`/`createEarthFog`,
674
897
  `createEarthAudio`, `earthPerformanceTier` and `earthCredits`.
675
898
  The [World Explorer](https://molen.dev/play/world-explorer/) sample is built from them.
899
+
900
+ ## Boats and water conditions
901
+
902
+ Use `setMode('drive', { vehicle: 'molen.entities.watercraft.speedboat', force: true })` near
903
+ mapped water, or spawn an owned boat through `view.vehicles`. Actors can ride its passenger
904
+ seats. `water` configures deterministic swells and currents; `waterAt` can provide measured depths.
905
+ See [Boats and water](boats.md) for controls, mounting, limitations and the reusable kernel API.
906
+
907
+ ## Dioramas
908
+
909
+ Use `dioramas: { maxActive, placements }` or `view.dioramas.add(...)` for bounded scripted set
910
+ pieces such as a football game, apron traffic or a market. Each geographic placement supplies
911
+ a lazy scene loader, optional calendar policy, and entry/exit distances. It waits for terrain,
912
+ plays nearby, and releases its local world when out of range. See [Dioramas](dioramas.md) for
913
+ the full contract and current prototype limits.
@@ -62,5 +62,36 @@ serves them like any other model. See [Aircraft](aircraft.md) for world-view con
62
62
  `molen.entities.transit.bus` is a 12 m city bus, `molen.entities.transit.lightrail` a 27 m
63
63
  two-section light-rail car, and `molen.entities.aircraft.airliner` a narrow-body airliner. They are
64
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.
65
+ through their `ambientRole` component, as it does the pack's road vehicles and the two aircraft above.
66
66
  In the engine repository, `content/entities/scenes/transit.scene.json` shows them side by side.
67
+
68
+ ## Road, cycle and water fleets
69
+
70
+ The road fleet has eleven mountable models. Alongside compact, sedan, SUV, pickup and van,
71
+ `molen.entities.vehicle.*` includes `sports_coupe`, `station_wagon`, `electric_hatchback`,
72
+ `taxi`, `offroad` and `box_truck`. They expose the usual wheel pivots, paint material, driver
73
+ seat and vehicle tuning, and join the ambient car pool.
74
+
75
+ `molen.entities.cycle.*` contains `standard_motorcycle`, `cruiser_motorcycle`, `motor_scooter`,
76
+ `city_bicycle`, `road_bicycle` and `cargo_bicycle`. These are rideable through the same vehicle/mount API as cars, with self-balancing
77
+ handling, saddle poses, animated steering and bicycle pedals. See [Riding cycles](vehicles.md#riding-cycles).
78
+ They do not spawn as ambient traffic or in car parking bays.
79
+
80
+ `molen.entities.watercraft.*` contains `speedboat`, `sailboat`, `fishing_boat`, `tugboat`,
81
+ `container_ship`, `bulk_carrier`, `passenger_ferry` and `car_ferry`. Their origin is **Y=0 at
82
+ the waterline**, with the hull extending below it. The two ferries have `ambientRole.role:
83
+ "ferry"`; the other vessels have `role: "boat"`. See [water traffic](ambient-life.md#water-traffic)
84
+ for routing and terminal stops. Each type also supplies a powered `boat` and driver/passenger
85
+ seats for [player boating](boats.md), swells, currents and dockside boarding. The sailboat uses
86
+ its auxiliary motor.
87
+
88
+ The id helpers `MOLEN_CYCLE_ENTITY_IDS` and `MOLEN_WATERCRAFT_ENTITY_IDS` enumerate the new
89
+ collections. All are in `MOLEN_ENTITY_IDS` and the pack's type documents.
90
+
91
+ In the engine repository, `content/entities/scenes/fleet.scene.json` displays the road and
92
+ cycle models; `content/entities/scenes/harbor.scene.json` displays the water fleet with moving
93
+ ferries. Each new bundle has an editable `models/recipe.json`; the shared authoring capability
94
+ `packages/entities/scripts/generate-fleet.mjs --ids=sports-coupe,tugboat` rebuilds selected
95
+ models. It preserves an artist-edited master that no longer matches its generator pin.
96
+ After importing, `node packages/entities/scripts/capture-fleet.mjs` renders four views of each
97
+ model and both demo scenes; `--ids=sports-coupe,tugboat` narrows the review to selected models.
@@ -112,7 +112,13 @@ anchored to a tick, so a steadily walking figure sends no deltas. `figureIntent.
112
112
  mode; `lookAt` aims the head at a point or an entity.
113
113
 
114
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.
115
+ writes their transform along footways and `speedSource: 'transform'` animates the gait. The Earth
116
+ view, whose world steps on the main thread without the figures systems, poses its pedestrians,
117
+ [actors](earth-view.md#actors-companions-and-npcs) and the walker's avatar client-side with the
118
+ same `evaluatePose` from `@bendyline/molen-figures/client` (sitting in vehicle seats with the `eye`
119
+ anchor, and turning heads with `worldToFigure` look targets). Cycle drivers use a `pelvis`
120
+ anchor and `cycleRiderPose(vehicle, state, seat)` to reach the handlebars and pedals; the kernel,
121
+ figure kind and Earth avatar share that contact solver.
116
122
 
117
123
  ## Sockets and attachments
118
124
 
@@ -41,6 +41,14 @@ sample at 15 Hz and hidden meshes at 5 Hz by default; returning nearby updates i
41
41
  Use `animation: false` for full-rate sampling everywhere. Snapshot/capture poses remain exact.
42
42
  Finite local lights whose entire influence sphere lies outside the camera frustum are omitted.
43
43
  An explicit light-count cap ranks remaining lights by intensity/distance and can change images.
44
+ On WebGPU, capped point lights without shadows use persistent shader slots: moving or turning
45
+ changes each slot's position, color and intensity instead of compiling a new lighting shader
46
+ for every selected combination. Unused slots have zero intensity. Shadow-casting lights and
47
+ spotlights retain their own objects.
48
+
49
+ Resuming a paused simulation re-anchors the interpolation clock while keeping its pose history.
50
+ Loading screens and paused manual turns therefore do not leave live motion snapping between
51
+ simulation ticks while the clock slowly catches up.
44
52
 
45
53
  ## Staged preparation and admission
46
54
 
@@ -126,9 +134,14 @@ and cell-preparation timings are reported separately. Compatible opaque groups a
126
134
  by the resolved Three material, including groups with different authored references that resolve
127
135
  to the same material. Transparent group order is preserved.
128
136
 
129
- World prop cells start at 512 metres and grow with coarser terrain levels, capped at 8192 metres.
130
- This retains fine nearby culling without creating thousands of tiny distant batches. Every prop
131
- placement remains intact; larger cells trade some culling precision for fewer submissions.
137
+ World props (trees, ground cover, rocks, rooftop and street props) keep one batch per model per
138
+ terrain tile: the tile is already the culling unit. On WebGPU, three.js builds a separate shader
139
+ for every `InstancedMesh`, about 6 ms on the main thread even when the material and geometry are
140
+ shared, so splitting each tile into culling cells multiplied that cost by cells times LOD levels
141
+ and starved terrain publication during fast flight. Every prop placement remains intact; whole-tile
142
+ batches trade some culling precision (more instanced triangles drawn) for far fewer shader builds
143
+ and draw submissions. `createInstancedPlacementLod` still accepts a finite `cellSize` for callers
144
+ that want spatial cells.
132
145
 
133
146
  Terrain palettes compile once per mesh. Terrain index topology is immutable and shared in a
134
147
  bounded CPU cache; use a copy before editing or transferring it. Grids and building cells use
@@ -89,12 +89,14 @@ its neighbors.
89
89
 
90
90
  ## Color and palette
91
91
 
92
- The palette is vivid and coherent. Use clear, pleasant hues in a narrow band of lightness for
93
- each kind of surface. Avoid both grey-on-grey and candy color.
92
+ The palette is clean, coherent and realistic. Each kind of surface uses a narrow band of
93
+ lightness. Houses carry most of the color; downtown blocks are mostly light neutrals with color
94
+ where real buildings have it. Avoid both grey-on-grey and candy color.
94
95
 
95
96
  | Surface | HSL lightness | HSL saturation | Reference swatches |
96
97
  | --- | --- | --- | --- |
97
98
  | Painted wall, siding, render | 60–90% | 15–60% | sage `#a3b78f`, slate blue `#8199b2`, cream `#efe3c4`, butter `#e6cf86` |
99
+ | Urban wall: concrete, panel, limestone | 55–90% | 0–25% | light concrete `#d2cec5`, limestone `#ddd6c6`, cool grey `#b8bfc4`, graphite `#8f9397` |
98
100
  | Masonry, brick, timber walls | 45–65% | 25–45% | brick `#a8634b`, sandstone `#c9ab84`, cedar `#a77a54` |
99
101
  | Pitched roof (shingle, tile, slate) | 35–50% | 6–40% | charcoal `#575c62`, brown `#725c49`, moss `#5a6d55`, terracotta `#a5644b` |
100
102
  | Flat roof (membrane, gravel) | 62–80% | 0–12% | gravel `#a9a59c`, membrane `#c4c0b6` |
@@ -108,14 +110,21 @@ each kind of surface. Avoid both grey-on-grey and candy color.
108
110
 
109
111
  Palette rules:
110
112
 
111
- - **Give a third of a palette a clear hue.** At least a third of a wall palette's weight should be
112
- colors with saturation of 25% or more, so a street of procedural houses never reads as grey
113
- concrete. Neutrals (whites, creams, greys) are welcome, but not as the majority.
113
+ - **Houses carry the hue; urban blocks stay mostly neutral.** A house palette gives at least a
114
+ third of its weight to colors with saturation of 25% or more, so a street of procedural houses
115
+ never reads as grey concrete. Commercial, office and apartment palettes reverse that: about
116
+ three quarters light neutrals (concrete, limestone, off-white, warm and cool greys), with clear
117
+ hue as the minority. A downtown should read as a clean, light skyline, not a patchwork.
118
+ - **Tie color to material.** Brick colors belong on brick and concrete colors on concrete, so a
119
+ style that mixes them names a `palette` on each material choice. Keep red and brown brick to
120
+ about a tenth of an urban style's weight. Dark red and brown towers read as heavy blocks across
121
+ a whole skyline.
114
122
  - **No black and no white on large surfaces.** Large surfaces stay between 22% and 94% lightness.
115
123
  A near-black roof reads as a hole in the frame, and a pure white wall blooms in sun.
116
124
  - **Roofs are darker than walls; flat commercial roofs are lighter.** Pitched roofs sit 15–35
117
125
  lightness points below their walls, so a neighborhood seen from above reads as roofs. Large
118
- flat roofs are light membranes and gravel, as they are in reality.
126
+ flat roofs are light membranes and gravel, as they are in reality. A pitched style declares
127
+ `materials.flatRoof` so its flat fallback is membrane, not shingle tinted charcoal.
119
128
  - **Reserve saturated accents.** Strong saturation belongs to identity: a store's sign band, a
120
129
  landmark's signature color, a bus livery, a fire station. Use one accent per object.
121
130
  - **Real landmarks use their real colors.** The Tacoma Narrows towers are green and the Golden
@@ -106,8 +106,9 @@ lighting changes visibly; moving the camera does not rebuild it. It is enabled b
106
106
  `mountEarthView` and the world explorer. General viewers keep the legacy default (`false`).
107
107
  The approximation provides sky reflections, not reflections of nearby buildings or trees.
108
108
  Without `environment.sky`, it uses the ambient/sun rig and background color. Its filtered map
109
- replaces the hemisphere's diffuse contribution during rendering to avoid lighting surfaces twice,
110
- and carries the same irradiance: `sky.lighting.dayAmbient` and `nightAmbient` (or
109
+ replaces the hemisphere light, which stays hidden (`visible` false, its intensity as authored)
110
+ while the map is the scene environment so surfaces are not lit twice. The map carries the same
111
+ irradiance: `sky.lighting.dayAmbient` and `nightAmbient` (or
111
112
  `environment.ambient.intensity`) set the sky fill whether reflections are on or off.
112
113
  A host-supplied `renderer.scene.environment` takes precedence; the host retains ownership of that
113
114
  texture and control of its light balance.
@@ -203,7 +203,10 @@ These are approximate interiors, not surveyed tunnel geometry. Semantic provider
203
203
  Fragments are clipped out of their tile buffers and joined across neighboring tiles before
204
204
  grading, so tile boundaries do not create portals or conflicting floor heights. Searches are
205
205
  bounded to 16 tiles. Unresolved long routes and branches are omitted rather than assigning a
206
- terrain height to an underground tile boundary. Tunnel inference runs at the finest source
206
+ terrain height to an underground tile boundary. A route end counts as a portal only where an
207
+ ordinary (non-tunnel) line continues from it: a gap between fragments of a longer buried line,
208
+ such as a city subway split into thousands of pieces, would otherwise grade the bore to the
209
+ street there and open the ground along its whole length. Tunnel inference runs at the finest source
207
210
  feature level and above. Hiding the Human layer also removes its portal cuts and navigation
208
211
  support; the original elevation heightfield always remains available for surface anchoring.
209
212