Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile has trouble with "forward" in landscape mode #59

Closed
scottgarner opened this issue Mar 29, 2016 · 7 comments
Closed

Mobile has trouble with "forward" in landscape mode #59

scottgarner opened this issue Mar 29, 2016 · 7 comments

Comments

@scottgarner
Copy link

When viewing the boilerplate demo on both iOS and Android devices, the rotating cube appears in front of me when holding the device in portrait mode.

When in landscape mode, the cube appears either 90 degrees to my left or right depending on whether I'm in landscape left or landscape right.

This happens even when I manually call for a resetPose. It seems that device orientation needs to be accounted for in the pose reset.

@scottgarner
Copy link
Author

My temporary workaround for this was to apply the screen rotation Q in resetPose.

  this.resetQ.copy(this.filter.getOrientation());
  this.resetQ.multiply(this.worldToScreenQ);

Unfortunately, that wouldn't work on Android because of the screen locking stuff. It seems that window.orientation just gives the locked orientation (with no indication that it is indeed locked), so the rotation was wrong if you entered VR mode form anything other than landscape-primary.

My workaround there was to just disable screen locking, though then I had to mess with the instructions display to make it work with the fullscreen wrapper.

@scottgarner
Copy link
Author

Just to clarify this issue, it happens only when starting in landscape mode—"forward" appears 90 degrees to the left or right depending on device orientation.

@scottgarner
Copy link
Author

I've tinkered with this a bit more and still haven't come to a satisfactory solution.

To summarize, the initial world transformation should account for the device orientation, as should calls to resetPose. Unfortunately, when the orientation is locked on Android, it always returns the locked value, not the true orientation, which makes it difficult to account for.

I'm not sure how to fix this without knowing the "true" orientation.

@zazabe
Copy link

zazabe commented May 2, 2016

We are using a "preparation" step to access the VR mode:

  • unlock the orientation (if it was locked)
  • display some instructions, asking the user to turn his phone
  • detect orientation changes and only display the button to enter VR when the phone is in landscape
  • when the user click on the button, reset the device sensor + do all the VR stuff (fullscreen, orientation lock, distortion, etc...)

We have a trick to detect the orientation even if it's locked at the OS level, we use the event.accelerationIncludingGravity.y value on devicemotion, the phone should be in landscape when the value is around 0 (it works only if the phone is perpendicular to the earth actually)...

We are still using an old version of the WebVR polyfill, without the requestPresent method, but anyhow, those steps have to be done before entering VR, so before requestPresent.

@borismus
Copy link
Contributor

borismus commented May 6, 2016

I addressed this slightly, but it's still not perfect. c6720ed

borismus added a commit that referenced this issue May 17, 2016
@borismus
Copy link
Contributor

Alright, should be fixed now: 716f8a1

@scottgarner
Copy link
Author

Great news! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants