The edges of multiple meshes intersect, how to make auto close

const wallMeshGeometries = [];
      scanedResult.walls.forEach((wall, index) => {
        // 创建一个Matrix4对象并设置其元素值
        const wallMatrix = new THREE.Matrix4();
        wallMatrix.fromArray(wall.transform);

        // 创建一个BufferGeometry对象,例如一个简单的立方体
        const wallGeometry = new THREE.BoxGeometry(
          wall.dimensions[0] + 0.25,
          wall.dimensions[1],
          wall.dimensions[2] == 0 ? 0.25 : wall.dimensions[2]
          // wall.dimensions[2]
        );

        const material = new THREE.MeshBasicMaterial({
          color: 0x8d8e8c,
          side: THREE.DoubleSide,
          transparent: true, // 开启透明
          // opacity: 0.5, // 设置透明度,值在0到1之间,0表示完全透明,1表示完全不透明
        });

        // 创建一个Mesh对象,将几何结构和矩阵组合在一起
        const wallMesh = new THREE.Mesh(wallGeometry, material);
        wallMesh.geometry.applyMatrix4(wallMatrix);
        console.log(wallMesh);

        scene.add(wallMesh);

        wallMeshGeometries.push(new THREE.EdgesGeometry(wallMesh.geometry));

        // // 创建边框的几何体
        // const edges = new THREE.EdgesGeometry(wallMesh.geometry);
        // const lineMaterial = new THREE.LineBasicMaterial({ color: 0x000000 });
        // const wireframe = new THREE.LineSegments(edges, lineMaterial);
        // wireframe.applyMatrix4(wallMatrix);

        // // 将边框添加到场景
        // scene.add(wallMesh, wireframe);
      });

      if (wallMeshGeometries.length > 0) {
        // 合并几何体
        const edgesGeometry =
          BufferGeometryUtils.mergeGeometries(wallMeshGeometries, true);

        // 创建边框线段
        const edges = new THREE.LineSegments(
          edgesGeometry,
          new THREE.LineBasicMaterial({ color: 0x000000 })
        );

        // 将实体和边框添加到场景
        scene.add(edges);
      }

How to handle the edges to be as below picture2


picture1

Weixin Screenshot_20231125144307
picture2

You can use upward-extruded (docs) ShapeGeometry to create pretty walls.

Alternatively, you can just create pre-fabs for intersections, or hide the overlapping faces under another overlapping face because we’re all professionals here.

1 Like

smoke and mirrors.