@bendyline/molen-tooling 0.0.12 → 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 (55) hide show
  1. package/dist/capture/harness.js +616 -332
  2. package/dist/capture/worldgen-preview.js +540 -326
  3. package/dist/docs-src/guide/adaptive-performance.md +42 -9
  4. package/dist/docs-src/guide/aircraft.md +171 -11
  5. package/dist/docs-src/guide/ambient-life.md +30 -3
  6. package/dist/docs-src/guide/audio.md +38 -1
  7. package/dist/docs-src/guide/boats.md +9 -4
  8. package/dist/docs-src/guide/boost-mode.md +64 -0
  9. package/dist/docs-src/guide/browser-mount.md +11 -0
  10. package/dist/docs-src/guide/determinism.md +2 -1
  11. package/dist/docs-src/guide/dioramas.md +11 -4
  12. package/dist/docs-src/guide/earth-view.md +145 -8
  13. package/dist/docs-src/guide/entities.md +3 -0
  14. package/dist/docs-src/guide/glass.md +134 -0
  15. package/dist/docs-src/guide/graphics-performance.md +196 -14
  16. package/dist/docs-src/guide/input.md +34 -1
  17. package/dist/docs-src/guide/liveries.md +167 -0
  18. package/dist/docs-src/guide/livery-catalog.md +2659 -0
  19. package/dist/docs-src/guide/livery-gallery.md +2684 -0
  20. package/dist/docs-src/guide/medium-fi.md +13 -5
  21. package/dist/docs-src/guide/navigation.md +23 -5
  22. package/dist/docs-src/guide/night-lighting.md +97 -0
  23. package/dist/docs-src/guide/project.md +1 -1
  24. package/dist/docs-src/guide/regional-fleets.md +9 -4
  25. package/dist/docs-src/guide/regional-world.md +9 -3
  26. package/dist/docs-src/guide/rendering-backends.md +6 -2
  27. package/dist/docs-src/guide/sky.md +2 -2
  28. package/dist/docs-src/guide/surface-rendering.md +21 -3
  29. package/dist/docs-src/guide/terrain.md +68 -3
  30. package/dist/docs-src/guide/vehicle-interiors.md +34 -3
  31. package/dist/docs-src/guide/vehicles.md +60 -2
  32. package/dist/docs-src/guide/weather.md +60 -21
  33. package/dist/docs-src/guide/worldgen.md +20 -5
  34. package/dist/docs-src/llms.txt +8 -2
  35. package/dist/docs-src/schemas/archstyle.md +29 -0
  36. package/dist/docs-src/schemas/components.md +1790 -176
  37. package/dist/docs-src/schemas/regional-catalog.md +39 -0
  38. package/dist/docs-src/schemas/scatter.md +36 -0
  39. package/dist/docs-src/schemas/structure-placement-data.md +91 -0
  40. package/dist/docs-src/schemas/structure-placements.md +91 -0
  41. package/dist/docs-src/schemas/worldgen-batch.md +105 -0
  42. package/dist/templates/city-courier/gen/molen-types.ts +204 -1
  43. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +203 -0
  44. package/dist/templates/city-courier/src/shared/playback.ts +21 -10
  45. package/dist/templates/cubes/src/shared/playback.ts +21 -10
  46. package/dist/templates/data-viz/src/shared/playback.ts +21 -10
  47. package/dist/templates/figures-gallery/src/shared/playback.ts +21 -10
  48. package/dist/templates/index.json +17 -17
  49. package/dist/templates/skybound/gen/molen-types.ts +204 -1
  50. package/dist/templates/skybound/scripts/molen-scripts.d.ts +203 -0
  51. package/dist/templates/skybound/src/shared/playback.ts +21 -10
  52. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +203 -0
  53. package/dist/templates/top-down-arena/src/gen/molen-types.ts +204 -1
  54. package/dist/templates/top-down-arena/src/shared/playback.ts +21 -10
  55. package/package.json +12 -12
@@ -12,6 +12,13 @@ composes:
12
12
 
