|
@@ -24,6 +24,7 @@ function WebVRManager( renderer ) {
|
|
|
if ( typeof window !== 'undefined' && 'VRFrameData' in window ) {
|
|
|
|
|
|
frameData = new window.VRFrameData();
|
|
|
+ window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -45,11 +46,17 @@ function WebVRManager( renderer ) {
|
|
|
|
|
|
//
|
|
|
|
|
|
+ function isPresenting() {
|
|
|
+
|
|
|
+ return device !== null && device.isPresenting === true;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
var currentSize, currentPixelRatio;
|
|
|
|
|
|
function onVRDisplayPresentChange() {
|
|
|
|
|
|
- if ( device !== null && device.isPresenting ) {
|
|
|
+ if ( isPresenting() ) {
|
|
|
|
|
|
var eyeParameters = device.getEyeParameters( 'left' );
|
|
|
var renderWidth = eyeParameters.renderWidth;
|
|
@@ -68,12 +75,6 @@ function WebVRManager( renderer ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( typeof window !== 'undefined' ) {
|
|
|
-
|
|
|
- window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
//
|
|
|
|
|
|
this.enabled = false;
|
|
@@ -227,7 +228,7 @@ function WebVRManager( renderer ) {
|
|
|
|
|
|
this.submitFrame = function () {
|
|
|
|
|
|
- if ( device && device.isPresenting ) device.submitFrame();
|
|
|
+ if ( isPresenting() ) device.submitFrame();
|
|
|
|
|
|
};
|
|
|
|