Options
All
  • Public
  • Public/Protected
  • All
Menu

Class used to store any kind of animation

Hierarchy

  • Animation

Index

Constructors

  • new Animation(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number, enableBlending?: boolean): 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

      The loop mode of the animation

    • Optional enableBlending: boolean

      Specifies if blending should be enabled

    Returns Animation

Properties

blendingSpeed: number

Stores the blending speed of the animation

dataType: number

The data type of the animation

enableBlending?: boolean

Specifies if blending should be enabled

framePerSecond: number

The frames per second of the animation

loopMode?: number

The loop mode of the animation

name: string

Name of the animation

snippetId: string

Snippet ID if the animation was created from the snippet server

targetProperty: string

Property to animate

targetPropertyPath: string[]

Stores an array of target property paths

uniqueId: number

Gets or sets the unique id of the animation (the uniqueness is solely among other animations)

ANIMATIONLOOPMODE_CONSTANT: 2 = 2

Constant Loop Mode

ANIMATIONLOOPMODE_CYCLE: 1 = 1

Cycle Loop Mode

ANIMATIONLOOPMODE_RELATIVE: 0 = 0

Relative Loop Mode

ANIMATIONLOOPMODE_YOYO: 4 = 4

Yoyo Loop Mode

ANIMATIONTYPE_COLOR3: 4 = 4

Color3 animation type

ANIMATIONTYPE_COLOR4: 7 = 7

Color3 animation type

ANIMATIONTYPE_FLOAT: 0 = 0

Float animation type

ANIMATIONTYPE_MATRIX: 3 = 3

Matrix animation type

ANIMATIONTYPE_QUATERNION: 2 = 2

Quaternion animation type

ANIMATIONTYPE_SIZE: 6 = 6

Size animation type

ANIMATIONTYPE_VECTOR2: 5 = 5

Vector2 animation type

ANIMATIONTYPE_VECTOR3: 1 = 1

Vector3 animation type

AllowMatricesInterpolation: boolean

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

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

CreateFromSnippetAsync: ((snippetId: string) => Promise<Animation | Animation[]>)

Type declaration

    • Creates an animation or an array of animations from a snippet saved by the Inspector

      Parameters

      • snippetId: string

        defines the snippet to load

      Returns Promise<Animation | Animation[]>

      a promise that will resolve to the new animation or a new array of animations

SnippetUrl: string

Define the Url to load snippets

Accessors

  • get hasRunningRuntimeAnimations(): boolean
  • Specifies if any of the runtime animations are currently running

    Returns boolean

  • Return the array of runtime animations currently using this animation

    Returns RuntimeAnimation[]

