diff --git a/src/plugin.js b/src/plugin.js index 782c8fb8..b00de17e 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -1,11 +1,10 @@ -import 'webvr-polyfill/build/webvr-polyfill'; - +import window from 'global/window'; +/* THIS CONFIGURES webvr-polyfill don't change the order */ +import './webvr-config.js'; +import 'webvr-polyfill/src/main'; import videojs from 'video.js'; import {version as VERSION} from '../package.json'; -import window from 'global/window'; - import * as THREE from 'three'; - // previously we used // * three/examples/js/controls/VRControls.js // * three/examples/js/effects/VREffects.js @@ -13,11 +12,8 @@ import * as THREE from 'three'; // so the code has been copied locally to allow exporting import VRControls from './VRControls.js'; import VREffect from './VREffect.js'; - -import WebVrConfig from './webvr.config.js'; import WebVRManager from 'webvr-boilerplate'; -window.WebVrConfig = WebVrConfig; window.WebVRManager = WebVRManager; const navigator = window.navigator; @@ -238,7 +234,7 @@ const vr = function(options) { return; } - const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000); + const camera = new THREE.PerspectiveCamera(75, player.currentWidth() / player.currentHeight(), 1, 1000); // Store vector representing the direction in which the camera is looking, in world space. cameraVector = new THREE.Vector3(); @@ -335,10 +331,10 @@ const vr = function(options) { antialias: true }); - renderer.setSize(window.innerWidth, window.innerHeight); + renderer.setSize(player.currentWidth(), player.currentHeight()); const effect = new VREffect(renderer); - effect.setSize(window.innerWidth, window.innerHeight); + effect.setSize(player.currentWidth(), player.currentHeight()); let vrDisplay = null; diff --git a/src/webvr-config.js b/src/webvr-config.js new file mode 100644 index 00000000..ca2f803a --- /dev/null +++ b/src/webvr-config.js @@ -0,0 +1,21 @@ +import window from 'global/window'; +// this is used to configure webvr-polyfill +// see https://github.com/googlevr/webvr-polyfill#configuration +const WebVRConfig = { + // TODO: + // implement controls so that thy only work when the player is in focus. + // This will require MOUSE_KEYBOARD_CONTROLS_DISABLED, and TOUCH_PANNER_DISABLED to be set to true + // and various points in the code will have to be changed. As a lot of the code + // expects some sort of controls to be set up, and when no controls are set up + // it throws an error about no vr displays being found. VrDisplays is actually referring to controls. + + // Flag to disable touch panner. In case you have your own touch controls. + // Default: true. + // TOUCH_PANNER_DISABLED: true, + // To disable keyboard and mouse controls, if you want to use your own + // implementation. + // Default: false. + // MOUSE_KEYBOARD_CONTROLS_DISABLED: true, +}; + +window.WebVRConfig = WebVRConfig; diff --git a/src/webvr.config.js b/src/webvr.config.js deleted file mode 100644 index 89b648a0..00000000 --- a/src/webvr.config.js +++ /dev/null @@ -1,51 +0,0 @@ -export default { - // Forces availability of VR mode, even for non-mobile devices. - // Default: false. - FORCE_ENABLE_VR: false, - - // Complementary filter coefficient. 0 for accelerometer, 1 for gyro. - // Default: 0.98. - K_FILTER: 0.98, - - // How far into the future to predict during fast motion (in seconds). - // Default: 0.040. - PREDICTION_TIME_S: 0.040, - - // Flag to disable touch panner. In case you have your own touch controls. - // Default: false. - TOUCH_PANNER_DISABLED: false, - - // Enable yaw panning only, disabling roll and pitch. This can be useful - // for panoramas with nothing interesting above or below. - // Default: false. - YAW_ONLY: false, - - // To disable keyboard and mouse controls, if you want to use your own - // implementation. - // Default: false. - MOUSE_KEYBOARD_CONTROLS_DISABLED: false, - - // Prevent the polyfill from initializing immediately. Requires the app - // to call InitializeWebVRPolyfill() before it can be used. - // Default: false. - DEFER_INITIALIZATION: false, - - // Enable the deprecated version of the API (navigator.getVRDevices). - // Default: false. - ENABLE_DEPRECATED_API: false, - - // Scales the recommended buffer size reported by WebVR, which can improve - // performance. - // Default: 1.0. - BUFFER_SCALE: 0.5, - - // Allow VRDisplay.submitFrame to change gl bindings, which is more - // efficient if the application code will re-bind its resources on the - // next frame anyway. This has been seen to cause rendering glitches with - // THREE.js. - // Dirty bindings include: gl.FRAMEBUFFER_BINDING, gl.CURRENT_PROGRAM, - // gl.ARRAY_BUFFER_BINDING, gl.ELEMENT_ARRAY_BUFFER_BINDING, - // and gl.TEXTURE_BINDING_2D for texture unit 0. - // Default: false. - DIRTY_SUBMIT_FRAME_BINDINGS: false -};