loadKTX(resourceOrUrlOrBuffer) → Promise.<CompressedTextureBuffer>|undefined
Asynchronously loads and parses the given URL to a KTX file or parses the raw binary data of a KTX file.
Returns a promise that will resolve to an object containing the image buffer, width, height and format once loaded,
or reject if the URL failed to load or failed to parse the data. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
The following are part of the KTX format specification but are not supported:
- Big-endian files
- Metadata
- 3D textures
- Texture Arrays
- Cubemaps
- Mipmaps
Name | Type | Description |
---|---|---|
resourceOrUrlOrBuffer |
Resource | String | ArrayBuffer | The URL of the binary data or an ArrayBuffer. |
Returns:
A promise that will resolve to the requested data when loaded. Returns undefined if
request.throttle
is true and the request does not have high enough priority.
Throws:
-
RuntimeError : Invalid KTX file.
-
RuntimeError : File is the wrong endianness.
-
RuntimeError : glInternalFormat is not a valid format.
-
RuntimeError : glType must be zero when the texture is compressed.
-
RuntimeError : The type size for compressed textures must be 1.
-
RuntimeError : glFormat must be zero when the texture is compressed.
-
RuntimeError : Generating mipmaps for a compressed texture is unsupported.
-
RuntimeError : The base internal format must be the same as the format for uncompressed textures.
-
RuntimeError : 3D textures are not supported.
-
RuntimeError : Texture arrays are not supported.
-
RuntimeError : Cubemaps are not supported.
Example:
// load a single URL asynchronously
Cesium.loadKTX('some/url').then(function(ktxData) {
var width = ktxData.width;
var height = ktxData.height;
var format = ktxData.internalFormat;
var arrayBufferView = ktxData.bufferView;
// use the data to create a texture
}).otherwise(function(error) {
// an error occurred
});