Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions app/prototypes/run-diorama/HOW_IT_WORKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,26 @@ Buildings follow OpenStreetMap's Simple 3D Buildings tags so landmarks keep thei
- Walls carry a repeating window-and-floor texture: one cell per 3.4 m bay and 3.2 m floor, measured from the ground so floors line up across parts.
- Pitched roofs are lofted from the footprint toward a ridge, point or ring in a frame aligned with the longest wall (`building-geometry.ts`). All buildings merge into one mesh.

## A living city

Every diorama comes alive on its own, SimCity style, placed from the map data so no city needs hand work (`life.ts`, one instanced mesh per model, moved on the CPU each frame; about 0.15 ms per frame in total; paused under reduced motion).

The models are playful, game-style toys built in Blender (`landmarks-src/props.py`, run with the same `bpy` venv as the landmarks) into one file, `public/run-diorama/props.glb` (21 models, about 1 MB): sedan, hatchback, SUV, taxi, pickup, van, city bus and box truck; speedboat, sailboat, yacht, tugboat and ferry; a train cab and carriage; a person (body and legs, so the legs can step); a gull; an airliner; a hot-air balloon; a factory chimney. `props.ts` loads it once (the scene starts the fetch as it opens) and bakes each model into one geometry with per-vertex colour plus three flags: `paint` (Blender material "paint": tinted by each instance's colour, so a red car keeps black tyres), `glow` (materials named `glow_*`: lamps and windows that light up after dark through a shared `nightGlow` uniform, which the bloom picks up) and `flap` (the gull's wings). All props share one material (`propMaterial`), and `Fleet` keeps one instanced mesh per variant. If the map is ready before the models, the moving life joins a moment later.


- **Boats** (up to 26, 14 on phones) on open water found in the water mask: motorboats, sailboats and, on wide water, ferries. Each looks ahead and steers toward open water when land is coming, bobs and rolls, and trails a soft white wake.
- **Trains** on rail lines: rail pieces inside the square are joined end to end, and the longest (up to 6) each carry a 3–6 carriage train with a cab at both ends. It rides bridge decks at their height, stops at the end of the line for 3 s and heads back.
- **People** (up to 320, 160 on phones) walking footpaths and the sidewalks of ordinary streets with a stepping gait; on bridges they walk the deck. At night 70% go home.
- **Birds**: 2–3 flocks circling and banking, wings flapping in the vertex shader; white gulls when a flock flies over water, dark birds inland. They roost at night.
- **Factory chimneys**: the largest industrial areas (up to 6) get a banded brick chimney puffing steam that rises, swells and leans downwind with the run's wind.
- **Sky**: an airliner crosses every 45 s (blinking light at night), and on calm days a striped hot-air balloon drifts downwind across the square.
- **Cars** (`traffic.ts`) are a weighted mix of the eight vehicles (buses and trucks only on roads 8 m and wider), with headlights and tail lights that glow after dark.
- **Trees sway**: the crown material bends each tree downwind in rolling gusts (phase follows position along the wind, so neighbours move together); strength follows the run-hour wind speed.

## Ambient sound

`ambience.ts` synthesises the soundscape live with Web Audio (no audio files): a low city hum and drifting traffic swish scaled by buildings per km², surf swells rolling in by the water share, wind through a moving band filter, rain hiss, songbirds by day (more with more trees), gulls over water, crickets at night, and now and then a car horn, a train clacking past with its horn, or a ship's horn when boats are out. The scene reports the mix (`onSoundscape`) after each build and weather change. `use-ambience.ts` turns it on with the first tap or key press (browsers block sound before one), remembers mute per browser (`localStorage` `run-diorama:sound`), and fades out and suspends the audio when the diorama is scrolled away or the tab is hidden. `sound-toggle.tsx` is the mute button under the top-right controls.

## Sun and weather

