All 2D shapes (primitives or the results of operations) can be extruded in various ways. In all cases, the function returns the results, and never changes the original shapes.
Example
const { extrudeLinear, extrudeRectangular, extrudeRotate } = require('@jscad/modeling').extrusions
Methods
(static) extrudeFromSlices(options, base) → {geom3}
Extrude a solid from the slices as returned by the callback function.
Example
// Parameters:
// progress : the percent complete [0..1]
// index : the index of the current slice [0..numberOfSlices - 1]
// base : the base object as given
// Return Value:
// slice or null (to skip)
const callback = (progress, index, base) => {
...
return slice
}
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options for extrude Properties
|
|||||||||||||||||||||||||||||||||||
base |
Object | the base object which is used to create slices (see the example for callback information) |
Returns:
the extruded shape
- Type
- geom3
(static) extrudeHelical(options, geometry) → {geom3}
Perform a helical extrude of the geometry, using the given options.
Example
const myshape = extrudeHelical(
{
angle: Math.PI * 4,
pitch: 10,
segmentsPerRotation: 64
},
circle({size: 3, center: [10, 0]})
)
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options for extrusion Properties
|
|||||||||||||||||||||||||||||||||||
geometry |
geom2 | the geometry to extrude |
Returns:
the extruded geometry
- Type
- geom3
(static) extrudeLinear(options, …objects) → {Object|Array}
Extrude the given geometry in an upward linear direction using the given options. Accepts path2 or geom2 objects as input. Paths must be closed.
Example
let myshape = extrudeLinear({height: 10}, rectangle({size: [20, 25]}))
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options for extrude Properties
|
|||||||||||||||||||||
objects |
Object |
<repeatable> |
the geometries to extrude |
Returns:
the extruded geometry, or a list of extruded geometry
- Type
- Object | Array
(static) extrudeRectangular(options, …objects) → {Object|Array}
- Source:
- See:
-
- expand for addition options
Extrude the given geometry by following the outline(s) with a rectangle.
Example
let mywalls = extrudeRectangular({size: 1, height: 3}, square({size: 20}))
let mywalls = extrudeRectangular({size: 1, height: 300, twistAngle: TAU / 2}, square({size: 20}))
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options for extrusion, if any Properties
|
||||||||||||||||
objects |
Object |
<repeatable> |
the geometries to extrude |
Returns:
the extruded object, or a list of extruded objects
- Type
- Object | Array
(static) extrudeRotate(options, geometry) → {geom3}
Rotate extrude the given geometry using the given options.
Example
const myshape = extrudeRotate({segments: 8, angle: TAU / 2}, circle({size: 3, center: [4, 0]}))
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options for extrusion Properties
|
|||||||||||||||||||||||||
geometry |
geom2 | the geometry to extrude |
Returns:
the extruded geometry
- Type
- geom3
(static) project(options, …objects) → {geom2|Array}
Project the given 3D geometry on to the given plane.
Example
let myshape = project({}, sphere({radius: 20, segments: 5}))
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options for project Properties
|
||||||||||||||||
objects |
Object |
<repeatable> |
the list of 3D geometry to project |
Returns:
the projected 2D geometry, or a list of 2D projected geometry
- Type
- geom2 | Array