loadKTX

loadKTX(resourceOrUrlOrBuffer)Promise.<CompressedTextureBuffer>|undefined

异步加载和解析给定的URL到KTX文件或解析KTX文件的原始二进制数据。 返回一个promise,它将在加载后解析为包含图像缓冲区、宽度、高度和格式的对象, 如果URL无法加载或无法解析数据,则拒绝。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。

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 二进制数据或ArrayBuffer的URL。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Throws:
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
});
See: