In the article “Procedural SciFi Texture Generation”, I showed how a Voronoi diagram works on a plane and turns into a texture. Here is the next step: the same idea, but in volume. The output is not an image or a point cloud, but a real 3D shape: a closed polygonal shell of a cell that can be rotated, selected, and taken apart.

I specifically searched the internet for a browser demo that builds exactly three-dimensional Manhattan Voronoi cells as polygonal bodies, and I didn't find one. There are 2D generators, screen-space shaders, and voxel approximations, but not exact three-dimensional geometry. So I had to build a separate generator in TypeScript and WebGL2 — without external libraries.

InteractiveManhattan Voronoi 3DExact L1 cells in a cube. Click to load the WebGL2 scene

Demo updated in 2026: a new visual interface and translations.

Below is how the method works, why a single distance formula is not enough here, and what such cells give procedural SciFi.

Why Manhattan Distance

A standard Voronoi diagram uses Euclidean distance L2: a point's cell is the region all of whose points are closer to it than to any other point in the set. On a plane, the boundaries of such cells are straight lines; in three-dimensional problems, they are planes. With Manhattan distance L1, things get more interesting: distance is measured not along a straight line but as the sum of the absolute differences of the coordinates.

d(p, s) = |p.x − s.x| + |p.y − s.y| + |p.z − s.z|

In the two-dimensional case, this metric produces the familiar “blocky” boundaries at 45 degrees. In three dimensions, it produces faceted polyhedra with slanted faces. Visually, these are no longer soft Euclidean honeycombs but a technological, crystalline language: panels, chips, beveled planes. That is exactly why Manhattan Voronoi fits SciFi modeling so well.

Cube Partitioning and Half-Spaces

The main difficulty is that L1 is not a linear function over the whole cube: the sign of each coordinate difference changes when crossing a site coordinate. If you try to simply intersect the cube with one plane for each pair of points, nothing will work — a cell boundary does not have to be a single plane.

So the algorithm first partitions the cube with the planes x = s.x, y = s.y, and z = s.z drawn through all coordinates of all sites. The cube breaks into rectangular boxes. Inside each box, the signs of all coordinate differences are fixed, which means the distance to each site becomes an affine function.

Next, for site i and any neighbor j, the usual definition of a Voronoi cell is used: a point belongs to cell i if d(p, sᵢ) ≤ d(p, sⱼ). Inside a box, this is a linear inequality, that is, a half-space. We start with the current convex piece and successively cut it with half-spaces for all neighbors.

After clipping, a convex polyhedron remains. A site's cell is the union of all such pieces across all boxes. It may be non-convex, but each of its pieces is constructed exactly. This is fundamental: there is no voxel grid, marching cubes, or point-cloud approximation here. Cell boundaries are true polygonal surfaces.

How the 3D Shape Is Produced

After clipping, each piece has vertices, edges, and polygonal faces. The faces are triangulated as a fan, after which volume, center of mass, and normals can be calculated. These triangles are what go into WebGL2: the scene draws cells in the site color, highlights the selected one, and shows outlines.

In the demo, you can change the seed, the number of points, and the spread strength. The spread shifts cells along the direction away from the center, producing a kind of “exploded view” that makes it convenient to examine the structure of the shape. You can isolate a single cell, select it with a click, and view statistics. The camera rotates with the mouse, zooms with the wheel, and a double-click resets the view.

All cells are rebuilt whenever parameters change. The seed makes generation reproducible: the same combination of seed and point count produces the same set of shapes. This matters if you want to return to a successful variant or use it as the basis for a model.

What the Demo Shows

On the left is the 3D scene; on the right is the control panel. It contains the seed, the number of sites, the spread, a list of cells, and a statistics block. A coverage check is displayed separately: the algorithm takes random points in the cube, finds the nearest site by L1, and verifies that the point actually falls into the constructed cell.

The demo uses 20,000 random points. The counters show misses, intersections, and incorrect assignments. If the geometry is assembled correctly, all three counters are zero. This is not interface decoration but an independent check: it catches errors in clipping, lost pieces, and incorrect cell assembly.

Why Procedural SciFi Needs This

Manhattan Voronoi cells produce complex shapes that are hard to invent by hand: they have sharp edges, beveled planes, and unexpected combinations of large and small details. They yield hull panels, station segments, containers, debris, blocks for an arena or architecture. At the same time, every shape remains procedural: it can be reproduced from a seed and changed with parameters.

For SciFi modeling, this is a convenient starting point. The generator does not replace the artist and does not try to be a full DCC package. It provides geometry and variations that can be examined, selected, and carried into further work: adding bevels, thickness, fasteners, lighting, and materials. Complex faceted bodies read well as technological objects — from small modules to large space structures.

If you develop the idea further, the cells can be combined: grouped in several, nested inside one another, cut, mirrored, and assembled into larger structures. Such a set of shapes is useful for game assets, concept art, and variant generation when you need to quickly obtain many dissimilar silhouettes.

Reflections, Grouping, and Displacement

Reflection and grouping are a simple way to get fantastic shapes from fairly strict geometry. A mirrored copy of a cell next to the original turns a single polyhedron into a symmetric module; several modules form a station, dock, or ship fragment. If you change the scale and orientation of the groups, the silhouette becomes more complex but retains its procedural logic.

Another path is displacement maps. If such a map is applied to the faces of a cell, flat panels become armor, hatches, engine blocks, and technical details. A simple convex body becomes a spaceship, station, or more complex structure. Here the generator acts as a shape supplier, while displacement and materials add scale and detail.

Accuracy and Limitations

The algorithm is exact but not infinitely fast: the number of boxes and checks grows with the number of sites, so large point sets require optimization. The demo is designed for interactive work with a small number of cells, which is enough to see the method and obtain interesting shapes.

If textures are close to your interests, see the article on procedural SciFi textures and the 3D preview of the texture generator. There, the same Voronoi idea works on a plane, while here it works in volume, already as full-fledged polygonal geometry.