Skip to content

alfaoz/babellery

Repository files navigation

the gallery of babel

live on https://babel.alfaoz.dev

an infinite gallery you can walk through. every room (section) has a monolith, every monolith has four paintings, and every painting is deterministic.

inspired by borges' the library of babel, but for images instead of text.

how it works

you navigate a 3d grid of rooms in first person. each room is an open 20m space with a monolith at its center. the monolith has four faces (north, south, east, west), each displaying a 64x64 rgb painting, 12,288 bytes, generated purely from the room coordinate and face index.

the grid is centered on (0, 0) and extends roughly 2^49,000 rooms in each direction, far more than atoms in the observable universe. every coordinate always produces the same painting. there is no randomness at render time.

coordinates

rooms use signed coordinates displayed in hex with an explicit sign prefix:

+7F3A2, -12C

the first value is x (east-west), the second is z (north-south). coordinates can also be represented as compressed base64url tokens for sharing.

internally, signed values are encoded with a zigzag scheme: 0 -> 0, -1 -> 1, 1 -> 2, -2 -> 3, ... this keeps small coordinates compact regardless of sign.

the mapper

the mapper is the core of the gallery of babel. given (roomX, roomZ, faceIndex), it produces exactly 12,288 bytes (64 * 64 * 3 rgb). the pipeline:

  1. pack - encode the x coordinate into the first half of the byte array, z into the second half, and the face index (0-3) into the lowest 2 bits of the first byte.

  2. diffuse - run 4 forward mixing rounds and 4 backward mixing rounds over the packed bytes. each round adds the previous byte plus a stepped tweak value, propagating small coordinate changes across the entire array. forward and backward passes ensure every byte depends on every other byte.

  3. permute - rearrange all 12,288 bytes using a fixed permutation (coprime step walk).

  4. affine transform - multiply each byte by a precomputed odd number and add a constant, all mod 256. the multipliers and addends are seeded deterministically from 0x0badc0de using mulberry32 prng. using odd multipliers guarantee this invertibility.

given an image, the mapper can recover the exact coordinate it belongs to by running the pipeline backwards.

controls

key action
wasd move
mouse look
shift run
space jump
r random jump
ctrl+z undo jump
c copy coordinate
shift+c toggle compact/raw format
f flashlight
p toggle hud
tab navigator panel
click painting inspect image

tech stack

three.js, esbuild, web audio api.

license

gnu gplv3

About

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors