1
0

feat: SFO, LAX, both bridges, a road that reads as a road, and aeroplanes that move

**The aeroplanes were stuck because the wire could not describe motion.**
`WireAircraft` carried position, altitude and heading and nothing else, so the
client could only interpolate between the last two observations: every aircraft
replayed a segment it had already flown, arrived at the newest known point, and
sat still until the next poll landed five to fifteen seconds later. The feed had
the missing numbers the whole time and the server threw them away. Sampled live
from `api.adsb.lol/v2/point` while writing this — `gs` ground speed, `track`,
`baro_rate`, plus `r` registration and `t` type designator. They are on the wire
now in SI, aircraft dead-reckon along their own track and correct toward the
truth when a fix lands, and the click card an anonymous visitor gets says
"B739 · N68834". That last part is the enrichment FR24 was wanted for, obtained
from an ODbL feed we may actually republish.

**SFO and LAX exist.** A new `engine/airports.ts` composes an airport from
runways, taxiways, aprons and terminal masses, with markings drawn on a canvas
rather than modelled; the pattern of the runways is what the eye recognises from
altitude, long before any building does. SFO is the two crossing pairs on the bay
fill; LAX is the four parallels either side of the terminal horseshoe, plus the
Southland fields under the traffic that actually flies there.

**The Golden Gate and the Bay Bridge are those bridges.** One kit in
`engine/bridges.ts`, because a suspension bridge is a repeated tower, a catenary
main cable, a series of hangers and a deck — so both are configurations rather
than two private implementations. The Bay Bridge carries the real 2013 topology:
two suspension towers west of Yerba Buena, one east, then the piered causeway.
The freeway stopped being a wireframe overlay and became a road, with shoulders,
a median, and lane markings as texture.

**And the board got faster while all of that landed.** California went from
728,744 triangles and 562 draw calls to 391,169 and 371 — headroom from 2.8% to
47.8%. The Bay Area board is 506,550 triangles lighter than before this work.
Two things paid for it:

- `transmission: 0.08` on the aircraft cockpit glass. three.js runs a full
  transmission backdrop pass whenever any rendered material has transmission
  above zero, re-drawing the entire opaque scene into a second target every
  frame — so the city was rendering terrain, every block and every freeway piece
  TWICE. Measured by patching only that number in a copy of the built bundle:
  703,267 tris / 562 draws with it, 398,608 / 371 without. The material was
  already `transparent: true, opacity: 0.86`, so it was buying nothing.
- Flatness-adaptive terrain LOD, which collapses runs of lattice cells wherever
  the height and colour agree with the quad replacing them. The coastline is
  provably untouched — a patch collapses only when every point is on land and
  agrees about `park` — and a test asserts the drawn footprint matches the
  cell-by-cell area to 1e-6. `createTerrain` got *faster*: the vertices it stops
  emitting cost more than the flatness scan costs to run.

**The budget now watches the boards this was built on.** There was no `bay-area`
or `socal` cell — so SFO, LAX and both bridges all landed in frames nothing
measured, which is how a cap you do not have looks from the inside. Both are in
the matrix now with caps set from measurement, and the rationale lives in the
harness because JSON cannot hold a comment.

Two known defects ship with this, both recorded in TODO.md rather than hidden:

- `bay-area.desktop` drops about one frame in twenty (p50 16.7, p95 33.3). It is
  desktop-only and not fill rate — mobile runs the same 2.26 M triangles at a
  comparable pixel count and holds 16.7 flat — which points at the 2048 shadow
  map desktop uses against handheld's 1024. Measured at the commit before this
  work with the same harness: identical p95 33.3. Pre-existing, and invisible
  until the cell existed.
- The aeroplane glyph is still about 1.5x the Golden Gate's main span at chapter
  zoom, down from 2.5x. `GLYPH_MAX_SCALE` is 52 because the raw scale at the far
  end of the California orbit is 51.0 at a 60-degree field of view, and 26 —
  tried first — put the glyph at 0.0123 of the frame against the 0.012 where the
  wings stop resolving. The real fix is to clamp against the camera's focus
  distance rather than the aircraft's, which is a signature change.

