meta data for this page
  •  

This is an old revision of the document!


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 documentation
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 documentation
const mypath = line([ [10, 10], [-10, 10] ]) API documentation
const myshape = polygon({ points: [ [10, 11], [0, 11], [5, 20] ], paths: [0, 1, 2]}) API documentation
const myshape = rectangle({center: [6.5, 6.5], size: [10, 20]}) API documentation
const myshape = roundedRectangle({center: [6.5, 6.5], size: [10, 20], roundRadius: 2, segments: 64}) API documentation
const myshape = square({center: [6.5, 6.5], size: 10}) API documentation
const myshape = star({vertices: 8, outerRadius: 10}) /* star with 8/2 density */ API documentation
const myshape = star({vertices: 12, outerRadius: 40, innerRadius: 20}) /* star with given radius */ API documentation

3D Primitives

Primitive Notes
const myshape = cube({center: [6.5, 6.5, 6.5], size: 7}) API documentation
const myshape = cuboid({center: [6.5, 6.5, 6.5], size: [3, 5, 7]}) API documentation
const myshape = cylinder({center: [-5, -5, -5], height: 10, radius: 4, segments: 5}) API documentation
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 documentation
const myshape = ellipsoid({center: [-5, -5, -5], radius: [4, 6, 8], segments: 64}) API documentation