← labopen blocks →

Blocks

Stone blocks on a lattice, set with a finger. You set plain blocks and nothing else: no block has a part to play, and no form has a name. Every cell, stone or empty, is read from the cells round it as a few plain quantities. Two programs then fill it with small cubes, twelve a side, from its read and its neighbours' reads.

What comes of that is a small diorama. Ring a patch of ground with walls and it becomes a court:

Walls carry a cornice. Roofs have a parapet, and a dome where the roof is roof all round. Stacks taper into fluted columns, arches are cut under what has nothing beneath it, and ivy climbs where the surroundings say. Nothing in the code asks for a courtyard, a porch or a column. Where the quantities fall in between, you get something in between.

Set one block and the shapes round it change. So do the shapes across any court it closes or opens. You see the change run out from your finger, ring by ring.

Hands

TouchMouse and keys
see where a block would gotouch: it shows already as it would be there, fainthover
set itlift your fingerclick
lay a rundrag: a floor across the top you touched, a wall up the sidedrag
take a blockhold on it; drag on to take moreright-click
take, for a whiletake (it goes red), then touch or dragX
step backundo: a run is one step⌘Z / Ctrl-Z
look aroundtwo fingers turn and pinch; or drag the skyright-drag (or shift-drag); the wheel
start againbegin again

Each block clicks as you set it. The click is higher the higher the block is, brighter for a slender stone and deeper in a mass. The phone buzzes too. The build is kept on this device.

What a cell reads

A cell reads the cells two each way round it: 124 cells. An empty cell also looks along its own level, up to six cells each way. Nothing about a cell is stored: read the same arrangement again, anywhere, and you get the same cell.

A stone cell reads:

An empty cell reads:

Both read their surroundings turned to a canonical orientation: the least of the eight turns and mirrors about the vertical, compared cell by cell. That gives a code, which seeds whatever is chosen by chance (where ivy grows, the lilies, the blooms). Cells with the same surroundings, however turned, come out alike.

And where a mass's top is, and how broad:

None of these is a name given to a block. A small tall mass with a narrow top reads as a house; a thick loaded one as rock.

What a stone cell becomes

The empty cell in frontThe face
covered, with stone beyond ita sunk panel of tile (a niche)
covered, walled at its sidesthe back of a porch: a pointed opening framed in tile, a door on the ground, a window above
covereda pointed opening
a court, with stone over this blocka window, or a door on the ground
outside, above the ground, with stone over this blocka slit window

Where the empty cell's code says so, ivy grows over the face, thicker low down.

What an empty cell becomes

How it's made

Each cell's cubes come from its own read and the reads of the 26 cells round it. A cell's mesh is made from its cubes and its neighbours' cubes. So a mesh depends only on the reads of the cells two each way round it, and it's named and kept by them: the same arrangement anywhere is the same mesh, made once.

A face of a cube shows where it meets nothing, in this cell or the next. Faces of the same stuff in one plane, shaded alike, are merged into one quad. Each corner is darkened by the cubes round it. Every face lies on the lattice of twelfths, the same from either cell, so the build is closed whatever order it was built in.

When you set a block:

  1. The block itself is shaped already; the faint preview made it.
  2. The cells round it are read again, and so are the cells across its court.
  3. Workers shape whatever is new, nearest first, and each new shape is put in as it arrives. The workers are this lab's own bundle, loaded again as workers.

The page's own thread spends a few milliseconds on an edit. The shapes spring, settle and sink in the vertex shader, so a touch is felt without any work on the CPU.

Drawing

The build is seen from above, square on to the diagonal, with no perspective. It stands on a pale ground, in soft light, on a slab cut square round it, with the section of earth and stone strata showing.

Each cube's face is coloured by its stuff and where it is:

It's lit by a warm sun with soft shadows, a pale sky that fills the shade, and light thrown back from the ground.

Presets

the stone goes: two quay arms and a back quay round a basin, rock in three terraces with a crag, and small masses on each terrace with gaps between. The village comes from the reads.

Checks

node cells/lab/devtools/blocks.test.mjs checks:

node cells/lab/devtools/blocks-shot.mjs [outdir] [view,view…] draws each demo and tries the hand in a browser: a tap sets, a drag lays a run, a hold takes, and undo puts it back.

node cells/lab/devtools/cliff-board.mjs blocks draws the cliff demo from a pinned eye beside the target it's working toward (devtools/targets/cliff-village.jpg: a village stacked on a cliff over a harbour, made as a tabletop piece), in devtools/out/cliff-board.png.