Bone

Class used to store bone information

see

http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons

Hierarchy

Implements

Index

Constructors

constructor

Find examples in Playground
  • Create a new bone

    Parameters

    • name: string

      defines the bone name

    • skeleton: Skeleton

      defines the parent skeleton

    • Optional parentBone: Nullable<Bone>

      defines the parent (can be null if the bone is the root)

    • Optional localMatrix: Nullable<Matrix>

      defines the local matrix

    • Optional restPose: Nullable<Matrix>

      defines the rest pose matrix

    • Optional baseMatrix: Nullable<Matrix>

      defines the base matrix

    • Optional index: Nullable<number>

      defines index of the bone in the hiearchy

    Returns Bone

Properties

animationPropertiesOverride

Find examples in Playground
animationPropertiesOverride: Nullable<AnimationPropertiesOverride>

Gets the animation properties override

animations

Find examples in Playground
animations: Animation[]

Gets the animations associated with this bone

behaviors

Find examples in Playground
behaviors: Behavior<Node>[]

Gets the list of attached behaviors

see

http://doc.babylonjs.com/features/behaviour

children

Find examples in Playground
children: Bone[]

Gets the list of child bones

doNotSerialize

Find examples in Playground
doNotSerialize: boolean

Gets or sets a boolean used to define if the node must be serialized

id

Find examples in Playground
id: string

Gets or sets the id of the node

length

Find examples in Playground
length: number

Gets or sets bone length

metadata

Find examples in Playground
metadata: any

Gets or sets an object used to store user defined information for the node

name

Find examples in Playground
name: string

defines the bone name

onDispose

Find examples in Playground
onDispose: function

Sets a callback that will be raised when the node will be disposed

Type declaration

    • (): void
    • Returns void

onDisposeObservable

Find examples in Playground
onDisposeObservable: Observable<Node>

An event triggered when the mesh is disposed

onReady

Find examples in Playground
onReady: function

Callback raised when the node is ready to be used

Type declaration

    • (node: Node): void
    • Parameters

      Returns void

parent

Find examples in Playground
parent: Nullable<Node>

Gets or sets the parent of the node

position

Find examples in Playground
position: Vector3

Gets or sets current position (in local space)

reservedDataStore

Find examples in Playground
reservedDataStore: any

For internal use only. Please do not use.

rotation

Find examples in Playground
rotation: Vector3

Gets or sets current rotation (in local space)

rotationQuaternion

Find examples in Playground
rotationQuaternion: Quaternion

Gets or sets current rotation quaternion (in local space)

scaling

Find examples in Playground
scaling: Vector3

Gets or sets current scaling (in local space)

state

Find examples in Playground
state: string

Gets or sets a string used to store user defined state for the node

uniqueId

Find examples in Playground
uniqueId: number

Gets or sets the unique id of the node

worldMatrixFromCache

Find examples in Playground
worldMatrixFromCache: Matrix

Returns directly the latest state of the mesh World matrix. A Matrix is returned.

Methods

addBehavior

Find examples in Playground

beginAnimation

Find examples in Playground
  • beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: function): Nullable<Animatable>
  • Will start the animation sequence

    Parameters

    • name: string

      defines the range frames for animation sequence

    • Optional loop: boolean

      defines if the animation should loop (false by default)

    • Optional speedRatio: number

      defines the speed factor in which to run the animation (1 by default)

    • Optional onAnimationEnd: function

      defines a function to be executed when the animation ended (undefined by default)

        • (): void
        • Returns void

    Returns Nullable<Animatable>

    the object created for this animation. If range does not exist, it will return null

computeAbsoluteTransforms

Find examples in Playground
  • computeAbsoluteTransforms(): void
  • Compute the absolute transforms of this bone and its children

    Returns void

computeWorldMatrix

Find examples in Playground
  • computeWorldMatrix(force?: boolean): Matrix
  • Computes the world matrix of the node

    Parameters

    • Optional force: boolean

      defines if the cache version should be invalidated forcing the world matrix to be created from scratch

    Returns Matrix

    the world matrix

copyAnimationRange

