# How do you track InstancedMeshed instance so that they can be interacted with?

**URL:** <https://discourse.threejs.org/t/how-do-you-track-instancedmeshed-instance-so-that-they-can-be-interacted-with/25356>\
**Category:** Questions\
**Tags:** instanced-mesh\
**Created:** [April 14, 2021, 3:56pm UTC](https://discourse.threejs.org/t/how-do-you-track-instancedmeshed-instance-so-that-they-can-be-interacted-with/25356 "2021-04-14T15:56:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![garma](https://avatars.discourse-cdn.com/v4/letter/g/90db22/32.png) [@garma](https://discourse.threejs.org/u/garma)\
**Post date:** [April 14, 2021, 3:56pm UTC](https://discourse.threejs.org/t/how-do-you-track-instancedmeshed-instance-so-that-they-can-be-interacted-with/25356/1 "2021-04-14T15:56:15Z")

</div>

Hi! I have a scene with about 150 instanced meshes, each representing 10-20 instances. I need to track the instances, and follow up with some action (e.g. if the user clicks an instance, I need to do something with data related to that specific instance)

With normal geometry I would set the userData object on the mesh, and then retrieve it when a user clicks the scene (using a raytracer)

How would I do this with InstancedMeshes? can I set the userData object specifically for an instance?

---

<div class="post-metadata">

**Author:** ![garma](https://avatars.discourse-cdn.com/v4/letter/g/90db22/32.png) [@garma](https://discourse.threejs.org/u/garma)\
**Post date:** [April 14, 2021, 5:53pm UTC](https://discourse.threejs.org/t/how-do-you-track-instancedmeshed-instance-so-that-they-can-be-interacted-with/25356/2 "2021-04-14T17:53:00Z")

</div>

I found out that the intersection has a property called instanceId, and I created a dictionary of the mesh id and the instanceId to get the data I need. This works for me and I hope its the right way.

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [April 14, 2021, 8:50pm UTC](https://discourse.threejs.org/t/how-do-you-track-instancedmeshed-instance-so-that-they-can-be-interacted-with/25356/3 "2021-04-14T20:50:54Z")

</div>

Related example: [three.js webgl - instancing - raycast](https://threejs.org/examples/webgl_instancing_raycast)
