Container in, levels out
Keep the data in the form a renderer expects.
The loader returns normalized levels rather than a browser image object. That makes container metadata available to WebGL, WebGPU, and application-specific texture upload code.
Reads
KTX, KTX2, DDS, and PVR containers
Preserves
Dimensions, mip levels, compression, and format tags
Returns
TextureLevel[] with typed payloads
Pairs with
BasisLoader for KTX2 Basis transcoding
Loader for compressed texture containers in the KTX, DDS and PVR formats.
Detailed guide
Compressed texture details
The sections below cover container support, usage, normalized texture levels, and format-specific metadata.
| CompressedTextureLoader | |
|---|---|
| File Format | PVR, DDS, KTX |
| File Extension | .dds, .pvr, .ktx, .ktx2 |
| File Type | Binary |
| Data Format | TextureLevel[] |
| Supported APIs | load, parse |
Usage
import {CompressedTextureLoader} from '@loaders.gl/images/texture';
import {load} from '@loaders.gl/core';
const mipLevels = await load(url, CompressedTextureLoader);
for (const level of mipLevels) {
console.log(level.shape, level.format, level.textureFormat);
}
Data Format
Returns TextureLevel[], one entry per mip level.
Each level includes:
shape: 'texture-level'compressedformattextureFormatwidthheightdatalevelSizewhen available
Options
| Option | Type | Default | Description |
|---|---|---|---|
compressed-texture.useBasis | Boolean | false | Use BasisLoader to decode KTX2 texture |
Basis loader
Use BasisLoader for KTX2 assets that need Basis transcoding.
Module Overrides
When compressed-texture.useBasis is true, CompressedTextureLoader uses the Basis transcoder runtime through options.modules.
modules.basis: supply a preloaded transcoder module containingKTX2File.'basis_transcoder.js': override the transcoder JavaScript wrapper URL.'basis_transcoder.wasm': override the transcoder WebAssembly URL.