13
13
  You speak latitude and longitude; the view keeps its metric world frame internally.
14
14
 
15
+ [Night lighting](night-lighting.md) follows the sky’s Sun position: occupied windows and street
16
+ lamps fade in through dusk. Existing model glass can opt in with material lighting metadata.
17
+
18
+ [Boost mode](boost-mode.md) makes walking, driving and flying four times faster: press **T**, or
19
+ call `view.setBoostMode(true)`. Pass `boostMode: true` at mount to start enabled; read
20
+ `view.boostMode` and listen for `boostchange` to keep a host's toggle in sync.
21
+
15
22
  ```ts
16
23
  import {
17
24
  loadEarthContent,
@@ -44,12 +51,18 @@ creditsElement.textContent = view.credits.map((credit) => credit.label).join('
44
51
  ```
45
52
 
46
53
  Each worker file is one line, for example `import '@bendyline/molen-earth/workers/elevation';`.
47
- There are entries for `elevation`, `landcover`, `surface`, `worldgen` and `material`. Any worker
48
- you omit does its work on the main thread instead.
54
+ There are entries for `elevation`, `landcover`, `surface`, `worldgen`, `material` and `semantic`
55
+ (map tiles decoded off the main thread, where a town tile took 10-18 ms of a frame; hosts using
56
+ `createProfiledTerrainPackageSemanticLayers` directly pass such a worker as `decoderWorker`). Any
57
+ worker you omit does its work on the main thread instead.
49
58
 
50
59
  Buildings appear with vertex colors while shared material textures bake in the background.
51
60
  Completed textures update the existing materials without regenerating buildings. Terrain detail
52
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.
53
66
 
54
67
  Metal and glass use a shared procedural sky/ground reflection environment by default. The viewer
55
68
  reuses its filtered texture until lighting changes; camera movement does not regenerate it.
@@ -82,11 +95,27 @@ neutral olive.
82
95
 
83
96
  Buildings, trees and landmarks cast sun shadows onto everything around what the camera frames:
84
97
  the orbit target (sized to the view), or a little ahead of the walker, car or aircraft. The
85
- 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
86
101
  turns shadows off at its two lowest levels; `shadows: false` turns them off entirely. Only layer
87
102
  parts taller than `EARTH_SHADOW_CASTER_HEIGHT` (3.5 m) cast: shrubs, brambles and saplings stay
88
103
  out of the shadow pass, where their shadows would mostly fall inside the canopy's.
89
104
 
105
+ In flight the shadow footprint widens with height above the local ground: its half-width is
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
109
+ the shadow boundary farther into the distance in aerial views, trading some shadow sharpness
110
+ for coverage at the same map resolution. Walking and driving keep their tighter footprints.
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
+
90
119
  `touchJoystickContainer` adds an on-screen movement stick while walking, driving or flying. By default it
91
120
  appears only on touch devices; pass `touchJoystick: 'always'` to show it everywhere.
92
121
 
@@ -166,8 +195,8 @@ geographic (`viewer`, poses, places) is stable across re-anchors.
166
195
  ```ts
167
196
  view.setMode('walk', { at: { latitude, longitude, heading } }); // start here, facing heading
168
197
  view.walker.place({ latitude, longitude }); // teleport (enters walk mode if needed)
169
- view.walker.pose(); // { latitude, longitude, altitude, heading, speed, grounded } | undefined
170
- 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
171
200
  ```
172
201
 
