1
0

perf: one lake mesh per board, and the merged board's metro layers get an LOD

Closing the merged board's red budget cells, and one of the two fixes turned out
to be a win for every board in the product rather than for this one.

**Every lake on a board is now one mesh.** `createWater` built a `Mesh` and a
`MeshStandardMaterial` per inland-water polygon, so a board paid a draw call per
lake. It went unnoticed while the boards were separate — California draws one,
the Salton Sea — and a scene census on a phone found it the moment `unify.ts`
folded three packs together: **water=20 against water=1**, nineteen of the
fifty-eight draw calls that put the merged board over the mobile cap. They differ
in nothing but shape, so the geometries merge and the material is shared. The
0.05 lift is baked in before the merge, since afterwards there is no per-lake
mesh to carry it.

Measured on the shipping default, unrelated to any flag: socal 218 -> 205 draw
calls, bay-area 208 -> 202, california 374 -> 373, california-drive 233 -> 232.
It was never free anywhere.

**The metro-scale layers now follow the same reveal as the buildings.** Bridges,
airports, ports and vessels are handed to `applyDetailLod` and hidden with the
detail districts. That every one of them is metro detail on a merged board is
measured rather than assumed: the same census showed all seven named bridges,
all eight airport layers and every port mesh going from *zero* on the state pack
to one on the merged board — `california.ts` authors none of them. Together they
were the remaining 27 of those 58 draws, for structures sub-pixel at 1,919 m to
the unit.

Result on the merged board: california desktop 348,271 triangles of 440,000 and
372 draws of 415 on mobile, both green where mobile was 428 before.

**`DETAIL_REACH_M` is 60 km, down from 150.** At 150 km the test asked "are you
in the same half of the state as a city", which the corridor drive answers yes to
along most of its length. 60 km asks "are you looking at a city", which is what
the flag is for — and driving up US-101 the Southland now appears as you come
into it rather than while you are still in the Salinas Valley.

**The metro chapters were merged, photographed and reverted, and the reason is
recorded rather than the attempt deleted.** Converting a metro rung onto this
board is easy and was done correctly — `focus.lat/lng` is absolute, `distance`
is horizontal in the owning board's units and `height` has already been through
that board's exaggeration, so each keeps its true metres. The camera arrives
exactly where it should. What is *at* that range is the problem: two scene units
from the target on a 551-unit board, and the corridor there is a deliberate
4.7 km-wide atlas glyph, because DRIVE mode has to be able to drive down it on a
board where a real freeway is a fifth of a pixel. The delivered frame is a black
slab across San Francisco. A rung that flies you into that is worse than no rung.
They come back when the corridor is drawn at true width, which is
`createFreewayWorld` and the `roads` rule, not `unify.ts`.

`airportsAndCard.test.ts` asserted a literal one-liner that is now two statements
— the airport group is captured so the LOD can hide it. Split into the two facts
it was ever about: the `?? []` call exists, and the result is added.

1,701 tests pass. The full budget passes on the shipping default.

Still open on the merged board: `california-drive` mobile peaks at 315 draws
against 280. The steady state is +3 drawables over the state board; the peak is
the car driving into a metro and revealing it, against a cap set when the
corridor had no cities on it. That is a cap to re-derive for a board that now has
them, and it is an owner's call rather than a number to quietly raise — which is
why this is still behind `?one=1`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-24 02:53:26 -07:00
parent 15d7accdbb
commit 64618cb47d
5 changed files with 179 additions and 57 deletions
+27 -7
View File
@@ -166,6 +166,32 @@ export function unifiedCalifornia(): { city: City; report: UnifyReport } {
m.districts.map((d) => ({ ...d, detail: true as const })),
);
/*
* ---- Chapters: the state's, and only the state's -------------------------
*
* **Tried, photographed, reverted.** Merging all twenty-four rungs onto this
* board is arithmetically easy — `focus.lat/lng` is absolute, `distance` is a
* horizontal length in the owning board's units and `height` has already been
* through that board's exaggeration, so each converts by keeping its true
* metres. That was done, and the camera arrives exactly where it should.
*
* The frame it arrives at is the problem, and it is a fact about the board
* rather than about the conversion. Flying to FiDi puts the camera about two
* scene units from its target on a board that is 551 units across, and what
* is at that range is *state-scale content*: `createFreewayWorld` draws the
* corridor as a deliberate 4.7 km-wide atlas glyph — `main.ts` says so where
* it sets the corridor altitude, because DRIVE mode has to be able to drive
* down it on a board where a real freeway is a fifth of a pixel — and the
* terrain under it is 300 m cells. The delivered picture is a black slab
* across San Francisco.
*
* So a rung that flies you into that is worse than not having the rung. The
* metro chapters come back when the corridor is drawn at true width on this
* board, which is `createFreewayWorld`'s hard-coded scene units and the
* `roads` reconciliation rule between them — not this file.
*/
const mergedChapters = state.chapters;
const fine = UNIFIED_FINE_METRES / 111_320;
const city: City = {
@@ -196,13 +222,7 @@ export function unifiedCalifornia(): { city: City; report: UnifyReport } {
inlandWater: [...state.inlandWater, ...metros.flatMap((m) => m.inlandWater)],
airports: [...(state.airports ?? []), ...metros.flatMap((m) => m.airports ?? [])],
ports: [...(state.ports ?? []), ...metros.flatMap((m) => m.ports ?? [])],
/*
* Chapters are the state's alone. The metros' twenty-four rungs are poses
* expressed in *their* boards' framing, and `ladder.ts` already presents all
* of them as one list; re-pointing them at this board is its own piece of
* work and a wrong pose is a camera in the ground.
*/
chapters: state.chapters,
chapters: mergedChapters,
/*
* Landmasses are NOT unioned. `isLand` is a point-in-any-polygon test, so a
* metro's finer coastline can only ever add land the state's outline already