Find examples in Playground
  • copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean
  • Copy an animation range from another bone

    Parameters

    • source: Bone

      defines the source bone

    • rangeName: string

      defines the range name to copy

    • frameOffset: number

      defines the frame offset

    • Optional rescaleAsRequired: boolean

      defines if rescaling must be applied if required

    • Optional skelDimensionsRatio: Nullable<Vector3>

      defines the scaling ratio

    Returns boolean

    true if operation was successful

createAnimationRange

Find examples in Playground
  • createAnimationRange(name: string, from: number, to: number): void
  • Creates an animation range for this node

    Parameters

    • name: string

      defines the name of the range

    • from: number

      defines the starting key

    • to: number

      defines the end key

    Returns void

deleteAnimationRange

Find examples in Playground
  • deleteAnimationRange(name: string, deleteFrames?: boolean): void
  • Delete a specific animation range

    Parameters

    • name: string

      defines the name of the range to delete

    • Optional deleteFrames: boolean

      defines if animation frames from the range must be deleted as well

    Returns void

dispose

Find examples in Playground
  • dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void
  • Releases resources associated with this node.

    Parameters

    • Optional doNotRecurse: boolean

      Set to true to not recurse into each children (recurse into each children by default)

    • Optional disposeMaterialAndTextures: boolean

      Set to true to also dispose referenced materials and textures (false by default)

    Returns void

getAbsolutePosition

Find examples in Playground
  • Get the absolute position of the bone (world space)

    Parameters

    Returns Vector3

    The absolute position of the bone

getAbsolutePositionFromLocal

Find examples in Playground
  • Get the world position of a point that is in the local space of the bone

    Parameters

    Returns Vector3

    The world position

getAbsolutePositionFromLocalToRef

Find examples in Playground
  • Get the world position of a point that is in the local space of the bone and copy it to the result param

    Parameters

    • position: Vector3

      The local position

    • mesh: AbstractMesh | null | undefined

      The mesh that this bone is attached to

    • result: Vector3

      The vector3 that the world position should be copied to

    Returns void

getAbsolutePositionToRef

Find examples in Playground
  • Copy the absolute position of the bone (world space) to the result param

    Parameters

    • mesh: AbstractMesh

      The mesh that this bone is attached to

    • result: Vector3

      The vector3 to copy the absolute position to

    Returns void

getAbsoluteTransform

Find examples in Playground
  • getAbsoluteTransform(): Matrix
  • Gets the absolute transform matrix (ie base matrix * parent world matrix)

    Returns Matrix

    a matrix

getAnimationByName

Find examples in Playground
  • Get an animation by name

    Parameters

    • name: string

      defines the name of the animation to look for

    Returns Nullable<Animation>

    null if not found else the requested animation

getAnimationRange

Find examples in Playground
  • Get an animation range by name

    Parameters

    • name: string

      defines the name of the animation range to look for

    Returns Nullable<AnimationRange>

    null if not found else the requested animation range

getBaseMatrix

Find examples in Playground
  • Gets the base matrix (initial matrix which remains unchanged)

    Returns Matrix

    a matrix

getBehaviorByName

Find examples in Playground

getChildMeshes

Find examples in Playground
  • getChildMeshes(directDescendantsOnly?: boolean, predicate?: function): AbstractMesh[]
  • Get all child-meshes of this node

    Parameters

    • Optional directDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered

    • Optional predicate: function

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    Returns AbstractMesh[]

    an array of AbstractMesh

getChildTransformNodes

Find examples in Playground
  • getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: function): TransformNode[]
  • Get all child-transformNodes of this node

    Parameters

    • Optional directDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered

    • Optional predicate: function

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    Returns TransformNode[]

    an array of TransformNode

getChildren

Find examples in Playground
  • getChildren(predicate?: function, directDescendantsOnly?: boolean): Node[]
  • Get all direct children of this node

    Parameters

    • Optional predicate: function

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    • Optional directDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)

    Returns Node[]

    an array of Node

getClassName

Find examples in Playground
  • getClassName(): string
  • Gets a string idenfifying the name of the class

    Returns string

    "Node" string

getDescendants

