@bendyline/molen-tooling 0.0.16 → 0.0.18

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 +466 -432
  2. package/dist/capture/worldgen-preview.js +405 -287
  3. package/dist/docs-src/guide/3d-art-guidelines.md +10 -7
  4. package/dist/docs-src/guide/building-interiors.md +59 -8
  5. package/dist/docs-src/guide/determinism.md +1 -1
  6. package/dist/docs-src/guide/earth-view.md +56 -11
  7. package/dist/docs-src/guide/entities.md +4 -1
  8. package/dist/docs-src/guide/graphics-performance.md +78 -6
  9. package/dist/docs-src/guide/medium-fi.md +40 -7
  10. package/dist/docs-src/guide/night-lighting.md +12 -2
  11. package/dist/docs-src/guide/recognizable-places.md +54 -5
  12. package/dist/docs-src/guide/regional-world.md +166 -36
  13. package/dist/docs-src/guide/rendering-backends.md +5 -2
  14. package/dist/docs-src/guide/sky.md +2 -1
  15. package/dist/docs-src/guide/surface-rendering.md +43 -6
  16. package/dist/docs-src/guide/typography.md +36 -0
  17. package/dist/docs-src/guide/vehicles.md +16 -1
  18. package/dist/docs-src/guide/worldgen.md +143 -7
  19. package/dist/docs-src/llms.txt +1 -1
  20. package/dist/docs-src/schemas/README.md +1 -0
  21. package/dist/docs-src/schemas/archstyle.md +209 -2
  22. package/dist/docs-src/schemas/components.md +41 -0
  23. package/dist/docs-src/schemas/region-atlas.md +2 -2
  24. package/dist/docs-src/schemas/regional-catalog.md +28 -2
  25. package/dist/docs-src/schemas/scatter.md +22 -2
  26. package/dist/docs-src/schemas/sign-looks.md +174 -0
  27. package/dist/docs-src/schemas/structure-placement-data.md +10 -0
  28. package/dist/docs-src/schemas/structure-placements.md +10 -0
  29. package/dist/docs-src/schemas/worldgen-batch.md +80 -0
  30. package/dist/templates/city-courier/gen/molen-types.ts +9 -1
  31. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +8 -0
  32. package/dist/templates/index.json +17 -17
  33. package/dist/templates/skybound/gen/molen-types.ts +9 -1
  34. package/dist/templates/skybound/scripts/molen-scripts.d.ts +8 -0
  35. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +8 -0
  36. package/dist/templates/top-down-arena/src/gen/molen-types.ts +9 -1
  37. package/package.json +12 -12
@@ -25,10 +25,11 @@ reconstructions. Surface detail does not compensate for incorrect body or cabin
25
25
  ## Recognition and shape
26
26
 
27
27
  Work from large to small: footprint and height, roof and massing, entrance and facade rhythm,
28
- then sign and surface detail. For a mapped business, use a generic category wordmark, an
29
- initial-based emblem, a controlled accent color, and an entrance treatment. Source-inspired
30
- palettes may distinguish descriptor variants, but model IDs, filenames, displayed names and
31
- emblem geometry stay generic.
28
+ then sign and surface detail. A mapped business shows its mapped name on a plain plate, set in the
29
+ shared lettering faces, in a look of plate, letter and band colors; a recognized chain's colors are
30
+ source-inspired, never its logo, emblem or typeface. A descriptor model stands in where there is
31
+ no name: a generic category wordmark, an initial-based emblem, a controlled accent color and an
32
+ entrance treatment, with generic model IDs, filenames, titles and emblem geometry.
32
33
 
33
34
  Keep mapped footprints, courtyards, height, and minimum height when supplied. Missing height is
34
35
  unknown: the category recipe supplies a conservative default. An identified tenant does not
@@ -74,7 +75,7 @@ model; scene and tile budgets still control total instances and building vertice
74
75
 
75
76
  | Asset | Near target | Medium/distant treatment |
76
77
  | --- | --- | --- |
77
- | Identity sign | Under 650 triangles, one material | Remove small lettering first; retain symbol and color |
78
+ | Identity sign | Descriptor model under 650 triangles, one material; a named sign about 10 plus 2 a letter | Remove small lettering first; retain symbol, plate and color |
78
79
  | Bench, rack, charger, lamp | 50–500 triangles | Merge slats/cables; retain silhouette |
79
80
  | Ordinary tree | 300–2,000 triangles | Fewer crown clusters, then a faceted crown/cone |
80
81
  | Small static building | 1,000–8,000 triangles | Remove furniture and small facade details |
@@ -84,8 +85,10 @@ model; scene and tile budgets still control total instances and building vertice
84
85
 
85
86
  Higher budgets need a visible reason and a distance fallback. Repeated street furniture and signs
86
87
  should be instanced by model reference. Prefer a shared vertex-color material; do not allocate
87
- one material or texture per store. Never put an unlimited number of signs on a complex outline:
88
- the current frontage contract admits at most twelve per generated building.
88
+ one material or texture per store. Named signs follow the same rule: every one shares one glyph
89
+ atlas texture and one material, and a tile's names are a single mesh. Never put an unlimited number
90
+ of signs on a complex outline: the current frontage contract admits at most twelve per generated
91
+ building.
89
92
 
90
93
  The sign library preserves exact geometry between instances. Source business identity controls
91
94
  matching; stable feature identity controls placement and variation. Do not use wall-clock time,
@@ -1,13 +1,14 @@
1
1
  # Inferred building interiors
2
2
 
3
- World explorer enables lazy interiors in the styled **Human** layer: choose **Walk**, approach
4
- a building, and walk through its framed entrance. Near the entrance, the windows become
5
- transparent and reveal the same interior you can enter.
3
+ World explorer enables lazy interiors in the styled **Human** layer: choose **Walk**, walk up to
4
+ a building's front door, press **E** to open it, and walk in. Near the entrance, the windows
5
+ become transparent and reveal the same interior you can enter.
6
6
 
