@loaders.gl/3d-tiles 4.0.0-alpha.6 → 4.0.0-alpha.7
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/dist/dist.min.js +1462 -1354
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +7 -5
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js +4 -4
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +5 -3
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-header.js +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/tiles-3d-loader.js +60 -56
- package/dist/es5/tiles-3d-loader.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +4 -2
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +4 -2
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-header.js +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/tiles-3d-loader.js +26 -28
- package/dist/esm/tiles-3d-loader.js.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +3 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +1 -1
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts +6 -1
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-composite.js +0 -2
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +3 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.js +3 -1
- package/dist/lib/parsers/parse-3d-tile-header.d.ts +2 -1
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-header.js +1 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +3 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +4 -2
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.js +1 -0
- package/dist/tiles-3d-loader.d.ts +15 -1
- package/dist/tiles-3d-loader.d.ts.map +1 -1
- package/dist/tiles-3d-loader.js +34 -32
- package/package.json +8 -8
- package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +4 -2
- package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +1 -1
- package/src/lib/parsers/parse-3d-tile-composite.ts +17 -6
- package/src/lib/parsers/parse-3d-tile-gltf.ts +12 -3
- package/src/lib/parsers/parse-3d-tile-header.ts +3 -2
- package/src/lib/parsers/parse-3d-tile-instanced-model.ts +17 -3
- package/src/lib/parsers/parse-3d-tile-point-cloud.ts +37 -10
- package/src/tiles-3d-loader.ts +65 -33
package/dist/dist.min.js
CHANGED
|
@@ -417,7 +417,7 @@
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
returnWorkerToQueue(worker) {
|
|
420
|
-
const shouldDestroyWorker = this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
|
|
420
|
+
const shouldDestroyWorker = !isBrowser2 || this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
|
|
421
421
|
if (shouldDestroyWorker) {
|
|
422
422
|
worker.destroy();
|
|
423
423
|
this.count--;
|
|
@@ -515,7 +515,7 @@
|
|
|
515
515
|
// ../worker-utils/src/lib/worker-api/get-worker-url.ts
|
|
516
516
|
function getWorkerURL(worker, options = {}) {
|
|
517
517
|
const workerOptions = options[worker.id] || {};
|
|
518
|
-
const workerFile = `${worker.id}-worker.js`;
|
|
518
|
+
const workerFile = isBrowser2 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
|
|
519
519
|
let url = workerOptions.workerUrl;
|
|
520
520
|
if (!url && worker.id === "compression") {
|
|
521
521
|
url = options.workerUrl;
|
|
@@ -538,6 +538,7 @@
|
|
|
538
538
|
var init_get_worker_url = __esm({
|
|
539
539
|
"../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
|
|
540
540
|
init_assert2();
|
|
541
|
+
init_globals2();
|
|
541
542
|
NPM_TAG = "beta";
|
|
542
543
|
}
|
|
543
544
|
});
|
|
@@ -5341,39 +5342,60 @@
|
|
|
5341
5342
|
}
|
|
5342
5343
|
});
|
|
5343
5344
|
|
|
5345
|
+
// ../core/src/lib/utils/url-utils.ts
|
|
5346
|
+
function extractQueryString(url) {
|
|
5347
|
+
const matches3 = url.match(QUERY_STRING_PATTERN);
|
|
5348
|
+
return matches3 && matches3[0];
|
|
5349
|
+
}
|
|
5350
|
+
function stripQueryString(url) {
|
|
5351
|
+
return url.replace(QUERY_STRING_PATTERN, "");
|
|
5352
|
+
}
|
|
5353
|
+
var QUERY_STRING_PATTERN;
|
|
5354
|
+
var init_url_utils = __esm({
|
|
5355
|
+
"../core/src/lib/utils/url-utils.ts"() {
|
|
5356
|
+
QUERY_STRING_PATTERN = /\?.*/;
|
|
5357
|
+
}
|
|
5358
|
+
});
|
|
5359
|
+
|
|
5344
5360
|
// ../core/src/lib/utils/resource-utils.ts
|
|
5345
|
-
function
|
|
5361
|
+
function getResourceUrl(resource) {
|
|
5346
5362
|
if (isResponse(resource)) {
|
|
5347
|
-
const
|
|
5348
|
-
|
|
5349
|
-
return {
|
|
5350
|
-
url,
|
|
5351
|
-
type: parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(url)
|
|
5352
|
-
};
|
|
5363
|
+
const response = resource;
|
|
5364
|
+
return response.url;
|
|
5353
5365
|
}
|
|
5354
5366
|
if (isBlob(resource)) {
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
type: resource.type || ""
|
|
5358
|
-
};
|
|
5367
|
+
const blob = resource;
|
|
5368
|
+
return blob.name || "";
|
|
5359
5369
|
}
|
|
5360
5370
|
if (typeof resource === "string") {
|
|
5361
|
-
return
|
|
5362
|
-
url: stripQueryString(resource),
|
|
5363
|
-
type: parseMIMETypeFromURL(resource)
|
|
5364
|
-
};
|
|
5371
|
+
return resource;
|
|
5365
5372
|
}
|
|
5366
|
-
return
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5373
|
+
return "";
|
|
5374
|
+
}
|
|
5375
|
+
function getResourceMIMEType(resource) {
|
|
5376
|
+
if (isResponse(resource)) {
|
|
5377
|
+
const response = resource;
|
|
5378
|
+
const contentTypeHeader = response.headers.get("content-type") || "";
|
|
5379
|
+
const noQueryUrl = stripQueryString(response.url);
|
|
5380
|
+
return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);
|
|
5381
|
+
}
|
|
5382
|
+
if (isBlob(resource)) {
|
|
5383
|
+
const blob = resource;
|
|
5384
|
+
return blob.type || "";
|
|
5385
|
+
}
|
|
5386
|
+
if (typeof resource === "string") {
|
|
5387
|
+
return parseMIMETypeFromURL(resource);
|
|
5388
|
+
}
|
|
5389
|
+
return "";
|
|
5370
5390
|
}
|
|
5371
5391
|
function getResourceContentLength(resource) {
|
|
5372
5392
|
if (isResponse(resource)) {
|
|
5373
|
-
|
|
5393
|
+
const response = resource;
|
|
5394
|
+
return response.headers["content-length"] || -1;
|
|
5374
5395
|
}
|
|
5375
5396
|
if (isBlob(resource)) {
|
|
5376
|
-
|
|
5397
|
+
const blob = resource;
|
|
5398
|
+
return blob.size;
|
|
5377
5399
|
}
|
|
5378
5400
|
if (typeof resource === "string") {
|
|
5379
5401
|
return resource.length;
|
|
@@ -5386,15 +5408,11 @@
|
|
|
5386
5408
|
}
|
|
5387
5409
|
return -1;
|
|
5388
5410
|
}
|
|
5389
|
-
function stripQueryString(url) {
|
|
5390
|
-
return url.replace(QUERY_STRING_PATTERN, "");
|
|
5391
|
-
}
|
|
5392
|
-
var QUERY_STRING_PATTERN;
|
|
5393
5411
|
var init_resource_utils = __esm({
|
|
5394
5412
|
"../core/src/lib/utils/resource-utils.ts"() {
|
|
5395
5413
|
init_is_type();
|
|
5396
5414
|
init_mime_type_utils();
|
|
5397
|
-
|
|
5415
|
+
init_url_utils();
|
|
5398
5416
|
}
|
|
5399
5417
|
});
|
|
5400
5418
|
|
|
@@ -5408,7 +5426,8 @@
|
|
|
5408
5426
|
if (contentLength >= 0) {
|
|
5409
5427
|
headers["content-length"] = String(contentLength);
|
|
5410
5428
|
}
|
|
5411
|
-
const
|
|
5429
|
+
const url = getResourceUrl(resource);
|
|
5430
|
+
const type = getResourceMIMEType(resource);
|
|
5412
5431
|
if (type) {
|
|
5413
5432
|
headers["content-type"] = type;
|
|
5414
5433
|
}
|
|
@@ -5497,7 +5516,7 @@
|
|
|
5497
5516
|
}
|
|
5498
5517
|
});
|
|
5499
5518
|
|
|
5500
|
-
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
5519
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
5501
5520
|
function isElectron(mockUserAgent) {
|
|
5502
5521
|
if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
|
|
5503
5522
|
return true;
|
|
@@ -5513,25 +5532,25 @@
|
|
|
5513
5532
|
return false;
|
|
5514
5533
|
}
|
|
5515
5534
|
var init_is_electron = __esm({
|
|
5516
|
-
"../../node_modules/@probe.gl/env/dist/lib/is-electron.js"() {
|
|
5535
|
+
"../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js"() {
|
|
5517
5536
|
}
|
|
5518
5537
|
});
|
|
5519
5538
|
|
|
5520
|
-
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
5539
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
5521
5540
|
function isBrowser3() {
|
|
5522
5541
|
const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
|
|
5523
5542
|
return !isNode || isElectron();
|
|
5524
5543
|
}
|
|
5525
5544
|
var init_is_browser = __esm({
|
|
5526
|
-
"../../node_modules/@probe.gl/env/dist/lib/is-browser.js"() {
|
|
5545
|
+
"../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js"() {
|
|
5527
5546
|
init_is_electron();
|
|
5528
5547
|
}
|
|
5529
5548
|
});
|
|
5530
5549
|
|
|
5531
|
-
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
5550
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
|
|
5532
5551
|
var self_3, window_3, document_3, process_, console_, navigator_;
|
|
5533
5552
|
var init_globals3 = __esm({
|
|
5534
|
-
"../../node_modules/@probe.gl/env/dist/lib/globals.js"() {
|
|
5553
|
+
"../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js"() {
|
|
5535
5554
|
self_3 = globalThis.self || globalThis.window || globalThis.global;
|
|
5536
5555
|
window_3 = globalThis.window || globalThis.self || globalThis.global;
|
|
5537
5556
|
document_3 = globalThis.document || {};
|
|
@@ -5541,19 +5560,19 @@
|
|
|
5541
5560
|
}
|
|
5542
5561
|
});
|
|
5543
5562
|
|
|
5544
|
-
// ../../node_modules/@probe.gl/env/dist/utils/globals.js
|
|
5563
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
|
|
5545
5564
|
var VERSION3, isBrowser4;
|
|
5546
5565
|
var init_globals4 = __esm({
|
|
5547
|
-
"../../node_modules/@probe.gl/env/dist/utils/globals.js"() {
|
|
5566
|
+
"../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js"() {
|
|
5548
5567
|
init_is_browser();
|
|
5549
5568
|
VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
|
|
5550
5569
|
isBrowser4 = isBrowser3();
|
|
5551
5570
|
}
|
|
5552
5571
|
});
|
|
5553
5572
|
|
|
5554
|
-
// ../../node_modules/@probe.gl/env/dist/index.js
|
|
5573
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/index.js
|
|
5555
5574
|
var init_dist = __esm({
|
|
5556
|
-
"../../node_modules/@probe.gl/env/dist/index.js"() {
|
|
5575
|
+
"../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/index.js"() {
|
|
5557
5576
|
init_globals4();
|
|
5558
5577
|
init_globals3();
|
|
5559
5578
|
init_is_browser();
|
|
@@ -6394,8 +6413,9 @@
|
|
|
6394
6413
|
return loader;
|
|
6395
6414
|
}
|
|
6396
6415
|
function selectLoaderInternal(data, loaders, options, context) {
|
|
6397
|
-
const
|
|
6398
|
-
const
|
|
6416
|
+
const url = getResourceUrl(data);
|
|
6417
|
+
const type = getResourceMIMEType(data);
|
|
6418
|
+
const testUrl = stripQueryString(url) || context?.url;
|
|
6399
6419
|
let loader = null;
|
|
6400
6420
|
let reason = "";
|
|
6401
6421
|
if (options?.mimeType) {
|
|
@@ -6424,7 +6444,8 @@
|
|
|
6424
6444
|
return true;
|
|
6425
6445
|
}
|
|
6426
6446
|
function getNoValidLoaderMessage(data) {
|
|
6427
|
-
const
|
|
6447
|
+
const url = getResourceUrl(data);
|
|
6448
|
+
const type = getResourceMIMEType(data);
|
|
6428
6449
|
let message = "No valid loader found (";
|
|
6429
6450
|
message += url ? `${path_exports.filename(url)}, ` : "no url provided, ";
|
|
6430
6451
|
message += `MIME type: ${type ? `"${type}"` : "not provided"}, `;
|
|
@@ -6543,6 +6564,7 @@
|
|
|
6543
6564
|
init_resource_utils();
|
|
6544
6565
|
init_register_loaders();
|
|
6545
6566
|
init_is_type();
|
|
6567
|
+
init_url_utils();
|
|
6546
6568
|
EXT_PATTERN = /\.([^.]+)$/;
|
|
6547
6569
|
}
|
|
6548
6570
|
});
|
|
@@ -6755,18 +6777,25 @@
|
|
|
6755
6777
|
});
|
|
6756
6778
|
|
|
6757
6779
|
// ../core/src/lib/loader-utils/loader-context.ts
|
|
6758
|
-
function getLoaderContext(context, options,
|
|
6759
|
-
if (
|
|
6760
|
-
return
|
|
6780
|
+
function getLoaderContext(context, options, parentContext) {
|
|
6781
|
+
if (parentContext) {
|
|
6782
|
+
return parentContext;
|
|
6761
6783
|
}
|
|
6762
|
-
const
|
|
6784
|
+
const newContext = {
|
|
6763
6785
|
fetch: getFetchFunction(options, context),
|
|
6764
6786
|
...context
|
|
6765
6787
|
};
|
|
6766
|
-
if (
|
|
6767
|
-
|
|
6788
|
+
if (newContext.url) {
|
|
6789
|
+
const baseUrl = stripQueryString(newContext.url);
|
|
6790
|
+
newContext.baseUrl = baseUrl;
|
|
6791
|
+
newContext.queryString = extractQueryString(newContext.url);
|
|
6792
|
+
newContext.filename = path_exports.filename(baseUrl);
|
|
6793
|
+
newContext.baseUrl = path_exports.dirname(baseUrl);
|
|
6794
|
+
}
|
|
6795
|
+
if (!Array.isArray(newContext.loaders)) {
|
|
6796
|
+
newContext.loaders = null;
|
|
6768
6797
|
}
|
|
6769
|
-
return
|
|
6798
|
+
return newContext;
|
|
6770
6799
|
}
|
|
6771
6800
|
function getLoadersFromContext(loaders, context) {
|
|
6772
6801
|
if (!context && loaders && !Array.isArray(loaders)) {
|
|
@@ -6785,6 +6814,8 @@
|
|
|
6785
6814
|
var init_loader_context = __esm({
|
|
6786
6815
|
"../core/src/lib/loader-utils/loader-context.ts"() {
|
|
6787
6816
|
init_get_fetch_function();
|
|
6817
|
+
init_url_utils();
|
|
6818
|
+
init_src2();
|
|
6788
6819
|
}
|
|
6789
6820
|
});
|
|
6790
6821
|
|
|
@@ -6798,7 +6829,7 @@
|
|
|
6798
6829
|
}
|
|
6799
6830
|
data = await data;
|
|
6800
6831
|
options = options || {};
|
|
6801
|
-
const
|
|
6832
|
+
const url = getResourceUrl(data);
|
|
6802
6833
|
const typedLoaders = loaders;
|
|
6803
6834
|
const candidateLoaders = getLoadersFromContext(typedLoaders, context);
|
|
6804
6835
|
const loader = await selectLoader(data, candidateLoaders, options);
|
|
@@ -6806,7 +6837,7 @@
|
|
|
6806
6837
|
return null;
|
|
6807
6838
|
}
|
|
6808
6839
|
options = normalizeOptions(options, loader, candidateLoaders, url);
|
|
6809
|
-
context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context);
|
|
6840
|
+
context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context || null);
|
|
6810
6841
|
return await parseWithLoader(loader, data, options, context);
|
|
6811
6842
|
}
|
|
6812
6843
|
async function parseWithLoader(loader, data, options, context) {
|
|
@@ -6980,7 +7011,6 @@
|
|
|
6980
7011
|
var DEFAULT_DRACO_OPTIONS, DracoLoader;
|
|
6981
7012
|
var init_draco_loader = __esm({
|
|
6982
7013
|
"../draco/src/draco-loader.ts"() {
|
|
6983
|
-
init_src();
|
|
6984
7014
|
init_version3();
|
|
6985
7015
|
DEFAULT_DRACO_OPTIONS = {
|
|
6986
7016
|
draco: {
|
|
@@ -6992,7 +7022,7 @@
|
|
|
6992
7022
|
};
|
|
6993
7023
|
DracoLoader = {
|
|
6994
7024
|
name: "Draco",
|
|
6995
|
-
id:
|
|
7025
|
+
id: "draco",
|
|
6996
7026
|
module: "draco",
|
|
6997
7027
|
version: VERSION5,
|
|
6998
7028
|
worker: true,
|
|
@@ -8791,763 +8821,300 @@
|
|
|
8791
8821
|
}
|
|
8792
8822
|
});
|
|
8793
8823
|
|
|
8794
|
-
// ../
|
|
8824
|
+
// ../images/src/lib/utils/version.ts
|
|
8795
8825
|
var VERSION7;
|
|
8796
8826
|
var init_version5 = __esm({
|
|
8797
|
-
"../
|
|
8798
|
-
VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "
|
|
8827
|
+
"../images/src/lib/utils/version.ts"() {
|
|
8828
|
+
VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
8799
8829
|
}
|
|
8800
8830
|
});
|
|
8801
8831
|
|
|
8802
|
-
// ../
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8832
|
+
// ../images/src/lib/category-api/image-type.ts
|
|
8833
|
+
function isImageTypeSupported(type) {
|
|
8834
|
+
switch (type) {
|
|
8835
|
+
case "auto":
|
|
8836
|
+
return IMAGE_BITMAP_SUPPORTED || IMAGE_SUPPORTED || DATA_SUPPORTED;
|
|
8837
|
+
case "imagebitmap":
|
|
8838
|
+
return IMAGE_BITMAP_SUPPORTED;
|
|
8839
|
+
case "image":
|
|
8840
|
+
return IMAGE_SUPPORTED;
|
|
8841
|
+
case "data":
|
|
8842
|
+
return DATA_SUPPORTED;
|
|
8843
|
+
default:
|
|
8844
|
+
throw new Error(`@loaders.gl/images: image ${type} not supported in this environment`);
|
|
8807
8845
|
}
|
|
8808
|
-
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTrascoder(options);
|
|
8809
|
-
return await loadBasisTranscoderPromise;
|
|
8810
|
-
}
|
|
8811
|
-
async function loadBasisTrascoder(options) {
|
|
8812
|
-
let BASIS = null;
|
|
8813
|
-
let wasmBinary = null;
|
|
8814
|
-
[BASIS, wasmBinary] = await Promise.all([
|
|
8815
|
-
await loadLibrary("basis_transcoder.js", "textures", options),
|
|
8816
|
-
await loadLibrary("basis_transcoder.wasm", "textures", options)
|
|
8817
|
-
]);
|
|
8818
|
-
BASIS = BASIS || globalThis.BASIS;
|
|
8819
|
-
return await initializeBasisTrascoderModule(BASIS, wasmBinary);
|
|
8820
8846
|
}
|
|
8821
|
-
function
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
options.wasmBinary = wasmBinary;
|
|
8847
|
+
function getDefaultImageType() {
|
|
8848
|
+
if (IMAGE_BITMAP_SUPPORTED) {
|
|
8849
|
+
return "imagebitmap";
|
|
8825
8850
|
}
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
const { BasisFile, initializeBasis } = module;
|
|
8829
|
-
initializeBasis();
|
|
8830
|
-
resolve2({ BasisFile });
|
|
8831
|
-
});
|
|
8832
|
-
});
|
|
8833
|
-
}
|
|
8834
|
-
async function loadBasisEncoderModule(options) {
|
|
8835
|
-
const modules = options.modules || {};
|
|
8836
|
-
if (modules.basisEncoder) {
|
|
8837
|
-
return modules.basisEncoder;
|
|
8851
|
+
if (IMAGE_SUPPORTED) {
|
|
8852
|
+
return "image";
|
|
8838
8853
|
}
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
}
|
|
8842
|
-
async function loadBasisEncoder(options) {
|
|
8843
|
-
let BASIS_ENCODER = null;
|
|
8844
|
-
let wasmBinary = null;
|
|
8845
|
-
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
8846
|
-
await loadLibrary(BASIS_CDN_ENCODER_JS, "textures", options),
|
|
8847
|
-
await loadLibrary(BASIS_CDN_ENCODER_WASM, "textures", options)
|
|
8848
|
-
]);
|
|
8849
|
-
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
8850
|
-
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
8851
|
-
}
|
|
8852
|
-
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
8853
|
-
const options = {};
|
|
8854
|
-
if (wasmBinary) {
|
|
8855
|
-
options.wasmBinary = wasmBinary;
|
|
8854
|
+
if (DATA_SUPPORTED) {
|
|
8855
|
+
return "data";
|
|
8856
8856
|
}
|
|
8857
|
-
|
|
8858
|
-
BasisEncoderModule(options).then((module) => {
|
|
8859
|
-
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
8860
|
-
initializeBasis();
|
|
8861
|
-
resolve2({ BasisFile, KTX2File, BasisEncoder });
|
|
8862
|
-
});
|
|
8863
|
-
});
|
|
8857
|
+
throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");
|
|
8864
8858
|
}
|
|
8865
|
-
var
|
|
8866
|
-
var
|
|
8867
|
-
"../
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8859
|
+
var _parseImageNode, IMAGE_SUPPORTED, IMAGE_BITMAP_SUPPORTED, NODE_IMAGE_SUPPORTED, DATA_SUPPORTED;
|
|
8860
|
+
var init_image_type = __esm({
|
|
8861
|
+
"../images/src/lib/category-api/image-type.ts"() {
|
|
8862
|
+
init_src2();
|
|
8863
|
+
({ _parseImageNode } = globalThis);
|
|
8864
|
+
IMAGE_SUPPORTED = typeof Image !== "undefined";
|
|
8865
|
+
IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
|
|
8866
|
+
NODE_IMAGE_SUPPORTED = Boolean(_parseImageNode);
|
|
8867
|
+
DATA_SUPPORTED = isBrowser ? true : NODE_IMAGE_SUPPORTED;
|
|
8872
8868
|
}
|
|
8873
8869
|
});
|
|
8874
8870
|
|
|
8875
|
-
// ../
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
|
|
8881
|
-
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
|
|
8882
|
-
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
|
|
8883
|
-
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
|
|
8884
|
-
COMPRESSED_R11_EAC: 37488,
|
|
8885
|
-
COMPRESSED_SIGNED_R11_EAC: 37489,
|
|
8886
|
-
COMPRESSED_RG11_EAC: 37490,
|
|
8887
|
-
COMPRESSED_SIGNED_RG11_EAC: 37491,
|
|
8888
|
-
COMPRESSED_RGB8_ETC2: 37492,
|
|
8889
|
-
COMPRESSED_RGBA8_ETC2_EAC: 37493,
|
|
8890
|
-
COMPRESSED_SRGB8_ETC2: 37494,
|
|
8891
|
-
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
8892
|
-
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
8893
|
-
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
8894
|
-
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
8895
|
-
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
8896
|
-
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
8897
|
-
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
8898
|
-
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
8899
|
-
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
8900
|
-
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
8901
|
-
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
8902
|
-
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
8903
|
-
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
8904
|
-
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
8905
|
-
COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
|
|
8906
|
-
COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
|
|
8907
|
-
COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
|
|
8908
|
-
COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
|
|
8909
|
-
COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
|
|
8910
|
-
COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
|
|
8911
|
-
COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
|
|
8912
|
-
COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
|
|
8913
|
-
COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
|
|
8914
|
-
COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
|
|
8915
|
-
COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
|
|
8916
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
|
|
8917
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
|
|
8918
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
|
|
8919
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
|
|
8920
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
|
|
8921
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
|
|
8922
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
|
|
8923
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
|
|
8924
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
|
|
8925
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
|
|
8926
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
|
|
8927
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
8928
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
8929
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
8930
|
-
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
8931
|
-
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
8932
|
-
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
8933
|
-
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
8934
|
-
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
8935
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
8936
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
8937
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
|
|
8938
|
-
};
|
|
8871
|
+
// ../images/src/lib/category-api/parsed-image-api.ts
|
|
8872
|
+
function getImageType(image) {
|
|
8873
|
+
const format = getImageTypeOrNull(image);
|
|
8874
|
+
if (!format) {
|
|
8875
|
+
throw new Error("Not an image");
|
|
8939
8876
|
}
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
}
|
|
8877
|
+
return format;
|
|
8878
|
+
}
|
|
8879
|
+
function getImageData(image) {
|
|
8880
|
+
switch (getImageType(image)) {
|
|
8881
|
+
case "data":
|
|
8882
|
+
return image;
|
|
8883
|
+
case "image":
|
|
8884
|
+
case "imagebitmap":
|
|
8885
|
+
const canvas = document.createElement("canvas");
|
|
8886
|
+
const context = canvas.getContext("2d");
|
|
8887
|
+
if (!context) {
|
|
8888
|
+
throw new Error("getImageData");
|
|
8953
8889
|
}
|
|
8954
|
-
|
|
8890
|
+
canvas.width = image.width;
|
|
8891
|
+
canvas.height = image.height;
|
|
8892
|
+
context.drawImage(image, 0, 0);
|
|
8893
|
+
return context.getImageData(0, 0, image.width, image.height);
|
|
8894
|
+
default:
|
|
8895
|
+
throw new Error("getImageData");
|
|
8955
8896
|
}
|
|
8956
|
-
return formats;
|
|
8957
8897
|
}
|
|
8958
|
-
function
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
return
|
|
8898
|
+
function getImageTypeOrNull(image) {
|
|
8899
|
+
if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
|
|
8900
|
+
return "imagebitmap";
|
|
8901
|
+
}
|
|
8902
|
+
if (typeof Image !== "undefined" && image instanceof Image) {
|
|
8903
|
+
return "image";
|
|
8904
|
+
}
|
|
8905
|
+
if (image && typeof image === "object" && image.data && image.width && image.height) {
|
|
8906
|
+
return "data";
|
|
8964
8907
|
}
|
|
8908
|
+
return null;
|
|
8965
8909
|
}
|
|
8966
|
-
var
|
|
8967
|
-
|
|
8968
|
-
"../textures/src/lib/utils/texture-formats.ts"() {
|
|
8969
|
-
BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
8970
|
-
WEBGL_EXTENSIONS = {
|
|
8971
|
-
WEBGL_compressed_texture_s3tc: "dxt",
|
|
8972
|
-
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
8973
|
-
WEBGL_compressed_texture_etc1: "etc1",
|
|
8974
|
-
WEBGL_compressed_texture_etc: "etc2",
|
|
8975
|
-
WEBGL_compressed_texture_pvrtc: "pvrtc",
|
|
8976
|
-
WEBGL_compressed_texture_atc: "atc",
|
|
8977
|
-
WEBGL_compressed_texture_astc: "astc",
|
|
8978
|
-
EXT_texture_compression_rgtc: "rgtc"
|
|
8979
|
-
};
|
|
8980
|
-
formats = null;
|
|
8910
|
+
var init_parsed_image_api = __esm({
|
|
8911
|
+
"../images/src/lib/category-api/parsed-image-api.ts"() {
|
|
8981
8912
|
}
|
|
8982
8913
|
});
|
|
8983
8914
|
|
|
8984
|
-
//
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
}(o || (o = {})), function(t2) {
|
|
9002
|
-
t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
|
|
9003
|
-
}(l || (l = {})), function(t2) {
|
|
9004
|
-
t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
|
|
9005
|
-
}(f || (f = {}));
|
|
8915
|
+
// ../images/src/lib/parsers/svg-utils.ts
|
|
8916
|
+
function isSVG(url) {
|
|
8917
|
+
return url && (SVG_DATA_URL_PATTERN.test(url) || SVG_URL_PATTERN.test(url));
|
|
8918
|
+
}
|
|
8919
|
+
function getBlobOrSVGDataUrl(arrayBuffer, url) {
|
|
8920
|
+
if (isSVG(url)) {
|
|
8921
|
+
const textDecoder = new TextDecoder();
|
|
8922
|
+
let xmlText = textDecoder.decode(arrayBuffer);
|
|
8923
|
+
try {
|
|
8924
|
+
if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
|
|
8925
|
+
xmlText = unescape(encodeURIComponent(xmlText));
|
|
8926
|
+
}
|
|
8927
|
+
} catch (error) {
|
|
8928
|
+
throw new Error(error.message);
|
|
8929
|
+
}
|
|
8930
|
+
const src = `data:image/svg+xml;base64,${btoa(xmlText)}`;
|
|
8931
|
+
return src;
|
|
9006
8932
|
}
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
// ../textures/src/lib/parsers/parse-ktx.ts
|
|
9010
|
-
function isKTX(data) {
|
|
9011
|
-
const id = new Uint8Array(data);
|
|
9012
|
-
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || id[1] !== KTX2_ID[1] || id[2] !== KTX2_ID[2] || id[3] !== KTX2_ID[3] || id[4] !== KTX2_ID[4] || id[5] !== KTX2_ID[5] || id[6] !== KTX2_ID[6] || id[7] !== KTX2_ID[7] || id[8] !== KTX2_ID[8] || id[9] !== KTX2_ID[9] || id[10] !== KTX2_ID[10] || id[11] !== KTX2_ID[11];
|
|
9013
|
-
return !notKTX;
|
|
8933
|
+
return getBlob(arrayBuffer, url);
|
|
9014
8934
|
}
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
48,
|
|
9027
|
-
187,
|
|
9028
|
-
13,
|
|
9029
|
-
10,
|
|
9030
|
-
26,
|
|
9031
|
-
10
|
|
9032
|
-
];
|
|
8935
|
+
function getBlob(arrayBuffer, url) {
|
|
8936
|
+
if (isSVG(url)) {
|
|
8937
|
+
throw new Error("SVG cannot be parsed directly to imagebitmap");
|
|
8938
|
+
}
|
|
8939
|
+
return new Blob([new Uint8Array(arrayBuffer)]);
|
|
8940
|
+
}
|
|
8941
|
+
var SVG_DATA_URL_PATTERN, SVG_URL_PATTERN;
|
|
8942
|
+
var init_svg_utils = __esm({
|
|
8943
|
+
"../images/src/lib/parsers/svg-utils.ts"() {
|
|
8944
|
+
SVG_DATA_URL_PATTERN = /^data:image\/svg\+xml/;
|
|
8945
|
+
SVG_URL_PATTERN = /\.svg((\?|#).*)?$/;
|
|
9033
8946
|
}
|
|
9034
8947
|
});
|
|
9035
8948
|
|
|
9036
|
-
// ../
|
|
9037
|
-
async function
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
8949
|
+
// ../images/src/lib/parsers/parse-to-image.ts
|
|
8950
|
+
async function parseToImage(arrayBuffer, options, url) {
|
|
8951
|
+
const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);
|
|
8952
|
+
const URL2 = self.URL || self.webkitURL;
|
|
8953
|
+
const objectUrl = typeof blobOrDataUrl !== "string" && URL2.createObjectURL(blobOrDataUrl);
|
|
8954
|
+
try {
|
|
8955
|
+
return await loadToImage(objectUrl || blobOrDataUrl, options);
|
|
8956
|
+
} finally {
|
|
8957
|
+
if (objectUrl) {
|
|
8958
|
+
URL2.revokeObjectURL(objectUrl);
|
|
9042
8959
|
}
|
|
9043
|
-
const { BasisFile } = await loadBasisTrascoderModule(options);
|
|
9044
|
-
return parseBasisFile(BasisFile, data, options);
|
|
9045
|
-
}
|
|
9046
|
-
switch (options.basis.module) {
|
|
9047
|
-
case "encoder":
|
|
9048
|
-
const fileConstructors = await loadBasisEncoderModule(options);
|
|
9049
|
-
switch (options.basis.containerFormat) {
|
|
9050
|
-
case "ktx2":
|
|
9051
|
-
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
9052
|
-
case "basis":
|
|
9053
|
-
default:
|
|
9054
|
-
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
9055
|
-
}
|
|
9056
|
-
case "transcoder":
|
|
9057
|
-
default:
|
|
9058
|
-
const { BasisFile } = await loadBasisTrascoderModule(options);
|
|
9059
|
-
return parseBasisFile(BasisFile, data, options);
|
|
9060
8960
|
}
|
|
9061
8961
|
}
|
|
9062
|
-
function
|
|
9063
|
-
const
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
const imageCount = basisFile.getNumImages();
|
|
9069
|
-
const images = [];
|
|
9070
|
-
for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
|
|
9071
|
-
const levelsCount = basisFile.getNumLevels(imageIndex);
|
|
9072
|
-
const levels = [];
|
|
9073
|
-
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
9074
|
-
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
9075
|
-
}
|
|
9076
|
-
images.push(levels);
|
|
9077
|
-
}
|
|
9078
|
-
return images;
|
|
9079
|
-
} finally {
|
|
9080
|
-
basisFile.close();
|
|
9081
|
-
basisFile.delete();
|
|
8962
|
+
async function loadToImage(url, options) {
|
|
8963
|
+
const image = new Image();
|
|
8964
|
+
image.src = url;
|
|
8965
|
+
if (options.image && options.image.decode && image.decode) {
|
|
8966
|
+
await image.decode();
|
|
8967
|
+
return image;
|
|
9082
8968
|
}
|
|
8969
|
+
return await new Promise((resolve2, reject) => {
|
|
8970
|
+
try {
|
|
8971
|
+
image.onload = () => resolve2(image);
|
|
8972
|
+
image.onerror = (err) => reject(new Error(`Could not load image ${url}: ${err}`));
|
|
8973
|
+
} catch (error) {
|
|
8974
|
+
reject(error);
|
|
8975
|
+
}
|
|
8976
|
+
});
|
|
9083
8977
|
}
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
const hasAlpha = basisFile.getHasAlpha();
|
|
9088
|
-
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
9089
|
-
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
9090
|
-
const decodedData = new Uint8Array(decodedSize);
|
|
9091
|
-
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
9092
|
-
throw new Error("failed to start Basis transcoding");
|
|
8978
|
+
var init_parse_to_image = __esm({
|
|
8979
|
+
"../images/src/lib/parsers/parse-to-image.ts"() {
|
|
8980
|
+
init_svg_utils();
|
|
9093
8981
|
}
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
8982
|
+
});
|
|
8983
|
+
|
|
8984
|
+
// ../images/src/lib/parsers/parse-to-image-bitmap.ts
|
|
8985
|
+
async function parseToImageBitmap(arrayBuffer, options, url) {
|
|
8986
|
+
let blob;
|
|
8987
|
+
if (isSVG(url)) {
|
|
8988
|
+
const image = await parseToImage(arrayBuffer, options, url);
|
|
8989
|
+
blob = image;
|
|
8990
|
+
} else {
|
|
8991
|
+
blob = getBlob(arrayBuffer, url);
|
|
8992
|
+
}
|
|
8993
|
+
const imagebitmapOptions = options && options.imagebitmap;
|
|
8994
|
+
return await safeCreateImageBitmap(blob, imagebitmapOptions);
|
|
9102
8995
|
}
|
|
9103
|
-
function
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
break;
|
|
8996
|
+
async function safeCreateImageBitmap(blob, imagebitmapOptions = null) {
|
|
8997
|
+
if (isEmptyObject(imagebitmapOptions) || !imagebitmapOptionsSupported) {
|
|
8998
|
+
imagebitmapOptions = null;
|
|
8999
|
+
}
|
|
9000
|
+
if (imagebitmapOptions) {
|
|
9001
|
+
try {
|
|
9002
|
+
return await createImageBitmap(blob, imagebitmapOptions);
|
|
9003
|
+
} catch (error) {
|
|
9004
|
+
console.warn(error);
|
|
9005
|
+
imagebitmapOptionsSupported = false;
|
|
9114
9006
|
}
|
|
9115
|
-
return [levels];
|
|
9116
|
-
} finally {
|
|
9117
|
-
ktx2File.close();
|
|
9118
|
-
ktx2File.delete();
|
|
9119
9007
|
}
|
|
9008
|
+
return await createImageBitmap(blob);
|
|
9120
9009
|
}
|
|
9121
|
-
function
|
|
9122
|
-
const
|
|
9123
|
-
|
|
9124
|
-
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
9125
|
-
const decodedData = new Uint8Array(decodedSize);
|
|
9126
|
-
if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
|
|
9127
|
-
throw new Error("Failed to transcode KTX2 image");
|
|
9010
|
+
function isEmptyObject(object) {
|
|
9011
|
+
for (const key in object || EMPTY_OBJECT) {
|
|
9012
|
+
return false;
|
|
9128
9013
|
}
|
|
9129
|
-
return
|
|
9130
|
-
width,
|
|
9131
|
-
height,
|
|
9132
|
-
data: decodedData,
|
|
9133
|
-
compressed,
|
|
9134
|
-
levelSize: decodedSize,
|
|
9135
|
-
hasAlpha: alphaFlag,
|
|
9136
|
-
format
|
|
9137
|
-
};
|
|
9014
|
+
return true;
|
|
9138
9015
|
}
|
|
9139
|
-
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9016
|
+
var EMPTY_OBJECT, imagebitmapOptionsSupported;
|
|
9017
|
+
var init_parse_to_image_bitmap = __esm({
|
|
9018
|
+
"../images/src/lib/parsers/parse-to-image-bitmap.ts"() {
|
|
9019
|
+
init_svg_utils();
|
|
9020
|
+
init_parse_to_image();
|
|
9021
|
+
EMPTY_OBJECT = {};
|
|
9022
|
+
imagebitmapOptionsSupported = true;
|
|
9143
9023
|
}
|
|
9144
|
-
|
|
9145
|
-
|
|
9024
|
+
});
|
|
9025
|
+
|
|
9026
|
+
// ../images/src/lib/category-api/parse-isobmff-binary.ts
|
|
9027
|
+
function getISOBMFFMediaType(buffer) {
|
|
9028
|
+
if (!checkString(buffer, "ftyp", 4)) {
|
|
9029
|
+
return null;
|
|
9146
9030
|
}
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
}
|
|
9150
|
-
function selectSupportedBasisFormat() {
|
|
9151
|
-
const supportedFormats = getSupportedGPUTextureFormats();
|
|
9152
|
-
if (supportedFormats.has("astc")) {
|
|
9153
|
-
return "astc-4x4";
|
|
9154
|
-
} else if (supportedFormats.has("dxt")) {
|
|
9155
|
-
return {
|
|
9156
|
-
alpha: "bc3",
|
|
9157
|
-
noAlpha: "bc1"
|
|
9158
|
-
};
|
|
9159
|
-
} else if (supportedFormats.has("pvrtc")) {
|
|
9160
|
-
return {
|
|
9161
|
-
alpha: "pvrtc1-4-rgba",
|
|
9162
|
-
noAlpha: "pvrtc1-4-rgb"
|
|
9163
|
-
};
|
|
9164
|
-
} else if (supportedFormats.has("etc1")) {
|
|
9165
|
-
return "etc1";
|
|
9166
|
-
} else if (supportedFormats.has("etc2")) {
|
|
9167
|
-
return "etc2";
|
|
9031
|
+
if ((buffer[8] & 96) === 0) {
|
|
9032
|
+
return null;
|
|
9168
9033
|
}
|
|
9169
|
-
return
|
|
9034
|
+
return decodeMajorBrand(buffer);
|
|
9170
9035
|
}
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
init_parse_ktx();
|
|
9178
|
-
OutputFormat = {
|
|
9179
|
-
etc1: {
|
|
9180
|
-
basisFormat: 0,
|
|
9181
|
-
compressed: true,
|
|
9182
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
9183
|
-
},
|
|
9184
|
-
etc2: { basisFormat: 1, compressed: true },
|
|
9185
|
-
bc1: {
|
|
9186
|
-
basisFormat: 2,
|
|
9187
|
-
compressed: true,
|
|
9188
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
|
|
9189
|
-
},
|
|
9190
|
-
bc3: {
|
|
9191
|
-
basisFormat: 3,
|
|
9192
|
-
compressed: true,
|
|
9193
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
9194
|
-
},
|
|
9195
|
-
bc4: { basisFormat: 4, compressed: true },
|
|
9196
|
-
bc5: { basisFormat: 5, compressed: true },
|
|
9197
|
-
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
9198
|
-
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
9199
|
-
"pvrtc1-4-rgb": {
|
|
9200
|
-
basisFormat: 8,
|
|
9201
|
-
compressed: true,
|
|
9202
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
|
9203
|
-
},
|
|
9204
|
-
"pvrtc1-4-rgba": {
|
|
9205
|
-
basisFormat: 9,
|
|
9206
|
-
compressed: true,
|
|
9207
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
|
9208
|
-
},
|
|
9209
|
-
"astc-4x4": {
|
|
9210
|
-
basisFormat: 10,
|
|
9211
|
-
compressed: true,
|
|
9212
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
9213
|
-
},
|
|
9214
|
-
"atc-rgb": { basisFormat: 11, compressed: true },
|
|
9215
|
-
"atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
|
|
9216
|
-
rgba32: { basisFormat: 13, compressed: false },
|
|
9217
|
-
rgb565: { basisFormat: 14, compressed: false },
|
|
9218
|
-
bgr565: { basisFormat: 15, compressed: false },
|
|
9219
|
-
rgba4444: { basisFormat: 16, compressed: false }
|
|
9220
|
-
};
|
|
9221
|
-
}
|
|
9222
|
-
});
|
|
9223
|
-
|
|
9224
|
-
// ../textures/src/basis-loader.ts
|
|
9225
|
-
var BasisWorkerLoader, BasisLoader;
|
|
9226
|
-
var init_basis_loader = __esm({
|
|
9227
|
-
"../textures/src/basis-loader.ts"() {
|
|
9228
|
-
init_src();
|
|
9229
|
-
init_version5();
|
|
9230
|
-
init_parse_basis();
|
|
9231
|
-
BasisWorkerLoader = {
|
|
9232
|
-
name: "Basis",
|
|
9233
|
-
id: isBrowser2 ? "basis" : "basis-nodejs",
|
|
9234
|
-
module: "textures",
|
|
9235
|
-
version: VERSION7,
|
|
9236
|
-
worker: true,
|
|
9237
|
-
extensions: ["basis", "ktx2"],
|
|
9238
|
-
mimeTypes: ["application/octet-stream", "image/ktx2"],
|
|
9239
|
-
tests: ["sB"],
|
|
9240
|
-
binary: true,
|
|
9241
|
-
options: {
|
|
9242
|
-
basis: {
|
|
9243
|
-
format: "auto",
|
|
9244
|
-
libraryPath: "libs/",
|
|
9245
|
-
containerFormat: "auto",
|
|
9246
|
-
module: "transcoder"
|
|
9247
|
-
}
|
|
9248
|
-
}
|
|
9249
|
-
};
|
|
9250
|
-
BasisLoader = {
|
|
9251
|
-
...BasisWorkerLoader,
|
|
9252
|
-
parse: parseBasis
|
|
9253
|
-
};
|
|
9254
|
-
}
|
|
9255
|
-
});
|
|
9256
|
-
|
|
9257
|
-
// ../images/src/lib/utils/version.ts
|
|
9258
|
-
var VERSION9;
|
|
9259
|
-
var init_version6 = __esm({
|
|
9260
|
-
"../images/src/lib/utils/version.ts"() {
|
|
9261
|
-
VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
9262
|
-
}
|
|
9263
|
-
});
|
|
9264
|
-
|
|
9265
|
-
// ../images/src/lib/category-api/image-type.ts
|
|
9266
|
-
function isImageTypeSupported(type) {
|
|
9267
|
-
switch (type) {
|
|
9268
|
-
case "auto":
|
|
9269
|
-
return IMAGE_BITMAP_SUPPORTED || IMAGE_SUPPORTED || DATA_SUPPORTED;
|
|
9270
|
-
case "imagebitmap":
|
|
9271
|
-
return IMAGE_BITMAP_SUPPORTED;
|
|
9272
|
-
case "image":
|
|
9273
|
-
return IMAGE_SUPPORTED;
|
|
9274
|
-
case "data":
|
|
9275
|
-
return DATA_SUPPORTED;
|
|
9036
|
+
function decodeMajorBrand(buffer) {
|
|
9037
|
+
const brandMajor = getUTF8String(buffer, 8, 12).replace("\0", " ").trim();
|
|
9038
|
+
switch (brandMajor) {
|
|
9039
|
+
case "avif":
|
|
9040
|
+
case "avis":
|
|
9041
|
+
return { extension: "avif", mimeType: "image/avif" };
|
|
9276
9042
|
default:
|
|
9277
|
-
|
|
9043
|
+
return null;
|
|
9278
9044
|
}
|
|
9279
9045
|
}
|
|
9280
|
-
function
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9046
|
+
function getUTF8String(array, start, end) {
|
|
9047
|
+
return String.fromCharCode(...array.slice(start, end));
|
|
9048
|
+
}
|
|
9049
|
+
function stringToBytes(string) {
|
|
9050
|
+
return [...string].map((character) => character.charCodeAt(0));
|
|
9051
|
+
}
|
|
9052
|
+
function checkString(buffer, header, offset = 0) {
|
|
9053
|
+
const headerBytes = stringToBytes(header);
|
|
9054
|
+
for (let i2 = 0; i2 < headerBytes.length; ++i2) {
|
|
9055
|
+
if (headerBytes[i2] !== buffer[i2 + offset]) {
|
|
9056
|
+
return false;
|
|
9057
|
+
}
|
|
9289
9058
|
}
|
|
9290
|
-
|
|
9059
|
+
return true;
|
|
9291
9060
|
}
|
|
9292
|
-
var
|
|
9293
|
-
|
|
9294
|
-
"../images/src/lib/category-api/image-type.ts"() {
|
|
9295
|
-
init_src2();
|
|
9296
|
-
({ _parseImageNode } = globalThis);
|
|
9297
|
-
IMAGE_SUPPORTED = typeof Image !== "undefined";
|
|
9298
|
-
IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
|
|
9299
|
-
NODE_IMAGE_SUPPORTED = Boolean(_parseImageNode);
|
|
9300
|
-
DATA_SUPPORTED = isBrowser ? true : NODE_IMAGE_SUPPORTED;
|
|
9061
|
+
var init_parse_isobmff_binary = __esm({
|
|
9062
|
+
"../images/src/lib/category-api/parse-isobmff-binary.ts"() {
|
|
9301
9063
|
}
|
|
9302
9064
|
});
|
|
9303
9065
|
|
|
9304
|
-
// ../images/src/lib/category-api/
|
|
9305
|
-
function
|
|
9306
|
-
const
|
|
9307
|
-
|
|
9308
|
-
throw new Error("Not an image");
|
|
9309
|
-
}
|
|
9310
|
-
return format;
|
|
9066
|
+
// ../images/src/lib/category-api/binary-image-api.ts
|
|
9067
|
+
function getBinaryImageMetadata(binaryData) {
|
|
9068
|
+
const dataView = toDataView(binaryData);
|
|
9069
|
+
return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView) || getISOBMFFMetadata(dataView);
|
|
9311
9070
|
}
|
|
9312
|
-
function
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
case "imagebitmap":
|
|
9318
|
-
const canvas = document.createElement("canvas");
|
|
9319
|
-
const context = canvas.getContext("2d");
|
|
9320
|
-
if (!context) {
|
|
9321
|
-
throw new Error("getImageData");
|
|
9322
|
-
}
|
|
9323
|
-
canvas.width = image.width;
|
|
9324
|
-
canvas.height = image.height;
|
|
9325
|
-
context.drawImage(image, 0, 0);
|
|
9326
|
-
return context.getImageData(0, 0, image.width, image.height);
|
|
9327
|
-
default:
|
|
9328
|
-
throw new Error("getImageData");
|
|
9071
|
+
function getISOBMFFMetadata(binaryData) {
|
|
9072
|
+
const buffer = new Uint8Array(binaryData instanceof DataView ? binaryData.buffer : binaryData);
|
|
9073
|
+
const mediaType = getISOBMFFMediaType(buffer);
|
|
9074
|
+
if (!mediaType) {
|
|
9075
|
+
return null;
|
|
9329
9076
|
}
|
|
9077
|
+
return {
|
|
9078
|
+
mimeType: mediaType.mimeType,
|
|
9079
|
+
width: 0,
|
|
9080
|
+
height: 0
|
|
9081
|
+
};
|
|
9330
9082
|
}
|
|
9331
|
-
function
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
return "image";
|
|
9083
|
+
function getPngMetadata(binaryData) {
|
|
9084
|
+
const dataView = toDataView(binaryData);
|
|
9085
|
+
const isPng = dataView.byteLength >= 24 && dataView.getUint32(0, BIG_ENDIAN) === 2303741511;
|
|
9086
|
+
if (!isPng) {
|
|
9087
|
+
return null;
|
|
9337
9088
|
}
|
|
9338
|
-
|
|
9339
|
-
|
|
9089
|
+
return {
|
|
9090
|
+
mimeType: "image/png",
|
|
9091
|
+
width: dataView.getUint32(16, BIG_ENDIAN),
|
|
9092
|
+
height: dataView.getUint32(20, BIG_ENDIAN)
|
|
9093
|
+
};
|
|
9094
|
+
}
|
|
9095
|
+
function getGifMetadata(binaryData) {
|
|
9096
|
+
const dataView = toDataView(binaryData);
|
|
9097
|
+
const isGif = dataView.byteLength >= 10 && dataView.getUint32(0, BIG_ENDIAN) === 1195984440;
|
|
9098
|
+
if (!isGif) {
|
|
9099
|
+
return null;
|
|
9340
9100
|
}
|
|
9341
|
-
return
|
|
9101
|
+
return {
|
|
9102
|
+
mimeType: "image/gif",
|
|
9103
|
+
width: dataView.getUint16(6, LITTLE_ENDIAN),
|
|
9104
|
+
height: dataView.getUint16(8, LITTLE_ENDIAN)
|
|
9105
|
+
};
|
|
9342
9106
|
}
|
|
9343
|
-
|
|
9344
|
-
|
|
9107
|
+
function getBmpMetadata(binaryData) {
|
|
9108
|
+
const dataView = toDataView(binaryData);
|
|
9109
|
+
const isBmp = dataView.byteLength >= 14 && dataView.getUint16(0, BIG_ENDIAN) === 16973 && dataView.getUint32(2, LITTLE_ENDIAN) === dataView.byteLength;
|
|
9110
|
+
if (!isBmp) {
|
|
9111
|
+
return null;
|
|
9345
9112
|
}
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
}
|
|
9352
|
-
function getBlobOrSVGDataUrl(arrayBuffer, url) {
|
|
9353
|
-
if (isSVG(url)) {
|
|
9354
|
-
const textDecoder = new TextDecoder();
|
|
9355
|
-
let xmlText = textDecoder.decode(arrayBuffer);
|
|
9356
|
-
try {
|
|
9357
|
-
if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
|
|
9358
|
-
xmlText = unescape(encodeURIComponent(xmlText));
|
|
9359
|
-
}
|
|
9360
|
-
} catch (error) {
|
|
9361
|
-
throw new Error(error.message);
|
|
9362
|
-
}
|
|
9363
|
-
const src = `data:image/svg+xml;base64,${btoa(xmlText)}`;
|
|
9364
|
-
return src;
|
|
9365
|
-
}
|
|
9366
|
-
return getBlob(arrayBuffer, url);
|
|
9367
|
-
}
|
|
9368
|
-
function getBlob(arrayBuffer, url) {
|
|
9369
|
-
if (isSVG(url)) {
|
|
9370
|
-
throw new Error("SVG cannot be parsed directly to imagebitmap");
|
|
9371
|
-
}
|
|
9372
|
-
return new Blob([new Uint8Array(arrayBuffer)]);
|
|
9373
|
-
}
|
|
9374
|
-
var SVG_DATA_URL_PATTERN, SVG_URL_PATTERN;
|
|
9375
|
-
var init_svg_utils = __esm({
|
|
9376
|
-
"../images/src/lib/parsers/svg-utils.ts"() {
|
|
9377
|
-
SVG_DATA_URL_PATTERN = /^data:image\/svg\+xml/;
|
|
9378
|
-
SVG_URL_PATTERN = /\.svg((\?|#).*)?$/;
|
|
9379
|
-
}
|
|
9380
|
-
});
|
|
9381
|
-
|
|
9382
|
-
// ../images/src/lib/parsers/parse-to-image.ts
|
|
9383
|
-
async function parseToImage(arrayBuffer, options, url) {
|
|
9384
|
-
const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);
|
|
9385
|
-
const URL2 = self.URL || self.webkitURL;
|
|
9386
|
-
const objectUrl = typeof blobOrDataUrl !== "string" && URL2.createObjectURL(blobOrDataUrl);
|
|
9387
|
-
try {
|
|
9388
|
-
return await loadToImage(objectUrl || blobOrDataUrl, options);
|
|
9389
|
-
} finally {
|
|
9390
|
-
if (objectUrl) {
|
|
9391
|
-
URL2.revokeObjectURL(objectUrl);
|
|
9392
|
-
}
|
|
9393
|
-
}
|
|
9394
|
-
}
|
|
9395
|
-
async function loadToImage(url, options) {
|
|
9396
|
-
const image = new Image();
|
|
9397
|
-
image.src = url;
|
|
9398
|
-
if (options.image && options.image.decode && image.decode) {
|
|
9399
|
-
await image.decode();
|
|
9400
|
-
return image;
|
|
9401
|
-
}
|
|
9402
|
-
return await new Promise((resolve2, reject) => {
|
|
9403
|
-
try {
|
|
9404
|
-
image.onload = () => resolve2(image);
|
|
9405
|
-
image.onerror = (err) => reject(new Error(`Could not load image ${url}: ${err}`));
|
|
9406
|
-
} catch (error) {
|
|
9407
|
-
reject(error);
|
|
9408
|
-
}
|
|
9409
|
-
});
|
|
9410
|
-
}
|
|
9411
|
-
var init_parse_to_image = __esm({
|
|
9412
|
-
"../images/src/lib/parsers/parse-to-image.ts"() {
|
|
9413
|
-
init_svg_utils();
|
|
9414
|
-
}
|
|
9415
|
-
});
|
|
9416
|
-
|
|
9417
|
-
// ../images/src/lib/parsers/parse-to-image-bitmap.ts
|
|
9418
|
-
async function parseToImageBitmap(arrayBuffer, options, url) {
|
|
9419
|
-
let blob;
|
|
9420
|
-
if (isSVG(url)) {
|
|
9421
|
-
const image = await parseToImage(arrayBuffer, options, url);
|
|
9422
|
-
blob = image;
|
|
9423
|
-
} else {
|
|
9424
|
-
blob = getBlob(arrayBuffer, url);
|
|
9425
|
-
}
|
|
9426
|
-
const imagebitmapOptions = options && options.imagebitmap;
|
|
9427
|
-
return await safeCreateImageBitmap(blob, imagebitmapOptions);
|
|
9428
|
-
}
|
|
9429
|
-
async function safeCreateImageBitmap(blob, imagebitmapOptions = null) {
|
|
9430
|
-
if (isEmptyObject(imagebitmapOptions) || !imagebitmapOptionsSupported) {
|
|
9431
|
-
imagebitmapOptions = null;
|
|
9432
|
-
}
|
|
9433
|
-
if (imagebitmapOptions) {
|
|
9434
|
-
try {
|
|
9435
|
-
return await createImageBitmap(blob, imagebitmapOptions);
|
|
9436
|
-
} catch (error) {
|
|
9437
|
-
console.warn(error);
|
|
9438
|
-
imagebitmapOptionsSupported = false;
|
|
9439
|
-
}
|
|
9440
|
-
}
|
|
9441
|
-
return await createImageBitmap(blob);
|
|
9442
|
-
}
|
|
9443
|
-
function isEmptyObject(object) {
|
|
9444
|
-
for (const key in object || EMPTY_OBJECT) {
|
|
9445
|
-
return false;
|
|
9446
|
-
}
|
|
9447
|
-
return true;
|
|
9448
|
-
}
|
|
9449
|
-
var EMPTY_OBJECT, imagebitmapOptionsSupported;
|
|
9450
|
-
var init_parse_to_image_bitmap = __esm({
|
|
9451
|
-
"../images/src/lib/parsers/parse-to-image-bitmap.ts"() {
|
|
9452
|
-
init_svg_utils();
|
|
9453
|
-
init_parse_to_image();
|
|
9454
|
-
EMPTY_OBJECT = {};
|
|
9455
|
-
imagebitmapOptionsSupported = true;
|
|
9456
|
-
}
|
|
9457
|
-
});
|
|
9458
|
-
|
|
9459
|
-
// ../images/src/lib/category-api/parse-isobmff-binary.ts
|
|
9460
|
-
function getISOBMFFMediaType(buffer) {
|
|
9461
|
-
if (!checkString(buffer, "ftyp", 4)) {
|
|
9462
|
-
return null;
|
|
9463
|
-
}
|
|
9464
|
-
if ((buffer[8] & 96) === 0) {
|
|
9465
|
-
return null;
|
|
9466
|
-
}
|
|
9467
|
-
return decodeMajorBrand(buffer);
|
|
9468
|
-
}
|
|
9469
|
-
function decodeMajorBrand(buffer) {
|
|
9470
|
-
const brandMajor = getUTF8String(buffer, 8, 12).replace("\0", " ").trim();
|
|
9471
|
-
switch (brandMajor) {
|
|
9472
|
-
case "avif":
|
|
9473
|
-
case "avis":
|
|
9474
|
-
return { extension: "avif", mimeType: "image/avif" };
|
|
9475
|
-
default:
|
|
9476
|
-
return null;
|
|
9477
|
-
}
|
|
9478
|
-
}
|
|
9479
|
-
function getUTF8String(array, start, end) {
|
|
9480
|
-
return String.fromCharCode(...array.slice(start, end));
|
|
9481
|
-
}
|
|
9482
|
-
function stringToBytes(string) {
|
|
9483
|
-
return [...string].map((character) => character.charCodeAt(0));
|
|
9484
|
-
}
|
|
9485
|
-
function checkString(buffer, header, offset = 0) {
|
|
9486
|
-
const headerBytes = stringToBytes(header);
|
|
9487
|
-
for (let i2 = 0; i2 < headerBytes.length; ++i2) {
|
|
9488
|
-
if (headerBytes[i2] !== buffer[i2 + offset]) {
|
|
9489
|
-
return false;
|
|
9490
|
-
}
|
|
9491
|
-
}
|
|
9492
|
-
return true;
|
|
9493
|
-
}
|
|
9494
|
-
var init_parse_isobmff_binary = __esm({
|
|
9495
|
-
"../images/src/lib/category-api/parse-isobmff-binary.ts"() {
|
|
9496
|
-
}
|
|
9497
|
-
});
|
|
9498
|
-
|
|
9499
|
-
// ../images/src/lib/category-api/binary-image-api.ts
|
|
9500
|
-
function getBinaryImageMetadata(binaryData) {
|
|
9501
|
-
const dataView = toDataView(binaryData);
|
|
9502
|
-
return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView) || getISOBMFFMetadata(dataView);
|
|
9503
|
-
}
|
|
9504
|
-
function getISOBMFFMetadata(binaryData) {
|
|
9505
|
-
const buffer = new Uint8Array(binaryData instanceof DataView ? binaryData.buffer : binaryData);
|
|
9506
|
-
const mediaType = getISOBMFFMediaType(buffer);
|
|
9507
|
-
if (!mediaType) {
|
|
9508
|
-
return null;
|
|
9509
|
-
}
|
|
9510
|
-
return {
|
|
9511
|
-
mimeType: mediaType.mimeType,
|
|
9512
|
-
width: 0,
|
|
9513
|
-
height: 0
|
|
9514
|
-
};
|
|
9515
|
-
}
|
|
9516
|
-
function getPngMetadata(binaryData) {
|
|
9517
|
-
const dataView = toDataView(binaryData);
|
|
9518
|
-
const isPng = dataView.byteLength >= 24 && dataView.getUint32(0, BIG_ENDIAN) === 2303741511;
|
|
9519
|
-
if (!isPng) {
|
|
9520
|
-
return null;
|
|
9521
|
-
}
|
|
9522
|
-
return {
|
|
9523
|
-
mimeType: "image/png",
|
|
9524
|
-
width: dataView.getUint32(16, BIG_ENDIAN),
|
|
9525
|
-
height: dataView.getUint32(20, BIG_ENDIAN)
|
|
9526
|
-
};
|
|
9527
|
-
}
|
|
9528
|
-
function getGifMetadata(binaryData) {
|
|
9529
|
-
const dataView = toDataView(binaryData);
|
|
9530
|
-
const isGif = dataView.byteLength >= 10 && dataView.getUint32(0, BIG_ENDIAN) === 1195984440;
|
|
9531
|
-
if (!isGif) {
|
|
9532
|
-
return null;
|
|
9533
|
-
}
|
|
9534
|
-
return {
|
|
9535
|
-
mimeType: "image/gif",
|
|
9536
|
-
width: dataView.getUint16(6, LITTLE_ENDIAN),
|
|
9537
|
-
height: dataView.getUint16(8, LITTLE_ENDIAN)
|
|
9538
|
-
};
|
|
9539
|
-
}
|
|
9540
|
-
function getBmpMetadata(binaryData) {
|
|
9541
|
-
const dataView = toDataView(binaryData);
|
|
9542
|
-
const isBmp = dataView.byteLength >= 14 && dataView.getUint16(0, BIG_ENDIAN) === 16973 && dataView.getUint32(2, LITTLE_ENDIAN) === dataView.byteLength;
|
|
9543
|
-
if (!isBmp) {
|
|
9544
|
-
return null;
|
|
9545
|
-
}
|
|
9546
|
-
return {
|
|
9547
|
-
mimeType: "image/bmp",
|
|
9548
|
-
width: dataView.getUint32(18, LITTLE_ENDIAN),
|
|
9549
|
-
height: dataView.getUint32(22, LITTLE_ENDIAN)
|
|
9550
|
-
};
|
|
9113
|
+
return {
|
|
9114
|
+
mimeType: "image/bmp",
|
|
9115
|
+
width: dataView.getUint32(18, LITTLE_ENDIAN),
|
|
9116
|
+
height: dataView.getUint32(22, LITTLE_ENDIAN)
|
|
9117
|
+
};
|
|
9551
9118
|
}
|
|
9552
9119
|
function getJpegMetadata(binaryData) {
|
|
9553
9120
|
const dataView = toDataView(binaryData);
|
|
@@ -9618,150 +9185,612 @@
|
|
|
9618
9185
|
}
|
|
9619
9186
|
});
|
|
9620
9187
|
|
|
9621
|
-
// ../images/src/lib/parsers/parse-to-node-image.ts
|
|
9622
|
-
async function parseToNodeImage(arrayBuffer, options) {
|
|
9623
|
-
const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
|
|
9624
|
-
const _parseImageNode2 = globalThis._parseImageNode;
|
|
9625
|
-
assert2(_parseImageNode2);
|
|
9626
|
-
return await _parseImageNode2(arrayBuffer, mimeType);
|
|
9188
|
+
// ../images/src/lib/parsers/parse-to-node-image.ts
|
|
9189
|
+
async function parseToNodeImage(arrayBuffer, options) {
|
|
9190
|
+
const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
|
|
9191
|
+
const _parseImageNode2 = globalThis._parseImageNode;
|
|
9192
|
+
assert2(_parseImageNode2);
|
|
9193
|
+
return await _parseImageNode2(arrayBuffer, mimeType);
|
|
9194
|
+
}
|
|
9195
|
+
var init_parse_to_node_image = __esm({
|
|
9196
|
+
"../images/src/lib/parsers/parse-to-node-image.ts"() {
|
|
9197
|
+
init_src2();
|
|
9198
|
+
init_binary_image_api();
|
|
9199
|
+
}
|
|
9200
|
+
});
|
|
9201
|
+
|
|
9202
|
+
// ../images/src/lib/parsers/parse-image.ts
|
|
9203
|
+
async function parseImage(arrayBuffer, options, context) {
|
|
9204
|
+
options = options || {};
|
|
9205
|
+
const imageOptions = options.image || {};
|
|
9206
|
+
const imageType = imageOptions.type || "auto";
|
|
9207
|
+
const { url } = context || {};
|
|
9208
|
+
const loadType = getLoadableImageType(imageType);
|
|
9209
|
+
let image;
|
|
9210
|
+
switch (loadType) {
|
|
9211
|
+
case "imagebitmap":
|
|
9212
|
+
image = await parseToImageBitmap(arrayBuffer, options, url);
|
|
9213
|
+
break;
|
|
9214
|
+
case "image":
|
|
9215
|
+
image = await parseToImage(arrayBuffer, options, url);
|
|
9216
|
+
break;
|
|
9217
|
+
case "data":
|
|
9218
|
+
image = await parseToNodeImage(arrayBuffer, options);
|
|
9219
|
+
break;
|
|
9220
|
+
default:
|
|
9221
|
+
assert2(false);
|
|
9222
|
+
}
|
|
9223
|
+
if (imageType === "data") {
|
|
9224
|
+
image = getImageData(image);
|
|
9225
|
+
}
|
|
9226
|
+
return image;
|
|
9227
|
+
}
|
|
9228
|
+
function getLoadableImageType(type) {
|
|
9229
|
+
switch (type) {
|
|
9230
|
+
case "auto":
|
|
9231
|
+
case "data":
|
|
9232
|
+
return getDefaultImageType();
|
|
9233
|
+
default:
|
|
9234
|
+
isImageTypeSupported(type);
|
|
9235
|
+
return type;
|
|
9236
|
+
}
|
|
9237
|
+
}
|
|
9238
|
+
var init_parse_image = __esm({
|
|
9239
|
+
"../images/src/lib/parsers/parse-image.ts"() {
|
|
9240
|
+
init_src2();
|
|
9241
|
+
init_image_type();
|
|
9242
|
+
init_parsed_image_api();
|
|
9243
|
+
init_parse_to_image();
|
|
9244
|
+
init_parse_to_image_bitmap();
|
|
9245
|
+
init_parse_to_node_image();
|
|
9246
|
+
}
|
|
9247
|
+
});
|
|
9248
|
+
|
|
9249
|
+
// ../images/src/image-loader.ts
|
|
9250
|
+
var EXTENSIONS, MIME_TYPES, DEFAULT_IMAGE_LOADER_OPTIONS, ImageLoader;
|
|
9251
|
+
var init_image_loader = __esm({
|
|
9252
|
+
"../images/src/image-loader.ts"() {
|
|
9253
|
+
init_version5();
|
|
9254
|
+
init_parse_image();
|
|
9255
|
+
init_binary_image_api();
|
|
9256
|
+
EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
|
|
9257
|
+
MIME_TYPES = [
|
|
9258
|
+
"image/png",
|
|
9259
|
+
"image/jpeg",
|
|
9260
|
+
"image/gif",
|
|
9261
|
+
"image/webp",
|
|
9262
|
+
"image/avif",
|
|
9263
|
+
"image/bmp",
|
|
9264
|
+
"image/vnd.microsoft.icon",
|
|
9265
|
+
"image/svg+xml"
|
|
9266
|
+
];
|
|
9267
|
+
DEFAULT_IMAGE_LOADER_OPTIONS = {
|
|
9268
|
+
image: {
|
|
9269
|
+
type: "auto",
|
|
9270
|
+
decode: true
|
|
9271
|
+
}
|
|
9272
|
+
};
|
|
9273
|
+
ImageLoader = {
|
|
9274
|
+
id: "image",
|
|
9275
|
+
module: "images",
|
|
9276
|
+
name: "Images",
|
|
9277
|
+
version: VERSION7,
|
|
9278
|
+
mimeTypes: MIME_TYPES,
|
|
9279
|
+
extensions: EXTENSIONS,
|
|
9280
|
+
parse: parseImage,
|
|
9281
|
+
tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
|
|
9282
|
+
options: DEFAULT_IMAGE_LOADER_OPTIONS
|
|
9283
|
+
};
|
|
9284
|
+
}
|
|
9285
|
+
});
|
|
9286
|
+
|
|
9287
|
+
// ../images/src/lib/category-api/image-format.ts
|
|
9288
|
+
function isImageFormatSupported(mimeType) {
|
|
9289
|
+
if (mimeTypeSupportedSync[mimeType] === void 0) {
|
|
9290
|
+
const supported = isBrowser ? checkBrowserImageFormatSupport(mimeType) : checkNodeImageFormatSupport(mimeType);
|
|
9291
|
+
mimeTypeSupportedSync[mimeType] = supported;
|
|
9292
|
+
}
|
|
9293
|
+
return mimeTypeSupportedSync[mimeType];
|
|
9294
|
+
}
|
|
9295
|
+
function checkNodeImageFormatSupport(mimeType) {
|
|
9296
|
+
const NODE_FORMAT_SUPPORT = ["image/png", "image/jpeg", "image/gif"];
|
|
9297
|
+
const { _parseImageNode: _parseImageNode2, _imageFormatsNode = NODE_FORMAT_SUPPORT } = globalThis;
|
|
9298
|
+
return Boolean(_parseImageNode2) && _imageFormatsNode.includes(mimeType);
|
|
9299
|
+
}
|
|
9300
|
+
function checkBrowserImageFormatSupport(mimeType) {
|
|
9301
|
+
switch (mimeType) {
|
|
9302
|
+
case "image/avif":
|
|
9303
|
+
case "image/webp":
|
|
9304
|
+
return testBrowserImageFormatSupport(mimeType);
|
|
9305
|
+
default:
|
|
9306
|
+
return true;
|
|
9307
|
+
}
|
|
9308
|
+
}
|
|
9309
|
+
function testBrowserImageFormatSupport(mimeType) {
|
|
9310
|
+
try {
|
|
9311
|
+
const element = document.createElement("canvas");
|
|
9312
|
+
const dataURL = element.toDataURL(mimeType);
|
|
9313
|
+
return dataURL.indexOf(`data:${mimeType}`) === 0;
|
|
9314
|
+
} catch {
|
|
9315
|
+
return false;
|
|
9316
|
+
}
|
|
9317
|
+
}
|
|
9318
|
+
var mimeTypeSupportedSync;
|
|
9319
|
+
var init_image_format = __esm({
|
|
9320
|
+
"../images/src/lib/category-api/image-format.ts"() {
|
|
9321
|
+
init_src2();
|
|
9322
|
+
mimeTypeSupportedSync = {};
|
|
9323
|
+
}
|
|
9324
|
+
});
|
|
9325
|
+
|
|
9326
|
+
// ../images/src/index.ts
|
|
9327
|
+
var init_src8 = __esm({
|
|
9328
|
+
"../images/src/index.ts"() {
|
|
9329
|
+
init_image_loader();
|
|
9330
|
+
init_binary_image_api();
|
|
9331
|
+
init_image_format();
|
|
9332
|
+
}
|
|
9333
|
+
});
|
|
9334
|
+
|
|
9335
|
+
// ../textures/src/lib/utils/version.ts
|
|
9336
|
+
var VERSION8;
|
|
9337
|
+
var init_version6 = __esm({
|
|
9338
|
+
"../textures/src/lib/utils/version.ts"() {
|
|
9339
|
+
VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
9340
|
+
}
|
|
9341
|
+
});
|
|
9342
|
+
|
|
9343
|
+
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
9344
|
+
async function loadBasisTrascoderModule(options) {
|
|
9345
|
+
const modules = options.modules || {};
|
|
9346
|
+
if (modules.basis) {
|
|
9347
|
+
return modules.basis;
|
|
9348
|
+
}
|
|
9349
|
+
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTrascoder(options);
|
|
9350
|
+
return await loadBasisTranscoderPromise;
|
|
9351
|
+
}
|
|
9352
|
+
async function loadBasisTrascoder(options) {
|
|
9353
|
+
let BASIS = null;
|
|
9354
|
+
let wasmBinary = null;
|
|
9355
|
+
[BASIS, wasmBinary] = await Promise.all([
|
|
9356
|
+
await loadLibrary("basis_transcoder.js", "textures", options),
|
|
9357
|
+
await loadLibrary("basis_transcoder.wasm", "textures", options)
|
|
9358
|
+
]);
|
|
9359
|
+
BASIS = BASIS || globalThis.BASIS;
|
|
9360
|
+
return await initializeBasisTrascoderModule(BASIS, wasmBinary);
|
|
9361
|
+
}
|
|
9362
|
+
function initializeBasisTrascoderModule(BasisModule, wasmBinary) {
|
|
9363
|
+
const options = {};
|
|
9364
|
+
if (wasmBinary) {
|
|
9365
|
+
options.wasmBinary = wasmBinary;
|
|
9366
|
+
}
|
|
9367
|
+
return new Promise((resolve2) => {
|
|
9368
|
+
BasisModule(options).then((module) => {
|
|
9369
|
+
const { BasisFile, initializeBasis } = module;
|
|
9370
|
+
initializeBasis();
|
|
9371
|
+
resolve2({ BasisFile });
|
|
9372
|
+
});
|
|
9373
|
+
});
|
|
9374
|
+
}
|
|
9375
|
+
async function loadBasisEncoderModule(options) {
|
|
9376
|
+
const modules = options.modules || {};
|
|
9377
|
+
if (modules.basisEncoder) {
|
|
9378
|
+
return modules.basisEncoder;
|
|
9379
|
+
}
|
|
9380
|
+
loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
|
|
9381
|
+
return await loadBasisEncoderPromise;
|
|
9382
|
+
}
|
|
9383
|
+
async function loadBasisEncoder(options) {
|
|
9384
|
+
let BASIS_ENCODER = null;
|
|
9385
|
+
let wasmBinary = null;
|
|
9386
|
+
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
9387
|
+
await loadLibrary(BASIS_CDN_ENCODER_JS, "textures", options),
|
|
9388
|
+
await loadLibrary(BASIS_CDN_ENCODER_WASM, "textures", options)
|
|
9389
|
+
]);
|
|
9390
|
+
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
9391
|
+
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
9392
|
+
}
|
|
9393
|
+
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
9394
|
+
const options = {};
|
|
9395
|
+
if (wasmBinary) {
|
|
9396
|
+
options.wasmBinary = wasmBinary;
|
|
9397
|
+
}
|
|
9398
|
+
return new Promise((resolve2) => {
|
|
9399
|
+
BasisEncoderModule(options).then((module) => {
|
|
9400
|
+
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
9401
|
+
initializeBasis();
|
|
9402
|
+
resolve2({ BasisFile, KTX2File, BasisEncoder });
|
|
9403
|
+
});
|
|
9404
|
+
});
|
|
9405
|
+
}
|
|
9406
|
+
var VERSION9, BASIS_CDN_ENCODER_WASM, BASIS_CDN_ENCODER_JS, loadBasisTranscoderPromise, loadBasisEncoderPromise;
|
|
9407
|
+
var init_basis_module_loader = __esm({
|
|
9408
|
+
"../textures/src/lib/parsers/basis-module-loader.ts"() {
|
|
9409
|
+
init_src();
|
|
9410
|
+
VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
9411
|
+
BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION9}/dist/libs/basis_encoder.wasm`;
|
|
9412
|
+
BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION9}/dist/libs/basis_encoder.js`;
|
|
9413
|
+
}
|
|
9414
|
+
});
|
|
9415
|
+
|
|
9416
|
+
// ../textures/src/lib/gl-extensions.ts
|
|
9417
|
+
var GL_EXTENSIONS_CONSTANTS;
|
|
9418
|
+
var init_gl_extensions = __esm({
|
|
9419
|
+
"../textures/src/lib/gl-extensions.ts"() {
|
|
9420
|
+
GL_EXTENSIONS_CONSTANTS = {
|
|
9421
|
+
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
|
|
9422
|
+
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
|
|
9423
|
+
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
|
|
9424
|
+
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
|
|
9425
|
+
COMPRESSED_R11_EAC: 37488,
|
|
9426
|
+
COMPRESSED_SIGNED_R11_EAC: 37489,
|
|
9427
|
+
COMPRESSED_RG11_EAC: 37490,
|
|
9428
|
+
COMPRESSED_SIGNED_RG11_EAC: 37491,
|
|
9429
|
+
COMPRESSED_RGB8_ETC2: 37492,
|
|
9430
|
+
COMPRESSED_RGBA8_ETC2_EAC: 37493,
|
|
9431
|
+
COMPRESSED_SRGB8_ETC2: 37494,
|
|
9432
|
+
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
9433
|
+
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
9434
|
+
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
9435
|
+
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
9436
|
+
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
9437
|
+
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
9438
|
+
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
9439
|
+
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
9440
|
+
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
9441
|
+
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
9442
|
+
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
9443
|
+
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
9444
|
+
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
9445
|
+
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
9446
|
+
COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
|
|
9447
|
+
COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
|
|
9448
|
+
COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
|
|
9449
|
+
COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
|
|
9450
|
+
COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
|
|
9451
|
+
COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
|
|
9452
|
+
COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
|
|
9453
|
+
COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
|
|
9454
|
+
COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
|
|
9455
|
+
COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
|
|
9456
|
+
COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
|
|
9457
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
|
|
9458
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
|
|
9459
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
|
|
9460
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
|
|
9461
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
|
|
9462
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
|
|
9463
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
|
|
9464
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
|
|
9465
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
|
|
9466
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
|
|
9467
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
|
|
9468
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
9469
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
9470
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
9471
|
+
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
9472
|
+
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
9473
|
+
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
9474
|
+
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
9475
|
+
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
9476
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
9477
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
9478
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
|
|
9479
|
+
};
|
|
9480
|
+
}
|
|
9481
|
+
});
|
|
9482
|
+
|
|
9483
|
+
// ../textures/src/lib/utils/texture-formats.ts
|
|
9484
|
+
function getSupportedGPUTextureFormats(gl) {
|
|
9485
|
+
if (!formats) {
|
|
9486
|
+
gl = gl || getWebGLContext() || void 0;
|
|
9487
|
+
formats = new Set();
|
|
9488
|
+
for (const prefix of BROWSER_PREFIXES) {
|
|
9489
|
+
for (const extension in WEBGL_EXTENSIONS) {
|
|
9490
|
+
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
9491
|
+
const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
|
|
9492
|
+
formats.add(gpuTextureFormat);
|
|
9493
|
+
}
|
|
9494
|
+
}
|
|
9495
|
+
}
|
|
9496
|
+
}
|
|
9497
|
+
return formats;
|
|
9498
|
+
}
|
|
9499
|
+
function getWebGLContext() {
|
|
9500
|
+
try {
|
|
9501
|
+
const canvas = document.createElement("canvas");
|
|
9502
|
+
return canvas.getContext("webgl");
|
|
9503
|
+
} catch (error) {
|
|
9504
|
+
return null;
|
|
9505
|
+
}
|
|
9506
|
+
}
|
|
9507
|
+
var BROWSER_PREFIXES, WEBGL_EXTENSIONS, formats;
|
|
9508
|
+
var init_texture_formats = __esm({
|
|
9509
|
+
"../textures/src/lib/utils/texture-formats.ts"() {
|
|
9510
|
+
BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
9511
|
+
WEBGL_EXTENSIONS = {
|
|
9512
|
+
WEBGL_compressed_texture_s3tc: "dxt",
|
|
9513
|
+
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
9514
|
+
WEBGL_compressed_texture_etc1: "etc1",
|
|
9515
|
+
WEBGL_compressed_texture_etc: "etc2",
|
|
9516
|
+
WEBGL_compressed_texture_pvrtc: "pvrtc",
|
|
9517
|
+
WEBGL_compressed_texture_atc: "atc",
|
|
9518
|
+
WEBGL_compressed_texture_astc: "astc",
|
|
9519
|
+
EXT_texture_compression_rgtc: "rgtc"
|
|
9520
|
+
};
|
|
9521
|
+
formats = null;
|
|
9522
|
+
}
|
|
9523
|
+
});
|
|
9524
|
+
|
|
9525
|
+
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
9526
|
+
var t, n, i, s, a, r, o, l, f;
|
|
9527
|
+
var init_ktx_parse_modern = __esm({
|
|
9528
|
+
"../../node_modules/ktx-parse/dist/ktx-parse.modern.js"() {
|
|
9529
|
+
t = new Uint8Array([0]);
|
|
9530
|
+
!function(t2) {
|
|
9531
|
+
t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
|
|
9532
|
+
}(n || (n = {})), function(t2) {
|
|
9533
|
+
t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
|
|
9534
|
+
}(i || (i = {})), function(t2) {
|
|
9535
|
+
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
|
|
9536
|
+
}(s || (s = {})), function(t2) {
|
|
9537
|
+
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
|
|
9538
|
+
}(a || (a = {})), function(t2) {
|
|
9539
|
+
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.LINEAR = 1] = "LINEAR", t2[t2.SRGB = 2] = "SRGB", t2[t2.ITU = 3] = "ITU", t2[t2.NTSC = 4] = "NTSC", t2[t2.SLOG = 5] = "SLOG", t2[t2.SLOG2 = 6] = "SLOG2";
|
|
9540
|
+
}(r || (r = {})), function(t2) {
|
|
9541
|
+
t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
|
|
9542
|
+
}(o || (o = {})), function(t2) {
|
|
9543
|
+
t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
|
|
9544
|
+
}(l || (l = {})), function(t2) {
|
|
9545
|
+
t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
|
|
9546
|
+
}(f || (f = {}));
|
|
9547
|
+
}
|
|
9548
|
+
});
|
|
9549
|
+
|
|
9550
|
+
// ../textures/src/lib/parsers/parse-ktx.ts
|
|
9551
|
+
function isKTX(data) {
|
|
9552
|
+
const id = new Uint8Array(data);
|
|
9553
|
+
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || id[1] !== KTX2_ID[1] || id[2] !== KTX2_ID[2] || id[3] !== KTX2_ID[3] || id[4] !== KTX2_ID[4] || id[5] !== KTX2_ID[5] || id[6] !== KTX2_ID[6] || id[7] !== KTX2_ID[7] || id[8] !== KTX2_ID[8] || id[9] !== KTX2_ID[9] || id[10] !== KTX2_ID[10] || id[11] !== KTX2_ID[11];
|
|
9554
|
+
return !notKTX;
|
|
9627
9555
|
}
|
|
9628
|
-
var
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9556
|
+
var KTX2_ID;
|
|
9557
|
+
var init_parse_ktx = __esm({
|
|
9558
|
+
"../textures/src/lib/parsers/parse-ktx.ts"() {
|
|
9559
|
+
init_ktx_parse_modern();
|
|
9560
|
+
KTX2_ID = [
|
|
9561
|
+
171,
|
|
9562
|
+
75,
|
|
9563
|
+
84,
|
|
9564
|
+
88,
|
|
9565
|
+
32,
|
|
9566
|
+
50,
|
|
9567
|
+
48,
|
|
9568
|
+
187,
|
|
9569
|
+
13,
|
|
9570
|
+
10,
|
|
9571
|
+
26,
|
|
9572
|
+
10
|
|
9573
|
+
];
|
|
9632
9574
|
}
|
|
9633
9575
|
});
|
|
9634
9576
|
|
|
9635
|
-
// ../
|
|
9636
|
-
async function
|
|
9637
|
-
options
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
case "imagebitmap":
|
|
9645
|
-
image = await parseToImageBitmap(arrayBuffer, options, url);
|
|
9646
|
-
break;
|
|
9647
|
-
case "image":
|
|
9648
|
-
image = await parseToImage(arrayBuffer, options, url);
|
|
9649
|
-
break;
|
|
9650
|
-
case "data":
|
|
9651
|
-
image = await parseToNodeImage(arrayBuffer, options);
|
|
9652
|
-
break;
|
|
9653
|
-
default:
|
|
9654
|
-
assert2(false);
|
|
9655
|
-
}
|
|
9656
|
-
if (imageType === "data") {
|
|
9657
|
-
image = getImageData(image);
|
|
9577
|
+
// ../textures/src/lib/parsers/parse-basis.ts
|
|
9578
|
+
async function parseBasis(data, options) {
|
|
9579
|
+
if (options.basis.containerFormat === "auto") {
|
|
9580
|
+
if (isKTX(data)) {
|
|
9581
|
+
const fileConstructors = await loadBasisEncoderModule(options);
|
|
9582
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
9583
|
+
}
|
|
9584
|
+
const { BasisFile } = await loadBasisTrascoderModule(options);
|
|
9585
|
+
return parseBasisFile(BasisFile, data, options);
|
|
9658
9586
|
}
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9587
|
+
switch (options.basis.module) {
|
|
9588
|
+
case "encoder":
|
|
9589
|
+
const fileConstructors = await loadBasisEncoderModule(options);
|
|
9590
|
+
switch (options.basis.containerFormat) {
|
|
9591
|
+
case "ktx2":
|
|
9592
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
9593
|
+
case "basis":
|
|
9594
|
+
default:
|
|
9595
|
+
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
9596
|
+
}
|
|
9597
|
+
case "transcoder":
|
|
9666
9598
|
default:
|
|
9667
|
-
|
|
9668
|
-
return
|
|
9599
|
+
const { BasisFile } = await loadBasisTrascoderModule(options);
|
|
9600
|
+
return parseBasisFile(BasisFile, data, options);
|
|
9669
9601
|
}
|
|
9670
9602
|
}
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
var init_image_loader = __esm({
|
|
9685
|
-
"../images/src/image-loader.ts"() {
|
|
9686
|
-
init_version6();
|
|
9687
|
-
init_parse_image();
|
|
9688
|
-
init_binary_image_api();
|
|
9689
|
-
EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
|
|
9690
|
-
MIME_TYPES = [
|
|
9691
|
-
"image/png",
|
|
9692
|
-
"image/jpeg",
|
|
9693
|
-
"image/gif",
|
|
9694
|
-
"image/webp",
|
|
9695
|
-
"image/avif",
|
|
9696
|
-
"image/bmp",
|
|
9697
|
-
"image/vnd.microsoft.icon",
|
|
9698
|
-
"image/svg+xml"
|
|
9699
|
-
];
|
|
9700
|
-
DEFAULT_IMAGE_LOADER_OPTIONS = {
|
|
9701
|
-
image: {
|
|
9702
|
-
type: "auto",
|
|
9703
|
-
decode: true
|
|
9603
|
+
function parseBasisFile(BasisFile, data, options) {
|
|
9604
|
+
const basisFile = new BasisFile(new Uint8Array(data));
|
|
9605
|
+
try {
|
|
9606
|
+
if (!basisFile.startTranscoding()) {
|
|
9607
|
+
throw new Error("Failed to start basis transcoding");
|
|
9608
|
+
}
|
|
9609
|
+
const imageCount = basisFile.getNumImages();
|
|
9610
|
+
const images = [];
|
|
9611
|
+
for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
|
|
9612
|
+
const levelsCount = basisFile.getNumLevels(imageIndex);
|
|
9613
|
+
const levels = [];
|
|
9614
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
9615
|
+
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
9704
9616
|
}
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
mimeTypes: MIME_TYPES,
|
|
9712
|
-
extensions: EXTENSIONS,
|
|
9713
|
-
parse: parseImage,
|
|
9714
|
-
tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
|
|
9715
|
-
options: DEFAULT_IMAGE_LOADER_OPTIONS
|
|
9716
|
-
};
|
|
9617
|
+
images.push(levels);
|
|
9618
|
+
}
|
|
9619
|
+
return images;
|
|
9620
|
+
} finally {
|
|
9621
|
+
basisFile.close();
|
|
9622
|
+
basisFile.delete();
|
|
9717
9623
|
}
|
|
9718
|
-
}
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9624
|
+
}
|
|
9625
|
+
function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
9626
|
+
const width = basisFile.getImageWidth(imageIndex, levelIndex);
|
|
9627
|
+
const height = basisFile.getImageHeight(imageIndex, levelIndex);
|
|
9628
|
+
const hasAlpha = basisFile.getHasAlpha();
|
|
9629
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
9630
|
+
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
9631
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
9632
|
+
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
9633
|
+
throw new Error("failed to start Basis transcoding");
|
|
9725
9634
|
}
|
|
9726
|
-
return
|
|
9635
|
+
return {
|
|
9636
|
+
width,
|
|
9637
|
+
height,
|
|
9638
|
+
data: decodedData,
|
|
9639
|
+
compressed,
|
|
9640
|
+
format,
|
|
9641
|
+
hasAlpha
|
|
9642
|
+
};
|
|
9727
9643
|
}
|
|
9728
|
-
function
|
|
9729
|
-
const
|
|
9730
|
-
|
|
9731
|
-
|
|
9644
|
+
function parseKTX2File(KTX2File, data, options) {
|
|
9645
|
+
const ktx2File = new KTX2File(new Uint8Array(data));
|
|
9646
|
+
try {
|
|
9647
|
+
if (!ktx2File.startTranscoding()) {
|
|
9648
|
+
throw new Error("failed to start KTX2 transcoding");
|
|
9649
|
+
}
|
|
9650
|
+
const levelsCount = ktx2File.getLevels();
|
|
9651
|
+
const levels = [];
|
|
9652
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
9653
|
+
levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
|
|
9654
|
+
break;
|
|
9655
|
+
}
|
|
9656
|
+
return [levels];
|
|
9657
|
+
} finally {
|
|
9658
|
+
ktx2File.close();
|
|
9659
|
+
ktx2File.delete();
|
|
9660
|
+
}
|
|
9732
9661
|
}
|
|
9733
|
-
function
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9662
|
+
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
9663
|
+
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
9664
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
|
|
9665
|
+
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
9666
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
9667
|
+
if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
|
|
9668
|
+
throw new Error("Failed to transcode KTX2 image");
|
|
9669
|
+
}
|
|
9670
|
+
return {
|
|
9671
|
+
width,
|
|
9672
|
+
height,
|
|
9673
|
+
data: decodedData,
|
|
9674
|
+
compressed,
|
|
9675
|
+
levelSize: decodedSize,
|
|
9676
|
+
hasAlpha: alphaFlag,
|
|
9677
|
+
format
|
|
9678
|
+
};
|
|
9679
|
+
}
|
|
9680
|
+
function getBasisOptions(options, hasAlpha) {
|
|
9681
|
+
let format = options && options.basis && options.basis.format;
|
|
9682
|
+
if (format === "auto") {
|
|
9683
|
+
format = selectSupportedBasisFormat();
|
|
9740
9684
|
}
|
|
9685
|
+
if (typeof format === "object") {
|
|
9686
|
+
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
9687
|
+
}
|
|
9688
|
+
format = format.toLowerCase();
|
|
9689
|
+
return OutputFormat[format];
|
|
9741
9690
|
}
|
|
9742
|
-
function
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9691
|
+
function selectSupportedBasisFormat() {
|
|
9692
|
+
const supportedFormats = getSupportedGPUTextureFormats();
|
|
9693
|
+
if (supportedFormats.has("astc")) {
|
|
9694
|
+
return "astc-4x4";
|
|
9695
|
+
} else if (supportedFormats.has("dxt")) {
|
|
9696
|
+
return {
|
|
9697
|
+
alpha: "bc3",
|
|
9698
|
+
noAlpha: "bc1"
|
|
9699
|
+
};
|
|
9700
|
+
} else if (supportedFormats.has("pvrtc")) {
|
|
9701
|
+
return {
|
|
9702
|
+
alpha: "pvrtc1-4-rgba",
|
|
9703
|
+
noAlpha: "pvrtc1-4-rgb"
|
|
9704
|
+
};
|
|
9705
|
+
} else if (supportedFormats.has("etc1")) {
|
|
9706
|
+
return "etc1";
|
|
9707
|
+
} else if (supportedFormats.has("etc2")) {
|
|
9708
|
+
return "etc2";
|
|
9749
9709
|
}
|
|
9710
|
+
return "rgb565";
|
|
9750
9711
|
}
|
|
9751
|
-
var
|
|
9752
|
-
var
|
|
9753
|
-
"../
|
|
9754
|
-
|
|
9755
|
-
|
|
9712
|
+
var OutputFormat;
|
|
9713
|
+
var init_parse_basis = __esm({
|
|
9714
|
+
"../textures/src/lib/parsers/parse-basis.ts"() {
|
|
9715
|
+
init_basis_module_loader();
|
|
9716
|
+
init_gl_extensions();
|
|
9717
|
+
init_texture_formats();
|
|
9718
|
+
init_parse_ktx();
|
|
9719
|
+
OutputFormat = {
|
|
9720
|
+
etc1: {
|
|
9721
|
+
basisFormat: 0,
|
|
9722
|
+
compressed: true,
|
|
9723
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
9724
|
+
},
|
|
9725
|
+
etc2: { basisFormat: 1, compressed: true },
|
|
9726
|
+
bc1: {
|
|
9727
|
+
basisFormat: 2,
|
|
9728
|
+
compressed: true,
|
|
9729
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
|
|
9730
|
+
},
|
|
9731
|
+
bc3: {
|
|
9732
|
+
basisFormat: 3,
|
|
9733
|
+
compressed: true,
|
|
9734
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
9735
|
+
},
|
|
9736
|
+
bc4: { basisFormat: 4, compressed: true },
|
|
9737
|
+
bc5: { basisFormat: 5, compressed: true },
|
|
9738
|
+
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
9739
|
+
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
9740
|
+
"pvrtc1-4-rgb": {
|
|
9741
|
+
basisFormat: 8,
|
|
9742
|
+
compressed: true,
|
|
9743
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
|
9744
|
+
},
|
|
9745
|
+
"pvrtc1-4-rgba": {
|
|
9746
|
+
basisFormat: 9,
|
|
9747
|
+
compressed: true,
|
|
9748
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
|
9749
|
+
},
|
|
9750
|
+
"astc-4x4": {
|
|
9751
|
+
basisFormat: 10,
|
|
9752
|
+
compressed: true,
|
|
9753
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
9754
|
+
},
|
|
9755
|
+
"atc-rgb": { basisFormat: 11, compressed: true },
|
|
9756
|
+
"atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
|
|
9757
|
+
rgba32: { basisFormat: 13, compressed: false },
|
|
9758
|
+
rgb565: { basisFormat: 14, compressed: false },
|
|
9759
|
+
bgr565: { basisFormat: 15, compressed: false },
|
|
9760
|
+
rgba4444: { basisFormat: 16, compressed: false }
|
|
9761
|
+
};
|
|
9756
9762
|
}
|
|
9757
9763
|
});
|
|
9758
9764
|
|
|
9759
|
-
// ../
|
|
9760
|
-
var
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
+
// ../textures/src/basis-loader.ts
|
|
9766
|
+
var BasisWorkerLoader, BasisLoader;
|
|
9767
|
+
var init_basis_loader = __esm({
|
|
9768
|
+
"../textures/src/basis-loader.ts"() {
|
|
9769
|
+
init_version6();
|
|
9770
|
+
init_parse_basis();
|
|
9771
|
+
BasisWorkerLoader = {
|
|
9772
|
+
name: "Basis",
|
|
9773
|
+
id: "basis",
|
|
9774
|
+
module: "textures",
|
|
9775
|
+
version: VERSION8,
|
|
9776
|
+
worker: true,
|
|
9777
|
+
extensions: ["basis", "ktx2"],
|
|
9778
|
+
mimeTypes: ["application/octet-stream", "image/ktx2"],
|
|
9779
|
+
tests: ["sB"],
|
|
9780
|
+
binary: true,
|
|
9781
|
+
options: {
|
|
9782
|
+
basis: {
|
|
9783
|
+
format: "auto",
|
|
9784
|
+
libraryPath: "libs/",
|
|
9785
|
+
containerFormat: "auto",
|
|
9786
|
+
module: "transcoder"
|
|
9787
|
+
}
|
|
9788
|
+
}
|
|
9789
|
+
};
|
|
9790
|
+
BasisLoader = {
|
|
9791
|
+
...BasisWorkerLoader,
|
|
9792
|
+
parse: parseBasis
|
|
9793
|
+
};
|
|
9765
9794
|
}
|
|
9766
9795
|
});
|
|
9767
9796
|
|
|
@@ -9784,6 +9813,119 @@
|
|
|
9784
9813
|
}
|
|
9785
9814
|
});
|
|
9786
9815
|
|
|
9816
|
+
// ../gltf/src/lib/parsers/parse-glb.ts
|
|
9817
|
+
function getMagicString4(dataView, byteOffset = 0) {
|
|
9818
|
+
return `${String.fromCharCode(dataView.getUint8(byteOffset + 0))}${String.fromCharCode(dataView.getUint8(byteOffset + 1))}${String.fromCharCode(dataView.getUint8(byteOffset + 2))}${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;
|
|
9819
|
+
}
|
|
9820
|
+
function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
|
|
9821
|
+
const dataView = new DataView(arrayBuffer);
|
|
9822
|
+
const { magic = MAGIC_glTF } = options;
|
|
9823
|
+
const magic1 = dataView.getUint32(byteOffset, false);
|
|
9824
|
+
return magic1 === magic || magic1 === MAGIC_glTF;
|
|
9825
|
+
}
|
|
9826
|
+
function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
|
|
9827
|
+
const dataView = new DataView(arrayBuffer);
|
|
9828
|
+
const type = getMagicString4(dataView, byteOffset + 0);
|
|
9829
|
+
const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
9830
|
+
const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
|
|
9831
|
+
Object.assign(glb, {
|
|
9832
|
+
header: {
|
|
9833
|
+
byteOffset,
|
|
9834
|
+
byteLength,
|
|
9835
|
+
hasBinChunk: false
|
|
9836
|
+
},
|
|
9837
|
+
type,
|
|
9838
|
+
version,
|
|
9839
|
+
json: {},
|
|
9840
|
+
binChunks: []
|
|
9841
|
+
});
|
|
9842
|
+
byteOffset += GLB_FILE_HEADER_SIZE;
|
|
9843
|
+
switch (glb.version) {
|
|
9844
|
+
case 1:
|
|
9845
|
+
return parseGLBV1(glb, dataView, byteOffset);
|
|
9846
|
+
case 2:
|
|
9847
|
+
return parseGLBV2(glb, dataView, byteOffset, options = {});
|
|
9848
|
+
default:
|
|
9849
|
+
throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);
|
|
9850
|
+
}
|
|
9851
|
+
}
|
|
9852
|
+
function parseGLBV1(glb, dataView, byteOffset) {
|
|
9853
|
+
assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
9854
|
+
const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
|
|
9855
|
+
const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
9856
|
+
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
9857
|
+
assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
|
|
9858
|
+
parseJSONChunk(glb, dataView, byteOffset, contentLength);
|
|
9859
|
+
byteOffset += contentLength;
|
|
9860
|
+
byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
|
|
9861
|
+
return byteOffset;
|
|
9862
|
+
}
|
|
9863
|
+
function parseGLBV2(glb, dataView, byteOffset, options) {
|
|
9864
|
+
assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
9865
|
+
parseGLBChunksSync(glb, dataView, byteOffset, options);
|
|
9866
|
+
return byteOffset + glb.header.byteLength;
|
|
9867
|
+
}
|
|
9868
|
+
function parseGLBChunksSync(glb, dataView, byteOffset, options) {
|
|
9869
|
+
while (byteOffset + 8 <= glb.header.byteLength) {
|
|
9870
|
+
const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
|
|
9871
|
+
const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
9872
|
+
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
9873
|
+
switch (chunkFormat) {
|
|
9874
|
+
case GLB_CHUNK_TYPE_JSON:
|
|
9875
|
+
parseJSONChunk(glb, dataView, byteOffset, chunkLength);
|
|
9876
|
+
break;
|
|
9877
|
+
case GLB_CHUNK_TYPE_BIN:
|
|
9878
|
+
parseBINChunk(glb, dataView, byteOffset, chunkLength);
|
|
9879
|
+
break;
|
|
9880
|
+
case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
|
|
9881
|
+
if (!options.strict) {
|
|
9882
|
+
parseJSONChunk(glb, dataView, byteOffset, chunkLength);
|
|
9883
|
+
}
|
|
9884
|
+
break;
|
|
9885
|
+
case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:
|
|
9886
|
+
if (!options.strict) {
|
|
9887
|
+
parseBINChunk(glb, dataView, byteOffset, chunkLength);
|
|
9888
|
+
}
|
|
9889
|
+
break;
|
|
9890
|
+
default:
|
|
9891
|
+
break;
|
|
9892
|
+
}
|
|
9893
|
+
byteOffset += padToNBytes(chunkLength, 4);
|
|
9894
|
+
}
|
|
9895
|
+
return byteOffset;
|
|
9896
|
+
}
|
|
9897
|
+
function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
|
|
9898
|
+
const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
|
|
9899
|
+
const textDecoder = new TextDecoder("utf8");
|
|
9900
|
+
const jsonText = textDecoder.decode(jsonChunk);
|
|
9901
|
+
glb.json = JSON.parse(jsonText);
|
|
9902
|
+
return padToNBytes(chunkLength, 4);
|
|
9903
|
+
}
|
|
9904
|
+
function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
|
|
9905
|
+
glb.header.hasBinChunk = true;
|
|
9906
|
+
glb.binChunks.push({
|
|
9907
|
+
byteOffset,
|
|
9908
|
+
byteLength: chunkLength,
|
|
9909
|
+
arrayBuffer: dataView.buffer
|
|
9910
|
+
});
|
|
9911
|
+
return padToNBytes(chunkLength, 4);
|
|
9912
|
+
}
|
|
9913
|
+
var LITTLE_ENDIAN2, MAGIC_glTF, GLB_FILE_HEADER_SIZE, GLB_CHUNK_HEADER_SIZE, GLB_CHUNK_TYPE_JSON, GLB_CHUNK_TYPE_BIN, GLB_V1_CONTENT_FORMAT_JSON, GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED, GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED;
|
|
9914
|
+
var init_parse_glb = __esm({
|
|
9915
|
+
"../gltf/src/lib/parsers/parse-glb.ts"() {
|
|
9916
|
+
init_src2();
|
|
9917
|
+
LITTLE_ENDIAN2 = true;
|
|
9918
|
+
MAGIC_glTF = 1735152710;
|
|
9919
|
+
GLB_FILE_HEADER_SIZE = 12;
|
|
9920
|
+
GLB_CHUNK_HEADER_SIZE = 8;
|
|
9921
|
+
GLB_CHUNK_TYPE_JSON = 1313821514;
|
|
9922
|
+
GLB_CHUNK_TYPE_BIN = 5130562;
|
|
9923
|
+
GLB_V1_CONTENT_FORMAT_JSON = 0;
|
|
9924
|
+
GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
|
|
9925
|
+
GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
|
|
9926
|
+
}
|
|
9927
|
+
});
|
|
9928
|
+
|
|
9787
9929
|
// ../gltf/src/lib/gltf-utils/resolve-url.ts
|
|
9788
9930
|
function resolveUrl(url, options) {
|
|
9789
9931
|
const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
|
|
@@ -9838,10 +9980,24 @@
|
|
|
9838
9980
|
assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
|
|
9839
9981
|
return { ArrayType, length: length4, byteLength };
|
|
9840
9982
|
}
|
|
9841
|
-
|
|
9983
|
+
function getMemoryUsageGLTF(gltf) {
|
|
9984
|
+
let { images, bufferViews } = gltf;
|
|
9985
|
+
images = images || [];
|
|
9986
|
+
bufferViews = bufferViews || [];
|
|
9987
|
+
const imageBufferViews = images.map((i2) => i2.bufferView);
|
|
9988
|
+
bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
|
|
9989
|
+
const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
|
|
9990
|
+
const pixelCount = images.reduce((acc, image) => {
|
|
9991
|
+
const { width, height } = image.image;
|
|
9992
|
+
return acc + width * height;
|
|
9993
|
+
}, 0);
|
|
9994
|
+
return bufferMemory + Math.ceil(4 * pixelCount * MIPMAP_FACTOR);
|
|
9995
|
+
}
|
|
9996
|
+
var MIPMAP_FACTOR, TYPES, ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT, ARRAY_TO_COMPONENT_TYPE, ATTRIBUTE_TYPE_TO_COMPONENTS, ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE, ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY;
|
|
9842
9997
|
var init_gltf_utils = __esm({
|
|
9843
9998
|
"../gltf/src/lib/gltf-utils/gltf-utils.ts"() {
|
|
9844
9999
|
init_assert6();
|
|
10000
|
+
MIPMAP_FACTOR = 1.33;
|
|
9845
10001
|
TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
|
|
9846
10002
|
ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
|
|
9847
10003
|
[Int8Array, 5120],
|
|
@@ -9882,25 +10038,30 @@
|
|
|
9882
10038
|
});
|
|
9883
10039
|
|
|
9884
10040
|
// ../gltf/src/lib/api/gltf-scenegraph.ts
|
|
9885
|
-
|
|
10041
|
+
function makeDefaultGLTFJson() {
|
|
10042
|
+
return {
|
|
10043
|
+
asset: {
|
|
10044
|
+
version: "2.0",
|
|
10045
|
+
generator: "loaders.gl"
|
|
10046
|
+
},
|
|
10047
|
+
buffers: [],
|
|
10048
|
+
extensions: {},
|
|
10049
|
+
extensionsRequired: [],
|
|
10050
|
+
extensionsUsed: []
|
|
10051
|
+
};
|
|
10052
|
+
}
|
|
10053
|
+
var GLTFScenegraph;
|
|
9886
10054
|
var init_gltf_scenegraph = __esm({
|
|
9887
10055
|
"../gltf/src/lib/api/gltf-scenegraph.ts"() {
|
|
9888
10056
|
init_src8();
|
|
9889
10057
|
init_src2();
|
|
9890
10058
|
init_assert6();
|
|
9891
10059
|
init_gltf_utils();
|
|
9892
|
-
DEFAULT_GLTF_JSON = {
|
|
9893
|
-
asset: {
|
|
9894
|
-
version: "2.0",
|
|
9895
|
-
generator: "loaders.gl"
|
|
9896
|
-
},
|
|
9897
|
-
buffers: []
|
|
9898
|
-
};
|
|
9899
10060
|
GLTFScenegraph = class {
|
|
9900
10061
|
constructor(gltf) {
|
|
9901
|
-
this.gltf =
|
|
9902
|
-
json:
|
|
9903
|
-
buffers: []
|
|
10062
|
+
this.gltf = {
|
|
10063
|
+
json: gltf?.json || makeDefaultGLTFJson(),
|
|
10064
|
+
buffers: gltf?.buffers || []
|
|
9904
10065
|
};
|
|
9905
10066
|
this.sourceBuffers = [];
|
|
9906
10067
|
this.byteLength = 0;
|
|
@@ -9920,10 +10081,15 @@
|
|
|
9920
10081
|
const extras = this.json.extras || {};
|
|
9921
10082
|
return extras[key];
|
|
9922
10083
|
}
|
|
10084
|
+
hasExtension(extensionName) {
|
|
10085
|
+
const isUsedExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
|
|
10086
|
+
const isRequiredExtension = this.getRequiredExtensions().find((name10) => name10 === extensionName);
|
|
10087
|
+
return typeof isUsedExtension === "string" || typeof isRequiredExtension === "string";
|
|
10088
|
+
}
|
|
9923
10089
|
getExtension(extensionName) {
|
|
9924
10090
|
const isExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
|
|
9925
10091
|
const extensions = this.json.extensions || {};
|
|
9926
|
-
return isExtension ? extensions[extensionName]
|
|
10092
|
+
return isExtension ? extensions[extensionName] : null;
|
|
9927
10093
|
}
|
|
9928
10094
|
getRequiredExtension(extensionName) {
|
|
9929
10095
|
const isRequired = this.getRequiredExtensions().find((name10) => name10 === extensionName);
|
|
@@ -10030,10 +10196,15 @@
|
|
|
10030
10196
|
extensions[extensionName] = data;
|
|
10031
10197
|
}
|
|
10032
10198
|
removeObjectExtension(object, extensionName) {
|
|
10033
|
-
const extensions = object
|
|
10034
|
-
|
|
10199
|
+
const extensions = object?.extensions || {};
|
|
10200
|
+
if (extensions[extensionName]) {
|
|
10201
|
+
this.json.extensionsRemoved = this.json.extensionsRemoved || [];
|
|
10202
|
+
const extensionsRemoved = this.json.extensionsRemoved;
|
|
10203
|
+
if (!extensionsRemoved.includes(extensionName)) {
|
|
10204
|
+
extensionsRemoved.push(extensionName);
|
|
10205
|
+
}
|
|
10206
|
+
}
|
|
10035
10207
|
delete extensions[extensionName];
|
|
10036
|
-
return extension;
|
|
10037
10208
|
}
|
|
10038
10209
|
addExtension(extensionName, extensionData = {}) {
|
|
10039
10210
|
assert7(extensionData);
|
|
@@ -10062,8 +10233,15 @@
|
|
|
10062
10233
|
}
|
|
10063
10234
|
}
|
|
10064
10235
|
removeExtension(extensionName) {
|
|
10065
|
-
if (
|
|
10066
|
-
|
|
10236
|
+
if (this.json.extensions?.[extensionName]) {
|
|
10237
|
+
this.json.extensionsRemoved = this.json.extensionsRemoved || [];
|
|
10238
|
+
const extensionsRemoved = this.json.extensionsRemoved;
|
|
10239
|
+
if (!extensionsRemoved.includes(extensionName)) {
|
|
10240
|
+
extensionsRemoved.push(extensionName);
|
|
10241
|
+
}
|
|
10242
|
+
}
|
|
10243
|
+
if (this.json.extensions) {
|
|
10244
|
+
delete this.json.extensions[extensionName];
|
|
10067
10245
|
}
|
|
10068
10246
|
if (this.json.extensionsRequired) {
|
|
10069
10247
|
this._removeStringFromArray(this.json.extensionsRequired, extensionName);
|
|
@@ -10071,16 +10249,6 @@
|
|
|
10071
10249
|
if (this.json.extensionsUsed) {
|
|
10072
10250
|
this._removeStringFromArray(this.json.extensionsUsed, extensionName);
|
|
10073
10251
|
}
|
|
10074
|
-
if (this.json.extensions) {
|
|
10075
|
-
delete this.json.extensions[extensionName];
|
|
10076
|
-
}
|
|
10077
|
-
if (!Array.isArray(this.json.extensionsRemoved)) {
|
|
10078
|
-
this.json.extensionsRemoved = [];
|
|
10079
|
-
}
|
|
10080
|
-
const extensionsRemoved = this.json.extensionsRemoved;
|
|
10081
|
-
if (!extensionsRemoved.includes(extensionName)) {
|
|
10082
|
-
extensionsRemoved.push(extensionName);
|
|
10083
|
-
}
|
|
10084
10252
|
}
|
|
10085
10253
|
setDefaultScene(sceneIndex) {
|
|
10086
10254
|
this.json.scene = sceneIndex;
|
|
@@ -10515,9 +10683,8 @@
|
|
|
10515
10683
|
const source = new Uint8Array(buffer.arrayBuffer, buffer.byteOffset + byteOffset, byteLength);
|
|
10516
10684
|
const result = new Uint8Array(scenegraph.gltf.buffers[bufferView.buffer].arrayBuffer, bufferView.byteOffset, bufferView.byteLength);
|
|
10517
10685
|
await meshoptDecodeGltfBuffer(result, count, byteStride, source, mode, filter);
|
|
10518
|
-
|
|
10686
|
+
scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION);
|
|
10519
10687
|
}
|
|
10520
|
-
return null;
|
|
10521
10688
|
}
|
|
10522
10689
|
var EXT_MESHOPT_COMPRESSION, name;
|
|
10523
10690
|
var init_EXT_meshopt_compression = __esm({
|
|
@@ -10576,8 +10743,8 @@
|
|
|
10576
10743
|
const extension = scene.getObjectExtension(texture, KHR_TEXTURE_BASISU);
|
|
10577
10744
|
if (extension) {
|
|
10578
10745
|
texture.source = extension.source;
|
|
10746
|
+
scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU);
|
|
10579
10747
|
}
|
|
10580
|
-
scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU);
|
|
10581
10748
|
}
|
|
10582
10749
|
scene.removeExtension(KHR_TEXTURE_BASISU);
|
|
10583
10750
|
}
|
|
@@ -10710,6 +10877,7 @@
|
|
|
10710
10877
|
if (decodedData.indices) {
|
|
10711
10878
|
primitive.indices = getGLTFAccessor(decodedData.indices);
|
|
10712
10879
|
}
|
|
10880
|
+
scenegraph.removeObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION);
|
|
10713
10881
|
checkPrimitive(primitive);
|
|
10714
10882
|
}
|
|
10715
10883
|
function compressMesh(attributes, indices, mode = 4, options, context) {
|
|
@@ -10792,8 +10960,8 @@
|
|
|
10792
10960
|
});
|
|
10793
10961
|
async function decode4(gltfData, options) {
|
|
10794
10962
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
10795
|
-
const
|
|
10796
|
-
if (!
|
|
10963
|
+
const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);
|
|
10964
|
+
if (!hasExtension) {
|
|
10797
10965
|
return;
|
|
10798
10966
|
}
|
|
10799
10967
|
const materials = gltfData.json.materials || [];
|
|
@@ -10927,10 +11095,10 @@
|
|
|
10927
11095
|
}
|
|
10928
11096
|
function makeTransformationMatrix(extensionData) {
|
|
10929
11097
|
const { offset = [0, 0], rotation = 0, scale: scale5 = [1, 1] } = extensionData;
|
|
10930
|
-
const
|
|
10931
|
-
const
|
|
11098
|
+
const translationMatrix = new Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);
|
|
11099
|
+
const rotationMatrix = scratchRotationMatrix.set(Math.cos(rotation), Math.sin(rotation), 0, -Math.sin(rotation), Math.cos(rotation), 0, 0, 0, 1);
|
|
10932
11100
|
const scaleMatrix = scratchScaleMatrix.set(scale5[0], 0, 0, 0, scale5[1], 0, 0, 0, 1);
|
|
10933
|
-
return
|
|
11101
|
+
return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);
|
|
10934
11102
|
}
|
|
10935
11103
|
var EXT_MESHOPT_TRANSFORM, name5, scratchVector7, scratchRotationMatrix, scratchScaleMatrix;
|
|
10936
11104
|
var init_KHR_texture_transform = __esm({
|
|
@@ -11459,7 +11627,197 @@
|
|
|
11459
11627
|
}
|
|
11460
11628
|
});
|
|
11461
11629
|
|
|
11630
|
+
// ../gltf/src/lib/parsers/parse-gltf.ts
|
|
11631
|
+
async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, context) {
|
|
11632
|
+
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);
|
|
11633
|
+
normalizeGLTFV1(gltf, { normalize: options?.gltf?.normalize });
|
|
11634
|
+
preprocessExtensions(gltf, options, context);
|
|
11635
|
+
const promises = [];
|
|
11636
|
+
if (options?.gltf?.loadBuffers && gltf.json.buffers) {
|
|
11637
|
+
await loadBuffers(gltf, options, context);
|
|
11638
|
+
}
|
|
11639
|
+
if (options?.gltf?.loadImages) {
|
|
11640
|
+
const promise2 = loadImages(gltf, options, context);
|
|
11641
|
+
promises.push(promise2);
|
|
11642
|
+
}
|
|
11643
|
+
const promise = decodeExtensions(gltf, options, context);
|
|
11644
|
+
promises.push(promise);
|
|
11645
|
+
await Promise.all(promises);
|
|
11646
|
+
return gltf;
|
|
11647
|
+
}
|
|
11648
|
+
function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
11649
|
+
if (options.uri) {
|
|
11650
|
+
gltf.baseUri = options.uri;
|
|
11651
|
+
}
|
|
11652
|
+
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) {
|
|
11653
|
+
const textDecoder = new TextDecoder();
|
|
11654
|
+
data = textDecoder.decode(data);
|
|
11655
|
+
}
|
|
11656
|
+
if (typeof data === "string") {
|
|
11657
|
+
gltf.json = parseJSON(data);
|
|
11658
|
+
} else if (data instanceof ArrayBuffer) {
|
|
11659
|
+
const glb = {};
|
|
11660
|
+
byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);
|
|
11661
|
+
assert7(glb.type === "glTF", `Invalid GLB magic string ${glb.type}`);
|
|
11662
|
+
gltf._glb = glb;
|
|
11663
|
+
gltf.json = glb.json;
|
|
11664
|
+
} else {
|
|
11665
|
+
assert7(false, "GLTF: must be ArrayBuffer or string");
|
|
11666
|
+
}
|
|
11667
|
+
const buffers = gltf.json.buffers || [];
|
|
11668
|
+
gltf.buffers = new Array(buffers.length).fill(null);
|
|
11669
|
+
if (gltf._glb && gltf._glb.header.hasBinChunk) {
|
|
11670
|
+
const { binChunks } = gltf._glb;
|
|
11671
|
+
gltf.buffers[0] = {
|
|
11672
|
+
arrayBuffer: binChunks[0].arrayBuffer,
|
|
11673
|
+
byteOffset: binChunks[0].byteOffset,
|
|
11674
|
+
byteLength: binChunks[0].byteLength
|
|
11675
|
+
};
|
|
11676
|
+
}
|
|
11677
|
+
const images = gltf.json.images || [];
|
|
11678
|
+
gltf.images = new Array(images.length).fill({});
|
|
11679
|
+
}
|
|
11680
|
+
async function loadBuffers(gltf, options, context) {
|
|
11681
|
+
const buffers = gltf.json.buffers || [];
|
|
11682
|
+
for (let i2 = 0; i2 < buffers.length; ++i2) {
|
|
11683
|
+
const buffer = buffers[i2];
|
|
11684
|
+
if (buffer.uri) {
|
|
11685
|
+
const { fetch: fetch2 } = context;
|
|
11686
|
+
assert7(fetch2);
|
|
11687
|
+
const uri = resolveUrl(buffer.uri, options);
|
|
11688
|
+
const response = await context?.fetch?.(uri);
|
|
11689
|
+
const arrayBuffer = await response?.arrayBuffer?.();
|
|
11690
|
+
gltf.buffers[i2] = {
|
|
11691
|
+
arrayBuffer,
|
|
11692
|
+
byteOffset: 0,
|
|
11693
|
+
byteLength: arrayBuffer.byteLength
|
|
11694
|
+
};
|
|
11695
|
+
delete buffer.uri;
|
|
11696
|
+
} else if (gltf.buffers[i2] === null) {
|
|
11697
|
+
gltf.buffers[i2] = {
|
|
11698
|
+
arrayBuffer: new ArrayBuffer(buffer.byteLength),
|
|
11699
|
+
byteOffset: 0,
|
|
11700
|
+
byteLength: buffer.byteLength
|
|
11701
|
+
};
|
|
11702
|
+
}
|
|
11703
|
+
}
|
|
11704
|
+
}
|
|
11705
|
+
async function loadImages(gltf, options, context) {
|
|
11706
|
+
const imageIndices = getReferencesImageIndices(gltf);
|
|
11707
|
+
const images = gltf.json.images || [];
|
|
11708
|
+
const promises = [];
|
|
11709
|
+
for (const imageIndex of imageIndices) {
|
|
11710
|
+
promises.push(loadImage(gltf, images[imageIndex], imageIndex, options, context));
|
|
11711
|
+
}
|
|
11712
|
+
return await Promise.all(promises);
|
|
11713
|
+
}
|
|
11714
|
+
function getReferencesImageIndices(gltf) {
|
|
11715
|
+
const imageIndices = new Set();
|
|
11716
|
+
const textures = gltf.json.textures || [];
|
|
11717
|
+
for (const texture of textures) {
|
|
11718
|
+
if (texture.source !== void 0) {
|
|
11719
|
+
imageIndices.add(texture.source);
|
|
11720
|
+
}
|
|
11721
|
+
}
|
|
11722
|
+
return Array.from(imageIndices).sort();
|
|
11723
|
+
}
|
|
11724
|
+
async function loadImage(gltf, image, index, options, context) {
|
|
11725
|
+
const { fetch: fetch2, parse: parse5 } = context;
|
|
11726
|
+
let arrayBuffer;
|
|
11727
|
+
if (image.uri && !image.hasOwnProperty("bufferView")) {
|
|
11728
|
+
const uri = resolveUrl(image.uri, options);
|
|
11729
|
+
const response = await fetch2(uri);
|
|
11730
|
+
arrayBuffer = await response.arrayBuffer();
|
|
11731
|
+
image.bufferView = {
|
|
11732
|
+
data: arrayBuffer
|
|
11733
|
+
};
|
|
11734
|
+
}
|
|
11735
|
+
if (Number.isFinite(image.bufferView)) {
|
|
11736
|
+
const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);
|
|
11737
|
+
arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
|
|
11738
|
+
}
|
|
11739
|
+
assert7(arrayBuffer, "glTF image has no data");
|
|
11740
|
+
let parsedImage = await parse5(arrayBuffer, [ImageLoader, BasisLoader], { mimeType: image.mimeType, basis: options.basis || { format: selectSupportedBasisFormat() } }, context);
|
|
11741
|
+
if (parsedImage && parsedImage[0]) {
|
|
11742
|
+
parsedImage = {
|
|
11743
|
+
compressed: true,
|
|
11744
|
+
mipmaps: false,
|
|
11745
|
+
width: parsedImage[0].width,
|
|
11746
|
+
height: parsedImage[0].height,
|
|
11747
|
+
data: parsedImage[0]
|
|
11748
|
+
};
|
|
11749
|
+
}
|
|
11750
|
+
gltf.images = gltf.images || [];
|
|
11751
|
+
gltf.images[index] = parsedImage;
|
|
11752
|
+
}
|
|
11753
|
+
var init_parse_gltf = __esm({
|
|
11754
|
+
"../gltf/src/lib/parsers/parse-gltf.ts"() {
|
|
11755
|
+
init_src2();
|
|
11756
|
+
init_src8();
|
|
11757
|
+
init_src9();
|
|
11758
|
+
init_assert6();
|
|
11759
|
+
init_parse_glb();
|
|
11760
|
+
init_resolve_url();
|
|
11761
|
+
init_get_typed_array();
|
|
11762
|
+
init_gltf_extensions();
|
|
11763
|
+
init_normalize_gltf_v1();
|
|
11764
|
+
}
|
|
11765
|
+
});
|
|
11766
|
+
|
|
11767
|
+
// ../gltf/src/gltf-loader.ts
|
|
11768
|
+
async function parse3(arrayBuffer, options = {}, context) {
|
|
11769
|
+
options = { ...GLTFLoader.options, ...options };
|
|
11770
|
+
options.gltf = { ...GLTFLoader.options.gltf, ...options.gltf };
|
|
11771
|
+
const { byteOffset = 0 } = options;
|
|
11772
|
+
const gltf = {};
|
|
11773
|
+
return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
|
|
11774
|
+
}
|
|
11775
|
+
var GLTFLoader;
|
|
11776
|
+
var init_gltf_loader = __esm({
|
|
11777
|
+
"../gltf/src/gltf-loader.ts"() {
|
|
11778
|
+
init_version4();
|
|
11779
|
+
init_parse_gltf();
|
|
11780
|
+
GLTFLoader = {
|
|
11781
|
+
name: "glTF",
|
|
11782
|
+
id: "gltf",
|
|
11783
|
+
module: "gltf",
|
|
11784
|
+
version: VERSION6,
|
|
11785
|
+
extensions: ["gltf", "glb"],
|
|
11786
|
+
mimeTypes: ["model/gltf+json", "model/gltf-binary"],
|
|
11787
|
+
text: true,
|
|
11788
|
+
binary: true,
|
|
11789
|
+
tests: ["glTF"],
|
|
11790
|
+
parse: parse3,
|
|
11791
|
+
options: {
|
|
11792
|
+
gltf: {
|
|
11793
|
+
normalize: true,
|
|
11794
|
+
loadBuffers: true,
|
|
11795
|
+
loadImages: true,
|
|
11796
|
+
decompressMeshes: true
|
|
11797
|
+
},
|
|
11798
|
+
log: console
|
|
11799
|
+
},
|
|
11800
|
+
deprecatedOptions: {
|
|
11801
|
+
fetchImages: "gltf.loadImages",
|
|
11802
|
+
createImages: "gltf.loadImages",
|
|
11803
|
+
decompress: "gltf.decompressMeshes",
|
|
11804
|
+
postProcess: "gltf.postProcess",
|
|
11805
|
+
gltf: {
|
|
11806
|
+
decompress: "gltf.decompressMeshes",
|
|
11807
|
+
postProcess: "removed in v4"
|
|
11808
|
+
}
|
|
11809
|
+
}
|
|
11810
|
+
};
|
|
11811
|
+
}
|
|
11812
|
+
});
|
|
11813
|
+
|
|
11462
11814
|
// ../gltf/src/lib/api/post-process-gltf.ts
|
|
11815
|
+
function makeDefaultSampler() {
|
|
11816
|
+
return {
|
|
11817
|
+
id: "default-sampler",
|
|
11818
|
+
parameters: DEFAULT_SAMPLER_PARAMETERS
|
|
11819
|
+
};
|
|
11820
|
+
}
|
|
11463
11821
|
function getBytesFromComponentType(componentType) {
|
|
11464
11822
|
return BYTES2[componentType];
|
|
11465
11823
|
}
|
|
@@ -11469,7 +11827,7 @@
|
|
|
11469
11827
|
function postProcessGLTF(gltf, options) {
|
|
11470
11828
|
return new GLTFPostProcessor().postProcess(gltf, options);
|
|
11471
11829
|
}
|
|
11472
|
-
var COMPONENTS2, BYTES2, GL_SAMPLER, SAMPLER_PARAMETER_GLTF_TO_GL,
|
|
11830
|
+
var COMPONENTS2, BYTES2, GL_SAMPLER, SAMPLER_PARAMETER_GLTF_TO_GL, DEFAULT_SAMPLER_PARAMETERS, GLTFPostProcessor;
|
|
11473
11831
|
var init_post_process_gltf = __esm({
|
|
11474
11832
|
"../gltf/src/lib/api/post-process-gltf.ts"() {
|
|
11475
11833
|
init_assert6();
|
|
@@ -11506,7 +11864,7 @@
|
|
|
11506
11864
|
wrapS: GL_SAMPLER.TEXTURE_WRAP_S,
|
|
11507
11865
|
wrapT: GL_SAMPLER.TEXTURE_WRAP_T
|
|
11508
11866
|
};
|
|
11509
|
-
|
|
11867
|
+
DEFAULT_SAMPLER_PARAMETERS = {
|
|
11510
11868
|
[GL_SAMPLER.TEXTURE_MAG_FILTER]: GL_SAMPLER.LINEAR,
|
|
11511
11869
|
[GL_SAMPLER.TEXTURE_MIN_FILTER]: GL_SAMPLER.NEAREST_MIPMAP_LINEAR,
|
|
11512
11870
|
[GL_SAMPLER.TEXTURE_WRAP_S]: GL_SAMPLER.REPEAT,
|
|
@@ -11515,171 +11873,198 @@
|
|
|
11515
11873
|
GLTFPostProcessor = class {
|
|
11516
11874
|
constructor() {
|
|
11517
11875
|
this.baseUri = "";
|
|
11518
|
-
this.json = {};
|
|
11519
11876
|
this.buffers = [];
|
|
11520
11877
|
this.images = [];
|
|
11521
11878
|
}
|
|
11522
11879
|
postProcess(gltf, options = {}) {
|
|
11523
|
-
const { json, buffers = [], images = []
|
|
11880
|
+
const { json, buffers = [], images = [] } = gltf;
|
|
11881
|
+
const { baseUri = "" } = gltf;
|
|
11524
11882
|
assert7(json);
|
|
11525
11883
|
this.baseUri = baseUri;
|
|
11526
|
-
this.json = json;
|
|
11527
11884
|
this.buffers = buffers;
|
|
11528
11885
|
this.images = images;
|
|
11529
|
-
this.
|
|
11886
|
+
this.jsonUnprocessed = json;
|
|
11887
|
+
this.json = this._resolveTree(gltf.json, options);
|
|
11530
11888
|
return this.json;
|
|
11531
11889
|
}
|
|
11532
|
-
_resolveTree(
|
|
11533
|
-
|
|
11534
|
-
|
|
11890
|
+
_resolveTree(gltf, options = {}) {
|
|
11891
|
+
const json = { ...gltf };
|
|
11892
|
+
this.json = json;
|
|
11893
|
+
if (gltf.bufferViews) {
|
|
11894
|
+
json.bufferViews = gltf.bufferViews.map((bufView, i2) => this._resolveBufferView(bufView, i2));
|
|
11535
11895
|
}
|
|
11536
|
-
if (
|
|
11537
|
-
json.images =
|
|
11896
|
+
if (gltf.images) {
|
|
11897
|
+
json.images = gltf.images.map((image, i2) => this._resolveImage(image, i2));
|
|
11538
11898
|
}
|
|
11539
|
-
if (
|
|
11540
|
-
json.samplers =
|
|
11899
|
+
if (gltf.samplers) {
|
|
11900
|
+
json.samplers = gltf.samplers.map((sampler, i2) => this._resolveSampler(sampler, i2));
|
|
11541
11901
|
}
|
|
11542
|
-
if (
|
|
11543
|
-
json.textures =
|
|
11902
|
+
if (gltf.textures) {
|
|
11903
|
+
json.textures = gltf.textures.map((texture, i2) => this._resolveTexture(texture, i2));
|
|
11544
11904
|
}
|
|
11545
|
-
if (
|
|
11546
|
-
json.accessors =
|
|
11905
|
+
if (gltf.accessors) {
|
|
11906
|
+
json.accessors = gltf.accessors.map((accessor, i2) => this._resolveAccessor(accessor, i2));
|
|
11547
11907
|
}
|
|
11548
|
-
if (
|
|
11549
|
-
json.materials =
|
|
11908
|
+
if (gltf.materials) {
|
|
11909
|
+
json.materials = gltf.materials.map((material, i2) => this._resolveMaterial(material, i2));
|
|
11550
11910
|
}
|
|
11551
|
-
if (
|
|
11552
|
-
json.meshes =
|
|
11911
|
+
if (gltf.meshes) {
|
|
11912
|
+
json.meshes = gltf.meshes.map((mesh, i2) => this._resolveMesh(mesh, i2));
|
|
11553
11913
|
}
|
|
11554
|
-
if (
|
|
11555
|
-
json.nodes =
|
|
11914
|
+
if (gltf.nodes) {
|
|
11915
|
+
json.nodes = gltf.nodes.map((node3, i2) => this._resolveNode(node3, i2));
|
|
11916
|
+
json.nodes = json.nodes.map((node3, i2) => this._resolveNodeChildren(node3));
|
|
11556
11917
|
}
|
|
11557
|
-
if (
|
|
11558
|
-
json.skins =
|
|
11918
|
+
if (gltf.skins) {
|
|
11919
|
+
json.skins = gltf.skins.map((skin, i2) => this._resolveSkin(skin, i2));
|
|
11559
11920
|
}
|
|
11560
|
-
if (
|
|
11561
|
-
json.scenes =
|
|
11921
|
+
if (gltf.scenes) {
|
|
11922
|
+
json.scenes = gltf.scenes.map((scene, i2) => this._resolveScene(scene, i2));
|
|
11562
11923
|
}
|
|
11563
|
-
if (json.scene
|
|
11924
|
+
if (typeof this.json.scene === "number" && json.scenes) {
|
|
11564
11925
|
json.scene = json.scenes[this.json.scene];
|
|
11565
11926
|
}
|
|
11927
|
+
return json;
|
|
11566
11928
|
}
|
|
11567
11929
|
getScene(index) {
|
|
11568
|
-
return this._get(
|
|
11930
|
+
return this._get(this.json.scenes, index);
|
|
11569
11931
|
}
|
|
11570
11932
|
getNode(index) {
|
|
11571
|
-
return this._get(
|
|
11933
|
+
return this._get(this.json.nodes, index);
|
|
11572
11934
|
}
|
|
11573
11935
|
getSkin(index) {
|
|
11574
|
-
return this._get(
|
|
11936
|
+
return this._get(this.json.skins, index);
|
|
11575
11937
|
}
|
|
11576
11938
|
getMesh(index) {
|
|
11577
|
-
return this._get(
|
|
11939
|
+
return this._get(this.json.meshes, index);
|
|
11578
11940
|
}
|
|
11579
11941
|
getMaterial(index) {
|
|
11580
|
-
return this._get(
|
|
11942
|
+
return this._get(this.json.materials, index);
|
|
11581
11943
|
}
|
|
11582
11944
|
getAccessor(index) {
|
|
11583
|
-
return this._get(
|
|
11945
|
+
return this._get(this.json.accessors, index);
|
|
11584
11946
|
}
|
|
11585
11947
|
getCamera(index) {
|
|
11586
|
-
return
|
|
11948
|
+
return this._get(this.json.cameras, index);
|
|
11587
11949
|
}
|
|
11588
11950
|
getTexture(index) {
|
|
11589
|
-
return this._get(
|
|
11951
|
+
return this._get(this.json.textures, index);
|
|
11590
11952
|
}
|
|
11591
11953
|
getSampler(index) {
|
|
11592
|
-
return this._get(
|
|
11954
|
+
return this._get(this.json.samplers, index);
|
|
11593
11955
|
}
|
|
11594
11956
|
getImage(index) {
|
|
11595
|
-
return this._get(
|
|
11957
|
+
return this._get(this.json.images, index);
|
|
11596
11958
|
}
|
|
11597
11959
|
getBufferView(index) {
|
|
11598
|
-
return this._get(
|
|
11960
|
+
return this._get(this.json.bufferViews, index);
|
|
11599
11961
|
}
|
|
11600
11962
|
getBuffer(index) {
|
|
11601
|
-
return this._get(
|
|
11963
|
+
return this._get(this.json.buffers, index);
|
|
11602
11964
|
}
|
|
11603
11965
|
_get(array, index) {
|
|
11604
11966
|
if (typeof index === "object") {
|
|
11605
11967
|
return index;
|
|
11606
11968
|
}
|
|
11607
|
-
const object =
|
|
11969
|
+
const object = array && array[index];
|
|
11608
11970
|
if (!object) {
|
|
11609
11971
|
console.warn(`glTF file error: Could not find ${array}[${index}]`);
|
|
11610
11972
|
}
|
|
11611
11973
|
return object;
|
|
11612
11974
|
}
|
|
11613
11975
|
_resolveScene(scene, index) {
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11976
|
+
return {
|
|
11977
|
+
...scene,
|
|
11978
|
+
id: scene.id || `scene-${index}`,
|
|
11979
|
+
nodes: (scene.nodes || []).map((node3) => this.getNode(node3))
|
|
11980
|
+
};
|
|
11617
11981
|
}
|
|
11618
|
-
_resolveNode(
|
|
11619
|
-
node3
|
|
11620
|
-
|
|
11621
|
-
|
|
11982
|
+
_resolveNode(gltfNode, index) {
|
|
11983
|
+
const node3 = {
|
|
11984
|
+
...gltfNode,
|
|
11985
|
+
id: gltfNode?.id || `node-${index}`
|
|
11986
|
+
};
|
|
11987
|
+
if (gltfNode.mesh !== void 0) {
|
|
11988
|
+
node3.mesh = this.getMesh(gltfNode.mesh);
|
|
11989
|
+
}
|
|
11990
|
+
if (gltfNode.camera !== void 0) {
|
|
11991
|
+
node3.camera = this.getCamera(gltfNode.camera);
|
|
11622
11992
|
}
|
|
11623
|
-
if (
|
|
11624
|
-
node3.
|
|
11625
|
-
}
|
|
11626
|
-
|
|
11993
|
+
if (gltfNode.skin !== void 0) {
|
|
11994
|
+
node3.skin = this.getSkin(gltfNode.skin);
|
|
11995
|
+
}
|
|
11996
|
+
if (gltfNode.meshes !== void 0 && gltfNode.meshes.length) {
|
|
11997
|
+
node3.mesh = gltfNode.meshes.reduce((accum, meshIndex) => {
|
|
11627
11998
|
const mesh = this.getMesh(meshIndex);
|
|
11628
11999
|
accum.id = mesh.id;
|
|
11629
12000
|
accum.primitives = accum.primitives.concat(mesh.primitives);
|
|
11630
12001
|
return accum;
|
|
11631
12002
|
}, { primitives: [] });
|
|
11632
12003
|
}
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
if (node3.
|
|
11637
|
-
node3.
|
|
12004
|
+
return node3;
|
|
12005
|
+
}
|
|
12006
|
+
_resolveNodeChildren(node3) {
|
|
12007
|
+
if (node3.children) {
|
|
12008
|
+
node3.children = node3.children.map((child) => this.getNode(child));
|
|
11638
12009
|
}
|
|
11639
12010
|
return node3;
|
|
11640
12011
|
}
|
|
11641
|
-
_resolveSkin(
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
12012
|
+
_resolveSkin(gltfSkin, index) {
|
|
12013
|
+
const inverseBindMatrices = typeof gltfSkin.inverseBindMatrices === "number" ? this.getAccessor(gltfSkin.inverseBindMatrices) : void 0;
|
|
12014
|
+
return {
|
|
12015
|
+
...gltfSkin,
|
|
12016
|
+
id: gltfSkin.id || `skin-${index}`,
|
|
12017
|
+
inverseBindMatrices
|
|
12018
|
+
};
|
|
12019
|
+
}
|
|
12020
|
+
_resolveMesh(gltfMesh, index) {
|
|
12021
|
+
const mesh = {
|
|
12022
|
+
...gltfMesh,
|
|
12023
|
+
id: gltfMesh.id || `mesh-${index}`,
|
|
12024
|
+
primitives: []
|
|
12025
|
+
};
|
|
12026
|
+
if (gltfMesh.primitives) {
|
|
12027
|
+
mesh.primitives = gltfMesh.primitives.map((gltfPrimitive) => {
|
|
12028
|
+
const primitive = {
|
|
12029
|
+
...gltfPrimitive,
|
|
12030
|
+
attributes: {},
|
|
12031
|
+
indices: void 0,
|
|
12032
|
+
material: void 0
|
|
12033
|
+
};
|
|
12034
|
+
const attributes = gltfPrimitive.attributes;
|
|
11653
12035
|
for (const attribute in attributes) {
|
|
11654
12036
|
primitive.attributes[attribute] = this.getAccessor(attributes[attribute]);
|
|
11655
12037
|
}
|
|
11656
|
-
if (
|
|
11657
|
-
primitive.indices = this.getAccessor(
|
|
12038
|
+
if (gltfPrimitive.indices !== void 0) {
|
|
12039
|
+
primitive.indices = this.getAccessor(gltfPrimitive.indices);
|
|
11658
12040
|
}
|
|
11659
|
-
if (
|
|
11660
|
-
primitive.material = this.getMaterial(
|
|
12041
|
+
if (gltfPrimitive.material !== void 0) {
|
|
12042
|
+
primitive.material = this.getMaterial(gltfPrimitive.material);
|
|
11661
12043
|
}
|
|
11662
12044
|
return primitive;
|
|
11663
12045
|
});
|
|
11664
12046
|
}
|
|
11665
12047
|
return mesh;
|
|
11666
12048
|
}
|
|
11667
|
-
_resolveMaterial(
|
|
11668
|
-
material
|
|
12049
|
+
_resolveMaterial(gltfMaterial, index) {
|
|
12050
|
+
const material = {
|
|
12051
|
+
...gltfMaterial,
|
|
12052
|
+
id: gltfMaterial.id || `material-${index}`
|
|
12053
|
+
};
|
|
11669
12054
|
if (material.normalTexture) {
|
|
11670
12055
|
material.normalTexture = { ...material.normalTexture };
|
|
11671
12056
|
material.normalTexture.texture = this.getTexture(material.normalTexture.index);
|
|
11672
12057
|
}
|
|
11673
12058
|
if (material.occlusionTexture) {
|
|
11674
|
-
material.
|
|
12059
|
+
material.occlusionTexture = { ...material.occlusionTexture };
|
|
11675
12060
|
material.occlusionTexture.texture = this.getTexture(material.occlusionTexture.index);
|
|
11676
12061
|
}
|
|
11677
12062
|
if (material.emissiveTexture) {
|
|
11678
|
-
material.
|
|
12063
|
+
material.emissiveTexture = { ...material.emissiveTexture };
|
|
11679
12064
|
material.emissiveTexture.texture = this.getTexture(material.emissiveTexture.index);
|
|
11680
12065
|
}
|
|
11681
12066
|
if (!material.emissiveFactor) {
|
|
11682
|
-
material.emissiveFactor = material.
|
|
12067
|
+
material.emissiveFactor = material.emissiveTexture ? [1, 1, 1] : [0, 0, 0];
|
|
11683
12068
|
}
|
|
11684
12069
|
if (material.pbrMetallicRoughness) {
|
|
11685
12070
|
material.pbrMetallicRoughness = { ...material.pbrMetallicRoughness };
|
|
@@ -11695,14 +12080,23 @@
|
|
|
11695
12080
|
}
|
|
11696
12081
|
return material;
|
|
11697
12082
|
}
|
|
11698
|
-
_resolveAccessor(
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
12083
|
+
_resolveAccessor(gltfAccessor, index) {
|
|
12084
|
+
const bytesPerComponent = getBytesFromComponentType(gltfAccessor.componentType);
|
|
12085
|
+
const components = getSizeFromAccessorType(gltfAccessor.type);
|
|
12086
|
+
const bytesPerElement = bytesPerComponent * components;
|
|
12087
|
+
const accessor = {
|
|
12088
|
+
...gltfAccessor,
|
|
12089
|
+
id: gltfAccessor.id || `accessor-${index}`,
|
|
12090
|
+
bytesPerComponent,
|
|
12091
|
+
components,
|
|
12092
|
+
bytesPerElement,
|
|
12093
|
+
value: void 0,
|
|
12094
|
+
bufferView: void 0,
|
|
12095
|
+
sparse: void 0
|
|
12096
|
+
};
|
|
12097
|
+
if (gltfAccessor.bufferView !== void 0) {
|
|
12098
|
+
accessor.bufferView = this.getBufferView(gltfAccessor.bufferView);
|
|
11702
12099
|
}
|
|
11703
|
-
accessor.bytesPerComponent = getBytesFromComponentType(accessor.componentType);
|
|
11704
|
-
accessor.components = getSizeFromAccessorType(accessor.type);
|
|
11705
|
-
accessor.bytesPerElement = accessor.bytesPerComponent * accessor.components;
|
|
11706
12100
|
if (accessor.bufferView) {
|
|
11707
12101
|
const buffer = accessor.bufferView.buffer;
|
|
11708
12102
|
const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
|
|
@@ -11723,15 +12117,20 @@
|
|
|
11723
12117
|
}
|
|
11724
12118
|
return result.buffer;
|
|
11725
12119
|
}
|
|
11726
|
-
_resolveTexture(
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
12120
|
+
_resolveTexture(gltfTexture, index) {
|
|
12121
|
+
return {
|
|
12122
|
+
...gltfTexture,
|
|
12123
|
+
id: gltfTexture.id || `texture-${index}`,
|
|
12124
|
+
sampler: typeof gltfTexture.sampler === "number" ? this.getSampler(gltfTexture.sampler) : makeDefaultSampler(),
|
|
12125
|
+
source: typeof gltfTexture.source === "number" ? this.getImage(gltfTexture.source) : void 0
|
|
12126
|
+
};
|
|
11731
12127
|
}
|
|
11732
|
-
_resolveSampler(
|
|
11733
|
-
sampler
|
|
11734
|
-
|
|
12128
|
+
_resolveSampler(gltfSampler, index) {
|
|
12129
|
+
const sampler = {
|
|
12130
|
+
id: gltfSampler.id || `sampler-${index}`,
|
|
12131
|
+
...gltfSampler,
|
|
12132
|
+
parameters: {}
|
|
12133
|
+
};
|
|
11735
12134
|
for (const key in sampler) {
|
|
11736
12135
|
const glEnum = this._enumSamplerParameter(key);
|
|
11737
12136
|
if (glEnum !== void 0) {
|
|
@@ -11743,337 +12142,44 @@
|
|
|
11743
12142
|
_enumSamplerParameter(key) {
|
|
11744
12143
|
return SAMPLER_PARAMETER_GLTF_TO_GL[key];
|
|
11745
12144
|
}
|
|
11746
|
-
_resolveImage(
|
|
11747
|
-
image
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
12145
|
+
_resolveImage(gltfImage, index) {
|
|
12146
|
+
const image = {
|
|
12147
|
+
...gltfImage,
|
|
12148
|
+
id: gltfImage.id || `image-${index}`,
|
|
12149
|
+
image: null,
|
|
12150
|
+
bufferView: gltfImage.bufferView !== void 0 ? this.getBufferView(gltfImage.bufferView) : void 0
|
|
12151
|
+
};
|
|
11751
12152
|
const preloadedImage = this.images[index];
|
|
11752
12153
|
if (preloadedImage) {
|
|
11753
12154
|
image.image = preloadedImage;
|
|
11754
12155
|
}
|
|
11755
12156
|
return image;
|
|
11756
12157
|
}
|
|
11757
|
-
_resolveBufferView(
|
|
11758
|
-
const bufferIndex =
|
|
11759
|
-
const result = {
|
|
11760
|
-
id: `bufferView-${index}`,
|
|
11761
|
-
...bufferView,
|
|
11762
|
-
buffer: this.buffers[bufferIndex]
|
|
11763
|
-
};
|
|
12158
|
+
_resolveBufferView(gltfBufferView, index) {
|
|
12159
|
+
const bufferIndex = gltfBufferView.buffer;
|
|
11764
12160
|
const arrayBuffer = this.buffers[bufferIndex].arrayBuffer;
|
|
11765
12161
|
let byteOffset = this.buffers[bufferIndex].byteOffset || 0;
|
|
11766
|
-
if (
|
|
11767
|
-
byteOffset +=
|
|
11768
|
-
}
|
|
11769
|
-
result.data = new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
|
|
11770
|
-
return result;
|
|
11771
|
-
}
|
|
11772
|
-
_resolveCamera(camera, index) {
|
|
11773
|
-
camera.id = camera.id || `camera-${index}`;
|
|
11774
|
-
if (camera.perspective) {
|
|
11775
|
-
}
|
|
11776
|
-
if (camera.orthographic) {
|
|
11777
|
-
}
|
|
11778
|
-
return camera;
|
|
11779
|
-
}
|
|
11780
|
-
};
|
|
11781
|
-
}
|
|
11782
|
-
});
|
|
11783
|
-
|
|
11784
|
-
// ../gltf/src/lib/parsers/parse-glb.ts
|
|
11785
|
-
function getMagicString4(dataView, byteOffset = 0) {
|
|
11786
|
-
return `${String.fromCharCode(dataView.getUint8(byteOffset + 0))}${String.fromCharCode(dataView.getUint8(byteOffset + 1))}${String.fromCharCode(dataView.getUint8(byteOffset + 2))}${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;
|
|
11787
|
-
}
|
|
11788
|
-
function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
|
|
11789
|
-
const dataView = new DataView(arrayBuffer);
|
|
11790
|
-
const { magic = MAGIC_glTF } = options;
|
|
11791
|
-
const magic1 = dataView.getUint32(byteOffset, false);
|
|
11792
|
-
return magic1 === magic || magic1 === MAGIC_glTF;
|
|
11793
|
-
}
|
|
11794
|
-
function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
|
|
11795
|
-
const dataView = new DataView(arrayBuffer);
|
|
11796
|
-
const type = getMagicString4(dataView, byteOffset + 0);
|
|
11797
|
-
const version = dataView.getUint32(byteOffset + 4, LE);
|
|
11798
|
-
const byteLength = dataView.getUint32(byteOffset + 8, LE);
|
|
11799
|
-
Object.assign(glb, {
|
|
11800
|
-
header: {
|
|
11801
|
-
byteOffset,
|
|
11802
|
-
byteLength,
|
|
11803
|
-
hasBinChunk: false
|
|
11804
|
-
},
|
|
11805
|
-
type,
|
|
11806
|
-
version,
|
|
11807
|
-
json: {},
|
|
11808
|
-
binChunks: []
|
|
11809
|
-
});
|
|
11810
|
-
byteOffset += GLB_FILE_HEADER_SIZE;
|
|
11811
|
-
switch (glb.version) {
|
|
11812
|
-
case 1:
|
|
11813
|
-
return parseGLBV1(glb, dataView, byteOffset);
|
|
11814
|
-
case 2:
|
|
11815
|
-
return parseGLBV2(glb, dataView, byteOffset, options = {});
|
|
11816
|
-
default:
|
|
11817
|
-
throw new Error(`Invalid GLB version ${glb.version}. Only supports v1 and v2.`);
|
|
11818
|
-
}
|
|
11819
|
-
}
|
|
11820
|
-
function parseGLBV1(glb, dataView, byteOffset) {
|
|
11821
|
-
assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
11822
|
-
const contentLength = dataView.getUint32(byteOffset + 0, LE);
|
|
11823
|
-
const contentFormat = dataView.getUint32(byteOffset + 4, LE);
|
|
11824
|
-
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
11825
|
-
assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
|
|
11826
|
-
parseJSONChunk(glb, dataView, byteOffset, contentLength);
|
|
11827
|
-
byteOffset += contentLength;
|
|
11828
|
-
byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
|
|
11829
|
-
return byteOffset;
|
|
11830
|
-
}
|
|
11831
|
-
function parseGLBV2(glb, dataView, byteOffset, options) {
|
|
11832
|
-
assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
11833
|
-
parseGLBChunksSync(glb, dataView, byteOffset, options);
|
|
11834
|
-
return byteOffset + glb.header.byteLength;
|
|
11835
|
-
}
|
|
11836
|
-
function parseGLBChunksSync(glb, dataView, byteOffset, options) {
|
|
11837
|
-
while (byteOffset + 8 <= glb.header.byteLength) {
|
|
11838
|
-
const chunkLength = dataView.getUint32(byteOffset + 0, LE);
|
|
11839
|
-
const chunkFormat = dataView.getUint32(byteOffset + 4, LE);
|
|
11840
|
-
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
11841
|
-
switch (chunkFormat) {
|
|
11842
|
-
case GLB_CHUNK_TYPE_JSON:
|
|
11843
|
-
parseJSONChunk(glb, dataView, byteOffset, chunkLength);
|
|
11844
|
-
break;
|
|
11845
|
-
case GLB_CHUNK_TYPE_BIN:
|
|
11846
|
-
parseBINChunk(glb, dataView, byteOffset, chunkLength);
|
|
11847
|
-
break;
|
|
11848
|
-
case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
|
|
11849
|
-
if (!options.strict) {
|
|
11850
|
-
parseJSONChunk(glb, dataView, byteOffset, chunkLength);
|
|
12162
|
+
if (gltfBufferView.byteOffset) {
|
|
12163
|
+
byteOffset += gltfBufferView.byteOffset;
|
|
11851
12164
|
}
|
|
11852
|
-
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
12165
|
+
const bufferView = {
|
|
12166
|
+
id: `bufferView-${index}`,
|
|
12167
|
+
...gltfBufferView,
|
|
12168
|
+
buffer: this.buffers[bufferIndex],
|
|
12169
|
+
data: new Uint8Array(arrayBuffer, byteOffset, gltfBufferView.byteLength)
|
|
12170
|
+
};
|
|
12171
|
+
return bufferView;
|
|
12172
|
+
}
|
|
12173
|
+
_resolveCamera(gltfCamera, index) {
|
|
12174
|
+
const camera = {
|
|
12175
|
+
...gltfCamera,
|
|
12176
|
+
id: gltfCamera.id || `camera-${index}`
|
|
12177
|
+
};
|
|
12178
|
+
if (camera.perspective) {
|
|
11856
12179
|
}
|
|
11857
|
-
|
|
11858
|
-
default:
|
|
11859
|
-
break;
|
|
11860
|
-
}
|
|
11861
|
-
byteOffset += padToNBytes(chunkLength, 4);
|
|
11862
|
-
}
|
|
11863
|
-
return byteOffset;
|
|
11864
|
-
}
|
|
11865
|
-
function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
|
|
11866
|
-
const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
|
|
11867
|
-
const textDecoder = new TextDecoder("utf8");
|
|
11868
|
-
const jsonText = textDecoder.decode(jsonChunk);
|
|
11869
|
-
glb.json = JSON.parse(jsonText);
|
|
11870
|
-
return padToNBytes(chunkLength, 4);
|
|
11871
|
-
}
|
|
11872
|
-
function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
|
|
11873
|
-
glb.header.hasBinChunk = true;
|
|
11874
|
-
glb.binChunks.push({
|
|
11875
|
-
byteOffset,
|
|
11876
|
-
byteLength: chunkLength,
|
|
11877
|
-
arrayBuffer: dataView.buffer
|
|
11878
|
-
});
|
|
11879
|
-
return padToNBytes(chunkLength, 4);
|
|
11880
|
-
}
|
|
11881
|
-
var MAGIC_glTF, GLB_FILE_HEADER_SIZE, GLB_CHUNK_HEADER_SIZE, GLB_CHUNK_TYPE_JSON, GLB_CHUNK_TYPE_BIN, GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED, GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED, GLB_V1_CONTENT_FORMAT_JSON, LE;
|
|
11882
|
-
var init_parse_glb = __esm({
|
|
11883
|
-
"../gltf/src/lib/parsers/parse-glb.ts"() {
|
|
11884
|
-
init_src2();
|
|
11885
|
-
MAGIC_glTF = 1735152710;
|
|
11886
|
-
GLB_FILE_HEADER_SIZE = 12;
|
|
11887
|
-
GLB_CHUNK_HEADER_SIZE = 8;
|
|
11888
|
-
GLB_CHUNK_TYPE_JSON = 1313821514;
|
|
11889
|
-
GLB_CHUNK_TYPE_BIN = 5130562;
|
|
11890
|
-
GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
|
|
11891
|
-
GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
|
|
11892
|
-
GLB_V1_CONTENT_FORMAT_JSON = 0;
|
|
11893
|
-
LE = true;
|
|
11894
|
-
}
|
|
11895
|
-
});
|
|
11896
|
-
|
|
11897
|
-
// ../gltf/src/lib/parsers/parse-gltf.ts
|
|
11898
|
-
async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, context) {
|
|
11899
|
-
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);
|
|
11900
|
-
normalizeGLTFV1(gltf, { normalize: options?.gltf?.normalize });
|
|
11901
|
-
preprocessExtensions(gltf, options, context);
|
|
11902
|
-
const promises = [];
|
|
11903
|
-
if (options?.gltf?.loadBuffers && gltf.json.buffers) {
|
|
11904
|
-
await loadBuffers(gltf, options, context);
|
|
11905
|
-
}
|
|
11906
|
-
if (options?.gltf?.loadImages) {
|
|
11907
|
-
const promise2 = loadImages(gltf, options, context);
|
|
11908
|
-
promises.push(promise2);
|
|
11909
|
-
}
|
|
11910
|
-
const promise = decodeExtensions(gltf, options, context);
|
|
11911
|
-
promises.push(promise);
|
|
11912
|
-
await Promise.all(promises);
|
|
11913
|
-
return options?.gltf?.postProcess ? postProcessGLTF(gltf, options) : gltf;
|
|
11914
|
-
}
|
|
11915
|
-
function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
11916
|
-
if (options.uri) {
|
|
11917
|
-
gltf.baseUri = options.uri;
|
|
11918
|
-
}
|
|
11919
|
-
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) {
|
|
11920
|
-
const textDecoder = new TextDecoder();
|
|
11921
|
-
data = textDecoder.decode(data);
|
|
11922
|
-
}
|
|
11923
|
-
if (typeof data === "string") {
|
|
11924
|
-
gltf.json = parseJSON(data);
|
|
11925
|
-
} else if (data instanceof ArrayBuffer) {
|
|
11926
|
-
const glb = {};
|
|
11927
|
-
byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);
|
|
11928
|
-
assert7(glb.type === "glTF", `Invalid GLB magic string ${glb.type}`);
|
|
11929
|
-
gltf._glb = glb;
|
|
11930
|
-
gltf.json = glb.json;
|
|
11931
|
-
} else {
|
|
11932
|
-
assert7(false, "GLTF: must be ArrayBuffer or string");
|
|
11933
|
-
}
|
|
11934
|
-
const buffers = gltf.json.buffers || [];
|
|
11935
|
-
gltf.buffers = new Array(buffers.length).fill(null);
|
|
11936
|
-
if (gltf._glb && gltf._glb.header.hasBinChunk) {
|
|
11937
|
-
const { binChunks } = gltf._glb;
|
|
11938
|
-
gltf.buffers[0] = {
|
|
11939
|
-
arrayBuffer: binChunks[0].arrayBuffer,
|
|
11940
|
-
byteOffset: binChunks[0].byteOffset,
|
|
11941
|
-
byteLength: binChunks[0].byteLength
|
|
11942
|
-
};
|
|
11943
|
-
}
|
|
11944
|
-
const images = gltf.json.images || [];
|
|
11945
|
-
gltf.images = new Array(images.length).fill({});
|
|
11946
|
-
}
|
|
11947
|
-
async function loadBuffers(gltf, options, context) {
|
|
11948
|
-
const buffers = gltf.json.buffers || [];
|
|
11949
|
-
for (let i2 = 0; i2 < buffers.length; ++i2) {
|
|
11950
|
-
const buffer = buffers[i2];
|
|
11951
|
-
if (buffer.uri) {
|
|
11952
|
-
const { fetch: fetch2 } = context;
|
|
11953
|
-
assert7(fetch2);
|
|
11954
|
-
const uri = resolveUrl(buffer.uri, options);
|
|
11955
|
-
const response = await context?.fetch?.(uri);
|
|
11956
|
-
const arrayBuffer = await response?.arrayBuffer?.();
|
|
11957
|
-
gltf.buffers[i2] = {
|
|
11958
|
-
arrayBuffer,
|
|
11959
|
-
byteOffset: 0,
|
|
11960
|
-
byteLength: arrayBuffer.byteLength
|
|
11961
|
-
};
|
|
11962
|
-
delete buffer.uri;
|
|
11963
|
-
} else if (gltf.buffers[i2] === null) {
|
|
11964
|
-
gltf.buffers[i2] = {
|
|
11965
|
-
arrayBuffer: new ArrayBuffer(buffer.byteLength),
|
|
11966
|
-
byteOffset: 0,
|
|
11967
|
-
byteLength: buffer.byteLength
|
|
11968
|
-
};
|
|
11969
|
-
}
|
|
11970
|
-
}
|
|
11971
|
-
}
|
|
11972
|
-
async function loadImages(gltf, options, context) {
|
|
11973
|
-
const imageIndices = getReferencesImageIndices(gltf);
|
|
11974
|
-
const images = gltf.json.images || [];
|
|
11975
|
-
const promises = [];
|
|
11976
|
-
for (const imageIndex of imageIndices) {
|
|
11977
|
-
promises.push(loadImage(gltf, images[imageIndex], imageIndex, options, context));
|
|
11978
|
-
}
|
|
11979
|
-
return await Promise.all(promises);
|
|
11980
|
-
}
|
|
11981
|
-
function getReferencesImageIndices(gltf) {
|
|
11982
|
-
const imageIndices = new Set();
|
|
11983
|
-
const textures = gltf.json.textures || [];
|
|
11984
|
-
for (const texture of textures) {
|
|
11985
|
-
if (texture.source !== void 0) {
|
|
11986
|
-
imageIndices.add(texture.source);
|
|
11987
|
-
}
|
|
11988
|
-
}
|
|
11989
|
-
return Array.from(imageIndices).sort();
|
|
11990
|
-
}
|
|
11991
|
-
async function loadImage(gltf, image, index, options, context) {
|
|
11992
|
-
const { fetch: fetch2, parse: parse5 } = context;
|
|
11993
|
-
let arrayBuffer;
|
|
11994
|
-
if (image.uri && !image.hasOwnProperty("bufferView")) {
|
|
11995
|
-
const uri = resolveUrl(image.uri, options);
|
|
11996
|
-
const response = await fetch2(uri);
|
|
11997
|
-
arrayBuffer = await response.arrayBuffer();
|
|
11998
|
-
image.bufferView = {
|
|
11999
|
-
data: arrayBuffer
|
|
12000
|
-
};
|
|
12001
|
-
}
|
|
12002
|
-
if (Number.isFinite(image.bufferView)) {
|
|
12003
|
-
const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);
|
|
12004
|
-
arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
|
|
12005
|
-
}
|
|
12006
|
-
assert7(arrayBuffer, "glTF image has no data");
|
|
12007
|
-
let parsedImage = await parse5(arrayBuffer, [ImageLoader, BasisLoader], { mimeType: image.mimeType, basis: options.basis || { format: selectSupportedBasisFormat() } }, context);
|
|
12008
|
-
if (parsedImage && parsedImage[0]) {
|
|
12009
|
-
parsedImage = {
|
|
12010
|
-
compressed: true,
|
|
12011
|
-
mipmaps: false,
|
|
12012
|
-
width: parsedImage[0].width,
|
|
12013
|
-
height: parsedImage[0].height,
|
|
12014
|
-
data: parsedImage[0]
|
|
12015
|
-
};
|
|
12016
|
-
}
|
|
12017
|
-
gltf.images = gltf.images || [];
|
|
12018
|
-
gltf.images[index] = parsedImage;
|
|
12019
|
-
}
|
|
12020
|
-
var init_parse_gltf = __esm({
|
|
12021
|
-
"../gltf/src/lib/parsers/parse-gltf.ts"() {
|
|
12022
|
-
init_src9();
|
|
12023
|
-
init_src8();
|
|
12024
|
-
init_src2();
|
|
12025
|
-
init_assert6();
|
|
12026
|
-
init_resolve_url();
|
|
12027
|
-
init_get_typed_array();
|
|
12028
|
-
init_gltf_extensions();
|
|
12029
|
-
init_normalize_gltf_v1();
|
|
12030
|
-
init_post_process_gltf();
|
|
12031
|
-
init_parse_glb();
|
|
12032
|
-
}
|
|
12033
|
-
});
|
|
12034
|
-
|
|
12035
|
-
// ../gltf/src/gltf-loader.ts
|
|
12036
|
-
async function parse3(arrayBuffer, options = {}, context) {
|
|
12037
|
-
options = { ...GLTFLoader.options, ...options };
|
|
12038
|
-
options.gltf = { ...GLTFLoader.options.gltf, ...options.gltf };
|
|
12039
|
-
const { byteOffset = 0 } = options;
|
|
12040
|
-
const gltf = {};
|
|
12041
|
-
return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
|
|
12042
|
-
}
|
|
12043
|
-
var GLTFLoader;
|
|
12044
|
-
var init_gltf_loader = __esm({
|
|
12045
|
-
"../gltf/src/gltf-loader.ts"() {
|
|
12046
|
-
init_version4();
|
|
12047
|
-
init_parse_gltf();
|
|
12048
|
-
GLTFLoader = {
|
|
12049
|
-
name: "glTF",
|
|
12050
|
-
id: "gltf",
|
|
12051
|
-
module: "gltf",
|
|
12052
|
-
version: VERSION6,
|
|
12053
|
-
extensions: ["gltf", "glb"],
|
|
12054
|
-
mimeTypes: ["model/gltf+json", "model/gltf-binary"],
|
|
12055
|
-
text: true,
|
|
12056
|
-
binary: true,
|
|
12057
|
-
tests: ["glTF"],
|
|
12058
|
-
parse: parse3,
|
|
12059
|
-
options: {
|
|
12060
|
-
gltf: {
|
|
12061
|
-
normalize: true,
|
|
12062
|
-
loadBuffers: true,
|
|
12063
|
-
loadImages: true,
|
|
12064
|
-
decompressMeshes: true,
|
|
12065
|
-
postProcess: true
|
|
12066
|
-
},
|
|
12067
|
-
log: console
|
|
12068
|
-
},
|
|
12069
|
-
deprecatedOptions: {
|
|
12070
|
-
fetchImages: "gltf.loadImages",
|
|
12071
|
-
createImages: "gltf.loadImages",
|
|
12072
|
-
decompress: "gltf.decompressMeshes",
|
|
12073
|
-
postProcess: "gltf.postProcess",
|
|
12074
|
-
gltf: {
|
|
12075
|
-
decompress: "gltf.decompressMeshes"
|
|
12180
|
+
if (camera.orthographic) {
|
|
12076
12181
|
}
|
|
12182
|
+
return camera;
|
|
12077
12183
|
}
|
|
12078
12184
|
};
|
|
12079
12185
|
}
|
|
@@ -12083,6 +12189,8 @@
|
|
|
12083
12189
|
var init_src10 = __esm({
|
|
12084
12190
|
"../gltf/src/index.ts"() {
|
|
12085
12191
|
init_gltf_loader();
|
|
12192
|
+
init_post_process_gltf();
|
|
12193
|
+
init_gltf_utils();
|
|
12086
12194
|
}
|
|
12087
12195
|
});
|
|
12088
12196
|
|
|
@@ -12113,7 +12221,9 @@
|
|
|
12113
12221
|
tile.gltfByteOffset = 0;
|
|
12114
12222
|
}
|
|
12115
12223
|
if (tile.gltfArrayBuffer) {
|
|
12116
|
-
|
|
12224
|
+
const gltfWithBuffers = await parse5(tile.gltfArrayBuffer, GLTFLoader, options, context);
|
|
12225
|
+
tile.gltf = postProcessGLTF(gltfWithBuffers);
|
|
12226
|
+
tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
|
|
12117
12227
|
delete tile.gltfArrayBuffer;
|
|
12118
12228
|
delete tile.gltfByteOffset;
|
|
12119
12229
|
delete tile.gltfByteLength;
|
|
@@ -12355,7 +12465,9 @@
|
|
|
12355
12465
|
tile.rotateYtoZ = true;
|
|
12356
12466
|
tile.gltfUpAxis = options["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
|
|
12357
12467
|
const { parse: parse5 } = context;
|
|
12358
|
-
|
|
12468
|
+
const gltfWithBuffers = await parse5(arrayBuffer, GLTFLoader, options, context);
|
|
12469
|
+
tile.gltf = postProcessGLTF(gltfWithBuffers);
|
|
12470
|
+
tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
|
|
12359
12471
|
}
|
|
12360
12472
|
var init_parse_3d_tile_gltf = __esm({
|
|
12361
12473
|
"src/lib/parsers/parse-3d-tile-gltf.ts"() {
|
|
@@ -13936,7 +14048,7 @@
|
|
|
13936
14048
|
if (!tile.contentUrl) {
|
|
13937
14049
|
return TILE_TYPE.EMPTY;
|
|
13938
14050
|
}
|
|
13939
|
-
const contentUrl = tile.contentUrl;
|
|
14051
|
+
const contentUrl = tile.contentUrl.split("?")[0];
|
|
13940
14052
|
const fileExtension = contentUrl.split(".").pop();
|
|
13941
14053
|
switch (fileExtension) {
|
|
13942
14054
|
case "pnts":
|
|
@@ -14087,8 +14199,27 @@
|
|
|
14087
14199
|
});
|
|
14088
14200
|
|
|
14089
14201
|
// src/tiles-3d-loader.ts
|
|
14090
|
-
function
|
|
14091
|
-
|
|
14202
|
+
async function parse4(data, options = {}, context) {
|
|
14203
|
+
const loaderOptions = options["3d-tiles"] || {};
|
|
14204
|
+
let isTileset;
|
|
14205
|
+
if (loaderOptions.isTileset === "auto") {
|
|
14206
|
+
isTileset = context?.url && context.url.indexOf(".json") !== -1;
|
|
14207
|
+
} else {
|
|
14208
|
+
isTileset = loaderOptions.isTileset;
|
|
14209
|
+
}
|
|
14210
|
+
return await isTileset ? parseTileset(data, options, context) : parseTile(data, options, context);
|
|
14211
|
+
}
|
|
14212
|
+
async function parseTileset(data, options, context) {
|
|
14213
|
+
const tilesetJson = JSON.parse(new TextDecoder().decode(data));
|
|
14214
|
+
tilesetJson.loader = options?.loader || Tiles3DLoader;
|
|
14215
|
+
tilesetJson.url = context?.url || "";
|
|
14216
|
+
tilesetJson.queryString = context?.queryString || "";
|
|
14217
|
+
tilesetJson.basePath = getBaseUri(tilesetJson);
|
|
14218
|
+
tilesetJson.root = await normalizeTileHeaders(tilesetJson, options || {});
|
|
14219
|
+
tilesetJson.type = TILESET_TYPE.TILES3D;
|
|
14220
|
+
tilesetJson.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
|
|
14221
|
+
tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
|
|
14222
|
+
return tilesetJson;
|
|
14092
14223
|
}
|
|
14093
14224
|
async function parseTile(arrayBuffer, options, context) {
|
|
14094
14225
|
const tile = {
|
|
@@ -14100,31 +14231,8 @@
|
|
|
14100
14231
|
await parse3DTile(arrayBuffer, byteOffset, options, context, tile.content);
|
|
14101
14232
|
return tile.content;
|
|
14102
14233
|
}
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
tilesetJson.loader = options.loader || Tiles3DLoader;
|
|
14106
|
-
tilesetJson.url = context.url;
|
|
14107
|
-
tilesetJson.basePath = getBaseUri(tilesetJson);
|
|
14108
|
-
tilesetJson.root = await normalizeTileHeaders(tilesetJson, options);
|
|
14109
|
-
tilesetJson.type = TILESET_TYPE.TILES3D;
|
|
14110
|
-
tilesetJson.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
|
|
14111
|
-
tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
|
|
14112
|
-
return tilesetJson;
|
|
14113
|
-
}
|
|
14114
|
-
async function parse4(data, options, context) {
|
|
14115
|
-
const loaderOptions = options["3d-tiles"] || {};
|
|
14116
|
-
let isTileset;
|
|
14117
|
-
if (loaderOptions.isTileset === "auto") {
|
|
14118
|
-
isTileset = context.url && context.url.indexOf(".json") !== -1;
|
|
14119
|
-
} else {
|
|
14120
|
-
isTileset = loaderOptions.isTileset;
|
|
14121
|
-
}
|
|
14122
|
-
if (isTileset) {
|
|
14123
|
-
data = await parseTileset(data, options, context);
|
|
14124
|
-
} else {
|
|
14125
|
-
data = await parseTile(data, options, context);
|
|
14126
|
-
}
|
|
14127
|
-
return data;
|
|
14234
|
+
function getBaseUri(tileset) {
|
|
14235
|
+
return path_exports.dirname(tileset.url);
|
|
14128
14236
|
}
|
|
14129
14237
|
var Tiles3DLoader;
|
|
14130
14238
|
var init_tiles_3d_loader = __esm({
|