copy method
recursive
-- If set to true
, descendants of the object are copied next to the existing ones.
If set to false
, descendants are left unchanged. Default is true
.
Copies the given object into this object. Note: Event listeners and user-defined callbacks (onAfterRender and onBeforeRender) are not copied.
Implementation
Object3D copy(Object3D source, [bool? recursive = true]) {
recursive = recursive ?? true;
name = source.name;
up.setFrom(source.up);
position.setFrom(source.position);
rotation.order = source.rotation.order;
quaternion.setFrom(source.quaternion);
scale.setFrom(source.scale);
matrix.setFrom(source.matrix);
matrixWorld.setFrom(source.matrixWorld);
matrixAutoUpdate = source.matrixAutoUpdate;
matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
layers.mask = source.layers.mask;
visible = source.visible;
castShadow = source.castShadow;
receiveShadow = source.receiveShadow;
frustumCulled = source.frustumCulled;
renderOrder = source.renderOrder;
userData = json.decode(json.encode(source.userData));
if (recursive == true) {
for (int i = 0; i < source.children.length; i++) {
final child = source.children[i];
add(child.clone());
}
}
return this;
}