I’d like to clone a mesh without its descendants, but Mesh.clone isn’t using the recursive argument (like Object3D).I want to know, is there any reason why it’s always doing deep clone?. Thx!
It’s likely expected that a Mesh will not have children so it doesn’t support taking a “recursive” argument.
It looks like the relevant piece of code is here where the Object3D copy function is called without a recursive argument, which defaults it to
What’s your use case for adding children to a Mesh object?
Thanks for the help! I need add a stroke geometry to my mesh, i’m adding the stroke like child to inherit the transformations. Too i’m implementing a text frame (a mesh with mesh children of letters).
In that case I would add the meshes as sibling objects to a group and set the transform of the group:
Group └ Mesh └ Outline
If that’s not suitable then you can create an issue in the three.js github to add the capability or at least make the Mesh class consistent. If the clone function and other code expects that there are no children then it might make sense to disallow child objects to be added to the object, as well.
Alternately, a simple way of doing this is just removing the children from the mesh when you clone it.
var children = mesh.children; mesh.children = ; var clonedMesh = mesh.clone(); mesh.children = children;
Probably not ideal but it should work…