Mesh
This class is used to connect every three points into a triangle and draws every meshes as corresponding material in the scene.
Type Parameters
- M extends Material = Material
- G extends BufferGeometry<TriangleList> = BufferGeometry<TriangleList>
Hierarchy
Constructors
constructor
- new Mesh<
M extends Material = Material,
G extends BufferGeometry<TriangleList> = BufferGeometry<TriangleList>,
>(
geometry?: G,
material?: M | M[],
): Mesh<M, G>Type Parameters
- M extends Material = Material
- G extends BufferGeometry<TriangleList> = BufferGeometry<TriangleList>
Returns Mesh<M, G>
Overrides Drawable<M, G>.constructor
Properties
StaticDefault UpVector3(0, 1, 0)
Every objects in 3D space must have a default up direction.
Inherited from Drawable.DefaultUp
id
Unique number for each object3D instance.
Inherited from Drawable.id
scene
The scene which this object belong to.
Inherited from Drawable.scene
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,
Inherited from Drawable.updateDirtyId
name
The name of this object, it is empty if useless.
Inherited from Drawable.name
is Object3 D
Used to check type of this or extended instance. This value should not be changed by user.
Inherited from Drawable.isObject3D
parent
Object's parent node in the scene graph. An object can have at most one parent.
Inherited from Drawable.parent
children
Array with object's children.
Inherited from Drawable.children
up
This is used by the lookAt method, for example, to determine the orientation of the result. Default is DefaultUp .
Inherited from Drawable.up
world Matrix Update Timestamp
Record when this object's world matrix last updated.
Inherited from Drawable.worldMatrixUpdateTimestamp
transform Changed
Record whether the object's any attribute| attribute is updated.
Inherited from Drawable.transformChanged
visible Changed
Inherited from Drawable.visibleChanged
matrix World
The global transform of the object. If the Object3D has no parent, then it's identical to the local transform matrix.
Inherited from Drawable.matrixWorld
matrix World Needs Updatefalse
When this is set, it calculates the matrixWorld in that frame and resets this property to false.
Inherited from Drawable.matrixWorldNeedsUpdate
net Visibility
Record if the object is really visible in rendering process. If the Object3D has no parent, it would be set by visible ;
Inherited from Drawable.netVisibility
local Matrix Need Updatefalse
When this is set, it calculates the model matrix in that frame and resets this property to false.
Inherited from Drawable.localMatrixNeedUpdate
render Order0
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 Group| Group, all descendants objects will be sorted and rendered together. Sorting is from lowest to highest renderOrder.
Inherited from Sprite.renderOrder
draw ModeMesh.
This is a decisive attribute for drawing method.
overlay Layers
Inherited from Sprite.overlayLayers
cast Shadow
Mark this drawable can cast shadow
Inherited from Sprite.castShadow
cast Planar Shadow
Mark this drawable can cast shadow
Inherited from Sprite.castPlanarShadow
is Drawable
Used to check type of this or extended instance. This value should not be changed by user.
Inherited from Sprite.isDrawable
material Changedtrue
Mark the material reference changed.
Inherited from Sprite.materialChanged
geometry Changedtrue
Mark the geometry reference changed.
Inherited from Sprite.geometryChanged
front Face CWfalse
Specify the winding orientation of mesh as counter-clock-wise, only meaningful on mesh.
Inherited from Sprite.frontFaceCW
model View Matrix
Store the Model-View matrix for this object. It is not suggested to change the matrix because it will be update automatically when camera move.
Inherited from Sprite.modelViewMatrix
normal Matrix
This matrix is used to calculate the normal in eye-space.
Inherited from Sprite.normalMatrix
world Bounding Dirtytrue
Mark bounding need to be recalculated.
Inherited from Sprite.worldBoundingDirty
world Bounding Box
Calculate the bounding as box.
Inherited from Sprite.worldBoundingBox
world Bounding Sphere
Calculate the bounding as sphere.
Inherited from Sprite.worldBoundingSphere
z
The distance from object to camera in the direction of camera. Use this value to simply estimate the depth in 3D scene.
on Before Render
This method allow user manually process data before the engine drawing object.
Inherited from Sprite.onBeforeRender
view Independent Scale
This is used to scale a drawable object by specified number when enableViewIndependentScale| enableViewIndependentScale is true.
Inherited from Sprite.viewIndependentScale
category Id
Reserved attribute
Inherited from Sprite.categoryId
source Type
Record the object rendered as instance or other type.
Inherited from Sprite.sourceType
should Use Geometry Groups When Only Has One Material
Inherited from Sprite.shouldUseGeometryGroupsWhenOnlyHasOneMaterial
is Mesh
Check the type whether it belongs to Mesh. This value should not be changed by user.
use Origin Material In Transparent Mode
Mark this mesh use origin material in transparent mode
type
The type of this Object3D.
edges
Bind edges to a mesh. Since the material is same, so all the groups will be combined together here.
_ synced Edge Threshold
Readonlyuser Data
Inherited from Drawable.userData
_ uuid
Inherited from Drawable._uuid
uuid
Inherited from Drawable.uuid
_ listeners
Inherited from Drawable._listeners
Accessors
layers
Returns Layers
Inherited from Drawable.layers
interaction Layers
Returns Layers | undefined
Inherited from Drawable.interactionLayers
group Layer
Returns Layers | undefined
Inherited from Drawable.groupLayer
position
Returns Vector3
Inherited from Drawable.position
rotation
quaternion
Returns Quaternion
Inherited from Drawable.quaternion
Object's local rotation as a Quaternion.
Parameters
- _quaternion: Quaternion
Returns void
Remarks
See Quaternion for more details.
Inherited from Drawable.quaternion
scaleVector3( 1, 1, 1 )
Returns Vector3
Inherited from Drawable.scale
matrix
visibletrue
- get visible(): boolean
Object gets rendered if true.
Returns boolean
Inherited from Drawable.visible
- set visible(value: boolean): void
Parameters
- value: boolean
Returns void
Inherited from Drawable.visible
outline Mode
- get outlineMode(): OutlineMode
Mark this drawable should be rendered in outline style if you set outlinePipelineMode & outlineShadingMode, get this value maybe error
Returns OutlineMode
Inherited from Drawable.outlineMode
- set outlineMode(v: OutlineMode): void
Parameters
- v: OutlineMode
Returns void
Inherited from Drawable.outlineMode
outline Shading Mode
- get outlineShadingMode(): OutlineShadingMode
Returns OutlineShadingMode
Inherited from Drawable.outlineShadingMode
- set outlineShadingMode(value: OutlineShadingMode): void
Parameters
- value: OutlineShadingMode
Returns void
Inherited from Drawable.outlineShadingMode
outline Render Mode
- get outlineRenderMode(): OutlineRenderMode
Returns OutlineRenderMode
Inherited from Drawable.outlineRenderMode
- set outlineRenderMode(value: OutlineRenderMode): void
OutlineRenderMode.Overlay is deprecated. use renderMode replaced
Parameters
- value: OutlineRenderMode
Returns void
Inherited from Drawable.outlineRenderMode
render Mode
Returns DrawableRenderMode
Inherited from Drawable.renderMode
is Always Dynamic
- get isAlwaysDynamic(): boolean
Returns boolean
Inherited from Drawable.isAlwaysDynamic
- set isAlwaysDynamic(v: boolean): void
Parameters
- v: boolean
Returns void
Inherited from Drawable.isAlwaysDynamic
enable View Independent Scale
- get enableViewIndependentScale(): boolean
Let this object can be scale independently.
Returns boolean
Inherited from Drawable.enableViewIndependentScale
- set enableViewIndependentScale(v: boolean): void
Parameters
- v: boolean
Returns void
Inherited from Drawable.enableViewIndependentScale
geometryBoxBufferGeometry| BoxBufferGeometry
- get geometry(): G
This attribute stores Geometry| Geometry or BufferGeometry| BufferGeometry (or derived classes), defining the object's shape.
Returns G
Inherited from Drawable.geometry
- set geometry(newGeo: G): void
Parameters
- newGeo: G
Returns void
Inherited from Drawable.geometry
render Geometry
- get renderGeometry(): BufferGeometryBase
Get the geometry which is really rendered by gpu.
Returns BufferGeometryBase
Inherited from Drawable.renderGeometry
render Material
Get the material which is really rendered by gpu.
Returns Material[]
Inherited from Drawable.renderMaterial
__ material
- set __material(v: M[]): void
Parameters
- v: M[]
Returns void
Inherited from Drawable.__material
instance Key
- get instanceKey(): Nullable<string>
Returns Nullable<string>
- set instanceKey(value: Nullable<string>): void
merge Key
- get mergeKey(): Nullable<string>
Returns Nullable<string>
- set mergeKey(value: Nullable<string>): void
This key is used to merge different meshes which have same key into one WebGL Draw Call.
Parameters
- value: Nullable<string>
Returns void
business Tag
- get businessTag(): string
Returns string
Inherited from Drawable.businessTag
- set businessTag(v: string): void
Parameters
- v: string
Returns void
Inherited from Drawable.businessTag
Methods
free GPU
Returns void
Inherited from Drawable.freeGPU
sync Data
Returns void
Inherited from Drawable.syncData
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
Inherited from Drawable.updateVisibility
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.
Inherited from Drawable.setMatrixUpdated
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
Inherited from Drawable.notifySceneChange
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
Inherited from Drawable.setMatrixDirty
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
Inherited from Drawable.updateWorldRenderData
- updateID: number
is Flipped
If there are zero or two negative numbers in xyz, return false, otherwise return true.
Returns boolean
Inherited from Drawable.isFlipped
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
Inherited from Drawable.applyMatrix
- 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
Inherited from Drawable.applyQuaternion
- 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
Inherited from Drawable.setRotationFromAxisAngle
- 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
Inherited from Drawable.setRotationFromEuler
- euler: Euler
set Rotation From Matrix
Calls setFromRotationMatrix (m) on the Quaternion.
Parameters
- m: Matrix4
Euler angle specifying rotation amount.
Returns void
Inherited from Drawable.setRotationFromMatrix
- m: Matrix4
set Rotation From Quaternion
Copy the given quaternion to object's quaternion .
Parameters
- q: Quaternion
Euler angle specifying rotation amount.
Returns void
Inherited from Drawable.setRotationFromQuaternion
- 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
Inherited from Drawable.rotateOnAxis
- 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
Inherited from Drawable.rotateOnWorldAxis
- axis: Vector3
rotate X
Rotates the object around x axis in local space.
Parameters
- angle: number
The angle to rotate in radians.
Returns this
Inherited from Drawable.rotateX
- angle: number
rotate Y
Rotates the object around x axis in local space.
Parameters
- angle: number
The angle to rotate in radians.
Returns this
Inherited from Drawable.rotateY
- angle: number
rotate Z
Rotates the object around x axis in local space.
Parameters
- angle: number
The angle to rotate in radians.
Returns this
Inherited from Drawable.rotateZ
- 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
Inherited from Drawable.translateOnAxis
- axis: Vector3
translate X
Translates object along x axis in object space by distance units.
Parameters
- distance: number
The distance to translate.
Returns this
Inherited from Drawable.translateX
- distance: number
translate Y
Translates object along y axis in object space by distance units.
Parameters
- distance: number
The distance to translate.
Returns this
Inherited from Drawable.translateY
- distance: number
translate Z
Translates object along z axis in object space by distance units.
Parameters
- distance: number
The distance to translate.
Returns this
Inherited from Drawable.translateZ
- 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
Inherited from Drawable.lookAt
- _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
Inherited from Drawable.lookAtLocalPoint
- _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
Inherited from Drawable.add
remove
Remove the specified object form children.
Parameters
- object: Object3D
The object which needs to be removed.
Returns this
Inherited from Drawable.remove
- object: Object3D
remove From Parent
Returns void
Inherited from Drawable.removeFromParent
remove All Children
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
Inherited from Drawable.removeObjects
- 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
Inherited from Drawable.getObjectById
- 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
Inherited from Drawable.getObjectByName
- 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
Inherited from Drawable.getObjectByProperty
- 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
Inherited from Drawable.getWorldQuaternion
- 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
Inherited from Drawable.traverse
- 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
Inherited from Drawable.traverseWithChildrenSkip
- 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
Inherited from Drawable.traverseVisible
- 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
Inherited from Drawable.traverseAncestors
- callback: (object: Object3D) => any
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
Inherited from Drawable.updateMatrixWorld
- 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
Inherited from Drawable.updateWorldMatrix
- 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
Inherited from Drawable.getUUID
get Materials
Returns readonly M[]
Inherited from Drawable.getMaterials
get Material Count
Returns number
Inherited from Drawable.getMaterialCount
set Material
Add a new material into this object. If use this method, please make sure that the material| material has set to Array.
Parameters
- material: M
a new material which is set.
- index: number
the target position in the Array.
Returns this
Inherited from Drawable.setMaterial
- material: M
set Materials
set Only Material
expect Only Material
Expect this drawable only has one material, and return it.
Returns M
Inherited from Drawable.expectOnlyMaterial
check If Only Material
Parameters
- innerChecker: (m: Material) => boolean
Returns boolean
Inherited from Drawable.checkIfOnlyMaterial
for Each Material
Do something for every material| material whatever it is an instance or array.
Parameters
- v: (m: M) => any
Returns void
Inherited from Drawable.forEachMaterial
update Boundings
update the data of bounding box and bounding sphere, set dirty mark to false.
Returns void
Inherited from Drawable.updateBoundings
_ update Matrix By View Independent Scale
Parameters
- camera: Camera3D
- viewHeight: number
Returns void
Inherited from Drawable._updateMatrixByViewIndependentScale
update Matrix
Update the matrix local transform. Override
Returns void
Inherited from Drawable.updateMatrix
_ clear View Independent Override Scale
Returns void
Inherited from Drawable._clearViewIndependentOverrideScale
clear Change Mark
Set all changing mark, such as geometryChanged| geometryChanged, materialChanged| materialChanged and extended mark .
Returns void
Inherited from Drawable.clearChangeMark
raycast
This method need override in derived classes to give a special calculation for picking feature.
Parameters
- raycaster: Raycaster
- intersects: Intersection[]
Returns void
Remarks
See Raycaster for more detail.
Inherited from Drawable.raycast
reset Render Entity
Clean render data for optimization.
Returns void
Inherited from Drawable.resetRenderEntity
update Render Entity
Update render data for optimization. This method is used to assign data from geometry| geometry and material| material to renderGeometry| renderGeometry and renderMaterial| renderMaterial.
Returns void
Inherited from Drawable.updateRenderEntity
refresh Scene Reference
set Material Changed
If user changes material| material for drawable, use this method to refresh corresponding states.
Returns void
Inherited from Drawable.setMaterialChanged
use Geometry Groups When Only Has One Material
Returns this
Inherited from Drawable.useGeometryGroupsWhenOnlyHasOneMaterial
destroy All Resources Owned
Returns void
Inherited from Drawable.destroyAllResourcesOwned
free All Gpu Resource Owned
Returns void
Inherited from Drawable.freeAllGpuResourceOwned
class Name
The name of instance's class.
Returns string
Overrides Drawable.className
update Render Info
Update the data which need be changed according to the camera's state and attributes of Drawable.updateRenderInfo| Drawable before drawing this object.
Parameters
- camera: Camera3D
the camera which is used in current frame.
- viewHeight: number
the height of canvas.
Returns void
Overrides Drawable.updateRenderInfo
- camera: Camera3D
set Geometry Changed
If user change the data of geometry, use this method to refresh the data.
Returns void
Overrides Drawable.setGeometryChanged
on Referenced Geometry Content Change
copy
clone
destroy
Returns void
Overrides Drawable.destroy
raycast Js Impl
Get intersections between a casted Ray| ray and this Mesh. The method intersectObject() will call this method, but the results are not ordered.
Parameters
- raycaster: Raycaster
the instance of Raycaster is used to get the data for calculation.
- intersects: Intersection[]
the result will be stored here.
Returns void
Overrides Drawable.raycastJsImpl
- raycaster: Raycaster
mark Business Tag
Parameters
- v: string
Returns this
Inherited from Drawable.markBusinessTag
is Destroyed
Returns boolean
Inherited from Drawable.isDestroyed
validate
Returns void
Inherited from Drawable.validate
on
once
has
off
emit
Active the event and call the registered listener.
Parameters
- type: EventType<never>
Returns void
Inherited from Drawable.emit
clear All Listeners
Removes all listeners from listening list.
Returns void
Inherited from Drawable.clearAllListeners
This class is used to connect every three points into a triangle and draws every meshes as corresponding material in the scene.