CLASSES
TagsA - Z

AbstractMesh

NodeMesh

Description

class AbstractMesh extends Node

Constructor

new AbstractMesh(name, scene)

Parameters

Name Type Description
name string
scene Scene

Members

static OCCLUSION_TYPE_NONE : number

static OCCLUSION_TYPE_OPTIMISTIC : number

static OCCLUSION_TYPE_STRICT : number

static OCCLUSION_ALGORITHM_TYPE_ACCURATE : number

static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE : number

static BILLBOARDMODE_NONE : number

static BILLBOARDMODE_X : number

static BILLBOARDMODE_Y : number

static BILLBOARDMODE_Z : number

static BILLBOARDMODE_ALL : number

facetNb : number

Read-only : the number of facets in the mesh

partitioningSubdivisions : number

The number (integer) of subdivisions per axis in the partioning space

partitioningBBoxRatio : number

The ratio (float) to apply to the bouding box size to set to the partioning space.

Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.

isFacetDataEnabled : boolean

Read-only boolean : is the feature facetData enabled ?

onCollideObservable : Observable<AbstractMesh>

An event triggered when this mesh collides with another one

@type {BABYLON.Observable}

onCollide : () => void

onCollisionPositionChangeObservable : Observable<Vector3>

An event triggered when the collision's position changes

@type {BABYLON.Observable}

onCollisionPositionChange : () => void

onAfterWorldMatrixUpdateObservable : Observable<AbstractMesh>

An event triggered after the world matrix is updated

@type {BABYLON.Observable}

onMaterialChangedObservable : Observable<AbstractMesh>

An event triggered when material is changed

@type {BABYLON.Observable}

definedFacingForward : boolean

position : Vector3

occlusionQueryAlgorithmType : number

This property determines the type of occlusion query algorithm to run in WebGl, you can use:

AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.

or

AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.

for more info check WebGl documentations

occlusionType : number

This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:

OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.

OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.

OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.

occlusionRetryCount : number

This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.

The default value is -1 which means don't break the query and wait till the result.

isOccluded : boolean

Property isOccluded : Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not.

isOcclusionQueryInProgress : boolean

Flag to check the progress status of the query

billboardMode : number

visibility : number

alphaIndex : number

infiniteDistance : boolean

isVisible : boolean

isPickable : boolean

showBoundingBox : boolean

showSubMeshesBoundingBox : boolean

isBlocker : boolean

enablePointerMoveEvents : boolean

renderingGroupId : number

material : Material

receiveShadows : boolean

renderOutline : boolean

outlineColor : Color3

outlineWidth : number

renderOverlay : boolean

overlayColor : Color3

overlayAlpha : number

hasVertexAlpha : boolean

useVertexColors : boolean

computeBonesUsingShaders : boolean

numBoneInfluencers : number

applyFog : boolean

scalingDeterminant : number

useOctreeForRenderingSelection : boolean

useOctreeForPicking : boolean

useOctreeForCollisions : boolean

layerMask : number

alwaysSelectAsActiveMesh : boolean

True if the mesh must be rendered in any case.

actionManager : Nullable<ActionManager>

This scene's action manager

@type {BABYLON.ActionManager}

physicsImpostor : Nullable<PhysicsImpostor>

ellipsoid : Vector3

ellipsoidOffset : Vector3

collisionMask : number

collisionGroup : number

edgesWidth : number

edgesColor : Color4

subMeshes : SubMesh[]

skeleton : Nullable<Skeleton>

rotation : Vector3

Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.

If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!

Default : (0.0, 0.0, 0.0)

scaling : Vector3

Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.

Default : (1.0, 1.0, 1.0)

rotationQuaternion : Nullable<Quaternion>

Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.

It's null by default.

If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)

isBlocked : boolean

Returns true if the mesh is blocked. Used by the class Mesh.

Returns the boolean false by default.

Float32Array : undefined

useBones : boolean

worldMatrixFromCache : Matrix

Returns directly the last state of the mesh World matrix.

A Matrix is returned.

absolutePosition : Vector3