7
7
  `?interiors=0` disables this capability. `?synthetic=1&stores=1` provides a repeatable block of recognizable
8
- stores; `test/visual/interiors.play.json` walks into and out of its fast-food restaurant and grocery store.
8
+ stores; `test/visual/interiors.play.json` opens the doors of its fast-food restaurant and grocery
9
+ store, walks in, and walks back out.
9
10
  Use `?synthetic=1&houses=1` for a residential block with two-storey houses and a bungalow.
10
- `test/visual/houses.play.json` walks through its entrance, climbs the stairs, and enters a bedroom.
11
+ `test/visual/houses.play.json` opens a front door, walks in, climbs the stairs, and enters a bedroom.
11
12
 
12
13
  These layouts are plausible procedural interpretations of building use, **not surveyed floor
13
14
  plans**. Confirmed occupant categories take precedence over building labels, then surrounding
@@ -209,6 +210,16 @@ using the style pack's catalog (and generating no interiors when the pack has no
209
210
  `renderers.updateInteriors(cameraPosition)` each frame. Only complete buildings at the finest
210
211
  semantic level receive sites; coarse representations retain the cheap exterior path.
211
212
 
213
+ A site comes with a building's full detail, and a crowded tile cannot detail every building: a
214
+ dense Seattle tile holds 1,091 buildings and a WebGL host's vertex budget details 75 of them.
215
+ From the air those are the largest. Once the position passed to `updateInteriors` is down among
216
+ the buildings and moving at a walk, the tiles within 90 m of it are regenerated with their
217
+ buildings queued nearest first, and again each 36 m it moves, so the houses round a walker
218
+ (148 of them in that tile, out to 140 m) are the ones with doors. Nothing is regenerated while the
219
+ viewer is inside a building or travelling faster than 10 m/s, and the tile on screen stays
220
+ until its replacement is ready. `viewerFocus: false` on the renderers keeps a tile's first
221
+ choice; World Explorer accepts `?focus=0`, and frozen captures (`?freeze`) never regenerate.
222
+
212
223
  Defaults are a 65 m load distance, 90 m release distance, 12 resident interiors and a 16 MiB
213
224
  resident geometry cap. Distance is measured to the footprint (including courtyard boundaries)
214
225
  and vertically to the available storey envelope, so a large building remains resident while you are inside
@@ -218,7 +229,8 @@ candidate modules and 160 fixtures (hard ceilings 4,096 and 512). The work budge
218
229
  64 iterator steps per frame, with at most one completed upload per frame. This is a cooperative
219
230
  budget, not a hard deadline: triangulation and final buffer upload are indivisible operations.
220
231
 
