@bendyline/molen-tooling 0.0.13 → 0.0.15

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 (38) hide show
  1. package/dist/capture/harness.js +551 -335
  2. package/dist/capture/worldgen-preview.js +539 -325
  3. package/dist/docs-src/guide/adaptive-performance.md +23 -17
  4. package/dist/docs-src/guide/aircraft.md +66 -18
  5. package/dist/docs-src/guide/ambient-life.md +15 -2
  6. package/dist/docs-src/guide/audio.md +38 -1
  7. package/dist/docs-src/guide/browser-mount.md +11 -0
  8. package/dist/docs-src/guide/determinism.md +2 -1
  9. package/dist/docs-src/guide/dioramas.md +7 -0
  10. package/dist/docs-src/guide/earth-view.md +45 -8
  11. package/dist/docs-src/guide/glass.md +134 -0
  12. package/dist/docs-src/guide/graphics-performance.md +42 -13
  13. package/dist/docs-src/guide/navigation.md +23 -5
  14. package/dist/docs-src/guide/night-lighting.md +2 -1
  15. package/dist/docs-src/guide/regional-fleets.md +9 -4
  16. package/dist/docs-src/guide/regional-world.md +6 -2
  17. package/dist/docs-src/guide/sky.md +2 -2
  18. package/dist/docs-src/guide/surface-rendering.md +9 -3
  19. package/dist/docs-src/guide/terrain.md +42 -9
  20. package/dist/docs-src/guide/vehicle-interiors.md +34 -3
  21. package/dist/docs-src/guide/vehicles.md +47 -1
  22. package/dist/docs-src/guide/weather.md +60 -21
  23. package/dist/docs-src/llms.txt +3 -2
  24. package/dist/docs-src/schemas/components.md +979 -140
  25. package/dist/templates/city-courier/gen/molen-types.ts +103 -2
  26. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +102 -1
  27. package/dist/templates/city-courier/src/shared/playback.ts +21 -10
  28. package/dist/templates/cubes/src/shared/playback.ts +21 -10
  29. package/dist/templates/data-viz/src/shared/playback.ts +21 -10
  30. package/dist/templates/figures-gallery/src/shared/playback.ts +21 -10
  31. package/dist/templates/index.json +17 -17
  32. package/dist/templates/skybound/gen/molen-types.ts +103 -2
  33. package/dist/templates/skybound/scripts/molen-scripts.d.ts +102 -1
  34. package/dist/templates/skybound/src/shared/playback.ts +21 -10
  35. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +102 -1
  36. package/dist/templates/top-down-arena/src/gen/molen-types.ts +103 -2
  37. package/dist/templates/top-down-arena/src/shared/playback.ts +21 -10
  38. package/package.json +12 -12
