diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index 5663c8e8affb88..def81cbdf66d53 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -117,6 +117,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } + function getTargetType( texture ) { + + if ( texture.isWebGLCubeRenderTarget ) return _gl.TEXTURE_CUBE_MAP; + if ( texture.isWebGL3DRenderTarget ) return _gl.TEXTURE_3D; + if ( texture.isWebGLArrayRenderTarget || texture.isCompressedArrayTexture ) return _gl.TEXTURE_2D_ARRAY; + return _gl.TEXTURE_2D; + + } + function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) { if ( internalFormatName !== null ) { @@ -1927,11 +1936,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( textureNeedsGenerateMipmaps( texture ) ) { - const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D; + const targetType = getTargetType( renderTarget ); const webglTexture = properties.get( texture ).__webglTexture; - state.bindTexture( target, webglTexture ); - generateMipmap( target ); + state.bindTexture( targetType, webglTexture ); + generateMipmap( targetType ); state.unbindTexture(); }