Explorar o código

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

PaHae %!s(int64=8) %!d(string=hai) anos
pai
achega
5cf791f9ed
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  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 ) {