173
202
  A place inside the current frame drops the walker at once (it lands when the ground there has
@@ -176,6 +205,12 @@ another terrain region with `terrainSource`, re-anchors first: the mode is `walk
176
205
  orbit camera holds over the destination while the frame rebuilds, and the walker lands when it is
177
206
  done.
178
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
+
179
214
  ```ts
180
215
  view.walker.setAvatar({ figure: { preset: 'human.adult', height: 1.7, palette: { top: '#2f5a3b' } } });
181
216
  view.walker.setAvatar({ type: 'my.app.character.guide' }); // an entity type with a `figure`
@@ -405,7 +440,22 @@ for `terrainchange` to refresh an attribution panel when the package changes. Di
405
440
  completed flights resolve the destination immediately; manual panning rechecks the host source
406
441
  after about five kilometers. A second jump while a region is loading follows the latest target.
407
442
 
408
- ## Byte cache and prefetch
443
+ ## Tile preparation, byte cache and prefetch
444
+
445
+ During flight and fast driving, nearby terrain is prepared ahead of travel automatically, even
446
+ without a byte cache. The view predicts camera positions 2, 4, 8 and 12 seconds ahead (up to 4 km),
447
+ following the measured turn rate through a bank as well as straight travel,
448
+ selects their tiles at the current detail budget, and builds terrain, enabled layers and GPU
449
+ resources into the hidden resident cache. Arrival reuses that work. Predictions reset after
450
+ teleports, re-anchoring and camera-entry animations, and follow turns with a short velocity filter.
451
+
452
+ Preparation is bounded to the larger of 16 tiles or a quarter of the selected-tile budget,
453
+ limited by spare residency, and shares the existing tile,
454
+ layer and memory limits. With three or more load slots, up to half can advance the predicted route
455
+ while visible work remains queued; smaller budgets use spare slots. Displayed coverage takes
456
+ priority under memory pressure. `view.stats()` reports `preloadingTiles` and `preloadedTiles` counts.
457
+ This reduces late detail but cannot guarantee readiness when downloads or generation take longer
458
+ than the available lead time. The separate byte prefetch below warms a longer route.
409
459
 
410
460
  Terrain, landcover, feature and building tiles, content packs and the small documents that name
411
461
  them can persist across visits in a byte cache from `@bendyline/molen-pack/cache`. Ground a viewer
@@ -551,14 +601,47 @@ footprint polygon. It replaces the rectangle for suppression, including concave
551
601
  parallel road segments outside it remain intact. Connection stations use the outline's outer
552
602
  intersections with native Z=0, ordered negative to positive X. Without an intersecting outline,
553
603
  they fall back to X=-length/2 and X=+length/2. `deckHeights` keeps that endpoint order.
604
+ When a curved crossing's actual ends lie away from native Z=0, supply
605
+ `replaceRoads.deckEndpoints: [[negativeEndX, negativeEndZ], [positiveEndX, positiveEndZ]]`.
606
+ These native coordinates override the inferred connection stations and follow the model's
607
+ heading and X/Z scale. They require `deckHeight` or `deckHeights`, with the same endpoint order.
608
+ For side connections on a sloping or curved deck, add `deckProfile: [[x, y, z], ...]` in
609
+ increasing X order. Remaining bridge fragments join at their actual outline cut using the
610
+ nearest profile segment's interpolated height. The model's scale and resolved datum apply.
611
+ `includeTransverseBridges: true` also replaces bridge-tagged side connectors that terminate
612
+ inside the exact outline, such as paths covered by viewing pods. It requires an outline;
613
+ untagged ground crossings, tunnels, through crossings with both endpoints outside the model,
614
+ and bridge segments outside the outline remain independent.
554
615
  If the asset includes its retaining walls and approach pavement, set
555
616
  `replaceRoads.includeConnectedApproaches: true`. A grade road is then clipped inside the outline
556
617
  only if it shares a covered endpoint with a mapped bridge and continues outward along the bridge
557
618
  axis. The remaining grade fragment receives a 20 m terrain blend. Nearby roads, transverse paths
558
619
  and tunnels remain intact. This requires the source tile to retain the shared bridge/approach
559
620
  endpoint; disconnected or generalized map geometry is left in place.
621
+ For this opted-in mode, a retained mapped bridge tail up to 32 m can carry its deck height
622
+ to the connected street, including through one covered gateway up to 8 m long. The gateway
623
+ itself stays unchanged. Raised ground approaches receive retaining side and end faces down
624
+ to the original terrain; their paving supplies the top. These supports follow the model's
625
+ load and unload lifetime. They provide approximate continuity where coarse elevation data
626
+ misses a bank or quay; they do not establish surveyed ground levels.
560
627
  Sunken structures can declare `groundCutout: { outline: [[x, z], ...], basis: 'source evidence' }` on a placement. The simple polygon uses native model metres and follows the same heading and scale as the model. It should bound the ground opening covered by the authored concourse or rim. The terrain pyramid subtracts the polygon from actual elevation and draped ground triangles across tile and LOD boundaries, preserving interpolated heights and surface attributes along its edge. The cutout becomes active only when its successfully loaded structure is visible, and the original ground returns on layer hiding or eviction. Failed or cancelled models leave the ground intact. Heights remain available for anchoring; an opening does not itself author walkable floors or collision. Separate excavations can add `additionalOutlines: [[[x, z], ...], ...]` to the same object (up to 64 total polygons). Ground between those outlines stays intact; every opening needs matching model geometry. Client integrations can register the same set with `setTerrainGroundCutouts(object, outlines)`. The singular `setTerrainGroundCutout` remains available for one polygon.
561
628
 
629
+ Bridge openings can set `groundCutout.minHeight` to a native model Y threshold. Only ground
630
+ above that threshold is removed inside the outlines and capped at the threshold; lower dry
631
+ riverbanks remain visible. This explicitly reconstructs a bounded rendered bank without changing
632
+ source height samples. It must be supported by the model's site-fit evidence.
633
+ When `preservePaving` is set, `groundCutout.pavingOutlines` can still name smaller explicit
634
+ paving areas that need the same treatment, such as a river walk passing below a bridge.
635
+ Approach roads outside those paving outlines retain their deck-connection heights and geometry.
636
+ Custom owners pass `{ minHeight }` as the fourth argument to `setTerrainGroundCutouts`.
637
+ The threshold follows the owner's vertical translation and scale, like the existing ceiling.
638
+
639
+ Bridge landings can set `groundCutout.preservePaving: true` to open coarse terrain and
640
+ generated shoreline walls while retaining native approach roads and sidewalks. The default
641
+ also removes covered paving, as required by sunken buildings. Custom paving adapters use
642
+ `markTerrainPavementSurface`; custom owners pass `{ preservePaving: true }` as the fourth
643
+ argument to `setTerrainGroundCutouts`. Water and source elevation samples remain independent.
644
+
562
645
  For separated parts, `groundCutout.outlines` supplies the complete set of up to 64 simple polygons
563
646
  and supersedes the single `outline`. Keep `outline` as the primary boundary for compatibility.
564
647
  Each ring follows the same model pose and lifetime; ground in the gaps stays visible. This lets
@@ -940,7 +1023,8 @@ These regional forms are visual priors, not surveyed attributes of individual bu
940
1023
  switch to the high preset, which rebuilds them across the view). Where the browser can time the GPU (`renderer.createGpuTimer()`), the view
