How can I optimise selecting vertices? i.e. scene.pick()

I have a scene where I am using the mouse to select faces on a mesh.

I drag the mouse which creates a box then I loop over all of the positions in that box.

I then call - scene.pick(xPos, yPos);

from that I can highlight the the faces and get there Id’s to do modifications on them etc.

Please see below.


The problem is this works fine when the box is 50*50 but the bigger the box the longer it takes (can lock the browser on high pixel screens)

Does anyone have any idea how I could optimise this?

Current ideas are
- Spacing each picked point (not as accurate though)
- Using webworkers

I’m wondering how they do this in 3d modelling programs as they seem to have no problem doing something like this, e.g blender does this stuff instantly

Any help would be very much appreciated

Have a look at:

https://doc.babylonjs.com/how_to/how_to_use_facetdata

It seems to have what you need:

getClosestFacetAtCoordinates

and mesh partitioning to keep working with chunks of 50*50 for example

2 Likes