Animation

Class used to store any kind of animation

Hierarchy

  • Animation

Index

Constructors

constructor

  • new Animation(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined): Animation
  • Initializes the animation

    Parameters

    • name: string

      Name of the animation

    • targetProperty: string

      Property to animate

    • framePerSecond: number

      The frames per second of the animation

    • dataType: number

      The data type of the animation

    • Optional loopMode: number | undefined

      The loop mode of the animation

    • Optional enableBlending: boolean | undefined

    Returns Animation

Properties

blendingSpeed

blendingSpeed: number

Stores the blending speed of the animation

dataType

dataType: number

The data type of the animation

enableBlending

enableBlending: boolean | undefined

Specifies if blending should be enabled

framePerSecond

framePerSecond: number

The frames per second of the animation

hasRunningRuntimeAnimations

hasRunningRuntimeAnimations: boolean

Specifies if any of the runtime animations are currently running

loopMode

loopMode: number | undefined

The loop mode of the animation

name

name: string

Name of the animation

runtimeAnimations

runtimeAnimations: RuntimeAnimation[]

Return the array of runtime animations currently using this animation

targetProperty

targetProperty: string

Property to animate

targetPropertyPath

targetPropertyPath: string[]

Stores an array of target property paths

Static ANIMATIONLOOPMODE_CONSTANT

ANIMATIONLOOPMODE_CONSTANT: number

Get the Constant Loop Mode

Static ANIMATIONLOOPMODE_CYCLE

ANIMATIONLOOPMODE_CYCLE: number

Get the Cycle Loop Mode

Static ANIMATIONLOOPMODE_RELATIVE

ANIMATIONLOOPMODE_RELATIVE: number

Get the Relative Loop Mode

Static ANIMATIONTYPE_COLOR3

ANIMATIONTYPE_COLOR3: number

Get the Color3 animation type

Static ANIMATIONTYPE_FLOAT

ANIMATIONTYPE_FLOAT: number

Get the float animation type

Static ANIMATIONTYPE_MATRIX

ANIMATIONTYPE_MATRIX: number

Get the Matrix animation type

Static ANIMATIONTYPE_QUATERNION

ANIMATIONTYPE_QUATERNION: number

Get the Quaternion animation type

Static ANIMATIONTYPE_SIZE

ANIMATIONTYPE_SIZE: number

Get the Size animation type

Static ANIMATIONTYPE_VECTOR2

ANIMATIONTYPE_VECTOR2: number

Get the Vectpr2 animation type

Static ANIMATIONTYPE_VECTOR3

ANIMATIONTYPE_VECTOR3: number

Get the Vector3 animation type

Static AllowMatricesInterpolation

AllowMatricesInterpolation: boolean

Use matrix interpolation instead of using direct key value when animating matrices

Static AllowMatrixDecomposeForInterpolation

AllowMatrixDecomposeForInterpolation: boolean

When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower

Methods

addEvent

  • Add an event to this animation

    Parameters

    Returns void

clone

  • Makes a copy of the animation

    Returns Animation

    Cloned animation

color3InterpolateFunction

  • color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3
  • Interpolates a Color3 linearly

    Parameters

    • startValue: Color3

      Start value of the animation curve

    • endValue: Color3

      End value of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Color3

    Interpolated Color3 value

createRange

  • createRange(name: string, from: number, to: number): void
  • Creates an animation range

    Parameters

    • name: string

      Name of the animation range

    • from: number

      Starting frame of the animation range

    • to: number

      Ending frame of the animation

    Returns void

deleteRange

  • deleteRange(name: string, deleteFrames?: boolean): void
  • Deletes an animation range by name

    Parameters

    • name: string

      Name of the animation range to delete

    • Optional deleteFrames: boolean

      Specifies if the key frames for the range should also be deleted (true) or not (false)

    Returns void

floatInterpolateFunction

  • floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number
  • Interpolates a scalar linearly

    Parameters

    • startValue: number

      Start value of the animation curve

    • endValue: number

      End value of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns number

    Interpolated scalar value

