@loaders.gl/textures 4.4.0-alpha.16 → 4.4.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/basis-loader.d.ts +17 -8
- package/dist/basis-loader.d.ts.map +1 -1
- package/dist/basis-loader.js.map +1 -1
- package/dist/basis-worker-node.js +317 -188
- package/dist/basis-worker.js +252 -123
- package/dist/compressed-texture-worker.js +1035 -326
- package/dist/crunch-worker.js +141 -82
- package/dist/dist.dev.js +1220 -334
- package/dist/dist.min.js +1 -2
- package/dist/index.cjs +657 -317
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/ktx2-basis-writer-worker-node.js +2 -2
- package/dist/ktx2-basis-writer-worker.js +2 -2
- package/dist/lib/gl-extensions.d.ts +164 -58
- package/dist/lib/gl-extensions.d.ts.map +1 -1
- package/dist/lib/gl-extensions.js +175 -66
- package/dist/lib/gl-extensions.js.map +1 -1
- package/dist/lib/parsers/parse-basis.d.ts +16 -1
- package/dist/lib/parsers/parse-basis.d.ts.map +1 -1
- package/dist/lib/parsers/parse-basis.js +216 -43
- package/dist/lib/parsers/parse-basis.js.map +1 -1
- package/dist/lib/parsers/parse-crunch.d.ts.map +1 -1
- package/dist/lib/parsers/parse-crunch.js +4 -4
- package/dist/lib/parsers/parse-crunch.js.map +1 -1
- package/dist/lib/parsers/parse-dds.d.ts.map +1 -1
- package/dist/lib/parsers/parse-dds.js +7 -7
- package/dist/lib/parsers/parse-dds.js.map +1 -1
- package/dist/lib/parsers/parse-ktx.d.ts.map +1 -1
- package/dist/lib/parsers/parse-ktx.js +7 -0
- package/dist/lib/parsers/parse-ktx.js.map +1 -1
- package/dist/lib/parsers/parse-pvr.d.ts.map +1 -1
- package/dist/lib/parsers/parse-pvr.js +28 -70
- package/dist/lib/parsers/parse-pvr.js.map +1 -1
- package/dist/lib/utils/detect-supported-texture-formats.d.ts +14 -0
- package/dist/lib/utils/detect-supported-texture-formats.d.ts.map +1 -0
- package/dist/lib/utils/detect-supported-texture-formats.js +197 -0
- package/dist/lib/utils/detect-supported-texture-formats.js.map +1 -0
- package/dist/lib/utils/extract-mipmap-images.d.ts +2 -2
- package/dist/lib/utils/extract-mipmap-images.d.ts.map +1 -1
- package/dist/lib/utils/extract-mipmap-images.js +12 -2
- package/dist/lib/utils/extract-mipmap-images.js.map +1 -1
- package/dist/lib/utils/ktx-format-helper.d.ts +2 -1
- package/dist/lib/utils/ktx-format-helper.d.ts.map +1 -1
- package/dist/lib/utils/ktx-format-helper.js +67 -109
- package/dist/lib/utils/ktx-format-helper.js.map +1 -1
- package/dist/lib/utils/texture-format-map.d.ts +3 -0
- package/dist/lib/utils/texture-format-map.d.ts.map +1 -0
- package/dist/lib/utils/texture-format-map.js +71 -0
- package/dist/lib/utils/texture-format-map.js.map +1 -0
- package/dist/lib/utils/version.js +1 -1
- package/dist/npy-worker.js +1 -1
- package/package.json +6 -6
- package/src/basis-loader.ts +21 -8
- package/src/index.ts +2 -4
- package/src/lib/gl-extensions.ts +186 -81
- package/src/lib/parsers/parse-basis.ts +274 -40
- package/src/lib/parsers/parse-crunch.ts +13 -6
- package/src/lib/parsers/parse-dds.ts +16 -9
- package/src/lib/parsers/parse-ktx.ts +12 -2
- package/src/lib/parsers/parse-pvr.ts +72 -72
- package/src/lib/utils/detect-supported-texture-formats.ts +210 -0
- package/src/lib/utils/extract-mipmap-images.ts +15 -4
- package/src/lib/utils/ktx-format-helper.ts +124 -111
- package/src/lib/utils/texture-format-map.ts +135 -0
- package/dist/lib/utils/texture-formats.d.ts +0 -8
- package/dist/lib/utils/texture-formats.d.ts.map +0 -1
- package/dist/lib/utils/texture-formats.js +0 -51
- package/dist/lib/utils/texture-formats.js.map +0 -1
- package/src/lib/utils/texture-formats.ts +0 -59
|
@@ -7,6 +7,541 @@
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
11
|
+
var window_ = globalThis;
|
|
12
|
+
var document_ = globalThis.document || {};
|
|
13
|
+
var process_ = globalThis.process || {};
|
|
14
|
+
var console_ = globalThis.console;
|
|
15
|
+
var navigator_ = globalThis.navigator || {};
|
|
16
|
+
|
|
17
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
18
|
+
function isElectron(mockUserAgent) {
|
|
19
|
+
if (typeof window !== "undefined" && window.process?.type === "renderer") {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (typeof process !== "undefined" && Boolean(process.versions?.["electron"])) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
const realUserAgent = typeof navigator !== "undefined" && navigator.userAgent;
|
|
26
|
+
const userAgent = mockUserAgent || realUserAgent;
|
|
27
|
+
return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
31
|
+
function isBrowser() {
|
|
32
|
+
const isNode = (
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
typeof process === "object" && String(process) === "[object process]" && !process?.browser
|
|
35
|
+
);
|
|
36
|
+
return !isNode || isElectron();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ../../node_modules/@probe.gl/env/dist/index.js
|
|
40
|
+
var VERSION = true ? "4.1.1" : "untranspiled source";
|
|
41
|
+
|
|
42
|
+
// ../../node_modules/@probe.gl/log/dist/utils/assert.js
|
|
43
|
+
function assert2(condition, message) {
|
|
44
|
+
if (!condition) {
|
|
45
|
+
throw new Error(message || "Assertion failed");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ../../node_modules/@probe.gl/log/dist/loggers/log-utils.js
|
|
50
|
+
function normalizeLogLevel(logLevel) {
|
|
51
|
+
if (!logLevel) {
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
let resolvedLevel;
|
|
55
|
+
switch (typeof logLevel) {
|
|
56
|
+
case "number":
|
|
57
|
+
resolvedLevel = logLevel;
|
|
58
|
+
break;
|
|
59
|
+
case "object":
|
|
60
|
+
resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
assert2(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
|
|
66
|
+
return resolvedLevel;
|
|
67
|
+
}
|
|
68
|
+
function normalizeArguments(opts) {
|
|
69
|
+
const { logLevel, message } = opts;
|
|
70
|
+
opts.logLevel = normalizeLogLevel(logLevel);
|
|
71
|
+
const args = opts.args ? Array.from(opts.args) : [];
|
|
72
|
+
while (args.length && args.shift() !== message) {
|
|
73
|
+
}
|
|
74
|
+
switch (typeof logLevel) {
|
|
75
|
+
case "string":
|
|
76
|
+
case "function":
|
|
77
|
+
if (message !== void 0) {
|
|
78
|
+
args.unshift(message);
|
|
79
|
+
}
|
|
80
|
+
opts.message = logLevel;
|
|
81
|
+
break;
|
|
82
|
+
case "object":
|
|
83
|
+
Object.assign(opts, logLevel);
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
}
|
|
87
|
+
if (typeof opts.message === "function") {
|
|
88
|
+
opts.message = opts.message();
|
|
89
|
+
}
|
|
90
|
+
const messageType = typeof opts.message;
|
|
91
|
+
assert2(messageType === "string" || messageType === "object");
|
|
92
|
+
return Object.assign(opts, { args }, opts.opts);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ../../node_modules/@probe.gl/log/dist/loggers/base-log.js
|
|
96
|
+
var noop = () => {
|
|
97
|
+
};
|
|
98
|
+
var BaseLog = class {
|
|
99
|
+
constructor({ level = 0 } = {}) {
|
|
100
|
+
this.userData = {};
|
|
101
|
+
this._onceCache = /* @__PURE__ */ new Set();
|
|
102
|
+
this._level = level;
|
|
103
|
+
}
|
|
104
|
+
set level(newLevel) {
|
|
105
|
+
this.setLevel(newLevel);
|
|
106
|
+
}
|
|
107
|
+
get level() {
|
|
108
|
+
return this.getLevel();
|
|
109
|
+
}
|
|
110
|
+
setLevel(level) {
|
|
111
|
+
this._level = level;
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
getLevel() {
|
|
115
|
+
return this._level;
|
|
116
|
+
}
|
|
117
|
+
// Unconditional logging
|
|
118
|
+
warn(message, ...args) {
|
|
119
|
+
return this._log("warn", 0, message, args, { once: true });
|
|
120
|
+
}
|
|
121
|
+
error(message, ...args) {
|
|
122
|
+
return this._log("error", 0, message, args);
|
|
123
|
+
}
|
|
124
|
+
// Conditional logging
|
|
125
|
+
log(logLevel, message, ...args) {
|
|
126
|
+
return this._log("log", logLevel, message, args);
|
|
127
|
+
}
|
|
128
|
+
info(logLevel, message, ...args) {
|
|
129
|
+
return this._log("info", logLevel, message, args);
|
|
130
|
+
}
|
|
131
|
+
once(logLevel, message, ...args) {
|
|
132
|
+
return this._log("once", logLevel, message, args, { once: true });
|
|
133
|
+
}
|
|
134
|
+
_log(type, logLevel, message, args, options = {}) {
|
|
135
|
+
const normalized = normalizeArguments({
|
|
136
|
+
logLevel,
|
|
137
|
+
message,
|
|
138
|
+
args: this._buildArgs(logLevel, message, args),
|
|
139
|
+
opts: options
|
|
140
|
+
});
|
|
141
|
+
return this._createLogFunction(type, normalized, options);
|
|
142
|
+
}
|
|
143
|
+
_buildArgs(logLevel, message, args) {
|
|
144
|
+
return [logLevel, message, ...args];
|
|
145
|
+
}
|
|
146
|
+
_createLogFunction(type, normalized, options) {
|
|
147
|
+
if (!this._shouldLog(normalized.logLevel)) {
|
|
148
|
+
return noop;
|
|
149
|
+
}
|
|
150
|
+
const tag = this._getOnceTag(options.tag ?? normalized.tag ?? normalized.message);
|
|
151
|
+
if ((options.once || normalized.once) && tag !== void 0) {
|
|
152
|
+
if (this._onceCache.has(tag)) {
|
|
153
|
+
return noop;
|
|
154
|
+
}
|
|
155
|
+
this._onceCache.add(tag);
|
|
156
|
+
}
|
|
157
|
+
return this._emit(type, normalized);
|
|
158
|
+
}
|
|
159
|
+
_shouldLog(logLevel) {
|
|
160
|
+
return this.getLevel() >= normalizeLogLevel(logLevel);
|
|
161
|
+
}
|
|
162
|
+
_getOnceTag(tag) {
|
|
163
|
+
if (tag === void 0) {
|
|
164
|
+
return void 0;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
return typeof tag === "string" ? tag : String(tag);
|
|
168
|
+
} catch {
|
|
169
|
+
return void 0;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
175
|
+
function getStorage(type) {
|
|
176
|
+
try {
|
|
177
|
+
const storage = window[type];
|
|
178
|
+
const x = "__storage_test__";
|
|
179
|
+
storage.setItem(x, x);
|
|
180
|
+
storage.removeItem(x);
|
|
181
|
+
return storage;
|
|
182
|
+
} catch (e) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
var LocalStorage = class {
|
|
187
|
+
constructor(id, defaultConfig, type = "sessionStorage") {
|
|
188
|
+
this.storage = getStorage(type);
|
|
189
|
+
this.id = id;
|
|
190
|
+
this.config = defaultConfig;
|
|
191
|
+
this._loadConfiguration();
|
|
192
|
+
}
|
|
193
|
+
getConfiguration() {
|
|
194
|
+
return this.config;
|
|
195
|
+
}
|
|
196
|
+
setConfiguration(configuration) {
|
|
197
|
+
Object.assign(this.config, configuration);
|
|
198
|
+
if (this.storage) {
|
|
199
|
+
const serialized = JSON.stringify(this.config);
|
|
200
|
+
this.storage.setItem(this.id, serialized);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// Get config from persistent store, if available
|
|
204
|
+
_loadConfiguration() {
|
|
205
|
+
let configuration = {};
|
|
206
|
+
if (this.storage) {
|
|
207
|
+
const serializedConfiguration = this.storage.getItem(this.id);
|
|
208
|
+
configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
|
|
209
|
+
}
|
|
210
|
+
Object.assign(this.config, configuration);
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// ../../node_modules/@probe.gl/log/dist/utils/formatters.js
|
|
216
|
+
function formatTime(ms) {
|
|
217
|
+
let formatted;
|
|
218
|
+
if (ms < 10) {
|
|
219
|
+
formatted = `${ms.toFixed(2)}ms`;
|
|
220
|
+
} else if (ms < 100) {
|
|
221
|
+
formatted = `${ms.toFixed(1)}ms`;
|
|
222
|
+
} else if (ms < 1e3) {
|
|
223
|
+
formatted = `${ms.toFixed(0)}ms`;
|
|
224
|
+
} else {
|
|
225
|
+
formatted = `${(ms / 1e3).toFixed(2)}s`;
|
|
226
|
+
}
|
|
227
|
+
return formatted;
|
|
228
|
+
}
|
|
229
|
+
function leftPad(string, length = 8) {
|
|
230
|
+
const padLength = Math.max(length - string.length, 0);
|
|
231
|
+
return `${" ".repeat(padLength)}${string}`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ../../node_modules/@probe.gl/log/dist/utils/color.js
|
|
235
|
+
var COLOR;
|
|
236
|
+
(function(COLOR2) {
|
|
237
|
+
COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
|
|
238
|
+
COLOR2[COLOR2["RED"] = 31] = "RED";
|
|
239
|
+
COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
|
|
240
|
+
COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
|
|
241
|
+
COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
|
|
242
|
+
COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
|
|
243
|
+
COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
|
|
244
|
+
COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
|
|
245
|
+
COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
|
|
246
|
+
COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
|
|
247
|
+
COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
|
|
248
|
+
COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
|
|
249
|
+
COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
|
|
250
|
+
COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
|
|
251
|
+
COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
|
|
252
|
+
COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
|
|
253
|
+
})(COLOR || (COLOR = {}));
|
|
254
|
+
var BACKGROUND_INCREMENT = 10;
|
|
255
|
+
function getColor(color) {
|
|
256
|
+
if (typeof color !== "string") {
|
|
257
|
+
return color;
|
|
258
|
+
}
|
|
259
|
+
color = color.toUpperCase();
|
|
260
|
+
return COLOR[color] || COLOR.WHITE;
|
|
261
|
+
}
|
|
262
|
+
function addColor(string, color, background) {
|
|
263
|
+
if (!isBrowser && typeof string === "string") {
|
|
264
|
+
if (color) {
|
|
265
|
+
const colorCode = getColor(color);
|
|
266
|
+
string = `\x1B[${colorCode}m${string}\x1B[39m`;
|
|
267
|
+
}
|
|
268
|
+
if (background) {
|
|
269
|
+
const colorCode = getColor(background);
|
|
270
|
+
string = `\x1B[${colorCode + BACKGROUND_INCREMENT}m${string}\x1B[49m`;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return string;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// ../../node_modules/@probe.gl/log/dist/utils/autobind.js
|
|
277
|
+
function autobind(obj, predefined = ["constructor"]) {
|
|
278
|
+
const proto = Object.getPrototypeOf(obj);
|
|
279
|
+
const propNames = Object.getOwnPropertyNames(proto);
|
|
280
|
+
const object = obj;
|
|
281
|
+
for (const key of propNames) {
|
|
282
|
+
const value = object[key];
|
|
283
|
+
if (typeof value === "function") {
|
|
284
|
+
if (!predefined.find((name) => key === name)) {
|
|
285
|
+
object[key] = value.bind(obj);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
|
|
292
|
+
function getHiResTimestamp() {
|
|
293
|
+
let timestamp;
|
|
294
|
+
if (isBrowser() && window_.performance) {
|
|
295
|
+
timestamp = window_?.performance?.now?.();
|
|
296
|
+
} else if ("hrtime" in process_) {
|
|
297
|
+
const timeParts = process_?.hrtime?.();
|
|
298
|
+
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
299
|
+
} else {
|
|
300
|
+
timestamp = Date.now();
|
|
301
|
+
}
|
|
302
|
+
return timestamp;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// ../../node_modules/@probe.gl/log/dist/loggers/probe-log.js
|
|
306
|
+
var originalConsole = {
|
|
307
|
+
debug: isBrowser() ? console.debug || console.log : console.log,
|
|
308
|
+
log: console.log,
|
|
309
|
+
info: console.info,
|
|
310
|
+
warn: console.warn,
|
|
311
|
+
error: console.error
|
|
312
|
+
};
|
|
313
|
+
var DEFAULT_LOG_CONFIGURATION = {
|
|
314
|
+
enabled: true,
|
|
315
|
+
level: 0
|
|
316
|
+
};
|
|
317
|
+
var ProbeLog = class extends BaseLog {
|
|
318
|
+
constructor({ id } = { id: "" }) {
|
|
319
|
+
super({ level: 0 });
|
|
320
|
+
this.VERSION = VERSION;
|
|
321
|
+
this._startTs = getHiResTimestamp();
|
|
322
|
+
this._deltaTs = getHiResTimestamp();
|
|
323
|
+
this.userData = {};
|
|
324
|
+
this.LOG_THROTTLE_TIMEOUT = 0;
|
|
325
|
+
this.id = id;
|
|
326
|
+
this.userData = {};
|
|
327
|
+
this._storage = new LocalStorage(`__probe-${this.id}__`, { [this.id]: DEFAULT_LOG_CONFIGURATION });
|
|
328
|
+
this.timeStamp(`${this.id} started`);
|
|
329
|
+
autobind(this);
|
|
330
|
+
Object.seal(this);
|
|
331
|
+
}
|
|
332
|
+
isEnabled() {
|
|
333
|
+
return this._getConfiguration().enabled;
|
|
334
|
+
}
|
|
335
|
+
getLevel() {
|
|
336
|
+
return this._getConfiguration().level;
|
|
337
|
+
}
|
|
338
|
+
/** @return milliseconds, with fractions */
|
|
339
|
+
getTotal() {
|
|
340
|
+
return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
|
|
341
|
+
}
|
|
342
|
+
/** @return milliseconds, with fractions */
|
|
343
|
+
getDelta() {
|
|
344
|
+
return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
|
|
345
|
+
}
|
|
346
|
+
/** @deprecated use logLevel */
|
|
347
|
+
set priority(newPriority) {
|
|
348
|
+
this.level = newPriority;
|
|
349
|
+
}
|
|
350
|
+
/** @deprecated use logLevel */
|
|
351
|
+
get priority() {
|
|
352
|
+
return this.level;
|
|
353
|
+
}
|
|
354
|
+
/** @deprecated use logLevel */
|
|
355
|
+
getPriority() {
|
|
356
|
+
return this.level;
|
|
357
|
+
}
|
|
358
|
+
// Configure
|
|
359
|
+
enable(enabled = true) {
|
|
360
|
+
this._updateConfiguration({ enabled });
|
|
361
|
+
return this;
|
|
362
|
+
}
|
|
363
|
+
setLevel(level) {
|
|
364
|
+
this._updateConfiguration({ level });
|
|
365
|
+
return this;
|
|
366
|
+
}
|
|
367
|
+
/** return the current status of the setting */
|
|
368
|
+
get(setting) {
|
|
369
|
+
return this._getConfiguration()[setting];
|
|
370
|
+
}
|
|
371
|
+
// update the status of the setting
|
|
372
|
+
set(setting, value) {
|
|
373
|
+
this._updateConfiguration({ [setting]: value });
|
|
374
|
+
}
|
|
375
|
+
/** Logs the current settings as a table */
|
|
376
|
+
settings() {
|
|
377
|
+
if (console.table) {
|
|
378
|
+
console.table(this._storage.config);
|
|
379
|
+
} else {
|
|
380
|
+
console.log(this._storage.config);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
// Unconditional logging
|
|
384
|
+
assert(condition, message) {
|
|
385
|
+
if (!condition) {
|
|
386
|
+
throw new Error(message || "Assertion failed");
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
warn(message, ...args) {
|
|
390
|
+
return this._log("warn", 0, message, args, {
|
|
391
|
+
method: originalConsole.warn,
|
|
392
|
+
once: true
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
error(message, ...args) {
|
|
396
|
+
return this._log("error", 0, message, args, {
|
|
397
|
+
method: originalConsole.error
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
/** Print a deprecation warning */
|
|
401
|
+
deprecated(oldUsage, newUsage) {
|
|
402
|
+
return this.warn(`\`${oldUsage}\` is deprecated and will be removed in a later version. Use \`${newUsage}\` instead`);
|
|
403
|
+
}
|
|
404
|
+
/** Print a removal warning */
|
|
405
|
+
removed(oldUsage, newUsage) {
|
|
406
|
+
return this.error(`\`${oldUsage}\` has been removed. Use \`${newUsage}\` instead`);
|
|
407
|
+
}
|
|
408
|
+
probe(logLevel, message, ...args) {
|
|
409
|
+
return this._log("log", logLevel, message, args, {
|
|
410
|
+
method: originalConsole.log,
|
|
411
|
+
time: true,
|
|
412
|
+
once: true
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
log(logLevel, message, ...args) {
|
|
416
|
+
return this._log("log", logLevel, message, args, {
|
|
417
|
+
method: originalConsole.debug
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
info(logLevel, message, ...args) {
|
|
421
|
+
return this._log("info", logLevel, message, args, { method: console.info });
|
|
422
|
+
}
|
|
423
|
+
once(logLevel, message, ...args) {
|
|
424
|
+
return this._log("once", logLevel, message, args, {
|
|
425
|
+
method: originalConsole.debug || originalConsole.info,
|
|
426
|
+
once: true
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
/** Logs an object as a table */
|
|
430
|
+
table(logLevel, table, columns) {
|
|
431
|
+
if (table) {
|
|
432
|
+
return this._log("table", logLevel, table, columns && [columns] || [], {
|
|
433
|
+
method: console.table || noop,
|
|
434
|
+
tag: getTableHeader(table)
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
return noop;
|
|
438
|
+
}
|
|
439
|
+
time(logLevel, message) {
|
|
440
|
+
return this._log("time", logLevel, message, [], {
|
|
441
|
+
method: console.time ? console.time : console.info
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
timeEnd(logLevel, message) {
|
|
445
|
+
return this._log("time", logLevel, message, [], {
|
|
446
|
+
method: console.timeEnd ? console.timeEnd : console.info
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
timeStamp(logLevel, message) {
|
|
450
|
+
return this._log("time", logLevel, message, [], {
|
|
451
|
+
method: console.timeStamp || noop
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
group(logLevel, message, opts = { collapsed: false }) {
|
|
455
|
+
const method = (opts.collapsed ? console.groupCollapsed : console.group) || console.info;
|
|
456
|
+
return this._log("group", logLevel, message, [], { method });
|
|
457
|
+
}
|
|
458
|
+
groupCollapsed(logLevel, message, opts = {}) {
|
|
459
|
+
return this.group(logLevel, message, Object.assign({}, opts, { collapsed: true }));
|
|
460
|
+
}
|
|
461
|
+
groupEnd(logLevel) {
|
|
462
|
+
return this._log("groupEnd", logLevel, "", [], {
|
|
463
|
+
method: console.groupEnd || noop
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
// EXPERIMENTAL
|
|
467
|
+
withGroup(logLevel, message, func) {
|
|
468
|
+
this.group(logLevel, message)();
|
|
469
|
+
try {
|
|
470
|
+
func();
|
|
471
|
+
} finally {
|
|
472
|
+
this.groupEnd(logLevel)();
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
trace() {
|
|
476
|
+
if (console.trace) {
|
|
477
|
+
console.trace();
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
_shouldLog(logLevel) {
|
|
481
|
+
return this.isEnabled() && super._shouldLog(logLevel);
|
|
482
|
+
}
|
|
483
|
+
_emit(_type, normalized) {
|
|
484
|
+
const method = normalized.method;
|
|
485
|
+
assert2(method);
|
|
486
|
+
normalized.total = this.getTotal();
|
|
487
|
+
normalized.delta = this.getDelta();
|
|
488
|
+
this._deltaTs = getHiResTimestamp();
|
|
489
|
+
const message = decorateMessage(this.id, normalized.message, normalized);
|
|
490
|
+
return method.bind(console, message, ...normalized.args);
|
|
491
|
+
}
|
|
492
|
+
_getConfiguration() {
|
|
493
|
+
if (!this._storage.config[this.id]) {
|
|
494
|
+
this._updateConfiguration(DEFAULT_LOG_CONFIGURATION);
|
|
495
|
+
}
|
|
496
|
+
return this._storage.config[this.id];
|
|
497
|
+
}
|
|
498
|
+
_updateConfiguration(configuration) {
|
|
499
|
+
const currentConfiguration = this._storage.config[this.id] || {
|
|
500
|
+
...DEFAULT_LOG_CONFIGURATION
|
|
501
|
+
};
|
|
502
|
+
this._storage.setConfiguration({
|
|
503
|
+
[this.id]: { ...currentConfiguration, ...configuration }
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
ProbeLog.VERSION = VERSION;
|
|
508
|
+
function decorateMessage(id, message, opts) {
|
|
509
|
+
if (typeof message === "string") {
|
|
510
|
+
const time = opts.time ? leftPad(formatTime(opts.total)) : "";
|
|
511
|
+
message = opts.time ? `${id}: ${time} ${message}` : `${id}: ${message}`;
|
|
512
|
+
message = addColor(message, opts.color, opts.background);
|
|
513
|
+
}
|
|
514
|
+
return message;
|
|
515
|
+
}
|
|
516
|
+
function getTableHeader(table) {
|
|
517
|
+
for (const key in table) {
|
|
518
|
+
for (const title in table[key]) {
|
|
519
|
+
return title || "untitled";
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return "empty";
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// ../../node_modules/@probe.gl/log/dist/init.js
|
|
526
|
+
globalThis.probe = {};
|
|
527
|
+
|
|
528
|
+
// ../../node_modules/@probe.gl/log/dist/index.js
|
|
529
|
+
var dist_default = new ProbeLog({ id: "@probe.gl/log" });
|
|
530
|
+
|
|
531
|
+
// ../loader-utils/src/lib/log-utils/log.ts
|
|
532
|
+
var VERSION2 = true ? "4.4.0-alpha.17" : "latest";
|
|
533
|
+
var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
|
|
534
|
+
function createLog() {
|
|
535
|
+
const log2 = new ProbeLog({ id: "loaders.gl" });
|
|
536
|
+
globalThis.loaders ||= {};
|
|
537
|
+
globalThis.loaders.log = log2;
|
|
538
|
+
globalThis.loaders.version = version;
|
|
539
|
+
globalThis.probe ||= {};
|
|
540
|
+
globalThis.probe.loaders = log2;
|
|
541
|
+
return log2;
|
|
542
|
+
}
|
|
543
|
+
var log = createLog();
|
|
544
|
+
|
|
10
545
|
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
11
546
|
function registerJSModules(modules) {
|
|
12
547
|
globalThis.loaders ||= {};
|
|
@@ -29,15 +564,15 @@
|
|
|
29
564
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
30
565
|
warningIssued = true;
|
|
31
566
|
} else {
|
|
32
|
-
globalThis._loadersgl_.version = "4.4.0-alpha.
|
|
567
|
+
globalThis._loadersgl_.version = "4.4.0-alpha.17";
|
|
33
568
|
}
|
|
34
569
|
}
|
|
35
570
|
return globalThis._loadersgl_.version;
|
|
36
571
|
}
|
|
37
|
-
var
|
|
572
|
+
var VERSION3 = getVersion();
|
|
38
573
|
|
|
39
574
|
// ../worker-utils/src/lib/env-utils/assert.ts
|
|
40
|
-
function
|
|
575
|
+
function assert3(condition, message) {
|
|
41
576
|
if (!condition) {
|
|
42
577
|
throw new Error(message || "loaders.gl assertion failed.");
|
|
43
578
|
}
|
|
@@ -51,10 +586,10 @@
|
|
|
51
586
|
document: typeof document !== "undefined" && document
|
|
52
587
|
};
|
|
53
588
|
var self_ = globals.self || globals.window || globals.global || {};
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
589
|
+
var window_2 = globals.window || globals.self || globals.global || {};
|
|
590
|
+
var global_2 = globals.global || globals.self || globals.window || {};
|
|
591
|
+
var document_2 = globals.document || {};
|
|
592
|
+
var isBrowser2 = (
|
|
58
593
|
// @ts-ignore process.browser
|
|
59
594
|
typeof process !== "object" || String(process) !== "[object process]" || process.browser
|
|
60
595
|
);
|
|
@@ -203,12 +738,12 @@
|
|
|
203
738
|
if (modules[libraryName]) {
|
|
204
739
|
return modules[libraryName];
|
|
205
740
|
}
|
|
206
|
-
if (!
|
|
741
|
+
if (!isBrowser2) {
|
|
207
742
|
return `modules/${moduleName}/dist/libs/${libraryName}`;
|
|
208
743
|
}
|
|
209
744
|
if (options.CDN) {
|
|
210
|
-
|
|
211
|
-
return `${options.CDN}/${moduleName}@${
|
|
745
|
+
assert3(options.CDN.startsWith("http"));
|
|
746
|
+
return `${options.CDN}/${moduleName}@${VERSION3}/dist/libs/${libraryName}`;
|
|
212
747
|
}
|
|
213
748
|
if (isWorker) {
|
|
214
749
|
return `../src/libs/${libraryName}`;
|
|
@@ -219,7 +754,7 @@
|
|
|
219
754
|
if (libraryUrl.endsWith("wasm")) {
|
|
220
755
|
return await loadAsArrayBuffer(libraryUrl);
|
|
221
756
|
}
|
|
222
|
-
if (!
|
|
757
|
+
if (!isBrowser2) {
|
|
223
758
|
const { requireFromFile } = globalThis.loaders || {};
|
|
224
759
|
try {
|
|
225
760
|
const result = await requireFromFile?.(libraryUrl);
|
|
@@ -245,7 +780,7 @@
|
|
|
245
780
|
return loadLibraryFromString(scriptSource, libraryUrl);
|
|
246
781
|
}
|
|
247
782
|
function loadLibraryFromString(scriptSource, id) {
|
|
248
|
-
if (!
|
|
783
|
+
if (!isBrowser2) {
|
|
249
784
|
const { requireFromString } = globalThis.loaders || {};
|
|
250
785
|
return requireFromString?.(scriptSource, id);
|
|
251
786
|
}
|
|
@@ -265,7 +800,7 @@
|
|
|
265
800
|
}
|
|
266
801
|
async function loadAsArrayBuffer(url) {
|
|
267
802
|
const { readFileAsArrayBuffer } = globalThis.loaders || {};
|
|
268
|
-
if (
|
|
803
|
+
if (isBrowser2 || !readFileAsArrayBuffer || url.startsWith("http")) {
|
|
269
804
|
const response = await fetch(url);
|
|
270
805
|
return await response.arrayBuffer();
|
|
271
806
|
}
|
|
@@ -280,7 +815,7 @@
|
|
|
280
815
|
}
|
|
281
816
|
async function loadAsText(url) {
|
|
282
817
|
const { readFileAsText } = globalThis.loaders || {};
|
|
283
|
-
if (
|
|
818
|
+
if (isBrowser2 || !readFileAsText || url.startsWith("http")) {
|
|
284
819
|
const response = await fetch(url);
|
|
285
820
|
return await response.text();
|
|
286
821
|
}
|
|
@@ -379,7 +914,7 @@
|
|
|
379
914
|
}
|
|
380
915
|
|
|
381
916
|
// src/lib/utils/version.ts
|
|
382
|
-
var
|
|
917
|
+
var VERSION4 = true ? "4.4.0-alpha.17" : "latest";
|
|
383
918
|
|
|
384
919
|
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
385
920
|
var KHR_SUPERCOMPRESSION_NONE = 0;
|
|
@@ -630,23 +1165,164 @@
|
|
|
630
1165
|
return container;
|
|
631
1166
|
}
|
|
632
1167
|
|
|
1168
|
+
// src/lib/gl-extensions.ts
|
|
1169
|
+
var GL_RGBA4 = 32854;
|
|
1170
|
+
var GL_RGBA8 = 32856;
|
|
1171
|
+
var GL_RGB565 = 36194;
|
|
1172
|
+
var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776;
|
|
1173
|
+
var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777;
|
|
1174
|
+
var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778;
|
|
1175
|
+
var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779;
|
|
1176
|
+
var GL_COMPRESSED_R11_EAC = 37488;
|
|
1177
|
+
var GL_COMPRESSED_SIGNED_R11_EAC = 37489;
|
|
1178
|
+
var GL_COMPRESSED_RG11_EAC = 37490;
|
|
1179
|
+
var GL_COMPRESSED_SIGNED_RG11_EAC = 37491;
|
|
1180
|
+
var GL_COMPRESSED_RGB8_ETC2 = 37492;
|
|
1181
|
+
var GL_COMPRESSED_RGBA8_ETC2_EAC = 37493;
|
|
1182
|
+
var GL_COMPRESSED_SRGB8_ETC2 = 37494;
|
|
1183
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 37495;
|
|
1184
|
+
var GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37496;
|
|
1185
|
+
var GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37497;
|
|
1186
|
+
var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840;
|
|
1187
|
+
var GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 35841;
|
|
1188
|
+
var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842;
|
|
1189
|
+
var GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 35843;
|
|
1190
|
+
var GL_COMPRESSED_RGB_ETC1_WEBGL = 36196;
|
|
1191
|
+
var GL_COMPRESSED_RGB_ATC_WEBGL = 35986;
|
|
1192
|
+
var GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 35987;
|
|
1193
|
+
var GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 34798;
|
|
1194
|
+
var GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 37808;
|
|
1195
|
+
var GL_COMPRESSED_RGBA_ASTC_5x4_KHR = 37809;
|
|
1196
|
+
var GL_COMPRESSED_RGBA_ASTC_5x5_KHR = 37810;
|
|
1197
|
+
var GL_COMPRESSED_RGBA_ASTC_6x5_KHR = 37811;
|
|
1198
|
+
var GL_COMPRESSED_RGBA_ASTC_6x6_KHR = 37812;
|
|
1199
|
+
var GL_COMPRESSED_RGBA_ASTC_8x5_KHR = 37813;
|
|
1200
|
+
var GL_COMPRESSED_RGBA_ASTC_8x6_KHR = 37814;
|
|
1201
|
+
var GL_COMPRESSED_RGBA_ASTC_8x8_KHR = 37815;
|
|
1202
|
+
var GL_COMPRESSED_RGBA_ASTC_10x5_KHR = 37816;
|
|
1203
|
+
var GL_COMPRESSED_RGBA_ASTC_10x6_KHR = 37817;
|
|
1204
|
+
var GL_COMPRESSED_RGBA_ASTC_10x8_KHR = 37818;
|
|
1205
|
+
var GL_COMPRESSED_RGBA_ASTC_10x10_KHR = 37819;
|
|
1206
|
+
var GL_COMPRESSED_RGBA_ASTC_12x10_KHR = 37820;
|
|
1207
|
+
var GL_COMPRESSED_RGBA_ASTC_12x12_KHR = 37821;
|
|
1208
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 37840;
|
|
1209
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 37841;
|
|
1210
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 37842;
|
|
1211
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 37843;
|
|
1212
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 37844;
|
|
1213
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 37845;
|
|
1214
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 37846;
|
|
1215
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 37847;
|
|
1216
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 37848;
|
|
1217
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 37849;
|
|
1218
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 37850;
|
|
1219
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 37851;
|
|
1220
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 37852;
|
|
1221
|
+
var GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 37853;
|
|
1222
|
+
var GL_COMPRESSED_RED_RGTC1_EXT = 36283;
|
|
1223
|
+
var GL_COMPRESSED_SIGNED_RED_RGTC1_EXT = 36284;
|
|
1224
|
+
var GL_COMPRESSED_RED_GREEN_RGTC2_EXT = 36285;
|
|
1225
|
+
var GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 36286;
|
|
1226
|
+
var GL_COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492;
|
|
1227
|
+
var GL_COMPRESSED_SRGB_S3TC_DXT1_EXT = 35916;
|
|
1228
|
+
var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 35917;
|
|
1229
|
+
var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 35918;
|
|
1230
|
+
var GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 35919;
|
|
1231
|
+
|
|
1232
|
+
// src/lib/utils/texture-format-map.ts
|
|
1233
|
+
var WEBGL_TO_TEXTURE_FORMAT = {
|
|
1234
|
+
[GL_COMPRESSED_RGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-webgl",
|
|
1235
|
+
[GL_COMPRESSED_SRGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-srgb-webgl",
|
|
1236
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT1_EXT]: "bc1-rgba-unorm",
|
|
1237
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT]: "bc1-rgba-unorm-srgb",
|
|
1238
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT3_EXT]: "bc2-rgba-unorm",
|
|
1239
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT]: "bc2-rgba-unorm-srgb",
|
|
1240
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT5_EXT]: "bc3-rgba-unorm",
|
|
1241
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT]: "bc3-rgba-unorm-srgb",
|
|
1242
|
+
[GL_COMPRESSED_RED_RGTC1_EXT]: "bc4-r-unorm",
|
|
1243
|
+
[GL_COMPRESSED_SIGNED_RED_RGTC1_EXT]: "bc4-r-snorm",
|
|
1244
|
+
[GL_COMPRESSED_RED_GREEN_RGTC2_EXT]: "bc5-rg-unorm",
|
|
1245
|
+
[GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT]: "bc5-rg-snorm",
|
|
1246
|
+
[GL_COMPRESSED_RGB8_ETC2]: "etc2-rgb8unorm",
|
|
1247
|
+
[GL_COMPRESSED_SRGB8_ETC2]: "etc2-rgb8unorm-srgb",
|
|
1248
|
+
[GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2]: "etc2-rgb8a1unorm",
|
|
1249
|
+
[GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2]: "etc2-rgb8a1unorm-srgb",
|
|
1250
|
+
[GL_COMPRESSED_RGBA8_ETC2_EAC]: "etc2-rgba8unorm",
|
|
1251
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC]: "etc2-rgba8unorm-srgb",
|
|
1252
|
+
[GL_COMPRESSED_R11_EAC]: "eac-r11unorm",
|
|
1253
|
+
[GL_COMPRESSED_SIGNED_R11_EAC]: "eac-r11snorm",
|
|
1254
|
+
[GL_COMPRESSED_RG11_EAC]: "eac-rg11unorm",
|
|
1255
|
+
[GL_COMPRESSED_SIGNED_RG11_EAC]: "eac-rg11snorm",
|
|
1256
|
+
[GL_COMPRESSED_RGBA_ASTC_4x4_KHR]: "astc-4x4-unorm",
|
|
1257
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR]: "astc-4x4-unorm-srgb",
|
|
1258
|
+
[GL_COMPRESSED_RGBA_ASTC_5x4_KHR]: "astc-5x4-unorm",
|
|
1259
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR]: "astc-5x4-unorm-srgb",
|
|
1260
|
+
[GL_COMPRESSED_RGBA_ASTC_5x5_KHR]: "astc-5x5-unorm",
|
|
1261
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR]: "astc-5x5-unorm-srgb",
|
|
1262
|
+
[GL_COMPRESSED_RGBA_ASTC_6x5_KHR]: "astc-6x5-unorm",
|
|
1263
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR]: "astc-6x5-unorm-srgb",
|
|
1264
|
+
[GL_COMPRESSED_RGBA_ASTC_6x6_KHR]: "astc-6x6-unorm",
|
|
1265
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR]: "astc-6x6-unorm-srgb",
|
|
1266
|
+
[GL_COMPRESSED_RGBA_ASTC_8x5_KHR]: "astc-8x5-unorm",
|
|
1267
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR]: "astc-8x5-unorm-srgb",
|
|
1268
|
+
[GL_COMPRESSED_RGBA_ASTC_8x6_KHR]: "astc-8x6-unorm",
|
|
1269
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR]: "astc-8x6-unorm-srgb",
|
|
1270
|
+
[GL_COMPRESSED_RGBA_ASTC_8x8_KHR]: "astc-8x8-unorm",
|
|
1271
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR]: "astc-8x8-unorm-srgb",
|
|
1272
|
+
[GL_COMPRESSED_RGBA_ASTC_10x5_KHR]: "astc-10x5-unorm",
|
|
1273
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR]: "astc-10x5-unorm-srgb",
|
|
1274
|
+
[GL_COMPRESSED_RGBA_ASTC_10x6_KHR]: "astc-10x6-unorm",
|
|
1275
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR]: "astc-10x6-unorm-srgb",
|
|
1276
|
+
[GL_COMPRESSED_RGBA_ASTC_10x8_KHR]: "astc-10x8-unorm",
|
|
1277
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR]: "astc-10x8-unorm-srgb",
|
|
1278
|
+
[GL_COMPRESSED_RGBA_ASTC_10x10_KHR]: "astc-10x10-unorm",
|
|
1279
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR]: "astc-10x10-unorm-srgb",
|
|
1280
|
+
[GL_COMPRESSED_RGBA_ASTC_12x10_KHR]: "astc-12x10-unorm",
|
|
1281
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR]: "astc-12x10-unorm-srgb",
|
|
1282
|
+
[GL_COMPRESSED_RGBA_ASTC_12x12_KHR]: "astc-12x12-unorm",
|
|
1283
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]: "astc-12x12-unorm-srgb",
|
|
1284
|
+
[GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG]: "pvrtc-rgb4unorm-webgl",
|
|
1285
|
+
[GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]: "pvrtc-rgba4unorm-webgl",
|
|
1286
|
+
[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: "pvrtc-rbg2unorm-webgl",
|
|
1287
|
+
[GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]: "pvrtc-rgba2unorm-webgl",
|
|
1288
|
+
[GL_COMPRESSED_RGB_ETC1_WEBGL]: "etc1-rbg-unorm-webgl",
|
|
1289
|
+
[GL_COMPRESSED_RGB_ATC_WEBGL]: "atc-rgb-unorm-webgl",
|
|
1290
|
+
[GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]: "atc-rgba-unorm-webgl",
|
|
1291
|
+
[GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]: "atc-rgbai-unorm-webgl"
|
|
1292
|
+
};
|
|
1293
|
+
function getTextureFormatFromWebGLFormat(format) {
|
|
1294
|
+
if (format === void 0) {
|
|
1295
|
+
return void 0;
|
|
1296
|
+
}
|
|
1297
|
+
return WEBGL_TO_TEXTURE_FORMAT[format];
|
|
1298
|
+
}
|
|
1299
|
+
|
|
633
1300
|
// src/lib/utils/extract-mipmap-images.ts
|
|
634
1301
|
function extractMipmapImages(data, options) {
|
|
635
1302
|
const images = new Array(options.mipMapLevels);
|
|
1303
|
+
const format = options.internalFormat;
|
|
1304
|
+
const textureFormat = format === void 0 ? void 0 : getTextureFormatFromWebGLFormat(format);
|
|
636
1305
|
let levelWidth = options.width;
|
|
637
1306
|
let levelHeight = options.height;
|
|
638
1307
|
let offset = 0;
|
|
639
1308
|
for (let i = 0; i < options.mipMapLevels; ++i) {
|
|
640
1309
|
const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i);
|
|
641
1310
|
const levelData = getLevelData(data, i, offset, levelSize);
|
|
642
|
-
|
|
1311
|
+
const image = {
|
|
1312
|
+
shape: "texture-level",
|
|
643
1313
|
compressed: true,
|
|
644
|
-
format: options.internalFormat,
|
|
645
1314
|
data: levelData,
|
|
646
1315
|
width: levelWidth,
|
|
647
1316
|
height: levelHeight,
|
|
648
1317
|
levelSize
|
|
649
1318
|
};
|
|
1319
|
+
if (format !== void 0) {
|
|
1320
|
+
image.format = format;
|
|
1321
|
+
}
|
|
1322
|
+
if (textureFormat) {
|
|
1323
|
+
image.textureFormat = textureFormat;
|
|
1324
|
+
}
|
|
1325
|
+
images[i] = image;
|
|
650
1326
|
levelWidth = Math.max(1, levelWidth >> 1);
|
|
651
1327
|
levelHeight = Math.max(1, levelHeight >> 1);
|
|
652
1328
|
offset += levelSize;
|
|
@@ -666,186 +1342,74 @@
|
|
|
666
1342
|
return options.sizeFunction(data[index]);
|
|
667
1343
|
}
|
|
668
1344
|
|
|
669
|
-
// src/lib/gl-extensions.ts
|
|
670
|
-
var GL_EXTENSIONS_CONSTANTS = {
|
|
671
|
-
// WEBGL_compressed_texture_s3tc
|
|
672
|
-
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
|
|
673
|
-
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
|
|
674
|
-
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
|
|
675
|
-
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
|
|
676
|
-
// WEBGL_compressed_texture_es3
|
|
677
|
-
COMPRESSED_R11_EAC: 37488,
|
|
678
|
-
COMPRESSED_SIGNED_R11_EAC: 37489,
|
|
679
|
-
COMPRESSED_RG11_EAC: 37490,
|
|
680
|
-
COMPRESSED_SIGNED_RG11_EAC: 37491,
|
|
681
|
-
COMPRESSED_RGB8_ETC2: 37492,
|
|
682
|
-
COMPRESSED_RGBA8_ETC2_EAC: 37493,
|
|
683
|
-
COMPRESSED_SRGB8_ETC2: 37494,
|
|
684
|
-
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
685
|
-
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
686
|
-
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
687
|
-
// WEBGL_compressed_texture_pvrtc
|
|
688
|
-
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
689
|
-
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
690
|
-
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
691
|
-
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
692
|
-
// WEBGL_compressed_texture_etc1
|
|
693
|
-
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
694
|
-
// WEBGL_compressed_texture_atc
|
|
695
|
-
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
696
|
-
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
697
|
-
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
698
|
-
// WEBGL_compressed_texture_astc
|
|
699
|
-
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
700
|
-
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
701
|
-
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
702
|
-
COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
|
|
703
|
-
COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
|
|
704
|
-
COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
|
|
705
|
-
COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
|
|
706
|
-
COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
|
|
707
|
-
COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
|
|
708
|
-
COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
|
|
709
|
-
COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
|
|
710
|
-
COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
|
|
711
|
-
COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
|
|
712
|
-
COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
|
|
713
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
|
|
714
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
|
|
715
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
|
|
716
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
|
|
717
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
|
|
718
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
|
|
719
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
|
|
720
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
|
|
721
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
|
|
722
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
|
|
723
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
|
|
724
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
725
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
726
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
727
|
-
// EXT_texture_compression_rgtc
|
|
728
|
-
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
729
|
-
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
730
|
-
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
731
|
-
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
732
|
-
// WEBGL_compressed_texture_s3tc_srgb
|
|
733
|
-
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
734
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
735
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
736
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
|
|
737
|
-
};
|
|
738
|
-
|
|
739
1345
|
// src/lib/utils/ktx-format-helper.ts
|
|
740
1346
|
var VULKAN_TO_WEBGL_FORMAT_MAP = {
|
|
741
|
-
131:
|
|
742
|
-
132:
|
|
743
|
-
133:
|
|
744
|
-
134:
|
|
745
|
-
135:
|
|
746
|
-
136:
|
|
747
|
-
137:
|
|
748
|
-
138:
|
|
749
|
-
139:
|
|
750
|
-
140:
|
|
751
|
-
141:
|
|
752
|
-
142:
|
|
753
|
-
147:
|
|
754
|
-
148:
|
|
755
|
-
149:
|
|
756
|
-
150:
|
|
757
|
-
151:
|
|
758
|
-
152:
|
|
759
|
-
153:
|
|
760
|
-
154:
|
|
761
|
-
155:
|
|
762
|
-
156:
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
// @ts-ignore
|
|
808
|
-
179: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
809
|
-
// @ts-ignore
|
|
810
|
-
180: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
811
|
-
// @ts-ignore
|
|
812
|
-
181: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
813
|
-
// @ts-ignore
|
|
814
|
-
182: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
815
|
-
// @ts-ignore
|
|
816
|
-
183: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
817
|
-
// @ts-ignore
|
|
818
|
-
184: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
819
|
-
1000054e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
820
|
-
1000054001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
821
|
-
// @ts-ignore
|
|
822
|
-
1000066e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
823
|
-
// @ts-ignore
|
|
824
|
-
1000066001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
825
|
-
// @ts-ignore
|
|
826
|
-
1000066002: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
827
|
-
// @ts-ignore
|
|
828
|
-
1000066003: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
829
|
-
// @ts-ignore
|
|
830
|
-
1000066004: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
831
|
-
// @ts-ignore
|
|
832
|
-
1000066005: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
833
|
-
// @ts-ignore
|
|
834
|
-
1000066006: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
835
|
-
// @ts-ignore
|
|
836
|
-
1000066007: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
837
|
-
// @ts-ignore
|
|
838
|
-
1000066008: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
839
|
-
// @ts-ignore
|
|
840
|
-
1000066009: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
841
|
-
// @ts-ignore
|
|
842
|
-
1000066010: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
843
|
-
// @ts-ignore
|
|
844
|
-
1000066011: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
845
|
-
// @ts-ignore
|
|
846
|
-
1000066012: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
847
|
-
// @ts-ignore
|
|
848
|
-
1000066013: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR
|
|
1347
|
+
131: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
1348
|
+
132: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
1349
|
+
133: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
1350
|
+
134: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
1351
|
+
135: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
1352
|
+
136: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
1353
|
+
137: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
1354
|
+
138: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
1355
|
+
139: GL_COMPRESSED_RED_RGTC1_EXT,
|
|
1356
|
+
140: GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
1357
|
+
141: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
1358
|
+
142: GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
1359
|
+
147: GL_COMPRESSED_RGB8_ETC2,
|
|
1360
|
+
148: GL_COMPRESSED_SRGB8_ETC2,
|
|
1361
|
+
149: GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
1362
|
+
150: GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
1363
|
+
151: GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
1364
|
+
152: GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
1365
|
+
153: GL_COMPRESSED_R11_EAC,
|
|
1366
|
+
154: GL_COMPRESSED_SIGNED_R11_EAC,
|
|
1367
|
+
155: GL_COMPRESSED_RG11_EAC,
|
|
1368
|
+
156: GL_COMPRESSED_SIGNED_RG11_EAC,
|
|
1369
|
+
157: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
1370
|
+
158: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
1371
|
+
159: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
1372
|
+
160: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
1373
|
+
161: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
1374
|
+
162: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
1375
|
+
163: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
1376
|
+
164: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
1377
|
+
165: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
1378
|
+
166: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
1379
|
+
167: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
1380
|
+
168: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
1381
|
+
169: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
1382
|
+
170: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
1383
|
+
171: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
1384
|
+
172: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
1385
|
+
173: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
1386
|
+
174: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
1387
|
+
175: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
1388
|
+
176: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
1389
|
+
177: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
1390
|
+
178: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
1391
|
+
179: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
1392
|
+
180: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
1393
|
+
181: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
1394
|
+
182: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
1395
|
+
183: GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
1396
|
+
184: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
1397
|
+
1000054e3: GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
1398
|
+
1000054001: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
1399
|
+
1000066e3: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
1400
|
+
1000066001: GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
1401
|
+
1000066002: GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
1402
|
+
1000066003: GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
1403
|
+
1000066004: GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
1404
|
+
1000066005: GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
1405
|
+
1000066006: GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
1406
|
+
1000066007: GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
1407
|
+
1000066008: GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
1408
|
+
1000066009: GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
1409
|
+
1000066010: GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
1410
|
+
1000066011: GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
1411
|
+
1000066012: GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
1412
|
+
1000066013: GL_COMPRESSED_RGBA_ASTC_12x12_KHR
|
|
849
1413
|
};
|
|
850
1414
|
function mapVkFormatToWebGL(vkFormat) {
|
|
851
1415
|
return VULKAN_TO_WEBGL_FORMAT_MAP[vkFormat];
|
|
@@ -890,6 +1454,11 @@
|
|
|
890
1454
|
const width = ktx.pixelWidth;
|
|
891
1455
|
const height = ktx.pixelHeight;
|
|
892
1456
|
const internalFormat = mapVkFormatToWebGL(ktx.vkFormat);
|
|
1457
|
+
if (internalFormat === void 0) {
|
|
1458
|
+
log.warn(
|
|
1459
|
+
`KTX2 container vkFormat ${ktx.vkFormat} does not map to a known WebGL format; returning texture levels without format metadata.`
|
|
1460
|
+
)();
|
|
1461
|
+
}
|
|
893
1462
|
return extractMipmapImages(ktx.levels, {
|
|
894
1463
|
mipMapLevels,
|
|
895
1464
|
width,
|
|
@@ -915,12 +1484,12 @@
|
|
|
915
1484
|
DDPF_FOURCC: 4
|
|
916
1485
|
};
|
|
917
1486
|
var DDS_PIXEL_FORMATS = {
|
|
918
|
-
DXT1:
|
|
919
|
-
DXT3:
|
|
920
|
-
DXT5:
|
|
921
|
-
"ATC ":
|
|
922
|
-
ATCA:
|
|
923
|
-
ATCI:
|
|
1487
|
+
DXT1: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
1488
|
+
DXT3: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
1489
|
+
DXT5: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
1490
|
+
"ATC ": GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
1491
|
+
ATCA: GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,
|
|
1492
|
+
ATCI: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL
|
|
924
1493
|
};
|
|
925
1494
|
var getATCLevelSize = getDxt1LevelSize;
|
|
926
1495
|
var getATCALevelSize = getDxtXLevelSize;
|
|
@@ -995,75 +1564,33 @@
|
|
|
995
1564
|
METADATA_SIZE_INDEX: 12
|
|
996
1565
|
};
|
|
997
1566
|
var PVR_PIXEL_FORMATS = {
|
|
998
|
-
0: [
|
|
999
|
-
1: [
|
|
1000
|
-
2: [
|
|
1001
|
-
3: [
|
|
1002
|
-
6: [
|
|
1003
|
-
7: [
|
|
1004
|
-
9: [
|
|
1005
|
-
11: [
|
|
1006
|
-
22: [
|
|
1007
|
-
23: [
|
|
1008
|
-
24: [
|
|
1009
|
-
25: [
|
|
1010
|
-
26: [
|
|
1011
|
-
27: [
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
],
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
],
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
],
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR
|
|
1026
|
-
],
|
|
1027
|
-
31: [
|
|
1028
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6X6_KHR,
|
|
1029
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR
|
|
1030
|
-
],
|
|
1031
|
-
32: [
|
|
1032
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X5_KHR,
|
|
1033
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR
|
|
1034
|
-
],
|
|
1035
|
-
33: [
|
|
1036
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X6_KHR,
|
|
1037
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR
|
|
1038
|
-
],
|
|
1039
|
-
34: [
|
|
1040
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8X8_KHR,
|
|
1041
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR
|
|
1042
|
-
],
|
|
1043
|
-
35: [
|
|
1044
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X5_KHR,
|
|
1045
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR
|
|
1046
|
-
],
|
|
1047
|
-
36: [
|
|
1048
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X6_KHR,
|
|
1049
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR
|
|
1050
|
-
],
|
|
1051
|
-
37: [
|
|
1052
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X8_KHR,
|
|
1053
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR
|
|
1054
|
-
],
|
|
1055
|
-
38: [
|
|
1056
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10X10_KHR,
|
|
1057
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR
|
|
1058
|
-
],
|
|
1059
|
-
39: [
|
|
1060
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12X10_KHR,
|
|
1061
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR
|
|
1062
|
-
],
|
|
1063
|
-
40: [
|
|
1064
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12X12_KHR,
|
|
1065
|
-
GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR
|
|
1066
|
-
]
|
|
1567
|
+
0: [GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG],
|
|
1568
|
+
1: [GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG],
|
|
1569
|
+
2: [GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG],
|
|
1570
|
+
3: [GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG],
|
|
1571
|
+
6: [GL_COMPRESSED_RGB_ETC1_WEBGL],
|
|
1572
|
+
7: [GL_COMPRESSED_RGB_S3TC_DXT1_EXT],
|
|
1573
|
+
9: [GL_COMPRESSED_RGBA_S3TC_DXT3_EXT],
|
|
1574
|
+
11: [GL_COMPRESSED_RGBA_S3TC_DXT5_EXT],
|
|
1575
|
+
22: [GL_COMPRESSED_RGB8_ETC2],
|
|
1576
|
+
23: [GL_COMPRESSED_RGBA8_ETC2_EAC],
|
|
1577
|
+
24: [GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2],
|
|
1578
|
+
25: [GL_COMPRESSED_R11_EAC],
|
|
1579
|
+
26: [GL_COMPRESSED_RG11_EAC],
|
|
1580
|
+
27: [GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR],
|
|
1581
|
+
28: [GL_COMPRESSED_RGBA_ASTC_5x4_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR],
|
|
1582
|
+
29: [GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR],
|
|
1583
|
+
30: [GL_COMPRESSED_RGBA_ASTC_6x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR],
|
|
1584
|
+
31: [GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR],
|
|
1585
|
+
32: [GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR],
|
|
1586
|
+
33: [GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR],
|
|
1587
|
+
34: [GL_COMPRESSED_RGBA_ASTC_8x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR],
|
|
1588
|
+
35: [GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR],
|
|
1589
|
+
36: [GL_COMPRESSED_RGBA_ASTC_10x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR],
|
|
1590
|
+
37: [GL_COMPRESSED_RGBA_ASTC_10x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR],
|
|
1591
|
+
38: [GL_COMPRESSED_RGBA_ASTC_10x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR],
|
|
1592
|
+
39: [GL_COMPRESSED_RGBA_ASTC_12x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR],
|
|
1593
|
+
40: [GL_COMPRESSED_RGBA_ASTC_12x12_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]
|
|
1067
1594
|
};
|
|
1068
1595
|
var PVR_SIZE_FUNCTIONS = {
|
|
1069
1596
|
0: pvrtc2bppSize,
|
|
@@ -1096,8 +1623,8 @@
|
|
|
1096
1623
|
};
|
|
1097
1624
|
function isPVR(data) {
|
|
1098
1625
|
const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH);
|
|
1099
|
-
const
|
|
1100
|
-
return
|
|
1626
|
+
const version2 = header[PVR_CONSTANTS.MAGIC_NUMBER_INDEX];
|
|
1627
|
+
return version2 === PVR_CONSTANTS.MAGIC_NUMBER || version2 === PVR_CONSTANTS.MAGIC_NUMBER_EXTRA;
|
|
1101
1628
|
}
|
|
1102
1629
|
function parsePVR(data) {
|
|
1103
1630
|
const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH);
|
|
@@ -1266,35 +1793,101 @@
|
|
|
1266
1793
|
});
|
|
1267
1794
|
}
|
|
1268
1795
|
|
|
1269
|
-
// src/lib/utils/texture-formats.ts
|
|
1796
|
+
// src/lib/utils/detect-supported-texture-formats.ts
|
|
1270
1797
|
var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
1271
|
-
var
|
|
1798
|
+
var WEBGL_TEXTURE_FORMATS = {
|
|
1272
1799
|
/* eslint-disable camelcase */
|
|
1273
|
-
WEBGL_compressed_texture_s3tc:
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1800
|
+
WEBGL_compressed_texture_s3tc: [
|
|
1801
|
+
"bc1-rgb-unorm-webgl",
|
|
1802
|
+
"bc1-rgba-unorm",
|
|
1803
|
+
"bc2-rgba-unorm",
|
|
1804
|
+
"bc3-rgba-unorm"
|
|
1805
|
+
],
|
|
1806
|
+
WEBGL_compressed_texture_s3tc_srgb: [
|
|
1807
|
+
"bc1-rgb-unorm-srgb-webgl",
|
|
1808
|
+
"bc1-rgba-unorm-srgb",
|
|
1809
|
+
"bc2-rgba-unorm-srgb",
|
|
1810
|
+
"bc3-rgba-unorm-srgb"
|
|
1811
|
+
],
|
|
1812
|
+
EXT_texture_compression_rgtc: ["bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm"],
|
|
1813
|
+
EXT_texture_compression_bptc: [
|
|
1814
|
+
"bc6h-rgb-ufloat",
|
|
1815
|
+
"bc6h-rgb-float",
|
|
1816
|
+
"bc7-rgba-unorm",
|
|
1817
|
+
"bc7-rgba-unorm-srgb"
|
|
1818
|
+
],
|
|
1819
|
+
WEBGL_compressed_texture_etc1: ["etc1-rbg-unorm-webgl"],
|
|
1820
|
+
WEBGL_compressed_texture_etc: [
|
|
1821
|
+
"etc2-rgb8unorm",
|
|
1822
|
+
"etc2-rgb8unorm-srgb",
|
|
1823
|
+
"etc2-rgb8a1unorm",
|
|
1824
|
+
"etc2-rgb8a1unorm-srgb",
|
|
1825
|
+
"etc2-rgba8unorm",
|
|
1826
|
+
"etc2-rgba8unorm-srgb",
|
|
1827
|
+
"eac-r11unorm",
|
|
1828
|
+
"eac-r11snorm",
|
|
1829
|
+
"eac-rg11unorm",
|
|
1830
|
+
"eac-rg11snorm"
|
|
1831
|
+
],
|
|
1832
|
+
WEBGL_compressed_texture_pvrtc: [
|
|
1833
|
+
"pvrtc-rgb4unorm-webgl",
|
|
1834
|
+
"pvrtc-rgba4unorm-webgl",
|
|
1835
|
+
"pvrtc-rbg2unorm-webgl",
|
|
1836
|
+
"pvrtc-rgba2unorm-webgl"
|
|
1837
|
+
],
|
|
1838
|
+
WEBGL_compressed_texture_atc: [
|
|
1839
|
+
"atc-rgb-unorm-webgl",
|
|
1840
|
+
"atc-rgba-unorm-webgl",
|
|
1841
|
+
"atc-rgbai-unorm-webgl"
|
|
1842
|
+
],
|
|
1843
|
+
WEBGL_compressed_texture_astc: [
|
|
1844
|
+
"astc-4x4-unorm",
|
|
1845
|
+
"astc-4x4-unorm-srgb",
|
|
1846
|
+
"astc-5x4-unorm",
|
|
1847
|
+
"astc-5x4-unorm-srgb",
|
|
1848
|
+
"astc-5x5-unorm",
|
|
1849
|
+
"astc-5x5-unorm-srgb",
|
|
1850
|
+
"astc-6x5-unorm",
|
|
1851
|
+
"astc-6x5-unorm-srgb",
|
|
1852
|
+
"astc-6x6-unorm",
|
|
1853
|
+
"astc-6x6-unorm-srgb",
|
|
1854
|
+
"astc-8x5-unorm",
|
|
1855
|
+
"astc-8x5-unorm-srgb",
|
|
1856
|
+
"astc-8x6-unorm",
|
|
1857
|
+
"astc-8x6-unorm-srgb",
|
|
1858
|
+
"astc-8x8-unorm",
|
|
1859
|
+
"astc-8x8-unorm-srgb",
|
|
1860
|
+
"astc-10x5-unorm",
|
|
1861
|
+
"astc-10x5-unorm-srgb",
|
|
1862
|
+
"astc-10x6-unorm",
|
|
1863
|
+
"astc-10x6-unorm-srgb",
|
|
1864
|
+
"astc-10x8-unorm",
|
|
1865
|
+
"astc-10x8-unorm-srgb",
|
|
1866
|
+
"astc-10x10-unorm",
|
|
1867
|
+
"astc-10x10-unorm-srgb",
|
|
1868
|
+
"astc-12x10-unorm",
|
|
1869
|
+
"astc-12x10-unorm-srgb",
|
|
1870
|
+
"astc-12x12-unorm",
|
|
1871
|
+
"astc-12x12-unorm-srgb"
|
|
1872
|
+
]
|
|
1281
1873
|
/* eslint-enable camelcase */
|
|
1282
1874
|
};
|
|
1283
|
-
var
|
|
1284
|
-
function
|
|
1285
|
-
if (!
|
|
1875
|
+
var textureFormats = null;
|
|
1876
|
+
function detectSupportedTextureFormats(gl) {
|
|
1877
|
+
if (!textureFormats) {
|
|
1286
1878
|
gl = gl || getWebGLContext() || void 0;
|
|
1287
|
-
|
|
1879
|
+
textureFormats = /* @__PURE__ */ new Set();
|
|
1288
1880
|
for (const prefix of BROWSER_PREFIXES) {
|
|
1289
|
-
for (const extension in
|
|
1881
|
+
for (const extension in WEBGL_TEXTURE_FORMATS) {
|
|
1290
1882
|
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1883
|
+
for (const textureFormat of WEBGL_TEXTURE_FORMATS[extension]) {
|
|
1884
|
+
textureFormats.add(textureFormat);
|
|
1885
|
+
}
|
|
1293
1886
|
}
|
|
1294
1887
|
}
|
|
1295
1888
|
}
|
|
1296
1889
|
}
|
|
1297
|
-
return
|
|
1890
|
+
return textureFormats;
|
|
1298
1891
|
}
|
|
1299
1892
|
function getWebGLContext() {
|
|
1300
1893
|
try {
|
|
@@ -1306,49 +1899,113 @@
|
|
|
1306
1899
|
}
|
|
1307
1900
|
|
|
1308
1901
|
// src/lib/parsers/parse-basis.ts
|
|
1309
|
-
var
|
|
1902
|
+
var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
|
|
1310
1903
|
etc1: {
|
|
1311
1904
|
basisFormat: 0,
|
|
1312
1905
|
compressed: true,
|
|
1313
|
-
format:
|
|
1906
|
+
format: GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
1907
|
+
textureFormat: "etc1-rbg-unorm-webgl"
|
|
1908
|
+
},
|
|
1909
|
+
etc2: {
|
|
1910
|
+
basisFormat: 1,
|
|
1911
|
+
compressed: true,
|
|
1912
|
+
format: GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
1913
|
+
textureFormat: "etc2-rgba8unorm"
|
|
1314
1914
|
},
|
|
1315
|
-
etc2: { basisFormat: 1, compressed: true },
|
|
1316
1915
|
bc1: {
|
|
1317
1916
|
basisFormat: 2,
|
|
1318
1917
|
compressed: true,
|
|
1319
|
-
format:
|
|
1918
|
+
format: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
1919
|
+
textureFormat: "bc1-rgb-unorm-webgl"
|
|
1320
1920
|
},
|
|
1321
1921
|
bc3: {
|
|
1322
1922
|
basisFormat: 3,
|
|
1323
1923
|
compressed: true,
|
|
1324
|
-
format:
|
|
1924
|
+
format: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
1925
|
+
textureFormat: "bc3-rgba-unorm"
|
|
1926
|
+
},
|
|
1927
|
+
bc4: {
|
|
1928
|
+
basisFormat: 4,
|
|
1929
|
+
compressed: true,
|
|
1930
|
+
format: GL_COMPRESSED_RED_RGTC1_EXT,
|
|
1931
|
+
textureFormat: "bc4-r-unorm"
|
|
1932
|
+
},
|
|
1933
|
+
bc5: {
|
|
1934
|
+
basisFormat: 5,
|
|
1935
|
+
compressed: true,
|
|
1936
|
+
format: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
1937
|
+
textureFormat: "bc5-rg-unorm"
|
|
1938
|
+
},
|
|
1939
|
+
"bc7-m6-opaque-only": {
|
|
1940
|
+
basisFormat: 6,
|
|
1941
|
+
compressed: true,
|
|
1942
|
+
format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
1943
|
+
textureFormat: "bc7-rgba-unorm"
|
|
1944
|
+
},
|
|
1945
|
+
"bc7-m5": {
|
|
1946
|
+
basisFormat: 7,
|
|
1947
|
+
compressed: true,
|
|
1948
|
+
format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
1949
|
+
textureFormat: "bc7-rgba-unorm"
|
|
1325
1950
|
},
|
|
1326
|
-
bc4: { basisFormat: 4, compressed: true },
|
|
1327
|
-
bc5: { basisFormat: 5, compressed: true },
|
|
1328
|
-
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
1329
|
-
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
1330
1951
|
"pvrtc1-4-rgb": {
|
|
1331
1952
|
basisFormat: 8,
|
|
1332
1953
|
compressed: true,
|
|
1333
|
-
format:
|
|
1954
|
+
format: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
1955
|
+
textureFormat: "pvrtc-rgb4unorm-webgl"
|
|
1334
1956
|
},
|
|
1335
1957
|
"pvrtc1-4-rgba": {
|
|
1336
1958
|
basisFormat: 9,
|
|
1337
1959
|
compressed: true,
|
|
1338
|
-
format:
|
|
1960
|
+
format: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
1961
|
+
textureFormat: "pvrtc-rgba4unorm-webgl"
|
|
1339
1962
|
},
|
|
1340
1963
|
"astc-4x4": {
|
|
1341
1964
|
basisFormat: 10,
|
|
1342
1965
|
compressed: true,
|
|
1343
|
-
format:
|
|
1966
|
+
format: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
1967
|
+
textureFormat: "astc-4x4-unorm"
|
|
1968
|
+
},
|
|
1969
|
+
"atc-rgb": {
|
|
1970
|
+
basisFormat: 11,
|
|
1971
|
+
compressed: true,
|
|
1972
|
+
format: GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
1973
|
+
textureFormat: "atc-rgb-unorm-webgl"
|
|
1974
|
+
},
|
|
1975
|
+
"atc-rgba-interpolated-alpha": {
|
|
1976
|
+
basisFormat: 12,
|
|
1977
|
+
compressed: true,
|
|
1978
|
+
format: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
|
|
1979
|
+
textureFormat: "atc-rgbai-unorm-webgl"
|
|
1980
|
+
},
|
|
1981
|
+
rgba32: {
|
|
1982
|
+
basisFormat: 13,
|
|
1983
|
+
compressed: false,
|
|
1984
|
+
format: GL_RGBA8,
|
|
1985
|
+
textureFormat: "rgba8unorm"
|
|
1986
|
+
},
|
|
1987
|
+
rgb565: {
|
|
1988
|
+
basisFormat: 14,
|
|
1989
|
+
compressed: false,
|
|
1990
|
+
format: GL_RGB565,
|
|
1991
|
+
textureFormat: "rgb565unorm-webgl"
|
|
1344
1992
|
},
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1993
|
+
bgr565: {
|
|
1994
|
+
basisFormat: 15,
|
|
1995
|
+
compressed: false,
|
|
1996
|
+
format: GL_RGB565,
|
|
1997
|
+
textureFormat: "rgb565unorm-webgl"
|
|
1998
|
+
},
|
|
1999
|
+
rgba4444: {
|
|
2000
|
+
basisFormat: 16,
|
|
2001
|
+
compressed: false,
|
|
2002
|
+
format: GL_RGBA4,
|
|
2003
|
+
textureFormat: "rgba4unorm-webgl"
|
|
2004
|
+
}
|
|
1351
2005
|
};
|
|
2006
|
+
var BASIS_FORMATS = Object.freeze(
|
|
2007
|
+
Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS)
|
|
2008
|
+
);
|
|
1352
2009
|
async function parseBasis(data, options = {}) {
|
|
1353
2010
|
if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
|
|
1354
2011
|
if (isKTX(data)) {
|
|
@@ -1402,7 +2059,7 @@
|
|
|
1402
2059
|
const hasAlpha = basisFile.getHasAlpha(
|
|
1403
2060
|
/* imageIndex, levelIndex */
|
|
1404
2061
|
);
|
|
1405
|
-
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
2062
|
+
const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, hasAlpha);
|
|
1406
2063
|
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
1407
2064
|
const decodedData = new Uint8Array(decodedSize);
|
|
1408
2065
|
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
@@ -1410,11 +2067,13 @@
|
|
|
1410
2067
|
}
|
|
1411
2068
|
return {
|
|
1412
2069
|
// standard loaders.gl image category payload
|
|
2070
|
+
shape: "texture-level",
|
|
1413
2071
|
width,
|
|
1414
2072
|
height,
|
|
1415
2073
|
data: decodedData,
|
|
1416
2074
|
compressed,
|
|
1417
|
-
format,
|
|
2075
|
+
...format !== void 0 ? { format } : {},
|
|
2076
|
+
...textureFormat !== void 0 ? { textureFormat } : {},
|
|
1418
2077
|
// Additional fields
|
|
1419
2078
|
// Add levelSize field.
|
|
1420
2079
|
hasAlpha
|
|
@@ -1439,7 +2098,7 @@
|
|
|
1439
2098
|
}
|
|
1440
2099
|
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
1441
2100
|
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
1442
|
-
const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
|
|
2101
|
+
const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, alphaFlag);
|
|
1443
2102
|
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(
|
|
1444
2103
|
levelIndex,
|
|
1445
2104
|
0,
|
|
@@ -1462,48 +2121,98 @@
|
|
|
1462
2121
|
}
|
|
1463
2122
|
return {
|
|
1464
2123
|
// standard loaders.gl image category payload
|
|
2124
|
+
shape: "texture-level",
|
|
1465
2125
|
width,
|
|
1466
2126
|
height,
|
|
1467
2127
|
data: decodedData,
|
|
1468
2128
|
compressed,
|
|
2129
|
+
...format !== void 0 ? { format } : {},
|
|
2130
|
+
...textureFormat !== void 0 ? { textureFormat } : {},
|
|
1469
2131
|
// Additional fields
|
|
1470
2132
|
levelSize: decodedSize,
|
|
1471
|
-
hasAlpha: alphaFlag
|
|
1472
|
-
format
|
|
2133
|
+
hasAlpha: alphaFlag
|
|
1473
2134
|
};
|
|
1474
2135
|
}
|
|
1475
2136
|
function getBasisOptions(options, hasAlpha) {
|
|
1476
|
-
let format = options.basis?.format;
|
|
2137
|
+
let format = options.basis?.format || "auto";
|
|
1477
2138
|
if (format === "auto") {
|
|
1478
|
-
format = selectSupportedBasisFormat();
|
|
2139
|
+
format = options.basis?.supportedTextureFormats ? selectSupportedBasisFormat(options.basis.supportedTextureFormats) : selectSupportedBasisFormat();
|
|
1479
2140
|
}
|
|
1480
2141
|
if (typeof format === "object") {
|
|
1481
2142
|
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
1482
2143
|
}
|
|
1483
|
-
|
|
1484
|
-
|
|
2144
|
+
const normalizedFormat = format.toLowerCase();
|
|
2145
|
+
const basisOutputOptions = BASIS_FORMAT_TO_OUTPUT_OPTIONS[normalizedFormat];
|
|
2146
|
+
if (!basisOutputOptions) {
|
|
2147
|
+
throw new Error(`Unknown Basis format ${format}`);
|
|
2148
|
+
}
|
|
2149
|
+
return basisOutputOptions;
|
|
1485
2150
|
}
|
|
1486
|
-
function selectSupportedBasisFormat() {
|
|
1487
|
-
const
|
|
1488
|
-
if (
|
|
2151
|
+
function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTextureFormats()) {
|
|
2152
|
+
const textureFormats2 = new Set(supportedTextureFormats);
|
|
2153
|
+
if (hasSupportedTextureFormat(textureFormats2, ["astc-4x4-unorm", "astc-4x4-unorm-srgb"])) {
|
|
1489
2154
|
return "astc-4x4";
|
|
1490
|
-
} else if (
|
|
2155
|
+
} else if (hasSupportedTextureFormat(textureFormats2, ["bc7-rgba-unorm", "bc7-rgba-unorm-srgb"])) {
|
|
2156
|
+
return {
|
|
2157
|
+
alpha: "bc7-m5",
|
|
2158
|
+
noAlpha: "bc7-m6-opaque-only"
|
|
2159
|
+
};
|
|
2160
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
2161
|
+
"bc1-rgb-unorm-webgl",
|
|
2162
|
+
"bc1-rgb-unorm-srgb-webgl",
|
|
2163
|
+
"bc1-rgba-unorm",
|
|
2164
|
+
"bc1-rgba-unorm-srgb",
|
|
2165
|
+
"bc2-rgba-unorm",
|
|
2166
|
+
"bc2-rgba-unorm-srgb",
|
|
2167
|
+
"bc3-rgba-unorm",
|
|
2168
|
+
"bc3-rgba-unorm-srgb"
|
|
2169
|
+
])) {
|
|
1491
2170
|
return {
|
|
1492
2171
|
alpha: "bc3",
|
|
1493
2172
|
noAlpha: "bc1"
|
|
1494
2173
|
};
|
|
1495
|
-
} else if (
|
|
2174
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
2175
|
+
"pvrtc-rgb4unorm-webgl",
|
|
2176
|
+
"pvrtc-rgba4unorm-webgl",
|
|
2177
|
+
"pvrtc-rbg2unorm-webgl",
|
|
2178
|
+
"pvrtc-rgba2unorm-webgl"
|
|
2179
|
+
])) {
|
|
1496
2180
|
return {
|
|
1497
2181
|
alpha: "pvrtc1-4-rgba",
|
|
1498
2182
|
noAlpha: "pvrtc1-4-rgb"
|
|
1499
2183
|
};
|
|
1500
|
-
} else if (
|
|
1501
|
-
|
|
1502
|
-
|
|
2184
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
2185
|
+
"etc2-rgb8unorm",
|
|
2186
|
+
"etc2-rgb8unorm-srgb",
|
|
2187
|
+
"etc2-rgb8a1unorm",
|
|
2188
|
+
"etc2-rgb8a1unorm-srgb",
|
|
2189
|
+
"etc2-rgba8unorm",
|
|
2190
|
+
"etc2-rgba8unorm-srgb",
|
|
2191
|
+
"eac-r11unorm",
|
|
2192
|
+
"eac-r11snorm",
|
|
2193
|
+
"eac-rg11unorm",
|
|
2194
|
+
"eac-rg11snorm"
|
|
2195
|
+
])) {
|
|
1503
2196
|
return "etc2";
|
|
2197
|
+
} else if (textureFormats2.has("etc1-rbg-unorm-webgl")) {
|
|
2198
|
+
return "etc1";
|
|
2199
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
2200
|
+
"atc-rgb-unorm-webgl",
|
|
2201
|
+
"atc-rgba-unorm-webgl",
|
|
2202
|
+
"atc-rgbai-unorm-webgl"
|
|
2203
|
+
])) {
|
|
2204
|
+
return {
|
|
2205
|
+
alpha: "atc-rgba-interpolated-alpha",
|
|
2206
|
+
noAlpha: "atc-rgb"
|
|
2207
|
+
};
|
|
1504
2208
|
}
|
|
1505
2209
|
return "rgb565";
|
|
1506
2210
|
}
|
|
2211
|
+
function hasSupportedTextureFormat(supportedTextureFormats, candidateTextureFormats) {
|
|
2212
|
+
return candidateTextureFormats.some(
|
|
2213
|
+
(textureFormat) => supportedTextureFormats.has(textureFormat)
|
|
2214
|
+
);
|
|
2215
|
+
}
|
|
1507
2216
|
|
|
1508
2217
|
// src/compressed-texture-loader.ts
|
|
1509
2218
|
var CompressedTextureWorkerLoader = {
|
|
@@ -1512,7 +2221,7 @@
|
|
|
1512
2221
|
name: "Texture Containers",
|
|
1513
2222
|
id: "compressed-texture",
|
|
1514
2223
|
module: "textures",
|
|
1515
|
-
version:
|
|
2224
|
+
version: VERSION4,
|
|
1516
2225
|
worker: true,
|
|
1517
2226
|
extensions: [
|
|
1518
2227
|
"ktx",
|