浏览代码

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 );
 
 }