meta data for this page

Primitive Shapes

The 'primitives' are accessed through the modeling API using the following:

const { cube, ellipse, star } = require('@jscad/modeling').primitives

2D Primitives

Primitive Notes
const mypath = arc({center: [2, 2], radius: 2, startAngle: Math.PI, endAngle: Math.PI * 2, segments: 64}) API
const myshape = circle({center: [6.5, 6.5], radius: 3.5, startAngle: Math.PI / 2, endAngle: Math.PI, segments: 64}) User Guide API
const myshape = ellipse({center: [6.5, 6.5], radius: [7, 9], startAngle: Math.PI / 2, endAngle: Math.PI, segments: 64}) API
const mypath = line([ [10, 10], [-10, 10] ]) API
const myshape = polygon({ points: [ [10, 11], [0, 11], [5, 20] ], paths: [0, 1, 2]}) API
const myshape = rectangle({center: [6.5, 6.5], size: [10, 20]}) API
const myshape = roundedRectangle({center: [6.5, 6.5], size: [10, 20], roundRadius: 2, segments: 64}) API
const myshape = square({center: [6.5, 6.5], size: 10}) API
const myshape = star({vertices: 8, outerRadius: 10}) /* star with 8/2 density */ API
const myshape = star({vertices: 12, outerRadius: 40, innerRadius: 20}) /* star with given radius */ API

3D Primitives

Primitive Notes
const myshape = cube({center: [6.5, 6.5, 6.5], size: 7}) API
const myshape = cuboid({center: [6.5, 6.5, 6.5], size: [3, 5, 7]}) API
const myshape = cylinder({center: [-5, -5, -5], height: 10, radius: 4, segments: 5}) API
const myshape = cylinderElliptic({center: [-5, -5, -5], height: 10, startRadius: [1, 2], endRadius: [2, 1], startAngle: Math.PI / 2, endAngle: Math.PI * 2 * 0.75, segments: 5}) API
const myshape = ellipsoid({center: [-5, -5, -5], radius: [4, 6, 8], segments: 64}) API
const myshape = geodesicSphere({radius: 15, frequency: 18}) API
const myshape = polyhedron({points: mypoints, faces: myfaces, orientation: 'inward'}) API
const myshape = roundedCuboid({center: [-5, -5, -5], size: [10, 20, 10], roundRadius: 2, segments: 16}) API
const myshape = roundedCylinder({center: [-5, -5, -5], height: 10, radius: 2, roundRadius: 0.5, segments: 16}) API
const myshape = sphere({center: [-5, -5, -5], radius: 5, }) API
const myshape = torus({innerRadius: 10, outerRadius: 100, innerSegments: 32, outerSegments: 8, innerRotation: Math.PI, startAngle: Math.PI}) API