new CSG()
Class CSG
Holds a binary space partition tree representing a 3D solid. Two solids can
be combined using the `union()`, `subtract()`, and `intersect()` methods.
Classes
Members
(static) angleEPS
Epsilon used during determination of near zero areas.
(static) areaEPS
Epsilon used during determination of near zero areas.
This is the minimal area of a minimal polygon.
(static) defaultResolution2D
Number of polygons per 360 degree revolution for 2D objects.
(static) defaultResolution3D
Number of polygons per 360 degree revolution for 3D objects.
(static) EPS
Epsilon used during determination of near zero distances.
Methods
(static) cube(optionsopt) → {CSG}
Construct an axis-aligned solid cuboid.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
options for construction
Properties
|
Returns:
new 3D solid
- Type
- CSG
Example
var cube = CSG.cube({
center: [5, 5, 5],
radius: 5, // scalar radius
});
(static) cylinder(optionsopt) → {CSG}
Construct a solid cylinder.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
options for construction
Properties
|
Returns:
new 3D solid
- Type
- CSG
Example
var cylinder = CSG.cylinder({
start: [0, -10, 0],
end: [0, 10, 0],
radius: 10,
resolution: 16
});
(static) cylinderElliptic(optionsopt) → {CSG}
Construct an elliptic cylinder.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
options for construction
Properties
|
Returns:
new 3D solid
- Type
- CSG
Example
var cylinder = CSG.cylinderElliptic({
start: [0, -10, 0],
end: [0, 10, 0],
radiusStart: [10,5],
radiusEnd: [8,3],
resolution: 16
});
(static) fromCompactBinary(bin) → {CSG}
Reconstruct a CSG from the output of toCompactBinary().
Parameters:
Name | Type | Description |
---|---|---|
bin |
CompactBinary | see toCompactBinary(). |
Returns:
new CSG object
- Type
- CSG
(static) fromObject(obj) → {CSG}
Reconstruct a CSG solid from an object with identical property names.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | anonymous object, typically from JSON |
Returns:
new CSG object
- Type
- CSG
(static) fromPolygons(polygons) → {CSG}
Construct a CSG solid from a list of `CSG.Polygon` instances.
Parameters:
Name | Type | Description |
---|---|---|
polygons |
Array.<CSG.Polygon> | list of polygons |
Returns:
new CSG object
- Type
- CSG
(static) fromSlices(options) → {CSG}
Construct a CSG solid from a list of pre-generated slices.
See CSG.Polygon.prototype.solidFromSlices() for details.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | options passed to solidFromSlices() |
Returns:
new CSG object
- Type
- CSG
(static) polyhedron(optionsopt) → {CSG}
Create a polyhedron using Openscad style arguments.
Define face vertices clockwise looking from outside.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
options for construction |
Returns:
new 3D solid
- Type
- CSG
(static) roundedCube(optionsopt) → {CSG}
Construct an axis-aligned solid rounded cuboid.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
options for construction
Properties
|
Returns:
new 3D solid
- Type
- CSG
Example
var cube = CSG.roundedCube({
center: [2, 0, 2],
radius: 15,
roundradius: 2,
resolution: 36,
});
(static) roundedCylinder(optionsopt) → {CSG}
Construct a cylinder with rounded ends.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
options for construction
Properties
|
Returns:
new 3D solid
- Type
- CSG
Example
var cylinder = CSG.roundedCylinder({
start: [0, -10, 0],
end: [0, 10, 0],
radius: 2,
resolution: 16
});
(static) sphere(optionsopt) → {CSG}
Construct a solid sphere
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
options for construction
Properties
|
Returns:
new 3D solid
- Type
- CSG
Example
var sphere = CSG.sphere({
center: [0, 0, 0],
radius: 2,
resolution: 32,
});
toPolygons() → {Array.<CSG.Polygon>}
Returns:
The list of polygons.
- Type
- Array.<CSG.Polygon>