Configuration for the extrusion.
Optionalcaps?: booleanWhether to fill the start/end with the cross-section.
Only applied when closedShape && !closedPath.
OptionalclosedPath?: booleanWhether the path closes into a loop.
OptionalclosedShape?: booleanWhether the cross-section is a closed loop.
Centreline, flat [x0, y0, z0, x1, y1, z1, ...].
Must contain at least 2 vertices (length ≥ 6, multiple of 3).
Cross-section polygon, flat [x0, y0, x1, y1, ...].
Must contain at least 3 vertices (length ≥ 6, even).
Geometry arrays for the extrusion, or an error.
Sweep a 2D polygon cross-section along a 3D centreline path, producing extruded geometry.
Useful for beams, mouldings, conduit, gutters, parapets, stair stringers — anything with a constant cross-section along a curve.
The cross-section lies in the plane perpendicular to the path's tangent at each path vertex. The local frame
(N, B)is computed via parallel transport along the path so the cross-section doesn't twist between vertices.Conventions
shapeis a flat array[x0, y0, x1, y1, ...]defining the cross-section in its local plane. List vertices CCW (viewed from+T) so face normals point outward. For closed shapes the last vertex implicitly connects back to the first — don't repeat the first vertex.pathis a flat array[x0, y0, z0, x1, y1, z1, ...]defining the 3D centreline.closedShape(defaulttrue) controls whether the cross-section closes into a loop. Open shapes produce a swept strip and never get caps.closedPath(defaultfalse) controls whether the path itself closes into a loop. Closed paths skip caps.caps(defaulttrue) fills the start and end with the cross-section polygon when bothclosedShapeistrueandclosedPathisfalse. The cap triangulation is a simple fan from vertex 0; convex shapes work, non-convex shapes produce overlapping triangles and should not be capped via this builder.Sharp corners on the path bevel the cross-section (the per-vertex tangent averages the incoming and outgoing edge directions); for cleaner mitres pre-process the path to insert duplicated vertices at the corners with the desired offset.
Usage