1
0

feat: give the boards a horizon, a sea that reflects, and a state worth flying over

The wide shot, which is what an anonymous visitor actually lands on.

**The sea was `MeshLambertMaterial`** — a material with no specular term at all,
by construction — on a board where water is half the frame. It is now a
low-roughness dielectric that reads `scene.environment`, with a runtime-generated
tiling swell normal map sampled twice per fragment at two scales and two
headings, so the sun breaks into a moving glitter path instead of a mirror point.
An `onBeforeCompile` patch takes the body colour toward the deep value looking
straight down and leaves it to the reflection at grazing, and walks roughness up
past 1.6 board spans so the far water cannot shimmer.

The swell spectrum is 1/k^2 and not 1/k because the first attempt was
photographed: at 1/k every component carries the same slope, the shortest wave
wins, and the sea renders as hard diagonal corduroy. A test holds it now.

**The board no longer ends in a diamond.** The sea plane went from 1.8 board
spans to 18, past the fog's far plane from anywhere the orbit reaches, and the
sky is a world-space dome rather than a screen-space gradient. That gradient was
wrong in a way dusk made obvious: the sunset band was painted along the *bottom*
of the picture, under the board, while the true horizon at the top of frame stayed
zenith blue. `daylight.ts` pinning the horizon stop to the fog colour to hide the
seam was a symptom of it.

**Terrain casts shadows.** Left off before because double-sided terrain against a
~16 m-per-texel shadow map gives acne; `shadowSide = BackSide` is the cure, shot
at four sun elevations down to +0.0 degrees to confirm no stippling. The caster is
a stride-2 decimation appended to the same index buffer and swapped in by
`onBeforeShadow`/`onAfterShadow` via `drawRange`: no extra draw call, a quarter of
the depth cost, and indistinguishable from the full-resolution caster in a
side-by-side crop. Stride 1 was measured at +65,566 triangles and would have
missed the budget by ~47,000, so it was not shipped.

**California reads as California.** It was a beige kite: the eastern edge one
ruled line for five degrees of latitude, the south closing in a diagonal V, the
whole south-east a featureless tan wedge. Now the coast runs to the Mexican
border with San Diego on it, the eastern edge follows the Colorado and the Nevada
diagonal, and the south-east is the Basin and Range — forty parallel desert ridges
throwing shadows east, Death Valley as a white pan between the Panamints and the
Black Mountains, the Salton Sea the one cool value for two hundred kilometres.
The opening pose is retuned to the bigger board; the old 452/392 stand-off left a
slab of empty ocean where the state should be.

**The aircraft were six pixels.** Measured, by enlarging a screenshot 200% to
find one at all — indistinguishable from a dead pixel, on a board whose entire
claim is that the sky is live. They are airliners now, with planform and trail,
and clicking one raises its card for a signed-out visitor.

**The Model X is off the wall.** It stood at floor level outside a studio 188 m up
a Transbay tower, reading as a car balanced on a parapet. The apron is now chosen
from `site.elevation`, which the pack already carries — not from an office id,
which is the bug class this repo already hit once when a door marker gated on
`id === "sf"` and would have pinned the Los Angeles building to San Francisco.

Also fixed, and nearly shipped: sea z-fighting dithered every flat piece of ground
on the Bay Area and SoCal boards. And one test asserted an exact source line for
the water material, so the better multi-line implementation failed it — it now
asserts the property (dielectric, metalness 0, low roughness) rather than the
author's first guess at formatting.

