@bendyline/molen-tooling 0.0.11 → 0.0.12

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 (60) hide show
  1. package/dist/capture/harness.js +596 -275
  2. package/dist/capture/worldgen-preview.js +394 -296
  3. package/dist/cli.mjs +2 -2
  4. package/dist/docs-src/guide/3d-art-guidelines.md +34 -10
  5. package/dist/docs-src/guide/3d-model-assets.md +27 -2
  6. package/dist/docs-src/guide/adaptive-performance.md +12 -4
  7. package/dist/docs-src/guide/aircraft.md +126 -26
  8. package/dist/docs-src/guide/ambient-life.md +13 -4
  9. package/dist/docs-src/guide/audio.md +19 -5
  10. package/dist/docs-src/guide/building-interiors.md +7 -2
  11. package/dist/docs-src/guide/determinism.md +1 -1
  12. package/dist/docs-src/guide/dioramas.md +6 -0
  13. package/dist/docs-src/guide/earth-view.md +121 -20
  14. package/dist/docs-src/guide/entities.md +84 -5
  15. package/dist/docs-src/guide/figures.md +31 -7
  16. package/dist/docs-src/guide/graphics-performance.md +27 -12
  17. package/dist/docs-src/guide/medium-fi.md +269 -25
  18. package/dist/docs-src/guide/navigation.md +5 -2
  19. package/dist/docs-src/guide/project.md +5 -0
  20. package/dist/docs-src/guide/recognizable-places.md +6 -0
  21. package/dist/docs-src/guide/regional-fleets.md +94 -0
  22. package/dist/docs-src/guide/regional-world.md +16 -5
  23. package/dist/docs-src/guide/sky.md +36 -3
  24. package/dist/docs-src/guide/structure-library.md +4 -1
  25. package/dist/docs-src/guide/surface-rendering.md +264 -2
  26. package/dist/docs-src/guide/terrain.md +5 -0
  27. package/dist/docs-src/guide/typography.md +105 -0
  28. package/dist/docs-src/guide/vehicle-interiors.md +169 -9
  29. package/dist/docs-src/guide/vehicles.md +13 -2
  30. package/dist/docs-src/guide/weather.md +15 -8
  31. package/dist/docs-src/guide/worldgen.md +81 -9
  32. package/dist/docs-src/llms.txt +4 -1
  33. package/dist/docs-src/schemas/README.md +3 -0
  34. package/dist/docs-src/schemas/archstyle.md +36 -0
  35. package/dist/docs-src/schemas/components.md +1087 -66
  36. package/dist/docs-src/schemas/fleet-catalog.md +113 -0
  37. package/dist/docs-src/schemas/landmark.md +10 -0
  38. package/dist/docs-src/schemas/matgraph.md +11 -1
  39. package/dist/docs-src/schemas/pack-source.md +11 -1
  40. package/dist/docs-src/schemas/pack.md +1 -1
  41. package/dist/docs-src/schemas/project.md +1 -1
  42. package/dist/docs-src/schemas/structure-placement-data.md +662 -0
  43. package/dist/docs-src/schemas/structure-placement-index.md +87 -0
  44. package/dist/docs-src/schemas/structure-placements.md +183 -0
  45. package/dist/docs-src/schemas/transport-network.md +8 -0
  46. package/dist/docs-src/schemas/types.md +1 -1
  47. package/dist/docs-src/schemas/worldgen-batch.md +40 -0
  48. package/dist/index.d.mts +2 -0
  49. package/dist/index.mjs +1 -1
  50. package/dist/{mcp-BbxqqnD1.mjs → mcp-BXaK46X-.mjs} +1 -1
  51. package/dist/{ops-b4Pag8U-.mjs → ops-Cm7WNvb9.mjs} +55 -22
  52. package/dist/templates/city-courier/gen/molen-types.ts +138 -17
  53. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +138 -17
  54. package/dist/templates/figures-gallery/test/headless.test.ts +2 -1
  55. package/dist/templates/index.json +17 -17
  56. package/dist/templates/skybound/gen/molen-types.ts +138 -17
  57. package/dist/templates/skybound/scripts/molen-scripts.d.ts +138 -17
  58. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +138 -17
  59. package/dist/templates/top-down-arena/src/gen/molen-types.ts +138 -17
  60. package/package.json +13 -13
@@ -92,7 +92,10 @@ priors and do not identify the architecture of an individual mapped building.
92
92
  `facade.details` adds shutters, balconies, timber framing or pilasters, awnings and verandas.
93
93
  Details use the actual facade rhythm, a bounded perimeter allocation, and the existing
94
94
  `facade-bands` tier flag. Structural openings, clipped edges and courtyard constraints take
