I’m trying to create a feature where a user can select all meshes within a drawn square. I’ve currently been able to implement a feature where a user can select a mesh in the scene using a picking ray to detect any hit meshes. But I’m stuck how to detect all meshes within the coordinates of a 2d rectangle (which is drawn by the user with the pointer).
Is there a way to use a picking ray (or some other method) to detect all meshes within an area instead of just a single point coordinate?
Appreciate any help, guidance or direction, thanks.
If you are looking to find the meshes that come into contact with a 3D Square area you could create a temp mesh for that area and do a collision check on it to see if it intersects other meshes. A ray is a line and likely not the best performance solution for scanning a 3D area of space for meshes. Intersect Collisions - mesh - Babylon.js Documentation
Thanks, @Michael_Prosser, that’s great. Appreciate your help I’ll try that approach. I’m still a beginner with Babylon so apologies if this is an obvious question - is there a way to create the temp mesh on the position/orientation that the camera is viewing the scene from?
^ Similar to this screenshot?
So that when the user draws the black outline, the newly created mesh will ‘collide’ with what’s being shown to the user within the rectangle? I’ve tried to create the mesh in the correct position/orientation but not having much luck. We’re using an BABYLON.ArcRotateCamera camera. Thanks for all your help