Loads the Basis Codec from CDN by default, but can
also be configured to load the Codec from local files.
We also bundle the Basis Codec with the xeokit-viewer npm package, and in the repository.
What is KTX2?
A KTX2 file stores GPU texture data in the Khronos SceneTexture 2.0 (KTX2) container format. It contains image data for
a texture asset compressed with Basis Universal (BasisU) supercompression that can be transcoded to different formats
depending on the support provided by the target devices. KTX2 provides a lightweight format for distributing texture
assets to GPUs. Due to BasisU compression, KTX2 files can store any image format supported by GPUs.
Installation
npminstall@xeokit/sdk
Usage
Loading a glTF file containing KTX2 textures into a Viewer
Create a Viewer with a WebGLRenderer configured with a
KTX2TextureTranscoder. Then create a SceneModel within the Viewer, and use loadGLTF to
load a glTF file with KTX2-compressed textures into the SceneModel. For each KTX2 texture in the file, the
KTX2TextureTranscoder will transparently transcode the KTX2 data for us.
This time, we'll build the SceneModel ourselves, using its builder methods. When we
call builder method SceneModel.createTexture with a path to a KTX2-compressed texture file, the
KTX2TextureTranscoder will transparently transcode that KTX2 data for us.
Once more, build the SceneModel using its builder methods. This time, call builder method
SceneModel.createTexture with an ArrayBuffer containing the contents of a KTX2-compressed texture
file. As before, the KTX2TextureTranscoder will transparently transcode that KTX2 data for us.
xeokit KTX2 SceneTexture Transcoder
Enables the xeokit Viewer to load KTX2-compressed textures
What is KTX2?
A KTX2 file stores GPU texture data in the Khronos SceneTexture 2.0 (KTX2) container format. It contains image data for a texture asset compressed with Basis Universal (BasisU) supercompression that can be transcoded to different formats depending on the support provided by the target devices. KTX2 provides a lightweight format for distributing texture assets to GPUs. Due to BasisU compression, KTX2 files can store any image format supported by GPUs.
Installation
Usage
Loading a glTF file containing KTX2 textures into a Viewer
Create a Viewer with a WebGLRenderer configured with a KTX2TextureTranscoder. Then create a SceneModel within the Viewer, and use loadGLTF to load a glTF file with KTX2-compressed textures into the SceneModel. For each KTX2 texture in the file, the KTX2TextureTranscoder will transparently transcode the KTX2 data for us.
Loading KTX2 texture files into a Viewer
As in the previous example, create a Viewer with a WebGLRenderer configured with a KTX2TextureTranscoder, then create a SceneModel within the Viewer.
This time, we'll build the SceneModel ourselves, using its builder methods. When we call builder method SceneModel.createTexture with a path to a KTX2-compressed texture file, the KTX2TextureTranscoder will transparently transcode that KTX2 data for us.
Loading KTX2 texture ArrayBuffers into a Viewer
As in the previous two examples, create a Viewer that has a WebGLRenderer configured with a KTX2TextureTranscoder, and then create a SceneModel within the Viewer.
Once more, build the SceneModel using its builder methods. This time, call builder method SceneModel.createTexture with an ArrayBuffer containing the contents of a KTX2-compressed texture file. As before, the KTX2TextureTranscoder will transparently transcode that KTX2 data for us.