Free Shapes

Free shapes let you define custom 2D profiles and turn them into 3D solids.

polygon

polygon(pts, height) — Extrudes a closed 2D polygon (XY plane) along Z.

// Triangle
const result = polygon([[0,0],[30,0],[15,25]], 5);
Parameter Description
pts Array of [x, y] points (auto-closed)
height Extrusion depth along Z

extrude

extrude(pts, height, options) — Like polygon() but with optional twist and scale.

// Twisted prism
const result = extrude([[0,0],[20,0],[20,20],[0,20]], 30, { twist: 45 });
Option Default Description
twist 0 Rotation in degrees over full height
scale 1 End cross-section scale factor

revolve

revolve(pts, segs, options) — Revolves a 2D profile around the Z axis to create a solid of revolution.

const pts = [
    [0, -10], [8, -10],
    [10, -5], [7,  5],
    [9,  10], [0, 10],
];
const result = revolve(pts, 64);
Parameter Default Description
pts Array of [radius, height] points (radius ≥ 0)
segs 64 Number of revolution segments
center true Center shape at Z=0

Set { center: false } to place the base at Z=0 — useful when stacking with .sub().

See the dedicated revolve() page for more examples.