Deterministic void-pocket system for infinite 3D procedural worlds.
O(1) per cell. No stored world state. Zero bytes describe infinity.
The Koch Megastructure generates an infinite interior world from a single seed — no stored maps, no chunk files. But to place a large Point of Interest (a city gate, a reactor core, a transit hub), you need empty space that the topology won't fill in.
ZeroStructureMask punches void
pockets into the megastructure at registered coordinates. Any cell within the pocket
radius suppresses its Koch panel generation. The anchor cell at the centre renders a
diamond BSP placeholder — or a real .glb / .gltf model
when one is provided.
The system is a pure drop-in: it wraps buildCellMesh with an early-exit
guard and adds a second draw pass for placeholders. No existing functions are modified.
Left-click to place a Structure Site. Click an existing anchor to remove it. Drag right-click to pan. Scroll to zoom. Use the Y Slice slider to travel through layers.
For every cell coordinate (cx, cy, cz) queried during the Koch mesh build,
the mask runs a linear scan over STRUCTURE_SITES[]. For each site,
axis-aligned Chebyshev distance is computed and compared to the site's radius.
Three outcomes are possible: the cell is normal (no mask, build Koch geometry as usual), a pocket cell (fully suppressed, return empty mesh), or a boundary cell (Koch panels scaled down by a smoothstep ramp to blend the edge).
The anchor cell — at distance 0 from the site — is always empty and triggers a placeholder diamond draw in a separate render pass.
for (site of STRUCTURE_SITES) { dx = |cx - site.cx| dy = |cy - site.cy| dz = |cz - site.cz| if (dx ≤ radiusX AND dy ≤ radiusY AND dz ≤ radiusZ) { // Chebyshev dist → smoothstep blend blend = max(dx/rx, dy/ry, dz/rz) t = smoothstep(blend) return { masked: true, isAnchor: (dx=0 AND dy=0 AND dz=0), blend: t } } } return { masked: false }
ZeroStructureMask is inserted at five precise locations in
KochMegastructureV3.jsx. No existing function bodies
need to be altered — only wrapped or extended.
Insert the site array and querySiteMask() immediately after the existing constants block (BIOME_PROPS). Each site specifies its cell coordinate, axis radii, an optional model URL, and a display label.
{ id: 0, cx: 4, cy: 0, cz: 4,
radiusX: 2, radiusY: 1, radiusZ: 2,
modelUrl: null, // or '/models/nexus.glb'
label: 'NEXUS GATE ALPHA' }
Add an early-exit block at the very top of buildCellMesh. Anchors and deep pocket cells return Float32Array(0) immediately. Boundary cells derive a _maskScale value that is multiplied against every kochD() displacement call later in the function.
A new function builds a flat-shaded regular octahedron using the existing STRIDE/CELL constants. A second minimal WebGL shader (ANCHOR_VS / ANCHOR_FS) renders it with amber rim lighting and a slow pulse uniform. Buffers are cached in anchorCache keyed by site ID.
After the Koch cell draw loop, a short loop over STRUCTURE_SITES distance-culls each site and draws its anchor buffer. The main Koch shader is restored afterwards with gl.useProgram(prog).
Two new HUD lines show total site count and nearest site label. When the camera is inside a mask zone, the biome line flips to amber and displays the site label. Anchor buffers are deleted in the existing teardown return.
The full site registry is a plain JavaScript array — no database, no binary format, no file IO. It lives as a constant in the component body and is evaluated once at mount.
Sites can be authored by hand, generated procedurally from a secondary ZeroBytes pass, or exported from the ProceduralTerrain Structure Layer editor and ingested here.
| FIELD | TYPE | PURPOSE |
|---|---|---|
| id | number | Unique integer, used as GL buffer cache key |
| cx, cy, cz | number | Anchor cell coordinate (integer, any range) |
| radiusX/Y/Z | number | Void half-extents in cells per axis |
| modelUrl | string|null | Path to .glb/.gltf; null shows placeholder |
| label | string | Display name, shown in HUD and on anchor |
const STRUCTURE_SITES = [ { id: 0, cx: 4, cy: 0, cz: 4, radiusX: 2, radiusY: 1, radiusZ: 2, modelUrl: null, label: 'NEXUS GATE ALPHA', }, { id: 1, cx: -6, cy: 1, cz: 2, radiusX: 2, radiusY: 1, radiusZ: 2, modelUrl: '/models/shard.glb', label: 'TRANSIT SHARD BETA', }, { id: 2, cx: 0, cy: -1, cz: -8, radiusX: 3, // larger site radiusY: 2, radiusZ: 3, modelUrl: null, label: 'CATHEDRAL VOID', }, ];
cx × STRIDE where STRIDE = CELL + GAP = 608u.
The anchor mesh is automatically centred at cx×608 + 256.