===== Anatomy of a Design =====
A JSCAD design (script) must have at least one function defined, the **main()** function, which must to return a shape.
const { sphere } = require('@jscad/modeling').primitives
const main = () => {
return sphere() // a single shape
}
module.exports = { main }
Or an array of shapes.
const { cube, cylinder, sphere } = require('@jscad/modeling').primitives
const main () => {
const a = cube()
const b = sphere()
const c = cylinder()
return [a,b,c] // an array of shapes
}
module.exports = { main }
In addition, functions can be created to split the design into managable pieces, i.e. parts, etc.
const { cube, sphere } = require('@jscad/modeling').primitives
const partA = (options) => { // called from main() below
var shapes = []
shapes.push( sphere() )
shapes.push( cube(options) )
return shapes
}
const main = () => {
let list = partA({radius: 10})
return list
}
module.exports = { main }
{{page>design_guide_parameters}}
{{page>design_guide_projects}}
{{page>quick_reference_parameters}}