95
- precedence. Dormers use `roof.features.dormers` on eligible pitched wings. Simplified budget
95
+ precedence. Shutters, painted the dark tone of the trim, flank punched windows and, on houses with
96
+ walkable interiors, the structural window openings that replace them. A veranda wraps every
97
+ qualifying wall, so families whose lots sit close to the street leave it out. Dormers use
98
+ `roof.features.dormers` on eligible pitched wings. Simplified budget
96
99
  representations omit ornament while retaining their footprint, primary roof and measured envelope.
97
100
 
98
101
  The [standard material catalog](https://github.com/bendyline/molen/blob/main/content/worldgen/materials/README.md)
@@ -82,6 +82,89 @@ budgets can call the stream's `refreshMemoryUsage()` after a new revision finish
82
82
  Disposing the controller
83
83
  also disposes its generator; do not share that generator between separately owned controllers.
84
84
 
85
+ ## Pavement material
86
+
87
+ By default the surfaces draw in a plain vertex-color material. For textured asphalt, concrete and
88
+ paint, give the controller the pavement material for the renderer's backend once the renderer
89
+ exists; resident tiles switch in place and later tiles use it too:
90
+
91
+ ```ts
92
+ import {
93
+ createTerrainPavementMaterialAsync,
94
+ setTerrainGroundOrigin,
95
+ } from '@bendyline/molen-terrain/client';
96
+
97
+ const pavement = await createTerrainPavementMaterialAsync({}, renderer.backend);
98
+ surfaces.setMaterial(pavement);
99
+ // Each frame, or whenever the floating origin moves, keep the pattern on the ground:
100
+ setTerrainGroundOrigin(pavement, [worldOrigin[0], worldOrigin[2]]);
101
+ ```
102
+
103
+ The material reads a `surfaceDetail` attribute the surface builder writes on every road, sidewalk,
104
+ curb, marking and lot: meters along the band, meters across it from its edge, the surface kind
105
+ and band width, and a road's lane width. Roads and lots get asphalt aggregate (within a few meters,
106
+ crisp pale chips and dark pits a few centimeters across), blotchy wear, polished wheel
107
+ tracks and an oil line in each lane, grit in the gutters, storm-drain grates, manhole covers and
108
+ the odd darker repaired section; asphalt and concrete both get hairline cracks; lots get oil
109
+ stains; sidewalks and footways get 1.5 m saw-cut slabs and curbs 3 m ones, each slab its own
110
+ tone, weathered with water stains and, close up, the odd spot of gum; plazas and pedestrian areas get a half-meter paver grid; markings wear through to the
111
+ asphalt. Detail fades to the plain swatch with distance, so it never shimmers, and each layer's
112
+ noise is evaluated only where it still shows: distant pavement skips the fine layers, and only
113
+ fragments within 2 m of a frayed edge evaluate the fray. `setMaterial(undefined)` restores the plain material. Your own geometry can opt in with
114
+ `TerrainSurfaceMeshBuilder.surfaceSince(start, TERRAIN_SURFACE_KIND.road, …)`, or a
115
+ `surface` (and `lanes`) on a `TerrainLineBand`.
116
+
117
+ Edges that meet bare ground fray into it rather than ending on a ruled line: the lawn side of a
118
+ sidewalk, both sides of a footpath, dirt road or track bed, a road's shoulder, and a narrow fringe
119
+ traced around each lot and plaza (skipped where a road, footway, other paved area or building meets
120
+ it). The material discards a ragged margin so the ground shows through, and inside it a patchy
121
+ brown soil margin about a third of a meter wide, where soil washes and is tracked onto the paving;
122
+ it fades out by twenty or thirty meters away, where it would draw a ruled outline round each lawn.
123
+ Cast paving keeps its formed edge; grass blades creep up to 3 cm over it, and on the lawn side of
124
+ a street sidewalk or parking lot tufts of lawn about 35 cm across grow up to 10 cm over it,
125
+ so from mid distance that edge wanders rather than ending on a ruled line. Footpaths and plazas,
126
+ which often abut other paving, keep only the blades. Where a driveway, footway or paved lot crosses
127
+ a sidewalk's lawn side, that stretch stays clean (the builder clears the fray flag on its vertices,
128
+ `TerrainSurfaceMeshBuilder.unfraySince`), so no ragged seam runs between two slabs. Loose surfaces
129
+ (dirt, gravel, shoulders) break up to 0.1 m deep, a gentle waviness with blade-scale tufts rather
130
+ than blob islands. With multisampling the ragged edge is antialiased through alpha to coverage. The
131
+ margin shrinks away as its noise falls below a pixel, leaving the band's own antialiased edge, and
132
+ it also closes up within the last few meters of the camera, where its cells would grow to dozens of
133
+ pixels and read as torn paper. A band opts in with `fray: 'outer' | 'inner' | 'both'` on its
134
+ `TerrainLineBand` (outer is the edge away from the line); bridge decks keep their edges whole.
135
+
136
+ Maps often stop a cul-de-sac street at the bulb's near edge, or simply stop it, and trace only
137
+ the sidewalk wrapping round the end. Where a street dead-ends and a mapped footway rings most of a
138
+ circle about its end (rays from candidate centers meet the footway's inner edge at similar
139
+ distances, all but the mouth the street enters by), that circle is paved as plain asphalt: a
140
+ turning circle, or for a tight wrap a rounded end. Footway pieces inside it are clipped away, and
141
+ footways that merely connect to the street's end do not count as the ring, so a circle never
142
+ spills past a footway onto a lawn (`SurfaceNetwork.findTurningCircles`).
143
+
144
+ Roads overlap wherever they meet: at a junction, at the corners of their sidewalks, across a narrow
145
+ median. Their paving never shares a plane there, or which road drew on top would change pixel by
146
+ pixel as the camera moved: the widest road keeps its nominal heights, and each road overlapping
147
+ another sits one or more 2 mm steps lower, asphalt, sidewalks, curbs and paint alike
148
+ (`SurfaceNetwork.stackRoads`). A mapped line that would lie on itself becomes separate roads: where
149
+ it doubles back more sharply than a band can miter, as two one-way carriageways joined where a
150
+ divided road narrows do, and at the vertex its own end returns to, as a cul-de-sac mapped up the
151
+ street and round a loop back to its middle does. A stall line two parking bays share is painted once.
152
+
153
+ Curbs are a step, not a stripe: a 15 cm vertical face drops from the curb's road-side edge to the
154
+ asphalt, split finer than the ground grid so it follows the draped ground, and jointed like the curb top.
155
+ Any draped band can have one with `riser` (meters) on its `TerrainLineBand`.
156
+
157
+ Styles with streetlights also furnish their blocks: utility poles every 38 m on one side of each
158
+ street with sidewalks, set back behind the sidewalk with a crossarm and a pair of sagging lines
159
+ between neighbors, and a hydrant at the other curb about every 100 m. Residential streets that
160
+ run through residential land also get a mailbox on a post behind the sidewalk every 22–30 m on
161
+ both sides (on a mounting board, a top vaulted in stepped courses, a door with a handle facing the
162
+ curb and a red flag), about a third of them with a pair of wheeled bins beside it. Poles and
163
+ hydrants (1,200 boxes) and mailboxes and bins (4,800) have
164
+ per-tile budgets of their own, enough to furnish every street of a dense suburban tile.
165
+ Placement is fixed per road, skips junctions, buildings and other roads, and draws in the same
166
+ instanced box batch as the lights (`streetFurniture` in the surface stats).
167
+
85
168
  `TERRAIN_SURFACE_STYLES` provides immutable presets. Pass a custom `TerrainSurfaceStyle` to
