How to build animation for ArcRotateCamera so it can rotate smoothly

I usually use this very short and comfortable snippet

BABYLON.ArcRotateCamera.prototype.spinTo = function (whichprop, targetval, speed) {
    var ease = new BABYLON.CubicEase();
    ease.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT);
    BABYLON.Animation.CreateAndStartAnimation('at4', this, whichprop, speed, 120, this[whichprop], targetval, 0, ease);
}

and then use it as you want, separately or together, for example

       camera.spinTo("radius", 250, 50);
       camera.spinTo("alpha", Math.PI/2, 50);
       camera.spinTo("beta", 1.05, 50);

Example - https://playground.babylonjs.com/#U5SSCN#169 (press Return button).

6 Likes