@@ -0,0 +1,134 @@
1
+ # Glass surfaces and crash breakage
2
+
3
+ Glass is an authored surface with a material, metric dimensions and persistent damage. Fracture
4
+ and retention are separate: a windshield can be shattered and still fill its opening. Glass can
5
+ belong to a vehicle, a window frame or any other entity with a `transform`.
6
+
7
+ ## Materials and outcomes
8
+
9
+ | Material | Fracture | What leaves the frame |
10
+ | --- | --- | --- |
11
+ | `laminated` | Local cracks grow into a dense crack network | Fragments stay together until the frame/interlayer retention fails; then a connected sheet falls |
12
+ | `tempered` | The pane fragments once its strength is exceeded | Small granular pieces |
13
+ | `annealed` | Brittle fracture | Larger pieces |
14
+
15
+ These behaviors follow the distinction between toughened and laminated
16
+ [automotive glazing](https://my.pilkington.com/en/automotive/automotive-overview/automotive-glazing-processes).
17
+ Specify the actual construction: side windows can also be laminated. The material name is not
18
+ a claim that a particular vehicle model uses that glass.
19
+
20
+ ## Author a surface
21
+
22
+ Add a `glass` component beside the vehicle's existing components:
23
+
24
+ ```json
25
+ {
26
+ "glass": {
27
+ "crashPulseSeconds": 0.06,
28
+ "surfaces": [{
29
+ "id": "windshield",
30
+ "material": "laminated",
31
+ "center": [0, 1.2, 0.8],
32
+ "rotation": [0, 0, 0, 1],
33
+ "size": [1.4, 0.7],
34
+ "thickness": 0.005,
35
+ "nodes": ["windshield"]
36
+ }]
37
+ }
38
+ }
39
+ ```
40
+
41
+ The pane lies in its own XY plane; its normal is +Z. `center` and the unit quaternion `rotation`
42
+ place it in the owner's frame. Dimensions are meters. The example geometry is illustrative;
43
+ measure the model's pane and tilt its normal with the windshield rake.
44
+
45
+ `nodes` must identify dedicated glass meshes/groups. Never bind the whole car or a mesh combining
46
+ glass and body panels. Omit `nodes` to create a rectangular glass pane. A standalone entity with
47
+ `transform` and `glass` needs no `renderable`: the standard client creates the glass itself.
48
+ Existing fleet models opt in through these authored definitions; transparent materials are not
49
+ automatically classified as breakable glass. Curved panes use a rectangular physical/visual
50
+ approximation for cracks and granules; retained source geometry and released laminate sheets
51
+ keep their authored shape.
52
+
53
+ ## Physics model
54
+
55
+ `installVehicles` feeds resolved collision changes in linear and angular velocity to each pane.
56
+ There is no forward-speed trigger: braking or driving quickly without hitting something does not
57
+ break glass. Normal acceleration at the pane includes the contact's yaw impulse. Pane mass is
58
+ `density × width × height × thickness`; the default density is 2500 kg/m³. The chassis crash
59
+ pulse lasts `crashPulseSeconds`, independently of the tick rate and internal solver substeps.
60
+
61
+ For a direct contact, normal force is normal impulse divided by contact duration. A reduced
62
+ simply supported strip model estimates bending stress:
63
+
64
+ ```text
65
+ stress = coefficient × normalForce × shortSpan / (longSpan × thickness²)
66
+ coefficient = 1.5 for a centered point load, 0.75 for distributed inertia
67
+ ```
68
+
69
+ Point loads approach zero bending at the supported edge. Only the normal portion of impact
70
+ energy grows cracks. Effective `strength` defaults to 45 MPa for laminated/annealed and 120 MPa
71
+ for tempered glass. Above strength, excess energy accumulates fracture damage against
72
+ `fractureEnergy` (default 80 J/m²). Gentle repeated contacts below strength do not accumulate
73
+ fracture damage.
74
+
75
+ Retention has its own `retentionForce` (default 4000 N per meter of pane perimeter) and
76
+ `retentionEnergy` (default 3000 J/m² of area). Only loads exceeding the force threshold consume
77
+ retention work. Weak mounts can release an intact pane; strong mounts keep shattered laminate
78
+ attached. Tempered and annealed fragments leave when the pane shatters.
79
+
80
+ These are tunable game approximations, not measured vehicle failure limits or a safety/crash
81
+ prediction model. They do not resolve laminate plies, edge flaws, temperature, detailed body
82
+ deformation or crack-tip propagation. Tune strength and retention against the behavior needed
83
+ for the experience.
84
+
85
+ ## Other contacts and scripts
86
+
87
+ Scene worlds enable `glass-impact` automatically. A physics adapter or script supplies an
88
+ already-resolved load to a named pane:
89
+
90
+ ```ts
91
+ molen.emit('glass-impact', {
92
+ entity: 'car',
93
+ surface: 'windshield',
94
+ impulse: [0, 0, -80], // owner coordinates, newton seconds
95
+ energy: 120, // available contact energy, joules
96
+ duration: 0.02, // physical pulse duration, seconds
97
+ point: [0.1, 0.05] // contact in pane XY coordinates, meters
98
+ });
99
+ ```
100
+
101
+ Contact impulse and energy must come from the same contact. Negative energy, non-finite values
102
+ and nonpositive durations are rejected; contacts outside the pane are ignored. `velocity` can
103
+ supply the owner's world velocity at the pane. Direct contacts add an energy-limited impulse
104
+ velocity when glass releases. `distributed: true` describes inertial loading instead and avoids
105
+ adding that velocity a second time.
106
+
107
+ For a manually constructed `World`, call `installGlass(world)` from
108
+ `@bendyline/molen-kernel/glass`; it is idempotent. The same module exports `damageGlass`, the pure
109
+ `applyGlassImpact`, and `applyGlassCrash` for other chassis solvers. `glass` defines no collider;
110
+ non-vehicle physics adapters are responsible for contact detection and for removing or changing
111
+ their pane collider when an opening forms. Road vehicles retain their chassis collider.
112
+
113
+ ## State, events and rendering
114
+
115
+ The kernel writes `glassState.surfaces[id]`: `fracture`, `retained`, fracture `damage`,
116
+ `retentionDamage`, `peakStress` in Pa and the crack origin `point`. A released pane also carries
117
+ its initial world pose, velocity, energy-limited fragment dispersion and simulation time.
118
+ Missing state means intact. Remove `glassState` to repair all panes, or remove a surface's entry
119
+ to repair one. State and release timing survive checkpoints, replay and late model loading.
120
+
121
+ Transitions emit `glass-cracked`, `glass-shattered` and `glass-released` once, after the state is
122
+ written. A contact can emit all three. Payloads include `entity`, `surface`, `material`, `stress`
123
+ and `retained`; sound and gameplay can subscribe without changing the fracture solver.
124
+
125
+ The standard client and Earth vehicle host consume the components. Custom hosts can call
126
+ `createGlassVisual(model, glassData)` from `@bendyline/molen-client/glass`, then
127
+ `update(glassState, simulationSeconds)`. Call `dispose()` before releasing the model. Vehicle
128
+ hosts can instead pass `glassData` as the fourth argument to `createVehicleVisual`, and
129
+ `glassState` as the fifth argument to its `update` method.
130
+
131
+ Laminated cracks stay attached; released sheets and small fragments inherit motion and fall
132
+ under gravity. Debris is cosmetic, has no rigid-body collisions and expires after eight seconds.
133
+ The renderer caps a fragmented pane at 96 cells and uses simulation time, so seeking does not
134
+ spawn duplicate particles. Source GLB geometry and shared materials are never edited.
@@ -80,6 +80,16 @@ marked `'background'` prepares only in budget normal jobs leave: World Explorer'
80
80
  aircraft load with the world that way, as in the normal lane their ~200 jobs held terrain and
81
81
  buildings back by most of a minute on a software renderer.
82
82
 
83
+ Continuous urgent traffic shares service with normal work: after two urgent jobs, a normal job
84
+ waiting at least 50 ms gets a turn, including when each urgent job consumes a whole frame.
85
+ Normal jobs may provide `order: () => number` (lower first), read at dispatch so a moving camera
86
+ can reprioritize queued work. After three ordered jobs, the FIFO head gets a turn; shared decodes
87
+ and unrelated scene work continue to progress. These rules stay within the same frame budgets.
88
+ Terrain layer contexts scope this live order through generation and assembly; their GPU preparation
89
+ uses `userData.admissionOrder`, and publication keeps the same order. Only immediate replacement
90
+ siblings inherit a parent's priority; a distant ancestor must not give a whole city's leaves the
91
+ same priority.
92
+
83
93
  Main-thread work that runs as a tile's sources resolve is admitted too, because several tiles
84
94
  arriving together stacked it into one late frame: decoding vector tiles (the package semantic
85
95
  layers' `admission` option), a worldgen request's own preparation, prop batches, surface results
@@ -114,8 +124,11 @@ signal lenses, markings and parked cars past their draw distance (`updateDetail`
114
124
  [surface rendering](surface-rendering.md)) and street props below 1.5 px (`vanishPixels`, see
115
125
  [worldgen](worldgen.md)); at High over a town that cut a fifth of the draws. A visibility pass makes
116
126
  its first ground cut whatever it costs, but only 4 ms more (`TerrainGroundCutoutController.update`'s
117
- budget); the rest keep their current cut until the next stream update, so tiles arriving together
118
- no longer hold one frame for every cut they need.
127
+ budget); the rest keep their current cut until the next frame, so tiles arriving together
128
+ no longer hold one frame for every cut they need. `stream.updateTransitions(nowMs)` carries those
129
+ cuts on every frame, sharing one 4 ms budget a frame with `stream.update`: hosts update the stream
130
+ ten times a second while the camera is still, and at one budget an update, ground that a descent
131
+ had just shown stood uncut over its own harbor for most of a second.
119
132
 
120
133
  Earth hosts admit more while frames have time to spare: `createEarthAdmissionGovernor(backend)`
121
134
  smooths each frame's main-thread work and, through `earthAdmission`, switches the queue to 8 MiB
@@ -163,8 +176,9 @@ shared with drawn meshes (every building's wall) reported its ready program whil
163
176
  variant was still linking, and that variant's first draw waited for the link, 130 ms in flight.
164
177
  Content that appears beside the viewer is prepared before it shows as well: building interiors
165
178
  (`InteriorStreamingOptions.prepare`, which the Earth renderers pass their `prepareObject`; the
166
- entrance covers stay until it settles), ambient pedestrians and ambient aircraft stay hidden until
167
- their shaders are built.
179
+ entrance covers stay until it settles), ambient pedestrians, ambient aircraft and wildlife (when
180
+ `EarthWildlife`'s `prepare` returns a promise) stay hidden until their shaders are built, and
181
+ dioramas are prepared before they join the scene (see [Dioramas](dioramas.md)).
168
182
 
169
183
  Main-thread work that runs as tiles stream in beneath a fast aircraft is kept small. Ambient
170
184
  aircraft parse and merge each type once into a template, in 3 ms slices, without the cabin (its
@@ -173,9 +187,12 @@ its glyph vertices (`MeshBufferBuilder.addFlatMesh`). The worldgen tile cache ke
173
187
  by a fast hash of its JSON (the cache never leaves the session) rather than SHA-256, which spent up
174
188
  to 20 ms on a dense town tile. Ground cutouts read positions straight from their arrays and pass
175
189
  over triangles whose corners share a side outside every opening, or that one of a convex opening's
176
- edges separates from it. Parked cars bake from their template arrays, and
177
- `EarthAudioTerrain.sample` skips map features whose bounds cannot come nearer than the nearest
178
- found.
190
+ edges separates from it, and find the openings near a triangle without building and sorting a set
191
+ for it. Parked cars bake from their template arrays, and `EarthAudioTerrain.sample` skips map
192
+ features whose bounds cannot come nearer than the nearest found. An aircraft's ground probes (a
193
+ few hundred a tick) find airport pavement among meshes indexed by their bounds once per tagging,
194
+ not by walking every pavement mesh ever tagged; a tunnel query skips bores whose tile it is
195
+ outside before looking up their visibility.
179
196
 
180
197
  For custom streamed geometry, call `await renderer.prepareObject(object, signal, parent)` before
181
198
  publication. Connect the same queue to terrain, which passes each layer's tile group as `parent`:
@@ -190,6 +207,12 @@ const terrain = await createTerrainPackagePyramidStream(packageDescriptor, {
190
207
  });
191
208
  ```
192
209
 
210
+ A `transformHeightfield` replacement (Earth's airport grading) is meshed by the same worker through
211
+ the source's `meshPrepared`; meshed on the main thread, each graded tile beside an airport was one
212
+ admitted job of up to 20 ms. The grading itself finds each sample row's polygon crossings and nearby
213
+ ground edges once, instead of testing every edge of an airport's grounds for every sample: a tenth
214
+ of a second a tile over Boeing Field.
215
+
193
216
  The worker entry calls `installTerrainElevationWorker(self)`, exported from
194
217
  `@bendyline/molen-terrain/client` (use the worker-scope type cast shown by World Explorer when
195
218
  compiling with DOM rather than WebWorker types). The host reads archive bytes; the worker
@@ -220,9 +243,14 @@ and meshing still run for every tile the stream loads. Long-horizon byte prefetc
220
243
  The Earth view also prepares nearby future tiles through the normal construction and GPU queues,
221
244
  so aircraft can arrive over already prepared terrain and layers even without persistent caching.
222
245
 
223
- A generation worker runs one tile at a time, in the order requested (the stream asks for what the
224
- view needs most first); interleaved, every tile in flight finished late, the nearest with the
225
- rest. It yields to its event loop every 8 ms of work, through a message channel, so a
246
+ A generation worker runs one tile at a time; interleaved, every tile in flight finished late, the
247
+ nearest with the rest. Which tile runs next is decided when a worker frees, not when the tile was
248
+ requested: the worldgen pool keeps waiting tiles on the main thread (two posted per worker), and
249
+ the land cover and road surface queues pick their next job the same way, by each layer context's
250
+ `priority()` (meters from the camera, ground in view first). Posted in request order, a jet's
251
+ nearest ground waited a second or more behind ground it had already passed. Layer adapters that
252
+ pass work to their own workers can read `context.priority` the same way.
253
+ It yields to its event loop every 8 ms of work, through a message channel, so a
226
254
  `cancel` message gets through. It used to yield after every step with a zero `setTimeout`, which a
227
255
  browser holds for at least 4 ms once timers nest: a dense tile took a second of wall time for a
228
256
  fifth of a second of work. Streaming generators also pass `hashOutput: false`: the SHA-256 over
@@ -290,8 +318,9 @@ behind that parent. Cached LODs reuse their prepared geometry.
290
318
 
291
319
  Previously unvisited ground can show its base surface immediately; its enabled layers appear
292
320
  together once settled. Empty layer results count as ready. Failed replacement layers preserve
293
- the old tiles until `retryFailed()` succeeds or the layer is disabled; on cold ground, successful
294
- layers can still appear after another layer fails. Hidden layers do not delay a handoff. This
321
+ the old tiles until a later attempt (after `failedRetryDelayMs`, or `retryFailed()`) succeeds or the
322
+ layer is disabled; on cold ground, successful layers can still appear after another layer fails.
323
+ Hidden layers do not delay a handoff. This
295
324
  stages scene geometry rather than rendering a second full-screen image, and retains old visual
296
325
  coverage under residency pressure until its replacement can safely take over.
297
326
 
@@ -339,7 +368,7 @@ cut. An aircraft's center can pass behind its cockpit camera at a tile boundary;
339
368
  indefinitely for already cached ground to become visible before moving again.
340
369
 
341
370
  `morphMilliseconds` enables refinement height morphs for bare surfaces; call
342
- `stream.updateTransitions(nowMs)` in the frame loop. Vertices start on the actual parent
371
+ `stream.updateTransitions(nowMs)` in the frame loop (it also carries on unfinished ground cuts). Vertices start on the actual parent
343
372
  triangles and finish at their exact target positions with fixed horizontal coordinates. Grounded
344
373
  semantic layers use coverage-preserving atomic replacement and hysteresis instead. Enabling
345
374
  one finishes any surface morph before layer publication. Coarsening does not height-morph.
@@ -92,10 +92,28 @@ tree entirely. Queries reach at most `radius - rebuildDistance` from the subject
92
92
  `verticalRadius` unset for a walker, whose placement ray scans the whole column.
93
93
 
94
94
  Meshes opt out with `userData.walkIgnore = true`; world-generation ground cover does, so walkers
95
- pass through ferns and moss. Water materials and landcover overlays are never solid. An aircraft can
96
- pass `instanceBounds: true`, which collides with each instance of an instanced mesh as its bounding
97
- box rather than its triangles. A missing terrain tile pauses movement until it arrives, rather than
98
- dropping the walker.
95
+ pass through ferns and moss. Meshes with all render layers disabled are skipped unless marked
96
+ `userData.walkCollisionOnly = true`, as with the smooth ramps beneath visible stair steps.
97
+ Water materials are never solid. Visible landcover provides walking support, including when it
98
+ replaces the bare terrain.
99
+
100
+ Set `walker.sampleWaterHeight = (x, z) => ...` to enable automatic surface swimming. Return the
101
+ water height in world meters, `null` on dry land, or `undefined` while water coverage is loading.
102
+ The walker wades on shallow ground, floats with its eyes 45 cm above deep water, and resumes
103
+ walking when its capsule meets the shore. `walker.swimming` reports this state; the walk input
104
+ profile stays active, with Shift swimming faster and jumping available again on land. Solid
105
+ walls and bridges still collide normally. Water also supports initial placement without a
106
+ rendered lake bed. Earth view and world explorer supply this callback from their boat water
107
+ coverage automatically, excluding tunnels beneath water.
108
+
109
+ An aircraft can pass `instanceBounds: true`, which collides with each instance of an instanced mesh
110
+ as its bounding box rather than its triangles. A missing terrain tile pauses movement until it
111
+ arrives, rather than dropping the walker.
112
+
113
+ For tunnels, the `sampleHeight` callback passed to `walker.update` must return the bore floor
114
+ when the walker's feet are inside it, and the terrain height otherwise. Earth view does this
115
+ automatically. Returning the hill above a tunnel triggers streamed-ground recovery and lifts
116
+ the walker out of the bore. Initial placement still uses the surface height to land above ground.
99
117
 
100
118
  ## Follow
101
119
 
@@ -120,7 +138,7 @@ Default profiles come from `navigationInputProfiles()`:
120
138
  |---|---|---|
121
139
  | `orbit`, `fly` | WASD/arrows move, Q/E down/up, Shift sprint | left stick move, right stick look, bumpers up/down |
122
140
  | `walk`, `drive` | WASD/arrows move, Space jump/brake, E or F interact, V view, Shift sprint | left stick move, right stick look, A jump, X interact, Y view |
123
- | `pilot` | W/S or ↑/↓ nose down/up, A/D or ←/→ bank, Q/Z rudder, Shift/Ctrl (or +/−, Page Up/Down) power, I engine, G gear, F flaps, R recover, Space brake, V view, E exit | left stick pitch/bank, right stick look, triggers power, bumpers rudder, A brake, B engine, X exit, Y view |
141
+ | `pilot` | W/S or ↑/↓ nose down/up, A/D or ←/→ bank, Z/C rudder, =/− (or numpad +/−, Page Up/Down) power, I engine, G gear, F flaps, R recover, Space brake, V view, E exit | left stick pitch/bank, right stick look, triggers power, bumpers rudder, A brake, B engine, X exit, Y view |
124
142
 
125
143
  In the `pilot` profile each `NavigationInput` also carries `pilot`: the held `throttle` and `yaw`
126
144
  axes (-1..1) and edge-triggered `engine`, `gear`, `flaps` and `recover` presses. Pitch is
@@ -64,7 +64,8 @@ metadata; arbitrary tagged model lamps currently emit without creating a point l
64
64
  Active traffic and the driven car get white headlights and red tail lights, including when
65
65
  stopped at a signal. Lenses follow vehicle dimensions and the full chassis rotation, through
66
66
  proxy/model changes and floating-origin shifts. Braking brightens the rear lenses. Four nearby
67
- cars also receive forward, downward-aimed spotlights, with the driven car taking priority.
67
+ cars also receive a pair of forward, downward-aimed spotlights, with the driven car taking priority.
68
+ Each beam starts at its headlight lens and softly lights the road immediately ahead of the car.
68
69
  Their beams illuminate pavement, walls and vehicles ahead. Parked, unoccupied cars keep their
69
70
  lamps off and receive light from their surroundings. Hidden/despawned traffic loses its lights.
70
71
 
@@ -55,8 +55,10 @@ content retain their original behavior.
55
55
  World Explorer builds an entity archive for distribution and a versioned directory manifest for
56
56
  browser use. The index points to `molen-pack.json`, so even a static server without HTTP Range
57
57
  downloads only requested GLBs. Opening the catalog fetches no GLBs; distant traffic and parking
58
- use instanced proxies. Explicit player selection may load any vehicle. Node pack hosting also
59
- accepts a hosted directory index. Content hashes identify shared files in the Earth byte cache.
58
+ use lightweight proxies with shaped hoods, sloped windows, painted roofs and visible wheels.
59
+ The shared car silhouette uses 148 triangles and one material, with no model download.
60
+ Explicit player selection may load any vehicle. Node pack hosting also accepts a hosted directory
61
+ index. Content hashes identify shared files in the Earth byte cache.
60
62
 
61
63
  Directory reads share transfers. Cancelling one reader preserves another reader's request; when
62
64
  the last reader cancels, queued or active work is aborted. Failed/aborted reads can retry. The
@@ -73,8 +75,11 @@ residency budget rather than a process-wide memory ceiling.
73
75
 
74
76
  Configure `idleVehicleModels`, `vehicleModelBytes`, and `vehicleLoads` on `EarthAmbientSettings`
75
77
  or `AmbientRenderBudget`. Zero idle retention is supported. Parking independently loads at most
76
- eight nearby detailed cars with two background requests. Driven cars retain simulation state but
77
- release their model outside the near set. The mounted car and explicitly host-owned cars are
78
+ eight nearby detailed cars with two background requests. Both parking and traffic request full
79
+ car models within 45 metres and retain selected models out to 65 metres, subject to their count
80
+ and residency budgets. This hysteresis prevents repeated swaps at the approach threshold.
81
+ Driven cars retain simulation state but release their model outside the near set. The mounted car
82
+ and explicitly host-owned cars are
78
83
  exceptions, owned until removal. Aircraft keep their existing budget.
79
84
 
80
85
  ## Coverage and authoring
@@ -106,7 +106,7 @@ mangrove, deadwood, shrub, thicket, forb, vine, mat, and fallen-wood silhouettes
106
106
  parks, orchards, and wetlands. Regional refinements keep American cacti out of Old World wild
107
107
  desert profiles and avoid applying Australian eucalyptus profiles to New Zealand.
108
108
 
109
- Each of the 78 plant forms has a base, spreading, and slender preset, available in
109
+ Each of the 88 plant forms has a base, spreading, and slender preset, available in
110
110
  every applicable habitat and crop rule. Optional `shapeSeed` varies branch/frond arrangements,
111
111
  crown contours and stem profiles independently of the placement seed. Dimensions, crown height,
112
112
  trunk lean and restrained foliage tones also vary; these are visual forms, not additional taxa.
@@ -149,7 +149,11 @@ is their interchangeable fallback and its `weight` still controls species propor
149
149
  selection uses an independent random stream, keeping positions, density, crop rows and ordinary
150
150
  quality thinning intact. A tile reserves a base form for each retained species before admitting
151
151
  extra variants into spare model slots. Unretained forms use that base instead of disappearing;
152
- Economy and distant views therefore show fewer forms without increasing draw limits. Variant
152
+ Economy and distant views therefore show fewer forms without increasing draw limits. A species
153
+ past the tile's model budget likewise takes its rule's most common retained species, so a tight
154
+ budget simplifies a mixed stand rather than thinning it; a rule with no retained species, such
155
+ as a lone crop row, still drops out. Weights therefore also decide what a tight budget shows:
156
+ it keeps a tile's most numerous species, and minor ones appear only where it has room. Variant
153
157
  recipes must be suitable for the same habitat and placement-scale bounds as their parent.
154
158
 
155
159
  Mapped trees preserve source `species`, `genus`, `leafType`, `height`, and `crownDiameter` when
@@ -233,8 +233,8 @@ quantized to about 0.005° and magnitudes to 0.04. The engine repository regener
233
233
  No atmospheric refraction, horizon dip, terrain horizon calculation, eclipses, planetary bodies,
234
234
  Milky Way texture, lunar libration or photographic lunar map are modeled. The procedural lunar
235
235
  surface is illustrative. Sunrise and sunset are geometric approximations; this is an experience
236
- renderer, not a navigation or observational ephemeris. Layered clouds, precipitation, visibility
237
- and physical atmospheric state live in the separate [weather component](weather.md).
236
+ renderer, not a navigation or observational ephemeris. Volumetric clouds, precipitation,
237
+ visibility and physical atmospheric state live in the separate [weather component](weather.md).
238
238
  Volumetric atmospheric scattering remains future work.
239
239
 
240
240
  ## Try it
@@ -252,9 +252,15 @@ await surfaces.setOptions({
252
252
  The decoder preserves road `subclass`, `service`, `link` (including Protomaps `is_link`), `surface`, `lanes`, `oneway`, `layer`, `bridge`, `tunnel`
253
253
  and explicit `width`. Properties absent from the source use class-based defaults. Tunnel roads are
254
254
  excluded from the ground painter; Earth views add separate underground bores as described below.
255
- Bridges and differing layers do not form surface junctions. Bridge ribbons retain the
256
- existing approximate terrain-relative elevation; this renderer does not build engineered bridge
257
- decks. Crossing paint, inferred sidewalks, signal placement and parking occupancy are decorative,
255
+ Bridges and differing layers do not form surface junctions. Tagged bridges receive inferred
256
+ decks, slabs, barriers and supports. Motorway spans retain clearance through their ends;
257
+ connected approaches ease back to terrain over the surrounding road fragments, with retaining
258
+ sides below raised pavement. Curved profiles follow distance along the mapped road. Barriers
259
+ sit outside paved shoulders and open at merges where the adjoining carriageway is at the same
260
+ height; edge paint also clears these openings. Traffic uses the same grading samples.
261
+ Surveyed deck heights and authored bridge connections take precedence. Inferred grades depend
262
+ on the available tile geometry and terrain, so they are not surveyed engineering profiles.
263
+ Crossing paint, inferred sidewalks, signal placement and parking occupancy are decorative,
258
264
  not surveyed traffic-control or navigation data. [Ambient life](ambient-life.md) builds its own lane graph
259
265
  from the same features for NPC traffic. Earth view and world explorer match signal heads to
260
266
  that graph, displaying the same phase that controls approaching cars. Without a matching
@@ -141,16 +141,22 @@ do not change residency behavior. HTTP 404 is a stable missing tile; call `retry
141
141
  the backing data has changed. A *thrown* error is not: a dropped range request, a 503, or a CORS
142
142
  failure is retried with bounded exponential backoff (`maxRetries`, `retryDelayMs`,
143
143
  `maxRetryDelayMs`) before the tile is abandoned, and every request carries a `requestTimeoutMs`
144
- deadline so a stalled connection cannot hold a concurrent load slot. `stats()` counts `missing` and
145
- `retrying` separately from `failed`, and `tileFailures()` reports each tile's state, attempts, and
146
- next attempt time, so a host can tell a user "still retrying" rather than "gave up".
144
+ deadline so a stalled connection cannot hold a concurrent load slot. An abandoned tile is set aside,
145
+ not dropped: after `failedRetryDelayMs` (15000 ms by default, doubling with each further failure up
146
+ to eight times as long) the first `update()` that still wants it tries again, so an outage longer
147
+ than the quick retries leaves no permanent holes once it is over. Set it to 0 or Infinity to keep
148
+ abandoned tiles until `retryFailed()`. `stats()` counts `missing` and `retrying` separately from
149
+ `failed`, and `tileFailures()` reports each tile's state, attempts, and next attempt time, so a host
150
+ can tell a user "still retrying" rather than "gave up".
147
151
 
148
152
  The pyramid streamer applies the same retry policy to semantic layer generation and GPU
149
153
  preparation, with a separate `layerTimeoutMs` deadline (120000 ms by default; 0 or Infinity disables
150
154
  it). This allows CPU-heavy generation and software shader compilation more time than height
151
155
  requests. A stalled layer releases its load slot, and late cancelled results are disposed.
152
156
  `stats().retryingLayers` and `stats().failedLayers` report those failures independently from height
153
- tiles; `retryFailed()` retries both. Disabling a layer or evicting its tile clears its failure state.
157
+ tiles. An abandoned layer is tried again after the same `failedRetryDelayMs`, so a lake whose water
158
+ failed to load fills in on its own; `retryFailed()` retries tiles and layers at once. Disabling a
159
+ layer or evicting its tile clears its failure state.
154
160
 
155
161
  Adjacent tiles share their border heights, and the streamer keeps their border *normals* continuous
156
162
  too: each side recomputes its edge from the neighbouring tile's heights once that neighbour is
@@ -351,10 +357,19 @@ For moving cameras, `stream.update(view, futureViews)` accepts optional predicte
351
357
  in time first. It prepares a bounded set of future leaves, semantic layers and GPU resources in
352
358
  the hidden resident cache without changing the current selection. Omit the second argument to
353
359
  stop prediction. Both the Earth view and World Explorer use `createEarthTilePreloader` from
354
- `@bendyline/molen-earth/client` to predict 4, 8 and 12 seconds of fast travel, capped at 4 km.
360
+ `@bendyline/molen-earth/client` to predict 2, 4, 8 and 12 seconds of fast travel, capped at 4 km.
355
361
  Its `views(nowMs, view, steady)` takes positions already in the Earth adapter's metric world frame;
356
362
  pass `steady: false` during scripted camera animations and call `reset()` when changing frames.
357
363
 
364
+ Semantic preparation shares its request window across enabled layers, retaining capacity for
365
+ the next arriving tile's other layers even when one source stalls. Earth applies the same
366
+ 12-height / 24-layer preparation window to manual and automatic quality; bounded worker pools
367
+ and frame admission govern the work itself. Visual quality and selection budgets remain separate.
368
+ Layer priority follows the camera and predicted flight path through worker, assembly, GPU
369
+ preparation and publication queues, ahead of surrounding detail.
370
+ Repeated physics height probes cache the covering fields per finest-level cell; arriving tiles,
371
+ visibility changes and eviction invalidate that lookup without caching or quantizing heights.
372
+
358
373
  The selector measures projected source-sample spacing, adapts its error/range to the selected-tile
359
374
  budget, requests ancestors before descendants, and retains a displayed parent until all selected
360
375
  descendant coverage is resident. A selected tile that is not resident yet shows through its
@@ -367,9 +382,10 @@ screen-space error, displayed-level range, and leaf fallback count. Quality pres
367
382
  error, view-distance, concurrency, selection, and residency budgets. Include `direction` and
368
383
  `aspect` in each view update to reject tiles safely outside a guarded horizontal camera cone while
369
384
  retaining direction-independent coarse coverage to the configured distance. `peripheralDegrees`
370
- widens that cone for ground only: tiles up to that many degrees past it stay selected at reduced
371
- detail (`peripheralDetail`, default 0.4, weighs their error) as bare terrain, without layers, so
372
- turning the camera reveals ground that is already there; layers build once the tile is in view. In-flight surface
385
+ widens that cone: tiles up to that many degrees past it stay selected at reduced
386
+ detail (`peripheralDetail`, default 0.4, weighs their error), with hydrology prepared too, so
387
+ turning the camera reveals ground and mapped water that are already there. Buildings and vegetation
388
+ build once the tile is in view. In-flight surface
373
389
  requests finish into a bounded warm cache instead of being restarted on every small camera turn;
374
390
  hidden cached tiles are evicted only when capacity is needed. Sparse descendants also share a
375
391
  bounded decoded-ancestor cache, avoiding repeated PNG decode/resample work while panning.
@@ -383,6 +399,9 @@ water and road surfaces are marked) and water with `userData.shadowReceiver = fa
383
399
  adaptive tiles. Its optional inclusive `minLevel`/`maxLevel` bounds keep expensive decoration off
384
400
  coarse fallback and horizon tiles. Layer objects become visible only with their selected surface,
385
401
  remain cached briefly across LOD transitions, and are disposed with their resident height tile.
402
+ Hydrology is queued ahead of other visible layer work and appears as soon as it is prepared,
403
+ without waiting for buildings or vegetation. Refinement still retains parent water until its
404
+ replacement family is ready, avoiding gaps or overlapping parent/child shorelines.
386
405
  A layer object that drapes its whole tile with opaque ground (landcover over a full-tile
387
406
  background, as the regional worldgen classification layer builds) can set
388
407
  `userData[TERRAIN_COVERS_GROUND] = true`. While it is displayed, the stream stops drawing that
@@ -429,7 +448,8 @@ stay on the heap meanwhile.
429
448
 
430
449
  Mapped lake polygons also clear coarse elevation and landcover beneath their water surface,
431
450
  preserving polygon holes as islands. Small bank faces close the difference between the rendered
432
- ground triangles and the water level; clipped tile edges do not become artificial banks. These
451
+ ground triangles and the water level over the tile's own ground: clipped tile edges, and the
452
+ buffer that decoded and overzoomed areas carry past them, do not become artificial banks. These
433
453
  openings follow hydrology tile residency, independently of landmark loading, and restore the
434
454
  original ground on hide/unload. Roads and bridge surfaces retain their geometry. Source height
435
455
  samples remain available for anchoring and physics. Ground clipping keeps shared grid vertices
@@ -503,6 +523,19 @@ nearest declared ancestor when an exact tile is absent, then crops and resamples
503
523
  the requested tile bounds. This supports broad coarse coverage plus a small regional detail window
504
524
  without a hard distance cutoff. Set `parentFallback: false` when exact-level coverage is required.
505
525
 
526
+ Geospatial package loaders automatically reject isolated extreme elevation samples before
527
+ resampling or meshing, including in the elevation worker. A sample must sit above or below its
528
+ entire surrounding ring by more than 100 m, twice the native sample spacing, and twice the ring's
529
+ height range. Only those outliers are replaced with the ring median; ordinary slopes, ridges and
530
+ cliffs retain their samples. This conservative check removes narrow DEM spikes and pits without
531
+ blurring the whole terrain. It is not a general repair for broad corrupt regions or missing data.
532
+ Suspicious border samples read neighbouring archive tiles so shared edges receive the same result;
533
+ incomplete surrounding coverage is left unchanged. Meshes, ground queries and ancestor fallback
534
+ all use the corrected samples. Local authored packages keep their original heights by default.
535
+ Pass `filterElevation: false` to the package opening, stream or height-source options to inspect
536
+ the original DEM, or `true` to enable the same filter for a local package. Archive files are never
537
+ rewritten.
538
+
506
539
  Adaptive quality budgets include `maxSurfaceTileResolution` (33 economy, 65 balanced, 129 high).
507
540
  This limits render geometry without reducing the decoded heightfield used for sampling, feature
508
541
  draping, or collision.
@@ -309,12 +309,43 @@ and last eighth of that travel and stay open in between, while the legs swing:
309
309
 
310
310
  Each moving part rotates about one local axis, so the model gives it a parent frame aligned with
311
311
  its hinge: a canted trunnion, a door's edge. Author the GLB in the at-rest pose (gear down,
312
- doors as they stand on the ground); keys are displacements from it. A model whose retracted parts
313
- would show through the skin can also list them in `visual.gearNodes`, hidden while the gear is
314
- fully up. Simulated gear and flap positions come from `airplane.gearTransitTime` and
312
+ doors as they stand on the ground); keys are displacements from it. Rigged gear stays visible
313
+ inside its well, including exposed stowed wheels. Use an explicit `visible` binding if a part
314
+ must disappear at full retraction. The legacy `visual.gearNodes` hide/show fallback applies
315
+ only to nodes without position or rotation bindings. Simulated gear and flap positions come from `airplane.gearTransitTime` and
315
316
  `flapTransitTime` (see [Aircraft](aircraft.md)); a script can drive any other part by publishing
316
317
  a component and naming it in `sources`.
317
318
 
319
+ ## Graduated mechanisms
320
+
321
+ Vehicle and aircraft specs can declare `actuators`, keyed by a mechanism name. An ordinary
322
+ actuator takes `{ "seconds": 3 }` for a three-second full stroke. The corresponding input's
323
+ `actuators` map selects a number from 0 to 1 (or a boolean); the state component's map records
324
+ the actual position. Selecting the opposite target reverses from the current position. These
325
+ values are part of deterministic simulation and keyframes, including while parked.
326
+
327
+ For example, a car can declare `spec.actuators.hood = { seconds: 2 }`, receive
328
+ `vehicleInput.actuators.hood = 0.5`, and bind its `hood-hinge` rotation to a source
329
+ `{ "component": "vehicleState", "path": ["actuators", "hood"] }`. Bindings displace the
330
+ authored rest pose, so hinge origins belong in the model.
331
+
332
+ `mode: "cycle"` makes `seconds` the complete cycle duration: use a 0 → 1 → 0 binding curve
333
+ for a wiper and set its input true to run. Switching off completes the current cycle and parks.
334
+ `seconds: 0` switches a state immediately, such as headlight emission. `mode: "latch"` starts
335
+ an irreversible stroke once selected, suitable for emergency release. Ordinary positional
336
+ actuators are reversible. `initial` supplies the default target and initial position.
337
+
338
+ Aircraft use the same mechanism map for `canopy`, `tailHook` and `speedBrake`; gear and flaps
339
+ retain `gearPosition` and `flapPosition`. Set `airplane.speedBrakeDrag` to the drag coefficient
340
+ added at full speed-brake deployment. Helicopters default to fixed gear; a wheeled retractable
341
+ model sets `helicopter.fixedGear: false` and `gearTransitTime`.
342
+
343
+ The navigation drive/pilot profiles emit actuator press counts: B speed brakes, H hook,
344
+ O canopy, K wipers, L lights, 1–4 doors, 5 hood, 6 rear access. Earth vehicle/aircraft hosts
345
+ apply supported controls only. Use `EarthVehicles.toggleActuators` before `update` when
346
+ consuming navigation input directly. Aircraft cockpit panels expose fractional targets.
347
+ Unsupported equipment should be omitted from the spec instead of drawing fictional parts.
348
+
318
349
  ## Exterior views and detail levels
319
350
 
320
351
  Cockpit and chase views share the GLB. An interior can be a high-detail portion of that model,
@@ -1,5 +1,9 @@
1
1
  # Mountable vehicles and driving
2
2
 
3
+ Vehicles can carry authored [glass surfaces](glass.md). Collision impulses load each pane by
4
+ its mass and orientation: laminated windshields crack while retained, tempered panes fragment,
5
+ and frame/interlayer failure is independent of fracture.
6
+
3
7
  Generic vehicles use the Bendy house brand, with stable asset/type IDs. The Bendy Bus and
4
8
  Bendy Light Rail are also mountable through the vehicle API. World Explorer has buttons for
5
9
  both at the practice area: W/S applies traction or reverse, Space brakes, V switches view,
@@ -129,13 +133,40 @@ car it hits stays put. Terrain gaps pause motion; abrupt steps and slopes above
129
133
  the car. Cockpit views use the full chassis quaternion; chase views shorten at obstructions.
130
134
 
131
135
  This is a grounded driving model. It does not implement airborne rotation, rollovers, crash
132
- deformation or damage, pushing other cars, per-surface friction (grass and gravel grip like the
136
+ deformation, pushing other cars, per-surface friction (grass and gravel grip like the
133
137
  road), passenger animation, multiplayer ownership, or disk persistence. Background traffic is a
134
138
  separate package: [ambient life](ambient-life.md) moves NPC cars along lanes without this solver,
135
139
  and they stop for a car someone is driving. Without collision hooks, the reusable kernel solver
136
140
  supplies terrain driving only. Do not attach a second physics body to the same vehicle; the
137
141
  vehicle solver owns its transform.
138
142
 
143
+ ### Breakable parts
144
+
145
+ The ground-vehicle catalog (cars, buses, cycles and rail vehicles) binds independent wheels and
146
+ exterior panels to `spec.collisionParts`.
147
+ Hard contact reduces the struck part's joint integrity; a broken joint releases its named GLB
148
+ geometry as debris with its own velocity, spin, gravity and collisions. Other parts stay attached.
149
+ Lost wheels reduce grip and drive force on their axle; front-wheel loss also reduces steering.
150
+ Hard landings can break wheel joints. This remains a grounded chassis approximation: the body
151
+ does not roll over or simulate individual suspension collapse after losing a wheel.
152
+
153
+ Each part declares `id`, `role` (`frontWheel`, `rearWheel`, `panel` or `engine`), model-space
154
+ `center`, sphere `probes` and `radius`, `massFraction`, `breakSpeed` in m/s, and exact GLB `nodes`.
155
+ An optional `hinge` has a `pivot`, unit `axis`, full-travel `angle` and `actuator` name; it moves
156
+ door, hood and trunk probes with the panel. Joint strengths are gameplay tuning. Hosts supply
157
+ `VehicleEnvironment.contacts(probes, entity)` for detailed obstacles alongside `canOccupy` for
158
+ the chassis. Chassis impacts also load nearby joints using the inferred contact point, even
159
+ with only `canOccupy`. `vehicleObstacleContacts` from `client/vehicles` adapts resident triangle geometry
160
+ and nearby vehicles. Detailed contacts additionally detect parts extending beyond the chassis.
161
+
162
+ `vehicleState.damage` and `debris` survive keyframes. Debris expires after 20 simulation seconds;
163
+ the part stays missing. Pass the state as the sixth argument to `VehicleVisual.update` to apply
164
+ damage after animation; Earth view and World Explorer do this automatically. Press **R** once
165
+ stopped to repair parts in place. Hosts can call `EarthVehicles.recover()`, `EarthView.recover()`
166
+ in drive mode, or `repairVehicle(world, id)` from `kernel/vehicles`. Glass has its own fracture
167
+ state and is not repaired by this operation. Other vehicles remain static collision targets;
168
+ debris-to-debris collisions and damage transfer into the struck vehicle are not simulated.
169
+
139
170
  All durable simulation state and mount relationships live in ECS components and survive keyframes
140
171
  and replay. Install the same systems/environment when restoring. Host streaming and render resources
141
172
  are separate from those checkpoints.
@@ -151,6 +182,21 @@ ground (under open sky, never a roof or deck), `board(id)` without walking to th
151
182
  in. The entity's `vehicle.color`, when set, paints the model's `paintMaterial`; without one the
152
183
  authored paint stays.
153
184
 
185
+ A host can make boarding two presses, as the world explorer does: `openDoor(eye)` opens the shut
186
+ front door (`doorFrontLeft` or `doorFrontRight`) on the walker's side of the nearest car in reach
187
+ and returns false when there is none, so the next press falls through to `enter(eye)`.
188
+ `closedDoor(id, eye)` names that door for a prompt. The door shuts behind the driver, or once
189
+ nobody is within reach; calling `openDoor(eye, id)` after `exit()` swings it open as the driver
190
+ steps out.
191
+
192
+ A stopped [ambient traffic](ambient-life.md#taking-a-stopped-car) car (slower than 0.5 m/s) is a
193
+ car in reach too, in `mountEarthView` and for these methods: `openDoor` or `enter` takes it out
194
+ of traffic, and a drivable car of its type and paint stands at its pose, after which the doors,
195
+ seats and exits work as for any parked car. `trafficSolids()` lists circles around the cars a
196
+ driver has left standing, for `EarthAmbient.sync`, so traffic queued behind one keeps its gap
197
+ until it drives off. A taken car nobody drove away rejoins traffic once its model unloads 65 m
198
+ away; one driven elsewhere stays parked. Moving traffic is never boardable.
199
+
154
200
  Parked cars become simulation entities only within 300 m of the observer passed to `sync`, to
155
201
  approach, board and collide with; farther ones that nobody moved are reclaimed and stay part of
156
202
  their tile's merged mesh. Under an aircraft a town's parked cars were otherwise thousands of