Emmanuel BalogunFrontend & Full-Stack Developer
--:--:-- WAT

04Data visualisation · WebGPU map

Third Mainland

A GPU-rendered night map of how Lagos moves through a day

An installable web app where 40,000 particles flow along Lagos’s real roads, BRT lanes, rail lines and ferry routes. Scrub the clock or switch to a Saturday or a rain day, and every corridor’s speed, journey time and timetable changes with it.

Year
2026
Role
Frontend developer · Data visualisation
Stack
React 19 · TypeScript · three.js (WebGPU + TSL) · WebGL 2 fallback · OpenStreetMap / Overpass · Vite · vite-plugin-pwa · Vitest · Playwright + axe-core · GitHub Actions
Third Mainland at the 07:42 morning peak: amber particles packed onto Third Mainland Bridge, a corridor list with speeds on the right and a demand histogram along the bottom
PlateWeekday, 07:42 — Third Mainland Bridge selected, with both directions’ speed and journey time.
A — The problem

Everyone in Lagos knows Third Mainland Bridge is slow at 07:40, but traffic is usually shown as a red line on a map with no sense of rhythm. I wanted a map that shows the city breathing through a day — and runs smoothly on an ordinary phone, not just a gaming laptop.

B — What it does
  • 01Scrub the day on a demand histogram, jump to the morning peak, midday, evening peak or night, or press play to run the clock.
  • 02Switch between a weekday, a Saturday (midday market peak, thinner timetables) and a rain day (less road capacity, fewer ferries).
  • 03Tap any corridor, or pick it from a sortable list, for both directions’ speed and end-to-end time, or headway and next departure for transit.
  • 04Every figure on the map is also in a plain table view, and the app installs and works offline after the first visit.
C — Decisions & trade-offs
  1. D-01

    Move the dots on the GPU, write two numbers per road on the CPU

    Each particle is one instance of a quad with its corridor, direction and phase packed into attributes once. Every frame the CPU writes only how far the flow has advanced and how full the road is into a small texture; the vertex shader looks up the route in a path texture and places the dot. When nothing moves, the map only redraws on change.

    Trade-offShader code is harder to debug than DOM or Canvas 2D, but 40,000 moving points stay smooth on a mid-range phone.

  2. D-02

    WebGPU first, with two fallbacks

    The three.js WebGPU renderer falls back to WebGL 2 automatically, and again if a WebGPU device is lost at start-up. If neither starts, the table view becomes the whole app instead of a blank screen.

    Trade-offEvery visual has to work on two backends, which limits some effects, but nobody gets an empty canvas.

  3. D-03

    Real geometry, an honest model

    A small TypeScript pipeline pulls roads and routes from OpenStreetMap, traces each corridor with Dijkstra and simplifies it into a 125 KB file. The traffic on top is a hand-tuned model using the BPR speed curve transport planners use, and an “Illustrative” badge on screen explains exactly that.

    Trade-offIt cannot tell you about today’s traffic, but it never pretends to.

D — Outcome
40,000particles rendered on the GPU along real corridors
125 KBof processed map data, built from OpenStreetMap
2viewports (390px and 1440px) checked with Playwright and axe in CI
E — Known limits
  • Flows come from a modelled day, not live traffic data.
  • Map data covers a box around central Lagos, not the whole state.