Browse Source

WebGLRenderer: Handle incomplete images. See #6291.

Mr.doob 10 years ago
parent
commit
c06ebb822d
1 changed files with 12 additions and 4 deletions
  1. 12 4
      src/renderers/WebGLRenderer.js

+ 12 - 4
src/renderers/WebGLRenderer.js

@@ -5596,16 +5596,24 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		_gl.activeTexture( _gl.TEXTURE0 + slot );
 		_gl.activeTexture( _gl.TEXTURE0 + slot );
 
 
-		if ( texture.needsUpdate ) {
+		if ( texture.needsUpdate === true ) {
 
 
-			_this.uploadTexture( texture );
+			var image = texture.image;
 
 
-		} else {
+			if ( image.complete === false ) {
+
+				THREE.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete', texture );
+				return;
+
+			}
 
 
-			_gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture );
+			_this.uploadTexture( texture );
+			return;
 
 
 		}
 		}
 
 
+		_gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture );
+
 	};
 	};
 
 
 	function clampToMaxSize ( image, maxSize ) {
 	function clampToMaxSize ( image, maxSize ) {