浏览代码

#15162 fix: mark textures for update asynchronously

Daniel Toplak 6 年之前
父节点
当前提交
a8607ccb10
共有 1 个文件被更改,包括 14 次插入2 次删除
  1. 14 2
      examples/js/postprocessing/SMAAPass.js

+ 14 - 2
examples/js/postprocessing/SMAAPass.js

@@ -37,7 +37,7 @@ THREE.SMAAPass = function ( width, height ) {
 	this.areaTexture.format = THREE.RGBFormat;
 	this.areaTexture.minFilter = THREE.LinearFilter;
 	this.areaTexture.generateMipmaps = false;
-	this.areaTexture.needsUpdate = true;
+	this.areaTexture.needsUpdate = false;
 	this.areaTexture.flipY = false;
 
 	var searchTextureImage = new Image();
@@ -49,9 +49,21 @@ THREE.SMAAPass = function ( width, height ) {
 	this.searchTexture.magFilter = THREE.NearestFilter;
 	this.searchTexture.minFilter = THREE.NearestFilter;
 	this.searchTexture.generateMipmaps = false;
-	this.searchTexture.needsUpdate = true;
+	this.searchTexture.needsUpdate = false;
 	this.searchTexture.flipY = false;
 
+	var self = this;
+
+	setTimeout( function () {
+
+		// assigning data to HTMLImageElement.src is asynchronous (see #15162)
+		// using setTimeout() avoids the warning "Texture marked for update but image is incomplete"
+
+		self.searchTexture.needsUpdate = true;
+		self.areaTexture.needsUpdate = true;
+
+	}, 0 );
+
 	// materials - pass 1
 
 	if ( THREE.SMAAShader === undefined ) {