chandlerprall / ThreeCSG

CSG plugin for Three.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Holes after CSG subtract operation

isaachadad opened this issue · comments

I have been using CSG for geometry manipulation and it's awesome.
However, it seems there is a problem with the polygon splitting and there are missing/wrong polygons.
I have checked it with latest threeCSG.js and three.js
Also used all previously mentioned suggestions including changing EPSILON.
I have checked it with netfabb.
Here's the original and the fixed geometry pictures:

csg_problem
csg_fixed

Here is a very simple code:
var boxG = new THREE.BoxGeometry(100, 100, 100, 1, 1, 1);
boxG.verticesNeedUpdate = true;
boxG.computeVertexNormals();
boxG.computeFaceNormals();
boxG.normalsNeedUpdate = true;
var holeG = new THREE.BoxGeometry(50, 50, 50, 1, 1, 1);
var holeM = new THREE.Mesh(holeG);
holeM.position.z = 50;
var holeG = new THREE.Geometry();
THREE.GeometryUtils.merge(holeG, holeM);
holeG.verticesNeedUpdate = true;
holeG.computeVertexNormals();
holeG.computeFaceNormals();
holeG.normalsNeedUpdate = true;
var boxBsp = new ThreeBSP(boxG);
var holeBsp = new ThreeBSP(holeG);
boxBsp = boxBsp.subtract(holeBsp);
var boxG = boxBsp.toGeometry();

Is this familiar and planed to be fixed?

As you can see there are vertices that belong to one plane but not to another, which is regarded as holes and cannot be 3D printed (without fixing tools).
Can you please confirm if the problem is in the original CSG algorithm or the porting to three.js?
Thanks.

I am having a similar problem, with a union on different set of models (a complex 2d drawing extruded up plus a box)

Did you ever find a solution to this?