Tests 1020 -> 1137. Typecheck, build, eight budget cells, no-binaries,
provenance, zero-config boot, dependency licences, arena source hashes and the
UI smoke across two viewports and two access tiers all pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-22 05:06:12 -07:00
parent d9f8baf171
commit f81d5218d4
29 changed files with 7056 additions and 288 deletions
+101
View File
@@ -0,0 +1,101 @@
/**
* The aeroplane glyph has a floor AND a ceiling, and the ceiling is the newer half.
*
* The floor is a screen-space rule: never smaller than legible, because position
* and heading are what a reader wants off a map and neither survives half a
* pixel. It scales by the distance to *that aircraft*, which is the same thing
* as "how far the camera has zoomed" only when everything in frame is equally
* far away. On a whole-board pose it is. Beside a landmark it is not — at the
* Golden Gate the bridge is a couple of units from the camera and the traffic
* over the Pacific is a couple of thousand, so the floor fired hard on the
* aeroplane and not at all on the bridge, and an airliner was drawn about two
* and a half times the length of the main span.
*
* These tests pin both ends: that the board still gets a symbol it can read, and
* that no camera anywhere can produce a state-sized aeroplane again.
*/
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { glyphScale } from "../../engine/flights.ts";
/** The field of view the city scenes actually use, near enough for a ratio. */
const FOV = 50;
describe("glyph scale", () => {
it("never shrinks an aeroplane below the size it was drawn at", () => {
for (const d of [0.5, 5, 20, 34]) {
assert.ok(glyphScale(d, FOV) >= 1, `close camera at ${d} must not shrink the glyph`);
}
});
it("still grows the glyph across the whole-board range, where the floor is the point", () => {
const near = glyphScale(200, FOV);
const far = glyphScale(400, FOV);
assert.ok(near > 1, "a board-distance aeroplane must be enlarged to stay readable");
assert.ok(far > near, "the floor must keep tracking distance until the ceiling binds");
});
it("stops growing at all, however far the aircraft is", () => {
const capped = glyphScale(2280, FOV);
assert.equal(
glyphScale(4000, FOV),
capped,
"past the ceiling the scale must be flat, not merely slower",
);
assert.equal(glyphScale(1e9, FOV), capped, "and flat all the way out");
});
/*
* Deliberately asserts a REDUCTION and not an absolute size, because the
* ceiling is a mitigation and calling it a cure in a test name would be the
* test lying about the product.
*
* 2,280 units is the measured Golden Gate case, where the uncapped glyph
* reached about 81x — roughly two and a half times the bridge's 1,280 m main
* span at ~94 m to the unit. The ceiling takes that to about one and a half.
* It is still bigger than the bridge. The complete fix is to clamp against the
* camera's focus distance rather than the aircraft's, which is a signature
* change and is written up in `flights.ts`.
*/
it("cuts the worst case by a third without touching any board distance", () => {
/** The floor alone, with no ceiling — what the scale used to be. */
const uncapped = (d: number, fov: number): number => {
const frustum = 2 * d * Math.tan((fov * Math.PI) / 360);
return Math.max(1, (0.016 * frustum) / 0.42);
};
// 1,160 units is the far end of the orbit over the California corridor — a
// pose people actually use. It must be untouched at every field of view the
// scenes run at, because below 0.012 of the frame the wings stop resolving
// and a ceiling of 26 put it at 0.0123.
for (const fov of [42, 50, 60]) {
assert.equal(
glyphScale(1160, fov),
uncapped(1160, fov),
`the ceiling must not bind at 1160 units and ${fov} degrees`,
);
}
// And the chapter-zoom case must actually come down.
assert.ok(
glyphScale(2280, 50) < uncapped(2280, 50) * 0.7,
"the ceiling must remove at least 30% of the worst case",
);
});
it("is monotonic, so an aeroplane never grows as it approaches", () => {
let previous = 0;
for (const d of [1, 10, 50, 100, 300, 700, 900, 2000, 5000]) {
const s = glyphScale(d, FOV);
assert.ok(s >= previous, `scale fell between distances at ${d}`);
previous = s;
}
});
it("returns 1 for degenerate inputs rather than emptying the sky", () => {
for (const [d, fov] of [[0, FOV], [-1, FOV], [10, 0], [10, 180], [NaN, FOV], [10, NaN]]) {
assert.equal(glyphScale(d as number, fov as number), 1);
}
});
});