API

Class TransformNode

A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.

Hierarchy (View Summary)

Index
animations: Animation[] = []

Gets a list of Animations associated with the node

customMarkAsDirty: () => void

Allow user to specify custom mechanism for mark as dirty

id: string

Gets or sets the id of the node

ignoreNonUniformScaling: boolean = false

Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored. By default the system will update normals to compensate

inspectableCustomProperties: IInspectable[]

List of inspectable custom properties (used by the Inspector)

metadata: any = null

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

name: string

Gets or sets the name of the node

onAccessibilityTagChangedObservable: Observable<Nullable<IAccessibilityTag>> = ...

Observable fired when an accessibility tag is changed

onAfterWorldMatrixUpdateObservable: Observable<TransformNode> = ...

An event triggered after the world matrix is updated

onDisposeObservable: Observable<Node> = ...

An event triggered when the mesh is disposed

onReady: Nullable<(node: Node) => void> = null

Callback raised when the node is ready to be used

physicsBody: Nullable<PhysicsBody>

Gets or sets the physics body associated with this node.

reIntegrateRotationIntoRotationQuaternion: boolean = false

Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both

reservedDataStore: any = null

For internal use only. Please do not use.

scalingDeterminant: number = 1

Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube

state: string = ""

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

uniqueId: number

Gets or sets the unique id of the node

BILLBOARDMODE_ALL: number = 7

Object will rotate to face the camera

BILLBOARDMODE_NONE: number = 0

Object will not rotate to face the camera

BILLBOARDMODE_USE_POSITION: number = 128

Object will rotate to face the camera's position instead of orientation

BILLBOARDMODE_X: number = 1

Object will rotate to face the camera but only on the x axis

BILLBOARDMODE_Y: number = 2

Object will rotate to face the camera but only on the y axis

BILLBOARDMODE_Z: number = 4

Object will rotate to face the camera but only on the z axis

BillboardUseParentOrientation: boolean = false

