@bendyline/molen-tooling 0.0.13 → 0.0.14

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 (37) 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 +54 -16
  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/earth-view.md +45 -8
  10. package/dist/docs-src/guide/glass.md +134 -0
  11. package/dist/docs-src/guide/graphics-performance.md +24 -6
  12. package/dist/docs-src/guide/navigation.md +23 -5
  13. package/dist/docs-src/guide/night-lighting.md +2 -1
  14. package/dist/docs-src/guide/regional-fleets.md +9 -4
  15. package/dist/docs-src/guide/regional-world.md +6 -2
  16. package/dist/docs-src/guide/sky.md +2 -2
  17. package/dist/docs-src/guide/surface-rendering.md +9 -3
  18. package/dist/docs-src/guide/terrain.md +32 -5
  19. package/dist/docs-src/guide/vehicle-interiors.md +34 -3
  20. package/dist/docs-src/guide/vehicles.md +47 -1
  21. package/dist/docs-src/guide/weather.md +60 -21
  22. package/dist/docs-src/llms.txt +3 -2
  23. package/dist/docs-src/schemas/components.md +979 -140
  24. package/dist/templates/city-courier/gen/molen-types.ts +103 -2
  25. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +102 -1
  26. package/dist/templates/city-courier/src/shared/playback.ts +21 -10
  27. package/dist/templates/cubes/src/shared/playback.ts +21 -10
  28. package/dist/templates/data-viz/src/shared/playback.ts +21 -10
  29. package/dist/templates/figures-gallery/src/shared/playback.ts +21 -10
  30. package/dist/templates/index.json +17 -17
  31. package/dist/templates/skybound/gen/molen-types.ts +103 -2
  32. package/dist/templates/skybound/scripts/molen-scripts.d.ts +102 -1
  33. package/dist/templates/skybound/src/shared/playback.ts +21 -10
  34. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +102 -1
  35. package/dist/templates/top-down-arena/src/gen/molen-types.ts +103 -2
  36. package/dist/templates/top-down-arena/src/shared/playback.ts +21 -10
  37. package/package.json +12 -12
@@ -1,18 +1,20 @@
1
1
  # Adaptive rendering performance
2
2
 
3
3
  The world explorer defaults to **Auto (device)** quality. It measures frame cadence, CPU frame
4
- work, and asynchronous GPU time when the WebGL extension is available. Six rendering tiers
5
- target 60 FPS without changing simulation state. Manual Economy, Balanced, and High remain
6
- available and can be selected without reloading or moving the camera.
4
+ work, and asynchronous GPU time when WebGL timer queries or WebGPU timestamps are available.
5
+ Six rendering tiers target 60 FPS without changing simulation state. Manual Economy, Balanced,
6
+ and High remain available and can be selected without reloading or moving the camera.
7
7
 
8
8
  ## Feedback and budgets
9
9
 
10
10
  `AdaptiveQualityController` from `@bendyline/molen-client` returns a new integer tier when the
11
11
  host should change its budgets. It evaluates one-second windows, uses trimmed frame averages
12
12
  and slow-frame/p90 statistics, and waits for warmup and sustained overload before lowering detail.
13
- Memory pressure can also lower detail. Recovery requires stable headroom, no pending streaming,
14
- and memory margin in displayed content; failed upward probes increase the recovery delay. Hidden intervals and
15
- isolated long pauses reset or bypass measurements instead of being mistaken for normal rendering.
13
+ Memory pressure can also lower detail. Recovery requires stable headroom and memory margin in
14
+ displayed content. During continuous streaming, both CPU and GPU timings must show spare capacity;
15
+ without GPU timing, recovery waits for streaming to settle. Failed upward probes increase the
16
+ recovery delay. Hidden intervals and isolated long pauses reset or bypass measurements instead
17
+ of being mistaken for normal rendering.
16
18
  While content streams, slow frames lower detail only when the measured CPU/GPU frame work is itself
17
19
  heavy: streaming work runs outside the frame, and a lower tier would restart it. After a memory
18
20
  step, the controller lets that step's lower-detail replacements load (up to the recovery delay)
@@ -20,17 +22,21 @@ before stepping again, since retained content keeps displayed bytes high until t
20
22
  The explorer starts sampling once its first view has finished loading, or after 20 seconds: the
21
23
  first frames carry one-time work (ground refining under the camera, collision trees rebuilt for
22
24
  each refinement, models and materials arriving), and measured as overload it stepped a fast
