BabylonJS: Animations

The syntax for Animations:

var animationBox = new BABYLON.Animation(
   "myAnimation", 
   "scaling.x", 
   30, 
   BABYLON.Animation.ANIMATIONTYPE_FLOAT, 
   BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE
);

The parameters related to Animations with BabylonJS:

  • Name of the animation.
  • Property of the shape – for example, scaling, changing position, etc. Scaling is what is shown in the syntax; here, it will scale the box along the x-axis.
  • Frames per second requested: highest FPS possible in this animation.
  • Here you decide and enter what kind of value will be modified: is it afloat (e.g. a translation), a vector (e.g. a direction), or a quaternion.
  • Exact values are −
    • BABYLON.Animation.ANIMATIONTYPE_FLOAT
    • BABYLON.Animation.ANIMATIONTYPE_VECTOR2
    • BABYLON.Animation.ANIMATIONTYPE_VECTOR3
    • BABYLON.Animation.ANIMATIONTYPE_QUATERNION
    • BABYLON.Animation.ANIMATIONTYPE_COLOR3
  • The behavior for animation – to stop or to start the animation again.
  • Use previous values and increment it −
    • BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE
  • Restart from initial value −
    • BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE
  • Keep their final value
    • BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT

Create the animation object:

var animationBox = new BABYLON.Animation(
   "myAnimation", 
   "scaling.x", 
   30, 
   BABYLON.Animation.ANIMATIONTYPE_FLOAT, 
   BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE
);

Leave a Reply

Your email address will not be published. Required fields are marked *