|
|
|
|
|
by gorb314
2806 days ago
|
|
Constructive Solid Geometry using BSP trees. There is a javascript implementation [0] which is where I saw it the first time, it is about 500 lines of fully commented code. The algorithm is so simple, I absolutely love it. Basically, when performing a union on two meshes, we determine the 3d BSP trees from both meshes, then simply clip each mesh using the other's tree. The output is the union of the two leftover meshes. And since both intersection and difference can be written as a combination of inversion and union, they are simply composed from those. I can't find a good paper on the algorithm though, not sure where exactly it originated. [0] https://github.com/evanw/csg.js/blob/master/csg.js |
|
https://github.com/birkir/csg.js/blob/patch-1/csg.ts