floatInterpolateFunctionWithTangents

  • floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number
  • Interpolates a scalar cubically

    Parameters

    • startValue: number

      Start value of the animation curve

    • outTangent: number

      End tangent of the animation

    • endValue: number

      End value of the animation curve

    • inTangent: number

      Start tangent of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns number

    Interpolated scalar value

getEasingFunction

  • Gets the easing function of the animation

    Returns IEasingFunction

    Easing function of the animation

getEvents

  • Retrieves all the events from the animation

    Returns AnimationEvent[]

    Events from the animation

getHighestFrame

  • getHighestFrame(): number
  • Gets the highest frame rate of the animation

    Returns number

    Highest frame rate of the animation

getKeys

  • Gets the key frames from the animation

    Returns Array<IAnimationKey>

    The key frames of the animation

getRange

  • Gets the animation range by name, or null if not defined

    Parameters

    • name: string

      Name of the animation range

    Returns Nullable<AnimationRange>

    Nullable animation range

matrixInterpolateFunction

  • Defines the function to use to interpolate matrices

    Parameters

    • startValue: Matrix

      defines the start matrix

    • endValue: Matrix

      defines the end matrix

    • gradient: number

      defines the gradient between both matrices

    • Optional result: Matrix

      defines an optional target matrix where to store the interpolation

    Returns Matrix

    the interpolated matrix

quaternionInterpolateFunction

  • Interpolates a quaternion using a spherical linear interpolation

    Parameters

    • startValue: Quaternion

      Start value of the animation curve

    • endValue: Quaternion

      End value of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Quaternion

    Interpolated quaternion value

quaternionInterpolateFunctionWithTangents

  • Interpolates a quaternion cubically

    Parameters

    • startValue: Quaternion

      Start value of the animation curve

    • outTangent: Quaternion

      End tangent of the animation curve

    • endValue: Quaternion

      End value of the animation curve

    • inTangent: Quaternion

      Start tangent of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Quaternion

    Interpolated quaternion value

removeEvents

  • removeEvents(frame: number): void
  • Remove all events found at the given frame

    Parameters

    • frame: number

      The frame to remove events from

    Returns void

serialize

  • serialize(): any
  • Serializes the animation to an object

    Returns any

    Serialized object

setEasingFunction

  • Sets the easing function of the animation

    Parameters

    • easingFunction: EasingFunction

      A custom mathematical formula for animation

    Returns void

setKeys

  • Sets the key frames of the animation

    Parameters

    Returns void

sizeInterpolateFunction

  • sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size
  • Interpolates a size linearly

    Parameters

    • startValue: Size

      Start value of the animation curve

    • endValue: Size

      End value of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Size

    Interpolated Size value

toString

  • toString(fullDetails?: boolean): string
  • Converts the animation to a string

    Parameters

    • Optional fullDetails: boolean

      support for multiple levels of logging within scene loading

    Returns string

    String form of the animation

vector2InterpolateFunction

  • Interpolates a Vector2 linearly

    Parameters

    • startValue: Vector2

      Start value of the animation curve

    • endValue: Vector2

      End value of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Vector2

    Interpolated Vector2 value

vector2InterpolateFunctionWithTangents

  • Interpolates a Vector2 cubically

    Parameters

    • startValue: Vector2

      Start value of the animation curve

    • outTangent: Vector2

      End tangent of the animation

    • endValue: Vector2

      End value of the animation curve

    • inTangent: Vector2

      Start tangent of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Vector2

    Interpolated Vector2 value

vector3InterpolateFunction

  • Interpolates a Vector3 linearl

    Parameters

    • startValue: Vector3

      Start value of the animation curve

    • endValue: Vector3

      End value of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Vector3

    Interpolated scalar value

vector3InterpolateFunctionWithTangents

  • Interpolates a Vector3 cubically

    Parameters

    • startValue: Vector3

      Start value of the animation curve

    • outTangent: Vector3

      End tangent of the animation

    • endValue: Vector3

      End value of the animation curve

    • inTangent: Vector3

      Start tangent of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Vector3

    InterpolatedVector3 value

