Skip to content

Correct way to use PropertyResolver param of copy #495

Answered by donmccurdy
oddnugget asked this question in Q&A
Discussion options

You must be logged in to vote

Mainly the resolver argument is there for internal use by document.merge() and document.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:

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@oddnugget
Comment options

Answer selected by oddnugget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants