Geometries
Low-level geometry types and constructors. Most users interact with these indirectly via jscad.primitives and jscad.booleans; direct access is useful for building custom geometry or inspecting polygon/point data. The path2 namespace provides a full API for constructing open 2D paths incrementally.
See also:
namespace path22D open path construction and manipulation.
A Path2 is an ordered sequence of [x, y] points forming an open (or closed) polyline. Paths can be built incrementally by appending points, arcs, or bezier curves, then passed to extrusion functions or used directly as 2D output. Key operations:
path2.create(points?)— create empty or seeded pathpath2.fromPoints(options, points)— create from point array;{ closed: true }closes the looppath2.appendPoints(points, path)— append raw pointspath2.appendArc(options, path)— append an SVG-style elliptical arcpath2.appendBezier(options, path)— append a cubic bezier curvepath2.close(path)— close an open pathpath2.concat(...paths)— join multiple paths into onepath2.toPoints(path)— extract all points as [[x,y], …]
const { path2 } = jscad.geometriesconst { extrudeLinear } = jscad.extrusionsasync function main() { let p = path2.create([[0,0]]) p = path2.appendArc({ endpoint: [10, 0], radius: [5, 5] }, p) p = path2.appendPoints([[10, 5], [0, 5]], p) p = path2.close(p) return extrudeLinear({ height: 3 }, p)}See also:
namespace geom22D solid geometry type and low-level operations.
A Geom2 represents a closed 2D solid as an ordered set of line segments (sides).
Most users work with Geom2 indirectly via jscad.primitives (circle, square, etc.)
and jscad.booleans. Direct geom2 manipulation is needed for custom geometry
construction or inspection.
Key operations: geom2.create, geom2.fromPoints, geom2.toPoints,
geom2.toSides, geom2.clone, geom2.isA, geom2.reverse.
const { geom2 } = jscad.geometriesconst g = geom2.fromPoints([[0,0],[5,0],[5,5],[0,5]])const pts = geom2.toPoints(g)See also:
namespace geom33D solid geometry type and low-level operations.
A Geom3 represents a closed 3D solid as a list of polygons. Most users work
with Geom3 indirectly via jscad.primitives and jscad.booleans. Direct
geom3 manipulation is needed for custom geometry construction or inspection.
Key operations: geom3.create, geom3.fromPolygons, geom3.toPolygons,
geom3.clone, geom3.isA, geom3.toPoints, geom3.isConvex.
const { geom3 } = jscad.geometriesconst { sphere } = jscad.primitivesconst s = sphere({ radius: 5 })const polys = geom3.toPolygons(s)javasculpt.log('polygon count:', polys.length)See also: