modeling/extrusions

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.

Source:
Example
const { extrudeLinear, extrudeRectangular, extrudeRotate } = require('@jscad/modeling').extrusions

Methods

(static) extrudeFromSlices(options, base) → {geom3}

Source:
See:

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
Name Type Attributes Default Description
numberOfSlices Integer <optional>
2

the number of slices to be generated by the callback

capStart Boolean <optional>
true

the solid should have a cap at the start

capEnd Boolean <optional>
true

the solid should have a cap at the end

close Boolean <optional>
false

the solid should have a closing section between start and end

callback function <optional>

the callback function that generates each slice

base Object

the base object which is used to create slices (see the example for callback information)

Returns:

the extruded shape

Type
geom3

(static) extrudeLinear(options, …geometry) → {Object|Array}

Source:

Extrude the given geometry in an upward linear direction using the given options.

Example
let myshape = extrudeLinear({height: 10}, rectangle({size: [20, 25]}))
Parameters:
Name Type Attributes Description
options Object

options for extrude

Properties
Name Type Attributes Default Description
height Array <optional>
1

the height of the extrusion

twistAngle Number <optional>
0

the final rotation (RADIANS) about the origin of the shape (if any)

twistSteps Integer <optional>
1

the resolution of the twist about the axis (if any)

geometry Object <repeatable>

the list of geometry to extrude

Returns:

the extruded geometry, or a list of extruded geometry

Type
Object | Array

(static) extrudeRectangular(options, …geometry) → {Object|Array}

Source:
See:
  • expand for addition options

Extrude the given geometry by following the outline(s) with a rectangle.

Parameters:
Name Type Attributes Description
options Object

options for extrusion, if any

Properties
Name Type Attributes Default Description
size Number <optional>
1

size of the rectangle

height Number <optional>
1

height of the extrusion

geometry Object <repeatable>

the list of geometry to extrude

Returns:

the extruded object, or a list of extruded objects

Type
Object | Array

(static) extrudeRotate(options, geometry) → {geom3}

Source:

Rotate extrude the given geometry using the given options.

Parameters:
Name Type Description
options Object

options for extrusion

Properties
Name Type Attributes Default Description
angle Number <optional>
PI*2

angle of the extrusion (RADIANS)

startAngle Number <optional>
0

start angle of the extrusion (RADIANS)

overflow String <optional>
'cap'

what to do with points outside of bounds (+ / - x) : defaults to capping those points to 0 (only supported behaviour for now)

segments Number <optional>
12

number of segments of the extrusion

geometry geom2

the geometry to extrude

Returns:

the extruded geometry

Type
geom3

(static) project(options, …geometry) → {geom2|Array}

Source:

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
Name Type Attributes Default Description
axis Array <optional>
[0,0,1]

the axis of the plane (default is Z axis)

origin Array <optional>
[0,0,0]

the origin of the plane

geometry Object <repeatable>

the list of 3D geometry to project

Returns:

the projected 2D geometry, or a list of 2D projected geometry

Type
geom2 | Array