modeling/booleans

All shapes (primitives or the results of operations) can be passed to boolean functions to perform logical operations, e.g. remove a hole from a board. In all cases, the function returns the results, and never changes the original shapes.

Source:
Example
const { intersect, subtract, union } = require('@jscad/modeling').booleans

Methods

(static) intersect(…geometries) → {geom2|geom3}

Source:

Return a new geometry representing space in both the first geometry and all subsequent geometries. The given geometries should be of the same type, either geom2 or geom3.

Examples
let myshape = intersect(cube({size: [5,5,5]}), cube({size: [5,5,5], center: [5,5,5]}))
+-------+
|       |
|   A   |
|    +--+----+   =   +--+
+----+--+    |       +--+
     |   B   |
     |       |
     +-------+
Parameters:
Name Type Attributes Description
geometries Object <repeatable>

list of geometries

Returns:

a new geometry

Type
geom2 | geom3

(static) scission(…objects) → {Array}

Source:

Scission (divide) the given geometry into the component pieces.

Examples
let figure = require('./my.stl')
let pieces = scission(figure)
+-------+            +-------+
|       |            |       |
|   +---+            | A +---+
|   |    +---+   =   |   |    +---+
+---+    |   |       +---+    |   |
     +---+   |            +---+   |
     |       |            |    B  |
     +-------+            +-------+
Parameters:
Name Type Attributes Description
objects Object <repeatable>

list of geometries

Returns:

list of pieces from each geometry

Type
Array

(static) subtract(…geometries) → {geom2|geom3}

Source:

Return a new geometry representing space in the first geometry but not in all subsequent geometries. The given geometries should be of the same type, either geom2 or geom3.

Examples
let myshape = subtract(cuboid({size: [5,5,5]}), cuboid({size: [5,5,5], center: [5,5,5]}))
+-------+            +-------+
|       |            |       |
|   A   |            |       |
|    +--+----+   =   |    +--+
+----+--+    |       +----+
     |   B   |
     |       |
     +-------+
Parameters:
Name Type Attributes Description
geometries Object <repeatable>

list of geometries

Returns:

a new geometry

Type
geom2 | geom3

(static) union(…geometries) → {geom2|geom3}

Source:

Return a new geometry representing the total space in the given geometries. The given geometries should be of the same type, either geom2 or geom3.

Examples
let myshape = union(cube({size: [5,5,5]}), cube({size: [5,5,5], center: [5,5,5]}))
+-------+            +-------+
|       |            |       |
|   A   |            |       |
|    +--+----+   =   |       +----+
+----+--+    |       +----+       |
     |   B   |            |       |
     |       |            |       |
     +-------+            +-------+
Parameters:
Name Type Attributes Description
geometries Object <repeatable>

list of geometries

Returns:

a new geometry

Type
geom2 | geom3