← All projects

Case Study · 2026

Block Flight

Screenshot of Block Flight

The Problem

A voxel world is cheap to generate and expensive to stream at flying speed. I wanted a bush-flying sim that runs in a browser tab, with a flight model that behaves like an aeroplane and terrain that never visibly pops in.

Key Decisions

Move chunk generation off the main thread

The first version generated terrain chunks synchronously. Cruising for 15 seconds produced 102 frames longer than 30 ms, with a worst frame of 107 ms. I made the terrain, airport and voxel code pure modules and moved generation to a pool of three Web Workers. The same cruise then ran at 59.9 fps on average, up from 37.6, with no long frames and a worst frame of 27 ms.

Load the chunks the plane is flying toward

Loading nearest-first wastes effort behind the aircraft. Chunks are scored by distance minus a bonus for lying ahead of the velocity vector, so terrain in the direction of flight arrives first. That removed the need for a separate ready queue.

Three detail rings out to 60 km

Full voxels are drawn within 256 metres. Beyond that, three lower-detail terrain rings reach 4, 12 and 60 kilometres, with fog covering the far edge. Airports get tall markers so you can plan an approach from tens of kilometres out.

Write the flight model from forces, not animation

The plane is driven by a force integrator, not scripted motion. It models stall buffet and wing drop, spins, P-factor, ground effect, prop wash over the tail, and thrust that falls with air density at altitude. Prop wash gives the elevator authority at low speed, so on a tail-dragger takeoff the tail can lift first.

What Didn't Work

Instanced trees

Drawing trees as instanced meshes is the textbook optimization, so I tried it two ways. Per-chunk instances raised draw calls from 52 to 385. A single global pool still cruised at 21 fps against 32 without it. The greedy mesher was already merging adjacent tree blocks well, so I reverted both.

Results

  • Cruise frame rate up 59%, from 37.6 to 59.9 fps
  • Long frames during a 15-second cruise down from 102 to 0
  • Terrain visible to 60 km with no pop-in at cruise speed

Stack

TypeScriptViteThree.jsWebGLsimplex-noiseVercel