File: KTX2Loader.md | Updated: 11/15/2025
A loader for KTX 2.0 GPU Texture containers.
KTX 2.0 is a container format for various GPU texture formats. The loader supports Basis Universal GPU textures, which can be quickly transcoded to a wide variety of GPU texture compression formats. While KTX 2.0 also allows other hardware-specific formats, this loader does not yet parse them.
This loader parses the KTX 2.0 container and transcodes to a supported GPU compressed texture format. The required WASM transcoder and JS wrapper are available from the examples/jsm/libs/basis directory.
This loader relies on Web Assembly which is not supported in older browsers.
References:
const loader = new KTX2Loader();
loader.setTranscoderPath( 'examples/jsm/libs/basis/' );
loader.detectSupport( renderer );
const texture = loader.loadAsync( 'diffuse.ktx2' );
KTX2Loader is an addon, and must be imported explicitly, see Installation#Addons.
import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
Constructs a new KTX2 loader.
manager | The loading manager.
---|---
Detects hardware support for available compressed texture formats, to determine the output format for the transcoder. Must be called before loading a texture.
renderer | The renderer.
---|---
Returns: A reference to this loader.
Async version of KTX2Loader#detectSupport.
renderer | The renderer.
---|---
Deprecated: Yes
Returns: A Promise that resolves when the support has been detected.
Frees internal resources. This method should be called when the loader is no longer required.
Starts loading from the given URL and passes the loaded KTX2 texture to the onLoad() callback.
url | The path/URL of the file to be loaded. This can also be a data URI.
---|---
onLoad | Executed when the loading process has been finished.
onProgress | Executed while the loading is in progress.
onError | Executed when errors occur.
Overrides: Loader#load
Parses the given KTX2 data.
buffer | The raw KTX2 data as an array buffer.
---|---
onLoad | Executed when the loading/parsing process has been finished.
onError | Executed when errors occur.
Overrides: Loader#parse
Returns: A Promise that resolves when the parsing has been finished.
Sets the transcoder path.
The WASM transcoder and JS wrapper are available from the examples/jsm/libs/basis directory.
path | The transcoder path to set.
---|---
Returns: A reference to this loader.
Sets the maximum number of Web Workers to be allocated by this instance.
workerLimit | The worker limit.
---|---
Returns: A reference to this loader.