ExtrudeGeometry can't be correctlly processed by csg
magicmayu opened this issue · 1 comments
magicmayu commented
const path = new THREE.Path()
path.add(new THREE.LineCurve3(new THREE.Vector3(0, 0, 0), new THREE.Vector3(200, 0, 350)))
const shape = new THREE.Shape();
shape.moveTo(-50, 50);
shape.lineTo(-50, -50);
shape.lineTo(50, -50);
shape.lineTo(50, 50);
shape.lineTo(-50, 50);
const shape2 = new THREE.Shape();
shape2.moveTo(-55, 55);
shape2.lineTo(-55, -55);
shape2.lineTo(55, -55);
shape2.lineTo(55, 55);
shape2.lineTo(-55, 55);
const extrudeSettings = {
depth: 100,
extrudePath: path,
}
const geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings);
const geometry2 = new THREE.ExtrudeGeometry(shape2, extrudeSettings);
const csg1 = ThreeCSG.fromGeometry(geometry);
const csg2 = ThreeCSG.fromGeometry(geometry2);
const csg = csg2.subtract(csg1);
const material = new THREE.MeshPhongMaterial({
color: 0x999999,
});
const mesh = new THREE.Mesh(ThreeCSG.toGeometry(csg), material);
scene.add(mesh)
I want to use extrudeGeometry and ThreeCSG to make tunnel. So I made two shape, one is bigger than the other. And I extrude them with a single path. After that i subtract the smaller geometry from the bigger one.
But the result is not correct.
If i change end vector of the paht to (200, 0 ,300),the result is ok.
I don't know what happend.
manthrax commented
Yeah this looks like a numerical precision problem. To get reliable results you'll have to ensure that the 2 objects overlap with a small margin, and avoid faces in one model laying flat on faces of the other.
Sounds like you figured that out. :)
Thanks for reporting though.. let me know if there's other problems.