719 cells · 191 corners · 417 brushes
Five ways to build a world out of pieces that aren't cubes, each a shared world anyone can build on. Hex prisms stack in layers; rhombic dodecahedra and truncated octahedra fill space with no cube's corners; the dual grid puts pieces on the corners of a grid and draws what lies between them, the way Townscaper does; and the smooth world is sculpted from soft brushes of density.
What fold does here
Whatever the strategy, fold is the system of record. Putting a piece down inserts a row, taking one away retracts it, each one transaction; nothing drawn is stored. For the three lattices, fold keeps faces: every cell's sides keyed by the cell across each, without the cells that stand there, so only the sides you can see are kept. For the dual grid it keeps tiles, each cell's eight corners folded into a mask. For the smooth world it keeps field, every brush's share of density summed at each point of a grid.
Fold refuses a cell off its lattice (the face-centred cubic lattice's points sum to an even number, the body-centred one's are all even or all odd), anything out of bounds, a brush too big or small, and a world past its cap. Undo is a retraction too: it removes your newest piece still standing, read from a view of each builder's newest.
Why it shows off fold
The same few operators, a flat map, a key, an anti-join, a count, an aggregate, describe five quite different kinds of world, and fold keeps each one current as rows come and go. Retraction is the interesting half. Taking a cell away doesn't need the app to work out which of its neighbours' sides now show: fold retracts the cell from the anti-join and they come back. And in the smooth world, retracting a brush from an hour ago takes out exactly what it added or carved, leaving every brush since just as it was, because the field is a sum, not a history replayed.
Worth trying
- Click a face to put a piece against it; right-click (or Shift-click, or Remove) to take one away. Drag to turn, scroll or pinch to zoom.
- Open the same world in two windows and build in one.
- In the smooth world, add a few brushes over one another, then Retract the first: the ones on top stay put.
- Try to put a rhombic dodecahedron where it can't go: open the inspector (the backslash key) to see fold refuse it.
- Watch the inspector as you put a piece next to others: one row into
cells, and several sides out of faces.
Still app code
Each lattice's geometry and the meshing in the page (each side's polygon, and surface nets for the dual grid and the smooth field), the camera, and picking what's under the pointer.
Press \ in the app to watch fold's commits as they happen.