# Need advice on userData with Threejs Editor

**URL:** <https://discourse.threejs.org/t/need-advice-on-userdata-with-threejs-editor/11586>\
**Category:** Questions\
**Tags:** object3d\
**Created:** [December 16, 2019, 12:43am UTC](https://discourse.threejs.org/t/need-advice-on-userdata-with-threejs-editor/11586 "2019-12-16T00:43:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![makman](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/makman/32/4910_2.png) [@makman](https://discourse.threejs.org/u/makman)\
**Post date:** [December 16, 2019, 12:43am UTC](https://discourse.threejs.org/t/need-advice-on-userdata-with-threejs-editor/11586/1 "2019-12-16T00:43:28Z")

</div>

I am a designer using the ThreeJS editor. I do not assign a script to an object very often because I have very limited coding knowledge. But the editor has been an amazing resource for me regardless of my lacking coding skills.

I have been very interested in learning more about what I can do with the “User data” window that is located in the threejs editor.

I have done a lot of searching about userdata and it seems you can add any data you want there… I’ve seen several people searching on how to make an object a clickable weblink with userData for example…

I wanted to ask the community

1. Can I use the User data window to add functionality to an object without also creating a script? Or a script of some kind is always needed to interact with the user data created?

2. Does anyone have suggestions of use User data snippets I can plug into the User data window with in the editor?

I really appreciate the suggestions as it will help me learn a lot more about how to use userData!!

Thank you!!

---

<div class="post-metadata">

**Author:** ![pailhead](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pailhead/32/85_2.png) [@pailhead](https://discourse.threejs.org/u/pailhead)\
**Post date:** [December 16, 2019, 9:56am UTC](https://discourse.threejs.org/t/need-advice-on-userdata-with-threejs-editor/11586/2 "2019-12-16T09:56:34Z")

</div>

It’s just a simple javascript data structure - object / dictionary. Being javascript, anything can be a member of that object. Given some key, the value can be a number, string, Boolean (primitives), or other complex objects including functions.

I never worked with the editor, but you should be able to save a function there, and then evaluate it once you load the object. Of course you’d have to “script” the function yourself, or find one that sets up the js context so that it could address your object Appropriately.

---

<div class="post-metadata">

**Author:** ![makman](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/makman/32/4910_2.png) [@makman](https://discourse.threejs.org/u/makman)\
**Post date:** [December 17, 2019, 2:27am UTC](https://discourse.threejs.org/t/need-advice-on-userdata-with-threejs-editor/11586/3 "2019-12-17T02:27:23Z")

</div>

Thank you that explains a lot! I appreciate it!

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [December 17, 2019, 1:55pm UTC](https://discourse.threejs.org/t/need-advice-on-userdata-with-threejs-editor/11586/4 "2019-12-17T13:55:17Z")

</div>

BTW take care when storing anything that can’t be [serialized](https://developer.mozilla.org/en-US/docs/Glossary/Serialization) in `userData` if you plan to use `Object3D.copy` or `Object3D.clone`.

Functions won’t be copied or cloned, for example, and will be ignored. More complex object will cause a crash (I know this because I tried to store an `AnimationMixer` instance in there).

I’m not sure what the reason for serializing `userData` is, IMO it’s useful to be able to store simple functions in there.

---

<div class="post-metadata">

**Author:** ![Fyrestar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fyrestar/32/52793_2.png) [@Fyrestar](https://discourse.threejs.org/u/Fyrestar)\
**Post date:** [December 17, 2019, 8:04pm UTC](https://discourse.threejs.org/t/need-advice-on-userdata-with-threejs-editor/11586/5 "2019-12-17T20:04:29Z")

</div>

> [@looeee](#):
>
> I’m not sure what the reason for serializing `userData` is, IMO it’s useful to be able to store simple functions in there.

As it’s exported in json, to store some state etc. For methods or other cases it makes sense to create a new class extending Mesh or Object3D.

---

<div class="post-metadata">

**Author:** ![makman](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/makman/32/4910_2.png) [@makman](https://discourse.threejs.org/u/makman)\
**Post date:** [December 19, 2019, 11:31pm UTC](https://discourse.threejs.org/t/need-advice-on-userdata-with-threejs-editor/11586/6 "2019-12-19T23:31:43Z")

</div>

Thank you, that is helpful info! I am just getting started with things but I am sure I will need to use copy/clone at some point