Returns the current mesh absolute position.

Retuns a Vector3.

this : ()

isWorldMatrixFrozen : boolean

True if the World matrix has been frozen.

Returns a boolean.

checkCollisions : boolean

Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.

Default false.

this : undefined

Methods

isDisposed() boolean

Boolean : true if the mesh has been disposed.

getClassName() string

Returns the string "AbstractMesh"

toString(fullDetails) string

Parameters

Name Type Description
optional fullDetails boolean

updatePoseMatrix(matrix) AbstractMesh

Copies the paramater passed Matrix into the mesh Pose matrix.

Returns the AbstractMesh.

Parameters

Name Type Description
matrix Matrix

getPoseMatrix() Matrix

Returns the mesh Pose matrix.

Returned object : Matrix

disableEdgesRendering() AbstractMesh

Disables the mesh edger rendering mode.

Returns the AbstractMesh.

enableEdgesRendering(epsilon, checkVerticesInsteadOfIndices) AbstractMesh

Enables the edge rendering mode on the mesh.

This mode makes the mesh edges visible.

Returns the AbstractMesh.

Parameters

Name Type Description
optional epsilon number
optional checkVerticesInsteadOfIndices boolean

getLOD(camera) AbstractMesh

Returns the mesh itself by default, used by the class Mesh.

Returned type : AbstractMesh

Parameters

Name Type Description
camera Camera

getTotalVertices() number

Returns 0 by default, used by the class Mesh.

Returns an integer.

getIndices() Nullable<IndicesArray>

Returns null by default, used by the class Mesh.

Returned type : integer array

getVerticesData(kind) Nullable<number[]>

Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.

Returned type : float array or Float32Array

Parameters

Name Type Description
kind string

setVerticesData(kind, data, Float32Array, updatable, stride) AbstractMesh

Sets the vertex data of the mesh geometry for the requested kind.

If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.

The data are either a numeric array either a Float32Array.

The parameter updatable is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.

The parameter stride is an optional positive integer, it is usually automatically deducted from the kind (3 for positions or normals, 2 for UV, etc).

Note that a new underlying VertexBuffer object is created each call.

If the kind is the PositionKind, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.

     * Possible `kind` values :

Parameters

Name Type Description
kind string
data number[] or Float32Array
optional updatable boolean

updateVerticesData(kind, data, Float32Array, updateExtends, makeItUnique) AbstractMesh

Updates the existing vertex data of the mesh geometry for the requested kind.

If the mesh has no geometry, it is simply returned as it is.

The data are either a numeric array either a Float32Array.

No new underlying VertexBuffer object is created.

If the kind is the PositionKind and if updateExtends is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.

If the parameter makeItUnique is true, a new global geometry is created from this positions and is set to the mesh.

     * Possible `kind` values :

Parameters

Name Type Description
kind string
data number[] or Float32Array
optional updateExtends boolean

setIndices(indices, totalVertices) AbstractMesh

Sets the mesh indices.

Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).

If the mesh has no geometry, a new Geometry object is created and set to the mesh.

This method creates a new index buffer each call.

Returns the Mesh.

Parameters

Name Type Description
indices IndicesArray
totalVertices Nullable<number>

isVerticesDataPresent(kind) boolean

Returns a boolean

Parameters

Name Type Description
kind string

getBoundingInfo() Nullable<BoundingInfo>

Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.

Returns a BoundingInfo

setBoundingInfo(boundingInfo) AbstractMesh

Sets a mesh new object BoundingInfo.

Returns the AbstractMesh.

Parameters

Name Type Description
boundingInfo BoundingInfo

getWorldMatrix() Matrix

Returns the last update of the World matrix

Returns a Matrix.

freezeWorldMatrix() AbstractMesh

Prevents the World matrix to be computed any longer.

Returns the AbstractMesh.

unfreezeWorldMatrix()

Allows back the World matrix computation.

Returns the AbstractMesh.

rotate(axis, amount, space) AbstractMesh

Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.

space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.

