Pick multiple faces in one mesh

Hi Babylon.js community,

I have a problem and I’ve tried to find it over this forum but I can’t see any relevant answers, so I’d like to ask you for help.
I’m creating mesh using vertexdata and custom shader material.
I’ve also implemented some simple clipping algorithm in fragment shader (lines: 46 - 48)
Here is my simple playground:

But after I clip my mesh I’d like to be able to select visible faces (I added ray helper to visualize it). If I would have array of all crossed faces I could test it with clipping coordinates and select/highlight objects which are under the clipped part of mesh.

But … Now I can only get first face of clipped geometry.
Is it possible to get all faces id through ray?

Hey and welcome!!

Scene - Babylon.js Documentation will help you pick multiple meshes but not multiple faces

I feel like you could probably get inspired by the mesh.intersects code maybe to come with your own implementation:

Thanks @Deltakosh for the tip.

I took some code from subMesh._intersectTriangles and it works really nice. Below PG if somebody will be facing with the same problem:

I also added some code to combine pick & ray methods for my case:
First click on the mesh and after that rotate.

1 Like