Static AppendSerializedAnimations

  • AppendSerializedAnimations(source: IAnimatable, destination: any): void
  • Appends the serialized animations from the source animations

    Parameters

    • source: IAnimatable

      Source containing the animations

    • destination: any

      Target to store the animations

    Returns void

Static CreateAndStartAnimation

  • CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: function): Nullable<Animatable>
  • Create and start an animation on a node

    Parameters

    • name: string

      defines the name of the global animation that will be run on all nodes

    • node: Node

      defines the root node where the animation will take place

    • targetProperty: string

      defines property to animate

    • framePerSecond: number

      defines the number of frame per second yo use

    • totalFrame: number

      defines the number of frames in total

    • from: any

      defines the initial value

    • to: any

      defines the final value

    • Optional loopMode: number

      defines which loop mode you want to use (off by default)

    • Optional easingFunction: EasingFunction

      defines the easing function to use (linear by default)

    • Optional onAnimationEnd: function

      defines the callback to call when animation end

        • (): void
        • Returns void

    Returns Nullable<Animatable>

    the animatable created for this animation

Static CreateAndStartHierarchyAnimation

  • CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: function): Nullable<Animatable[]>
  • Create and start an animation on a node and its descendants

    example

    https://www.babylonjs-playground.com/#MH0VLI

    Parameters

    • name: string

      defines the name of the global animation that will be run on all nodes

    • node: Node

      defines the root node where the animation will take place

    • directDescendantsOnly: boolean

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

    • targetProperty: string

      defines property to animate

    • framePerSecond: number

      defines the number of frame per second to use

    • totalFrame: number

      defines the number of frames in total

    • from: any

      defines the initial value

    • to: any

      defines the final value

    • Optional loopMode: number

      defines which loop mode you want to use (off by default)

    • Optional easingFunction: EasingFunction

      defines the easing function to use (linear by default)

    • Optional onAnimationEnd: function

      defines the callback to call when an animation ends (will be called once per node)

        • (): void
        • Returns void

    Returns Nullable<Animatable[]>

    the list of animatables created for all nodes

Static CreateAnimation

  • CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation
  • Sets up an animation

    Parameters

    • property: string

      The property to animate

    • animationType: number

      The animation type to apply

    • framePerSecond: number

      The frames per second of the animation

    • easingFunction: EasingFunction

      The easing function used in the animation

    Returns Animation

    The created animation

Static CreateMergeAndStartAnimation

  • CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: function): Nullable<Animatable>
  • Creates a new animation, merges it with the existing animations and starts it

    Parameters

    • name: string

      Name of the animation

    • node: Node

      Node which contains the scene that begins the animations

    • targetProperty: string

      Specifies which property to animate

    • framePerSecond: number

      The frames per second of the animation

    • totalFrame: number

      The total number of frames

    • from: any

      The frame at the beginning of the animation

    • to: any

      The frame at the end of the animation

    • Optional loopMode: number

      Specifies the loop mode of the animation

    • Optional easingFunction: EasingFunction

      (Optional) The easing function of the animation, which allow custom mathematical formulas for animations

    • Optional onAnimationEnd: function

      Callback to run once the animation is complete

        • (): void
        • Returns void

    Returns Nullable<Animatable>

    Nullable animation

Static Parse

  • Parses an animation object and creates an animation

    Parameters

    • parsedAnimation: any

      Parsed animation object

    Returns Animation

    Animation object

Static TransitionTo

  • Transition property of an host to the target Value

    Parameters

    • property: string

      The property to transition

    • targetValue: any

      The target Value of the property

    • host: any

      The object where the property to animate belongs

    • scene: Scene

      Scene used to run the animation

    • frameRate: number

      Framerate (in frame/s) to use

    • transition: Animation

      The transition type we want to use

    • duration: number

      The duration of the animation, in milliseconds

    • Optional onAnimationEnd: Nullable<function>

      Callback trigger at the end of the animation

    Returns Nullable<Animatable>

    Nullable animation

Generated using TypeDoc