Project

Paraplot

A parametric CAD toy that runs in the browser: a pure JavaScript DSL builds signed-distance scenes — groups, set operations, splines and lofted surfaces — and a WebGL2 raymarcher renders them with live parameter controls.

ReactTypeScriptWebGL2GLSLMonacoOffscreenCanvas

Paraplot is a small parametric CAD / SDF modeller that runs entirely in the browser. A scene is a pure JavaScript function: parameters go in, a scene graph comes out, and a WebGL2 raymarcher turns the resulting signed-distance field into pixels.

There are no meshes, no kernel, and no server. Everything — modelling, compilation, rendering and persistence — happens in the tab.

A parametric handle bracket: rounded box, smooth unions, splines and drilled holes

Scene as code

A scene declares its controls and a build function. Parameters become sliders, toggles and colour pickers in the dock; build is pure, so the shape is a direct function of the current parameter values.

export const params = {
  span:   num(2.4, { min: 1.2, max: 4, step: 0.01 }),
  holes:  int(4, { min: 1, max: 8 }),
  finish: color('#c3ccd6'),
};
 
export default function build(k) {
  const plate = translate([0, 0.07, 0],
    paint(box({ s: [k.span / 2, 0.07, 0.5], round: 0.03 }), k.finish));
 
  const rail = spline({ name: 'rail', points: [[-1, 0.1, 0], [0, 1.4, 0], [1, 0.1, 0]], r: 0.05 });
 
  const holes = range(k.holes).map((i) =>
    translate([lerp(-1, 1, i / Math.max(1, k.holes - 1)), 0.07, 0],
      cylinder({ r: 0.07, h: 1 })));
 
  return subtract(smoothUnion(0.05, plate, rail), ...holes);
}

Because the model is code, it composes like code: loops, helper functions and shared sub-expressions all work, and a named spline can be reused under several transforms — the compiler emits it once and instances it.

Geometry

  • Primitives and set operations — union, intersection and subtraction, with optional smooth blending.
  • Groups and transforms — local coordinate systems with translate / rotate / scale, shown as a tree in the component panel.
  • Implicit expressions — custom surfaces from equations, evaluated in the shader, including animated ones driven by the clock.
  • Splines — 3D tube paths, extruded profiles and lathe profiles, edited with a live 3D point editor.
  • Ruled surfaces — loft a solid between two editable splines; the ruling interpolation is GLSL that runs on the GPU.

Impeller with lofted blades — ruled surfaces between a root and a tip spline

Spline references are resolved after overrides and after every clock tick, so moving a curve reshapes everything anchored to it — capsules, transformed parts and lofted blades — without recompiling the shader.

Rendering

The renderer is a single fullscreen triangle and one fragment shader. The scene graph compiles to small GLSL functions returning vec2(distance, material); transforms push the query point into local space, set operations combine distances while carrying the material, and all geometry values share one uniform pool so the shader text only changes when the tree shape changes.

The GL context lives in a Web Worker on an OffscreenCanvas, and the viewport renders on demand: a static scene stops the rAF loop and costs no GPU work at all. Interactive frames are drafted and refined, so dragging a slider stays responsive.

Gyroid lattice from a single implicit equation

Inspecting a model

The component tree lists every node with two actions: hide (skip a subtree — hiding a cutter simply stops cutting) and solo (render one component in place by keeping its ancestors' transforms). The viewport shows the active filter as a chip that clears it in one click.

For shape quality there is a smoothness analysis: normals, mean curvature, gradient and zebra shading, plus curvature combs on splines. The generated shader.glsl is available in a tab next to the editor, along with node and uniform counts.

Try it

The live app is at nikhedonia.net/paraplot. It opens on a project browser with six pre-rendered examples — a handle bracket, a lathe vessel, a gyroid lattice, an orbital rig, a wagging dog and an impeller. Opening one creates a fresh copy, and every project is auto-saved to IndexedDB, so edits survive a reload.

Read the design note: Paraplot: From Scene Code to a Draw Call.