0

I am currently in need of adding holes to a shape mesh that can be dynamically generated. The mesh is created from using mergeBufferGeometries on an array of ShapeGeometry. These shapes do have their curves defined by the scene's global coordinates. In consideration, we ignore the z axis as we have no offset on that.

I tried adding holes to the shape itself but it drastically hindered performance to the point it was unusable. With the coordinates of the holes in the world frame, I could just create a texture to add to the mesh as an alpha map to create holes. The issue is that it is based on the bounds of the mesh due to the default UV mapping. How could I change the mapping in such a way that it would be more like the mesh is a window looking into a static texture.

Also how would I then define the static texture to fit world coordinates. As my current setup with the default wrapping mode clamp doesnt stretch it to the edge:

          context.fillStyle = 'white';
          context.fillRect(0, 0, 100, 100);
          context.fillStyle = 'black';
          context.beginPath();
          context.arc(50, 50, 25, 0, Math.PI * 2);
          context.fill();
          const texture = new THREE.CanvasTexture(canvas);

Knowing the maximum possible dimensions of where my holes could be, is it possible to have the canvas coordinates to scale to where the holes are going to be?

0

Browse other questions tagged or ask your own question.