Browse Source

Merge pull request #12288 from hypothete/check-for-window

Check for window object when instantiating the WebVRManager
Mr.doob 7 years ago
parent
commit
67bfa4f92b
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/renderers/webvr/WebVRManager.js

+ 6 - 2
src/renderers/webvr/WebVRManager.js

@@ -14,7 +14,7 @@ function WebVRManager( renderer ) {
 	var device = null;
 	var frameData = null;
 
-	if ( 'VRFrameData' in window ) {
+	if ( typeof window !== 'undefined' && 'VRFrameData' in window ) {
 
 		frameData = new window.VRFrameData();
 
@@ -62,7 +62,11 @@ function WebVRManager( renderer ) {
 
 	}
 
-	window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
+	if ( typeof window !== 'undefined' ) {
+
+		window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
+
+	}
 
 	//