- `sky.ts` computes the sun's compass bearing and height for the run's start (a low-precision solar ephemeris) and reads that hour's weather from Open-Meteo. Without `start`, noon is assumed; without weather, a clear day.
Expand Down Expand Up @@ -134,12 +154,17 @@ RunDiorama (useRuns) → RunGlobe (full-screen claymation Earth with a pin per p

Target: a diorama in under 5 seconds. The square fits the run's longest side plus 8% each way (the old 30% built about 2.5 times the area). The page starts from the run list saved in IndexedDB on the last visit (`savedConfig`) rather than waiting about 5 s for Strava; the fresh list replaces it, reusing unchanged run objects so the diorama doesn't restart. Google's scan starts with the bare-ground build and the same `GoogleCity` is kept for the full build of that square, so it loads alongside the map data. The tile library advances its queues once per animation frame, which crawled on busy or throttled pages, so the probe drives `update()` and the queues on a 30 ms timer until its capture is done; queues are widened (64 downloads per origin, 12 parses) and the tile cache raised to 0.9 GB so a dense square isn't refused. A capture is taken only once loading has fully settled (checked again just before capturing), and the city is shown once a capture measures most buildings. Mapped bridge towers (slow Overpass) get 1.5 s; if later, the model shows without them and is rebuilt when they arrive (`SceneJob.later`). After a reveal, the next run in that place loads its map data in the background. A saved scene is built once (not as base and full). Timings are logged to the console ("ground ready", "map data ready", "shown after").

## Arrow keys

On desktop, the arrow keys slide the view across the city (left/right along the screen, up/down into and out of the scene), about half the view per second at any zoom, keeping the centre over the diorama. A key press also skips the opening shot. Ignored while typing in a field or with a modifier held.

## Route emphasis

So the run never gets lost in the city (David, Nov 30). The city fade around the route was tried and removed at his request:

- The line is hot pink (`palette.route`), glows (emissive 0.8) and draws over everything (no depth test, render order 10–12) with a dark rim (`palette.routeEdge`, a back-face copy pushed out along the normals), so buildings never hide it.
- The light wall is a fairly solid ribbon with a bright top edge, and a white pulse runs its length every 7 s.
- The line is hot pink (`palette.route`) matte clay (emissive 0.35, as in the first version; David asked for it back Dec 1), drawn over everything (no depth test, render order 10–12, in the see-through pass so the water can't cover it either) so buildings never hide it (David, Dec 1). During the opening shot the line and ball trace the run floating 15% of the wall's height above the ground; once drawn, the line eases up (1.1 s, `routeLift` in the tube shader) to ride along the top edge of the light wall, and every later redraw stays up there with the ball (David, Dec 1), so tall buildings in front can hide stretches of it. It keeps its dark rim (`palette.routeEdge`, a back-face copy pushed out along the normals).
- Its shadow is faked, since the scene has no shadow map: a soft dark ribbon (`routeShadowMesh`) on the ground along the wall's foot, marking where the run went, pushed away from the sun (about 3.5× further than true so it reads at the overview zoom), thinning and drawing along with the tube. Render order 9, after the ground's see-through layers.
- The light wall is a fairly solid ribbon with a bright top edge, and a white pulse runs its length every 2.3 s, and it stands 0.1875 × the square's width tall (David, Dec 1: 3× the pulses, 2.5× the height).

## Landmarks

Expand Down Expand Up @@ -205,6 +230,9 @@ A diorama's map data (elevation, map features, land cover and bridge parts) is s
- `google-tiles.ts` — Google photoreal tiles: loading, clipping, alignment, credits.
- `diorama-scene.ts` — three.js scene: terrain, sides, buildings, trees, route.
- `bridges.ts`, `piers.ts`, `live-water.ts`, `traffic.ts` — bridges, piers, water and cars.
- `life.ts` — boats, trains, people, birds, chimneys, plane and balloon.
- `props.ts` — loads the Blender-made models (`public/run-diorama/props.glb`, built by `landmarks-src/props.py`), their shared material and `Fleet`.
- `ambience.ts`, `use-ambience.ts`, `sound-toggle.tsx` — ambient sound and its mute button.
- `strava-bar.tsx` — the small Strava connect button.
- `diorama-loader.tsx` — the cover shown while the diorama builds.
- `light-wall.ts` — the glowing curtain of light rising from the route (7.5% of the square tall, the route's colour, semi-transparent, fades with height, drifting bands and sparks, follows the route as it draws).
Expand Down
Loading
Loading