23
- desktop to the lowest tier before the visitor had moved. While calibrating it recovers quickly
24
- but lowers detail only after 2.5 s of overload (`EARTH_CALIBRATION_QUALITY`): lifting off reveals
25
- a whole view at once, and the second of streaming that follows took every takeoff down a level,
26
- then back up in flight, a rebuild each way. Auto climbs no higher than Balanced, like Earth view's
27
- default `maxQualityLevel`; above it buildings switch to the high preset, which rebuilds them across
28
- the view. Once a level has held for
29
- `EARTH_QUALITY_CALIBRATION_MS` (12 s), the explorer, like Earth view, adapts with
30
- `EARTH_STICKY_QUALITY` timings: down after 2.5 s of sustained overload, up after 20 s of headroom,
31
- changes at least 6 s apart. Every change swaps resolution, shadows and building detail across the
32
- view (Low and Medium differ in worldgen quality, so a step regenerates every resident town tile),
33
- and the quick defaults flipped a jet between them every 10 to 15 seconds.
25
+ desktop to the lowest tier before the visitor had moved.
26
+
27
+ The explorer starts at Balanced and can climb through High to Ultra, using measured performance
28
+ rather than the GPU's name. It uses `EARTH_STICKY_QUALITY` timings from the start: down after
29
+ 2.5 s of sustained overload, up one tier after 20 s of headroom, and frame-time changes at least
30
+ 6 s apart. Measurements use one-second windows, so these are approximate delays. A failed upward
31
+ probe doubles the recovery delay, up to 120 s; that history stays with the controller throughout
32
+ the session. Selecting a manual preset resets it. Hidden time and startup loading do not earn an
33
+ upgrade. Manual presets remain fixed.
34
+
35
+ High switches buildings to a more detailed preset, so promotions need sustained headroom and the
36
+ explorer applies the resolution, terrain, building, surface and shadow changes over separate
37
+ frames. Brief takeoff/streaming stalls do not immediately undo an upgrade. The embeddable Earth
38
+ view retains its separate default ceiling of Balanced (`maxQualityLevel: 3`) and its initial
39
+ 12 s calibration policy; hosts can explicitly raise that ceiling.
34
40
 
35
41
  The explorer applies each tier to drawing-buffer resolution, terrain screen-space error and
36
42
  range, selected/resident tile limits, terrain and semantic request concurrency, worldgen cache
@@ -34,10 +34,10 @@ streaming and floating-origin changes. Reloading starts a fresh session.
34
34
  | --- | --- |
35
35
  | E | Board, or exit after landing, stopping and engine shutdown |
36
36
  | I | Start/stop engine; allow the propeller or rotor to spool |
37
- | Shift / Ctrl | Increase/decrease throttle or helicopter collective; fighter afterburners engage above 85% throttle |
37
+ | = / − | Increase/decrease throttle or helicopter collective; fighter afterburners engage above 85% throttle |
38
38
  | W / S | Nose down / nose up |
39
39
  | A / D | Bank left / right; helicopter cyclic |
40
- | Q / Z | Left / right rudder or anti-torque pedals; ground steering in the Mustang |
40
+ | Z / C | Left / right rudder or anti-torque pedals; ground steering in the Mustang |
41
41
  | Space | Wheel brakes |
42
42
  | G | Retract/extend airplane gear while airborne |
43
43
  | F | Toggle airplane flaps |
@@ -48,7 +48,7 @@ streaming and floating-origin changes. Reloading starts a fresh session.
48
48
 
49
49
  Mustang: start the engine, set flaps, hold the brake while raising throttle, then release the brake.
50
50
  The propeller swings the nose left as the tail gets light, and a crosswind turns it into the wind:
51
- hold a little right rudder (Z), or rudder away from the wind, to keep the runway centerline.
51
+ hold a little right rudder (C), or rudder away from the wind, to keep the runway centerline.
52
52
  Rotate around 85–100 knots and release the pitch key once the nose is about 10 degrees up; the
53
53
  airplane keeps the attitude it lifted off at. At climb power the propeller's torque rolls it
54
54
  slowly left, so tap right bank (D) as needed. Retract gear and flaps after climbing. Reduce
@@ -79,7 +79,7 @@ markings are decorative, while live flight readings come from the HUD. Board at
79
79
  entry point. Its larger footprint needs substantially more runway and clearance.
80
80
 
81
81
  Osprey and Harrier: use J to select vertical thrust (the parked Osprey starts there), allow the nacelles/nozzles to
82
- reach 90°, start the engine and increase power smoothly. W/S, A/D and Q/Z provide powered pitch,
82
+ reach 90°, start the engine and increase power smoothly. W/S, A/D and Z/C provide powered pitch,
83
83
  roll and yaw control in a hover. Transition toward forward thrust gradually while gaining airspeed;
84
84
  the nacelles take 12 seconds for full travel and Harrier nozzles take 3. These are simplified
85
85
  powered-lift dynamics, with finite travel, vertical thrust, engine-dependent hover authority and
@@ -105,25 +105,47 @@ and a small rebound. A wingtip strike can turn the aircraft while it keeps movin
105
105
  continues to fall, tumble and slide. Terrain is tested at the airframe probes as well as at the
106
106
  landing origin, so a banked wing can hit the runway before the wheels or fuselage.
107
107
 
