@@ -16,6 +16,8 @@ import {
1616 CompressedArrayTexture ,
1717 CompressedCubeTexture ,
1818 Data3DTexture ,
19+ DataArrayTexture ,
20+ DataCubeTexture ,
1921 DataTexture ,
2022 DisplayP3ColorSpace ,
2123 FileLoader ,
@@ -796,7 +798,6 @@ async function createRawTexture( container ) {
796798
797799 const mipmaps = [ ] ;
798800
799-
800801 for ( let levelIndex = 0 ; levelIndex < container . levels . length ; levelIndex ++ ) {
801802
802803 const levelWidth = Math . max ( 1 , container . pixelWidth >> levelIndex ) ;
@@ -864,19 +865,55 @@ async function createRawTexture( container ) {
864865
865866 if ( UNCOMPRESSED_FORMATS . has ( FORMAT_MAP [ vkFormat ] ) ) {
866867
867- texture = container . pixelDepth === 0
868- ? new DataTexture ( mipmaps [ 0 ] . data , container . pixelWidth , container . pixelHeight )
869- : new Data3DTexture ( mipmaps [ 0 ] . data , container . pixelWidth , container . pixelHeight , container . pixelDepth ) ;
868+ if ( container . faceCount === 6 ) {
869+
870+ texture = new DataCubeTexture ( mipmaps [ 0 ] . data , container . pixelWidth , container . pixelHeight ) ;
871+
872+ } else if ( container . layerCount > 1 ) {
873+
874+ texture = new DataArrayTexture ( mipmaps [ 0 ] . data , container . pixelWidth , container . pixelHeight , container . layerCount ) ;
875+
876+ } else if ( container . pixelDepth === 0 ) {
877+
878+ texture = new DataTexture ( mipmaps [ 0 ] . data , container . pixelWidth , container . pixelHeight ) ;
879+
880+ } else {
881+
882+ texture = new Data3DTexture ( mipmaps [ 0 ] . data , container . pixelWidth , container . pixelHeight , container . pixelDepth ) ;
883+
884+ }
870885
871886 } else {
872887
873- if ( container . pixelDepth > 0 ) throw new Error ( 'THREE.KTX2Loader: Unsupported pixelDepth.' ) ;
888+ if ( container . faceCount === 6 ) {
889+
890+ texture = new CompressedCubeTexture ( mipmaps ) ;
874891
875- texture = new CompressedTexture ( mipmaps , container . pixelWidth , container . pixelHeight ) ;
892+ } else if ( container . layerCount > 1 ) {
893+
894+ texture = new CompressedArrayTexture ( mipmaps , container . pixelWidth , container . pixelHeight , container . layerCount ) ;
895+
896+ } else if ( container . pixelDepth === 0 ) {
897+
898+ texture = new CompressedTexture ( mipmaps , container . pixelWidth , container . pixelHeight ) ;
899+
900+ } else {
901+
902+ throw new Error ( 'THREE.KTX2Loader: Unsupported pixelDepth.' ) ;
903+
904+ }
876905
877906 }
878907
879- texture . mipmaps = mipmaps ;
908+ if ( texture . isDataCubeTexture ) {
909+
910+ texture . mipmaps = mipmaps . map ( ( mip ) => new DataCubeTexture ( mip . data , mip . width , mip . height ) ) ;
911+
912+ } else {
913+
914+ texture . mipmaps = mipmaps ;
915+
916+ }
880917
881918 texture . type = TYPE_MAP [ vkFormat ] ;
882919 texture . format = FORMAT_MAP [ vkFormat ] ;
0 commit comments