Hello,
I’m calculating a new target and position for my camera with a given radius. This way I want to keep the same perspective the camera was in beforehand while I can adjust the radius. This works so far, however there is one unexpected thing happening. On start of the animation for like the first frame the camera jumps to an alpha value of Pi. Afterwards it continues the correct animation.
I couldn’t find out what was causing this. Maybe it is a bug? There doesn’t seem to be a link between certain radius/alpha/beta values for it to happen.
calulation/animation:
let newRadius = 20;
let newTarget = new BABYLON.Vector3(80, 2, 0);
let relativeVector = camera.position.clone().subtract(camera.target.clone()).normalize().multiplyByFloats(newRadius, newRadius, newRadius);
let newPosition = newTarget.add(relativeVector);
let easingFunction = new BABYLON.SineEase()
easingFunction.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT);
BABYLON.Animation.CreateAndStartAnimation("cam pos", camera, "position", 30, 30, camera.position.clone(), newPosition, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT, easingFunction);
BABYLON.Animation.CreateAndStartAnimation("cam tar", camera, "target", 30, 30, camera.target.clone(), newTarget, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT, easingFunction);