ThreeCSG icon indicating copy to clipboard operation
ThreeCSG copied to clipboard

How to cut object at a particular position?

Open tarun29061990 opened this issue 10 years ago • 0 comments

Below is my code

var bBox = new THREE.Box3().setFromObject(doorMesh),
    cubeGeom = new THREE.BoxGeometry(bBox.size().x,bBox.size().y,bBox.size().z),
    cubeMesh = new THREE.Mesh(cubeGeometry,new THREE.MeshNormalMaterial),
    geom = new THREE.Geometry();

    cubeMesh.position.set(doorMesh.position.x,doorMesh.position.y,doorMesh.position.z);
    cubeMesh.updateMatrix();
    geom.merge(cubeMesh.geometry, cubeMesh.matrix);

    var cubeBsp = new ThreeBSP(geom),
          wallBsp = new ThreeBSP(wallMesh.geometry);

        var sub = wallBsp.subtract(cubeBsp);

I am doing the above steps but it's not working. However when I convert cubeGeometry to BSP instead of geom then it works but the cut is at the center of the object.

tarun29061990 avatar Aug 19 '15 12:08 tarun29061990