# How to use picking ray to determine meshes in a given area

**URL:** <https://forum.babylonjs.com/t/how-to-use-picking-ray-to-determine-meshes-in-a-given-area/13631>\
**Category:** Questions\
**Created:** [August 24, 2020, 12:46pm UTC](https://forum.babylonjs.com/t/how-to-use-picking-ray-to-determine-meshes-in-a-given-area/13631 "2020-08-24T12:46:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcoop](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@jcoop](https://forum.babylonjs.com/u/jcoop)\
**Post date:** [August 24, 2020, 12:46pm UTC](https://forum.babylonjs.com/t/how-to-use-picking-ray-to-determine-meshes-in-a-given-area/13631/1 "2020-08-24T12:46:55Z")

</div>

Hi there,

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.

---

<div class="post-metadata">

**Author:** ![Michael\_Prosser](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/michael_prosser/32/6062_2.png) [@Michael\_Prosser](https://forum.babylonjs.com/u/Michael_Prosser)\
**Post date:** [August 24, 2020, 1:29pm UTC](https://forum.babylonjs.com/t/how-to-use-picking-ray-to-determine-meshes-in-a-given-area/13631/2 "2020-08-24T13:29:21Z")

</div>

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](https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh)

---

<div class="post-metadata">

**Author:** ![jcoop](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@jcoop](https://forum.babylonjs.com/u/jcoop)\
**Post date:** [August 24, 2020, 2:03pm UTC](https://forum.babylonjs.com/t/how-to-use-picking-ray-to-determine-meshes-in-a-given-area/13631/3 "2020-08-24T14:03:17Z")

</div>

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?

 ![Screenshot 2020-08-24 at 14.48.37](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/3/3420f4e94db60f0eaf20570aece105828f86a34a.png)

^ 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
