new CSG( [polygons])
Creates a new faceted solid ready for constructive solid geometry.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
polygons |
Array.<CSGPolygon> |
<optional> |
An optional array of polygon facets. |
Members
-
:boolean
isCSG <readonly>
-
A flag identifying this object as a CSG instance.
Type
- boolean
-
:Array.<CSGPolygon>
polygons
-
A list of connected polygons that define the boundary of a 3D shape.
Type
- Array.<CSGPolygon>
Methods
-
OLD_toBRepUnioned( [brep])
-
Copies the CSG data into the given boundary representation, trying to union together coplanar facets.
Parameters:
Name Type Argument Description brepPD.BRep <optional>
An optional boundary representation to store the result.
Returns:
Returns the given BRep or a newly created one.
- Type
- PD.BRep
-
addBRep(brep)
-
Adds faces from a
PD.BRepto this instance, converting polygonal faces directly to polygons..Parameters:
Name Type Description brepPD.BRep the boundary representation containing polygonal faces.
Returns:
Returns this CSG shape instance.
- Type
- PD.CSG
-
addBRepTriangles(brep)
-
Adds faces from a
PD.BRepto this instance, converting individual triangles in each face to polygons.Parameters:
Name Type Description brepPD.BRep The BRep containing the triangles.
Returns:
Returns a new CSG shape.
- Type
- PD.CSG
-
addShell(shell)
-
Add facets from a
PD.Shellto this instance, converting polygonal facets directly to polygons.Parameters:
Name Type Description shellPD.Shell The shell containing polygonal facets.
Returns:
Returns this CSG shape instance.
- Type
- PD.CSG
-
addShellTriangles(shell)
-
Add facets from a
PD.Shellto this instance, converting individual triangles in each face to polygons.Parameters:
Name Type Description shellPD.Shell the shell containing the triangles.
Returns:
Returns this CSG shape instance.
- Type
- PD.CSG
-
clone()
-
Creates a deep copy of this CSG shape.
Returns:
Returns the new cloned object.
- Type
- PD.CSG
-
intersect(csg)
-
Returns a new solid representing the space both this solid and in
csg.Neither this solid nor the solid
csgare modified.A.intersect(B) +-------+ | | | A | | +--+----+ = +--+ +----+--+ | +--+ | B | | | +-------+Parameters:
Name Type Description csgPD.CSG The CSG solid to union with this one.
Returns:
Returns the new unioned solid.
- Type
- PD.CSG
-
inverse()
-
Return a new solid with solid and empty space switched.
This solid is not modified.
Returns:
Returns the new unioned solid.
- Type
- PD.CSG
-
isEmpty()
-
Checks if this shape is empty (contains no polygons).
Returns:
Returns true if this shape contains no polygons.
- Type
- boolean
-
subtract(csg)
-
Returns a new solid representing the space in this solid but not in
csg.Neither this solid nor the solid
csgare modified.A.subtract(B) +-------+ +-------+ | | | | | A | | | | +--+----+ = | +--+ +----+--+ | +----+ | B | | | +-------+Parameters:
Name Type Description csgPD.CSG The CSG solid to union with this one.
Returns:
Returns the new unioned solid.
- Type
- PD.CSG
-
toBRep( [brep])
-
Copies the CSG data into the given boundary representation.
Parameters:
Name Type Argument Description brepPD.BRep <optional>
An optional boundary representation to store the result.
Returns:
Returns the given BRep or a newly created one.
- Type
- PD.BRep
-
toBRepUnioned( [brep])
-
Copies the CSG data into the given boundary representation, trying to union together coplanar facets.
Parameters:
Name Type Argument Description brepPD.BRep <optional>
An optional boundary representation to store the result.
Returns:
Returns the given BRep or a newly created one.
- Type
- PD.BRep
-
toPolygons()
-
Retrieves a list of all the polygons that make up this shape.
Returns:
Returns an array of bounding polygons.
- Type
- Array
-
toShell( [shell])
-
Copies the CSG data into the given shell.
Parameters:
Name Type Argument Description shellPD.Shell <optional>
An optional shell to store the resulting shape.
Returns:
Returns the given shell or a newly created one.
- Type
- PD.Shell
-
union(csg)
-
Returns a new solid representing the space in either this solid or
csg.Neither this solid nor the solid
csgare modified.A.union(B) +-------+ +-------+ | | | | | A | | | | +--+----+ = | +----+ +----+--+ | +----+ | | B | | | | | | | +-------+ +-------+Parameters:
Name Type Description csgPD.CSG The CSG solid to union with this one.
Returns:
Returns the new unioned solid.
- Type
- PD.CSG
-
bbox(corners, shared) <static>
-
Construct an axis-aligned solid rectangular prism.
Parameters are a list of 8 vertices in the order shown below. Each vertex is an [x,y,z] position array in model units.
+Z max | 7-----------6 | /| +Y /| |/ | / / | 4----/------5 | | |/ | | | 3--------|--2 | / | / |/ |/ 0-----------1-----+X minParameters:
Name Type Description cornersArray An array of 8 points defining the cube corners.
sharedobject An object to be shared by all faces, such as a color.
Returns:
Returns a new CSG shape.
- Type
- PD.CSG
-
cube( [options]) <static>
-
Constructs an axis-aligned solid cuboid.
Optional parameters are
centerandradius, which default to[0, 0, 0]and[1, 1, 1]. The radius can be specified using a single number or an array of three numbers, one for each axis.Parameters:
Name Type Argument Description optionsobject <optional>
An optional configuration object.
Properties of
options:Name Type Argument Description centerPD.CSG.Vector <optional>
The position of the center of the cube.
radiusnumber | Array <optional>
The size of the cube, as a single number or [x,y,z] array.
Returns:
Returns a new CSG shape.
- Type
- PD.CSG
Example
const cube = PD.CSG.cube({ center: [0, 0, 0], radius: 1 }); -
cylinder() <static>
-
Construct a solid cylinder.
Optional parameters are
start,end,radius, andslices, which default to[0, -1, 0],[0, 1, 0],1, and16. Theslicesparameter controls the tessellation.Returns:
Returns a new CSG shape.
- Type
- PD.CSG
Example
const cylinder = PD.CSG.cylinder({ start: [0, -1, 0], end: [0, 1, 0], radius: 1, slices: 16 }); -
extrudeClipPath(clipPath, vector [, botOffset] [, topOffset]) <static>
-
Construct an extruded CSG shape from a ClipperLib path.
Parameters:
Name Type Argument Description clipPathArray An array of ClipperLib {X,Y} points, or an array of such arrays.
vectorTHREE.Vector3 The normalised extrusion direction vector.
botOffsetnumber <optional>
An optional offset to apply to the bottom face along the extrusion vector, defaults to 0.
topOffsetnumber <optional>
An optional offset to apply to the top face along the extrusion vector, defaults to 0.
Returns:
Returns a new CSG shape, or null if the clip path is invalid.
- Type
- PD.CSG
-
extrudePolyline(polyline, vector [, botOffset] [, topOffset]) <static>
-
Construct an extruded CSG shape from a ClipperLib path.
Parameters:
Name Type Argument Description polylineArray An array of ClipperLib {X,Y} points, or an array of such arrays.
vectorTHREE.Vector3 The normalised extrusion direction vector.
botOffsetnumber <optional>
An optional offset to apply to the bottom face along the extrusion vector, defaults to 0.
topOffsetnumber <optional>
An optional offset to apply to the top face along the extrusion vector, defaults to 1000mm or 3' (36").
Returns:
Returns a new CSG shape, or null if the clip path is invalid.
- Type
- PD.CSG
-
fromBRep(brep) <static>
-
Construct a CSG solid from a
PD.BRepinstance converting polygonal faces to polygons.Parameters:
Name Type Description brepPD.BRep The BRep containing the polygon facets.
Returns:
Returns a new CSG shape.
- Type
- PD.CSG
-
fromBRepTriangles(brep) <static>
-
Construct a CSG solid from a
PD.BRepinstance converting individual triangles in each face to polygons.Parameters:
Name Type Description brepPD.BRep The BRep containing the triangles.
Returns:
Returns a new CSG shape.
- Type
- PD.CSG
-
fromPolygons(polygons) <static>
-
Construct a CSG solid from a list of
CSG.Polygoninstances.Parameters:
Name Type Description polygonsArray An array of connected bounding polygons.
Returns:
Returns a new CSG shape.
- Type
- PD.CSG
-
fromShell(shell) <static>
-
Construct a CSG solid from a
PD.Shellinstance, converting polygonal facets directly to polygons.Parameters:
Name Type Description shellPD.Shell the shell containing the polygon facets.
Returns:
Returns a new CSG shape.
- Type
- PD.CSG
-
fromShellTriangles(shell) <static>
-
Construct a CSG solid from a
PD.Shellinstance, converting individual triangles in each face to polygons.Parameters:
Name Type Description shellPD.Shell the shell containing the triangles.
Returns:
Returns a new CSG shape.
- Type
- PD.CSG
-
sphere() <static>
-
Construct a solid sphere.
Optional parameters are
center,radius,slices, andstacks, which default to[0, 0, 0],1,16, and8. Theslicesandstacksparameters control the tessellation along the longitude and latitude directions.Example
const sphere = PD.CSG.sphere({ center: [0, 0, 0], radius: 1, slices: 16, stacks: 8 });