Skip to content

Extrude 2D geometry into 3D solids, or project 3D geometry back to 2D. Supports linear extrusion with optional twist, rotational (lathe-style) extrusion, rectangular tube sweeps, and orthographic projection.

See also:

function extrudeLinear( options: { height?: number; twistAngle?: number; twistSteps?: number; center?: boolean }, geometry: Geom2 ): Geom3

Extrude a 2D geometry straight along the Z axis to produce a 3D solid.

Optionally twist the profile as it rises to produce helical shapes.

Parameters:

Name Type Description
options — Extrusion options.
options.height — Extrusion height along Z. Default 1.
options.twistAngle — Total twist angle in radians over the full height. Default 0.
options.twistSteps — Number of twist interpolation steps. Higher = smoother. Default 1.
options.center — If true, centre the solid on Z=0. Default false.
geometry — The 2D source geometry (Geom2).

Returns: A Geom3 solid.

const { star } = jscad.primitives
const { extrudeLinear } = jscad.extrusions
async function main() {
return extrudeLinear({ height: 10, twistAngle: Math.PI, twistSteps: 16 }, star({ outerRadius: 5 }))
}

See also:

function extrudeRotate( options: { angle?: number; startAngle?: number; segments?: number }, geometry: Geom2 ): Geom3

Revolve a 2D geometry around the Z axis to produce a 3D solid of revolution.

The 2D profile should lie in the XY plane on the positive-X side of Z.

Parameters:

Name Type Description
options — Rotation options.
options.angle — Total sweep angle in radians. Default 2π (full revolution).
options.startAngle — Starting angle in radians. Default 0.
options.segments — Segments in the sweep direction. Default 32.
geometry — The 2D profile to revolve (Geom2).

Returns: A Geom3 solid of revolution.

const { polygon } = jscad.primitives
const { extrudeRotate } = jscad.extrusions
async function main() {
const profile = polygon({ points: [[2,0],[4,0],[4,3],[3,3],[2,1]] })
return extrudeRotate({ segments: 48 }, profile)
}

See also:

function extrudeRectangular( options: { size?: number; height?: number; corners?: 'edge' | 'chamfer' | 'round'; segments?: number }, geometry: Geom2 | Path2 ): Geom3

Extrude a 2D geometry or open path along a rectangular cross-section.

Creates a solid by sweeping the input outline along a rectangular tube path. Useful for giving a flat 2D shape a uniform wall thickness.

Parameters:

Name Type Description
options — Rectangular extrusion options.
options.size — Wall thickness. Default 1.
options.height — Extrusion height along Z. Default 1.
options.corners — Corner style: ‘edge’, ‘chamfer’, or ‘round’. Default ‘edge’.
options.segments — Segments per rounded corner. Default 16.
geometry — The 2D source geometry (Geom2 or Path2).

Returns: A Geom3 solid.

const { circle } = jscad.primitives
const { extrudeRectangular } = jscad.extrusions
async function main() {
return extrudeRectangular({ size: 0.5, height: 5 }, circle({ radius: 8 }))
}

See also:

function project( options: { axis?: Vec3; origin?: Vec3 }, geometry: Geom3 ): Geom2

Project a 3D solid onto a 2D plane, producing a flat Geom2 silhouette.

The projection is along the specified axis from the given origin. Useful for creating flat outlines or shadow shapes from 3D geometry.

Parameters:

Name Type Description
options — Projection options.
options.axis — Projection direction vector. Default [0, 0, 1] (project down Z).
options.origin — Origin point of the projection axis. Default [0, 0, 0].
geometry — The Geom3 solid to project.

Returns: A Geom2 silhouette.

const { sphere } = jscad.primitives
const { project } = jscad.extrusions
async function main() {
const shadow = project({ axis: [0, 0, 1] }, sphere({ radius: 5 }))
return shadow
}

See also: