src/cardboard-vr-display.js
function CardboardVRDisplay(config) {
  var defaults = Util.extend({}, Options);
  config = Util.extend(defaults, config || {});

  VRDisplay.call(this, {
    wakelock: config.MOBILE_WAKE_LOCK,
  });

  this.config = config;

  this.displayName = 'Cardboard VRDisplay';

  this.capabilities = new VRDisplayCapabilities({
    hasPosition: false,
    hasOrientation: true,
    hasExternalDisplay: false,
    canPresent: true,
    maxLayers: 1
  });

  this.stageParameters = null;

  // "Private" members.
  this.bufferScale_ = this.config.BUFFER_SCALE;
  this.poseSensor_ = new PoseSensor(this.config);
  this.distorter_ = null;
  this.cardboardUI_ = null;

  this.dpdb_ = new Dpdb(this.config.DPDB_URL, this.onDeviceParamsUpdated_.bind(this));
  this.deviceInfo_ = new DeviceInfo(this.dpdb_.getDeviceParams(),
                                    config.ADDITIONAL_VIEWERS);

  this.viewerSelector_ = new ViewerSelector(config.DEFAULT_VIEWER);
  this.viewerSelector_.onChange(this.onViewerChanged_.bind(this));

  // Set the correct initial viewer.
  this.deviceInfo_.setViewer(this.viewerSelector_.getCurrentViewer());

  if (!this.config.ROTATE_INSTRUCTIONS_DISABLED) {
    this.rotateInstructions_ = new RotateInstructions();
  }

  if (Util.isIOS()) {
    // Listen for resize events to workaround this awful Safari bug.
    window.addEventListener('resize', this.onResize_.bind(this));
  }
}
function CardboardVRDisplay(config) {
  var defaults = Util.extend({}, Options);
  config = Util.extend(defaults, config || {});

  VRDisplay.call(this, {
    wakelock: config.MOBILE_WAKE_LOCK,
  });

  this.config = config;

  this.displayName = 'Cardboard VRDisplay';

  this.capabilities = new VRDisplayCapabilities({
    hasPosition: false,
    hasOrientation: true,
    hasExternalDisplay: false,
    canPresent: true,
    maxLayers: 1
  });

  this.stageParameters = null;

  // "Private" members.
  this.bufferScale_ = this.config.BUFFER_SCALE;
  this.poseSensor_ = new PoseSensor(this.config);
  this.distorter_ = null;
  this.cardboardUI_ = null;

  this.dpdb_ = new Dpdb(this.config.DPDB_URL, this.onDeviceParamsUpdated_.bind(this));
  this.deviceInfo_ = new DeviceInfo(this.dpdb_.getDeviceParams(),
                                    config.ADDITIONAL_VIEWERS);

  this.viewerSelector_ = new ViewerSelector(config.DEFAULT_VIEWER);
  this.viewerSelector_.onChange(this.onViewerChanged_.bind(this));

  // Set the correct initial viewer.
  this.deviceInfo_.setViewer(this.viewerSelector_.getCurrentViewer());

  if (!this.config.ROTATE_INSTRUCTIONS_DISABLED) {
    this.rotateInstructions_ = new RotateInstructions();
  }

  if (Util.isIOS()) {
    // Listen for resize events to workaround this awful Safari bug.
    window.addEventListener('resize', this.onResize_.bind(this));
  }
}
function CardboardVRDisplay ( config ) { var defaults = Util . extend ( { } , Options ) ; config = Util . extend ( defaults , config || { } ) ; VRDisplay . call ( this , { wakelock : config . MOBILE_WAKE_LOCK , } ) ; this . config = config ; this . displayName = 'Cardboard VRDisplay' ; this . capabilities = new VRDisplayCapabilities ( { hasPosition : false , hasOrientation : true , hasExternalDisplay : false , canPresent : true , maxLayers : 1 } ) ; this . stageParameters = null ; // "Private" members. this . bufferScale_ = this . config . BUFFER_SCALE ; this . poseSensor_ = new PoseSensor ( this . config ) ; this . distorter_ = null ; this . cardboardUI_ = null ; this . dpdb_ = new Dpdb ( this . config . DPDB_URL , this . onDeviceParamsUpdated_ . bind ( this ) ) ; this . deviceInfo_ = new DeviceInfo ( this . dpdb_ . getDeviceParams ( ) , config . ADDITIONAL_VIEWERS ) ; this . viewerSelector_ = new ViewerSelector ( config . DEFAULT_VIEWER ) ; this . viewerSelector_ . onChange ( this . onViewerChanged_ . bind ( this ) ) ; // Set the correct initial viewer. this . deviceInfo_ . setViewer ( this . viewerSelector_ . getCurrentViewer ( ) ) ; if ( ! this . config . ROTATE_INSTRUCTIONS_DISABLED ) { this . rotateInstructions_ = new RotateInstructions ( ) ; } if ( Util . isIOS ( ) ) { // Listen for resize events to workaround this awful Safari bug. window . addEventListener ( 'resize' , this . onResize_ . bind ( this ) ) ; } }
VRDisplay based on mobile device parameters and DeviceMotion APIs.
VRDisplay based on mobile device parameters and DeviceMotion APIs .