Skip to content

Firenze Story — Tech stack

A static site: everything is built ahead by the pipeline and served as files; there is no backend.

1. Runtime (browser)

Concern Choice Notes
3D engine three.js 0.187 with WebGPURenderer and TSL node materials WebGPU where the browser has it; the same renderer falls back to WebGL2 (most phones), and the TSL materials run on both.
City Own binary tiles (pipeline/23_city_tiles.py, web/src/scene/city.ts) Every building carries its start and end year, heights and style; tiles stream in around the view.
Time filter In the shader, from per-building years Moving the timeline never reloads the city's geometry; buildings rise and fall on the GPU.
Terrain Height grids from the LiDAR 2023 DTM (2 m and 4 m), a wider valley from Copernicus Two heights per cell (before and after the embankments), blended by year.
Landmarks glTF models built in Blender by script (blender/scripts/build_*.py) Parts named with their years; loaded by place and by year.
People Skinned figures with a period costume kit; full character models close to the camera Walk on the street graph from OpenStreetMap, filtered by era (web/src/sim/).
Events Scripted scenes (web/src/sim/scenes.ts, liveEvents.ts, flood.ts) Props from the Blender asset library; narration in the bubble above the timeline.
Post-processing TSL: tilt-shift for the miniature view, fog by tier
App shell Vite + TypeScript, plain DOM for the interface The view (year, day, mode, colours, overlay, selected building, camera) is kept in the address, so a link reopens it.

1b. Device tiers, loading and memory

Tiers. web/src/quality.ts runs before the renderer starts. The WebGPU adapter (vendor, fallback adapter, buffer limits) or the WebGL renderer string, navigator.deviceMemory, the core count, a coarse pointer and the screen size give a score and one of four tiers; the loading screen shows it. The adapter is asked for the high-performance GPU; a recent desktop graphics card (NVIDIA, AMD Radeon, Intel Arc) with at least 1 GB buffers gets high; the tier is remembered per GPU in the browser.

Tier For Pixel ratio Shadows City within Landmark models within Walkers Trees
high desktops with a graphics card 1.5 2048 px 1.3 km 1 km 120 all
mid laptops, recent phones 1.25 2048 px 1 km 800 m 80 60 %
low phones, 2–4 GB devices, software GPUs 1 none 800 m 700 m 45 30 %
min 2–3 GB phones 1, no antialiasing none 550 m 500 m 20 15 %

Phones and tablets. A touch device that is not high-end (WebGPU, 6+ cores and 6+ GB where the browser tells) draws no people, trees, animals, birds or boats and no shadows, and uses the 512 px textures: the buildings, the landmarks, the river and the timeline are what it is for. Live events keep their actors (at most 60 light figures, fetched only then). Touch devices draw at most 30 frames a second; a phone without life whose view is still draws twice a second. ?mobile tries this profile on a desktop.

What each frame draws (2026-12-03). Measured with the same views before and after, on the phone profile:

Before After
Street view (52 m up) 3.6 M triangles, 273 draw calls, 532 MB GPU 0.88 M triangles, 136 draw calls, 139 MB GPU
Overview (590 m up) 4.5 M triangles, 790 draw calls 2.0 M triangles, 315 draw calls, 228 MB GPU
Downloaded for the first view 128 MB ≈58 MB

On mid (laptops) the street view went from 11–12 M triangles to ≈3.7 M. How: - Crowd figure. The Mixamo figure, its costumes and heads are simplified from the masters in assets/masters (pipeline/24_pack_models.py: ≈67 000 → ≈11 000 triangles a figure), fetched once for every crowd and the close-up people. - Packed models. Every model is meshopt-compressed by gltfpack (24_pack_models.py, run by prepare.py after Blender; the .blend files stay the editable masters): landmarks 118 MB → 21 MB. One loader (gltfLoader() in scene/assets.ts) carries the decoder. - Ground in tiles. The core ground is 8 × 8 tiles with four levels of detail (every vertex, every 2nd, 4th, 8th), picked by distance, each tile skirted so no crack shows (buildTiles in scene/environment.ts). - Landmark pieces. On load, a model's pieces that stand the same years in the same material and member become one mesh (mergeParts in scene/landmarks.ts); pieces smaller on screen than the tier's smallCut are not drawn. - Textures. low, min and phones without life use half-size colour maps without roughness maps, and a 2k orthophoto (pipeline/31_small_textures.py). - Reach. How far the city and the landmarks load as the view rises is the tier's reach (× the camera's height): 2.4 on desktops, 1.2 on phones. - Shadows are drawn again only when the sun, the view's centre, the year, a scene or the loaded models change.

On low and min the ordinary buildings are plain off-white (walls a touch lighter than roofs, a faint per-building variation) and only the landmark models are drawn in full: the city's shader – procedural windows, shopfronts and roof tiles – is the biggest cost per pixel. The fog closes the view to a circle of focus that always reaches what the camera looks at. Both tiers use the 4 m ground and no tilt-shift.

URL switches for testing: ?q=min|low|mid|high (?lite = low), ?white (the plain city on any tier), ?heroes / ?noheroes (close-up characters), ?gl (the WebGL2 backend), ?prof (frame profiler: __prof.report() in the console, web/src/dev/prof.ts).

