MCPcopy
hub / github.com/mrdoob/three.js / copy

Method copy

src/core/Object3D.js:1594–1643  ·  view source on GitHub ↗

* Copies the values of the given 3D object to this instance. * * @param {Object3D} source - The 3D object to copy. * @param {boolean} [recursive=true] - When set to `true`, descendants of the 3D object are cloned. * @return {Object3D} A reference to this instance.

( source, recursive = true )

Source from the content-addressed store, hash-verified

1592 * @return {Object3D} A reference to this instance.
1593 */
1594 copy( source, recursive = true ) {
1595
1596 this.name = source.name;
1597
1598 this.up.copy( source.up );
1599
1600 this.position.copy( source.position );
1601 this.rotation.order = source.rotation.order;
1602 this.quaternion.copy( source.quaternion );
1603 this.scale.copy( source.scale );
1604
1605 this.pivot = ( source.pivot !== null ) ? source.pivot.clone() : null;
1606
1607 this.matrix.copy( source.matrix );
1608 this.matrixWorld.copy( source.matrixWorld );
1609
1610 this.matrixAutoUpdate = source.matrixAutoUpdate;
1611
1612 this.matrixWorldAutoUpdate = source.matrixWorldAutoUpdate;
1613 this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
1614
1615 this.layers.mask = source.layers.mask;
1616 this.visible = source.visible;
1617
1618 this.castShadow = source.castShadow;
1619 this.receiveShadow = source.receiveShadow;
1620
1621 this.frustumCulled = source.frustumCulled;
1622 this.renderOrder = source.renderOrder;
1623
1624 this.static = source.static;
1625
1626 this.animations = source.animations.slice();
1627
1628 this.userData = JSON.parse( JSON.stringify( source.userData ) );
1629
1630 if ( recursive === true ) {
1631
1632 for ( let i = 0; i < source.children.length; i ++ ) {
1633
1634 const child = source.children[ i ];
1635 this.add( child.clone() );
1636
1637 }
1638
1639 }
1640
1641 return this;
1642
1643 }
1644
1645}
1646

Callers 8

translateOnAxisMethod · 0.45
worldToLocalMethod · 0.45
lookAtMethod · 0.45
attachMethod · 0.45
updateMatrixWorldMethod · 0.45
updateWorldMatrixMethod · 0.45
cloneMethod · 0.45

Calls 4

addMethod · 0.95
sliceMethod · 0.80
cloneMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected