I’m creating a cubby in a shelf such that I’d like to set different textures & lightmap for each of the faces inside the cubby. So there will be at least 4 texture+ lightmap pair for inside of the cubby and 1 texture + lightmap pair for rest of the faces.
Ahh…makes sense. I failed to notice that the CSG subtract function takes in to account the materials for each of the meshes.
For anyone of you who are interested - here’s the playground link which shows that if you subtract a green box from a red box, then the resulting material of the mesh is a combination of both.
So the trick here is to apply the required textures on the box that will be used to subtract and it will show up in the resulting mesh.
As you can see the inner cube has the material applied with the facenumbers. However, after subtracting this cube from the outer mesh, the material in the new mesh is not retained.
@carolhmj@labris does this mean there is no way to achieve my intended outcome?
I was hoping there was an API that would give me the inner cavity as 4 separate planes. I could then create a new plane of that same dimensions and position and overlay it on top of the 4 sides of the inner cavity (making the inner cavity texture transparent).
Is there:
API that would give me the inner cavity as 4 separate planes? Perhaps I can shoot a ray from the center and see the face where it intersects and somehow get a plane from it ?
Allow me to set only those planes transparent in the mesh (leaving all other facets intact)?
For 1, nope, the only thing you get is the complete CSG mesh but that has no idea of what objects were used to create it. For 2, you can set some parts on the mesh with different transparencies by using either an opacity texture, or multimaterials: Morph setPositions, setNormals | Babylon.js Playground (babylonjs.com)