clone static method
dynamic
clone(
- dynamic source
Implementation
static clone(source) {
var sourceLookup = new Map();
var cloneLookup = new Map();
var clone = source.clone();
parallelTraverse(source, clone, (sourceNode, clonedNode) {
// sourceLookup.set( clonedNode, sourceNode );
// cloneLookup.set( sourceNode, clonedNode );
sourceLookup[clonedNode] = sourceNode;
cloneLookup[sourceNode] = clonedNode;
});
clone.traverse((node) {
if (node==null|| !(node is SkinnedMesh)) //|| !node.runtimeType.toString().contains("SkinnedMesh"))
return;//!node.runtimeType.toString().contains("SkinnedMesh")) return; // GL
var clonedMesh = node;
var sourceMesh = sourceLookup[node];
var sourceBones = sourceMesh.skeleton.bones;
clonedMesh.skeleton = sourceMesh.skeleton.clone();
if (sourceMesh!=null&&clonedMesh!=null&&sourceMesh.bindMatrix!=null&&clonedMesh.bindMatrix!=null) { //GL
clonedMesh.bindMatrix!.copy(sourceMesh!.bindMatrix);
clonedMesh.skeleton!.bones = List<Bone>.from(sourceBones.map((bone) {
return cloneLookup[bone];
}).toList());
clonedMesh.bind(clonedMesh.skeleton!, clonedMesh.bindMatrix!);
}
});
return clone;
}