I have a camera animation for desktop which goes like this: in mousemove event I have
mouseX = (event.clientX - windowHalfX) / 100;
mouseY = (event.clientY - windowHalfY) / 100;
and in the render function I have
camera.position.x += (mouseX - camera.position.x) * 0.05;
camera.position.y += (-mouseY - camera.position.y) * 0.05;
I want to achieve the same effect with a mobile gyroscope. I tried this:
in the deviceorientation event
gammaRotation = event.gamma;
betaRotation = event.beta;
and in the renderer function I have mostly the same thing as with the desktop version
camera.position.x += (gammaRotation/100 - camera.position.x) * 0.05;
camera.position.y += (-betaRotation/100 - camera.position.y) * 0.05;
But when the beta is 90 ( thats when the phone is vertical to the ground 90 degrees) my camera jumps to one site to another and then goes back to working correctly. It only “jumps” when beta is 90. I guess it’s a math error, but can’t really work it out because I don’t know how to enable inspector for Iphone right now…Maybe someone knows the answer to why this is happening
Thanks!