Find examples in Playground
  • getDescendants(directDescendantsOnly?: boolean, predicate?: function): Node[]
  • Will return all nodes that have this node as ascendant

    Parameters

    • Optional directDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered

    • Optional predicate: function

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    Returns Node[]

    all children nodes of all types

getDirection

Find examples in Playground
  • Get the world direction from an axis that is in the local space of the bone

    Parameters

    • localAxis: Vector3

      The local direction that is used to compute the world direction

    • Optional mesh: Nullable<AbstractMesh>

      The mesh that this bone is attached to

    Returns Vector3

    The world direction

getDirectionToRef

Find examples in Playground
  • Copy the world direction to a vector3 from an axis that is in the local space of the bone

    Parameters

    • localAxis: Vector3

      The local direction that is used to compute the world direction

    • mesh: AbstractMesh | null | undefined

      The mesh that this bone is attached to

    • result: Vector3

      The vector3 that the world direction will be copied to

    Returns void

getEngine

Find examples in Playground

getInvertedAbsoluteTransform

Find examples in Playground
  • getInvertedAbsoluteTransform(): Matrix
  • Gets the inverse of the absolute transform matrix. This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)

    Returns Matrix

    a matrix

getLocalMatrix

Find examples in Playground
  • Gets the local matrix

    Returns Matrix

    a matrix

getLocalPositionFromAbsolute

Find examples in Playground
  • Get the local position of a point that is in world space

    Parameters

    Returns Vector3

    The local position

getLocalPositionFromAbsoluteToRef

Find examples in Playground
  • Get the local position of a point that is in world space and copy it to the result param

    Parameters

    • position: Vector3

      The world position

    • mesh: AbstractMesh | null | undefined

      The mesh that this bone is attached to

    • result: Vector3

      The vector3 that the local position should be copied to

    Returns void

getParent

Find examples in Playground
  • Gets parent bone

    Returns Nullable<Bone>

    a bone or null if the bone is the root of the bone hierarchy

getPosition

Find examples in Playground
  • Get the position of the bone in local or world space

    Parameters

    • Optional space: Space

      The space that the returned position is in

    • Optional mesh: Nullable<AbstractMesh>

      The mesh that this bone is attached to. This is only used in world space

    Returns Vector3

    The position of the bone

getPositionToRef

Find examples in Playground
  • Copy the position of the bone to a vector3 in local or world space

    Parameters

    • space: Space | undefined

      The space that the returned position is in

    • mesh: Nullable<AbstractMesh>

      The mesh that this bone is attached to. This is only used in world space

    • result: Vector3

      The vector3 to copy the position to

    Returns void

getRestPose

Find examples in Playground
  • Gets the rest pose matrix

    Returns Matrix

    a matrix

getRotation

Find examples in Playground
  • Get the euler rotation of the bone in local or world space

    Parameters

    • Optional space: Space

      The space that the rotation should be in

    • Optional mesh: Nullable<AbstractMesh>

      The mesh that this bone is attached to. This is only used in world space

    Returns Vector3

    The euler rotation

getRotationMatrix

Find examples in Playground
  • Get the rotation matrix of the bone in local or world space

    Parameters

    • space: Space | undefined

      The space that the rotation should be in

    • mesh: AbstractMesh

      The mesh that this bone is attached to. This is only used in world space

    Returns Matrix

    The rotation matrix

getRotationMatrixToRef

Find examples in Playground
  • Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space

    Parameters

    • space: Space | undefined

      The space that the rotation should be in

    • mesh: AbstractMesh

      The mesh that this bone is attached to. This is only used in world space

    • result: Matrix

      The quaternion that the rotation should be copied to

    Returns void

getRotationQuaternion

Find examples in Playground
  • Get the quaternion rotation of the bone in either local or world space

    Parameters

    • Optional space: Space

      The space that the rotation should be in

    • Optional mesh: Nullable<AbstractMesh>

      The mesh that this bone is attached to. This is only used in world space

    Returns Quaternion

    The quaternion rotation

getRotationQuaternionToRef

Find examples in Playground
  • Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space

    Parameters

    • space: Space | undefined

      The space that the rotation should be in

    • mesh: AbstractMesh | null | undefined

      The mesh that this bone is attached to. This is only used in world space

    • result: Quaternion

      The quaternion that the rotation should be copied to

    Returns void

