UNPKG

@loaders.gl/textures

Version:

Framework-independent loaders for compressed and super compressed (basis) textures

1,266 lines (1,251 loc) 94.3 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // dist/index.js var dist_exports = {}; __export(dist_exports, { BASIS_EXTERNAL_LIBRARIES: () => BASIS_EXTERNAL_LIBRARIES, BasisLoader: () => BasisLoader, BasisWorkerLoader: () => BasisWorkerLoader, CRUNCH_EXTERNAL_LIBRARIES: () => CRUNCH_EXTERNAL_LIBRARIES, CompressedTextureLoader: () => CompressedTextureLoader, CompressedTextureWorkerLoader: () => CompressedTextureWorkerLoader, CompressedTextureWriter: () => CompressedTextureWriter, CrunchLoader: () => CrunchLoader, CrunchWorkerLoader: () => CrunchLoader, GL_COMPRESSED_R11_EAC: () => GL_COMPRESSED_R11_EAC, GL_COMPRESSED_RED_GREEN_RGTC2_EXT: () => GL_COMPRESSED_RED_GREEN_RGTC2_EXT, GL_COMPRESSED_RED_RGTC1_EXT: () => GL_COMPRESSED_RED_RGTC1_EXT, GL_COMPRESSED_RG11_EAC: () => GL_COMPRESSED_RG11_EAC, GL_COMPRESSED_RGB8_ETC2: () => GL_COMPRESSED_RGB8_ETC2, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: () => GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_RGBA8_ETC2_EAC: () => GL_COMPRESSED_RGBA8_ETC2_EAC, GL_COMPRESSED_RGBA_ASTC_10x10_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x10_KHR, GL_COMPRESSED_RGBA_ASTC_10x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_COMPRESSED_RGBA_ASTC_10x6_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x6_KHR, GL_COMPRESSED_RGBA_ASTC_10x8_KHR: () => GL_COMPRESSED_RGBA_ASTC_10x8_KHR, GL_COMPRESSED_RGBA_ASTC_12x10_KHR: () => GL_COMPRESSED_RGBA_ASTC_12x10_KHR, GL_COMPRESSED_RGBA_ASTC_12x12_KHR: () => GL_COMPRESSED_RGBA_ASTC_12x12_KHR, GL_COMPRESSED_RGBA_ASTC_4x4_KHR: () => GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_COMPRESSED_RGBA_ASTC_5x4_KHR: () => GL_COMPRESSED_RGBA_ASTC_5x4_KHR, GL_COMPRESSED_RGBA_ASTC_5x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_COMPRESSED_RGBA_ASTC_6x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_6x5_KHR, GL_COMPRESSED_RGBA_ASTC_6x6_KHR: () => GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x5_KHR: () => GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_COMPRESSED_RGBA_ASTC_8x6_KHR: () => GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x8_KHR: () => GL_COMPRESSED_RGBA_ASTC_8x8_KHR, GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: () => GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: () => GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT: () => GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: () => GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: () => GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: () => GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: () => GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: () => GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGB_ATC_WEBGL: () => GL_COMPRESSED_RGB_ATC_WEBGL, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: () => GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: () => GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, GL_COMPRESSED_RGB_ETC1_WEBGL: () => GL_COMPRESSED_RGB_ETC1_WEBGL, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: () => GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: () => GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, GL_COMPRESSED_RGB_S3TC_DXT1_EXT: () => GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_SIGNED_R11_EAC: () => GL_COMPRESSED_SIGNED_R11_EAC, GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: () => GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, GL_COMPRESSED_SIGNED_RED_RGTC1_EXT: () => GL_COMPRESSED_SIGNED_RED_RGTC1_EXT, GL_COMPRESSED_SIGNED_RG11_EAC: () => GL_COMPRESSED_SIGNED_RG11_EAC, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: () => GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: () => GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_COMPRESSED_SRGB8_ETC2: () => GL_COMPRESSED_SRGB8_ETC2, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: () => GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: () => GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: () => GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: () => GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: () => GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: () => GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_EXTENSIONS_CONSTANTS: () => GL_EXTENSIONS_CONSTANTS, GL_RGB: () => GL_RGB, GL_RGB565: () => GL_RGB565, GL_RGB5_A1: () => GL_RGB5_A1, GL_RGBA: () => GL_RGBA, GL_RGBA32F: () => GL_RGBA32F, GL_RGBA4: () => GL_RGBA4, GL_RGBA8: () => GL_RGBA8, KTX2BasisWriter: () => KTX2BasisWriter, KTX2BasisWriterWorker: () => KTX2BasisWriterWorker, NPYLoader: () => NPYLoader, NPYWorkerLoader: () => NPYWorkerLoader, RadianceHDRLoader: () => RadianceHDRLoader, TextureArrayLoader: () => TextureArrayLoader, TextureCubeArrayLoader: () => TextureCubeArrayLoader, TextureCubeLoader: () => TextureCubeLoader, TextureLoader: () => TextureLoader, loadImageTexture: () => loadImageTexture, loadImageTextureArray: () => loadImageTextureArray, loadImageTextureCube: () => loadImageTextureCube }); module.exports = __toCommonJS(dist_exports); // dist/lib/utils/version.js var VERSION = true ? "4.4.2" : "latest"; // dist/lib/parsers/parse-basis.js var import_worker_utils2 = require("@loaders.gl/worker-utils"); // dist/lib/parsers/basis-module-loader.js var import_loader_utils = require("@loaders.gl/loader-utils"); var import_worker_utils = require("@loaders.gl/worker-utils"); var BASIS_EXTERNAL_LIBRARIES = { /** Basis transcoder, javascript wrapper part */ TRANSCODER: "basis_transcoder.js", /** Basis transcoder, compiled web assembly part */ TRANSCODER_WASM: "basis_transcoder.wasm", /** Basis encoder, javascript wrapper part */ ENCODER: "basis_encoder.js", /** Basis encoder, compiled web assembly part */ ENCODER_WASM: "basis_encoder.wasm" }; var loadBasisTranscoderPromise; async function loadBasisTranscoderModule(options) { (0, import_loader_utils.registerJSModules)(options.modules); const basis = (0, import_loader_utils.getJSModuleOrNull)("basis"); if (basis) { return basis; } loadBasisTranscoderPromise ||= loadBasisTranscoder(options); return await loadBasisTranscoderPromise; } async function loadBasisTranscoder(options) { let BASIS = null; let wasmBinary = null; [BASIS, wasmBinary] = await Promise.all([ await (0, import_worker_utils.loadLibrary)(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options), await (0, import_worker_utils.loadLibrary)(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options) ]); BASIS = BASIS || globalThis.BASIS; return await initializeBasisTranscoderModule(BASIS, wasmBinary); } function initializeBasisTranscoderModule(BasisModule, wasmBinary) { const options = {}; if (wasmBinary) { options.wasmBinary = wasmBinary; } return new Promise((resolve) => { BasisModule(options).then((module2) => { const { BasisFile, initializeBasis } = module2; initializeBasis(); resolve({ BasisFile }); }); }); } var loadBasisEncoderPromise; async function loadBasisEncoderModule(options) { const modules = options.modules || {}; if (modules.basisEncoder) { return modules.basisEncoder; } loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options); return await loadBasisEncoderPromise; } async function loadBasisEncoder(options) { let BASIS_ENCODER = null; let wasmBinary = null; [BASIS_ENCODER, wasmBinary] = await Promise.all([ await (0, import_worker_utils.loadLibrary)(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options), await (0, import_worker_utils.loadLibrary)(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options) ]); BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS; return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary); } function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) { const options = {}; if (wasmBinary) { options.wasmBinary = wasmBinary; } return new Promise((resolve) => { BasisEncoderModule(options).then((module2) => { const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module2; initializeBasis(); resolve({ BasisFile, KTX2File, BasisEncoder }); }); }); } // dist/lib/gl-extensions.js var GL_RGB = 6407; var GL_RGBA = 6408; var GL_RGBA4 = 32854; var GL_RGB5_A1 = 32855; var GL_RGBA8 = 32856; var GL_RGB565 = 36194; var GL_RGBA32F = 34836; var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776; var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777; var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778; var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779; var GL_COMPRESSED_R11_EAC = 37488; var GL_COMPRESSED_SIGNED_R11_EAC = 37489; var GL_COMPRESSED_RG11_EAC = 37490; var GL_COMPRESSED_SIGNED_RG11_EAC = 37491; var GL_COMPRESSED_RGB8_ETC2 = 37492; var GL_COMPRESSED_RGBA8_ETC2_EAC = 37493; var GL_COMPRESSED_SRGB8_ETC2 = 37494; var GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 37495; var GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37496; var GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37497; var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840; var GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 35841; var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842; var GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 35843; var GL_COMPRESSED_RGB_ETC1_WEBGL = 36196; var GL_COMPRESSED_RGB_ATC_WEBGL = 35986; var GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 35987; var GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 34798; var GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 37808; var GL_COMPRESSED_RGBA_ASTC_5x4_KHR = 37809; var GL_COMPRESSED_RGBA_ASTC_5x5_KHR = 37810; var GL_COMPRESSED_RGBA_ASTC_6x5_KHR = 37811; var GL_COMPRESSED_RGBA_ASTC_6x6_KHR = 37812; var GL_COMPRESSED_RGBA_ASTC_8x5_KHR = 37813; var GL_COMPRESSED_RGBA_ASTC_8x6_KHR = 37814; var GL_COMPRESSED_RGBA_ASTC_8x8_KHR = 37815; var GL_COMPRESSED_RGBA_ASTC_10x5_KHR = 37816; var GL_COMPRESSED_RGBA_ASTC_10x6_KHR = 37817; var GL_COMPRESSED_RGBA_ASTC_10x8_KHR = 37818; var GL_COMPRESSED_RGBA_ASTC_10x10_KHR = 37819; var GL_COMPRESSED_RGBA_ASTC_12x10_KHR = 37820; var GL_COMPRESSED_RGBA_ASTC_12x12_KHR = 37821; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 37840; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 37841; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 37842; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 37843; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 37844; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 37845; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 37846; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 37847; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 37848; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 37849; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 37850; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 37851; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 37852; var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 37853; var GL_COMPRESSED_RED_RGTC1_EXT = 36283; var GL_COMPRESSED_SIGNED_RED_RGTC1_EXT = 36284; var GL_COMPRESSED_RED_GREEN_RGTC2_EXT = 36285; var GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 36286; var GL_COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492; var GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = 36493; var GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT = 36494; var GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT = 36495; var GL_COMPRESSED_SRGB_S3TC_DXT1_EXT = 35916; var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 35917; var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 35918; var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 35919; var GL_EXTENSIONS_CONSTANTS = { RGB: GL_RGB, RGBA: GL_RGBA, RGBA4: GL_RGBA4, RGB5_A1: GL_RGB5_A1, RGBA8: GL_RGBA8, RGB565: GL_RGB565, RGBA32F: GL_RGBA32F, COMPRESSED_RGB_S3TC_DXT1_EXT: GL_COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, COMPRESSED_RGBA_S3TC_DXT5_EXT: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, COMPRESSED_R11_EAC: GL_COMPRESSED_R11_EAC, COMPRESSED_SIGNED_R11_EAC: GL_COMPRESSED_SIGNED_R11_EAC, COMPRESSED_RG11_EAC: GL_COMPRESSED_RG11_EAC, COMPRESSED_SIGNED_RG11_EAC: GL_COMPRESSED_SIGNED_RG11_EAC, COMPRESSED_RGB8_ETC2: GL_COMPRESSED_RGB8_ETC2, COMPRESSED_RGBA8_ETC2_EAC: GL_COMPRESSED_RGBA8_ETC2_EAC, COMPRESSED_SRGB8_ETC2: GL_COMPRESSED_SRGB8_ETC2, COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, COMPRESSED_RGB_PVRTC_4BPPV1_IMG: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, COMPRESSED_RGB_PVRTC_2BPPV1_IMG: GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, COMPRESSED_RGB_ETC1_WEBGL: GL_COMPRESSED_RGB_ETC1_WEBGL, COMPRESSED_RGB_ATC_WEBGL: GL_COMPRESSED_RGB_ATC_WEBGL, COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, COMPRESSED_RGBA_ASTC_4x4_KHR: GL_COMPRESSED_RGBA_ASTC_4x4_KHR, COMPRESSED_RGBA_ASTC_5x4_KHR: GL_COMPRESSED_RGBA_ASTC_5x4_KHR, COMPRESSED_RGBA_ASTC_5x5_KHR: GL_COMPRESSED_RGBA_ASTC_5x5_KHR, COMPRESSED_RGBA_ASTC_6x5_KHR: GL_COMPRESSED_RGBA_ASTC_6x5_KHR, COMPRESSED_RGBA_ASTC_6x6_KHR: GL_COMPRESSED_RGBA_ASTC_6x6_KHR, COMPRESSED_RGBA_ASTC_8x5_KHR: GL_COMPRESSED_RGBA_ASTC_8x5_KHR, COMPRESSED_RGBA_ASTC_8x6_KHR: GL_COMPRESSED_RGBA_ASTC_8x6_KHR, COMPRESSED_RGBA_ASTC_8x8_KHR: GL_COMPRESSED_RGBA_ASTC_8x8_KHR, COMPRESSED_RGBA_ASTC_10x5_KHR: GL_COMPRESSED_RGBA_ASTC_10x5_KHR, COMPRESSED_RGBA_ASTC_10x6_KHR: GL_COMPRESSED_RGBA_ASTC_10x6_KHR, COMPRESSED_RGBA_ASTC_10x8_KHR: GL_COMPRESSED_RGBA_ASTC_10x8_KHR, COMPRESSED_RGBA_ASTC_10x10_KHR: GL_COMPRESSED_RGBA_ASTC_10x10_KHR, COMPRESSED_RGBA_ASTC_12x10_KHR: GL_COMPRESSED_RGBA_ASTC_12x10_KHR, COMPRESSED_RGBA_ASTC_12x12_KHR: GL_COMPRESSED_RGBA_ASTC_12x12_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, COMPRESSED_RED_RGTC1_EXT: GL_COMPRESSED_RED_RGTC1_EXT, COMPRESSED_SIGNED_RED_RGTC1_EXT: GL_COMPRESSED_SIGNED_RED_RGTC1_EXT, COMPRESSED_RED_GREEN_RGTC2_EXT: GL_COMPRESSED_RED_GREEN_RGTC2_EXT, COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, COMPRESSED_RGBA_BPTC_UNORM_EXT: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, COMPRESSED_SRGB_S3TC_DXT1_EXT: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, // Deprecated legacy aliases with non-standard ASTC casing. COMPRESSED_RGBA_ASTC_4X4_KHR: GL_COMPRESSED_RGBA_ASTC_4x4_KHR, COMPRESSED_RGBA_ASTC_5X4_KHR: GL_COMPRESSED_RGBA_ASTC_5x4_KHR, COMPRESSED_RGBA_ASTC_5X5_KHR: GL_COMPRESSED_RGBA_ASTC_5x5_KHR, COMPRESSED_RGBA_ASTC_6X5_KHR: GL_COMPRESSED_RGBA_ASTC_6x5_KHR, COMPRESSED_RGBA_ASTC_6X6_KHR: GL_COMPRESSED_RGBA_ASTC_6x6_KHR, COMPRESSED_RGBA_ASTC_8X5_KHR: GL_COMPRESSED_RGBA_ASTC_8x5_KHR, COMPRESSED_RGBA_ASTC_8X6_KHR: GL_COMPRESSED_RGBA_ASTC_8x6_KHR, COMPRESSED_RGBA_ASTC_8X8_KHR: GL_COMPRESSED_RGBA_ASTC_8x8_KHR, COMPRESSED_RGBA_ASTC_10X5_KHR: GL_COMPRESSED_RGBA_ASTC_10x5_KHR, COMPRESSED_RGBA_ASTC_10X6_KHR: GL_COMPRESSED_RGBA_ASTC_10x6_KHR, COMPRESSED_RGBA_ASTC_10X8_KHR: GL_COMPRESSED_RGBA_ASTC_10x8_KHR, COMPRESSED_RGBA_ASTC_10X10_KHR: GL_COMPRESSED_RGBA_ASTC_10x10_KHR, COMPRESSED_RGBA_ASTC_12X10_KHR: GL_COMPRESSED_RGBA_ASTC_12x10_KHR, COMPRESSED_RGBA_ASTC_12X12_KHR: GL_COMPRESSED_RGBA_ASTC_12x12_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR }; // dist/lib/utils/detect-supported-texture-formats.js var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"]; var WEBGL_TEXTURE_FORMATS = { /* eslint-disable camelcase */ WEBGL_compressed_texture_s3tc: [ "bc1-rgb-unorm-webgl", "bc1-rgba-unorm", "bc2-rgba-unorm", "bc3-rgba-unorm" ], WEBGL_compressed_texture_s3tc_srgb: [ "bc1-rgb-unorm-srgb-webgl", "bc1-rgba-unorm-srgb", "bc2-rgba-unorm-srgb", "bc3-rgba-unorm-srgb" ], EXT_texture_compression_rgtc: ["bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm"], EXT_texture_compression_bptc: [ "bc6h-rgb-ufloat", "bc6h-rgb-float", "bc7-rgba-unorm", "bc7-rgba-unorm-srgb" ], WEBGL_compressed_texture_etc1: ["etc1-rgb-unorm-webgl"], WEBGL_compressed_texture_etc: [ "etc2-rgb8unorm", "etc2-rgb8unorm-srgb", "etc2-rgb8a1unorm", "etc2-rgb8a1unorm-srgb", "etc2-rgba8unorm", "etc2-rgba8unorm-srgb", "eac-r11unorm", "eac-r11snorm", "eac-rg11unorm", "eac-rg11snorm" ], WEBGL_compressed_texture_pvrtc: [ "pvrtc-rgb4unorm-webgl", "pvrtc-rgba4unorm-webgl", "pvrtc-rgb2unorm-webgl", "pvrtc-rgba2unorm-webgl" ], WEBGL_compressed_texture_atc: [ "atc-rgb-unorm-webgl", "atc-rgba-unorm-webgl", "atc-rgbai-unorm-webgl" ], WEBGL_compressed_texture_astc: [ "astc-4x4-unorm", "astc-4x4-unorm-srgb", "astc-5x4-unorm", "astc-5x4-unorm-srgb", "astc-5x5-unorm", "astc-5x5-unorm-srgb", "astc-6x5-unorm", "astc-6x5-unorm-srgb", "astc-6x6-unorm", "astc-6x6-unorm-srgb", "astc-8x5-unorm", "astc-8x5-unorm-srgb", "astc-8x6-unorm", "astc-8x6-unorm-srgb", "astc-8x8-unorm", "astc-8x8-unorm-srgb", "astc-10x5-unorm", "astc-10x5-unorm-srgb", "astc-10x6-unorm", "astc-10x6-unorm-srgb", "astc-10x8-unorm", "astc-10x8-unorm-srgb", "astc-10x10-unorm", "astc-10x10-unorm-srgb", "astc-12x10-unorm", "astc-12x10-unorm-srgb", "astc-12x12-unorm", "astc-12x12-unorm-srgb" ] /* eslint-enable camelcase */ }; var textureFormats = null; function detectSupportedTextureFormats(gl) { if (!textureFormats) { gl = gl || getWebGLContext() || void 0; textureFormats = /* @__PURE__ */ new Set(); for (const prefix of BROWSER_PREFIXES) { for (const extension in WEBGL_TEXTURE_FORMATS) { if (gl && gl.getExtension(`${prefix}${extension}`)) { for (const textureFormat of WEBGL_TEXTURE_FORMATS[extension]) { textureFormats.add(textureFormat); } } } } } return textureFormats; } function getWebGLContext() { try { const canvas = document.createElement("canvas"); return canvas.getContext("webgl"); } catch (error) { return null; } } // dist/lib/parsers/parse-ktx.js var import_loader_utils2 = require("@loaders.gl/loader-utils"); var import_ktx_parse = require("ktx-parse"); // dist/lib/utils/texture-format-map.js var WEBGL_TO_TEXTURE_FORMAT = { [GL_RGBA32F]: "rgba32float", [GL_COMPRESSED_RGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-webgl", [GL_COMPRESSED_SRGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-srgb-webgl", [GL_COMPRESSED_RGBA_S3TC_DXT1_EXT]: "bc1-rgba-unorm", [GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT]: "bc1-rgba-unorm-srgb", [GL_COMPRESSED_RGBA_S3TC_DXT3_EXT]: "bc2-rgba-unorm", [GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT]: "bc2-rgba-unorm-srgb", [GL_COMPRESSED_RGBA_S3TC_DXT5_EXT]: "bc3-rgba-unorm", [GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT]: "bc3-rgba-unorm-srgb", [GL_COMPRESSED_RED_RGTC1_EXT]: "bc4-r-unorm", [GL_COMPRESSED_SIGNED_RED_RGTC1_EXT]: "bc4-r-snorm", [GL_COMPRESSED_RED_GREEN_RGTC2_EXT]: "bc5-rg-unorm", [GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT]: "bc5-rg-snorm", [GL_COMPRESSED_RGB8_ETC2]: "etc2-rgb8unorm", [GL_COMPRESSED_SRGB8_ETC2]: "etc2-rgb8unorm-srgb", [GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2]: "etc2-rgb8a1unorm", [GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2]: "etc2-rgb8a1unorm-srgb", [GL_COMPRESSED_RGBA8_ETC2_EAC]: "etc2-rgba8unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC]: "etc2-rgba8unorm-srgb", [GL_COMPRESSED_R11_EAC]: "eac-r11unorm", [GL_COMPRESSED_SIGNED_R11_EAC]: "eac-r11snorm", [GL_COMPRESSED_RG11_EAC]: "eac-rg11unorm", [GL_COMPRESSED_SIGNED_RG11_EAC]: "eac-rg11snorm", [GL_COMPRESSED_RGBA_ASTC_4x4_KHR]: "astc-4x4-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR]: "astc-4x4-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_5x4_KHR]: "astc-5x4-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR]: "astc-5x4-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_5x5_KHR]: "astc-5x5-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR]: "astc-5x5-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_6x5_KHR]: "astc-6x5-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR]: "astc-6x5-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_6x6_KHR]: "astc-6x6-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR]: "astc-6x6-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_8x5_KHR]: "astc-8x5-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR]: "astc-8x5-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_8x6_KHR]: "astc-8x6-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR]: "astc-8x6-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_8x8_KHR]: "astc-8x8-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR]: "astc-8x8-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_10x5_KHR]: "astc-10x5-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR]: "astc-10x5-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_10x6_KHR]: "astc-10x6-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR]: "astc-10x6-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_10x8_KHR]: "astc-10x8-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR]: "astc-10x8-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_10x10_KHR]: "astc-10x10-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR]: "astc-10x10-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_12x10_KHR]: "astc-12x10-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR]: "astc-12x10-unorm-srgb", [GL_COMPRESSED_RGBA_ASTC_12x12_KHR]: "astc-12x12-unorm", [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]: "astc-12x12-unorm-srgb", [GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG]: "pvrtc-rgb4unorm-webgl", [GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]: "pvrtc-rgba4unorm-webgl", [GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: "pvrtc-rgb2unorm-webgl", [GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]: "pvrtc-rgba2unorm-webgl", [GL_COMPRESSED_RGB_ETC1_WEBGL]: "etc1-rgb-unorm-webgl", [GL_COMPRESSED_RGB_ATC_WEBGL]: "atc-rgb-unorm-webgl", [GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]: "atc-rgba-unorm-webgl", [GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]: "atc-rgbai-unorm-webgl" }; var TEXTURE_FORMAT_TO_WEBGL = Object.fromEntries(Object.entries(WEBGL_TO_TEXTURE_FORMAT).map(([format, textureFormat]) => [ textureFormat, Number(format) ])); function getTextureFormatFromWebGLFormat(format) { if (format === void 0) { return void 0; } return WEBGL_TO_TEXTURE_FORMAT[format]; } function getWebGLFormatFromTextureFormat(textureFormat) { if (textureFormat === void 0) { return void 0; } return TEXTURE_FORMAT_TO_WEBGL[textureFormat]; } // dist/lib/utils/extract-mipmap-images.js function extractMipmapImages(data, options) { const images = new Array(options.mipMapLevels); const textureFormat = options.textureFormat || getTextureFormatFromWebGLFormat(options.internalFormat); const format = options.internalFormat || getWebGLFormatFromTextureFormat(options.textureFormat); let levelWidth = options.width; let levelHeight = options.height; let offset = 0; for (let i = 0; i < options.mipMapLevels; ++i) { const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i); const levelData = getLevelData(data, i, offset, levelSize); const image = { shape: "texture-level", compressed: true, data: levelData, width: levelWidth, height: levelHeight, levelSize }; if (format !== void 0) { image.format = format; } if (textureFormat) { image.textureFormat = textureFormat; } images[i] = image; levelWidth = Math.max(1, levelWidth >> 1); levelHeight = Math.max(1, levelHeight >> 1); offset += levelSize; } return images; } function getLevelData(data, index, offset, levelSize) { if (!Array.isArray(data)) { return new Uint8Array(data.buffer, data.byteOffset + offset, levelSize); } return data[index].levelData; } function getLevelSize(options, levelWidth, levelHeight, data, index) { if (!Array.isArray(data)) { return options.sizeFunction(levelWidth, levelHeight); } return options.sizeFunction(data[index]); } // dist/lib/utils/ktx-format-helper.js var VULKAN_TO_WEBGL_FORMAT_MAP = { 131: GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 132: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, 133: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 134: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 135: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 136: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 137: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 138: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 139: GL_COMPRESSED_RED_RGTC1_EXT, 140: GL_COMPRESSED_SIGNED_RED_RGTC1_EXT, 141: GL_COMPRESSED_RED_GREEN_RGTC2_EXT, 142: GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, 147: GL_COMPRESSED_RGB8_ETC2, 148: GL_COMPRESSED_SRGB8_ETC2, 149: GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, 150: GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 151: GL_COMPRESSED_RGBA8_ETC2_EAC, 152: GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, 153: GL_COMPRESSED_R11_EAC, 154: GL_COMPRESSED_SIGNED_R11_EAC, 155: GL_COMPRESSED_RG11_EAC, 156: GL_COMPRESSED_SIGNED_RG11_EAC, 157: GL_COMPRESSED_RGBA_ASTC_4x4_KHR, 158: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, 159: GL_COMPRESSED_RGBA_ASTC_5x4_KHR, 160: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, 161: GL_COMPRESSED_RGBA_ASTC_5x5_KHR, 162: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, 163: GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 164: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, 165: GL_COMPRESSED_RGBA_ASTC_6x6_KHR, 166: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, 167: GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 168: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, 169: GL_COMPRESSED_RGBA_ASTC_8x6_KHR, 170: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, 171: GL_COMPRESSED_RGBA_ASTC_8x8_KHR, 172: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, 173: GL_COMPRESSED_RGBA_ASTC_10x5_KHR, 174: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, 175: GL_COMPRESSED_RGBA_ASTC_10x6_KHR, 176: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, 177: GL_COMPRESSED_RGBA_ASTC_10x8_KHR, 178: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, 179: GL_COMPRESSED_RGBA_ASTC_10x10_KHR, 180: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 181: GL_COMPRESSED_RGBA_ASTC_12x10_KHR, 182: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 183: GL_COMPRESSED_RGBA_ASTC_12x12_KHR, 184: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 1000054e3: GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 1000054001: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 1000066e3: GL_COMPRESSED_RGBA_ASTC_4x4_KHR, 1000066001: GL_COMPRESSED_RGBA_ASTC_5x4_KHR, 1000066002: GL_COMPRESSED_RGBA_ASTC_5x5_KHR, 1000066003: GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 1000066004: GL_COMPRESSED_RGBA_ASTC_6x6_KHR, 1000066005: GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 1000066006: GL_COMPRESSED_RGBA_ASTC_8x6_KHR, 1000066007: GL_COMPRESSED_RGBA_ASTC_8x8_KHR, 1000066008: GL_COMPRESSED_RGBA_ASTC_10x5_KHR, 1000066009: GL_COMPRESSED_RGBA_ASTC_10x6_KHR, 1000066010: GL_COMPRESSED_RGBA_ASTC_10x8_KHR, 1000066011: GL_COMPRESSED_RGBA_ASTC_10x10_KHR, 1000066012: GL_COMPRESSED_RGBA_ASTC_12x10_KHR, 1000066013: GL_COMPRESSED_RGBA_ASTC_12x12_KHR }; function mapVkFormatToWebGL(vkFormat) { return VULKAN_TO_WEBGL_FORMAT_MAP[vkFormat]; } function mapVkFormatToTextureFormat(vkFormat) { return getTextureFormatFromWebGLFormat(mapVkFormatToWebGL(vkFormat)); } // dist/lib/parsers/parse-ktx.js var KTX2_ID = [ // '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n' 171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10 ]; function isKTX(data) { const id = new Uint8Array(data); const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || // '´' id[1] !== KTX2_ID[1] || // 'K' id[2] !== KTX2_ID[2] || // 'T' id[3] !== KTX2_ID[3] || // 'X' id[4] !== KTX2_ID[4] || // ' ' id[5] !== KTX2_ID[5] || // '2' id[6] !== KTX2_ID[6] || // '0' id[7] !== KTX2_ID[7] || // 'ª' id[8] !== KTX2_ID[8] || // '\r' id[9] !== KTX2_ID[9] || // '\n' id[10] !== KTX2_ID[10] || // '\x1A' id[11] !== KTX2_ID[11]; return !notKTX; } function parseKTX(arrayBuffer) { const uint8Array = new Uint8Array(arrayBuffer); const ktx = (0, import_ktx_parse.read)(uint8Array); const mipMapLevels = Math.max(1, ktx.levels.length); const width = ktx.pixelWidth; const height = ktx.pixelHeight; const textureFormat = mapVkFormatToTextureFormat(ktx.vkFormat); if (textureFormat === void 0) { import_loader_utils2.log.warn(`KTX2 container vkFormat ${ktx.vkFormat} does not map to a known texture format; returning texture levels without format metadata.`)(); } return extractMipmapImages(ktx.levels, { mipMapLevels, width, height, sizeFunction: (level) => level.uncompressedByteLength, textureFormat }); } // dist/lib/parsers/parse-basis.js var basisTranscodingLock = Promise.resolve(); var BASIS_FORMAT_TO_OUTPUT_OPTIONS = { etc1: { basisFormat: 0, compressed: true, format: GL_COMPRESSED_RGB_ETC1_WEBGL, textureFormat: "etc1-rgb-unorm-webgl" }, etc2: { basisFormat: 1, compressed: true, format: GL_COMPRESSED_RGBA8_ETC2_EAC, textureFormat: "etc2-rgba8unorm" }, bc1: { basisFormat: 2, compressed: true, format: GL_COMPRESSED_RGB_S3TC_DXT1_EXT, textureFormat: "bc1-rgb-unorm-webgl" }, bc3: { basisFormat: 3, compressed: true, format: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, textureFormat: "bc3-rgba-unorm" }, bc4: { basisFormat: 4, compressed: true, format: GL_COMPRESSED_RED_RGTC1_EXT, textureFormat: "bc4-r-unorm" }, bc5: { basisFormat: 5, compressed: true, format: GL_COMPRESSED_RED_GREEN_RGTC2_EXT, textureFormat: "bc5-rg-unorm" }, "bc7-m6-opaque-only": { basisFormat: 6, compressed: true, format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, textureFormat: "bc7-rgba-unorm" }, "bc7-m5": { basisFormat: 7, compressed: true, format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, textureFormat: "bc7-rgba-unorm" }, "pvrtc1-4-rgb": { basisFormat: 8, compressed: true, format: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, textureFormat: "pvrtc-rgb4unorm-webgl" }, "pvrtc1-4-rgba": { basisFormat: 9, compressed: true, format: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, textureFormat: "pvrtc-rgba4unorm-webgl" }, "astc-4x4": { basisFormat: 10, compressed: true, format: GL_COMPRESSED_RGBA_ASTC_4x4_KHR, textureFormat: "astc-4x4-unorm" }, "atc-rgb": { basisFormat: 11, compressed: true, format: GL_COMPRESSED_RGB_ATC_WEBGL, textureFormat: "atc-rgb-unorm-webgl" }, "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true, format: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, textureFormat: "atc-rgbai-unorm-webgl" }, rgba32: { basisFormat: 13, compressed: false, format: GL_RGBA8, textureFormat: "rgba8unorm" }, rgb565: { basisFormat: 14, compressed: false, format: GL_RGB565, textureFormat: "rgb565unorm-webgl" }, bgr565: { basisFormat: 15, compressed: false, format: GL_RGB565, textureFormat: "rgb565unorm-webgl" }, rgba4444: { basisFormat: 16, compressed: false, format: GL_RGBA4, textureFormat: "rgba4unorm-webgl" } }; var BASIS_FORMATS = Object.freeze(Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS)); async function withBasisTranscodingLock(transcode) { const previousLock = basisTranscodingLock; let releaseLock; basisTranscodingLock = new Promise((resolve) => { releaseLock = resolve; }); await previousLock; try { return await transcode(); } finally { releaseLock(); } } async function parseBasis(data, options = {}) { const loadLibraryOptions = (0, import_worker_utils2.extractLoadLibraryOptions)(options); return await withBasisTranscodingLock(async () => { var _a; if (!((_a = options.basis) == null ? void 0 : _a.containerFormat) || options.basis.containerFormat === "auto") { if (isKTX(data)) { const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions); return parseKTX2File(fileConstructors.KTX2File, data, options); } const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions); return parseBasisFile(BasisFile, data, options); } switch (options.basis.module) { case "encoder": const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions); switch (options.basis.containerFormat) { case "ktx2": return parseKTX2File(fileConstructors.KTX2File, data, options); case "basis": default: return parseBasisFile(fileConstructors.BasisFile, data, options); } case "transcoder": default: const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions); return parseBasisFile(BasisFile, data, options); } }); } function parseBasisFile(BasisFile, data, options) { const basisFile = new BasisFile(new Uint8Array(data)); try { if (!basisFile.startTranscoding()) { throw new Error("Failed to start basis transcoding"); } const imageCount = basisFile.getNumImages(); const images = []; for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) { const levelsCount = basisFile.getNumLevels(imageIndex); const levels = []; for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) { levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options)); } images.push(levels); } return images; } finally { basisFile.close(); basisFile.delete(); } } function transcodeImage(basisFile, imageIndex, levelIndex, options) { const width = basisFile.getImageWidth(imageIndex, levelIndex); const height = basisFile.getImageHeight(imageIndex, levelIndex); const hasAlpha = basisFile.getHasAlpha( /* imageIndex, levelIndex */ ); const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, hasAlpha); const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat); const decodedData = new Uint8Array(decodedSize); if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) { throw new Error("failed to start Basis transcoding"); } return { // standard loaders.gl image category payload shape: "texture-level", width, height, data: decodedData, compressed, ...format !== void 0 ? { format } : {}, ...textureFormat !== void 0 ? { textureFormat } : {}, // Additional fields // Add levelSize field. hasAlpha }; } function parseKTX2File(KTX2File, data, options) { const ktx2File = new KTX2File(new Uint8Array(data)); try { if (!ktx2File.startTranscoding()) { throw new Error("failed to start KTX2 transcoding"); } const levelsCount = ktx2File.getLevels(); const levels = []; for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) { levels.push(transcodeKTX2Image(ktx2File, levelIndex, options)); } return [levels]; } finally { ktx2File.close(); ktx2File.delete(); } } function transcodeKTX2Image(ktx2File, levelIndex, options) { const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0); const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, alphaFlag); const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat); const decodedData = new Uint8Array(decodedSize); if (!ktx2File.transcodeImage( decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1 /* channel1 */ )) { throw new Error("Failed to transcode KTX2 image"); } return { // standard loaders.gl image category payload shape: "texture-level", width, height, data: decodedData, compressed, ...format !== void 0 ? { format } : {}, ...textureFormat !== void 0 ? { textureFormat } : {}, // Additional fields levelSize: decodedSize, hasAlpha: alphaFlag }; } function getBasisOptions(options, hasAlpha) { var _a, _b; let format = ((_a = options.basis) == null ? void 0 : _a.format) || "auto"; if (format === "auto") { format = ((_b = options.basis) == null ? void 0 : _b.supportedTextureFormats) ? selectSupportedBasisFormat(options.basis.supportedTextureFormats) : selectSupportedBasisFormat(); } if (typeof format === "object") { format = hasAlpha ? format.alpha : format.noAlpha; } const normalizedFormat = format.toLowerCase(); const basisOutputOptions = BASIS_FORMAT_TO_OUTPUT_OPTIONS[normalizedFormat]; if (!basisOutputOptions) { throw new Error(`Unknown Basis format ${format}`); } return basisOutputOptions; } function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTextureFormats()) { const textureFormats2 = new Set(supportedTextureFormats); if (hasSupportedTextureFormat(textureFormats2, ["astc-4x4-unorm", "astc-4x4-unorm-srgb"])) { return "astc-4x4"; } else if (hasSupportedTextureFormat(textureFormats2, ["bc7-rgba-unorm", "bc7-rgba-unorm-srgb"])) { return { alpha: "bc7-m5", noAlpha: "bc7-m6-opaque-only" }; } else if (hasSupportedTextureFormat(textureFormats2, [ "bc1-rgb-unorm-webgl", "bc1-rgb-unorm-srgb-webgl", "bc1-rgba-unorm", "bc1-rgba-unorm-srgb", "bc2-rgba-unorm", "bc2-rgba-unorm-srgb", "bc3-rgba-unorm", "bc3-rgba-unorm-srgb" ])) { return { alpha: "bc3", noAlpha: "bc1" }; } else if (hasSupportedTextureFormat(textureFormats2, [ "pvrtc-rgb4unorm-webgl", "pvrtc-rgba4unorm-webgl", "pvrtc-rgb2unorm-webgl", "pvrtc-rgba2unorm-webgl" ])) { return { alpha: "pvrtc1-4-rgba", noAlpha: "pvrtc1-4-rgb" }; } else if (hasSupportedTextureFormat(textureFormats2, [ "etc2-rgb8unorm", "etc2-rgb8unorm-srgb", "etc2-rgb8a1unorm", "etc2-rgb8a1unorm-srgb", "etc2-rgba8unorm", "etc2-rgba8unorm-srgb", "eac-r11unorm", "eac-r11snorm", "eac-rg11unorm", "eac-rg11snorm" ])) { return "etc2"; } else if (textureFormats2.has("etc1-rgb-unorm-webgl")) { return "etc1"; } else if (hasSupportedTextureFormat(textureFormats2, [ "atc-rgb-unorm-webgl", "atc-rgba-unorm-webgl", "atc-rgbai-unorm-webgl" ])) { return { alpha: "atc-rgba-interpolated-alpha", noAlpha: "atc-rgb" }; } return "rgb565"; } function hasSupportedTextureFormat(supportedTextureFormats, candidateTextureFormats) { return candidateTextureFormats.some((textureFormat) => supportedTextureFormats.has(textureFormat)); } // dist/basis-loader.js var BasisWorkerLoader = { dataType: null, batchType: null, name: "Basis", id: "basis", module: "textures", version: VERSION, worker: true, extensions: ["basis", "ktx2"], mimeTypes: ["application/octet-stream", "image/ktx2"], tests: ["sB"], binary: true, options: { basis: { format: "auto", containerFormat: "auto", module: "transcoder" } } }; var BasisLoader = { ...BasisWorkerLoader, parse: parseBasis }; // dist/lib/parsers/parse-dds.js var import_loader_utils3 = require("@loaders.gl/loader-utils"); var DDS_CONSTANTS = { MAGIC_NUMBER: 542327876, HEADER_LENGTH: 31, MAGIC_NUMBER_INDEX: 0, HEADER_SIZE_INDEX: 1, HEADER_FLAGS_INDEX: 2, HEADER_HEIGHT_INDEX: 3, HEADER_WIDTH_INDEX: 4, MIPMAPCOUNT_INDEX: 7, HEADER_PF_FLAGS_INDEX: 20, HEADER_PF_FOURCC_INDEX: 21, DDSD_MIPMAPCOUNT: 131072, DDPF_FOURCC: 4 }; var DDS_TEXTURE_FORMATS = { DXT1: "bc1-rgb-unorm-webgl", DXT3: "bc2-rgba-unorm", DXT5: "bc3-rgba-unorm", "ATC ": "atc-rgb-unorm-webgl", ATCA: "atc-rgba-unorm-webgl", ATCI: "atc-rgbai-unorm-webgl" }; var getATCLevelSize = getDxt1LevelSize; var getATCALevelSize = getDxtXLevelSize; var getATCILevelSize = getDxtXLevelSize; var DDS_SIZE_FUNCTIONS = { DXT1: getDxt1LevelSize, DXT3: getDxtXLevelSize, DXT5: getDxtXLevelSize, "ATC ": getATCLevelSize, ATCA: getATCALevelSize, ATCI: getATCILevelSize }; function isDDS(data) { const header = new Uint32Array(data, 0, DDS_CONSTANTS.HEADER_LENGTH); const magic = header[DDS_CONSTANTS.MAGIC_NUMBER_INDEX]; return magic === DDS_CONSTANTS.MAGIC_NUMBER; } function parseDDS(data) { const header = new Int32Array(data, 0, DDS_CONSTANTS.HEADER_LENGTH); const pixelFormatNumber = header[DDS_CONSTANTS.HEADER_PF_FOURCC_INDEX]; (0, import_loader_utils3.assert)(Boolean(header[DDS_CONSTANTS.HEADER_PF_FLAGS_INDEX] & DDS_CONSTANTS.DDPF_FOURCC), "DDS: Unsupported format, must contain a FourCC code"); const fourCC = int32ToFourCC(pixelFormatNumber); const textureFormat = DDS_TEXTURE_FORMATS[fourCC]; const sizeFunction = DDS_SIZE_FUNCTIONS[fourCC]; (0, import_loader_utils3.assert)(textureFormat && sizeFunction, `DDS: Unknown pixel format ${pixelFormatNumber}`); let mipMapLevels = 1; if (header[DDS_CONSTANTS.HEADER_FLAGS_INDEX] & DDS_CONSTANTS.DDSD_MIPMAPCOUNT) { mipMapLevels = Math.max(1, header[DDS_CONSTANTS.MIPMAPCOUNT_INDEX]); } const width = header[DDS_CONSTANTS.HEADER_WIDTH_INDEX]; const height = header[DDS_CONSTANTS.HEADER_HEIGHT_INDEX]; const dataOffset = header[DDS_CONSTANTS.HEADER_SIZE_INDEX] + 4; const image = new Uint8Array(data, dataOffset); return extractMipmapImages(image, { mipMapLevels, width, height, sizeFunction, textureFormat }); } function getDxt1LevelSize(width, height) { return (width + 3 >> 2) * (height + 3 >> 2) * 8; } function getDxtXLevelSize(width, height) { return (width + 3 >> 2) * (height + 3 >> 2) * 16; } function int32ToFourCC(value) { return String.fromCharCode(value & 255, value >> 8 & 255, value >> 16 & 255, value >> 24 & 255); } // dist/lib/parsers/parse-pvr.js var PVR_CONSTANTS = { MAGIC_NUMBER: 55727696, MAGIC_NUMBER_EXTRA: 1347834371, HEADER_LENGTH: 13, HEADER_SIZE: 52, MAGIC_NUMBER_INDEX: 0, PIXEL_FORMAT_INDEX: 2, COLOUR_SPACE_INDEX: 4, HEIGHT_INDEX: 6, WIDTH_INDEX: 7, MIPMAPCOUNT_INDEX: 11, METADATA_SIZE_INDEX: 12 }; var PVR_TEXTURE_FORMATS = { 0: ["pvrtc-rgb2unorm-webgl"], 1: ["pvrtc-rgba2unorm-webgl"], 2: ["pvrtc-rgb4unorm-webgl"], 3: ["pvrtc-rgba4unorm-webgl"], 6: ["etc1-rgb-unorm-webgl"], 7: ["bc1-rgb-unorm-webgl"], 9: ["bc2-rgba-unorm"], 11: ["bc3-rgba-unorm"], 22: ["etc2-rgb8unorm"], 23: ["etc2-rgba8unorm"], 24: ["etc2-rgb8a1unorm"], 25: ["eac-r11unorm"], 26: ["eac-rg11unorm"], 27: ["astc-4x4-unorm", "astc-4x4-unorm-srgb"], 28: ["astc-5x4-unorm", "astc-5x4-unorm-srgb"], 29: ["astc-5x5-unorm", "astc-5x5-unorm-srgb"], 30: ["astc-6x5-unorm", "astc-6x5-unorm-srgb"], 31: ["astc-6x6-unorm", "astc-6x6-unorm-srgb"], 32: ["astc-8x5-unorm", "astc-8x5-unorm-srgb"], 33: ["astc-8x6-unorm", "astc-8x6-unorm-srgb"], 34: ["astc-8x8-unorm", "astc-8x8-unorm-srgb"], 35: ["astc-10x5-unorm", "astc-10x5-unorm-srgb"], 36: ["astc-10x6-unorm", "astc-10x6-unorm-srgb"], 37: ["astc-10x8-unorm", "astc-10x8-unorm-srgb"], 38: ["astc-10x10-unorm", "astc-10x10-unorm-srgb"], 39: ["astc-12x10-unorm", "astc-12x10-unorm-srgb"], 40: ["astc-12x12-unorm", "astc-12x12-unorm-srgb"] }; var PVR_SIZE_FUNCTIONS = { 0: pvrtc2bppSize, 1: pvrtc2bppSize, 2: pvrtc4bppSize, 3: pvrtc4bppSize, 6: dxtEtcSmallSize, 7: dxtEtcSmallSize, 9: dxtEtcAstcBigSize, 11: dxtEtcAstcBigSize, 22: dxtEtcSmallSize, 23: dxtEtcAstcBigSize, 24: dxtEtcSmallSize, 25: dxtEtcSmallSize, 26: dxtEtcAstcBigSize, 27: dxtEtcAstcBigSize, 28: atc5x4Size, 29: atc5x5Size, 30: atc6x5Size, 31: atc6x6Size, 32: atc8x5Size, 33: atc8x6Size, 34: atc8x8Size, 35: atc10x5Size, 36: atc10x6Size, 37: atc10x8Size, 38: atc10x10Size, 39: atc12x10Size, 40: atc12x12Size }; function isPVR(data) { const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH); const version = header[PVR_CONSTANTS.MAGIC_NUMBER_INDEX]; return version === PVR_CONSTANTS.MAGIC_NUMBER || version === PVR_CONSTANTS.MAGIC_NUMBER_EXTRA; } function parsePVR(data) { const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH); const pvrFormat = header[PVR_CONSTANTS.PIXEL_FORMAT_INDEX]; const colourSpace = header[PVR_CONSTANTS.COLOUR_SPACE_INDEX]; const textureFormats2 = PVR_TEXTURE_FORMATS[pvrFormat] || []; const textureFormat = textureFormats2.length > 1 && colourSpace ? textureFormats2[1] : textureFormats2[0]; const sizeFunction = PVR_SIZE_FUNCTIONS[pvrFormat]; const mipMapLevels = header[PVR_CONSTANTS.MIPMAPCOUNT_INDEX]; const width = header[PVR_CONSTANTS.WIDTH_INDEX]; const height = header[PVR_CONSTANTS.HEIGHT_INDEX]; const dataOffset = PVR_CONSTANTS.HEADER_SIZE + header[PVR_CONSTANTS.METADATA_SIZE_INDEX]; const image = new Uint8Array(data, dataOffset); return extractMipmapImages(image, { mipMapLevels, width, height, sizeFunction, textureFormat }); } function pvrtc2bppSize(width, height) { width = Math.max(width, 16); height = Math.max(height, 8); return width * height / 4; } function pvrtc4bppSize(width, height) { width = Math.max(width, 8); height = Math.max(height, 8); return width * height / 2; } function