CLASSES
TagsA - Z

Animation

Animation

Description

class Animation

The animation is based on objects called Animation.

An Animation is defined by various properties and a collection of keys

A tutorial about Animations ban be found here : https://doc.babylonjs.com/tutorials/animations

Constructor

new Animation(name, targetProperty, framePerSecond, dataType, loopMode, enableBlending)

Parameters

Name Type Description
name string
targetProperty string
framePerSecond number
dataType number
optional loopMode number

Members

name : string

Name of the animation

targetProperty : string

The property to change, for example rotate a Mesh : "rotation.x"

framePerSecond : number

The number of animation frames per second

dataType : number

The kind of value affected by the animation : ANIMATIONTYPE_FLOAT, ANIMATIONTYPE_VECTOR3, ANIMATIONTYPE_QUATERNION, ANIMATIONTYPE_MATRIX, ANIMATIONTYPE_COLOR3

loopMode : number

The loop mode : ANIMATIONLOOPMODE_RELATIVE, NIMATIONLOOPMODE_CYCLE, ANIMATIONLOOPMODE_CONSTANT

enableBlending : boolean

targetPropertyPath : string[]

An array of properties

currentFrame : number

The current animation key

allowMatricesInterpolation : boolean

blendingSpeed : number

static ANIMATIONTYPE_FLOAT : number

The value affected by the animation is a float

static ANIMATIONTYPE_VECTOR3 : number

The value affected by the animation is a Vector3

static ANIMATIONTYPE_VECTOR2 : number

static ANIMATIONTYPE_SIZE : number

static ANIMATIONTYPE_QUATERNION : number

The value affected by the animation is a Quaternion

static ANIMATIONTYPE_MATRIX : number

The value affected by the animation is a Matrix

static ANIMATIONTYPE_COLOR3 : number

The value affected by the animation is a Color3

static ANIMATIONLOOPMODE_RELATIVE : number

The animation loops but doesn't reset values and continues animation with values of the previous ending animation

static ANIMATIONLOOPMODE_CYCLE : number

The animation restarts with the inital values

static ANIMATIONLOOPMODE_CONSTANT : number

The animation keeps its final value i.e stopped

Methods

static CreateAndStartAnimation(name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) → Animatable

Parameters

Name Type Description
name string
node Node
targetProperty string
framePerSecond number
totalFrame number
from any The frame defining the begining of the animation
to any The frame defining the end of the animation
optional loopMode number
optional easingFunction EasingFunction

static CreateMergeAndStartAnimation(name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) → Animatable

Parameters

Name Type Description
name string
node Node
targetProperty string
framePerSecond number
totalFrame number
from any The frame defining the begining of the animation
to any The frame defining the end of the animation
optional loopMode number
optional easingFunction EasingFunction

toString(fullDetails) → string

Parameters

Name Type Description
optional fullDetails boolean

addEvent(event) → void

Add an event to this animation.

Parameters

Name Type Description
event AnimationEvent

removeEvents(frame) → void

Remove all events found at the given frame

Parameters

Name Type Description
frame number

createRange(name, from, to) → void

Parameters

Name Type Description
name string
from number The frame defining the begining of the animation
to number The frame defining the end of the animation

deleteRange(name, deleteFrames) → void

Parameters

Name Type Description
name string
optional deleteFrames boolean

getRange(name) → AnimationRange

Parameters

Name Type Description
name string

reset() → void

isStopped() → boolean

Tests if the animation is stopped

getKeys() → Array<{ frame: number, value: any }>

Returns the animation keys. Every key represents the value of the Animation at that key's given time.

getHighestFrame() → number

getEasingFunction() → IEasingFunction

setEasingFunction(easingFunction) → void

Parameters

Name Type Description
easingFunction EasingFunction

floatInterpolateFunction(startValue, endValue, gradient) → number

Used to interpolate (perform the transition ) between float keys

Parameters

Name Type Description
startValue number
endValue number
gradient number

floatInterpolateFunctionWithTangents(startValue, outTangent, endValue, inTangent, gradient) → number

Parameters

Name Type Description
startValue number
outTangent number
endValue number
inTangent number

quaternionInterpolateFunction(startValue, endValue, gradient) → Quaternion

Used to interpolate (perform the transition ) between Quaternion keys

Parameters

Name Type Description
startValue Quaternion
endValue Quaternion
gradient number

quaternionInterpolateFunctionWithTangents(startValue, outTangent, endValue, inTangent, gradient) → Quaternion

Parameters

Name Type Description
startValue Quaternion
outTangent Quaternion
endValue Quaternion
inTangent Quaternion

vector3InterpolateFunction(startValue, endValue, gradient) → Vector3

Used to interpolate (perform the transition ) between Vector3 keys

Parameters

Name Type Description
startValue Vector3
endValue Vector3
gradient number

vector3InterpolateFunctionWithTangents(startValue, outTangent, endValue, inTangent, gradient) → Vector3

Parameters

Name Type Description
startValue Vector3
outTangent Vector3
endValue Vector3
inTangent Vector3

vector2InterpolateFunction(startValue, endValue, gradient) → Vector2

Parameters

Name Type Description
startValue Vector2
endValue Vector2
gradient number

vector2InterpolateFunctionWithTangents(startValue, outTangent, endValue, inTangent, gradient) → Vector2

Parameters

Name Type Description
startValue Vector2
outTangent Vector2
endValue Vector2
inTangent Vector2

sizeInterpolateFunction(startValue, endValue, gradient) → Size

Parameters

Name Type Description
startValue Size
endValue Size
gradient number

color3InterpolateFunction(startValue, endValue, gradient) → Color3

Used to interpolate (perform the transition ) between Color3 keys

Parameters

Name Type Description
startValue Color3
endValue Color3
gradient number

matrixInterpolateFunction(startValue, endValue, gradient) → Matrix

Parameters

Name Type Description
startValue Matrix
endValue Matrix
gradient number

clone() → Animation

Clones this animation object

setKeys(values) → void

Adds the keys array to this Animation object

Parameters

Name Type Description
values Array<{ frame: number, value: any }> The keys to assign to this object

setValue(currentValue, blend) → void

Parameters

Name Type Description
currentValue any
optional blend boolean

goToFrame(frame) → void

Parameters

Name Type Description
frame number

animate(delay, from, to, loop, speedRatio, blend) → boolean

Parameters

Name Type Description
delay number @param delay
from number The frame defining the begining of the animation
to number The frame defining the end of the animation
loop boolean true loop the animation, false either
speedRatio number

serialize() → any

static Parse(parsedAnimation) → Animation

Parameters

Name Type Description
parsedAnimation any

static AppendSerializedAnimations(source, destination) → any

Parameters

Name Type Description
source IAnimatable
destination any