The 3-D scene engine

Every 3-D picture on this site — the transformer walkthrough, tensor stacks, data flowing up through layers — is drawn by one small module, scene3d.js. Scenes are data with swappable renderers: crisp isometric SVG by default (no library, works offline, every shape a real inspectable element), plus a hand-rolled WebGL orbit renderer (scene3d-webgl.js, still zero-dependency) you can switch to below and drag freely. Same scene data drives both — that's the whole architecture.

isometric SVGscene = data WebGL orbitzero deps · offline

Data in, depth out

You don't draw polygons. You hand the engine a list of typed primitives — slabs (tensor blocks), grids (matrix faces), flows (data arrows), labels — each with 3-D coordinates. The engine projects them to an isometric view, sorts them back-to-front (painter's algorithm), and emits SVG. Below: the exact data on the left, the render it produces on the right. Edit-in-your-head — change a number in the data, and the box moves.

Scene spec → render


      
renderer: SVG isometric
spin the whole scene about the vertical axis — the projection re-sorts every face
how steep the "camera" looks down — low = flatter, high = more top-down

Drag the sliders — the same scene data, re-projected. The engine re-computes depth order every frame so faces never draw in the wrong order.

The primitives

Four building blocks compose everything. A slab is a shaded box (top face lightest, sides darker — that shading is the whole "3-D" illusion). A stack is a slab repeated along an axis — perfect for transformer layers or a batch. A grid is a matrix face whose cells are coloured by value (reusing the same blue→white→green scale as the rest of the site) — for attention maps and activations. A flow is an arrow between two 3-D points — data moving through the network. Drive them:

Compose a network diagram from primitives

Press an experiment above the previous panel, or watch the stack build below.

Why this design (and the promise, kept)

The scene data is deliberately separate from the renderer. The default is isometric SVG — dependency-free, works offline forever (SVG is a 20-year-stable standard), crisp native text on every tensor. When this page first shipped, it promised that a second renderer "could be added later" consuming the exact same data — and that's now real: scene3d-webgl.js is a hand-rolled, still-zero-dependency WebGL orbit renderer (drag to fly around, wheel to zoom, labels stay crisp as a DOM overlay). Flip the toggle in the first panel: not one scene was rewritten. The durable asset is the scene description, not the pixels.

That's also what makes it a toolkit for future content: any technical idea that's really "boxes and flows" — an architecture from a paper, a pipeline, a data structure — can be expressed as a scene and dropped onto the site as a new page, without hand-drawing a single polygon. The 📄 Illustrated Papers collection is exactly that, generated from declarative storyboards.

⚠️ Notes & limits: this is a teaching diagram with depth, not a free-flying 3-D world — parallel lines stay parallel (isometric), and rotation is meant for modest angles (~10–70°), not full orbit · painter's-algorithm depth sorting is exact for stacked/adjacent blocks (what we draw) but can glitch on deeply interpenetrating geometry · hundreds of primitives are smooth; thousands would strain the DOM — use a `grid`'s per-cell colouring rather than thousands of tiny slabs.
Takeaways: a scene is a list of typed primitives (slab / stack / grid / flow / label) with 3-D coordinates · the engine projects + depth-sorts + emits SVG · shading (light top, dark sides) carries the 3-D read · data is decoupled from renderer, so the content outlives any one way of drawing it. Next, see it carry real weight: the LLM internals walkthrough.