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

Method attach

src/core/Object3D.js:874–908  ·  view source on GitHub ↗

* Adds the given 3D object as a child of this 3D object, while maintaining the object's world * transform. This method does not support scene graphs having non-uniformly-scaled nodes(s). * * @fires Object3D#added * @fires Object3D#childadded * @param {Object3D} object - The 3D object to at

( object )

Source from the content-addressed store, hash-verified

872 * @return {Object3D} A reference to this instance.
873 */
874 attach( object ) {
875
876 // adds object as a child of this, while maintaining the object's world transform
877
878 // Note: This method does not support scene graphs having non-uniformly-scaled nodes(s)
879
880 this.updateWorldMatrix( true, false );
881
882 _m1.copy( this.matrixWorld ).invert();
883
884 if ( object.parent !== null ) {
885
886 object.parent.updateWorldMatrix( true, false );
887
888 _m1.multiply( object.parent.matrixWorld );
889
890 }
891
892 object.applyMatrix4( _m1 );
893
894 object.removeFromParent();
895 object.parent = this;
896 this.children.push( object );
897
898 object.updateWorldMatrix( false, true );
899
900 object.dispatchEvent( _addedEvent );
901
902 _childaddedEvent.child = object;
903 this.dispatchEvent( _childaddedEvent );
904 _childaddedEvent.child = null;
905
906 return this;
907
908 }
909
910 /**
911 * Searches through the 3D object and its children, starting with the 3D object

Callers 1

Object3D.tests.jsFile · 0.45

Calls 8

updateWorldMatrixMethod · 0.95
removeFromParentMethod · 0.80
invertMethod · 0.45
copyMethod · 0.45
multiplyMethod · 0.45
applyMatrix4Method · 0.45
pushMethod · 0.45
dispatchEventMethod · 0.45

Tested by

no test coverage detected