941
1024
  reports GPU and CPU work per frame, so slow frames while tiles stream in lower the level only
942
1025
  when rendering itself is the cost; without GPU timing it goes by frame times alone. The view
943
- first calibrates quickly, so a slow device settles within seconds. Once a level has held for
1026
+ first calibrates quickly, so a slow device settles within seconds (it lowers detail after 2.5 s
1027
+ of overload, not one burst of streaming as a takeoff reveals the view). Once a level has held for
944
1028
  12 s it turns sticky, because a level change swaps resolution and detail across the view: down
945
1029
  after 2.5 s of sustained overload, up after 20 s of headroom, at least 6 s apart. Any change
946
1030
  waits until the camera has been still for 0.6 s (at most 4 s); memory pressure above 1.25
@@ -956,7 +1040,11 @@ These regional forms are visual priors, not surveyed attributes of individual bu
956
1040
  is still warm when the view pans back.
957
1041
  - `stats().worldgen` counts styled building generation since the current terrain stream started
958
1042
  (with content packs): tiles generated, buildings drawn as geometry, and instanced stand-ins.
959
- - `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
960
1048
  context, workers and listeners. Mounting is abortable through `signal`.
961
1049
 
962
1050
  ## Sound
@@ -1012,3 +1100,52 @@ pieces such as a football game, apron traffic or a market. Each geographic place
1012
1100
  a lazy scene loader, optional calendar policy, and entry/exit distances. It waits for terrain,
1013
1101
  plays nearby, and releases its local world when out of range. See [Dioramas](dioramas.md) for
1014
1102
  the full contract and current prototype limits.
1103
+
1104
+ ## Airport layouts
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
+
1114
+ The `molen.earth` content pack supplies a lazy worldwide runway catalog and a detailed Boeing
1115
+ Field layout. Both Earth hosts use measured runway endpoints and widths, draw runway numbers,
1116
+ thresholds and centre lines, and keep airport pavement visible from flight altitude. Mapped
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.
1121
+ The airport overlay also supplies mapped hangar/building footprints and suppresses inferred
1122
+ vegetation and buildings on the airfield. Aircraft traffic uses the runway approach/departure
1123
+ corridors and remains simulated, rather than live aviation tracking.
1124
+
1125
+ The runway snapshot covers 10,746 airports with complete endpoint and width records. Detailed
1126
+ aprons, taxiways and hangars are currently bundled for Boeing Field; elsewhere these depend on
1127
+ the map's coverage. Building heights and untagged taxiway widths are interpreted. Runways with
1128
+ missing endpoints, closed runways and water runways are omitted. Supplemental airports also
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
1132
+ terrain renderer can use `withEarthAirports`
1133
+ around semantic renderers and observers, passing `content.airports` from `loadEarthContent`.
1134
+
1135
+ Mapped layouts also populate their aprons with boardable aircraft. Fleet profiles distinguish
1136
+ general aviation, regional service, airline hubs and mixed operations; Boeing Field uses a mix
1137
+ of light aircraft, business aircraft and larger jets. Aircraft are fitted inside apron polygons
1138
+ with clearance from buildings, taxiways, runways, other aircraft and reserved diorama areas.
1139
+ The fleet and parking positions are simulated, not live aircraft tracking or exact stand assignments.
1140
+
1141
+ Walk to an aircraft's door and press **E** to board, **I** to start, and **=/−** to adjust
1142
+ power. The same aircraft taxis and flies away; its original stand remains empty for the session.
1143
+ Land, stop and shut down before exiting. Automatic parking keeps at most twelve unclaimed
1144
+ aircraft within 1.8 km; claimed aircraft remain owned vehicles across terrain re-anchors.
1145
+ Set `airportTraffic: false` on `mountEarthView`, or `?airportTraffic=0` in World Explorer, to
1146
+ disable automatic parking. Hosts composing their own loop can use `planAirportApron` and
1147
+ `EarthAirportPopulation` with callbacks into their aircraft world.
1148
+
1149
+ Detailed apron population currently ships for Boeing Field. Runway-only catalog records do
1150
+ not invent parking ground. The **Living places** picker also offers flight-school briefing and
1151
+ cargo handling there; these ground scenes reserve space beside the boardable fleet.
@@ -4,6 +4,9 @@ The `molen.entities` content pack is Molen's curated entity collection. It build
4
4
  `renderable.kind: "gltf"`, `molen/asset@1`, `molen/types@1`, and `molen/project@1` contracts;
5
5
  there is no second entity or asset runtime.
6
6
 
7
+ The [livery gallery](livery-gallery.md) compares vehicle paint and marking choices. The
8
+ [complete livery catalog](livery-catalog.md) lists their ids and reference evidence.
9
+
7
10
  The initial nature collection contains pine, fir, oak, birch, shrub, and boulder models under the
8
11
  stable `molen.entities.*` namespace. Every model is a deterministic texture-free GLB with a
9
12
  hash-verified sidecar, meter-scale bounds, a conservative collision hull, and a type definition.
@@ -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.