Free Camera Animation - Rotation

Hi,

I am desperatly trying to create an animation for a Free Camera. Setting “target” property does not work properly. The camera directly looks in wrong direction. But using Quaternions the transition is smooth.

Animation.CreateAndStartAnimation("cameraPosition", freeCamera, "target", 30, 60, freeCamera.getFrontPosition(1), tempCamera.getFrontPosition(1))

I am using free camera as start and by creating a temporary camera at final position and target I get the final quaternion. The following code is roughly what I tried:

var start = BABYLON.Quaternion.FromRotationMatrix(freeCamera.getWorldMatrix())
var end = BABYLON.Quaternion.FromRotationMatrix(tempCamera.getWorldMatrix())
tempCamera.dispose()
Animation.CreateAndStartAnimation("cameraPosition", freeCamera, "position", 30, 60, fromCamera.globalPosition, position,  Animation.ANIMATIONLOOPMODE_CONSTANT);
Animation.CreateAndStartAnimation("cameraRotation", freeCamera, "rotation", 30, 60, start.toEulerAngles(), end.toEulerAngles(), Animation.ANIMATIONLOOPMODE_CONSTANT);

However, if I move the free camera around after the first jump. The next transition start from the original position of the free camera. The world matrix does not consider looking around with the Free Camera. How can I get the right matrix from my current view?

Best,
Martin

1 Like

Target should work so maybe something is wrong. That being said rotation is also a good idea. We would need a repro in the playground to investigate

:see_no_evil: Seems like Playground is therapy…

Found the issue in my project. Transition via quaternion works well now, seems like target transition works in the given example, too. In my project I switch from ArcRotate to Free, so I had some issues with target. My mistake was, that I continously took the ArcRotate Matrix…
I hope I solved the issue now and that the playground assists some others…

Hehe hence why we ask for repro :smiley: