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

Suggestion/Question: normalize the accelerometer and gyroscope data on mobile devices #10

Closed
skezo opened this issue Aug 25, 2015 · 2 comments

Comments

@skezo
Copy link

skezo commented Aug 25, 2015

Firstly, I have to say thank you for the awesome and useful repository. It has made learning VR in the browser approachable.

I have been developing a display reticle manger to help with gaze interactions and found that when testing on different phones e.g. iOS and Android the initial load position differs, even on the same device at different orientations (i.e. iPhone 6 holding it in landscape and portrait will generate different results).

Have you considered normalizing the accelerometer and gyroscope data before sending it back to VRControls.js? For example using a similar approach as gyronorm.js you could update the alpha, beta and gamma values in getOrientation method allowing for most mobile devices to have a similar result...

Below is very rough example of what I mean.

GyroPositionSensorVRDevice.prototype.getOrientation = function(data) {
  if (this.deviceOrientation == null) {
    return null;
  }

  // Rotation around the z-axis.
  //var alpha = THREE.Math.degToRad(this.deviceOrientation.alpha);
  var alpha = THREE.Math.degToRad(data.do.alpha);
  //console.log(alpha, data.do.alpha)
  // Front-to-back (in portrait) rotation (x-axis).
  //var beta = THREE.Math.degToRad(this.deviceOrientation.beta);
  var beta = THREE.Math.degToRad(data.do.beta);
  // Left to right (in portrait) rotation (y-axis).
  //var gamma = THREE.Math.degToRad(this.deviceOrientation.gamma);
  var gamma = THREE.Math.degToRad(data.do.gamma);
@skezo skezo changed the title normalize the accelerometer and gyroscope data on mobile devices Suggestion/Question: normalize the accelerometer and gyroscope data on mobile devices Aug 25, 2015
@borismus
Copy link
Contributor

What do you mean about the initial load position? Where you are initially looking in VR is inevitably going to fluctuate, since we don't rely on the compass/magnetometer for some absolute reference.

As far as I can tell, this gyronorm.js thing is mainly for just ensuring that the values are consistent regardless of phone orientation (ie. landscape / portrait), which should already be the case.

@skezo
Copy link
Author

skezo commented Oct 19, 2015

Ignore my initial post. After playing it with some more I realized that using something like gyronorm.js was not the best approach to fix this. Your below point highlights this perfectly. I found it is something that you need design for instead.

Where you are initially looking in VR is inevitably going to fluctuate, since we don't rely on the compass/magnetometer for some absolute reference.

Thanks again for the reply and the work you are doing on this.

@skezo skezo closed this as completed Oct 19, 2015
wan-hellopupil pushed a commit to wan-hellopupil/webvr-polyfill that referenced this issue Apr 19, 2018
devicemotion-based FusionPoseSensor when not. Fixes immersive-web#10.
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

2 participants