From 76a81c4cfd90532dee06220c81e18dd11efef97a Mon Sep 17 00:00:00 2001 From: Vicente Date: Thu, 31 Aug 2023 23:49:24 +0200 Subject: [PATCH 1/3] KTX2Loader: fix data textures --- examples/jsm/loaders/KTX2Loader.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/jsm/loaders/KTX2Loader.js b/examples/jsm/loaders/KTX2Loader.js index f1c2ed359ea799..8816a1893e7328 100644 --- a/examples/jsm/loaders/KTX2Loader.js +++ b/examples/jsm/loaders/KTX2Loader.js @@ -864,9 +864,13 @@ async function createRawTexture( container ) { if ( UNCOMPRESSED_FORMATS.has( FORMAT_MAP[ vkFormat ] ) ) { + const textureData = mipmaps.length > 0 ? mipmaps[ 0 ].data : null; + texture = container.pixelDepth === 0 - ? new DataTexture( mipmaps, container.pixelWidth, container.pixelHeight ) - : new Data3DTexture( mipmaps, container.pixelWidth, container.pixelHeight, container.pixelDepth ); + ? new DataTexture( textureData, container.pixelWidth, container.pixelHeight ) + : new Data3DTexture( textureData, container.pixelWidth, container.pixelHeight, container.pixelDepth ); + + texture.mipmaps = mipmaps; } else { @@ -874,8 +878,6 @@ async function createRawTexture( container ) { texture = new CompressedTexture( mipmaps, container.pixelWidth, container.pixelHeight ); - - } texture.mipmaps = mipmaps; From 3a789fe1ec30ea7e40127ecb4270adfaecf765f5 Mon Sep 17 00:00:00 2001 From: Vicente Date: Fri, 1 Sep 2023 00:05:10 +0200 Subject: [PATCH 2/3] remove redundant mipmap assignment --- examples/jsm/loaders/KTX2Loader.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/jsm/loaders/KTX2Loader.js b/examples/jsm/loaders/KTX2Loader.js index 8816a1893e7328..22bc6cb5fe605a 100644 --- a/examples/jsm/loaders/KTX2Loader.js +++ b/examples/jsm/loaders/KTX2Loader.js @@ -870,8 +870,6 @@ async function createRawTexture( container ) { ? new DataTexture( textureData, container.pixelWidth, container.pixelHeight ) : new Data3DTexture( textureData, container.pixelWidth, container.pixelHeight, container.pixelDepth ); - texture.mipmaps = mipmaps; - } else { if ( container.pixelDepth > 0 ) throw new Error( 'THREE.KTX2Loader: Unsupported pixelDepth.' ); From f234bb485a5bf078f5d7d4da69f1fa9f7c3aee1a Mon Sep 17 00:00:00 2001 From: Vicente Date: Fri, 1 Sep 2023 00:24:38 +0200 Subject: [PATCH 3/3] use first mipmap unconditionally --- examples/jsm/loaders/KTX2Loader.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/jsm/loaders/KTX2Loader.js b/examples/jsm/loaders/KTX2Loader.js index 22bc6cb5fe605a..3a2c1ca3727631 100644 --- a/examples/jsm/loaders/KTX2Loader.js +++ b/examples/jsm/loaders/KTX2Loader.js @@ -864,11 +864,9 @@ async function createRawTexture( container ) { if ( UNCOMPRESSED_FORMATS.has( FORMAT_MAP[ vkFormat ] ) ) { - const textureData = mipmaps.length > 0 ? mipmaps[ 0 ].data : null; - texture = container.pixelDepth === 0 - ? new DataTexture( textureData, container.pixelWidth, container.pixelHeight ) - : new Data3DTexture( textureData, container.pixelWidth, container.pixelHeight, container.pixelDepth ); + ? new DataTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight ) + : new Data3DTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight, container.pixelDepth ); } else {