Note that the property rotationQuaternion is then automatically updated and the property rotation is set to (0,0,0) and no longer used.

The passed axis is also normalized.

Returns the AbstractMesh.

Parameters

Name Type Description
axis Vector3
amount number
optional space Space

rotateAround(point, axis, amount) AbstractMesh

Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.

Note that the property rotationQuaternion is then automatically updated and the property rotation is set to (0,0,0) and no longer used.

The passed axis is also normalized.

Returns the AbstractMesh.

Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm

Parameters

Name Type Description
point Vector3
axis Vector3
amount number

translate(axis, distance, space) AbstractMesh

Translates the mesh along the axis vector for the passed distance in the given space.

space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.

Returns the AbstractMesh.

Parameters

Name Type Description
axis Vector3
distance number
optional space Space

addRotation(x, y, z) AbstractMesh

Adds a rotation step to the mesh current rotation.

x, y, z are Euler angles expressed in radians.

This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.

This means this rotation is made in the mesh local space only.

It's useful to set a custom rotation order different from the BJS standard one YXZ.

Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.


mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);

Note that addRotation() accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.

Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.

Returns the AbstractMesh.

Parameters

Name Type Description
x number
y number
z number

getAbsolutePosition() Vector3

Retuns the mesh absolute position in the World.

Returns a Vector3.

setAbsolutePosition(absolutePosition) AbstractMesh

Sets the mesh absolute position in the World from a Vector3 or an Array(3).

Returns the AbstractMesh.

Parameters

Name Type Description
absolutePosition Vector3

movePOV(amountRight, amountUp, amountForward) AbstractMesh

Perform relative position change from the point of view of behind the front of the mesh.

This is performed taking into account the meshes current rotation, so you do not have to care.

Supports definition of mesh facing forward or backward.

     * Returns the [AbstractMesh](/classes/3.1/AbstractMesh).

Parameters

Name Type Description
amountRight number
amountUp number
amountForward number

calcMovePOV(amountRight, amountUp, amountForward) Vector3

Calculate relative position change from the point of view of behind the front of the mesh.

This is performed taking into account the meshes current rotation, so you do not have to care.

Supports definition of mesh facing forward or backward.

     * Returns a new [Vector3](/classes/3.1/Vector3).

Parameters

Name Type Description
amountRight number
amountUp number
amountForward number

rotatePOV(flipBack, twirlClockwise, tiltRight) AbstractMesh

Perform relative rotation change from the point of view of behind the front of the mesh.

Supports definition of mesh facing forward or backward.

     * Returns the [AbstractMesh](/classes/3.1/AbstractMesh).

Parameters

Name Type Description
flipBack number
twirlClockwise number
tiltRight number

calcRotatePOV(flipBack, twirlClockwise, tiltRight) Vector3

Calculate relative rotation change from the point of view of behind the front of the mesh.

Supports definition of mesh facing forward or backward.

     * Returns a new [Vector3](/classes/3.1/Vector3).

Parameters

Name Type Description
flipBack number
twirlClockwise number
tiltRight number

setPivotMatrix(matrix, postMultiplyPivotMatrix) AbstractMesh

Sets a new pivot matrix to the mesh.

Returns the AbstractMesh.

Parameters

Name Type Description
matrix Matrix
optional postMultiplyPivotMatrix boolean

getPivotMatrix() Matrix

Returns the mesh pivot matrix.

Default : Identity.

A Matrix is returned.

markAsDirty(property) AbstractMesh

Parameters

Name Type Description
property string

getHierarchyBoundingVectors() : Vector3 }

Return the minimum and maximum world vectors of the entire hierarchy under current mesh

computeWorldMatrix(force) Matrix

Computes the mesh World matrix and returns it.

If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.

If the parameter force is let to false (default), the current cached World matrix is returned.

If the parameter forceis set to true, the actual computation is done.

Returns the mesh World Matrix.

Parameters

Name Type Description
optional force boolean

registerAfterWorldMatrixUpdate(func) AbstractMesh

