Jump to content

Resetting device rotation


2x4b
 Share

Recommended Posts

Using camera.resetToCurrentRotation() I am able to set my camera to point to z+.

I really need to set the camera rotation on the y axis to face z- or x+ or x- as well.

Unfortunately I have been blundering about with quaternions for 2 days, and I can't seem to make it do what I want. Or it will do what I want, but only when the device is pointing a specific direction(very odd).

Link to comment
Share on other sites

I gave up on Quaternions. Solved my problem with Euler instead.

cam._initialQuaternion.x = 0;
cam._initialQuaternion.z = 0;
cam._initialQuaternion.y *= -1;
cam._initialQuaternion.normalize();
 
var rot = cam._initialQuaternion.toEulerAngles()
 
rot.y += Number(180).toRadians();
BABYLON.Quaternion.RotationYawPitchRollToRef(rot.y,rot.x,rot.z, cam._initialQuaternion);
cam._initialQuaternion.normalize();
 
// Apply to camera
cam._initialQuaternion.multiplyToRef(cam.rotationQuaternion, cam.rotationQuaternion);
Link to comment
Share on other sites

  • 2x4b changed the title to [SOLVED] Resetting device rotation

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...