86
169
  change colors, inferred road widths, sidewalk width, and defaults for each detail class:
87
170
 
@@ -102,16 +185,32 @@ await surfaces.setOptions({
102
185
 
103
186
  - Modern streets use asphalt, exposed shoulder strips, curb/sidewalk bands, lane dividers, edge paint, stop
104
187
  bars and zebra crossings. Shoulders, like the other street details, are drawn on the finest
105
- detail tiles only: a few decimeters wide, they are below a pixel on the coarser tiles kilometers
188
+ detail tiles only: local shoulders are a few decimeters wide, below a pixel on the coarser tiles kilometers
106
189
  away, where draping them segment by segment once cost more memory than the roads themselves. Mapped paths are cut at same-grade carriageway edges, so footway
107
190
  fills cannot compete with asphalt at walking height; paths beneath bridges remain continuous.
108
191
  Nearby nodes on divided roads form one junction; crossings follow
109
192
  the external approaches, and short turning links receive no independent crossings. Same-grade
110
193
  junctions leave their centers clear of lane paint.
111
- Four-way major junctions can receive curbside masts with bars over the incoming lanes,
194
+ Mapped signal junctions and inferred crossings of two substantial arterials can receive curbside masts with bars over the incoming lanes,
112
195
  yellow backplates, shaded round lenses, and one signal head per lane (up to three).
113
196
  Red, amber and green lenses are self-lit, remaining visible at night. Instanced streetlights
114
197
  occupy eligible corners outside road corridors, buildings, and water.
198
+ - Freeways receive wider paved shoulders, longer lane dashes, a yellow left edge on one-way
199
+ carriageways, and white ramp edges. Green overhead boards use mapped route references or
200
+ destinations. At a connected outgoing ramp, an advance gantry and roadside exit board use
201
+ its exit number and destination when supplied; otherwise the board says only `EXIT`.
202
+ Speed-limit boards require a literal numeric `maxspeed` and display its units. No exit numbers,
203
+ destinations, or numeric speed limits are invented. Supports sit outside the carriageway;
204
+ overhead panels retain at least six meters of inferred road clearance.
205
+ - Local intersections use octagonal stop signs by default. A local street meeting an arterial
206
+ receives stops only on the side street; an all-local junction receives all-way plaques.
207
+ Mapped `traffic_signals`, approach `stop`/`give_way` points and central `stop=all` controls
208
+ override this inference, with grade-separated points excluded. A broad `major_road` class
209
+ alone no longer puts lights at every residential intersection. Stop bars cover incoming lanes.
210
+ This is a North American visual fallback, not a survey of local regulations; disable
211
+ `details.inferStopSigns` to retain only mapped stops, or `details.roadSigns` to hide all signs.
212
+ Historical and minimal styles omit signs. Sign faces and lettering are batched geometry with
213
+ host-supplied fonts and no per-sign textures; the worker produces the same geometry as the direct renderer.
115
214
  - Parking, plazas, and pedestrian polygons are filled, with holes retained. Pedestrian polygons
116
215
  and mapped paths use distinct heights above parking pavement, including inferred lots, so
117
216
  overlapping sidewalk and asphalt fills remain stable at walking height. Land cover, paved
@@ -162,6 +261,34 @@ call `surfaces.updateSignals(elapsedSeconds, resolver?)`; a resolver receives a
162
261
  `updateTerrainSurfaceSignals(object, elapsedSeconds, resolver?)` on the surface object instead.
163
262
  Here `object` is the group returned by `createTerrainSurfaceObject`.
164
263
 
264
+ ## Signage data in PMTiles
265
+
266
+ PMTiles is the archive format, so its contents depend on the tile producer. OSM supports
267
+ [`highway=motorway_junction` with `ref`](https://wiki.openstreetmap.org/wiki/Tag:highway%3Dmotorway_junction)
268
+ for an exit number; ramps can carry `junction:ref`, `destination` and `destination:ref`.
269
+ Road `ref` identifies the route, not the exit. The decoder preserves these fields as `ref`,
270
+ `junctionRef`, `destination` and `destinationRef`, plus `maxspeed`; exit POIs retain `ref` and
271
+ legacy `exit_to` as `exitTo`. `oneway=-1` reverses the decoded geometry, and one-way fragments
272
+ join without reversing their travel direction. Motorways are implicitly one-way unless the
273
+ source explicitly says otherwise.
274
+
275
+ OSM also records [`highway=stop` and `stop=all`](https://wiki.openstreetmap.org/wiki/Tag:highway%3Dstop),
276
+ `highway=traffic_signals`, and `highway=give_way`. These need point features in the configured
277
+ POI layer; merely having an OSM-derived basemap does not guarantee their presence.
278
+ The [Protomaps layer reference](https://docs.protomaps.com/basemaps/layers) describes a selective
279
+ context map. Its current road producer retains route/shield text and high-zoom one-way cues,
280
+ but does not emit the destination, junction-reference or maxspeed attributes consumed here.
281
+ Accurate numbered exits and posted limits therefore require an enriched tile source that retains
282
+ those tags. There are no live Overpass requests or extra network lookups during rendering.
283
+
284
+ Numeric OSM speeds without a unit are km/h; explicit `mph` stays mph. Variable, conditional and
285
+ country-code speed values are not interpreted. Road signs, gantry positions and sparse spacing
286
+ are visual approximations, using a right-hand-traffic layout, with a maximum of 48 signs per
287
+ detail tile inside its shared fixture budget. Labels fit uniformly within the panel (bounded to 80 characters); unsupported
288
+ glyphs use a question mark. `stats().roadSigns` counts the placed boards. Ambient traffic uses
289
+ the more conservative signal inference and treats mapped stop controls as give-way controls;
290
+ this change does not add a full-stop/dwell simulation for the decorative signs.
291
+
165
292
  Ground surfaces render at all available semantic levels. Fine markings and fixtures default to
166
293
  the finest pyramid level; `detailLevelsBelowMax` extends them to coarser levels. Fixture/car and
167
294
  detail-work budgets bound each tile. A portion of the detail budget is reserved for parking.
@@ -253,3 +380,138 @@ world units along the path; callers can carry phase across tile fragments when t
253
380
  provides route chainage. `terrainLinePath` and `sampleTerrainLine` are exported for custom
254
381
  attachment/model placement. Railway switches, wire sag and route-level cross-tile topology are
255
382
  separate consumers of this foundation, and traffic simulation is [ambient life](ambient-life.md).
383
+
384
+ ## Road sign fonts
385
+
386
+ Pass `fonts` and optional `signFont` in surface options. The default Earth font catalog supplies
387
+ Overpass for highway, exit, speed and stop signs; source case and accents are preserved. Font
388
+ geometry is batched into the sign mesh and the worker receives font data only when it changes.
389
+ See [Fonts and lettering](typography.md) for the shared layout engine and custom typefaces.
390
+
391
+
392
+ ## Road sign pattern library
393
+
394
+ The world-explorer sample includes **Road sign library** (`road-signs.html`), linked from its
395
+ main view. It renders ten patterns from synthetic semantic tiles through the production
396
+ detector, with country/state selectors, a 50-state route-marker collection, searchable cards,
397
+ rotatable 3D previews, and source-cue annotations. The samples
398
+ are demonstrations, not records of surveyed signs. All hardware positions are estimated.
399
+
400
+ | Pattern ID | Supported cues | Missing-data behavior |
401
+ | --- | --- | --- |
402
+ | `highway-overhead` | Connected motorway departure; `destination`, `destination:ref`, `junction:ref`, or nearby `motorway_junction` metadata | Regional exit label, if configured, only when topology establishes a departure |
403
+ | `highway-exit` | Same departure cues; smaller roadside assembly | No invented exit numbers |
404
+ | `all-way-stop` | Central `stop=all` or mapped controls on every incoming approach | Local junctions may infer all-way stops; explicit signals override them |
405
+ | `minor-stop` | Mapped approach stop | Minor approaches to an arterial may infer stops |
406
+ | `street-speed` | Literal `maxspeed` | Omit unknown, conditional, or variable limits |
407
+ | `freeway-speed` | Motorway plus literal `maxspeed` | Same rule, with a 40% larger panel outside the shoulder |
408
+ | `yield` | Mapped `highway=give_way` approach | No inference from ramps or roundabouts alone |
409
+ | `attraction` | Ramp `destination` with aligned `destination:colour=brown` | Nearby tourism POIs alone do not establish an exit or driving distance |
410
+ | `route-guide` | Motorway `ref`/`shield_text`, name, or destination | Omit when labels are unknown |
411
+ | `route-marker` | Exact supported `network` plus `shield_text`/`ref`; explicit state reference; local `SR`/`SH` plus state geography | Omit ambiguous or unsupported networks; never invent a route number |
412
+
413
+ The MVT decoder retains `destination:colour` as `destinationColour`. Semicolon entries align
414
+ with the destination list, including empty entries. A single brown colour applies to the
415
+ whole destination list. Mixed green/brown destinations become separate boards, keeping only
416
+ the brown names on the attraction board. Exit numbers are included only when mapped.
417
+ See [OSM destination colours](https://wiki.openstreetmap.org/wiki/Key:destination:colour) and
418
+ [FHWA recreational sign guidance](https://mutcd.fhwa.dot.gov/pdfs/11th_Edition/mutcd11thedition.pdf).
419
+ Global pattern identities are independent of the regional appearance described below.
420
+ Directional/lane-specific destination suffixes, service logos,
421
+ temporary restrictions, and exact hardware surveys are not supported yet.
422
+
423
+ `TERRAIN_ROAD_SIGN_PATTERNS` from `@bendyline/molen-terrain/client` exposes the catalog.
424
+ Each `SurfaceSign` in `object.userData.roadSigns` carries `pattern`, `evidence`, `source`,
425
+ the resolved `appearance`, and an optional `roadId`. For an overhead exit or attraction board, that ID identifies the ramp
426
+ providing the legend. `source: 'mapped'` means the control or legend comes from mapped data;
427
+ it does not mean the gantry, pole, or exact sign location was surveyed. This metadata also
428
+ survives the surface-worker path. `createTerrainRoadSignObject(sign, context, { fonts })` renders
429
+ one detected sign with the same batched face/support geometry; dispose it with
430
+ `disposeTerrainSurfaceObject`. Coordinates remain local to the supplied tile context.
431
+
432
+ ## Regional sign appearances
433
+
434
+ Patterns describe what a sign means and which map cues support it. A `TerrainRoadSignProfile`
435
+ supplies guide colours, speed-sign shape, native units, exit wording, stop/yield legends,
436
+ roadside placement and a font role. The first Earth presets are:
437
+
438
+ | Country | Motorway guides | Posted speed panel | Roadside placement |
439
+ | --- | --- | --- | --- |
440
+ | United States | Green | Rectangular, mph | Right |
441
+ | Great Britain | Blue | Circular, mph | Left |
442
+ | Germany | Blue | Circular, km/h | Right |
443
+ | France | Blue | Circular, km/h | Right |
444
+ | Italy | Green | Circular, km/h | Right |
445
+ | Switzerland | Green | Circular, km/h | Right |
446
+
447
+ Europe has no single guide colour. Destination category also matters: British primary routes
448
+ use green and local destinations white; French major destinations use green and other
449
+ destinations white; Italian non-motorway interurban routes use blue. The British and French
450
+ side-exit presets use white when the destination category is unknown. A uniform mapped
451
+ `destination:colour` of green, blue, white or yellow overrides the default panel colour;
452
+ light panels receive dark lettering. Mixed-colour panels remain approximate. The catalog's
453
+ `sources` link the relevant national references, and its `notes` state each preset's limits.
454
+
455
+ The Earth pack provides `road-signs` (`signs/catalog.json`) and `road-sign-regions`
456
+ (`signs/regions.atlas.json`). `loadEarthContent` loads these independently of buildings and
457
+ fonts. World explorer and `mountEarthView` select a profile from the terrain tile's centre,
458
+ using dedicated country and U.S. state outlines in the same Mercator coordinate frame.
459
+ Exact containment wins; a bounded 2.5 km nearest-outline fallback fills coastal gaps.
460
+ Right-driving countries are included too, so their interiors cannot inherit a nearby left-driving rule.
461
+ Architectural regions do not select signs. These simplified outlines can be imprecise near borders and
462
+ coasts. Countries without a preset use the neutral `generic` profile; it is not a national
463
+ standard and keeps source units visible. Country coverage is deliberately explicit.
464
+
465
+ Posted values are never converted or guessed from the profile: `50` means 50 km/h, while
466
+ `50 mph` remains 50 mph even under a metric preset. Circular signs omit the unit only when
467
+ it matches the country's convention. All presets except the U.S. require mapped stop controls
468
+ by default; a local crossroad alone does not establish an all-way stop. Explicit mapped
469
+ signals still win. `details.inferStopSigns` can override the profile's inference default.
470
+ The same regional driving side controls roadside signs, approach stop lines, signal heads and
471
+ the inner edge of a one-way motorway. Mapped one-way direction is preserved. Marking colours
472
+ and sign hardware remain medium-fi approximations rather than complete national standards.
473
+
474
+ Earth uses these country outlines for ambient traffic too. Japan, Australia, New Zealand,
475
+ Ireland, India, Thailand, South Africa and other left-driving countries and territories use
476
+ the `generic-left` profile where a national sign appearance is not supplied. It retains neutral
477
+ panels and explicit source units while placing signs on the left. Hong Kong and Macao have
478
+ separate outlines from mainland China. Selection uses the same terrain tile centre for roads
479
+ and traffic; simplified borders and coastal outlines can be imprecise.
480
+
481
+ Custom hosts can pass `signProfile` in `TerrainSurfaceOptions`. It takes precedence over the
482
+ optional fourth argument to `createTerrainSurfaceRenderer`, a `(x, z) => profile` resolver.
483
+ The host resolves the profile before dispatching a serializable worker job. To share Earth's
484
+ selection, call `createEarthRoadSigns(content.roadSigns, metersPerUnit)` from
485
+ `@bendyline/molen-earth/client` and pass its `profileAt` callback. Without sign content or an
486
+ explicit profile, standalone terrain rendering keeps its existing U.S. appearance.
487
+
488
+ `TerrainSurfaceOptions.drivingSide` overrides handedness for markings, signals and signs together.
489
+ `mountEarthView({ ambient: { drivingSide: 'left' } })` applies this override to its surfaces as
490
+ well as its traffic. Without an override, the Earth sign content selects the rule automatically;
491
+ without that content, the default remains right. Custom hosts can share
492
+ `createEarthRoadSigns(...).drivingSideAt` with `EarthAmbient`.
493
+
494
+ Profiles request roles such as `sign.gb` or `sign.de`; hosts can bind those roles to additional
495
+ compiled font faces. The shipped catalog currently falls back to Overpass for every country.
496
+
497
+ The Earth pack also provides `road-sign-profiles` (`signs/us-states.json`) and `route-shields`
498
+ (`signs/route-shields.json`). All 50 U.S. states have primary route-marker artwork and subdivision
499
+ profiles, which override the country appearance. U.S. regulatory panels stay shared;
500
+ municipal street-name blade styles are not inferred from state identity. View all state markers
501
+ at `road-signs.html?view=states`, or use `?region=us-wa` for Washington's full pattern set.
502
+
503
+ The decoder retains `network` and `shield_text` independently as `network` and `shieldText`.
504
+ Exact network identity takes precedence over geography. County, Interstate, U.S. highway,
505
+ business, toll and unsupported secondary networks are not mapped to primary state shields.
506
+ Tennessee specifically requires `US:TN:primary`. Missing/compound route numbers are omitted.
507
+ For custom hosts, pass `routeShields: content.roadSigns.shields` with the profile resolver.
508
+ The worker caches this vector library just like fonts; sign annotations retain network and
509
+ number without copying the artwork into every detection record. `profileForSubdivision`
510
+ provides explicit subdivision lookup alongside `profileForCountry`.
511
+
512
+ Artwork is a medium-fi adaptation of CC0 OpenStreetMap Americana symbols and authored shapes;
513
+ state borders use public-domain Natural Earth data. It is not a set of exact DOT fabrication
514
+ drawings. See `content/earth/signs/README.md` for licenses, source pins and offline regeneration.
515
+ It approximates Highway Gothic and does not supply exact Transport, DIN or Frutiger faces.
516
+ Route shields, detailed national panel layouts, lane arrows and multilingual exit plaques
517
+ remain future extensions. Source destination names are preserved rather than translated.
@@ -368,6 +368,11 @@ water and road surfaces are marked) and water with `userData.shadowReceiver = fa
368
368
  adaptive tiles. Its optional inclusive `minLevel`/`maxLevel` bounds keep expensive decoration off
369
369
  coarse fallback and horizon tiles. Layer objects become visible only with their selected surface,
370
370
  remain cached briefly across LOD transitions, and are disposed with their resident height tile.
371
+ A layer object that drapes its whole tile with opaque ground (landcover over a full-tile
372
+ background, as the regional worldgen classification layer builds) can set
373
+ `userData[TERRAIN_COVERS_GROUND] = true`. While it is displayed, the stream stops drawing that
374
+ tile's bare surface, which it would hide anyway: the surface keeps `visible` for the stream's own
375
+ bookkeeping but leaves every render layer, so no camera or shadow pass draws it.
371
376
 
372
377
  Optional package sidecars cross a normalized boundary before reaching those layers. Call
373
378
  `openTerrainPackageSemantics(packageDoc, { decoder, baseUrl })` to open and header-check declared
@@ -0,0 +1,105 @@
1
+ # Fonts and world-space lettering
2
+
3
+ Use the shared font engine for shop names, highway signs, equipment labels and generated models.
4
+ `@bendyline/molen-materials/text` lays out text and emits indexed triangles without DOM, canvas,
5
+ three.js, GPU state or a system-font dependency. `@bendyline/molen-client/text` adds a three.js
6
+ geometry adapter and an offline outline compiler. Both consume the same host-supplied font data.
7
+
8
+ ## Loading fonts
9
+
10
+ `loadEarthContent` reads the Earth pack's `provides.fonts` catalog into `content.fonts`. Earth
11
+ view and world explorer pass it to road surfaces and storefront models. The stock catalog has
12
+ Overpass semibold (`highway`), Overpass regular (`sans`), Overpass Mono semibold (`mono`), and
13
+ Molen Sign Serif (`serif`, derived from Libre Baskerville). Overpass is inspired by Highway
14
+ Gothic; it does not reproduce an exact FHWA alphabet. Font assets carry their SIL OFL licenses
15
+ inside the content pack. Libraries ship code, not font files, and never choose a font host.
16
+
17
+ For another pack or local content source:
18
+
19
+ ```ts
20
+ import { loadFontLibrary } from '@bendyline/molen-materials/text';
21
+
22
+ const fonts = await loadFontLibrary(
23
+ await pack.readJson('fonts/catalog.json'),
24
+ (path) => pack.readJson(`fonts/${path}`),
25
+ );
26
+ ```
27
+
28
+ The catalog format is `molen/font-catalog@1`, with `defaultFont`, a `fonts` map from id to
29
+ catalog-relative JSON path, and optional `roles` mapping semantic names to ids. Loading validates
30
+ font ids, metrics and triangle buffers. Treat a loaded library as immutable; replace it with
31
+ a new library when changing faces. Terrain workers receive it once per change, not per tile.
32
+ Old packs without fonts still load; panels and symbols render without lettering until a host
33
+ supplies a library.
34
+
35
+ ## Rendering and fitting
36
+
37
+ ```ts
38
+ import * as THREE from 'three';
39
+ import { createTextGeometry } from '@bendyline/molen-client/text';
40
+
41
+ const geometry = createTextGeometry('Café Étoile', fonts, {
42
+ font: 'serif',
43
+ size: 0.6,
44
+ maxWidth: 3.2,
45
+ maxHeight: 0.5,
46
+ align: 'center',
47
+ verticalAlign: 'center',
48
+ });
49
+ const label = new THREE.Mesh(geometry, new THREE.MeshStandardMaterial({ color: '#eeeadd' }));
50
+ label.position.set(0, 2.8, 0.11);
51
+ scene.add(label);
52
+ ```
53
+
54
+ Text lies in XY with its front facing +Z. Rotate/place it in the sign's local frame and keep it
55
+ slightly ahead of the panel to prevent z-fighting. The caller owns the geometry and material;
56
+ dispose them when no longer used. Merge static labels into material batches or export their
57
+ buffers into a GLB, rather than adding a draw call for every letter.
58
+
59
+ `buildTextMesh(text, fonts, options)` returns `positions`, `indices`, fitted `width` and `height`,
60
+ the rendered `text`, `missingGlyphs`, and `truncated`. It uses proportional advances, pair
61
+ kerning, NFC normalization, Unicode code points and explicit `\n` line breaks. `size` is the
62
+ maximum em size; width/height constraints uniformly shrink the whole label. Glyphs are never
63
+ stretched sideways. `overflow: 'ellipsis'` shortens each line at the requested size before
64
+ fitting; default is `shrink`. `letterSpacing` adds em spacing, `lineHeight` sets baseline spacing,
65
+ and `fallbackFonts` supplies additional face ids/roles. `maxCharacters` bounds work (default 256,
66
+ maximum 4096). The geometry adapter exposes the same diagnostics in `geometry.userData.textLayout`.
67
+
68
+ The stock subset covers available Latin, accented Latin, digits, punctuation and arrows.
69
+ Unknown characters use a visible `?` and appear in `missingGlyphs`; they are never silently
70
+ dropped. This is left-to-right layout with pair kerning, not a complex-script shaper. Arabic,
71
+ Indic shaping, bidirectional paragraphs and automatic word wrapping need a shaping/layout stage
72
+ before adding those scripts. Font family selection alone does not provide that stage.
73
+
74
+ ## Signs and authored assets
75
+
76
+ Pass `{ fonts, signFont: 'highway' }` to `createTerrainSurfaceRenderer` or
77
+ `createTerrainSurfaceObject`. Preserve `fonts` when calling `setOptions`. Sign text keeps the
78
+ source's case and accents; an exit number still comes only from mapped exit metadata.
79
+
80
+ Storefront `SignDesign`/landmark `sign` accepts `font` and `letterSpacing`. Call
81
+ `generateSignModel(design, detail, fonts)`, `generateLandmarkModel(id, definitions, detail, fonts)`,
82
+ or `new ModelLibrary(loader, definitions, disposeLoadedScene, plants, fonts)`. Detail 2 keeps
83
+ the panel and mark and omits name lettering. `molen worldgen preview` also reads the `fonts` catalog provided by its style or configured
84
+ project content packs (including the Earth pack). Fine signs use real text instead of decorative
85
+ stripes. The generators' buffers can be passed to `encodeGlb` like any other model.
86
+
87
+ For Node asset generators, call `createTextGeometry` and merge its triangles into the authored
88
+ mesh; this is the same API used in the browser. Existing baked GLBs must be regenerated to
89
+ change their lettering. Seven-segment electronic displays can retain their physical segments;
90
+ fixed captions around those displays should use font geometry.
91
+
92
+ ## Compiling another face
93
+
94
+ `compileVectorFont(typefaceJson, { id, characters, weight, style, curveSegments, kerning })`
95
+ from `@bendyline/molen-client/text` converts three.js `FontLoader` typeface data to a serializable
96
+ `molen/vector-font@1` document. It preserves counters/holes and uses a configurable outline
97
+ tessellation (default six segments per curve). Store that document, its license and provenance
98
+ in your content pack. Runtime rendering does not parse TTFs or retessellate outlines.
99
+
100
+ TTFLoader output is accepted. It uses historical 100000/72 outline units per em: set its
101
+ `resolution = 100000 / 72` before compiling if you need true em metrics. Supply pair kerning
102
+ in matching em units from your font parser; TTFLoader's JSON does not include kerning tables.
103
+ Variable fonts use their default outlines unless instantiated to a static face beforehand.
104
+ Regular, bold and italic variants are separate faces, not synthetic distortions. Check the
105
+ font's redistribution license and reserved-name terms before shipping a compiled subset.