Browse Source

Always stop WebVRManager animation if started when exiting VR

Jaakko Manninen 7 years ago
parent
commit
6230e85ca9
1 changed files with 16 additions and 3 deletions
  1. 16 3
      src/renderers/webvr/WebVRManager.js

+ 16 - 3
src/renderers/webvr/WebVRManager.js

@@ -56,6 +56,7 @@ function WebVRManager( renderer ) {
 	}
 
 	var currentSize, currentPixelRatio;
+	var isAnimating;
 
 	function onVRDisplayPresentChange() {
 
@@ -72,11 +73,23 @@ function WebVRManager( renderer ) {
 
 			animation.start();
 
-		} else if ( scope.enabled ) {
+			isAnimating = true;
 
-			renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );
+		} else {
+
+			if ( scope.enabled ) {
+
+				renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );
+
+			}
 
-			animation.stop();
+			if ( isAnimating ) {
+
+				animation.stop();
+
+				isAnimating = false;
+
+			}
 
 		}