[SOLVED]FreeCamera vertical rotation jumps back on mouse click

I am trying to rotate the FreeCamera on the vertical axes with this code:

cam.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(0.7, 0, 0);

The rotation works, but on a mouse click into the rotated scene, the camera view jumps back to the previous orientation.

https://playground.babylonjs.com/#68CV79

There musst be some function to update the scene after the camera rotated but I could not finde it in the forum/docs.

greetings
mike

hey
try
if (scene) {
scene.render();
}

Hm, the camera jumps as soon as I move the clicked mouse. Unfortunately the scene.render() method could not solve this behaviour.

make PG we can see your error exactly

We can already see the issue in him playground, even without using the timeout

https://playground.babylonjs.com/#68CV79#1

This is because freeCamera uses a target to control its rotation.
You can actually forcefully write into its quaternion but it will be immediatly overwritten by the mouse inputs

The best option is to use setTarget directly:
https://playground.babylonjs.com/#68CV79#2

ok, thanks to all of you for looking into it. So now I know, how it works :relaxed:
Really awesome, how fast questions get answered by this forum!

1 Like