Преглед на файлове

Merge pull request #12809 from Mugen87/dev9

VideoTexture: Start update when first frame is loaded
Mr.doob преди 7 години
родител
ревизия
d271f4d235
променени са 1 файла, в които са добавени 12 реда и са изтрити 1 реда
  1. 12 1
      src/textures/VideoTexture.js

+ 12 - 1
src/textures/VideoTexture.js

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