108
- The Mustang has detachable wings, tail surfaces and propeller; the OH-6 has a detachable rotor
109
- and tail; the small airliner has detachable wings (with their engines) and tail. Strong impacts
108
+ The Mustang has detachable wings, tail surfaces and propeller; the OH-6 has separate main rotor,
109
+ tail rotor and tail sections; the small airliner has detachable wings (with their engines) and
110
+ tail. Every animated rotor, propeller and fan in the aircraft catalog has its own collision disc
111
+ and breakable joint. Strong impacts
110
112
  or repeated loaded scrapes consume joint integrity. Separation removes the section's collision
111
113
  probes, reduces lift/control authority and can disable its attached engines. An asymmetric wing
112
114
  loss produces a rolling moment. Detached geometry retains its own velocity and spin, then falls,
113
115
  bounces and slows against terrain and resident obstacles. Debris expires after 20 simulation
114
116
  seconds; the missing section stays missing. **R** repairs the aircraft and clears debris.
115
- The remaining aircraft use their existing probes with the new contact response; they need
116
- authored section bindings to display parts breaking away.
117
+ Losing both wings switches the fuselage to ballistic wreck motion, disabling thrust and flight
118
+ controls. Ground and obstacle contact dissipates wreck spin as well as sliding motion, so the
119
+ fuselage settles after impact; airborne wrecks continue to fall and tumble.
120
+ Other aircraft retain their existing airframe probes alongside their independent rotor parts;
121
+ additional wing, tail and gear separation requires authored section bindings.
122
+
123
+ Rotors collide across their complete swept disc, including its interior and the spaces between
124
+ the old tip probes. The obstacle adapter clips triangles to the disc's thickness and tests the
125
+ radial boundary: geometry above or below a horizontal rotor clears it. Both rotors on tandem
126
+ helicopters and both Osprey proprotors are independent; the latter follow the actual nacelle
127
+ conversion position. Blade speed contributes to joint damage, so hovering beside a post can
128
+ break a spinning rotor even when the hub is stationary. Propeller loss disables its engine;
129
+ tail-rotor loss removes anti-torque authority and produces yaw. These conservative swept
130
+ volumes remain active when stopped, regardless of visible blade phase.
117
131
 
118
132
  For custom models, `spec.collisionParts` replaces `collisionProbes`. Every section declares a
119
- unique `id`, a `role` (`body`, `leftWing`, `rightWing`, `tail`, `rotor`, `gear` or `engine`), local
133
+ unique `id`, a `role` (`body`, `leftWing`, `rightWing`, `tail`, `rotor`, `tailRotor`, `gear` or `engine`), local
120
134
  probe centers and sphere `radius`, a section `center`, `massFraction`, and GLB `nodes`. Add
121
135
  `breakSpeed` in m/s for a breakable joint and `engines` for engines carried by that section.
122
136
  Keep a non-detachable `body` and at least 20% of the mass. Optional `fragments` selects triangles
123
137
  from shared static detail meshes using a model-space bounding box, so markings follow a wing.
138
+ `disc` replaces a section's sphere probes with a model-space `center`, unit `normal`, `radius`,
139
+ `halfThickness` and `rotor` node from `visual.rotors`. Its optional `tilt` hinge (`pivot`, unit
140
+ `axis`, `angle`) follows `thrustVectorPosition`. A `parent` part id makes a rotor separate when
141
+ its supporting wing or tail breaks, with no duplicate geometry or debris. Detached rotors
142
+ inherit their shaft spin. Terrain uses deterministic samples of the disc interior, rim and
143
+ lowest point; arbitrary height fields are not exact triangle meshes.
144
+
124
145
  These are gameplay approximations with authored joint strengths, not a structural engineering
125
- or accident-reconstruction model. Pieces use sphere collision proxies; mesh deformation, fire,
126
- debris-to-debris contacts and impulse transfer into other vehicles are not simulated.
146
+ or accident-reconstruction model. Detached pieces use sphere collision proxies; mesh deformation, fire,
147
+ debris-to-debris contacts and impulse transfer into other vehicles are not simulated. The obstacle
148
+ adapter uses oriented boxes for other cars and body-center spheres for other aircraft.
127
149
 
128
150
  Hosts provide `AircraftEnvironment.contacts(probes, entity)` with world-space contact points,
129
151
  outward normals and penetration depths. `aircraftObstacleContacts` from `client/aircraft`