Methods

  • Add an event to this animation

    Parameters

    Returns void

  • Makes a copy of the animation

    Returns Animation

    Cloned animation

  • 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

  • Interpolates a Color3 cubically

    Parameters

    • startValue: Color3

      Start value of the animation curve

    • outTangent: Color3

      End tangent of the animation

    • endValue: Color3

      End value of the animation curve

    • inTangent: Color3

      Start tangent of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Color3

    interpolated value

  • Interpolates a Color4 linearly

    Parameters

    • startValue: Color4

      Start value of the animation curve

    • endValue: Color4

      End value of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Color4

    Interpolated Color3 value

  • Interpolates a Color4 cubically

    Parameters

    • startValue: Color4

      Start value of the animation curve

    • outTangent: Color4

      End tangent of the animation

    • endValue: Color4

      End value of the animation curve

    • inTangent: Color4

      Start tangent of the animation curve

    • gradient: number

      Scalar amount to interpolate

    Returns Color4

    interpolated value

  • createKeyForFrame(frame: number): number
  • Creates a key for the frame passed as a parameter and adds it to the animation IF a key doesn't already exist for that frame

    Parameters

    • frame: number

      Frame number

    Returns number

    The key index if the key was added or the index of the pre existing key if the frame passed as parameter already has a corresponding key

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

  • evaluate(currentFrame: number): any
  • Evaluate the animation value at a given frame

    Parameters

    • currentFrame: number

      defines the frame where we want to evaluate the animation

    Returns any

    the animation value

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

  • Gets the easing function of the animation

    Returns Nullable<IEasingFunction>

    Easing function of the animation

  • Retrieves all the events from the animation

    Returns AnimationEvent[]

    Events from the animation

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

    Returns number

    Highest frame rate of the animation

  • Gets the key frames from the animation

    Returns IAnimationKey[]

    The key frames of the animation

  • 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

  • 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

  • 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

  • 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(frame: number): void
  • Remove all events found at the given frame

    Parameters

    • frame: number

      The frame to remove events from

    Returns void

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

    Returns any

    Serialized object

  • Sets the easing function of the animation

    Parameters

    Returns void

  • Sets the key frames of the animation

    Parameters

    • values: IAnimationKey[]

      The animation key frames to set

    • Optional dontClone: boolean

      Whether to clone the keys or not (default is false, so the array of keys is cloned)

    Returns void

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

  • 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 (value between 0 and 1)

    Returns Vector2

    Interpolated Vector2 value

  • 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 (value between 0 and 1)

    Returns Vector2

    Interpolated Vector2 value

  • Interpolates a Vector3 linearly

    Parameters

    • startValue: Vector3

      Start value of the animation curve

    • endValue: Vector3

      End value of the animation curve

    • gradient: number

      Scalar amount to interpolate (value between 0 and 1)

    Returns Vector3

    Interpolated scalar value

  • 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 (value between 0 and 1)

    Returns Vector3

    InterpolatedVector3 value

  • 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

  • CreateAndStartAnimation(name: string, target: any, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: (() => void), scene?: Scene): 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

    • target: any

      defines the target 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: (() => void)

      defines the callback to call when animation end

        • (): void
        • Returns void

    • Optional scene: Scene

      defines the hosting scene

    Returns Nullable<Animatable>

    the animatable created for this animation

  • CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: (() => void)): 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: (() => void)

      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

  • 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

  • CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: (() => void)): 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: (() => void)

      Callback to run once the animation is complete

        • (): void
        • Returns void

    Returns Nullable<Animatable>

    Nullable animation

  • Convert the keyframes of an animation to be relative to a given reference frame.

    Parameters

    • sourceAnimation: Animation

      defines the Animation containing keyframes to convert

    • Optional referenceFrame: number

      defines the frame that keyframes in the range will be relative to (default: 0)

    • Optional range: string

      defines the name of the AnimationRange belonging to the Animation to convert

    • Optional cloneOriginal: boolean

      defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)

    • Optional clonedName: string

      defines the name of the resulting cloned Animation if cloneOriginal is true

    Returns Animation

    a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false

  • Convert the keyframes of an animation to be relative to a given reference frame.

    Parameters

    Returns Animation

    a new Animation if options.cloneOriginalAnimation is true or the original Animation if options.cloneOriginalAnimation is false

  • Parses an animation object and creates an animation

    Parameters

    • parsedAnimation: any

      Parsed animation object

    Returns Animation

    Animation object

  • Creates a new animation or an array of animations from a snippet saved in a remote file

    Parameters

    • name: Nullable<string>

      defines the name of the animation to create (can be null or empty to use the one from the json data)

    • url: string

      defines the url to load from

    Returns Promise<Animation | Animation[]>

    a promise that will resolve to the new animation or an array of animations

  • Creates an animation or an array of animations from a snippet saved by the Inspector

    Parameters

    • snippetId: string

      defines the snippet to load

    Returns Promise<Animation | Animation[]>

    a promise that will resolve to the new animation or a new array of animations

  • 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<(() => void)>

      Callback trigger at the end of the animation

    Returns Nullable<Animatable>

    Nullable animation

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Method
  • Static property
  • Static method

Settings

Theme