Capítulo 10 de 859
This is the base class for most objects in three.js and provides a set of properties and methods for manipulating objects in 3D space.
true, the 3D object gets rendered into shadow maps.true, the 3D object is honored by view frustum culling.Constructor
| Signature |
|---|
new Object3D() |
Properties
| Property | Description |
|---|---|
.animations : Array.<AnimationClip> | An array holding the animation clips of the 3D object. |
.castShadow : boolean | When set to true, the 3D object gets rendered into shadow maps. |
.children : Array.<Object3D> | An array holding the child 3D objects of this instance. |
| `.customDepthMaterial : Material | undefined` |
| `.customDistanceMaterial : Material | undefined` |
.frustumCulled : boolean | When set to true, the 3D object is honored by view frustum culling. |
.id : number (readonly) | The ID of the 3D object. |
.isObject3D : boolean (readonly) | This flag can be used for type testing. |
.layers : Layers | The layer membership of the 3D object. The 3D object is only visible if it has at least one layer in common with the camera in use. This property can also be used to filter out unwanted objects in ra… |
.matrix : Matrix4 | Represents the object's transformation matrix in local space. |
.matrixAutoUpdate : boolean | When set to true, the engine automatically computes the local matrix from position, rotation and scale every frame. If set to false, the app is responsible for recomputing the local matrix by cal… |
.matrixWorld : Matrix4 | Represents the object's transformation matrix in world space. If the 3D object has no parent, then it's identical to the local transformation matrix |
.matrixWorldAutoUpdate : boolean | When set to true, the engine automatically computes the world matrix from the current local matrix and the object's transformation hierarchy. If set to false, the app is responsible for recomputi… |
.matrixWorldNeedsUpdate : boolean | When set to true, it calculates the world matrix in that frame and resets this property to false. |
.modelViewMatrix : Matrix4 | Represents the object's model-view matrix. |
.name : string | The name of the 3D object. |
.normalMatrix : Matrix3 | Represents the object's normal matrix. |
.parent : Object3D | A reference to the parent object. |
.pivot : Vector3 | The pivot point for rotation and scale transformations. When set, rotation and scale are applied around this point instead of the object's origin. |
.position : Vector3 | Represents the object's local position. |
.quaternion : Quaternion | Represents the object's local rotation as Quaternions. |
.receiveShadow : boolean | When set to true, the 3D object is affected by shadows in the scene. |
.renderOrder : number | This value allows the default rendering order of scene graph objects to be overridden although opaque and transparent objects remain sorted independently. When this property is set for an instance of… |
.rotation : Euler | Represents the object's local rotation as Euler angles, in radians. |
.scale : Vector3 | Represents the object's local scale. |
.static : boolean | Whether the 3D object is supposed to be static or not. If set to true, it means the 3D object is not going to be changed after the initial renderer. This includes geometry and material settings. A … |
.type : string (readonly) | The type property is used for detecting the object type in context of serialization/deserialization. |
.up : Vector3 | Defines the up direction of the 3D object which influences the orientation via methods like Object3D#lookAt. |
.userData : Object | An object that can be used to store custom data about the 3D object. It should not hold references to functions as these will not be cloned. |
.uuid : string (readonly) | The UUID of the 3D object. |
.visible : boolean | When set to true, the 3D object gets rendered. |
.DEFAULT_MATRIX_AUTO_UPDATE : boolean | The default setting for Object3D#matrixAutoUpdate for newly created 3D objects. |
.DEFAULT_MATRIX_WORLD_AUTO_UPDATE : boolean | The default setting for Object3D#matrixWorldAutoUpdate for newly created 3D objects. |
.DEFAULT_UP : Vector3 | The default up direction for objects, also used as the default position for DirectionalLight and HemisphereLight. |
Methods
| Method | Description |
|---|---|
.add( object : Object3D ) : Object3D | Adds the given 3D object as a child to this 3D object. An arbitrary number of objects may be added. Any current parent on an object passed in here will be removed, since an object can have at most on… |
.applyMatrix4( matrix : Matrix4 ) | Applies the given transformation matrix to the object and updates the object's position, rotation and scale. |
.applyQuaternion( q : Quaternion ) : Object3D | Applies a rotation represented by given the quaternion to the 3D object. |
.attach( object : Object3D ) : Object3D | 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). |
.clear() : Object3D | Removes all child objects. |
.clone( recursive : boolean ) : Object3D | Returns a new 3D object with copied values from this instance. |
.copy( source : Object3D, recursive : boolean ) : Object3D | Copies the values of the given 3D object to this instance. |
| `.getObjectById( id : number ) : Object3D | undefined` |
| `.getObjectByName( name : string ) : Object3D | undefined` |
| `.getObjectByProperty( name : string, value : any ) : Object3D | undefined` |
.getObjectsByProperty( name : string, value : any, result : Array.<Object3D> ) : Array.<Object3D> | Searches through the 3D object and its children, starting with the 3D object itself, and returns all 3D objects with a matching property value. |
.getWorldDirection( target : Vector3 ) : Vector3 | Returns a vector representing the ("look") direction of the 3D object in world space. |
.getWorldPosition( target : Vector3 ) : Vector3 | Returns a vector representing the position of the 3D object in world space. |
.getWorldQuaternion( target : Quaternion ) : Quaternion | Returns a Quaternion representing the position of the 3D object in world space. |
.getWorldScale( target : Vector3 ) : Vector3 | Returns a vector representing the scale of the 3D object in world space. |
.localToWorld( vector : Vector3 ) : Vector3 | Converts the given vector from this 3D object's local space to world space. |
| `.lookAt( x : number | Vector3, y : number, z : number )` |
| `.onAfterRender( renderer : Renderer | WebGLRenderer, object : Object3D, camera : Camera, geometry : BufferGeometry, material : Material, group : Object )` |
| `.onAfterShadow( renderer : Renderer | WebGLRenderer, object : Object3D, camera : Camera, shadowCamera : Camera, geometry : BufferGeometry, depthMaterial : Material, group : Object )` |
| `.onBeforeRender( renderer : Renderer | WebGLRenderer, object : Object3D, camera : Camera, geometry : BufferGeometry, material : Material, group : Object )` |
| `.onBeforeShadow( renderer : Renderer | WebGLRenderer, object : Object3D, camera : Camera, shadowCamera : Camera, geometry : BufferGeometry, depthMaterial : Material, group : Object )` |
.raycast( raycaster : Raycaster, intersects : Array.<Object> ) (abstract) | Abstract method to get intersections between a casted ray and this 3D object. Renderable 3D objects such as Mesh, Line or Points implement this method in orde… |
.remove( object : Object3D ) : Object3D | Removes the given 3D object as child from this 3D object. An arbitrary number of objects may be removed. |
.removeFromParent() : Object3D | Removes this 3D object from its current parent. |
.rotateOnAxis( axis : Vector3, angle : number ) : Object3D | Rotates the 3D object along an axis in local space. |
.rotateOnWorldAxis( axis : Vector3, angle : number ) : Object3D | Rotates the 3D object along an axis in world space. |
.rotateX( angle : number ) : Object3D | Rotates the 3D object around its X axis in local space. |
.rotateY( angle : number ) : Object3D | Rotates the 3D object around its Y axis in local space. |
.rotateZ( angle : number ) : Object3D | Rotates the 3D object around its Z axis in local space. |
.setRotationFromAxisAngle( axis : Vector3, angle : number ) | Sets the given rotation represented as an axis/angle couple to the 3D object. |
.setRotationFromEuler( euler : Euler ) | Sets the given rotation represented as Euler angles to the 3D object. |
.setRotationFromMatrix( m : Matrix4 ) | Sets the given rotation represented as rotation matrix to the 3D object. |
.setRotationFromQuaternion( q : Quaternion ) | Sets the given rotation represented as a Quaternion to the 3D object. |
| `.toJSON( meta : Object | string ) : Object` |
.translateOnAxis( axis : Vector3, distance : number ) : Object3D | Translate the 3D object by a distance along the given axis in local space. |
.translateX( distance : number ) : Object3D | Translate the 3D object by a distance along its X-axis in local space. |
.translateY( distance : number ) : Object3D | Translate the 3D object by a distance along its Y-axis in local space. |
.translateZ( distance : number ) : Object3D | Translate the 3D object by a distance along its Z-axis in local space. |
.traverse( callback : function ) | Executes the callback on this 3D object and all descendants. |
.traverseAncestors( callback : function ) | Like Object3D#traverse, but the callback will only be executed for all ancestors. |
.traverseVisible( callback : function ) | Like Object3D#traverse, but the callback will only be executed for visible 3D objects. Descendants of invisible 3D objects are not traversed. |
.updateMatrix() | Updates the transformation matrix in local space by computing it from the current position, rotation and scale values. |
.updateMatrixWorld( force : boolean ) | Updates the transformation matrix in world space of this 3D objects and its descendants. |
.updateWorldMatrix( updateParents : boolean, updateChildren : boolean, force : boolean ) | An alternative version of Object3D#updateMatrixWorld with more control over the update of ancestor and descendant nodes. |
.worldToLocal( vector : Vector3 ) : Vector3 | Converts the given vector from this 3D object's world space to local space. |