A low-poly town on a round wooden board, generated entirely in code from a seed: no model files, textures, images or HDRIs. The generator is a pure TypeScript module (gen.ts, no Three.js) covered by Vitest; assets.ts is a small asset library that turns the generator's output into geometry, and scene.ts renders it.
Determinism. The seed text (trimmed, case-insensitive; a number is the same as its digits as text) is hashed to 32 bits and drives a small seeded random generator plus value-noise fbm. Every stage (terrain, streets, plots, piers, trees) draws from its own stream, so the same seed and sliders give the same town on every device, and adding trees with the slider only adds trees.
Terrain. Height is two layers of fbm (hills and a broad ridge), a rim that falls away unevenly so some edges are cliffs and some are beach, a sine-meandering river across the island, a round bay cut into the rim and a flat shelf in the middle for the centre. Once the streets exist they are flattened into the ground, so roads, plots and trees all read the same height function. The mesh is a jittered square grid pushed onto a circle, drawn flat-shaded with a colour per face from height and slope (sand, grass, rock), plus a cut-away wall in soil layers. A distance-to-water field (two-pass chamfer on a 0.5-unit grid) feeds ports and trees.
Streets and bridges. Four arms grow from the centre in steps of about three units: each tip goes straight (93 %), forks at right angles (more often near the centre), joins any crossing within half a step and refuses to cross another street. Before each step the generator scans up to about five units ahead; if there is water and then land, it lays a bridge to the far bank (at least 3.2 units from the previous one), with a slight arch, rails and stone piers.
Buildings. Plots run along both sides of every street. A plot is accepted only if all four corners are above the beach, the ground under it is nearly level, it is clear of streets and an oriented-box test finds no overlap with earlier plots. Zones: centre (inside 30 % of the radius: two to four floors, striped awnings, one clock tower), port (within two units of water: long low warehouses with cargo doors and crates, some with a pier and a moored boat) and homes. Each house is assembled from modules (plinth, wall block, gable, hip or flat roof, door with lintel, framed windows on all four walls, chimney, dormer) in one of five palettes chosen by the seed (Candy, Aegean, Nordic, Autumn, Seaside).
Instancing, merging and LOD. Buildings are merged into one geometry per 6-unit chunk, with vertex colours carrying the palette, and each chunk is built twice: a detailed version and a simple one (walls, roof and one glowing strip per floor). The simple version replaces the detailed one for chunks beyond a distance tied to the default camera distance (a little tighter on the light tier), with 3 % hysteresis; zooming out pushes every chunk to the simple version. Trees are three InstancedMesh objects (pine, round, bush) tinted per instance, with a small sway in the vertex shader; their number follows the density slider, higher ground and the shoreline, and thins out near the centre (capped at 2,200, or 900 on the light tier). Street lamps, bridges, piers and the windmill tower are one merged mesh; flowers, rocks, townsfolk, cars, gulls and chimney smoke are further InstancedMesh objects; boats and the windmill sails are separate small meshes.
Light and time of day. A hemisphere light and one directional light, Khronos neutral tone mapping, a gradient sky shader, fog in the horizon colour and a few stars at night. Morning, day, sunset and night are presets that ease towards each other; windows and lamps use one emissive material whose strength rises at dusk. Water is one translucent mesh whose vertex colour and alpha come from depth (light and clear at the shore), with a small vertex-shader ripple and specular glints on the flat facets. Shadows are on for the full tier only.
Life. Townsfolk (up to 70) walk the street graph on the pavements and cars (up to 14) drive on it, picking a new street at every crossing and rising over the arch on bridges; eight gulls circle the town and flap by scaling their wings; smoke puffs rise from the chimneys; the windmill (placed on level high ground clear of streets and houses) turns its sails; sailing boats turn away from shallows and the rim while moored boats bob; lamps get a soft additive halo at dusk. All of it is driven from the clock on the CPU or in the vertex shader and stops under reduced motion.
Motion between states. Regenerating fades the view into the table colour with a full-screen veil (about a third of a second), swaps the town while it is hidden, then fades back over under a second while the board settles by a few percent and the districts rise into place outward from the middle: no big zoom and no two towns on screen at once. The camera sweeps in once on load and eases with a rate that changes smoothly, the auto-turn fades in after a few idle seconds, and the time of day eases between presets. Under reduced motion every change is a cut.
Controls. One finger or the mouse turns and tilts the view, two fingers pinch, Ctrl plus the wheel zooms (a plain wheel keeps scrolling the page), buttons and keys do the same, and the camera drifts slowly when left alone.
Performance. One draw call per material and chunk: the default town draws in about 73 calls on the full tier and about 49 on the light tier (measured through renderer.info). Generation takes roughly 15–25 ms for a town in Node. Pixel ratio is capped at 2 (1.25 on the light tier), rendering pauses off screen and in hidden tabs, and every geometry, instanced mesh, material and the renderer are disposed on unmount or regeneration. Under reduced motion nothing moves on its own and the scene renders only when something changes.
Tests. Vitest checks determinism, that every building corner stands on dry land with no overlaps, that bridges start and end on land and cross water, and that the sliders do what they say.