Real weather, real aircraft, a heightfield off the main thread, and instruments
Three things that were built and never connected, connected.
**The weather was already there.** `observe()` has always taken a
`WeatherObservation` and `main.ts` has always passed null, so the cloud,
precipitation, visibility and marine-layer paths in atmosphere.ts had never run
outside a test. The server already shipped NWS, met.no and Open-Meteo, all
configured off. What was actually missing was that a single TERA_ORIGIN_LAT/LNG
served one metro and lied to the other — so weather and traffic are per-region
now, derived from the city's own bounds, and the Bay Area gets its fog while
Long Beach gets its own sky. The route takes ?city= or a validated ?lat=&lng=
and refuses to become an open geocoding proxy for the planet.
**The heightfield moved to a Worker.** 2.3 s of blocked main thread at boot, and
another ~950 ms of point-in-polygon on top of it: the park mask is filled in the
worker now, and block placement samples four corners and only runs the exact
test on a cell that straddles an edge — 8 buildings differ out of 185,036.
createScene is async and takes a Stage as a consequence, and there is a
main-thread fallback because "clone it and it works" has no exception clause.
**Spaces is a chunk you fetch when you reach for the door**, not one everybody
downloads. Same for the godmode tools. The entry chunk is 722 kB rather than
772; three.js is most of what is left and splitting it is a different job.
**Godmode is an instrument panel now** rather than one slider: the date and the
season, not just the hour, so the Meeus moon and the sun's seasonal arc become
visible instead of merely correct; a weather override that says on screen when
it is lying; a frame-time and draw-call readout; and a pose editor that emits a
paste-ready Chapter block, which is the thing that makes adding New York cheap.
Two blockers the review caught:
- Every city switch leaked 8 GPU textures — one of them a 2048x2048 shadow map
— and ~10.5 shader programs, and deleteTexture had never been called once in
the app's lifetime. The renderer was being built per scene; it belongs to the
canvas, for the life of the page.
- An upstream fetch that threw rather than returning null skipped the cache
stamp, so the TTL — the only rate limit on outbound calls — collapsed to one
upstream request per inbound request, and the caller got a 500.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+20
-2
@@ -131,8 +131,26 @@ export function createBlocks(world: World): THREE.InstancedMesh {
|
||||
|
||||
const [lat, lng] = world.unproject(x, z);
|
||||
if (!world.pointInPolygon(lat, lng, district.polygon)) continue;
|
||||
if (!world.isLand(lat, lng)) continue;
|
||||
if (world.pointInAny(lat, lng, world.city.parks)) continue;
|
||||
/**
|
||||
* Land and parks come off the lattice; the district polygon does not.
|
||||
*
|
||||
* The three tests used to be three exhaustive polygon walks each, and
|
||||
* on the Bay Area's 186k candidate lots that was 240 ms of the boot's
|
||||
* main thread — the largest single item in it, spent re-deriving what
|
||||
* the heightfield Worker had already worked out for the whole board.
|
||||
* `isLandSampled` and `inParkSampled` read that answer and fall through
|
||||
* to the exact test only on a lattice cell that straddles the edge, so
|
||||
* the coastline and the park boundaries are still decided by the
|
||||
* polygons; see `World.sampled`. Same 186k lots, 19 ms.
|
||||
*
|
||||
* The district stays exact because there is no mask for it: districts
|
||||
* are not a property of the lattice, they overlap, and San Francisco
|
||||
* declares fifty-two of them. It is also the cheap one — the polygons
|
||||
* are a dozen vertices and the bounding box rejects almost everything,
|
||||
* which is 47 ms against the coastline's 235.
|
||||
*/
|
||||
if (!world.isLandSampled(lat, lng)) continue;
|
||||
if (world.inParkSampled(lat, lng)) continue;
|
||||
if (rand() > coverage) continue; // yards, car parks, the unbuilt lots
|
||||
|
||||
// Cubed, so tall buildings stay rare and the skyline keeps a
|
||||
|
||||
Reference in New Issue
Block a user