@@ -175,6 +197,13 @@ ownership of a loaded GLB and animates the nodes named by `spec.visual` from air
175
197
  exterior moving parts as [model-signal bindings](vehicle-interiors.md#exterior-animation), with
176
198
  keyframed curves so one gear position can sequence doors and legs.
177
199
 
200
+ Exposed airplane propellers fade from individual blades into a translucent, soft-edged disk
201
+ between 20 and 60 rad/s (about 190–570 RPM). The disk follows actual shaft speed, including
202
+ independent engines and spool-down, so blades cannot appear frozen at normal operating RPM.
203
+ Its size and radial colors come from the blade geometry and materials; separate central hubs stay solid.
204
+ This render-only effect needs no model changes and works with WebGL and WebGPU. Helicopter
205
+ rotors and enclosed jet fans retain their existing animation.
206
+
178
207
  For powered lift, declare `spec.poweredLift` with positive `transitTime`, `controlFadeSpeed`,
179
208
  `pitchAuthority`, `rollAuthority`, `yawAuthority` and `damping`, and mark the participating
180
209
  forward-facing engine installations `vectored: true`. `aircraftInput.thrustVector` is 0–1;
@@ -258,8 +287,8 @@ Published cruise, maximum and operating speeds are different quantities. Where a
258
287
  not specify weight, altitude or throttle, the test condition is explicitly estimated. Some
259
288
  aircraft still have engineering-estimate anchors. Passing a fitted anchor establishes internal
260
289
  consistency, not independent real-world validation. All polar, lapse and high-alpha coefficients
261
- remain approximations. Fuel burn, stores, changing mass/CG, detailed engine maps, icing,
262
- structural failures and certified flight-control laws are not modeled.
290
+ remain approximations. Fuel burn, stores, continuous CG changes, detailed engine maps, icing,
291
+ fatigue, load-induced structural failures and certified flight-control laws are not modeled.
263
292
 
264
293
  Flight assistance is limited to the pitch axis, so a keyboard can fly it. The stick moves an
265
294
  elevator (deflecting at `pitchResponse` per second and springing back four times faster) that
@@ -420,10 +449,11 @@ wind and forward motion give consistent results. Collision sampling is at least
420
449
  of translation per substep. Unknown terrain pauses at the last known position and resumes when
421
450
  support is available.
422
451
 
423
- Hosts can supply `groundHeight`, `wind` and `canOccupy(transform, spec, entity)`. The world view
452
+ Hosts can supply `groundHeight`, `wind` and `contacts(probes, entity)` (or the legacy
453
+ `canOccupy(transform, spec, entity)`). The world view
424
454
  checks nearby resident geometry, the airfield, cars and other aircraft. Cars and exits also check
425
455
  conservative aircraft bounds. Imported collision hulls are
426
- available for hosts that need a different collision solver. Without `canOccupy`, the kernel only
456
+ available for hosts that need a different collision solver. Without either obstacle callback, the kernel only
427
457
  collides with terrain. Do not add a second physics body that also writes the aircraft transform.
428
458
 
429
459
  This is a game flight model with recognizable polygonal aircraft, not a full aircraft systems
@@ -446,7 +476,7 @@ master switches, individual engine switches and throttles for airplanes with nam
446
476
  parking brakes, and applicable gear, flap and nozzle controls. Supplemental labeled modules fill
447
477
  gaps in the original models; their layout approximates the aircraft rather than reproducing every
448
478
  real switch. The Cessna 172's existing master rocker and flap selector are directly operable.
449
- Moving common power (including Shift/Ctrl or the modeled **PWR ALL** handle)
479
+ Moving common power (including =/− or the modeled **PWR ALL** handle)
450
480
  synchronizes all throttle levers while preserving individual engine cutoffs, mixtures and propeller settings. A throttle indicates
451
481
  commanded power; shaft RPM follows the simulation's spool response. Retractable airplane gear is
452
482
  locked on the ground. Helicopters retain the existing shared engine/gearbox model and collective.
@@ -538,3 +568,11 @@ hold is a harness feature, not a player control or a certified performance chart
538
568
  `packages/kernel/test/aircraft-engines.test.ts` covers symmetric two/four-engine layouts,
539
569
  mirrored engine failures, counter-rudder, thrust moment arms, independent switches/spool,
540
570
  explicit repair, terrain rollback, exit safety, keyframe restoration and 30/60/120 Hz consistency.
571
+
572
+ Exterior mechanisms use the snapshot-owned [graduated actuator system](vehicle-interiors.md#graduated-mechanisms).
573
+ Canopies, hooks and speed brakes accept fractional targets through `aircraftInput.actuators`;
574
+ `aircraftState.actuators` holds actual travel. Ordinary mechanisms reverse immediately from
575
+ their current position. Speed-brake drag follows deployment. Retractable helicopter gear
576
+ uses `helicopter.fixedGear: false` and `gearTransitTime`; skids remain fixed by default.
577
+ The supplied aircraft expose only fitted equipment. Helicopter blade release is a gameplay
578
+ escape effect, triggered by the latched `eject` actuator, and removes rotor lift after release.
@@ -341,7 +341,8 @@ The quality tier caps the numbers:
341
341
  | Ultra | 320 | 120 | 2 | 4 | 16 | 1000 m |
342
342
 
343
343
  Ambient cars share the view's vehicle world, so the car you drive stops against them and traffic
344
- waits for you, and for the view's [actors](earth-view.md#actors-companions-and-npcs) on foot. They
344
+ waits for you, for the view's [actors](earth-view.md#actors-companions-and-npcs) on foot and for
345
+ cars a driver left standing. They
345
346
  follow the rendered ground and bridge decks, and they rebuild when the view re-anchors after a long
346
347
  trip.
347
348
 
@@ -367,6 +368,16 @@ no longer counts or removes it, and the actors draw it from then on, looking at
367
368
  interactable unless the spec says otherwise. `adopt` returns undefined when the pedestrian has
368
369
  already gone. It is one-way; an actor never returns to the pool.
369
370
 
371
+ ### Taking a stopped car
372
+
373
+ A walker can take over a traffic car that has stopped (slower than 0.5 m/s), such as one waiting
374
+ for them at the kerb. `EarthVehicles` counts it as a car in reach: `openDoor` and `enter` take it
375
+ out of traffic and stand a drivable car of the same type and paint at its pose, and the agent
376
+ leaves in the frame that car's model shows. Pass `vehicles.trafficSolids()` to `ambient.sync`
377
+ with your other solids, so the cars queued behind it keep their gap until it drives off. A taken
378
+ car nobody drove away rejoins traffic where it stopped once its model unloads (65 m away); one
379
+ driven elsewhere stays parked there. Moving traffic is never boardable.
380
+
370
381
  ## NPC content and `ambientRole`
371
382
 
372
383
  An entity type joins the ambient pools with an `ambientRole`:
@@ -489,7 +500,9 @@ most one tile every 200 ms. In the engine repository,
489
500
  counts follow the width when OSM does not give them.
490
501
  - Aircraft fly straight lines. They do not taxi, circle or land beyond the approach.
491
502
  - Pedestrians keep to their lane and follow the walker ahead. They do not step around each other.
492
- - Agents do not open doors, board, or park. A parked car in the Earth view is a separate entity.
503
+ - Agents do not open doors, board, or park. A walker can take a stopped car out of traffic (see
504
+ [Taking a stopped car](#taking-a-stopped-car)); a parked car in the Earth view is a separate
505
+ entity.
493
506
  - A promoted pedestrian keeps its body but nothing of its walk: it stands until its actor
494
507
  behaviour moves it, and it never rejoins ambient life.
495
508
 
@@ -17,7 +17,7 @@ play without opening a browser.
17
17
  | `molen.audio.*` | scene scripts | `play`, `stop` and `music`, emitted as `audio.*` events |
18
18
  | `@bendyline/molen-client/audio` | the page | `createAudioLayer` loads banks and plays what the rules ask for |
19
19
 
20
- The `molen.sounds` content pack carries 165 CC0 sounds (ambience, vehicles, footsteps, impacts,
20
+ The `molen.sounds` content pack carries 170 CC0 sounds (ambience, vehicles, footsteps, impacts,
21
21
  foley, UI, stings and six music tracks). Fetch it into a project with:
22
22
 
23
23
  ```sh
@@ -212,6 +212,43 @@ boats and exterior cameras retain outside ambience. Only one bed per category pl
212
212
  staggered rotation and five-second crossfades. See [Earth view](earth-view.md) for host inputs.
213
213
  Pass `audio: false` to turn it off, and use `view.audio` for volume.
214
214
 
215
+ Vehicle details use the same simulation snapshots as the visuals:
216
+
217
+ - Pedestrian-signal recordings belong to the `earth:category:crossing` pool. They require a
218
+ nearby mapped or rendered traffic signal, fade to silence 55 m from the junction edge and
219
+ 25 m above ground, and stay silent when the map context is unknown. Ordinary traffic keeps
220
+ its separate road-distance mix. The recording contains its own signal cycle; it is not a
221
+ promise that a simulated crossing is safe to use.
222
+ - Paved airplane touchdowns play a short tire spin-up chirp, scaled by ground speed and descent
223
+ rate. Retracted gear, crashes, grass/unknown surfaces, parked spawns and rapid landing bounces
224
+ stay quiet. Composing hosts supply `EarthAudioFrame.surfaceAt(x, z)` so contact uses the
225
+ aircraft's position; the standard Earth view and World Explorer do this automatically.
226
+ - Door, hood and trunk actuator movement triggers opening/sliding foley; a closing latch sounds
227
+ only when travel reaches the shut position. Van rear doors slide. Wipers sound at each
228
+ half-cycle of their actual actuator phase, including the return stroke when switched off.
229
+ Legacy vehicles retain boarding cues. Passenger boarding never starts or stops an engine.
230
+ - Flap and retractable landing-gear motor loops track changes in `flapPosition` and
231
+ `gearPosition`. They run during extension/retraction, preserve one voice through reversals,
232
+ and fade out when the mechanism stops, including partial flap settings. Fixed or instant
233
+ gear stays silent; retractable helicopter gear is supported. Pauses, teleports, removed
234
+ aircraft and world switches clean up the loops. The two generic servo recordings are CC0:
235
+ [vacuumfan7072](https://freesound.org/people/vacuumfan7072/sounds/264592/) and
236
+ [Burningmonkey](https://freesound.org/people/Burningmonkey/sounds/322021/).
237
+ - Helicopter engine loops tagged `rotor` use estimated collective and cyclic feathering angles,
238
+ bank/rate, descending inflow and listener direction to change gain, low-pass cutoff and a
239
+ once-per-revolution loading envelope. Web Audio generates that envelope at audio rate;
240
+ the recorded blade-passage chop remains intact. RPM still controls playback speed. This is
241
+ an authored acoustic approximation, not a calibrated aerodynamic noise solver, and it does
242
+ not change flight physics or replay hashes. The dependency choices are informed by NASA's
243
+ [maneuvering flight noise study](https://ntrs.nasa.gov/citations/20160005979).
244
+
245
+ Interactive emitters take priority over background beds when the voice budget is full. Missing
246
+ new foley in older/custom packs is silent. The added recordings are CC0, with source pages,
247
+ authors, verified license dates and source hashes in the sound pack's `sources.json` and credits
248
+ in `NOTICE.md`: [tire foley](https://freesound.org/people/johnnydekk/sounds/614627/),
249
+ [wipers](https://bigsoundbank.com/windshield-wipers-slow-2-s3111.html) and
250
+ [sliding door foley](https://freesound.org/people/SwagMuffinPlus/sounds/176146/).
251
+
215
252
  Sound packs can also provide a `birdsong` document (`molen/earth-birdsong@1`). The default pack
216
253
  contains eight CC0 regional recordings, selected by geography, observed habitat, calendar month
217
254
  and local sunlight. Dawn choruses peak near sunrise, breeding songs quieten outside their authored
@@ -166,6 +166,17 @@ renderer, and on a software rasterizer it will lose.
166
166
 
167
167
  ## Manual frame loop
168
168
 
169
+ Automatic clients pause the kernel and stop rendering when the browser window loses focus or
170
+ the tab becomes hidden. Queued GPU preparation waits too. Focus resumes playback without
171
+ catching up the time spent away; an explicit pause or a `startPaused` loading screen stays paused.
172
+ GPU resources remain allocated for a quick return — this frees rendering capacity, not VRAM.
173
+ Pass `pauseWhenInactive: false` to keep a live client running in the background.
174
+
175
+ Manual frame loops and snapshot captures remain host-controlled by default. A manual live client
176
+ can opt into worker suspension with `pauseWhenInactive: true`; its host still owns render calls.
177
+ Custom loops can use `observePageActivity(callback)` to observe initial activity and subsequent
178
+ window focus/blur and page visibility changes; its return value removes the listeners.
179
+
169
180
  Pass `frameLoop: 'manual'` to drive rendering yourself (machinima camera tracks, custom timing):
170
181
 
171
182
  ```ts
@@ -46,6 +46,7 @@ subsystem's contribution to the state hash reproduces.
46
46
  | Scene scripts | Cross-platform **until** the script calls a transcendental; then same JS engine | the Compartment's `Math` is IEEE-exact natives plus `dmath` for everything else (`kernel/src/scripting.ts`); `Math.random` is absent and `Date`/`Intl`/`Promise` are shadowed to `undefined` |
47
47
  | Quaternion helpers that use angles — `quatSlerp`, `lookRotation`, `quatFromYaw`, `quatFromEuler`, `yawOf` | Same JS engine | `kernel/src/math3d.ts` routes these through `dmath.sin/cos/acos/atan2`, and `dmath` is currently a thin re-export of native `Math` |
48
48
  | Vehicles and aircraft | Same JS engine | `kernel/src/vehicles.ts` and `aircraft.ts` use `dmath.sin/cos/tan/atan2/exp` |
49
+ | Glass fracture and retention | Same JS engine | Authored panes and resolved contact loads produce persistent `glassState`; vehicle-driven loads inherit the chassis solver's guarantee. Debris is cosmetic and uses simulation time |
49
50
  | Figures (`@bendyline/molen-figures/kernel`) | Same JS engine | its locomotion system writes `figureState` and `transform.rot` into the world and registers a `figures` snapshot provider, so it **is** hashed; it reaches `dmath.atan2` and `quatFromYaw`, and `gait.ts` reaches `dmath.pow`/`sin`/`cos` |
50
51
  | Ambient life (`@bendyline/molen-ambient/kernel`) | Same JS engine | agent state (`ambientAgent`, the `$ambient` bookkeeping entity) and transforms are written into the world, so it **is** hashed; occupancy, junction grants and signal phases are rebuilt from components every tick, so a keyframe restores exactly into a world whose transport network was built from the same inputs. It reaches `dmath.acos/sin/cos` and `lookRotation`. The network itself is a `WeakMap` side channel like worldgen's |
51
52
  | `physics.engine: "rapier"` (3D rigid bodies) | Same build + platform | `@dimforge/rapier3d-compat` WASM; the plugin hashes an opaque `takeSnapshot()` blob plus its id→handle maps |
@@ -135,7 +136,7 @@ Two constants live in `packages/kernel/src/version.ts` and they do different job
135
136
 
136
137
  | Constant | Today | Role |
137
138
  |---|---|---|
138
- | `ENGINE_VERSION` | `0.0.9` | metadata. Written into a keyframe's `engine` field so a save says which build wrote it. **Never compared on load, never hashed.** |
139
+ | `ENGINE_VERSION` | `0.0.10` | metadata. Written into a keyframe's `engine` field so a save says which build wrote it. **Never compared on load, never hashed.** |
139
140
  | `STATE_FORMAT` | `1` | the gate. Written into a keyframe under the reserved `plugins.$format` key, compared by `applyKeyframeTo`, and folded into `stateHash` as `stateFormat`. |
140
141
 
141
142
  So a release — even one that moves every package — keeps your keyframes
@@ -59,6 +59,10 @@ worker you omit does its work on the main thread instead.
59
59
  Buildings appear with vertex colors while shared material textures bake in the background.
60
60
  Completed textures update the existing materials without regenerating buildings. Terrain detail
61
61
  refines in small groups, retaining visible detail during camera turns while replacements load.
62
+ With worldgen content, distant tiles retain broad landcover colors and bounded building silhouettes;
63
+ trees and street detail remain nearby. Water appears independently of those slower layers and also
64
+ warms just outside the camera view. Byte-cache prefetch includes distant landcover at every available
65
+ map level, so revisiting an area can reuse that coverage as well as its elevation and water.
62
66
 
63
67
  Metal and glass use a shared procedural sky/ground reflection environment by default. The viewer
64
68
  reuses its filtered texture until lighting changes; camera movement does not regenerate it.
@@ -91,16 +95,27 @@ neutral olive.
91
95
 
92
96
  Buildings, trees and landmarks cast sun shadows onto everything around what the camera frames:
93
97
  the orbit target (sized to the view), or a little ahead of the walker, car or aircraft. The
94
- shadow map follows that focus in whole texels, so edges hold still as it moves. Adaptive quality
98
+ shadow map follows that focus in whole texels anchored to world coordinates, including through
99
+ floating-origin rebases. Its coverage changes in small steps with hysteresis, so camera bob and
100
+ minor altitude changes do not resize the texel grid every frame. Adaptive quality
95
101
  turns shadows off at its two lowest levels; `shadows: false` turns them off entirely. Only layer
96
102
  parts taller than `EARTH_SHADOW_CASTER_HEIGHT` (3.5 m) cast: shrubs, brambles and saplings stay
97
103
  out of the shadow pass, where their shadows would mostly fall inside the canopy's.
98
104
 
99
105
  In flight the shadow footprint widens with height above the local ground: its half-width is
100
- four times that height, capped at 5 km, with a tighter footprint near the ground. This pushes
106
+ four times that height, capped at 5 km. Below 8 m the half-width is 24 m plus the height,
107
+ preserving aircraft and contact-shadow detail on the runway. The renderer rounds coverage up
108
+ to a stable size (and holds it through small changes). This pushes
101
109
  the shadow boundary farther into the distance in aerial views, trading some shadow sharpness
102
110
  for coverage at the same map resolution. Walking and driving keep their tighter footprints.
103
111
 
112
+ Earth viewers reserve a 4096-pixel sun map before preparing materials. WebGPU retains that
113
+ allocation across quality changes, so High really uses 4096 pixels even after starting at a
114
+ lower tier; WebGL can resize it with the tier. A chase camera 10 m above ground covers an
115
+ 80 m square, giving roughly 2 cm shadow texels on High for wings, propellers and landing gear.
116
+ Chase views also reserve at least the camera-to-aircraft distance as their half-width, keeping
117
+ large airliners and their shadows inside the tighter runway footprint.
118
+
104
119
  `touchJoystickContainer` adds an on-screen movement stick while walking, driving or flying. By default it
105
120
  appears only on touch devices; pass `touchJoystick: 'always'` to show it everywhere.
106
121
 
@@ -180,8 +195,8 @@ geographic (`viewer`, poses, places) is stable across re-anchors.
180
195
  ```ts
181
196
  view.setMode('walk', { at: { latitude, longitude, heading } }); // start here, facing heading
182
197
  view.walker.place({ latitude, longitude }); // teleport (enters walk mode if needed)
183
- view.walker.pose(); // { latitude, longitude, altitude, heading, speed, grounded } | undefined
184
- view.walker.ready; // standing on streamed ground
198
+ view.walker.pose(); // { latitude, longitude, altitude, heading, speed, grounded, swimming } | undefined
199
+ view.walker.ready; // placed on streamed ground or water
185
200
  ```
186
201
 
187
202
  A place inside the current frame drops the walker at once (it lands when the ground there has
@@ -190,6 +205,12 @@ another terrain region with `terrainSource`, re-anchors first: the mode is `walk
190
205
  orbit camera holds over the destination while the frame rebuilds, and the walker lands when it is
191
206
  done.
192
207
 
208
+ Walking into deep water automatically starts surface swimming; reaching shallow ground returns
209
+ to walking. The same movement controls apply, with Shift swimming faster. The camera stays above
210
+ the water, and `view.walker.pose()?.swimming` reports the transition without changing the `walk`
211
+ navigation mode. Water coverage comes from rendered water surfaces or the `waterAt` option,
212
+ including lakes above sea level.
213
+
193
214
  ```ts
194
215
  view.walker.setAvatar({ figure: { preset: 'human.adult', height: 1.7, palette: { top: '#2f5a3b' } } });
195
216
  view.walker.setAvatar({ type: 'my.app.character.guide' }); // an entity type with a `figure`
@@ -1019,7 +1040,11 @@ These regional forms are visual priors, not surveyed attributes of individual bu
1019
1040
  is still warm when the view pans back.
1020
1041
  - `stats().worldgen` counts styled building generation since the current terrain stream started
1021
1042
  (with content packs): tiles generated, buildings drawn as geometry, and instanced stand-ins.
1022
- - `setPaused(true)` stops rendering while the view is hidden, and `dispose()` releases the GPU
1043
+ - Window blur and hidden tabs automatically pause simulation, rendering, queued GPU preparation,
1044
+ audio and prefetching. Returning to a visible, focused page resumes without simulation catch-up.
1045
+ `setPaused(true)` keeps the view paused even after focus returns; `setPaused(false)` releases
1046
+ that manual pause. Pass `pauseWhenInactive: false` for a host that manages activity itself.
1047
+ Resources stay loaded for quick resume; GPU memory is retained. `dispose()` releases the GPU
1023
1048
  context, workers and listeners. Mounting is abortable through `signal`.
1024
1049
 
1025
1050
  ## Sound
@@ -1078,10 +1103,21 @@ the full contract and current prototype limits.
1078
1103
 
1079
1104
  ## Airport layouts
1080
1105
 
1106
+ Airport terrain is graded before terrain meshes, pavement and ground physics consume it. All
1107
+ runways of an airport and its mapped aerodrome grounds share a level surface, with shoulders
1108
+ and a smooth transition back to surrounding terrain. The height is inferred from fixed terrain
1109
+ samples along the runways; it is not surveyed runway elevation or slope data. The reference
1110
+ samples are independent of camera detail and tile load order. Hosts composing a pyramid stream
1111
+ can pass `transformHeightfield: createAirportTerrainGrading(content.airports)` alongside their
1112
+ `withEarthAirports` semantic renderers.
1113
+
1081
1114
  The `molen.earth` content pack supplies a lazy worldwide runway catalog and a detailed Boeing
1082
1115
  Field layout. Both Earth hosts use measured runway endpoints and widths, draw runway numbers,
1083
1116
  thresholds and centre lines, and keep airport pavement visible from flight altitude. Mapped
1084
1117
  taxiways and aprons have airport markings; airside areas do not become car parks or city streets.
1118
+ The pavement is drawn about half a metre above the terrain, and aircraft stand on it. A host
1119
+ placing its own objects there reads that height with `sampleAirportPavement(root, x, z, ground)`
1120
+ from `@bendyline/molen-terrain/client`, which returns undefined off the pavement.
1085
1121
  The airport overlay also supplies mapped hangar/building footprints and suppresses inferred
1086
1122
  vegetation and buildings on the airfield. Aircraft traffic uses the runway approach/departure
1087
1123
  corridors and remains simulated, rather than live aviation tracking.
@@ -1090,8 +1126,9 @@ The runway snapshot covers 10,746 airports with complete endpoint and width reco
1090
1126
  aprons, taxiways and hangars are currently bundled for Boeing Field; elsewhere these depend on
1091
1127
  the map's coverage. Building heights and untagged taxiway widths are interpreted. Runways with
1092
1128
  missing endpoints, closed runways and water runways are omitted. Supplemental airports also
1093
- render when the basemap has no tile (Boeing Field lies south of the bundled Seattle street-detail
1094
- coverage). No airport data is fetched without a supplied pack. Hosts composing their own
1129
+ render when the basemap has no tile (Itami lies outside the bundled Kyoto street-detail
1130
+ coverage). Seattle's street-detail coverage includes Boeing Field and its surroundings.
1131
+ No airport data is fetched without a supplied pack. Hosts composing their own
1095
1132
  terrain renderer can use `withEarthAirports`
1096
1133
  around semantic renderers and observers, passing `content.airports` from `loadEarthContent`.
1097
1134
 
@@ -1101,7 +1138,7 @@ of light aircraft, business aircraft and larger jets. Aircraft are fitted inside
1101
1138
  with clearance from buildings, taxiways, runways, other aircraft and reserved diorama areas.
1102
1139
  The fleet and parking positions are simulated, not live aircraft tracking or exact stand assignments.
1103
1140
 
1104
- Walk to an aircraft's door and press **E** to board, **I** to start, and **Shift/Ctrl** to adjust
1141
+ Walk to an aircraft's door and press **E** to board, **I** to start, and **=/−** to adjust
1105
1142
  power. The same aircraft taxis and flies away; its original stand remains empty for the session.
1106
1143
  Land, stop and shut down before exiting. Automatic parking keeps at most twelve unclaimed
1107
1144
  aircraft within 1.8 km; claimed aircraft remain owned vehicles across terrain re-anchors.
@@ -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.