THREE.CSS2DObject needs a clone method
See original GitHub issueFirst of all THREE.CSS2DObject
is an amazing component, I’ve been using it intensively for labeling with rich HTML labels and KPI’s my 3D objects. I normally include them into a Group with the object they label for a relative position and move them together when animated.
I’m not sure if many devs are doing a so intensive use of this component, but the issue comes when I have many objects that use the same 3D model, and I try to clone the parent Group to optimize performance. The clone method of the Group recursively will call clone for all the children, including the CSS2Object which lacks of a clone method.
I have implemented it easily, it’s not a big deal, but I think this method should be implemented in the source of three.js main branch.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
BTW: It’s not really the clone method that needs a change. Instead,
CSS2DObject.copy()
needs to be implemented. And it’s important to ensure instances ofCSS2DObject
can be created without any parameters (which is currently not the case sinceelement
is mandatory).This code seems to work:
Thanks @Mugen87 for this quick implementation, this method is even simpler than mine. I’ve just updated my code and it runs perfectly.