UNPKG

@loaders.gl/textures

Version:

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

1,400 lines (1,369 loc) 79.7 kB
"use strict"; (() => { // ../loader-utils/src/lib/env-utils/assert.ts function assert(condition, message) { if (!condition) { throw new Error(message || "loader assertion failed."); } } // ../../node_modules/@probe.gl/env/dist/lib/globals.js var window_ = globalThis; var document_ = globalThis.document || {}; var process_ = globalThis.process || {}; var console_ = globalThis.console; var navigator_ = globalThis.navigator || {}; // ../../node_modules/@probe.gl/env/dist/lib/is-electron.js function isElectron(mockUserAgent) { if (typeof window !== "undefined" && window.process?.type === "renderer") { return true; } if (typeof process !== "undefined" && Boolean(process.versions?.["electron"])) { return true; } const realUserAgent = typeof navigator !== "undefined" && navigator.userAgent; const userAgent = mockUserAgent || realUserAgent; return Boolean(userAgent && userAgent.indexOf("Electron") >= 0); } // ../../node_modules/@probe.gl/env/dist/lib/is-browser.js function isBrowser() { const isNode = ( // @ts-expect-error typeof process === "object" && String(process) === "[object process]" && !process?.browser ); return !isNode || isElectron(); } // ../../node_modules/@probe.gl/env/dist/index.js var VERSION = true ? "4.1.1" : "untranspiled source"; // ../../node_modules/@probe.gl/log/dist/utils/assert.js function assert2(condition, message) { if (!condition) { throw new Error(message || "Assertion failed"); } } // ../../node_modules/@probe.gl/log/dist/loggers/log-utils.js function normalizeLogLevel(logLevel) { if (!logLevel) { return 0; } let resolvedLevel; switch (typeof logLevel) { case "number": resolvedLevel = logLevel; break; case "object": resolvedLevel = logLevel.logLevel || logLevel.priority || 0; break; default: return 0; } assert2(Number.isFinite(resolvedLevel) && resolvedLevel >= 0); return resolvedLevel; } function normalizeArguments(opts) { const { logLevel, message } = opts; opts.logLevel = normalizeLogLevel(logLevel); const args = opts.args ? Array.from(opts.args) : []; while (args.length && args.shift() !== message) { } switch (typeof logLevel) { case "string": case "function": if (message !== void 0) { args.unshift(message); } opts.message = logLevel; break; case "object": Object.assign(opts, logLevel); break; default: } if (typeof opts.message === "function") { opts.message = opts.message(); } const messageType = typeof opts.message; assert2(messageType === "string" || messageType === "object"); return Object.assign(opts, { args }, opts.opts); } // ../../node_modules/@probe.gl/log/dist/loggers/base-log.js var noop = () => { }; var BaseLog = class { constructor({ level = 0 } = {}) { this.userData = {}; this._onceCache = /* @__PURE__ */ new Set(); this._level = level; } set level(newLevel) { this.setLevel(newLevel); } get level() { return this.getLevel(); } setLevel(level) { this._level = level; return this; } getLevel() { return this._level; } // Unconditional logging warn(message, ...args) { return this._log("warn", 0, message, args, { once: true }); } error(message, ...args) { return this._log("error", 0, message, args); } // Conditional logging log(logLevel, message, ...args) { return this._log("log", logLevel, message, args); } info(logLevel, message, ...args) { return this._log("info", logLevel, message, args); } once(logLevel, message, ...args) { return this._log("once", logLevel, message, args, { once: true }); } _log(type, logLevel, message, args, options = {}) { const normalized = normalizeArguments({ logLevel, message, args: this._buildArgs(logLevel, message, args), opts: options }); return this._createLogFunction(type, normalized, options); } _buildArgs(logLevel, message, args) { return [logLevel, message, ...args]; } _createLogFunction(type, normalized, options) { if (!this._shouldLog(normalized.logLevel)) { return noop; } const tag = this._getOnceTag(options.tag ?? normalized.tag ?? normalized.message); if ((options.once || normalized.once) && tag !== void 0) { if (this._onceCache.has(tag)) { return noop; } this._onceCache.add(tag); } return this._emit(type, normalized); } _shouldLog(logLevel) { return this.getLevel() >= normalizeLogLevel(logLevel); } _getOnceTag(tag) { if (tag === void 0) { return void 0; } try { return typeof tag === "string" ? tag : String(tag); } catch { return void 0; } } }; // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js function getStorage(type) { try { const storage = window[type]; const x = "__storage_test__"; storage.setItem(x, x); storage.removeItem(x); return storage; } catch (e) { return null; } } var LocalStorage = class { constructor(id, defaultConfig, type = "sessionStorage") { this.storage = getStorage(type); this.id = id; this.config = defaultConfig; this._loadConfiguration(); } getConfiguration() { return this.config; } setConfiguration(configuration) { Object.assign(this.config, configuration); if (this.storage) { const serialized = JSON.stringify(this.config); this.storage.setItem(this.id, serialized); } } // Get config from persistent store, if available _loadConfiguration() { let configuration = {}; if (this.storage) { const serializedConfiguration = this.storage.getItem(this.id); configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {}; } Object.assign(this.config, configuration); return this; } }; // ../../node_modules/@probe.gl/log/dist/utils/formatters.js function formatTime(ms) { let formatted; if (ms < 10) { formatted = `${ms.toFixed(2)}ms`; } else if (ms < 100) { formatted = `${ms.toFixed(1)}ms`; } else if (ms < 1e3) { formatted = `${ms.toFixed(0)}ms`; } else { formatted = `${(ms / 1e3).toFixed(2)}s`; } return formatted; } function leftPad(string, length = 8) { const padLength = Math.max(length - string.length, 0); return `${" ".repeat(padLength)}${string}`; } // ../../node_modules/@probe.gl/log/dist/utils/color.js var COLOR; (function(COLOR2) { COLOR2[COLOR2["BLACK"] = 30] = "BLACK"; COLOR2[COLOR2["RED"] = 31] = "RED"; COLOR2[COLOR2["GREEN"] = 32] = "GREEN"; COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW"; COLOR2[COLOR2["BLUE"] = 34] = "BLUE"; COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA"; COLOR2[COLOR2["CYAN"] = 36] = "CYAN"; COLOR2[COLOR2["WHITE"] = 37] = "WHITE"; COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK"; COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED"; COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN"; COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW"; COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE"; COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA"; COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN"; COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE"; })(COLOR || (COLOR = {})); var BACKGROUND_INCREMENT = 10; function getColor(color) { if (typeof color !== "string") { return color; } color = color.toUpperCase(); return COLOR[color] || COLOR.WHITE; } function addColor(string, color, background) { if (!isBrowser && typeof string === "string") { if (color) { const colorCode = getColor(color); string = `\x1B[${colorCode}m${string}\x1B[39m`; } if (background) { const colorCode = getColor(background); string = `\x1B[${colorCode + BACKGROUND_INCREMENT}m${string}\x1B[49m`; } } return string; } // ../../node_modules/@probe.gl/log/dist/utils/autobind.js function autobind(obj, predefined = ["constructor"]) { const proto = Object.getPrototypeOf(obj); const propNames = Object.getOwnPropertyNames(proto); const object = obj; for (const key of propNames) { const value = object[key]; if (typeof value === "function") { if (!predefined.find((name) => key === name)) { object[key] = value.bind(obj); } } } } // ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js function getHiResTimestamp() { let timestamp; if (isBrowser() && window_.performance) { timestamp = window_?.performance?.now?.(); } else if ("hrtime" in process_) { const timeParts = process_?.hrtime?.(); timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6; } else { timestamp = Date.now(); } return timestamp; } // ../../node_modules/@probe.gl/log/dist/loggers/probe-log.js var originalConsole = { debug: isBrowser() ? console.debug || console.log : console.log, log: console.log, info: console.info, warn: console.warn, error: console.error }; var DEFAULT_LOG_CONFIGURATION = { enabled: true, level: 0 }; var ProbeLog = class extends BaseLog { constructor({ id } = { id: "" }) { super({ level: 0 }); this.VERSION = VERSION; this._startTs = getHiResTimestamp(); this._deltaTs = getHiResTimestamp(); this.userData = {}; this.LOG_THROTTLE_TIMEOUT = 0; this.id = id; this.userData = {}; this._storage = new LocalStorage(`__probe-${this.id}__`, { [this.id]: DEFAULT_LOG_CONFIGURATION }); this.timeStamp(`${this.id} started`); autobind(this); Object.seal(this); } isEnabled() { return this._getConfiguration().enabled; } getLevel() { return this._getConfiguration().level; } /** @return milliseconds, with fractions */ getTotal() { return Number((getHiResTimestamp() - this._startTs).toPrecision(10)); } /** @return milliseconds, with fractions */ getDelta() { return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10)); } /** @deprecated use logLevel */ set priority(newPriority) { this.level = newPriority; } /** @deprecated use logLevel */ get priority() { return this.level; } /** @deprecated use logLevel */ getPriority() { return this.level; } // Configure enable(enabled = true) { this._updateConfiguration({ enabled }); return this; } setLevel(level) { this._updateConfiguration({ level }); return this; } /** return the current status of the setting */ get(setting) { return this._getConfiguration()[setting]; } // update the status of the setting set(setting, value) { this._updateConfiguration({ [setting]: value }); } /** Logs the current settings as a table */ settings() { if (console.table) { console.table(this._storage.config); } else { console.log(this._storage.config); } } // Unconditional logging assert(condition, message) { if (!condition) { throw new Error(message || "Assertion failed"); } } warn(message, ...args) { return this._log("warn", 0, message, args, { method: originalConsole.warn, once: true }); } error(message, ...args) { return this._log("error", 0, message, args, { method: originalConsole.error }); } /** Print a deprecation warning */ deprecated(oldUsage, newUsage) { return this.warn(`\`${oldUsage}\` is deprecated and will be removed in a later version. Use \`${newUsage}\` instead`); } /** Print a removal warning */ removed(oldUsage, newUsage) { return this.error(`\`${oldUsage}\` has been removed. Use \`${newUsage}\` instead`); } probe(logLevel, message, ...args) { return this._log("log", logLevel, message, args, { method: originalConsole.log, time: true, once: true }); } log(logLevel, message, ...args) { return this._log("log", logLevel, message, args, { method: originalConsole.debug }); } info(logLevel, message, ...args) { return this._log("info", logLevel, message, args, { method: console.info }); } once(logLevel, message, ...args) { return this._log("once", logLevel, message, args, { method: originalConsole.debug || originalConsole.info, once: true }); } /** Logs an object as a table */ table(logLevel, table, columns) { if (table) { return this._log("table", logLevel, table, columns && [columns] || [], { method: console.table || noop, tag: getTableHeader(table) }); } return noop; } time(logLevel, message) { return this._log("time", logLevel, message, [], { method: console.time ? console.time : console.info }); } timeEnd(logLevel, message) { return this._log("time", logLevel, message, [], { method: console.timeEnd ? console.timeEnd : console.info }); } timeStamp(logLevel, message) { return this._log("time", logLevel, message, [], { method: console.timeStamp || noop }); } group(logLevel, message, opts = { collapsed: false }) { const method = (opts.collapsed ? console.groupCollapsed : console.group) || console.info; return this._log("group", logLevel, message, [], { method }); } groupCollapsed(logLevel, message, opts = {}) { return this.group(logLevel, message, Object.assign({}, opts, { collapsed: true })); } groupEnd(logLevel) { return this._log("groupEnd", logLevel, "", [], { method: console.groupEnd || noop }); } // EXPERIMENTAL withGroup(logLevel, message, func) { this.group(logLevel, message)(); try { func(); } finally { this.groupEnd(logLevel)(); } } trace() { if (console.trace) { console.trace(); } } _shouldLog(logLevel) { return this.isEnabled() && super._shouldLog(logLevel); } _emit(_type, normalized) { const method = normalized.method; assert2(method); normalized.total = this.getTotal(); normalized.delta = this.getDelta(); this._deltaTs = getHiResTimestamp(); const message = decorateMessage(this.id, normalized.message, normalized); return method.bind(console, message, ...normalized.args); } _getConfiguration() { if (!this._storage.config[this.id]) { this._updateConfiguration(DEFAULT_LOG_CONFIGURATION); } return this._storage.config[this.id]; } _updateConfiguration(configuration) { const currentConfiguration = this._storage.config[this.id] || { ...DEFAULT_LOG_CONFIGURATION }; this._storage.setConfiguration({ [this.id]: { ...currentConfiguration, ...configuration } }); } }; ProbeLog.VERSION = VERSION; function decorateMessage(id, message, opts) { if (typeof message === "string") { const time = opts.time ? leftPad(formatTime(opts.total)) : ""; message = opts.time ? `${id}: ${time} ${message}` : `${id}: ${message}`; message = addColor(message, opts.color, opts.background); } return message; } function getTableHeader(table) { for (const key in table) { for (const title in table[key]) { return title || "untitled"; } } return "empty"; } // ../../node_modules/@probe.gl/log/dist/init.js globalThis.probe = {}; // ../../node_modules/@probe.gl/log/dist/index.js var dist_default = new ProbeLog({ id: "@probe.gl/log" }); // ../loader-utils/src/lib/log-utils/log.ts var VERSION2 = true ? "4.4.2" : "latest"; var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : ""; function createLog() { const log2 = new ProbeLog({ id: "loaders.gl" }); globalThis.loaders ||= {}; globalThis.loaders.log = log2; globalThis.loaders.version = version; globalThis.probe ||= {}; globalThis.probe.loaders = log2; return log2; } var log = createLog(); // ../loader-utils/src/lib/module-utils/js-module-utils.ts function registerJSModules(modules) { globalThis.loaders ||= {}; globalThis.loaders.modules ||= {}; Object.assign(globalThis.loaders.modules, modules); } function getJSModuleOrNull(name) { const module = globalThis.loaders?.modules?.[name]; return module || null; } // ../worker-utils/src/lib/env-utils/version.ts function getVersion() { if (!globalThis._loadersgl_?.version) { globalThis._loadersgl_ = globalThis._loadersgl_ || {}; if (false) { console.warn( "loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN." ); globalThis._loadersgl_.version = NPM_TAG; warningIssued = true; } else { globalThis._loadersgl_.version = "4.4.2"; } } return globalThis._loadersgl_.version; } var VERSION3 = getVersion(); // ../worker-utils/src/lib/env-utils/assert.ts function assert3(condition, message) { if (!condition) { throw new Error(message || "loaders.gl assertion failed."); } } // ../worker-utils/src/lib/env-utils/globals.ts var globals = { self: typeof self !== "undefined" && self, window: typeof window !== "undefined" && window, global: typeof global !== "undefined" && global, document: typeof document !== "undefined" && document }; var self_ = globals.self || globals.window || globals.global || {}; var window_2 = globals.window || globals.self || globals.global || {}; var global_2 = globals.global || globals.self || globals.window || {}; var document_2 = globals.document || {}; var isBrowser2 = ( // @ts-ignore process.browser typeof process !== "object" || String(process) !== "[object process]" || process.browser ); var isWorker = typeof importScripts === "function"; var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined"; var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version); var nodeVersion = matches && parseFloat(matches[1]) || 0; // ../worker-utils/src/lib/node/worker_threads-browser.ts var parentPort = null; // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts function getTransferList(object, recursive = true, transfers) { const transfersSet = transfers || /* @__PURE__ */ new Set(); if (!object) { } else if (isTransferable(object)) { transfersSet.add(object); } else if (isTransferable(object.buffer)) { transfersSet.add(object.buffer); } else if (ArrayBuffer.isView(object)) { } else if (recursive && typeof object === "object") { for (const key in object) { getTransferList(object[key], recursive, transfersSet); } } return transfers === void 0 ? Array.from(transfersSet) : []; } function isTransferable(object) { if (!object) { return false; } if (object instanceof ArrayBuffer) { return true; } if (typeof MessagePort !== "undefined" && object instanceof MessagePort) { return true; } if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) { return true; } if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) { return true; } return false; } // ../worker-utils/src/lib/worker-farm/worker-body.ts async function getParentPort() { return parentPort; } var onMessageWrapperMap = /* @__PURE__ */ new Map(); var WorkerBody = class { /** Check that we are actually in a worker thread */ static async inWorkerThread() { return typeof self !== "undefined" || Boolean(await getParentPort()); } /* * (type: WorkerMessageType, payload: WorkerMessagePayload) => any */ static set onmessage(onMessage) { async function handleMessage(message) { const parentPort2 = await getParentPort(); const { type, payload } = parentPort2 ? message : message.data; onMessage(type, payload); } getParentPort().then((parentPort2) => { if (parentPort2) { parentPort2.on("message", (message) => { handleMessage(message); }); parentPort2.on("exit", () => console.debug("Node worker closing")); } else { globalThis.onmessage = handleMessage; } }); } static async addEventListener(onMessage) { let onMessageWrapper = onMessageWrapperMap.get(onMessage); if (!onMessageWrapper) { onMessageWrapper = async (message) => { if (!isKnownMessage(message)) { return; } const parentPort3 = await getParentPort(); const { type, payload } = parentPort3 ? message : message.data; onMessage(type, payload); }; } const parentPort2 = await getParentPort(); if (parentPort2) { console.error("not implemented"); } else { globalThis.addEventListener("message", onMessageWrapper); } } static async removeEventListener(onMessage) { const onMessageWrapper = onMessageWrapperMap.get(onMessage); onMessageWrapperMap.delete(onMessage); const parentPort2 = await getParentPort(); if (parentPort2) { console.error("not implemented"); } else { globalThis.removeEventListener("message", onMessageWrapper); } } /** * Send a message from a worker to creating thread (main thread) * @param type * @param payload */ static async postMessage(type, payload) { const data = { source: "loaders.gl", type, payload }; const transferList = getTransferList(payload); const parentPort2 = await getParentPort(); if (parentPort2) { parentPort2.postMessage(data, transferList); } else { globalThis.postMessage(data, transferList); } } }; function isKnownMessage(message) { const { type, data } = message; return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl"); } // ../worker-utils/src/lib/library-utils/library-utils.ts var loadLibraryPromises = {}; function extractLoadLibraryOptions(options = {}) { const useLocalLibraries = options.useLocalLibraries ?? options.core?.useLocalLibraries; const CDN = options.CDN ?? options.core?.CDN; const modules = options.modules; return { ...useLocalLibraries !== void 0 ? { useLocalLibraries } : {}, ...CDN !== void 0 ? { CDN } : {}, ...modules !== void 0 ? { modules } : {} }; } async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) { if (moduleName) { libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName); } loadLibraryPromises[libraryUrl] = // eslint-disable-next-line @typescript-eslint/no-misused-promises loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl); return await loadLibraryPromises[libraryUrl]; } function getLibraryUrl(library, moduleName, options = {}, libraryName = null) { if (options?.core) { throw new Error("loadLibrary: options.core must be pre-normalized"); } if (!options.useLocalLibraries && library.startsWith("http")) { return library; } libraryName = libraryName || library; const modules = options.modules || {}; if (modules[libraryName]) { return modules[libraryName]; } if (!isBrowser2) { return `modules/${moduleName}/dist/libs/${libraryName}`; } if (options.CDN) { assert3(options.CDN.startsWith("http")); return `${options.CDN}/${moduleName}@${VERSION3}/dist/libs/${libraryName}`; } if (isWorker) { return `../src/libs/${libraryName}`; } return `modules/${moduleName}/src/libs/${libraryName}`; } async function loadLibraryFromFile(libraryUrl) { if (libraryUrl.endsWith("wasm")) { return await loadAsArrayBuffer(libraryUrl); } if (!isBrowser2) { const { requireFromFile } = globalThis.loaders || {}; try { const result = await requireFromFile?.(libraryUrl); if (result || !libraryUrl.includes("/dist/libs/")) { return result; } return await requireFromFile?.(libraryUrl.replace("/dist/libs/", "/src/libs/")); } catch (error) { if (libraryUrl.includes("/dist/libs/")) { try { return await requireFromFile?.(libraryUrl.replace("/dist/libs/", "/src/libs/")); } catch { } } console.error(error); return null; } } if (isWorker) { return importScripts(libraryUrl); } const scriptSource = await loadAsText(libraryUrl); return loadLibraryFromString(scriptSource, libraryUrl); } function loadLibraryFromString(scriptSource, id) { if (!isBrowser2) { const { requireFromString } = globalThis.loaders || {}; return requireFromString?.(scriptSource, id); } if (isWorker) { eval.call(globalThis, scriptSource); return null; } const script = document.createElement("script"); script.id = id; try { script.appendChild(document.createTextNode(scriptSource)); } catch (e) { script.text = scriptSource; } document.body.appendChild(script); return null; } async function loadAsArrayBuffer(url) { const { readFileAsArrayBuffer } = globalThis.loaders || {}; if (isBrowser2 || !readFileAsArrayBuffer || url.startsWith("http")) { const response = await fetch(url); return await response.arrayBuffer(); } try { return await readFileAsArrayBuffer(url); } catch { if (url.includes("/dist/libs/")) { return await readFileAsArrayBuffer(url.replace("/dist/libs/", "/src/libs/")); } throw new Error(`Failed to load ArrayBuffer from ${url}`); } } async function loadAsText(url) { const { readFileAsText } = globalThis.loaders || {}; if (isBrowser2 || !readFileAsText || url.startsWith("http")) { const response = await fetch(url); return await response.text(); } try { return await readFileAsText(url); } catch { if (url.includes("/dist/libs/")) { return await readFileAsText(url.replace("/dist/libs/", "/src/libs/")); } throw new Error(`Failed to load text from ${url}`); } } // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts var requestId = 0; async function createLoaderWorker(loader) { if (!await WorkerBody.inWorkerThread()) { return; } WorkerBody.onmessage = async (type, payload) => { switch (type) { case "process": try { const { input, options = {}, context = {} } = payload; const result = await parseData({ loader, arrayBuffer: input, options, // @ts-expect-error fetch missing context: { ...context, _parse: parseOnMainThread } }); WorkerBody.postMessage("done", { result }); } catch (error) { const message = error instanceof Error ? error.message : ""; WorkerBody.postMessage("error", { error: message }); } break; default: } }; } function parseOnMainThread(arrayBuffer, loader, options, context) { return new Promise((resolve, reject) => { const id = requestId++; const onMessage = (type, payload2) => { if (payload2.id !== id) { return; } switch (type) { case "done": WorkerBody.removeEventListener(onMessage); resolve(payload2.result); break; case "error": WorkerBody.removeEventListener(onMessage); reject(payload2.error); break; default: } }; WorkerBody.addEventListener(onMessage); const payload = { id, input: arrayBuffer, options }; WorkerBody.postMessage("process", payload); }); } async function parseData({ loader, arrayBuffer, options, context }) { let data; let parser; if (loader.parseSync || loader.parse) { data = arrayBuffer; parser = loader.parseSync || loader.parse; } else if (loader.parseTextSync) { const textDecoder = new TextDecoder(); data = textDecoder.decode(arrayBuffer); parser = loader.parseTextSync; } else { throw new Error(`Could not load data with ${loader.name} loader`); } options = { ...options, modules: loader && loader.options && loader.options.modules || {}, core: { ...options.core, worker: false } }; return await parser(data, { ...options }, context, loader); } // src/lib/utils/version.ts var VERSION4 = true ? "4.4.2" : "latest"; // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js var KHR_SUPERCOMPRESSION_NONE = 0; var KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT = 0; var KHR_DF_VENDORID_KHRONOS = 0; var KHR_DF_VERSION = 2; var KHR_DF_MODEL_UNSPECIFIED = 0; var KHR_DF_FLAG_ALPHA_STRAIGHT = 0; var KHR_DF_TRANSFER_SRGB = 2; var KHR_DF_PRIMARIES_BT709 = 1; var KHR_DF_SAMPLE_DATATYPE_SIGNED = 64; var VK_FORMAT_UNDEFINED = 0; var KTX2Container = class { constructor() { this.vkFormat = VK_FORMAT_UNDEFINED; this.typeSize = 1; this.pixelWidth = 0; this.pixelHeight = 0; this.pixelDepth = 0; this.layerCount = 0; this.faceCount = 1; this.supercompressionScheme = KHR_SUPERCOMPRESSION_NONE; this.levels = []; this.dataFormatDescriptor = [{ vendorId: KHR_DF_VENDORID_KHRONOS, descriptorType: KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT, descriptorBlockSize: 0, versionNumber: KHR_DF_VERSION, colorModel: KHR_DF_MODEL_UNSPECIFIED, colorPrimaries: KHR_DF_PRIMARIES_BT709, transferFunction: KHR_DF_TRANSFER_SRGB, flags: KHR_DF_FLAG_ALPHA_STRAIGHT, texelBlockDimension: [0, 0, 0, 0], bytesPlane: [0, 0, 0, 0, 0, 0, 0, 0], samples: [] }]; this.keyValue = {}; this.globalData = null; } }; var BufferReader = class { constructor(data, byteOffset, byteLength, littleEndian) { this._dataView = void 0; this._littleEndian = void 0; this._offset = void 0; this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength); this._littleEndian = littleEndian; this._offset = 0; } _nextUint8() { const value = this._dataView.getUint8(this._offset); this._offset += 1; return value; } _nextUint16() { const value = this._dataView.getUint16(this._offset, this._littleEndian); this._offset += 2; return value; } _nextUint32() { const value = this._dataView.getUint32(this._offset, this._littleEndian); this._offset += 4; return value; } _nextUint64() { const left = this._dataView.getUint32(this._offset, this._littleEndian); const right = this._dataView.getUint32(this._offset + 4, this._littleEndian); const value = left + 2 ** 32 * right; this._offset += 8; return value; } _nextInt32() { const value = this._dataView.getInt32(this._offset, this._littleEndian); this._offset += 4; return value; } _nextUint8Array(len) { const value = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._offset, len); this._offset += len; return value; } _skip(bytes) { this._offset += bytes; return this; } _scan(maxByteLength, term = 0) { const byteOffset = this._offset; let byteLength = 0; while (this._dataView.getUint8(this._offset) !== term && byteLength < maxByteLength) { byteLength++; this._offset++; } if (byteLength < maxByteLength) this._offset++; return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength); } }; var NUL = new Uint8Array([0]); 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 decodeText(buffer) { return new TextDecoder().decode(buffer); } function read(data) { const id = new Uint8Array(data.buffer, data.byteOffset, KTX2_ID.length); if (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]) { throw new Error("Missing KTX 2.0 identifier."); } const container = new KTX2Container(); const headerByteLength = 17 * Uint32Array.BYTES_PER_ELEMENT; const headerReader = new BufferReader(data, KTX2_ID.length, headerByteLength, true); container.vkFormat = headerReader._nextUint32(); container.typeSize = headerReader._nextUint32(); container.pixelWidth = headerReader._nextUint32(); container.pixelHeight = headerReader._nextUint32(); container.pixelDepth = headerReader._nextUint32(); container.layerCount = headerReader._nextUint32(); container.faceCount = headerReader._nextUint32(); const levelCount = headerReader._nextUint32(); container.supercompressionScheme = headerReader._nextUint32(); const dfdByteOffset = headerReader._nextUint32(); const dfdByteLength = headerReader._nextUint32(); const kvdByteOffset = headerReader._nextUint32(); const kvdByteLength = headerReader._nextUint32(); const sgdByteOffset = headerReader._nextUint64(); const sgdByteLength = headerReader._nextUint64(); const levelByteLength = levelCount * 3 * 8; const levelReader = new BufferReader(data, KTX2_ID.length + headerByteLength, levelByteLength, true); for (let i = 0; i < levelCount; i++) { container.levels.push({ levelData: new Uint8Array(data.buffer, data.byteOffset + levelReader._nextUint64(), levelReader._nextUint64()), uncompressedByteLength: levelReader._nextUint64() }); } const dfdReader = new BufferReader(data, dfdByteOffset, dfdByteLength, true); const dfd = { vendorId: dfdReader._skip( 4 /* totalSize */ )._nextUint16(), descriptorType: dfdReader._nextUint16(), versionNumber: dfdReader._nextUint16(), descriptorBlockSize: dfdReader._nextUint16(), colorModel: dfdReader._nextUint8(), colorPrimaries: dfdReader._nextUint8(), transferFunction: dfdReader._nextUint8(), flags: dfdReader._nextUint8(), texelBlockDimension: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()], bytesPlane: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()], samples: [] }; const sampleStart = 6; const sampleWords = 4; const numSamples = (dfd.descriptorBlockSize / 4 - sampleStart) / sampleWords; for (let i = 0; i < numSamples; i++) { const sample = { bitOffset: dfdReader._nextUint16(), bitLength: dfdReader._nextUint8(), channelType: dfdReader._nextUint8(), samplePosition: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()], sampleLower: -Infinity, sampleUpper: Infinity }; if (sample.channelType & KHR_DF_SAMPLE_DATATYPE_SIGNED) { sample.sampleLower = dfdReader._nextInt32(); sample.sampleUpper = dfdReader._nextInt32(); } else { sample.sampleLower = dfdReader._nextUint32(); sample.sampleUpper = dfdReader._nextUint32(); } dfd.samples[i] = sample; } container.dataFormatDescriptor.length = 0; container.dataFormatDescriptor.push(dfd); const kvdReader = new BufferReader(data, kvdByteOffset, kvdByteLength, true); while (kvdReader._offset < kvdByteLength) { const keyValueByteLength = kvdReader._nextUint32(); const keyData = kvdReader._scan(keyValueByteLength); const key = decodeText(keyData); container.keyValue[key] = kvdReader._nextUint8Array(keyValueByteLength - keyData.byteLength - 1); if (key.match(/^ktx/i)) { const text = decodeText(container.keyValue[key]); container.keyValue[key] = text.substring(0, text.lastIndexOf("\0")); } const kvPadding = keyValueByteLength % 4 ? 4 - keyValueByteLength % 4 : 0; kvdReader._skip(kvPadding); } if (sgdByteLength <= 0) return container; const sgdReader = new BufferReader(data, sgdByteOffset, sgdByteLength, true); const endpointCount = sgdReader._nextUint16(); const selectorCount = sgdReader._nextUint16(); const endpointsByteLength = sgdReader._nextUint32(); const selectorsByteLength = sgdReader._nextUint32(); const tablesByteLength = sgdReader._nextUint32(); const extendedByteLength = sgdReader._nextUint32(); const imageDescs = []; for (let i = 0; i < levelCount; i++) { imageDescs.push({ imageFlags: sgdReader._nextUint32(), rgbSliceByteOffset: sgdReader._nextUint32(), rgbSliceByteLength: sgdReader._nextUint32(), alphaSliceByteOffset: sgdReader._nextUint32(), alphaSliceByteLength: sgdReader._nextUint32() }); } const endpointsByteOffset = sgdByteOffset + sgdReader._offset; const selectorsByteOffset = endpointsByteOffset + endpointsByteLength; const tablesByteOffset = selectorsByteOffset + selectorsByteLength; const extendedByteOffset = tablesByteOffset + tablesByteLength; const endpointsData = new Uint8Array(data.buffer, data.byteOffset + endpointsByteOffset, endpointsByteLength); const selectorsData = new Uint8Array(data.buffer, data.byteOffset + selectorsByteOffset, selectorsByteLength); const tablesData = new Uint8Array(data.buffer, data.byteOffset + tablesByteOffset, tablesByteLength); const extendedData = new Uint8Array(data.buffer, data.byteOffset + extendedByteOffset, extendedByteLength); container.globalData = { endpointCount, selectorCount, imageDescs, endpointsData, selectorsData, tablesData, extendedData }; return container; } // src/lib/gl-extensions.ts var GL_RGBA4 = 32854; 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_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; // src/lib/utils/texture-format-map.ts 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]; } // src/lib/utils/extract-mipmap-images.ts 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]); } // src/lib/utils/ktx-format-helper.ts 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_S