Browse Source

Update WebGLRenderer.js

Added check for mipmap level 0
Frank Olivier 5 years ago
parent
commit
5685eba453
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/renderers/WebGLRenderer.js

+ 4 - 4
src/renderers/WebGLRenderer.js

@@ -2801,7 +2801,7 @@ function WebGLRenderer( parameters ) {
 
 	};
 
-	this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level ) {
+	this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level = 0 ) {
 
 		var width = srcTexture.image.width;
 		var height = srcTexture.image.height;
@@ -2812,15 +2812,15 @@ function WebGLRenderer( parameters ) {
 
 		if ( srcTexture.isDataTexture ) {
 
-			_gl.texSubImage2D( _gl.TEXTURE_2D, level || 0, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
+			_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
 
 		} else {
 
-			_gl.texSubImage2D( _gl.TEXTURE_2D, level || 0, position.x, position.y, glFormat, glType, srcTexture.image );
+			_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );
 
 		}
 
-		if (dstTexture.generateMipmaps) _gl.generateMipmap( _gl.TEXTURE_2D );
+		if ( level == 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
 
 		state.unbindTexture();