MA
Lab 01

Contour field

The living map behind every page of this site, with the controls exposed. Point to raise the ground; click, tap or drag to drop peaks.

Terrain #1337 · everything stays saved in this browser.

fps
–
cells
–
line segments
–
How it works

Three ideas, one canvas

  1. 01

    Noise

    A 3D Perlin noise field is sampled on a grid of cells: two octaves for the landscape, and the third dimension is time, so the terrain drifts instead of jumping.

  2. 02

    Marching squares

    Each cell compares its four corners against every height level that crosses it. Sixteen cases decide where a line enters and leaves the cell, and interpolating along the edges keeps the lines smooth.

  3. 03

    Off the main thread

    Behind the rest of the site the same idea runs in a Web Worker on an OffscreenCanvas: coarser grid on phones, paused when the tab is hidden, frozen for visitors who ask for reduced motion. Scrolling never waits on it.

TypeScript · Canvas 2D · OffscreenCanvas · Web WorkersSee the real work