# Set InstancedMesh userData

**URL:** <https://discourse.threejs.org/t/set-instancedmesh-userdata/32860>\
**Category:** Questions\
**Tags:** instanced-mesh, react-three-fiber\
**Created:** [December 20, 2021, 10:10pm UTC](https://discourse.threejs.org/t/set-instancedmesh-userdata/32860 "2021-12-20T22:10:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![StephenDRoberts](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/stephendroberts/32/22633_2.png) [@StephenDRoberts](https://discourse.threejs.org/u/StephenDRoberts)\
**Post date:** [December 20, 2021, 10:10pm UTC](https://discourse.threejs.org/t/set-instancedmesh-userdata/32860/1 "2021-12-20T22:10:13Z")

</div>

Hello

Sorry I’ve tried figuring this out myself but not got anywhere with it.

I’m trying to pass userData into instances within an instancedMesh. I appreciate each instance will have it’s own instanceId but I’d like to pass in other details to the individual instances if possible.

In [this link](https://codesandbox.io/s/restless-sea-o4yq9?file=/src/Boxes.js) I’ve set up a grid of boxes. I see from the [docs](https://threejs.org/docs/#api/en/core/Object3D.userData) that userData is a property on an Object3D, which I’m using in my instancedMesh (denoted as `temp`). So on lines 17-19 I’m trying to pass in some data to the userData property. On line 38, within the onClick method I’m trying to console out what I believe is the intersected object so that I can see its userData, however it’s coming out as empty.

Is this possible to do?

Any help would be greatly appreciated!

Cheers

Steve

---

<div class="post-metadata">

**Author:** ![StephenDRoberts](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/stephendroberts/32/22633_2.png) [@StephenDRoberts](https://discourse.threejs.org/u/StephenDRoberts)\
**Post date:** [December 21, 2021, 9:06pm UTC](https://discourse.threejs.org/t/set-instancedmesh-userdata/32860/2 "2021-12-21T21:06:04Z")

</div>

Just giving this a little bump…

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [December 22, 2021, 12:28am UTC](https://discourse.threejs.org/t/set-instancedmesh-userdata/32860/3 "2021-12-22T00:28:03Z")

</div>

`.userData` is attached to an Object3D instance, like InstancedMesh in this case. So there is no `.userData` property for each instance individually – the InstancedMesh represents _all_ of the instances.

Instead what you might do is to store an array of the data you want, indexed by the instanceID. Then when you get a click event you can look up the data in that array.

---

<div class="post-metadata">

**Author:** ![StephenDRoberts](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/stephendroberts/32/22633_2.png) [@StephenDRoberts](https://discourse.threejs.org/u/StephenDRoberts)\
**Post date:** [December 22, 2021, 8:56am UTC](https://discourse.threejs.org/t/set-instancedmesh-userdata/32860/4 "2021-12-22T08:56:35Z")

</div>

Good idea, thanks for the clarification Don 👍
