@@ -2107,7 +2107,9 @@ function WebGLRenderer( parameters ) {
21072107
21082108 }
21092109
2110- const { width, height, data } = srcTexture . image ;
2110+ const width = sourceBox . max . x - sourceBox . min . x + 1 ;
2111+ const height = sourceBox . max . y - sourceBox . min . y + 1 ;
2112+ const depth = sourceBox . max . z - sourceBox . min . z + 1 ;
21112113 const glFormat = utils . convert ( dstTexture . format ) ;
21122114 const glType = utils . convert ( dstTexture . type ) ;
21132115 let glTarget ;
@@ -2139,25 +2141,32 @@ function WebGLRenderer( parameters ) {
21392141 const unpackSkipRows = _gl . getParameter ( _gl . UNPACK_SKIP_ROWS ) ;
21402142 const unpackSkipImages = _gl . getParameter ( _gl . UNPACK_SKIP_IMAGES ) ;
21412143
2142- _gl . pixelStorei ( _gl . UNPACK_ROW_LENGTH , width ) ;
2143- _gl . pixelStorei ( _gl . UNPACK_IMAGE_HEIGHT , height ) ;
2144+ const image = srcTexture . isCompressedTexture ? srcTexture . mipmaps [ 0 ] : srcTexture . image ;
2145+
2146+ _gl . pixelStorei ( _gl . UNPACK_ROW_LENGTH , image . width ) ;
2147+ _gl . pixelStorei ( _gl . UNPACK_IMAGE_HEIGHT , image . height ) ;
21442148 _gl . pixelStorei ( _gl . UNPACK_SKIP_PIXELS , sourceBox . min . x ) ;
21452149 _gl . pixelStorei ( _gl . UNPACK_SKIP_ROWS , sourceBox . min . y ) ;
21462150 _gl . pixelStorei ( _gl . UNPACK_SKIP_IMAGES , sourceBox . min . z ) ;
21472151
2148- _gl . texSubImage3D (
2149- glTarget ,
2150- level ,
2151- position . x ,
2152- position . y ,
2153- position . z ,
2154- sourceBox . max . x - sourceBox . min . x + 1 ,
2155- sourceBox . max . y - sourceBox . min . y + 1 ,
2156- sourceBox . max . z - sourceBox . min . z + 1 ,
2157- glFormat ,
2158- glType ,
2159- data
2160- ) ;
2152+ if ( srcTexture . isDataTexture || srcTexture . isDataTexture3D ) {
2153+
2154+ _gl . texSubImage3D ( glTarget , level , position . x , position . y , position . z , width , height , depth , glFormat , glType , image . data ) ;
2155+
2156+ } else {
2157+
2158+ if ( srcTexture . isCompressedTexture ) {
2159+
2160+ console . warn ( 'THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.' ) ;
2161+ _gl . compressedTexSubImage3D ( glTarget , level , position . x , position . y , position . z , width , height , depth , glFormat , image . data ) ;
2162+
2163+ } else {
2164+
2165+ _gl . texSubImage3D ( glTarget , level , position . x , position . y , position . z , width , height , depth , glFormat , glType , image ) ;
2166+
2167+ }
2168+
2169+ }
21612170
21622171 _gl . pixelStorei ( _gl . UNPACK_ROW_LENGTH , unpackRowLen ) ;
21632172 _gl . pixelStorei ( _gl . UNPACK_IMAGE_HEIGHT , unpackImageHeight ) ;
0 commit comments