tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

VRSimulationDriver.js (1911B)


      1 var VRServiceTest;
      2 var vrMockDisplay;
      3 
      4 var VRSimulationDriver = (function () {
      5  "use strict";
      6 
      7  var AttachWebVRDisplay = function () {
      8    if (vrMockDisplay) {
      9      // Avoid creating multiple displays
     10      return Promise.resolve(vrMockDisplay);
     11    }
     12    var promise = VRServiceTest.attachVRDisplay("VRDisplayTest");
     13    promise.then(function (display) {
     14      assert_true(display != null, "AttachWebVRDisplay should success.");
     15      vrMockDisplay = display;
     16    });
     17 
     18    return promise;
     19  };
     20 
     21  var SetVRDisplayPose = function (
     22    position,
     23    linearVelocity,
     24    linearAcceleration,
     25    orientation,
     26    angularVelocity,
     27    angularAcceleration
     28  ) {
     29    vrMockDisplay.setPose(
     30      position,
     31      linearVelocity,
     32      linearAcceleration,
     33      orientation,
     34      angularVelocity,
     35      angularAcceleration
     36    );
     37  };
     38 
     39  var SetEyeResolution = function (width, height) {
     40    vrMockDisplay.setEyeResolution(width, height);
     41  };
     42 
     43  var SetEyeParameter = function (
     44    eye,
     45    offsetX,
     46    offsetY,
     47    offsetZ,
     48    upDegree,
     49    rightDegree,
     50    downDegree,
     51    leftDegree
     52  ) {
     53    vrMockDisplay.setEyeParameter(
     54      eye,
     55      offsetX,
     56      offsetY,
     57      offsetZ,
     58      upDegree,
     59      rightDegree,
     60      downDegree,
     61      leftDegree
     62    );
     63  };
     64 
     65  var SetMountState = function (isMounted) {
     66    vrMockDisplay.setMountState(isMounted);
     67  };
     68 
     69  var UpdateVRDisplay = function () {
     70    vrMockDisplay.update();
     71  };
     72 
     73  var AttachVRController = function () {
     74    var promise = VRServiceTest.attachVRController("VRControllerTest");
     75    promise.then(function (controller) {
     76      assert_true(controller != null, "AttachVRController should success.");
     77    });
     78 
     79    return promise;
     80  };
     81 
     82  var API = {
     83    AttachWebVRDisplay,
     84    SetVRDisplayPose,
     85    SetEyeResolution,
     86    SetEyeParameter,
     87    SetMountState,
     88    UpdateVRDisplay,
     89    AttachVRController,
     90 
     91    none: false,
     92  };
     93 
     94  return API;
     95 })();