Tests 964 -> 1015. California desktop 562/650 draw calls and 728,744/750,000
triangles — 2.8% of triangle headroom left, which is the number the next person
should check first. No budget was raised.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-21 23:43:14 -07:00
parent 655848746d
commit 8fb85cd2e5
30 changed files with 4781 additions and 257 deletions
+60 -3
View File
@@ -25,6 +25,37 @@ import { seededRandom, type World } from "./world.ts";
const LOT = 0.42; // ~40 m at SF's scale
const BLOCK_LOTS = 4; // 3 made streets a third of the city's surface
/**
* The ground size at which a lot stops being a city block.
*
* `LOT` is fixed in **scene units**, which is right — the three boards are 1003,
* 308 and 284 units across and are looked at from comparable standoffs, so a
* lot that is legible on one is legible on the others. But it means a lot is
* 40 m in San Francisco, 164 m in Southern California and **806 m** on the
* statewide California board, and two things that are correct for a city are
* wrong at 806 m:
*
* - **The street lattice.** Skipping every fourth row and column leaves 44%
* of a district unbuilt. At 40 m those gaps are streets. At 806 m they are
* eight-hundred-metre voids, and Los Angeles came out as a chequerboard of
* separate white squares rather than as a city — the one thing the state
* board most needed it to be. Above the threshold the lots tile, and the
* district's `coverage` roll does all the thinning, which reads as urban
* fabric because its gaps are irregular.
* - **Casting shadows.** A shadow caster pays for itself twice, once in the
* shadow pass and once in the beauty pass. A 40 m building on a San
* Francisco hillside throws a shadow you can see; a 60 m building on a
* 806 m lot throws about one pixel, and paying a second pass over a hundred
* thousand triangles for it — on the board with the tightest budget of the
* three — is not a trade anyone would make on purpose. Lambert still shades
* the four walls, which is all the state camera can resolve anyway.
* - **The underside.** Same measurement, same argument; see the geometry.
*
* 260 m is comfortably above Southern California's 164 and far below
* California's 806, so neither of the detailed boards changes at all.
*/
const NEIGHBOURHOOD_LOT_METRES = 260;
const PALETTES = {
downtown: [0xb9c3cc, 0xa8b4c0, 0xc7cfd6, 0x9dabb8, 0xd2d8dd, 0x8f9eaa],
residential: [0xe8e2d6, 0xdcd3c4, 0xefe9dd, 0xd6cdbc, 0xe3d9c8, 0xcfc4b2, 0xf0ece2],
@@ -108,6 +139,12 @@ export function createBlocks(
const boxes: Box[] = [];
let seedBase = 1337;
// See `NEIGHBOURHOOD_LOT_METRES`. One measurement, two decisions, and both of
// them are about how much ground a lot covers rather than about which board
// this is — a self-hoster's pack gets the same treatment without naming it.
const lotMetres = LOT * world.metresPerUnit;
const lotIsABlock = lotMetres <= NEIGHBOURHOOD_LOT_METRES;
for (const district of world.city.districts) {
const rand = seededRandom(seedBase);
seedBase += 7919;
@@ -137,9 +174,9 @@ export function createBlocks(
const steps = Math.ceil(reach / LOT);
for (let iu = -steps; iu <= steps; iu++) {
if (((iu % BLOCK_LOTS) + BLOCK_LOTS) % BLOCK_LOTS === 0) continue; // street
if (lotIsABlock && ((iu % BLOCK_LOTS) + BLOCK_LOTS) % BLOCK_LOTS === 0) continue; // street
for (let iv = -steps; iv <= steps; iv++) {
if (((iv % BLOCK_LOTS) + BLOCK_LOTS) % BLOCK_LOTS === 0) continue; // street
if (lotIsABlock && ((iv % BLOCK_LOTS) + BLOCK_LOTS) % BLOCK_LOTS === 0) continue; // street
const u = (iu + (rand() - 0.5) * 0.34) * LOT;
const v = (iv + (rand() - 0.5) * 0.34) * LOT;
@@ -225,6 +262,26 @@ export function createBlocks(
const geometry = new THREE.BoxGeometry(1, 1, 1);
geometry.translate(0, 0.5, 0); // pivot at the base, so y is ground level
if (!lotIsABlock) {
/**
* Drop the underside at neighbourhood scale.
*
* `BoxGeometry` lays its groups out px, nx, py, ny, pz, nz, two triangles
* each, so the six indices from 18 are the floor. A building sits on the
* ground and that face is never visible — except on San Francisco's
* steepest blocks, where a 40 m lot spanning a 3.6×-exaggerated hillside can
* leave a corner clear of the terrain and you would see straight through the
* hole. So this is tied to the same measurement as the street lattice and
* the shadow pass: at 806 m to the lot the ground under a building is flat
* to within a hair and nothing can get beneath it, and one sixth of the
* board's largest triangle consumer goes back to the budget.
*/
const index = geometry.getIndex();
if (index) {
const kept = Array.from(index.array).filter((_, at) => at < 18 || at >= 24);
geometry.setIndex(kept);
}
}
// The per-instance facade data, drawn from a stream of its own.
//
@@ -244,7 +301,7 @@ export function createBlocks(
const mesh = new THREE.InstancedMesh(geometry, new THREE.MeshLambertMaterial(), boxes.length);
mesh.name = "blocks";
mesh.castShadow = true;
mesh.castShadow = lotIsABlock;
mesh.receiveShadow = true;
const matrix = new THREE.Matrix4();