How to Get the 3d model attached to the css2Object?

Hi,

What is the best way to get the 3d object attached to one css2Object ?

My goal is when clicking on a css2Object (label), I want to get the 3d object attached to it.

Thank you,

Since instances of CSS2DObject are normally children of their respective 3D object, it should be:

const object = css2Object.parent;
1 Like

Yes but my css2 Object appear as a html tag, such as a div.

My goal is when clicking on the label (html tag with a javascript event) i get the 3D object attached to. But The css2Object appears as a html form…

What is the best to achieve that?

This can be done in many ways. E.g. you give each HTML element an ID and map the respective CSS2DObject with a simple data structure (e.g. a Map). You can then use it like so:

const css2Object = map.get( element.id );