If you'd like to be called back after the mesh position, rotation or scaling has been updated.

    * Returns the [AbstractMesh](/classes/3.1/AbstractMesh).

Parameters

Name Type Description
func (mesh: AbstractMesh) => void : callback function to add

unregisterAfterWorldMatrixUpdate(func) AbstractMesh

Removes a registered callback function.

Returns the AbstractMesh.

Parameters

Name Type Description
func (mesh: AbstractMesh) => void

setPositionWithLocalVector(vector3) AbstractMesh

Sets the mesh position in its local space.

Returns the AbstractMesh.

Parameters

Name Type Description
vector3 Vector3

getPositionExpressedInLocalSpace() Vector3

Returns the mesh position in the local space from the current World matrix values.

Returns a new Vector3.

locallyTranslate(vector3) AbstractMesh

Translates the mesh along the passed Vector3 in its local space.

Returns the AbstractMesh.

Parameters

Name Type Description
vector3 Vector3

lookAt(targetPoint, yawCor, pitchCor, rollCor, space) AbstractMesh

Parameters

Name Type Description
targetPoint Vector3
optional yawCor number
optional pitchCor number
optional rollCor number

attachToBone(bone, affectedMesh) AbstractMesh

Parameters

Name Type Description
bone Bone
affectedMesh AbstractMesh

detachFromBone() AbstractMesh

isInFrustum(frustumPlanes) boolean

Returns true if the mesh is within the frustum defined by the passed array of planes.

A mesh is in the frustum if its bounding box intersects the frustum.

Boolean returned.

Parameters

Name Type Description
frustumPlanes Plane[]

isCompletelyInFrustum(frustumPlanes) boolean

Returns true if the mesh is completely in the frustum defined be the passed array of planes.

A mesh is completely in the frustum if its bounding box it completely inside the frustum.

Boolean returned.

Parameters

Name Type Description
frustumPlanes Plane[]

intersectsMesh(mesh, SolidParticle, precise, includeDescendants) boolean

True if the mesh intersects another mesh or a SolidParticle object.

Unless the parameter precise is set to true the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)

includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes

Returns a boolean.

Parameters

Name Type Description
mesh AbstractMesh or SolidParticle
optional precise boolean
optional includeDescendants boolean

intersectsPoint(point) boolean

Returns true if the passed point (Vector3) is inside the mesh bounding box.

Returns a boolean.

Parameters

Name Type Description
point Vector3

getPhysicsImpostor() Nullable<PhysicsImpostor>

getPositionInCameraSpace(camera) Vector3

Parameters

Name Type Description
optional camera Nullable<Camera>

getDistanceToCamera(camera) number

Returns the distance from the mesh to the active camera.

Returns a float.

Parameters

Name Type Description
optional camera Nullable<Camera>

applyImpulse(force, contactPoint) AbstractMesh

Parameters

Name Type Description
force Vector3
contactPoint Vector3

setPhysicsLinkWith(otherMesh, pivot1, pivot2, options) AbstractMesh

Parameters

Name Type Description
otherMesh Mesh
pivot1 Vector3
pivot2 Vector3

moveWithCollisions(displacement) AbstractMesh

Parameters

Name Type Description
displacement Vector3

createOrUpdateSubmeshesOctree(maxCapacity, maxDepth) Octree<SubMesh>

This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.

Please note that you must have a decent number of submeshes to get performance improvements when using an octree.

Returns an Octree of submeshes.

Parameters

Name Type Description
optional maxCapacity number
optional maxDepth number

intersects(ray, fastCheck) PickingInfo

Checks if the passed Ray intersects with the mesh.

Returns an object PickingInfo.

Parameters

Name Type Description
ray Ray
optional fastCheck boolean

clone(name, newParent, doNotCloneChildren) Nullable<AbstractMesh>

Clones the mesh, used by the class Mesh.

Just returns null for an AbstractMesh.

Parameters

Name Type Description
name string
newParent Node
optional doNotCloneChildren boolean

releaseSubMeshes() AbstractMesh

Disposes all the mesh submeshes.

Returns the AbstractMesh.

