Correct way to use PropertyResolver param of copy #495
-
I am trying to copy a mesh and and set a different material on it, but i noticed that the copy method will add children by reference, which naturally means that changing the material of the meshPrimitive will change it on both the source and copy. What's the correct way to implement the PropertyResolver in order to acomplish this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Mainly the resolver argument is there for internal use by const mesh2 = document.createMesh().copy(mesh1, (ref) => ref.clone()); If the same texture might be used more than once you'd probably want to keep track of it and return the same clone rather than additional clones here. |
Beta Was this translation helpful? Give feedback.
Mainly the resolver argument is there for internal use by
document.merge()
anddocument.clone()
, but you could also use it to make a deep copy. The function takes a child (or descendant) of the original as its argument and should return the property it maps to on the target. For the simplest example:If the same texture might be used more than once you'd probably want to keep track of it and return the same clone rather than additional clones here.