Browse Source

Add dispose function to VREffect. Otherwise it causes a memory leak if it is instantiated several times -> always add eventlistener on window (#9787)

PaHae 8 years ago
parent
commit
5cf791f9ed
1 changed files with 4 additions and 0 deletions
  1. 4 0
      examples/js/effects/VREffect.js

+ 4 - 0
examples/js/effects/VREffect.js

@@ -137,6 +137,10 @@ THREE.VREffect = function ( renderer, onError ) {
 
 	window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
 
+	this.dispose = function () {
+		window.removeEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
+	};
+
 	this.setFullScreen = function ( boolean ) {
 
 		return new Promise( function ( resolve, reject ) {