221
- One opaque portal batch covers unready entrances/windows per region. Publication attaches the
232
+ One opaque portal batch covers unready windows per region; a shut door closes its own doorway
233
+ (see [Doors](#doors)). Publication attaches the
222
234
  complete interior and removes those covers atomically. Eviction restores covers and disposes
223
235
  owned geometry; shared materials survive until streamer disposal. Hidden layers, region
224
236
  disposal and moving out of range cancel pending work. There is no unbounded interior cache:
@@ -241,7 +253,45 @@ the same published geometry, except that visible stair steps are skipped (`walkI
241
253
  a closed wedge supplies smooth stair collision. The published proxy is marked
242
254
  `walkCollisionOnly` and has rendering layers disabled. Hosts using the kernel buffers directly
243
255
  should likewise omit `steps` from physics and add `collision` to their collision scene. Portal index changes invalidate collision, and window glass is
244
- solid from either side. Doorways remain open without an interaction key or door animation.
256
+ solid from either side.
257
+
258
+ ## Doors
259
+
260
+ Every site's entrance has a door, shut until someone opens it. A house gets one painted panel
261
+ door, sometimes with a glass light, in one of a street's usual front-door colors, with a knob
262
+ and a fanlight over it where the opening is taller than a door. Shops, offices and everything
263
+ else get framed glass doors with a pull, in pairs where the doorway is 1.8 m or wider. A car
264
+ park's entrances stay open for cars. The look and the hinge side come from the site's identity,
265
+ so a building keeps its door.
266
+
267
+ `interiorDoors(site, catalog)` in the kernel describes them: each `InteriorDoor` has an `id`
268
+ (`<identity>#door0`), the doorway's `center`, `along` and `inward` directions, its leaves (each a
269
+ `hinge` and a direction across the leaf), and per leaf the `swing` angle about +Y that opens it
270
+ inward (the negative opens it outward). `buildInteriorDoorLeaf` and `buildInteriorDoorFrame`
271
+ build the closed leaves and the fixed transom. The kernel decides nothing about when a door opens.
272
+
273
+ `InteriorStreamer` draws every door of a region in one mesh and swings a leaf by rewriting its
274
+ own vertices, so doors cost one draw per region. Walking collision sees the leaves wherever they
275
+ are, shut or open, and picks up a swing on its next scan.
276
+
277
+ ```ts
278
+ const door = interiors.doorAt(eye, { facing: forward }); // within 1.8 m, in front of the viewer
279
+ if (door && !door.locked) interiors.setDoor(door.id, !door.open, feet);
280
+ ```
281
+
282
+ `doorAt` returns the nearest door within `reach` (1.8 m) of a position, at eye or foot height,
283
+ and ahead of `facing` when given. `setDoor(id, open, from)` opens a door away from `from`, so it
284
+ never swings into whoever opened it: from the street it opens inward, and from inside it opens
285
+ outward. It swings over 0.7 s, quickest at the start, on the streamer's clock (`now`, `performance.now` by default).
286
+ A door opens only onto rooms that are built: asked before then, it reports `waiting` and swings
287
+ when they are published, or gives up if the viewer leaves first. A site whose rooms could not
288
+ be built is `locked` and stays shut. Shutting is refused while `from` stands in the doorway.
289
+ When an interior is released, its door shuts with it.
290
+
291
+ The Earth renderers expose the same `doorAt` and `setDoor`. World Explorer and the Earth view
292
+ use the interact key for them: **E** opens or shuts the door the walker faces, and the explorer's
293
+ status line says which it will do. In the Earth view a door is an interactable of kind `door` (see
294
+ [Earth view](earth-view.md#interaction)).
245
295
 
246
296
  ## Current limits and next extensions
247
297
 
@@ -250,7 +300,8 @@ tower or mall, and every deck of a car park, in complete, non-elevated polygon b
250
300
  exterior geometry budget and have room for human-scale access. It does not promise entry into
251
301
  every mapped fragment: clipped footprints, elevated parts, very low/narrow structures,
252
302
  budget-boxed and omitted buildings lack a site. Additional storeys, switchback stairs, elevators,
253
- animated doors, tenant subdivision and persistent object edits remain future extensions.
303
+ doors between rooms (their doorways are open), tenant subdivision and persistent object edits
304
+ remain future extensions.
254
305
 
255
306
  Ground-floor platforms use the highest sampled perimeter height and an entrance ramp. Very
256
307
  steep sites, terrain protruding inside a large footprint, adjacent buildings obstructing a
@@ -136,7 +136,7 @@ Two constants live in `packages/kernel/src/version.ts` and they do different job
136
136
 
137
137
  | Constant | Today | Role |
138
138
  |---|---|---|
139
- | `ENGINE_VERSION` | `0.0.11` | 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.12` | metadata. Written into a keyframe's `engine` field so a save says which build wrote it. **Never compared on load, never hashed.** |
140
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`. |
141
141
 
142
142
  So a release — even one that moves every package — keeps your keyframes
@@ -347,7 +347,7 @@ walker. `actors.adopt(pedestrianId)` turns an ambient pedestrian into an actor (
347
347
  ```ts
348
348
  const view = await mountEarthView({ /* … */ interaction: { reach: 2.5, pedestrians: true } });
349
349
  view.setInteraction({ pedestrians: false }); // change it later, e.g. only while a game runs
350
- view.interactable(); // { kind: 'actor' | 'vehicle' | 'pedestrian' | 'none', id?, distance? }
350
+ view.interactable(); // { kind: 'actor' | 'vehicle' | 'pedestrian' | 'elevator' | 'door' | 'none', id?, distance?, open? }
351
351
  view.on('interact', (interaction) => {
352
352
  if (interaction.kind === 'actor') {
353
353
  interaction.claim(); // the view does nothing else with this press
@@ -355,17 +355,24 @@ view.on('interact', (interaction) => {
355
355
  } else if (interaction.kind === 'pedestrian') {
356
356
  const id = view.actors.adopt(interaction.id); // stop them and talk
357
357
  if (id) talkTo(id);
358
+ } else if (interaction.kind === 'door' && !interaction.open && !hasKey) {
359
+ interaction.claim(); // keep this door shut until the player finds the key
360
+ say('Locked.');
358
361
  }
359
362
  });
360
363
  ```
361
364
 
362
365
  The interact key (E, or F, or the right mouse button) emits `interact` first with what it found. On
363
366
  foot that is the nearest of: a car or aircraft within reach of its door (aircraft can be boarded on
364
- foot too), an interactable actor within `interaction.reach` (2.5 m) of the walker's eyes and in
365
- sight, and, with `interaction.pedestrians`, an ambient pedestrian. Aboard, it is the vehicle the
366
- viewer is in; otherwise `none`. A handler that calls `claim()` synchronously takes the press, and
367
- nothing else happens. Unclaimed, the view boards or leaves a vehicle as it always did (or explains
368
- why there is nothing to board), and does nothing for an actor or a pedestrian.
367
+ foot too), a building's door within 1.8 m and in front of the walker (`open` says whether it is
368
+ open), an interactable actor within `interaction.reach` (2.5 m) of the walker's eyes and in
369
+ sight, and, with `interaction.pedestrians`, an ambient pedestrian. Standing in a lift, it is the
370
+ `elevator`. Aboard, it is the vehicle the viewer is in; otherwise `none`. A handler that calls
371
+ `claim()` synchronously takes the press, and nothing else happens. Unclaimed, the view boards or
372
+ leaves a vehicle as it always did (or explains why there is nothing to board), opens or shuts a
373
+ door (away from the walker, so it never swings into them), takes a lift up a floor, and does
374
+ nothing for an actor or a pedestrian. A door opens onto rooms that are built, waiting for them
375
+ if need be; see [Doors](building-interiors.md#doors).
369
376
 
370
377
  ### Overrides: replacing mapped places
371
378
 
@@ -526,6 +533,23 @@ Entity types come from every opened pack that provides `types` documents, merged
526
533
  library with the entities pack first: pass your own pack's id in `ids` (for example
527
534
  `[...Object.values(EARTH_PACK_IDS), 'my.app']`) and its figure or prop types sit beside the stock
528
535
  cars and aircraft in `content.types`. A type id declared by two packs is an error that names both.
536
+ A type that fails its checks is left out, with any type that extends it, and reported through
537
+ `onWarning` (default `console.warn`); the rest still load.
538
+
539
+ Types are fully validated by default, which costs about half a second of main thread for the stock
540
+ aircraft and vehicles before a view can mount. A host that serves packs it built and validated
541
+ itself (`molen pack verify`, or `createTypeLibrary` in its build) can pass
542
+ `loadEarthContent(packs, { typeChecks: 'structure' })`: only what resolving relies on is checked,
543
+ and component fields this engine version does not know are kept instead of rejected.
544
+ `loadEarthContent` reads types, fonts, the style pack and the catalogs at once, so a large types
545
+ download does not hold up the rest.
546
+
547
+ Storefront signs show the names the map gives their places, set from the `molen.earth` pack's
548
+ glyph atlas; Japanese names need the Kyoto glyph pack, `molen.glyphs.kyoto`, opened beside it (pass
549
+ its id in `ids`). Other scripts, and names no open pack can set, fall back to the map's English
550
+ name, then to a generic descriptor such as `EATERY`. `signNames: 'generic'` on `mountEarthView`
551
+ shows the descriptors everywhere, with no business name. See
552
+ [Names on signs](recognizable-places.md#names-on-signs).
529
553
 
530
554
  `openPacksFromIndex(indexUrl, ids, fetchImpl)` accepts a host fetch implementation for the index,
531
555
  archive opening and subsequent asset requests. Landmark model bytes are loaded as nearby
@@ -837,6 +861,11 @@ For separated buildings or precincts, `buildingCutout.outlines` provides up to 6
837
861
  simple masks and supersedes `outline`. Keep the primary `outline` for compatibility. Separate
838
862
  masks preserve intervening buildings without inventing connecting structure geometry.
839
863
 
864
+ For an open carriage arch or similar at-grade passage, add `surfacePassageIds` and geographic
865
+ `bounds`. List exact transportation feature IDs from the map package. While the landmark is
866
+ loaded, the viewer paints those routes on the terrain through the model and skips their inferred
867
+ tunnel walls and ceiling. Failed loads retain the map's tunnel rendering.
868
+
840
869
  For a whole landmark whose source footprint slightly overlaps a neighboring building, set
841
870
  `buildingCutout.minimumCoverage` to a fraction in `(0, 1]`, for example `0.995`. This changes
842
871
  the mask to whole-building replacement: a mapped feature goes only when the union of that
@@ -895,6 +924,14 @@ model eviction. `build-copernicus-bridge-evidence.py` and the capture runner's
895
924
  neither capture set substitutes altered heights to make a bridge fit. These reports are research
896
925
  evidence and are excluded from the Earth runtime pack.
897
926
 
927
+ The Earth pack's optional `water-features` document supplies stable rendered elevations for
928
+ selected Protomaps water polygons. The viewer applies the same elevation to every tile that
929
+ contains the feature. A `hideLines` entry removes a redundant terrain-draped ribbon by feature
930
+ ID. Piva Lake and the downstream gorge at Mratinje use separate representative stages from
931
+ the retained terrain. Hosts composing their own renderer can provide `waterFeatureStyle` to
932
+ `createDefaultTerrainSemanticRenderer`. Its `elevation` is the final height in the terrain
933
+ frame, in meters. Unmatched features use the terrain sampler.
934
+
898
935
  If `replaceFootprint` is set, mapped buildings are suppressed only once the replacement model
899
936
  has loaded; failed models keep the procedural building. At any zoom a polygon goes when at least
900
937
  half of it stands on the model's own ground footprint (its triangles stamped on a 64-cell grid).
@@ -1064,7 +1101,7 @@ geometry and materials are counted once. Procedural scatter uses its separate in
1064
1101
  | Geometry CPU backing buffers | 64 MB | 192 MB |
1065
1102
  | Estimated geometry GPU uploads | 64 MB | 192 MB |
1066
1103
  | Shared worldgen textures, including mipmaps | 16 MB | 48 MB |
1067
- | Triangle / draw-call allowance | 350,000 / 100 | 1,000,000 / 200 |
1104
+ | Triangle / draw-call allowance | 350,000 / 100 | 1,000,000 / 400 |
1068
1105
  | Concurrent model loads | 2 | 4 |
1069
1106
  | Cooperative preparation time per frame | 2 ms | 4 ms |
1070
1107
 
@@ -1073,9 +1110,15 @@ overhead. Initial payload limits cover the active skyline set, not lifetime trav
1073
1110
  pack metadata. Upgrades can download larger files after a one-second skyline grace period.
1074
1111
  Draw/triangle admission reserves twice the nominal geometry cost for extra passes; shadows and
1075
1112
  other renderer passes have their own costs. Preparation yields between instances; an individual
1076
- GLB parse or GPU upload can exceed the cooperative time allowance.
1113
+ GLB parse or GPU upload can exceed the cooperative time allowance. Every placement is shown, at
1114
+ least on its skyline: skylines are reserved before detail, so a placement that overruns the
1115
+ allowance moves the farthest detailed landmarks down on the next update rather than being refused.
1116
+ Only drawn instances count: one in a tile hidden in the terrain's warm cache costs nothing until
1117
+ the tile is shown again.
1077
1118
 
1078
- Touch devices or browsers reporting at most 4 GB use the phone preset. Hosts can choose explicitly:
1119
+ Touch-first devices (a coarse primary pointer: phones and tablets) or browsers reporting at most
1120
+ 4 GB use the phone preset; a laptop with a touch screen keeps the desktop one. Hosts can choose
1121
+ explicitly:
1079
1122
 
1080
1123
  ```ts
1081
1124
  const view = await mountEarthView({
@@ -1092,8 +1135,10 @@ const view = await mountEarthView({
1092
1135
 
1093
1136
  Runtime variants use separate vertex attribute streams so Float32 positions and Uint8 colors
1094
1137
  do not cause overlapping GPU uploads. The reducer preserves source material references on detailed
1095
- levels; skyline uses a single color material and local convex pieces derived from the source.
1096
- Small openings and fine trim can disappear in that distant silhouette. Detailed levels use
1138
+ levels; skyline uses a single color material. A dense master's skyline is its own surfaces
1139
+ simplified, or local convex pieces where those are closer to the source (convex pieces fill a
1140
+ stadium bowl or a canopy). Small openings and fine trim can disappear in that distant silhouette.
1141
+ Detailed levels use
1097
1142
  conservative reduction and can exceed their advisory triangle targets. Expensive models stay
1098
1143
  coarse when an upgrade does not fit; source-authored LODs may be needed for more detail on phones.
1099
1144
  Geometric error is an estimate for selection, not a certified maximum deviation.
@@ -48,7 +48,10 @@ The entity type id and renderable asset ref are identical, such as
48
48
  `molen.entities.tree.conifer.pine`. For the type definitions, list the pack in the project's
49
49
  `packs` (see [Projects & types](project.md)); the CLI then resolves every `molen.entities.*` type.
50
50
  In code, read the documents the manifest `provides` as `types` and pass them to
51
- `createTypeLibrary` from `@bendyline/molen-kernel/content`.
51
+ `createTypeLibrary` from `@bendyline/molen-kernel/content`. It validates every document against
52
+ the schema by default; `{ checks: 'structure' }` checks only what resolving needs (the envelope,
53
+ type shapes, namespaces, script sources and `extends` cycles), for content validated where it was
54
+ built, and `onSkip` leaves out a failing type, with any that extend it, instead of throwing.
52
55
 
53
56
  In the engine repository, run `molen asset list` in `content/entities`, `molen types check --project
54
57
  content/entities/project.json`, or render `content/entities/scenes/gallery.scene.json` with
@@ -81,6 +81,13 @@ or more each while work waits), also get that share of themselves as budget: 2 m
81
81
  software frame left streaming under half a percent of the time, and a town's semantic layers
82
82
  spent their two-minute deadline in the queue. Interactive rates and a single long frame keep the
83
83
  fixed budget. `setLimits` changes the budget from the next frame on.
84
+
85
+ A fixed small budget protects the frame rate of a view that keeps up, and starves one that does
86
+ not. `backlog: { afterMs, maxMilliseconds, maxBytes }` (in the options or `setLimits`) lets the
87
+ budget grow while work is backing up: once the oldest waiting job outside the background lane
88
+ has waited `afterMs`, the frame's time and byte budgets rise with its wait and reach the backlog
89
+ values at twice that. They fall back as soon as the queue keeps up again, so a view at rest and a
90
+ slow pan never pay for it.
84
91
  A job's `priority` is `'normal'`, `'background'` or `'urgent'` (ahead of normal jobs, in its own
85
92
  order). Background jobs run in budget normal jobs leave and, once one has waited
86
93
  `backgroundWaitMs` (default 750), take a turn after every `backgroundShare` other jobs (default
@@ -137,7 +144,33 @@ Kyoto, some 1.4 million of the objects each collection walks.
137
144
 
138
145
  Three updates every object's world matrix each frame, hidden ones included. Hidden terrain tiles,
139
146
  pooled ambient figures (each with its skeleton) and the explorer's parked-aircraft cockpits skip
140
- that walk until they show again. Far detail stops drawing: a surface tile's signs, fixtures,
147
+ that walk until they show again.
148
+
149
+ Three also culls one mesh at a time, and only once it has walked to it: for world matrices, for
150
+ levels of detail and what to draw, and once more for each shadow map. A streamed world keeps
151
+ most of its tiles outside the view, finished and ready for a turn of the camera. On WebGL the
152
+ renderer leaves a render group (`createRenderGroup`, which the terrain stream uses for each tile)
153
+ out of the scene walk while its bounds lie wholly outside the camera's view, and out of a
154
+ directional light's shadow map while they lie outside that map; a group the camera cannot see
155
+ still casts into a map that reaches it. The group is hidden for the render alone, so nothing else
156
+ sees it change. Its owner states the bounds in `userData.renderBounds` (`RENDER_BOUNDS`: a
157
+ `Box3` in the frame of the group's parent, holding everything it draws) and keeps them true:
158
+ `expandRenderBounds` measures content from the bounds its meshes carry, and code that adds or replaces geometry
159
+ inside streamed content later (a landmark's next level of detail) calls
160
+ `markRenderBoundsChanged(object)`, after which the group is not culled until its owner has
161
+ measured it again. The terrain stream does all of this for its tiles. Over Seattle at High about
162
+ half of the tiles on show lay outside the view of a low flight, and leaving them out took the
163
+ main thread's time in a frame's render from 17-22 ms to 12-13 ms with the same draws.
164
+ `cullRenderGroups: false` turns it off (`?cull=0` in World Explorer).
165
+
166
+ An instanced detail switch (the level-of-detail batch for plants and props) chooses its level
167
+ again only once the camera could have reached a handover: each choice keeps how far the
168
+ measured distance was from the nearest threshold, and the camera's travel since, with any change
169
+ in the error budgets, is weighed against that. In flight nearly every batch is well short of its
170
+ next handover, and choosing again for each of some 2,200 of them every frame was 2.6 ms of a
171
+ 33 ms frame.
172
+
173
+ Far detail stops drawing: a surface tile's signs, fixtures,
141
174
  signal lenses, markings and parked cars past their draw distance (`updateDetail`, see
142
175
  [surface rendering](surface-rendering.md)) and street props below 1.5 px (`vanishPixels`, see
143
176
  [worldgen](worldgen.md)); at High over a town that cut a fifth of the draws. A visibility pass makes
@@ -148,13 +181,33 @@ cuts on every frame, sharing one 4 ms budget a frame with `stream.update`: hosts
148
181
  ten times a second while the camera is still, and at one budget an update, ground that a descent
149
182
  had just shown stood uncut over its own harbor for most of a second.
150
183
 
184
+ Where the stream's height source can cut off the main thread (`TerrainPyramidHeightSource.cutGround`,
185
+ a `TerrainGroundCutter`; the elevation worker's source has one), the clipping is done there. The
186
+ controller sends the mesh's arrays as copies, goes on to other ground, and swaps the cut in when
187
+ it lands, so the frame's budget pays for gathering openings and the swap alone; a cut whose
188
+ opening goes meanwhile is called off, and one the cutter fails is made on the main thread. A
189
+ mesh of fewer than 5,000 vertices (`cutVertices`) is still cut on the main thread, in the pass
190
+ that first shows it: a few milliseconds, against ground standing uncut for the trip's frames. A
191
+ tile's land cover over a shoreline is some 38,000 vertices against 50 openings: 46 ms of clipping,
192
+ of which a low flight over Seattle at High finished 48 in 50 seconds at 4 ms a frame, leaving most
193
+ ground it passed waiting for its cut. The worker made some 250 in a minute of the same flight,
194
+ and cutting fell from 7% of the main thread to under 2%.
195
+
151
196
  Earth hosts admit more while frames have time to spare: `createEarthAdmissionGovernor(backend)`
152
197
  smooths each frame's main-thread work and, through `earthAdmission`, switches the queue to 8 MiB
153
198
  of uploads a frame (and 4 ms of work on WebGL) below 10 ms of work, back to the renderer's
154
199
  defaults above 13 ms. Each terrain tile and layer passes several admission jobs; at 2 MiB a frame
155
200
  everything behind a building cell's upload waited 30 ms a job, and ground and buildings beneath a
156
201
  jet appeared a second late. A render-bound frame (High detail over a town) loses a sixth of its
157
- rate to the larger budget, so it keeps the defaults. This is not a hard GPU/driver time bound. Texture
202
+ rate to the larger budget, so it keeps the defaults while it keeps up. Either budget carries a
203
+ backlog (above) that grows it toward the arrival budget, 8 ms and 16 MiB, once work has waited
204
+ `EARTH_BACKLOG_MS` (400 ms): a P-51 at 290 kt over Seattle at High always had busy frames, the
205
+ 2 ms published a quarter of the layers the flight asked for, each job waited 3 s on average for
206
+ each of a layer's several turns, and no tile beyond 2 km had all of its layers on show at any
207
+ point of the flight: bare ground ahead, buildings arriving beneath. Held at 4 ms the same flight kept its 30 frames a second and finished four
208
+ fifths of the ground within 2 km; at 8 ms it finished nearly all of the view at 22 frames a
209
+ second, drawing three times the triangles. The backlog moves between the two as the queue needs.
210
+ This is not a hard GPU/driver time bound. Texture
158
211
  initialization, geometry preparation and async shader compilation use public Three facilities;
159
212
  shared resources share pending preparation promises. A cancelled tile cannot cancel another
160
213
  tile waiting on the same resource; queued work is dropped once every tile waiting for it has
@@ -165,8 +218,11 @@ camera and waits only for the selected levels. The other levels prepare in the q
165
218
  lane (`priority: 'background'`), which runs only in budget that normal jobs leave, and are dropped
166
219
  if their mesh or geometry is disposed first. This includes geometry-switch LODs whose current
167
220
  level is empty: invisible ground cover does not delay an aerial tile, and a later approach waits
168
- for its preparation before revealing it. WebGPU preparation shares the visible-light list between
169
- rendered frames instead of walking the whole scene for each mesh. A mesh that swaps its own material (an instanced
221
+ for its preparation before revealing it. Preparation shares the visible-light list instead of
222
+ walking the whole scene for each mesh, and the walk that finds the lights is made again only when
223
+ the scene's own children change or a quarter of a second has passed (each frame still checks
224
+ which of them are on show): once a frame, it was 1.2 ms of every frame of a flight over a city.
225
+ A mesh that swaps its own material (an instanced
170
226
  detail switch's opaque and shadow-free twins) lists every material in `userData.materialVariants`,
171
227
  and the renderer sets `userData.materialReady(material)`, which the mesh's owner asks before
172
228
  switching. Until it returns true the owner keeps what it shows; the first question queues that
@@ -231,10 +287,21 @@ admitted job of up to 20 ms. The grading itself finds each sample row's polygon
231
287
  ground edges once, instead of testing every edge of an airport's grounds for every sample: a tenth
232
288
  of a second a tile over Boeing Field.
233
289
 
290
+ Road earthworks (`createTerrainRoadGrading`'s `transformHeightfield`) are graded in the worker
291
+ too, where the source has `gradeEarthworks`. The host sends the tile's field and the road lines
292
+ that reach it; the worker reads the reference ground from its own decoded tiles, grades, and
293
+ meshes the result in the same trip, about 30 ms a town tile. On the main thread that was 2 ms
294
+ slices between frames, outside the frame queue, and 4 to 9% of the thread in a low flight over a
295
+ city. A reference tile is read as samples (`load`), without the full-resolution mesh
296
+ `loadPrepared` builds for a tile to be drawn. Bridge profiles (`gradeTile`) are still worked out
297
+ on the main thread, about 3% of it in that flight: a worker would need the tile's roads and its
298
+ neighbors' copied across, most of which no bridge is near.
299
+
234
300
  The worker entry calls `installTerrainElevationWorker(self)`, exported from
235
301
  `@bendyline/molen-terrain/client` (use the worker-scope type cast shown by World Explorer when
236
302
  compiling with DOM rather than WebWorker types). The host reads archive bytes; the worker
237
- owns PNG decoding, its decoded tile cache, ancestor resampling and surface meshing. Worker
303
+ owns PNG decoding, its decoded tile cache, ancestor resampling, surface meshing, road earthworks
304
+ and ground cuts. Worker
238
305
  buffers transfer without detaching archive caches or reusable topology. Omitting the worker
239
306
  retains the in-thread path. Worker errors are surfaced; they do not silently trigger duplicate work.
240
307
 
@@ -393,7 +460,12 @@ rebase above it is applied when it shows again. `stats()` walks every displayed
393
460
  exact byte totals and adds hidden tiles' tracked buffers; a live panel passes
394
461
  `{ geometry: 'tracked' }` for the retained estimate and visible-only counts. Ground cutouts stay on hidden tiles while their
395
462
  openings remain, keep the source grid's indices for triangles away from every opening, and
396
- re-count only the tiles whose ground they changed.
463
+ re-count only the tiles whose ground they changed. A cut is its source grid's vertices as they
464
+ are, then the few made on clipped edges, and the source stays for the next cut; once a cut is
465
+ applied the source's attributes read from the cut's arrays, so the pair holds its vertices once in
466
+ main memory. Over Seattle, where most ground meets water somewhere, the second copy was 174 of
467
+ 1,139 MiB on show at High (the page's array buffers fell from 1,403 to 1,233 MiB without it). The
468
+ source's GPU buffers stay until its tile goes.
397
469
 
398
470
  Height queries prefer displayed terrain and fall back to resident heights outside the visible
399
471
  cut. An aircraft's center can pass behind its cockpit camera at a tile boundary; it must not wait
@@ -147,7 +147,8 @@ where real buildings have it. Avoid both grey-on-grey and candy color.
147
147
  | Painted wall, siding, render | 60–90% | 15–60% | sage `#a3b78f`, slate blue `#8199b2`, cream `#efe3c4`, butter `#e6cf86` |
148
148
  | Urban wall: concrete, panel, limestone | 55–90% | 0–25% | light concrete `#d2cec5`, limestone `#ddd6c6`, cool grey `#b8bfc4`, graphite `#8f9397` |
149
149
  | Masonry, brick, timber walls | 45–65% | 25–45% | brick `#a8634b`, sandstone `#c9ab84`, cedar `#a77a54` |
150
- | Pitched roof (shingle, tile, slate) | 35–50% | 6–40% | charcoal `#575c62`, brown `#725c49`, moss `#5a6d55`, terracotta `#a5644b` |
150
+ | Pitched roof (shingle, slate, dark tile) | 35–50% | 6–40% | charcoal `#575c62`, brown `#725c49`, moss `#5a6d55`, engobe `#625e5c` |
151
+ | Clay tile roof in sun | 48–63% | 35–55% | terracotta `#c06c48`, pale weathered tile `#d1946f`, northern clay `#a25c48` |
151
152
  | Flat roof (membrane, gravel) | 45–90% | 0–12% | white membrane `#e6e6e2`, pale grey `#d3d4d0`, gravel `#b0a693`, dark membrane `#74777b`; mostly pale, a few dark |
152
153
  | Trim and frames | 85–95% or 22–30% | 0–30% | white `#f4f1ea`, dark frame `#3b3e42` |
153
154
  | Untextured window glass | 35–45% | 20–30% | blue-grey pane `#4d6178` |
@@ -189,6 +190,12 @@ Palette rules:
189
190
  lightness points below their walls, so a neighborhood seen from above reads as roofs. Large
190
191
  flat roofs are light membranes and gravel, as they are in reality. A pitched style declares
191
192
  `materials.flatRoof` so its flat fallback is membrane, not shingle tinted charcoal.
193
+ - **Clay tile is the one light pitched roof.** The tile texture and the roof's own shading draw
194
+ a tinted roof at about six tenths of its palette, so a terracotta inside the pitched band
195
+ (`#a8654a`) reaches the screen as dark red-brown at 28–35% lightness. Sunlit tile in
196
+ photographs of Nafplio and Lisbon measures 43–55% at a hue of 15–23°. Clay tile therefore has
197
+ its own band, above the other pitched roofs and still below the pale walls it sits on, and a
198
+ wider per-building jitter (±0.045 lightness), since a tiled town is mottled and never one tone.
192
199
  - **Reserve saturated accents.** Strong saturation belongs to identity: a store's sign band, a
193
200
  landmark's signature color, a bus livery, a fire station. Use one accent per object.
194
201
  - **Real landmarks use their real colors.** The Tacoma Narrows towers are green and the Golden
@@ -421,8 +428,9 @@ reference and proportion work; Bendy styling is not a substitute for the real ve
421
428
  - Never bake directional light, shadows, ambient occlusion or dirt gradients into base color.
422
429
  - Glass is a dark blue-grey pane with a modest reflection, not a mirror: the shared window graphs
423
430
  give frames a satin roughness and panes a smooth one, so the sky reflects in the pane and
424
- brightens it toward grazing angles. Identity lettering is geometry or vertex color, not a
425
- texture per business.
431
+ brightens it toward grazing angles.
432
+ - Identity lettering is geometry, vertex color, or letters from the one shared glyph atlas
433
+ (storefront names), never a texture per business.
426
434
  - Photographs from research are evidence, not textures, and never ship inside a model.
427
435
 
428
436
  ## Procedural buildings that fit any footprint
@@ -450,8 +458,14 @@ A style cannot do all of it. A generated street is also held to these:
450
458
  - **Tops are finished.** A tower ends in a parapet and a plant enclosure or crown and steps back
451
459
  where its style declares setbacks. A skyline shows more than one facade rhythm and more than
452
460
  one glass tint. A straight extrusion with a bare top is a stand-in.
461
+ - **A building is its region's.** Before a footprint is a shop, a hotel or an unknown, it is
462
+ built of what its town is built of: terracotta over warm render on the Mediterranean, slate
463
+ over brick in Britain, a roof terrace in the Maghreb and South Asia. A use changes a building's
464
+ frontage and its inside; it replaces the building only when the building was made for it.
453
465
  - **A row is houses.** A long, narrow residential footprint is divided at its party walls, each
454
- unit with its own roof, color and chimney, not roofed as one shed.
466
+ unit with its own roof, color and chimney, not roofed as one shed. Houses that share a wall
467
+ have no windows in it, and turn their ridges the way their region's rows do: eaves to the
468
+ street, or a gable to it.
455
469
  - **Mapped appearance wins.** Where the map records a roof shape, a wall or roof color or a
456
470
  material, use it, clamped to the palette bands.
457
471
  - **A building has a plot.** A house sits in a yard with an edge (fence, wall or hedge, by
@@ -459,7 +473,11 @@ A style cannot do all of it. A generated street is also held to these:
459
473
  yard and loading doors. Seeded buildings take their density from their mapped neighbors.
460
474
  - **Kinds are told apart.** A place of worship, a school, a fuel station, a greenhouse, a
461
475
  stadium and a building site each read as what they are from the air. A windowless box is a
462
- shed or a failure.
476
+ shed or a failure. A place of worship carries its tradition's crown (a dome, a spire, a
477
+ belfry, a minaret, a stepped tower) in its region's own walls and roof.
478
+ - **A pitched town stays pitched.** Where roofs are tile or slate, an irregular plan, a
479
+ courtyard block and a broad hall are roofed too (`roof.fallback: 'hipped'`), not left as flat
480
+ patches among their neighbours.
463
481
 
464
482
  The [worldgen guide](worldgen.md) and the
465
483
  [structure library](structure-library.md) cover the archstyle format and the 120 shipped styles.
@@ -629,8 +647,20 @@ A rain or snow frame is recognizable with its particles turned off.
629
647
  crown's shell (twenty clusters of four cards up close, six of three at medium distance) around
630
648
  a solid core in the crown's own shade, so the outline breaks into sprigs of leaves and the gaps
631
649
  show foliage rather than sky. Plants are sized by their foliage, not by the cards' clear
632
- corners. A distant crown is one faceted volume (six-sided and lumpy for broadleaf trees), drawn
633
- opaque. Clear atlas texels carry the tone of the leaves beside them, so filtering never blends
650
+ corners. A distant crown is one faceted volume, drawn opaque. For a broadleaf tree it is drawn
651
+ round the near crown's own clusters and core, on the same trunk (six sides and four rings, 56
652
+ triangles; five sides, three rings and no trunk past the horizon handover), so it stands where
653
+ the near crown stands with its lumps in its outline: one ellipsoid over the tree's whole height
654
+ was a ball on the ground, two fifths larger in view than the tree that replaced it. Such a
655
+ crown is a _foliage mass_ (`SCATTER_MASS_UV` in place of `SCATTER_SOLID_UV`; shrubs' far crowns
656
+ are too), and the scatter material shades it as clumps of leaves rather than a smooth ball:
657
+ clumps about 2.3 m across with sprays a finer size among them, each lit toward its top and
658
+ shaded beneath and where it meets the next, each in its own tone, with a relief that tilts the
659
+ normal so a clump has a sunlit side. Both sizes fade to their mean tone as a pixel grows past
660
+ them, so a far wood neither sparkles nor changes brightness. Its tone and reach are set against
661
+ the near tree's (a solid fills its outline and has no shade between cards, so it is drawn nine
662
+ percent narrower and a little toward gray), measured over six suns and two views: within four
663
+ percent of the near tree's area in view and one percent of its brightness. Clear atlas texels carry the tone of the leaves beside them, so filtering never blends
634
664
  a pale rim into a card's cut edge. Cards are for tree crowns only, and only
635
665
  through the shared scatter material: no alpha blending, no per-species textures, no cards on
636
666
  buildings, fences or ground cover. That material (`createScatterMaterialAsync` from
@@ -656,6 +686,9 @@ A rain or snow frame is recognizable with its particles turned off.
656
686
  - **Houses carry their own details.** North American homes have dark shutters, the odd dormer
657
687
  and a chimney, and lap-sided homes case their outside corners with trim boards
658
688
  (`cornerBoards`), all in the shared trim and roof materials, so they cost vertices but no draws.
689
+ A share of a family's houses has a porch (a step, two posts and a canopy); shutters and doors
690
+ are painted from the family's `paint` colors; chimneys stand only where winters have them, and
691
+ roof terraces carry water tanks or solar heaters as instanced props.
659
692
  The High tier's finest tiles budget 900,000 building vertices so a dense suburban block stays
660
693
  fully detailed near the camera instead of dropping to simplified stand-ins. On WebGL, which
661
694
  pays full price for every building and plant draw, the Earth view and the explorer ask for a
@@ -43,6 +43,9 @@ materials are retained.
43
43
 
44
44
  Modern surfaces place lamps along paved streets with sidewalks and at intersections. Placement
45
45
  is bounded, terrain-aware and avoids mapped buildings and water. Long blocks get fixtures at roughly 28 m intervals, alternating sides.
46
+ Arterials (motorways, trunk and primary roads, and any road of four or more lanes) get 7.4 m
47
+ mast arms whose heads hang over the carriageway; other streets get 5 m post-top lanterns at the
48
+ curb. A corner lamp is a mast arm when any road at its junction is an arterial.
46
49
  Bridges, tunnels and unpaved roads do not receive inferred block lighting. Explicit
47
50
  `tags.lit: "no"` disables block lamps. The existing surface style and `details.streetlights`
48
51
  control whether fixtures are generated; historic and unlit styles keep their own choices.
@@ -56,8 +59,15 @@ not cast additional shadows; walls do not occlude them. Distant lamps keep their
56
59
  and pavement pools beyond the real-light budget.
57
60
 
58
61
  Traffic lenses remain self-lit in both daytime and nighttime and keep their simulation-driven
59
- signal phases. Mapped props that replace inferred fixtures still need their own model lighting
60
- metadata; arbitrary tagged model lamps currently emit without creating a point light.
62
+ signal phases. After dark each lit lens also gets a soft glow in its own color, about a meter
63
+ across, which follows the phase from red to green (`surface:night-signal-glow`, one batch per
64
+ tile). Road signs light up too: their lettered faces fade in with the night factor, street
65
+ names at 85% as lit panels and the other boards at 60%, as retroreflective faces caught by
66
+ lamps and headlights. Each glow (`surface:night-street-names`, `surface:night-road-signs`)
67
+ draws its face mesh's own geometry, so it adds a draw call per tile, not memory; blank sign
68
+ backs and edges are a separate `surface:sign-backs` mesh and stay dark. Mapped props that
69
+ replace inferred fixtures still need their own model lighting metadata; arbitrary tagged model
70
+ lamps currently emit without creating a point light.
61
71
 
62
72
  ## Cars
63
73