Quellcode durchsuchen

VideoTexture: Clarified code.

Mr.doob vor 7 Jahren
Ursprung
Commit
6cb946444d
1 geänderte Dateien mit 6 neuen und 5 gelöschten Zeilen
  1. 6 5
      src/textures/VideoTexture.js

+ 6 - 5
src/textures/VideoTexture.js

@@ -10,17 +10,18 @@ function VideoTexture( video, mapping, wrapS, wrapT, magFilter, minFilter, forma
 
 	this.generateMipmaps = false;
 
-	var scope = this;
+	// Set needsUpdate when first frame is ready
 
-	// fires when the first frame of the media has finished loading (now there are valid texture data)
+	var scope = this;
 
-	video.addEventListener( 'loadeddata', function onLoaded() {
+	function onLoaded() {
 
+		video.removeEventListener( 'loadeddata', onLoaded, false );
 		scope.needsUpdate = true;
 
-		video.removeEventListener( 'loadeddata', onLoaded, false );
+	}
 
-	}, false );
+	video.addEventListener( 'loadeddata', onLoaded, false );
 
 }