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
+15 -3
View File
@@ -61,12 +61,24 @@ test("the scene builds them, from the field the packs fill in", () => {
scene.includes('import { createAirports } from "./airports.ts";'),
"scene.ts no longer imports the airport kit",
);
/*
* Two assertions rather than one literal line, because the call and the add
* are no longer the same statement: the group is captured so the merged
* board's detail LOD can hide it, and matching the old one-liner would fail
* for a formatting change while still passing for a real regression like a
* guard replacing `?? []`. The two facts are what the test was ever about.
*/
assert.ok(
/scene\.add\(createAirports\(world, city\.airports \?\? \[\]\)\);/.test(scene),
"scene.ts must add the airports for the city it was handed. `?? []` and not a " +
"guard, because a board with no airfields is the normal case and must cost " +
/createAirports\(world, city\.airports \?\? \[\]\)/.test(scene),
"scene.ts must build the airports for the city it was handed. `?? []` and not " +
"a guard, because a board with no airfields is the normal case and must cost " +
"nothing to express.",
);
assert.ok(
/scene\.add\(\s*airportGroup\s*\)/.test(scene) ||
/scene\.add\(createAirports\(/.test(scene),
"scene.ts builds the airports but never adds them to the scene",
);
});
test("the airport contract stays plain data, and off the package surface", () => {
+16
View File
@@ -127,3 +127,19 @@ describe("one California", () => {
assert.equal(unifiedCalifornia().city, city);
});
});
describe("one California's chapters", () => {
it("is the state's list, until the corridor is drawn at true width", () => {
/*
* The metro rungs were merged, photographed and reverted; `unify.ts` records
* why in full. The short version is that the conversion was right and the
* frame was not — a two-unit stand-off on a 551-unit board lands inside the
* corridor's 4.7 km-wide atlas glyph. This test exists so that the day
* somebody merges them again, they do it deliberately.
*/
assert.deepEqual(
city.chapters.map((c) => c.id),
CALIFORNIA.chapters.map((c) => c.id),
);
});
});