Change cube position three-bvh-csg scene

I got a three-bvh-csg that contains a cube as an operation, I want that operation mesh to be updates using the gui, current code that I am trying to run:

const loader = new GLTFLoader();

  const dracoLoader = new DRACOLoader();
  dracoLoader.setDecoderPath("/examples/jsm/libs/draco/");
  loader.setDRACOLoader(dracoLoader);

  loader.load(
    "https://cdn.glitch.me/dc99a522-a347-4f3e-a04f-210e55dccd91/Tall%20Base%201.glb?v=1709712049776c",
    function (gltf) {
      result = gltf.scene.children[0];

      let resultMaterial = new THREE.MeshPhongMaterial({
        specular: 0x111111,
        shininess: 5,
        side: THREE.DoubleSide,
        alphaToCoverage: true,
        stencilWrite: true,
        stencilRef: 0,
        vertexColors: true,
      });

      result.material = resultMaterial.clone();

      meshBrush = new tbc.Operation(result.geometry, resultMaterial);
      {
        inside = new tbc.Operation(
          new THREE.BoxGeometry(10, 10, 10),
          resultMaterial
        );
        meshBrush.add(inside);
        inside.operation = tbc.ADDITION;
      }

      mesh = csgEvaluator.evaluateHierarchy(meshBrush);
      {
        const colorArray = new Uint8Array(
          mesh.geometry.attributes.position.count * 3
        );
        colorArray.fill(255);
        const colorAttr = new THREE.BufferAttribute(colorArray, 3, true);
        colorAttr.setUsage(THREE.DynamicDrawUsage);
        mesh.geometry.setAttribute("color", colorAttr);

        mesh.geometry.boundsTree = mesh.geometry.computeBoundsTree();

        //Center the model
        mesh.scale.set(1, 1, 1);
        let bounds = new THREE.Box3();
        bounds.setFromObject(mesh);
        mesh.position.sub(bounds.getCenter(new THREE.Vector3()));
        mesh.updateMatrixWorld(true);
        //Scale model to 100

        bounds = new THREE.Box3().setFromObject(mesh);
        let size = bounds.getSize(new THREE.Vector3());
        let { max } = Math;
        let maxsz = max(size.x, max(size.y, size.z));
        mesh.scale.multiplyScalar(1 / maxsz);
        mesh.needsAutoUpdate = true;
        bounds.setFromObject(mesh);
        mesh.position.sub(bounds.getCenter(new THREE.Vector3()));
      }
      mesh.material = result.material.clone();
      mesh.geometry.computeBoundingBox();
      scene.add(point);
      point.add(mesh);
    }
  );

Here I want to change the position of the inside mesh from the gui I have tried using inside.position.set but no results from that too.

See this example - after you update the meshes participating in CSG calculations, you’ll need to update the CSG evaluation.

1 Like

The issue in this is that the Brush is accessible as a separate geometry but Operation is not getting updated that easily, though I have tried your example and it still doesn’t work maybe I am doing something wrong, if you can a little explanation can do.

BTW thanks for the help