revolve() — Revolution

revolve

revolve(pts, segs=64, options) — Creates a 3D solid by revolving a 2D profile around the Z axis.

Syntax

revolve(pts, segs = 64, { center = true } = {})
Parameter Description
pts Array of [x, y] points — x = radius (≥ 0), y = height
segs Number of segments (smoothness)
center If true (default), centers the shape at Z=0

Examples

Vase

const pts = [
    [0, -10], [8, -10],
    [10, -5], [7, 5],
    [9, 10],  [0, 10],
];
const result = revolve(pts, 64);

Cylinder (manual)

const pts = [[0, -5], [8, -5], [8, 5], [0, 5]];
const result = revolve(pts);  // centered at origin

Wine glass

const pts = [
    [0, -15], [5, -15],
    [5, -14], [1.5, -5],
    [8, 5],   [8, 6],
    [1, 6],   [1, 15],
    [5, 15],  [5, 16],
    [0, 16],
];
const result = revolve(pts, 128);

Base at Z=0

If you need the base to sit on Z=0 (e.g. for stacking with sub()):

const result = revolve(pts, 64, { center: false });