getRotationToRef

Find examples in Playground
  • Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space

    Parameters

    • space: Space | undefined

      The space that the rotation should be in

    • mesh: AbstractMesh | null | undefined

      The mesh that this bone is attached to. This is only used in world space

    • result: Vector3

      The vector3 that the rotation should be copied to

    Returns void

getScale

Find examples in Playground
  • Gets the current scaling in local space

    Returns Vector3

    the current scaling vector

getScaleToRef

Find examples in Playground
  • getScaleToRef(result: Vector3): void
  • Gets the current scaling in local space and stores it in a target vector

    Parameters

    • result: Vector3

      defines the target vector

    Returns void

getScene

Find examples in Playground

getSkeleton

Find examples in Playground
  • Gets the parent skeleton

    Returns Skeleton

    a skeleton

getWorldMatrix

Find examples in Playground
  • Gets a matrix used to store world matrix (ie. the matrix sent to shaders)

    Returns Matrix

isDescendantOf

Find examples in Playground
  • isDescendantOf(ancestor: Node): boolean
  • Is this node a descendant of the given node? The function will iterate up the hierarchy until the ancestor was found or no more parents defined

    Parameters

    • ancestor: Node

      defines the parent node to inspect

    Returns boolean

    a boolean indicating if this node is a descendant of the given node

isDisposed

Find examples in Playground
  • isDisposed(): boolean
  • Gets a boolean indicating if the node has been disposed

    Returns boolean

    true if the node was disposed

isEnabled

Find examples in Playground
  • isEnabled(checkAncestors?: boolean): boolean
  • Is this node enabled? If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true

    Parameters

    • Optional checkAncestors: boolean

      indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors

    Returns boolean

    whether this node (and its parent) is enabled

isReady

Find examples in Playground
  • isReady(completeCheck?: boolean): boolean
  • Is this node ready to be used/rendered

    Parameters

    • Optional completeCheck: boolean

      defines if a complete check (including materials and lights) has to be done (false by default)

    Returns boolean

    true if the node is ready

linkTransformNode

Find examples in Playground
  • Links with the given transform node. The local matrix of this bone is copied from the transform node every frame.

    Parameters

    Returns void

markAsDirty

Find examples in Playground
  • markAsDirty(): void
  • Flag the bone as dirty (Forcing it to update everything)

    Returns void

removeBehavior

Find examples in Playground

returnToRest

Find examples in Playground
  • returnToRest(): void
  • Sets the local matrix to rest pose matrix

    Returns void

rotate

Find examples in Playground
  • Add a rotation to the bone on an axis in local or world space

    Parameters

    • axis: Vector3

      The axis to rotate the bone on

    • amount: number

      The amount to rotate the bone

    • Optional space: Space

      The space that the axis is in

    • Optional mesh: AbstractMesh

      The mesh that this bone is attached to. This is only used in world space

    Returns void

scale

Find examples in Playground
  • scale(x: number, y: number, z: number, scaleChildren?: boolean): void
  • Scale the bone on the x, y and z axes (in local space)

    Parameters

    • x: number

      The amount to scale the bone on the x axis

    • y: number

      The amount to scale the bone on the y axis

    • z: number

      The amount to scale the bone on the z axis

    • Optional scaleChildren: boolean

      sets this to true if children of the bone should be scaled as well (false by default)

    Returns void

serializeAnimationRanges

Find examples in Playground
  • serializeAnimationRanges(): any

setAbsolutePosition

Find examples in Playground
  • Set the absolute position of the bone (world space)

    Parameters

    • position: Vector3

      The position to set the bone

    • Optional mesh: AbstractMesh

      The mesh that this bone is attached to

    Returns void

setAxisAngle

Find examples in Playground
  • Set the rotation of the bone to a particular axis angle in local or world space

    Parameters

    • axis: Vector3

      The axis to rotate the bone on

    • angle: number

      The angle that the bone should be rotated to

    • Optional space: Space

      The space that the axis is in

    • Optional mesh: AbstractMesh

      The mesh that this bone is attached to. This is only used in world space

    Returns void