dispose(doNotRecurse) void

Disposes the AbstractMesh.

Some internal references are kept for further use.

By default, all the mesh children are also disposed unless the parameter doNotRecurse is set to true.

Returns nothing.

Parameters

Name Type Description
optional doNotRecurse boolean

getDirection(localAxis) Vector3

Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.

This Vector3 is expressed in the World space.

Parameters

Name Type Description
localAxis Vector3

getDirectionToRef(localAxis, result) AbstractMesh

Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.

localAxis is expressed in the mesh local space.

result is computed in the Wordl space from the mesh World matrix.

Returns the AbstractMesh.

Parameters

Name Type Description
localAxis Vector3
result Vector3

setPivotPoint(point, space) AbstractMesh

Parameters

Name Type Description
point Vector3
optional space Space

getPivotPoint() Vector3

Returns a new Vector3 set with the mesh pivot point coordinates in the local space.

getPivotPointToRef(result) AbstractMesh

Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.

Returns the AbstractMesh.

Parameters

Name Type Description
result Vector3

getAbsolutePivotPoint() Vector3

Returns a new Vector3 set with the mesh pivot point World coordinates.

setParent(mesh) AbstractMesh

Defines the passed mesh as the parent of the current mesh.

Returns the AbstractMesh.

Parameters

Name Type Description
mesh Nullable<AbstractMesh>

addChild(mesh) AbstractMesh

Adds the passed mesh as a child to the current mesh.

Returns the AbstractMesh.

Parameters

Name Type Description
mesh AbstractMesh

removeChild(mesh) AbstractMesh

Removes the passed mesh from the current mesh children list.

Returns the AbstractMesh.

Parameters

Name Type Description
mesh AbstractMesh

getAbsolutePivotPointToRef(result) AbstractMesh

Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.

Returns the AbstractMesh.

Parameters

Name Type Description
result Vector3

updateFacetData() AbstractMesh

Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.

This method can be called within the render loop.

You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation.

Returns the AbstractMesh.

getFacetLocalNormals() Vector3[]

Returns the facetLocalNormals array.

The normals are expressed in the mesh local space.

getFacetLocalPositions() Vector3[]

Returns the facetLocalPositions array.

The facet positions are expressed in the mesh local space.

getFacetLocalPartitioning() number[][]

Returns the facetLocalPartioning array.

getFacetPosition(i) Vector3

Returns the i-th facet position in the world system.

This method allocates a new Vector3 per call.

Parameters

Name Type Description
i number

getFacetPositionToRef(i, ref) AbstractMesh

Sets the reference Vector3 with the i-th facet position in the world system.

Returns the AbstractMesh.

Parameters

Name Type Description
i number
ref Vector3

getFacetNormal(i) Vector3

Returns the i-th facet normal in the world system.

This method allocates a new Vector3 per call.

Parameters

Name Type Description
i number

getFacetNormalToRef(i, ref)

Sets the reference Vector3 with the i-th facet normal in the world system.

Returns the AbstractMesh.

Parameters

Name Type Description
i number
ref Vector3

getFacetsAtLocalCoordinates(x, y, z) Nullable<number[]>

Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system).

Parameters

Name Type Description
x number
y number
z number

getClosestFacetAtCoordinates(x, y, z, projected, checkFace, facing) Nullable<number>

Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.

If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.

If checkFace is true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned.

If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.

If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position.

Parameters

Name Type Description
x number
y number
z number
optional projected Vector3
optional checkFace boolean

getClosestFacetAtLocalCoordinates(x, y, z, projected, checkFace, facing) Nullable<number>

Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.

If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.

If checkFace is true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned.

If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.

If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position.

Parameters

Name Type Description
x number
y number
z number
optional projected Vector3
optional checkFace boolean

getFacetDataParameters() any

Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()

disableFacetData() AbstractMesh

Disables the feature FacetData and frees the related memory.

Returns the AbstractMesh.

createNormals(updatable) void

Creates new normals data for the mesh.

Parameters

Name Type Description
updatable boolean .