Run-time governor (web/src/perf.ts). Every 4 s it reads the mean frame time and (Chrome) the JS heap: over 45 ms a frame or 80 % of the heap it thins the crowds by a quarter (people.setBudget) and, lower down, the pixel ratio; under 24 ms and 60 % it gives back a little every 12 s, never above the tier.

Only what is in view is loaded. - City tiles and landmark models reach out with the camera's height (a high view loads farther, a street view less); those beyond 1.6 × the radius are let go with their geometry and materials freed. - Landmark models by year. spans.json (pipeline/57_landmark_spans.py) says which years each model shows. A model loads for the year on screen; while the timeline is dragged nothing new is asked for until the cursor rests 0.3 s; while it plays, the models of the next ~12 s of years come in ahead, those standing in the year shown first. On mid, low and min models of other centuries are let go (60 years of slack). Until a model is in, the city's plain shell of the building stands in its place. Models stream two at a time, nearest first; a load that fails or hangs (45 s) is tried again after 6 s, 12 s and so on up to a minute. A part of a model too small on screen (under 0.4 % of the view's angle) is not drawn. - Trees in tiles built as the view comes near (a few per frame), detailed within 900 m, simple crowns without shadows beyond (env.streamTrees). - People only from 220 m camera height down; figures outside the view are neither drawn nor animated, only those within 55 m cast shadows; idle hidden figures are freed every 5 s. On the two lower tiers the crowds wait until the city's tiles round the view are in. The squares' crowds are set up one site per half second. - River: boats from 700 m down, small craft and crews from 220 m, only within 900 m of the view's focus. - Walkable surface (web/src/scene/surface.ts) built in 16 m tiles of typed arrays within 450 m of the view's focus, dropped beyond 800 m. - Arrays freed after upload (web/src/scene/memory.ts): once the GPU holds a mesh's buffers, the browser's copies of the parts no code reads again are let go (the ground's normals and year heights; the city tiles' normals and façade coordinates; landmark normals and UVs). A mesh whose positions were freed is skipped by rays; the ground is picked by stepping along the height function. - One loading line just above the timeline says what is still coming in – city blocks, landmark models, trees, people – with a bar; the map stays usable while it fills. The shaders are compiled behind the loading screen (renderer.compileAsync). On handheld devices the loading screen carries a note that the app shows its best detail on a desktop or laptop.

A landmark on its own (showLandmark in web/src/main.ts, landmarks.solo). A hand-built model picked in the search or in the Landmarks list is shown alone, without the map, on a plain disc: it starts facing its front (the side its definition names in face, or the nearest square) and makes one slow full turn back to it, then drag turns round it and the wheel zooms; the timeline still runs its phases. Alone, every part of the model is drawn at full detail (lod(eye, true): no level-of-detail switching as the camera circles, which made it shake). Closing it brings the map back and the camera flies to the landmark.

A landmark on its own, through time. Opened from the Landmarks list, a model that changed over the centuries plays its phases first: the year runs from its first appearance through each change to the year asked for, a short pause on each, in at most six seconds of wall-clock time (solo.play in web/src/main.ts; the years come from its parts' names in landmarks.solo).

Pictures. The lightbox (web/src/ui/gallery.ts) zooms with the wheel, a pinch, a double tap or click and the + − buttons, and a zoomed picture is dragged round; on phones the arrows are large, red and low on the screen.

Trees on low-spec devices. On the low and min tiers the tree tiles are streamed only while the view is within 100 m of the ground; higher up every tile is hidden and its geometry freed.

Close-up figures and uniforms. The close-up characters (sim/heroes.ts) replace only ordinary townspeople: a figure dressed in a livery, a team colour or a uniform keeps its own clothes.

Weirs. Each pescaia is a closed solid (footprint, sloping top, walls to below the riverbed) built in web/src/scene/environment.ts from weirs.json.

Camera and touch. Wheel and pinch zoom towards the point under the cursor or fingers (zoomToCursor). When a zoom-in reaches the closest distance allowed, the view moves forward instead of stopping, keeping the target above the ground, so the zoom never sticks at an odd anchor. On touch devices (pointer: coarse) short hand-gesture animations (web/src/ui/gestures.ts) show once how to move, zoom, turn and tilt, and replace the keyboard list in the commands panel. On phones a building's card opens above the timeline.

Landmark models without scan jaggies (blender/scripts/landmark_new.py). The newer landmarks are built from their outlines, cleaned of small jogs (simplify), not massed from the LiDAR: one roof over the whole outline and its courtyards with straight eaves on the walls (hip_roof), walls from below the ground to the eaves with floors of windows (dressed_walls), and no windows in a bay where the scan shows a neighbour's wall just outside. Fronts are drawn by hand from photographs.

Roof tiles. The city's tile courses follow each roof face by the mesh's own normal, the same over a whole face.

Memory. A desktop at high holds ≈ 0.8 GB in the tab (overview) with ≈ 17 M triangles; a street view with its crowd ≈ 0.9 GB and ≈ 800 draw calls; min ≈ 250–500 MB.

Close-up townspeople (web/src/sim/heroes.ts). On high, with the view under ~90 m or a live event on, up to 24 figures nearest the camera (40 in a live event) wear a full character model instead of the crowd's body and costume kit. Each character copies its figure's skeleton every frame, as the change from rest in world space, so every clip, pose and gesture carries over. The models come from pipeline/people/ (concept image → rigged model → prepare.mjs checks and reduces them: ~14 k triangles, 1024 px WebP, ~1 MB).