setEnabled

Find examples in Playground
  • setEnabled(value: boolean): void
  • Set the enabled state of this node

    Parameters

    • value: boolean

      defines the new enabled state

    Returns void

setParent

Find examples in Playground
  • setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void
  • Sets the parent bone

    Parameters

    • parent: Nullable<Bone>

      defines the parent (can be null if the bone is the root)

    • Optional updateDifferenceMatrix: boolean

      defines if the difference matrix must be updated

    Returns void

setPosition

Find examples in Playground
  • Set the postion of the bone in local or world space

    Parameters

    • position: Vector3

      The position to set the bone

    • Optional space: Space

      The space that the position is in

    • Optional mesh: AbstractMesh

      The mesh that this bone is attached to. This is only used in world space

    Returns void

setRotation

Find examples in Playground
  • Set the euler rotation of the bone in local of world space

    Parameters

    • rotation: Vector3

      The euler rotation that the bone should be set to

    • Optional space: Space

      The space that the rotation is in

    • Optional mesh: AbstractMesh

      The mesh that this bone is attached to. This is only used in world space

    Returns void

setRotationMatrix

Find examples in Playground
  • Set the rotation matrix of the bone in local of world space

    Parameters

    • rotMat: Matrix

      The rotation matrix that the bone should be set to

    • Optional space: Space

      The space that the rotation is in

    • Optional mesh: AbstractMesh

      The mesh that this bone is attached to. This is only used in world space

    Returns void

setRotationQuaternion

Find examples in Playground
  • Set the quaternion rotation of the bone in local of world space

    Parameters

    • quat: Quaternion

      The quaternion rotation that the bone should be set to

    • Optional space: Space

      The space that the rotation is in

    • Optional mesh: AbstractMesh

      The mesh that this bone is attached to. This is only used in world space

    Returns void

setScale

Find examples in Playground
  • Set the bone scaling in local space

    Parameters

    • scale: Vector3

      defines the scaling vector

    Returns void

setYawPitchRoll

Find examples in Playground
  • setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void
  • Set the yaw, pitch, and roll of the bone in local or world space

    Parameters

    • yaw: number

      The rotation of the bone on the y axis

    • pitch: number

      The rotation of the bone on the x axis

    • roll: number

      The rotation of the bone on the z axis

    • Optional space: Space

      The space that the axes of rotation are in

    • Optional mesh: AbstractMesh

      The mesh that this bone is attached to. This is only used in world space

    Returns void

translate

Find examples in Playground
  • Translate the bone in local or world space

    Parameters

    • vec: Vector3

      The amount to translate the bone

    • Optional space: Space

      The space that the translation is in

    • Optional mesh: AbstractMesh

      The mesh that this bone is attached to. This is only used in world space

    Returns void

updateMatrix

Find examples in Playground
  • updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void
  • Update the base and local matrices

    Parameters

    • matrix: Matrix

      defines the new base or local matrix

    • Optional updateDifferenceMatrix: boolean

      defines if the difference matrix must be updated

    • Optional updateLocalMatrix: boolean

      defines if the local matrix should be updated

    Returns void

Static AddNodeConstructor

Find examples in Playground
  • Add a new node constructor

    Parameters

    • type: string

      defines the type name of the node to construct

    • constructorFunc: NodeConstructor

      defines the constructor function

    Returns void

Static Construct

Find examples in Playground
  • Construct(type: string, name: string, scene: Scene, options?: any): Nullable<function>
  • Returns a node constructor based on type name

    Parameters

    • type: string

      defines the type name

    • name: string

      defines the new node name

    • scene: Scene

      defines the hosting scene

    • Optional options: any

      defines optional options to transmit to constructors

    Returns Nullable<function>

    the new constructor or null

Static ParseAnimationRanges

Find examples in Playground
  • ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void
  • Parse animation range data from a serialization object and store them into a given node

    Parameters

    • node: Node

      defines where to store the animation ranges

    • parsedNode: any

      defines the serialization object to read data from

    • scene: Scene

      defines the hosting scene

    Returns void

Generated using TypeDoc