Parcourir la source

WebGLRenderer: Handle incomplete images. See #6291.

Mr.doob il y a 10 ans
Parent
commit
c06ebb822d
1 fichiers modifiés avec 12 ajouts et 4 suppressions
  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 );
 
-		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 ) {