Selaa lähdekoodia

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 vuotta sitten
vanhempi
commit
5cf791f9ed
1 muutettua tiedostoa jossa 4 lisäystä ja 0 poistoa
  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 ) {