Object3D
This class is a base class of every objects which can be added into scene tree for the 3d rendering. As a basic class, it has implemented event listening and serialization for every objects of scene. Each object has position, rotation and scale attribute to represent the spatial transform in a 3D coordinate.
Hierarchy
Implements
- SerializerableDelegatedAsReference
Constructors
constructor
Returns Object3D
Overrides ElementEventDispatcher.constructor
Properties
StaticDefault UpVector3(0, 1, 0)
Every objects in 3D space must have a default up direction.
id
Unique number for each object3D instance.
category Id
Reserved attribute
source Type
Record the object rendered as instance or other type.
scene
The scene which this object belong to.
update Dirty Id-1
The number is the frame id which this object is changed or participates change of scene graph. If this value equals to frame id - 1,
name
The name of this object, it is empty if useless.
is Object3 D
Used to check type of this or extended instance. This value should not be changed by user.
parent
Object's parent node in the scene graph. An object can have at most one parent.
children
Array with object's children.
up
This is used by the lookAt method, for example, to determine the orientation of the result. Default is DefaultUp .
world Matrix Update Timestamp
Record when this object's world matrix last updated.
transform Changed
Record whether the object's any attribute| attribute is updated.
visible Changed
matrix World
The global transform of the object. If the Object3D has no parent, then it's identical to the local transform matrix.
matrix World Needs Updatefalse
When this is set, it calculates the matrixWorld in that frame and resets this property to false.
net Visibility
Record if the object is really visible in rendering process. If the Object3D has no parent, it would be set by visible ;
local Matrix Need Updatefalse
When this is set, it calculates the model matrix in that frame and resets this property to false.
Readonlyuser Data
Inherited from ElementEventDispatcher.userData
_ uuid
Inherited from ElementEventDispatcher._uuid
uuid
Inherited from ElementEventDispatcher.uuid
_ listeners
Inherited from ElementEventDispatcher._listeners
Accessors
layers
interaction Layers
group Layer
position
Returns Vector3
rotation
Returns Euler
quaternion
Returns Quaternion
Object's local rotation as a Quaternion.
Parameters
- _quaternion: Quaternion
Returns void
Remarks
See Quaternion for more details.
scaleVector3( 1, 1, 1 )
Returns Vector3
matrix
Parameters
- value: Matrix4
Returns void
visibletrue
- get visible(): boolean
Object gets rendered if true.
Returns boolean
- set visible(value: boolean): void
Parameters
- value: boolean
Returns void
business Tag
- get businessTag(): string
Returns string
Inherited from ElementEventDispatcher.businessTag
- set businessTag(v: string): void
Parameters
- v: string
Returns void
Inherited from ElementEventDispatcher.businessTag
Methods
class Name
The name of instance's class.
Returns string
Implementation of SerializerableDelegatedAsReference.className
destroy
Returns void
Overrides ElementEventDispatcher.destroy
free GPU
Returns void
sync Data
Returns void
update Visibility
Scene will check the object's visibility in each render and make change netVisibility based on its and parent's visible .
Returns boolean
clear Change Mark
set Matrix Updated
If the local matrix is changed, use this method to manually refresh data in scene graph.
Returns void
Tips
It's better to use notifySceneChange() as an alternative.
notify Scene Change
Use this method to manually refresh data in scene graph and draw again. The engine may not notify every change of the scene. If any effect is not changed with the parameters, use this may solve.
Returns void
set Matrix Dirty
If the local matrix or world matrix is changed, use this method to make engine refresh data in scene graph automatically. This method will set matrixWorldNeedsUpdate and localMatrixNeedUpdate to true.
Returns void
update World Render Data
Change matrixWorldNeedsUpdate and worldMatrixUpdateTimestamp state. This method will refresh data of world matrix by updateMatrixWorld
Parameters
- updateID: number
This number is used to identify the render.
Returns boolean
- updateID: number
is Flipped
If there are zero or two negative numbers in xyz, return false, otherwise return true.
Returns boolean
local To World
world To Local
apply Matrix
Applies the matrix transform to the object and updates the object's position, rotation and scale.
Parameters
- matrix: Matrix4
A matrix represents the information of transform.
Returns void
- matrix: Matrix4
apply Quaternion
Applies the rotation represented by the quaternion to the object.
Parameters
- q: Quaternion
A Quaternion represents the information of rotation.
Returns this
- q: Quaternion
set Rotation From Axis Angle
Calls setFromAxisAngle ( axis, angle ) on the Quaternion.
Parameters
- axis: Vector3
A normalized vector in object space.
- angle: number
Angle in radians.
Returns void
- axis: Vector3
set Rotation From Euler
Calls Quaternion.setRotationFromEuler| setRotationFromEuler(euler, true) on the Quaternion.
Parameters
- euler: Euler
Euler angle specifying rotation amount.
Returns void
- euler: Euler
set Rotation From Matrix
Calls setFromRotationMatrix (m) on the Quaternion.
Parameters
- m: Matrix4
Euler angle specifying rotation amount.
Returns void
- m: Matrix4
set Rotation From Quaternion
Copy the given quaternion to object's quaternion .
Parameters
- q: Quaternion
Euler angle specifying rotation amount.
Returns void
- q: Quaternion
rotate On Axis
Rotate an object along an axis in object space. The axis is assumed to be normalized.
Parameters
- axis: Vector3
A normalized vector in object space.
- angle: number
Angle in radians.
Returns this
- axis: Vector3
rotate On World Axis
Rotate an object along an axis in world space. The axis is assumed to be normalized. Method Assumes no rotated parent.
Parameters
- axis: Vector3
A normalized vector in object space.
- angle: number
Angle in radians.
Returns this
- axis: Vector3
rotate X
Rotates the object around x axis in local space.
Parameters
- angle: number
The angle to rotate in radians.
Returns this
- angle: number
rotate Y
Rotates the object around x axis in local space.
Parameters
- angle: number
The angle to rotate in radians.
Returns this
- angle: number
rotate Z
Rotates the object around x axis in local space.
Parameters
- angle: number
The angle to rotate in radians.
Returns this
- angle: number
translate On Axis
Translate an object by distance along an axis in object space. The axis is assumed to be normalized.
Parameters
- axis: Vector3
A normalized vector in object space.
- distance: number
The distance to translate.
Returns this
- axis: Vector3
translate X
Translates object along x axis in object space by distance units.
Parameters
- distance: number
The distance to translate.
Returns this
- distance: number
translate Y
Translates object along y axis in object space by distance units.
Parameters
- distance: number
The distance to translate.
Returns this
- distance: number
translate Z
Translates object along z axis in object space by distance units.
Parameters
- distance: number
The distance to translate.
Returns this
- distance: number
look At
Rotates the object to face to a point in world space. This method does not support objects having non-uniformly-scaled parent(s)
Parameters
- _x: Vector3
A vector representing position of target in world space.
Returns void
- _x: Vector3
look At Local Point
Rotates the object to face a point in local space.
Parameters
- _x: Vector3
A vector representing position of target in local space.
Returns void
- _x: Vector3
add
Adds object as child of this 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 one parent. The scene graph change will be immediately notify by engine after adding nodes.
Parameters
Returns this
remove
Remove the specified object form children.
Parameters
- object: Object3D
The object which needs to be removed.
Returns this
- object: Object3D
remove From Parent
Returns void
remove All Children
Remove all children of this object.
Returns Object3D[]
remove Objects
Remove all children in specified objects from this objects. Migrate from tools common
Parameters
- objects: Object3D[]
An array of objects which need to be removed.
Returns this
- objects: Object3D[]
get Object By Id
Searches through an object and its children, starting with the object itself, and returns the first with a matching id. Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.
Parameters
- id: number
Unique number of the object instance.
Returns Object3D
- id: number
get Object By Name
Searches through an object and its children, starting with the object itself, and returns the first with a matching name. Note that for most objects the name is an empty string by default. You will have to set it manually to make use of this method.
Parameters
- name: string
String to match to the children's Object3D.name property.
Returns Object3D
- name: string
get Object By Property
Searches through an object and its children, starting with the object itself, and returns the first with a property that matches the value given.
Parameters
- name: string
The property name to search for.
- value: any
Value of the given property.
Returns Object3D
- name: string
get World Position
get World Quaternion
Return a quaternion representing the rotation of the object in world space.
Parameters
- target: Quaternion
the result will be copied into this Quaternion.
Returns Quaternion
- target: Quaternion
get World Scale
get World Direction
traverse
Execute the callback on this object and all descendants.
Parameters
- callback: (object: Object3D) => any
A function with as first argument an object3D object.
Returns void
- callback: (object: Object3D) => any
traverse With Children Skip
Execute the callback when return is false, stop traverse the object's descendants.
Parameters
- callback: (object: Object3D) => boolean
A function with as first argument an object3D object, return boolean.
Returns void
- callback: (object: Object3D) => boolean
traverse Visible
Execute the callback on this object and all descendants which is visible.
Parameters
- callback: (object: Object3D) => any
A function with as first argument an object3D object.
Returns void
- callback: (object: Object3D) => any
traverse Ancestors
Execute the callback on this object and all ancestors.
Parameters
- callback: (object: Object3D) => any
A function with as first argument an object3D object.
Returns void
- callback: (object: Object3D) => any
update Matrix
Update the matrix local transform.
Returns void
update Matrix World
Update the object's and its descendants' matrix of global transform with. If the parameter or matrixWorldNeedsUpdate is true, matrix will not skip updates.
Parameters
- force: boolean
Whether or not force to updates the matrix.
Returns void
- force: boolean
update World Matrix
Update the object's and its descendants' matrix of global transform with. will update parent or children according to the parameters
Parameters
- updateParents: boolean
update parents.
- updateChildren: boolean
update children.
- force: boolean
Whether or not force to updates the matrix.
Returns void
- updateParents: boolean
get Local Bounds
get UUID
Get UUID of this object instance. This value is automatically assigned, so this shouldn't be edited.
Returns string
Implementation of SerializerableDelegatedAsReference.getUUID
serialize
Store the attributes of this class into string as serializing format.
Parameters
- ctx: Serializer
this parameter has not supported external Serializer yet. It may cause that this method can not be used directly.
Returns void
Implementation of SerializerableDelegatedAsReference.serialize
- ctx: Serializer
deserialize
Parse the data for this class from string according to serializing format.
Parameters
- ctx: Deserializer
this parameter has not supported external Deserializer yet. It may cause that this method can not be used directly.
Returns void
Implementation of SerializerableDelegatedAsReference.deserialize
- ctx: Deserializer
clone
Return a cloned instance of this class and optionally all descendants.
Parameters
- recursive: boolean
if true, descendants of the object are also cloned. Default is true.
Returns Object3D
- recursive: boolean
copy
Copy the data to this object from source. This method need override in derived classes to copy extended data.
Parameters
- source: Object3D
the data source.
- recursive: boolean
if true, descendants of the object are also cloned. Default is true.
Returns this
- source: Object3D
mark Business Tag
Parameters
- v: string
Returns this
Inherited from ElementEventDispatcher.markBusinessTag
is Destroyed
Returns boolean
Inherited from ElementEventDispatcher.isDestroyed
validate
Returns void
Inherited from ElementEventDispatcher.validate
destroy All Resources Owned
Returns void
Inherited from ElementEventDispatcher.destroyAllResourcesOwned
free All Gpu Resource Owned
Returns void
Inherited from ElementEventDispatcher.freeAllGpuResourceOwned
on
once
has
off
emit
Active the event and call the registered listener.
Parameters
- type: EventType<never>
Returns void
Inherited from ElementEventDispatcher.emit
clear All Listeners
Removes all listeners from listening list.
Returns void
Inherited from ElementEventDispatcher.clearAllListeners
This class is a base class of every objects which can be added into scene tree for the 3d rendering. As a basic class, it has implemented event listening and serialization for every objects of scene. Each object has position, rotation and scale attribute to represent the spatial transform in a 3D coordinate.