Case study 12 / 25JS Front-End
Real-time rendering architecture for a browser-based 3D spill twin
Engineers now watch a spill spread at a steady ¼ cell per frame, not in 7-cell jumps, with 0 s of main-thread drawing instead of 1.7 s.
My roleDesigned it and led a team of up to 3: set its standards, mentored it, agreed the roadmap with operations and the client, presented to leadership.
Stack
- JavaScript
- CesiumJS
- WebGL
- Web Workers
- ImageBitmap
- Node.js
01 · How it works
- TodaytoChanged in this work
- Data flow
What it does
An offline, browser-based 3D twin that shows where fluid escaping from a pipeline system or a channel would travel over real terrain, how far it spreads and how deep it settles.
Read more
It runs with no server and no network, as a guided what-if tool for engineering audiences. I re-architected the path from simulation output to pixels and left a validated physics model exactly as it was.
5 connections· select a part to trace it
- Leak inputs to Worker: physics + raster: leak point, rate, fluid
- Worker: physics + raster to Main thread: path, thickness, halo image
- Main thread to Ground shape + halo: builds geometry once
- Playback clock to Ground shape + halo: each tick: attributes onlychanged
- Ground shape + halo to 3D map: draws on the terrain
02Results
- R01Lower is better
Main-thread rasterization per scenario
Before 1.7 s, after 0 s, eliminated. Lower is better.BeforeAfter - R02Lower is better
Largest spill-front jump per 60 Hz frame, in cells
Before 7, after 0.25, 28× lower. Lower is better.BeforeAfter - R03Higher is better
Physical pixels rendered at 150% display scaling
Before 44%, after 100%, 2.3× higher. Higher is better.BeforeAfter
What it achieved
- How the spill spreads on screen: jumps of up to 7 cells per frame, then stalls → a steady ¼ cell per frame, paced by the front itself, true to how a release propagates
- Architecture: physics and rendering on one thread → physics and rasterization in a Web Worker, byte-identical output, main-thread fallback
Read more
- Main-thread rasterization per scenario: about 1.7 s → 0
- Ground geometry: rebuilt on every tick → built once, updated through attributes only
- Rendering on scaled displays: 44% of physical pixels → 100%, with a deposit that reads as ground
- Demo surface: nine controls → four plus a menu
03Decisions and trade-offs
- Constraint
Drawing the model's output cost about 40× the physics itself.
DecisionLeave the validated model untouched; move it unchanged into a Web Worker.
What it costA main-thread fallback to keep, and output proven byte-identical.
- Constraint
A linear clock made the front jump up to 7 cells in a frame, then stall.
DecisionPace playback by the front itself; measure a slower playback before choosing.
What it costThe slower playback was dropped: the front's own pace fixed the jumps.
- Constraint
Automated checks do not see a picture.
DecisionAdd a structured visual review to the automated checks.
What it costFour faults had passed every test before the review caught them.
The challenge
The obvious target was the model. Profiling pointed elsewhere: converting its output into pictures cost about 40 times the physics, all on the main thread, with every frame rasterized as its own image layer and the ground geometry rebuilt on every tick.
Playback carried a modeling flaw as well. A linear clock spent most of the front's advance in the first moments, so the front jumped up to seven cells in a single frame and then stalled, which misrepresents how a release propagates.
Read more
On scaled displays the canvas rendered only 44% of its physical pixels, the deposit read as a glow rather than as ground, and nine controls stood between the audience and the scenario.
What I learned
Profile before touching a model. The cost lived downstream, so the right decision was to leave a validated simulation alone and re-architect around it; because it never touched the page, it moved to a worker unchanged, and byte-identical output proved the move safe.
Read more
Playback pacing is a modeling decision, not a cosmetic one: a front that jumps misstates how a release spreads. I also measured and dropped a wet-sheen shader.
Stack
- JavaScript
- CesiumJS
- WebGL
- Web Workers
- ImageBitmap
- Node.js
Skills
- Rendering architecture
- Web Workers and concurrency
- 3D geospatial visualization
- Simulation playback design
- Visual quality assurance

