diff --git a/public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0.py b/public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0.py index 6998b16c..126ffafa 100644 --- a/public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0.py +++ b/public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0.py @@ -56,7 +56,7 @@ def load_byte_array_from_file(file_path): with open("t1_icbm_normal_1mm_pn0_rf0_180x216x180_uint8_1x1.bin", "rb") as f: bytes_data = f.read() -gzip_filename = "t1_icbm_normal_1mm_pn0_rf0_180x216x180_uint8_1x1.bin.gz" +gzip_filename = "t1_icbm_normal_1mm_pn0_rf0_180x216x180_uint8_1x1.bin-gz" with gzip.open(gzip_filename, "wb", compresslevel=9) as f: f.write(bytes_data) diff --git a/public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_astc_12x12.bin.gz b/public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_astc_12x12.bin-gz similarity index 100% rename from public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_astc_12x12.bin.gz rename to public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_astc_12x12.bin-gz diff --git a/public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_bc4_4x4.bin.gz b/public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_bc4_4x4.bin-gz similarity index 100% rename from public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_bc4_4x4.bin.gz rename to public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_bc4_4x4.bin-gz diff --git a/public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_uint8_1x1.bin.gz b/public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_uint8_1x1.bin-gz similarity index 100% rename from public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_uint8_1x1.bin.gz rename to public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_uint8_1x1.bin-gz diff --git a/sample/volumeRenderingTexture3D/main.ts b/sample/volumeRenderingTexture3D/main.ts index 3319b69b..7af19ede 100644 --- a/sample/volumeRenderingTexture3D/main.ts +++ b/sample/volumeRenderingTexture3D/main.ts @@ -14,14 +14,14 @@ const brainImages = { blockLength: 1, feature: undefined, dataPath: - '../../assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_uint8_1x1.bin.gz', + '../../assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_uint8_1x1.bin-gz', }, 'bc4-r-unorm': { bytesPerBlock: 8, blockLength: 4, feature: 'texture-compression-bc-sliced-3d', dataPath: - '../../assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_bc4_4x4.bin.gz', + '../../assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_bc4_4x4.bin-gz', // Generated with texconv from https://github.com/microsoft/DirectXTex/releases }, 'astc-12x12-unorm': { @@ -29,7 +29,7 @@ const brainImages = { blockLength: 12, feature: 'texture-compression-astc-sliced-3d', dataPath: - '../../assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_astc_12x12.bin.gz', + '../../assets/img/volume/t1_icbm_normal_1mm_pn0_rf0_180x216x180_astc_12x12.bin-gz', // Generated with astcenc from https://github.com/ARM-software/astc-encoder/releases }, }; @@ -158,11 +158,20 @@ async function createVolumeTexture(format: GPUTextureFormat) { }); const response = await fetch(dataPath); - const buffer = await response.arrayBuffer(); - + const compressedBlob = await response.blob(); + + // Decompress the data using DecompressionStream for gzip format + const decompressionStream = new DecompressionStream('gzip'); + const decompressedStream = compressedBlob + .stream() + .pipeThrough(decompressionStream); + const decompressedArrayBuffer = await new Response( + decompressedStream + ).arrayBuffer(); + const byteArray = new Uint8Array(decompressedArrayBuffer); device.queue.writeTexture( { texture: volumeTexture }, - buffer, + byteArray, { bytesPerRow: bytesPerRow, rowsPerImage: blocksHigh }, [width, height, depth] );