Introduction
Constructive Solid Geometry (CSG) is a modeling technique that uses Boolean operations like union and intersection to combine 3D solids. This library implements CSG operations on meshes elegantly and concisely using BSP trees, and is meant to serve as an easily understandable implementation of the algorithm. All edge cases involving overlapping coplanar polygons in both solids are correctly handled. we’ll have to start using a technique called CSG.
Example usage: Here is the code that we will use:
var cube
=
CSG.cube();
var sphere
=
CSG.sphere(
{ radius: 1.3 });
var polygons
=
cube.subtract(
sphere ).toPolygons();
Operations
This library provides three CSG operations: union, subtract, and intersect. The operations are rendered below using lightgl.js and can be rotated by dragging the mouse if your browser supports WebGL.
var cube = CSG.cube({ center: [-0.25, -0.25, -0.25] });
|
var sphere = CSG.sphere({ radius: 1.3, center: [0.25, 0.25, 0.25] });
|
---|---|
a.union(b);
|
a.subtract(b);
|
More example usage: Identify the correct boolean operations