Child transform with Billboard flags should or should not apply parent rotation (default if off)

  • get doNotSerialize(): boolean

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

    Returns boolean

  • set doNotSerialize(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • get inheritVisibility(): boolean

    If set to true, this node, when renderable, will only be visible if its parent(s) are also visible.

    Returns boolean

    false
    
  • set inheritVisibility(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • get isVisible(): boolean

    Gets or sets a boolean indicating whether this node is visible, either this node itself when it is renderable or its renderable child nodes when inheritVisibility is true.

    Returns boolean

    true
    
  • set isVisible(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • set onDispose(callback: () => void): void

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

    Parameters

    • callback: () => void

    Returns void

  • get onEffectiveEnabledStateChangedObservable(): Observable<boolean>

    An event triggered when the effective enabled state of the node changes, i.e. whenever the value returned by isEnabled changes. Unlike onEnabledStateChangedObservable, this fires for changes caused by an ancestor's enabled state as well as this node's own state. The observable is created on first access, so no cost is incurred for nodes that never observe it.

    Returns Observable<boolean>

  • Adds the passed mesh as a child to the current mesh. The node will remain exactly where it is and its position / rotation will be updated accordingly. This method is equivalent to calling setParent().

    Parameters

    • mesh: TransformNode

      defines the child mesh

    • preserveScalingSign: boolean = false

      if true, keep scaling sign of child. Otherwise, scaling sign might change.

    Returns this

    the current mesh

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

    Parameters

    • x: number

      Rotation to add

    • y: number

      Rotation to add

    • z: number

      Rotation to add

    Returns TransformNode

    the TransformNode.

  • Will start the animation sequence

    Parameters

    • name: string

      defines the range frames for animation sequence

    • Optionalloop: boolean

      defines if the animation should loop (false by default)

    • OptionalspeedRatio: number

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

    • OptionalonAnimationEnd: () => void

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

    Returns Nullable<Animatable>

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

  • 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

  • Delete a specific animation range

    Parameters

    • name: string

      defines the name of the range to delete

    • deleteFrames: boolean = true

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

    Returns void

  • Detach the transform node if its associated with a bone

    Parameters

    • resetToPreviousParent: boolean = false

      Indicates if the parent that was in effect when attachToBone was called should be set back or if we should set parent to null instead (defaults to the latter)

    Returns TransformNode

    this object

  • Releases resources associated with this transform node.

    Parameters

    • OptionaldoNotRecurse: boolean

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

    • disposeMaterialAndTextures: boolean = false

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

    Returns void

  • Prevents the World matrix to be computed any longer. Please note that the "moral" contract is that the world matrix is not going to be updated anymore. It is up to the developer to force updates. You trade flexibility for performance. If you want to update it, you have to unfreeze it first.

    Parameters

    • newWorldMatrix: Nullable<Matrix> = null

      defines an optional matrix to use as world matrix

    • decompose: boolean = false

      defines whether to decompose the given newWorldMatrix or directly assign

    Returns TransformNode

    the TransformNode.

  • Get all child-meshes of this node

    Type Parameters

    Parameters

    • OptionaldirectDescendantsOnly: 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: false)

    • Optionalpredicate: (node: Node) => node is T

      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

    Returns T[]

    an array of AbstractMesh

  • Get all child-meshes of this node

    Parameters

    • OptionaldirectDescendantsOnly: 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: false)

    • Optionalpredicate: (node: Node) => boolean

      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

    Returns AbstractMesh[]

    an array of AbstractMesh

  • Get all direct children of this node

    Type Parameters

    Parameters

    • Optionalpredicate: (node: Node) => node is T

      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

    • OptionaldirectDescendantsOnly: 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 T[]

    an array of Node

  • Get all direct children of this node

    Parameters

    • Optionalpredicate: (node: Node) => boolean

      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

    • OptionaldirectDescendantsOnly: 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

  • Get all child-transformNodes of this node

    Parameters

    • OptionaldirectDescendantsOnly: 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

    • Optionalpredicate: (node: Node) => boolean

      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

    Returns TransformNode[]

    an array of TransformNode

  • Will return all nodes that have this node as ascendant

    Type Parameters

    Parameters

    • OptionaldirectDescendantsOnly: 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

    • Optionalpredicate: (node: Node) => node is T

      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

    Returns T[]

    all children nodes of all types

  • Will return all nodes that have this node as ascendant

    Parameters

    • OptionaldirectDescendantsOnly: 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

    • Optionalpredicate: (node: Node) => boolean

      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

    Returns Node[]

    all children nodes of all types

  • Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh. This Vector3 is expressed in the World space.

    Parameters

    • localAxis: Vector3

      axis to rotate

    Returns Vector3

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

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

    Parameters

    • includeDescendants: boolean = true

      Include bounding info from descendants as well (true by default)

    • predicate: Nullable<(abstractMesh: AbstractMesh) => boolean> = null

      defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors

    Returns { max: Vector3; min: Vector3 }

    the new bounding vectors

  • 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

  • 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

    • checkAncestors: boolean = true

      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

    To observe changes to the value returned when calling this with checkAncestors set to true (the default, i.e. the effective enabled state), subscribe to onEffectiveEnabledStateChangedObservable. To observe changes to the value returned when calling this with checkAncestors set to false (i.e. this node's own enabled state only), subscribe to onEnabledStateChangedObservable.

  • Is this node ready to be used/rendered

    Parameters

    • _completeCheck: boolean = false

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

    Returns boolean

    true if the node is ready

  • Returns boolean

    true if pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect.

  • Returns whether the transform node world matrix computation needs the camera information to be computed. This is the case when the node is a billboard or has an infinite distance for instance.

    Returns boolean

    true if the world matrix computation needs the camera information to be computed

  • Orients a mesh towards a target point. Mesh must be drawn facing user.

    Parameters

    • targetPoint: Vector3

      the position (must be in same space as current mesh) to look at

    • yawCor: number = 0

      optional yaw (y-axis) correction in radians

    • pitchCor: number = 0

      optional pitch (x-axis) correction in radians

    • rollCor: number = 0

      optional roll (z-axis) correction in radians

    • space: Space = Space.LOCAL

      the chosen space of the target

    Returns TransformNode

    the TransformNode.

  • Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)

    Parameters

    • includeDescendants: boolean = true

      Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false

    • ignoreRotation: boolean = false

      ignore rotation when computing the scale (ie. object will be axis aligned). Default is false

    • Optionalpredicate: Nullable<(node: AbstractMesh) => boolean>

      predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling

    Returns TransformNode

    the current mesh

  • Resets this nodeTransform's local matrix to Matrix.Identity().

    Parameters

    • independentOfChildren: boolean = true

      indicates if all child nodeTransform's world-space transform should be preserved.

    Returns void

  • 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 Space.LOCAL, either 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.

    Parameters

    • axis: Vector3

      the axis to rotate around

    • amount: number

      the amount to rotate in radians

    • Optionalspace: Space

      Space to rotate in (Default: local)

    Returns TransformNode

    the TransformNode.

  • Sets this transform node rotation to the given local axis.

    Parameters

    • localAxis: Vector3

      the axis in local space

    • yawCor: number = 0

      optional yaw (y-axis) correction in radians

    • pitchCor: number = 0

      optional pitch (x-axis) correction in radians

    • rollCor: number = 0

      optional roll (z-axis) correction in radians

    Returns TransformNode

    this TransformNode

  • Defines the passed node as the parent of the current node. The node will remain exactly where it is and its position / rotation will be updated accordingly. If you don't want to preserve the current rotation / position, assign the parent through parent accessor. Note that if the mesh has a pivot matrix / point defined it will be applied after the parent was updated. In that case the node will not remain in the same space as it is, as the pivot will be applied. To avoid this, you can set updatePivot to true and the pivot will be updated to identity

    Parameters

    • node: Nullable<Node>

      the node ot set as the parent

    • preserveScalingSign: boolean = false

      if true, keep scaling sign of child. Otherwise, scaling sign might change.

    • updatePivot: boolean = false

      if true, update the pivot matrix to keep the node in the same space as before

    Returns TransformNode

    this TransformNode.

  • Sets a new pivot matrix to the current node

    Parameters

    • matrix: DeepImmutable<Matrix>

      defines the new pivot matrix to use

    • postMultiplyPivotMatrix: boolean = true

      defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect

    Returns TransformNode

    the current TransformNode

  • 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

    • Optionaloptions: any

      defines optional options to transmit to constructors

    Returns Nullable<() => Node>

    the new constructor or null

  • 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