src/sensor-fusion/fusion-pose-sensor.js
function FusionPoseSensor(kFilter, predictionTime, yawOnly, isDebug) {
  this.yawOnly = yawOnly;

  this.accelerometer = new MathUtil.Vector3();
  this.gyroscope = new MathUtil.Vector3();

  this.filter = new ComplementaryFilter(kFilter, isDebug);
  this.posePredictor = new PosePredictor(predictionTime, isDebug);

  this.isFirefoxAndroid = Util.isFirefoxAndroid();
  this.isIOS = Util.isIOS();
  // Chrome as of m66 started reporting `rotationRate` in degrees rather
  // than radians, to be consistent with other browsers.
  // https://github.com/immersive-web/cardboard-vr-display/issues/18
  let chromeVersion = Util.getChromeVersion();
  this.isDeviceMotionInRadians = !this.isIOS && chromeVersion && chromeVersion < 66;
  // In Chrome m65 there's a regression of devicemotion events. Fallback
  // to using deviceorientation for these specific builds. More information
  // at `Util.isChromeWithoutDeviceMotion`.
  this.isWithoutDeviceMotion = Util.isChromeWithoutDeviceMotion();

  this.filterToWorldQ = new MathUtil.Quaternion();

  // Set the filter to world transform, depending on OS.
  if (Util.isIOS()) {
    this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1, 0, 0), Math.PI / 2);
  } else {
    this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1, 0, 0), -Math.PI / 2);
  }

  this.inverseWorldToScreenQ = new MathUtil.Quaternion();
  this.worldToScreenQ = new MathUtil.Quaternion();
  this.originalPoseAdjustQ = new MathUtil.Quaternion();
  this.originalPoseAdjustQ.setFromAxisAngle(new MathUtil.Vector3(0, 0, 1),
                                           -window.orientation * Math.PI / 180);

  this.setScreenTransform_();
  // Adjust this filter for being in landscape mode.
  if (Util.isLandscapeMode()) {
    this.filterToWorldQ.multiply(this.inverseWorldToScreenQ);
  }

  // Keep track of a reset transform for resetSensor.
  this.resetQ = new MathUtil.Quaternion();

  this.orientationOut_ = new Float32Array(4);

  this.start();
}
function FusionPoseSensor(kFilter, predictionTime, yawOnly, isDebug) {
  this.yawOnly = yawOnly;

  this.accelerometer = new MathUtil.Vector3();
  this.gyroscope = new MathUtil.Vector3();

  this.filter = new ComplementaryFilter(kFilter, isDebug);
  this.posePredictor = new PosePredictor(predictionTime, isDebug);

  this.isFirefoxAndroid = Util.isFirefoxAndroid();
  this.isIOS = Util.isIOS();
  // Chrome as of m66 started reporting `rotationRate` in degrees rather
  // than radians, to be consistent with other browsers.
  // https://github.com/immersive-web/cardboard-vr-display/issues/18
  let chromeVersion = Util.getChromeVersion();
  this.isDeviceMotionInRadians = !this.isIOS && chromeVersion && chromeVersion < 66;
  // In Chrome m65 there's a regression of devicemotion events. Fallback
  // to using deviceorientation for these specific builds. More information
  // at `Util.isChromeWithoutDeviceMotion`.
  this.isWithoutDeviceMotion = Util.isChromeWithoutDeviceMotion();

  this.filterToWorldQ = new MathUtil.Quaternion();

  // Set the filter to world transform, depending on OS.
  if (Util.isIOS()) {
    this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1, 0, 0), Math.PI / 2);
  } else {
    this.filterToWorldQ.setFromAxisAngle(new MathUtil.Vector3(1, 0, 0), -Math.PI / 2);
  }

  this.inverseWorldToScreenQ = new MathUtil.Quaternion();
  this.worldToScreenQ = new MathUtil.Quaternion();
  this.originalPoseAdjustQ = new MathUtil.Quaternion();
  this.originalPoseAdjustQ.setFromAxisAngle(new MathUtil.Vector3(0, 0, 1),
                                           -window.orientation * Math.PI / 180);

  this.setScreenTransform_();
  // Adjust this filter for being in landscape mode.
  if (Util.isLandscapeMode()) {
    this.filterToWorldQ.multiply(this.inverseWorldToScreenQ);
  }

  // Keep track of a reset transform for resetSensor.
  this.resetQ = new MathUtil.Quaternion();

  this.orientationOut_ = new Float32Array(4);

  this.start();
}
function FusionPoseSensor ( kFilter , predictionTime , yawOnly , isDebug ) { this . yawOnly = yawOnly ; this . accelerometer = new MathUtil . Vector3 ( ) ; this . gyroscope = new MathUtil . Vector3 ( ) ; this . filter = new ComplementaryFilter ( kFilter , isDebug ) ; this . posePredictor = new PosePredictor ( predictionTime , isDebug ) ; this . isFirefoxAndroid = Util . isFirefoxAndroid ( ) ; this . isIOS = Util . isIOS ( ) ; // Chrome as of m66 started reporting `rotationRate` in degrees rather // than radians, to be consistent with other browsers. // https://github.com/immersive-web/cardboard-vr-display/issues/18 let chromeVersion = Util . getChromeVersion ( ) ; this . isDeviceMotionInRadians = ! this . isIOS && chromeVersion && chromeVersion < 66 ; // In Chrome m65 there's a regression of devicemotion events. Fallback // to using deviceorientation for these specific builds. More information // at `Util.isChromeWithoutDeviceMotion`. this . isWithoutDeviceMotion = Util . isChromeWithoutDeviceMotion ( ) ; this . filterToWorldQ = new MathUtil . Quaternion ( ) ; // Set the filter to world transform, depending on OS. if ( Util . isIOS ( ) ) { this . filterToWorldQ . setFromAxisAngle ( new MathUtil . Vector3 ( 1 , 0 , 0 ) , Math . PI / 2 ) ; } else { this . filterToWorldQ . setFromAxisAngle ( new MathUtil . Vector3 ( 1 , 0 , 0 ) , - Math . PI / 2 ) ; } this . inverseWorldToScreenQ = new MathUtil . Quaternion ( ) ; this . worldToScreenQ = new MathUtil . Quaternion ( ) ; this . originalPoseAdjustQ = new MathUtil . Quaternion ( ) ; this . originalPoseAdjustQ . setFromAxisAngle ( new MathUtil . Vector3 ( 0 , 0 , 1 ) , - window . orientation * Math . PI / 180 ) ; this . setScreenTransform_ ( ) ; // Adjust this filter for being in landscape mode. if ( Util . isLandscapeMode ( ) ) { this . filterToWorldQ . multiply ( this . inverseWorldToScreenQ ) ; } // Keep track of a reset transform for resetSensor. this . resetQ = new MathUtil . Quaternion ( ) ; this . orientationOut_ = new Float32Array ( 4 ) ; this . start ( ) ; }
The pose sensor, implemented using DeviceMotion APIs.

@param {number} kFilter
@param {number} predictionTime
@param {boolean} yawOnly
@param {boolean} isDebug
The pose sensor implemented using DeviceMotion APIs .