CLASSES
TagsA - Z

AbstractMesh

NodeMesh

Description

class AbstractMesh extends Node

This class represents a mesh which can't be instantiated

Constructor

new AbstractMesh(name, scene)

The AbstractMesh constructor

Parameters

Name Type Description
name string The new name
scene Scene The scene where the mesh is.

Members

static BILLBOARDMODE_NONE : number

The billboard Mode None, the object is normal by default

@default AbstractMesh.BILLBOARDMODE_NONE

static BILLBOARDMODE_X : number

The billboard Mode X

@default AbstractMesh.BILLBOARDMODE_X

static BILLBOARDMODE_Y : number

The billboard Mode Y

@default AbstractMesh.BILLBOARDMODE_Y

static BILLBOARDMODE_Z : number

The billboard Mode Z

@default AbstractMesh.BILLBOARDMODE_Z

static BILLBOARDMODE_ALL : number

The billboard Mode

@default AbstractMesh.BILLBOARDMODE_ALL

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}

definedFacingForward : boolean

position : Vector3

The mesh position

@default Vector3(0, 0, 0)

billboardMode : number

The mesh billboardMode

@default AbstractMesh.BILLBOARDMODE_NONE

visibility : number

The mesh visibility

@default 1.0

alphaIndex : number

infiniteDistance : boolean

Is infinite distance

@default false

isVisible : boolean

Is visible

@default true

isPickable : boolean

Is pickable

@default true

showBoundingBox : boolean

Show bounding box

@default false

showSubMeshesBoundingBox : boolean

Show submeshes Bounding box

@default false

isBlocker : boolean

Is blocker

@default false

renderingGroupId : number

The rendering group ID

@default 0

material : Material

The material

receiveShadows : boolean

Receive shadows

@default false

renderOutline : boolean

Render Outline

outlineColor : Color3

outline color

outlineWidth : number

outline Width

renderOverlay : boolean

overlayColor : Color3

overlayAlpha : number

hasVertexAlpha : boolean

useVertexColors : boolean

computeBonesUsingShaders : boolean

numBoneInfluencers : number

applyFog : boolean

scalingDeterminant : number

useOctreeForRenderingSelection : boolean

Is use octree for rendering selection

@default true

useOctreeForPicking : boolean

Is use octree for picking

@default true

useOctreeForCollisions : boolean

Is use octree for collisions

@default true

layerMask : number

The layer mask

@default 0xFFFFFFFF

alwaysSelectAsActiveMesh : boolean

True if the mesh must be rendered in any case.

actionManager : ActionManager

This scene's action manager

@type {BABYLON.ActionManager}

physicsImpostor : undefined

ellipsoid : Vector3

Ellipsoid

ellipsoidOffset : Vector3

Ellipsoid offset

collisionMask : number

collisionGroup : number

edgesWidth : number

edgesColor : Color4

subMeshes : SubMesh[]

subMeshes

skeleton : Skeleton

The 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 : 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

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 @param 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() IndicesArray

Returns null by default, used by the class Mesh.

Returned type : integer array

getVerticesData(kind) 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 @param kind

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

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 @param kind
data number[] or Float32Array
optional updatable boolean

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

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 @param kind
data number[] or Float32Array
optional updateExtends boolean

setIndices(indices, totalVertices) Mesh

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
optional totalVertices number

isVerticesDataPresent(kind) boolean

Returns a boolean

Parameters

Name Type Description
kind string @param kind

getBoundingInfo() 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 the rotation axis
amount number the rotation angle
optional space Space local or global

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 the rotation axis
distance number the distance from the origin to the next position
optional space Space local or global

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 @param absolutePosition

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.0/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.0/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.0/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.0/Vector3).

Parameters

Name Type Description
flipBack number
twirlClockwise number
tiltRight number

setPivotMatrix(matrix) AbstractMesh

Sets a new pivot matrix to the mesh.

Returns the AbstractMesh.

Parameters

Name Type Description
matrix Matrix @param matrix

getPivotMatrix() Matrix

Returns the mesh pivot matrix.

Default : Identity.

A Matrix is returned.

markAsDirty(property) AbstractMesh

Parameters

Name Type Description
property string @param property

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 the force direction

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.0/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 the translation contact information

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 the translation contact information

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

Parameters

Name Type Description
targetPoint Vector3 The position (must be in same space as current mesh) to look at
optional yawCor number yaw (y-axis) correction in radians
optional pitchCor number pitch (x-axis) correction in radians
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[] is between near frustum plan and far frustum plan view

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[] is between near frustum plan and far frustum plan view

intersectsMesh(mesh, SolidParticle, precise) 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)

Returns a boolean.

Parameters

Name Type Description
mesh AbstractMesh or SolidParticle The mesh
optional precise boolean If true, the abstractMesh is closer to the mesh,

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 the intersect point

getPhysicsImpostor() PhysicsImpostor

Get a physics impostor

getPositionInCameraSpace(camera) Vector3

Parameters

Name Type Description
optional camera Camera

getDistanceToCamera(camera) number

Returns the distance from the mesh to the active camera.

Returns a float.

Parameters

Name Type Description
optional camera Camera

applyImpulse(force, contactPoint) AbstractMesh

Apply a force

Parameters

Name Type Description
force Vector3 the force direction
contactPoint Vector3 the contact point

setPhysicsLinkWith(otherMesh, pivot1, pivot2, options) AbstractMesh

Link the impostor in order to keep meshes linked

Parameters

Name Type Description
otherMesh Mesh the impostor
pivot1 Vector3 link the impostor with this mesh
pivot2 Vector3 link the impostor with this mesh

moveWithCollisions(velocity) AbstractMesh

Move a mesh

Parameters

Name Type Description
velocity Vector3 change the velocity

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 @param maxCapacity
optional maxDepth number @param maxDepth

intersects(ray, fastCheck) PickingInfo

Checks if the passed Ray intersects with the mesh.

Returns an object PickingInfo.

Parameters

Name Type Description
ray Ray The ray
optional fastCheck boolean if true, stop at the first result

clone(name, newParent, doNotCloneChildren) AbstractMesh

Clones the mesh, used by the class Mesh.

Just returns null for an AbstractMesh.

Parameters

Name Type Description
name string The new name
newParent Node @param newParent
optional doNotCloneChildren boolean Set true if you want to clone children, false otherwise

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 @param doNotRecurse

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 the intersect point
optional space Space local or global

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 AbstractMesh The mesh

addChild(mesh) AbstractMesh

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

Returns the AbstractMesh.

Parameters

Name Type Description
mesh AbstractMesh The mesh

removeChild(mesh) AbstractMesh

Removes the passed mesh from the current mesh children list.

Returns the AbstractMesh.

Parameters

Name Type Description
mesh AbstractMesh The mesh

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) 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) 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) 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 .