diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index 3c609c2d03f335..4c2da6447ba739 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -122,13 +122,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - function generateMipmap( target, texture, width, height ) { + function generateMipmap( target, texture, width, height, depth = 1 ) { _gl.generateMipmap( target ); const textureProperties = properties.get( texture ); - textureProperties.__maxMipLevel = Math.log2( Math.max( width, height ) ); + textureProperties.__maxMipLevel = Math.log2( Math.max( width, height, depth ) ); } @@ -1230,11 +1230,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { - generateMipmap( _gl.TEXTURE_2D, texture, renderTarget.width, renderTarget.height ); + generateMipmap( glTextureType, texture, renderTarget.width, renderTarget.height, renderTarget.depth ); } - state.bindTexture( _gl.TEXTURE_2D, null ); + state.bindTexture( glTextureType, null ); }