copy method

Object3D copy(
  1. Object3D source, [
  2. bool? recursive = true
])

Implementation

Object3D copy(Object3D source, [bool? recursive = true]) {
  recursive = recursive ?? true;

  name = source.name;

  up.copy(source.up);

  position.copy(source.position);
  rotation.order = source.rotation.order;
  quaternion.copy(source.quaternion);
  scale.copy(source.scale);

  matrix.copy(source.matrix);
  matrixWorld.copy(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 (var i = 0; i < source.children.length; i++) {
      var child = source.children[i];
      add(child.clone());
    }
  }

  return this;
}