CompressedTextureLoader
Loader for compressed texture containers in the KTX, DDS and PVR formats.
| Loader | Characteristic |
|---|---|
| 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/textures';
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 encoder runtime through options.modules.
modules.basisEncoder: supply a preloaded Basis encoder module that resolves to{BasisFile, KTX2File, BasisEncoder}.'basis_encoder.js': override the URL used for the Basis encoder JavaScript wrapper.'basis_encoder.wasm': override the URL used for the Basis encoder WebAssembly binary.