@loaders.gl/3d-tiles 4.0.0-alpha.6 → 4.0.0-alpha.8
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 +1778 -1499
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +4 -3
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +33 -19
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +12 -12
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js +5 -5
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +23 -6
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-header.js +98 -80
- package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +12 -21
- 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 +29 -5
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/tiles-3d-loader.js +61 -62
- package/dist/es5/tiles-3d-loader.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js +3 -3
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +19 -11
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +7 -7
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js +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 +16 -6
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-header.js +62 -45
- package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js +12 -21
- 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 +23 -2
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/tiles-3d-loader.js +32 -28
- package/dist/esm/tiles-3d-loader.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +4 -2
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +3 -3
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +3 -2
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts +5 -2
- 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 +18 -10
- package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts +2 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts +4 -2
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +7 -7
- package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts +4 -1
- package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-batched-model.js +1 -1
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts +7 -1
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-composite.js +1 -3
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +4 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.js +13 -3
- package/dist/lib/parsers/parse-3d-tile-header.d.ts +6 -6
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-header.js +57 -42
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +4 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.js +11 -25
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +5 -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 +24 -2
- package/dist/lib/parsers/parse-3d-tile.d.ts +4 -1
- package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile.js +0 -4
- 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 +35 -32
- package/dist/types.d.ts +257 -15
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +12 -1
- package/src/lib/parsers/helpers/normalize-3d-tile-colors.ts +10 -4
- package/src/lib/parsers/helpers/normalize-3d-tile-normals.ts +7 -3
- package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +4 -4
- package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +39 -15
- package/src/lib/parsers/helpers/parse-3d-tile-header.ts +7 -1
- package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +1 -1
- package/src/lib/parsers/helpers/parse-3d-tile-tables.ts +32 -11
- package/src/lib/parsers/parse-3d-tile-batched-model.ts +18 -3
- package/src/lib/parsers/parse-3d-tile-composite.ts +20 -8
- package/src/lib/parsers/parse-3d-tile-gltf.ts +22 -5
- package/src/lib/parsers/parse-3d-tile-header.ts +86 -53
- package/src/lib/parsers/parse-3d-tile-instanced-model.ts +35 -30
- package/src/lib/parsers/parse-3d-tile-point-cloud.ts +71 -12
- package/src/lib/parsers/parse-3d-tile.ts +10 -5
- package/src/tiles-3d-loader.ts +68 -38
- package/src/types.ts +269 -15
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) {
|
|
@@ -6891,24 +6922,24 @@
|
|
|
6891
6922
|
var TILE_REFINEMENT, TILE_TYPE, TILESET_TYPE, LOD_METRIC_TYPE;
|
|
6892
6923
|
var init_constants3 = __esm({
|
|
6893
6924
|
"../tiles/src/constants.ts"() {
|
|
6894
|
-
|
|
6895
|
-
ADD
|
|
6896
|
-
REPLACE
|
|
6897
|
-
};
|
|
6898
|
-
|
|
6899
|
-
EMPTY
|
|
6900
|
-
SCENEGRAPH
|
|
6901
|
-
POINTCLOUD
|
|
6902
|
-
MESH
|
|
6903
|
-
};
|
|
6904
|
-
|
|
6905
|
-
I3S
|
|
6906
|
-
TILES3D
|
|
6907
|
-
};
|
|
6908
|
-
|
|
6909
|
-
GEOMETRIC_ERROR
|
|
6910
|
-
MAX_SCREEN_THRESHOLD
|
|
6911
|
-
};
|
|
6925
|
+
(function(TILE_REFINEMENT2) {
|
|
6926
|
+
TILE_REFINEMENT2[TILE_REFINEMENT2["ADD"] = 1] = "ADD";
|
|
6927
|
+
TILE_REFINEMENT2[TILE_REFINEMENT2["REPLACE"] = 2] = "REPLACE";
|
|
6928
|
+
})(TILE_REFINEMENT || (TILE_REFINEMENT = {}));
|
|
6929
|
+
(function(TILE_TYPE2) {
|
|
6930
|
+
TILE_TYPE2["EMPTY"] = "empty";
|
|
6931
|
+
TILE_TYPE2["SCENEGRAPH"] = "scenegraph";
|
|
6932
|
+
TILE_TYPE2["POINTCLOUD"] = "pointcloud";
|
|
6933
|
+
TILE_TYPE2["MESH"] = "mesh";
|
|
6934
|
+
})(TILE_TYPE || (TILE_TYPE = {}));
|
|
6935
|
+
(function(TILESET_TYPE2) {
|
|
6936
|
+
TILESET_TYPE2["I3S"] = "I3S";
|
|
6937
|
+
TILESET_TYPE2["TILES3D"] = "TILES3D";
|
|
6938
|
+
})(TILESET_TYPE || (TILESET_TYPE = {}));
|
|
6939
|
+
(function(LOD_METRIC_TYPE2) {
|
|
6940
|
+
LOD_METRIC_TYPE2["GEOMETRIC_ERROR"] = "geometricError";
|
|
6941
|
+
LOD_METRIC_TYPE2["MAX_SCREEN_THRESHOLD"] = "maxScreenThreshold";
|
|
6942
|
+
})(LOD_METRIC_TYPE || (LOD_METRIC_TYPE = {}));
|
|
6912
6943
|
}
|
|
6913
6944
|
});
|
|
6914
6945
|
|
|
@@ -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,
|
|
@@ -8423,26 +8453,26 @@
|
|
|
8423
8453
|
return byteOffset;
|
|
8424
8454
|
}
|
|
8425
8455
|
function parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options) {
|
|
8426
|
-
const { featureTableJsonByteLength, featureTableBinaryByteLength, batchLength } = tile.header;
|
|
8456
|
+
const { featureTableJsonByteLength, featureTableBinaryByteLength, batchLength } = tile.header || {};
|
|
8427
8457
|
tile.featureTableJson = {
|
|
8428
8458
|
BATCH_LENGTH: batchLength || 0
|
|
8429
8459
|
};
|
|
8430
|
-
if (featureTableJsonByteLength > 0) {
|
|
8460
|
+
if (featureTableJsonByteLength && featureTableJsonByteLength > 0) {
|
|
8431
8461
|
const featureTableString = getStringFromArrayBuffer(arrayBuffer, byteOffset, featureTableJsonByteLength);
|
|
8432
8462
|
tile.featureTableJson = JSON.parse(featureTableString);
|
|
8433
8463
|
}
|
|
8434
|
-
byteOffset += featureTableJsonByteLength;
|
|
8464
|
+
byteOffset += featureTableJsonByteLength || 0;
|
|
8435
8465
|
tile.featureTableBinary = new Uint8Array(arrayBuffer, byteOffset, featureTableBinaryByteLength);
|
|
8436
|
-
byteOffset += featureTableBinaryByteLength;
|
|
8466
|
+
byteOffset += featureTableBinaryByteLength || 0;
|
|
8437
8467
|
return byteOffset;
|
|
8438
8468
|
}
|
|
8439
8469
|
function parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options) {
|
|
8440
|
-
const { batchTableJsonByteLength, batchTableBinaryByteLength } = tile.header;
|
|
8441
|
-
if (batchTableJsonByteLength > 0) {
|
|
8470
|
+
const { batchTableJsonByteLength, batchTableBinaryByteLength } = tile.header || {};
|
|
8471
|
+
if (batchTableJsonByteLength && batchTableJsonByteLength > 0) {
|
|
8442
8472
|
const batchTableString = getStringFromArrayBuffer(arrayBuffer, byteOffset, batchTableJsonByteLength);
|
|
8443
8473
|
tile.batchTableJson = JSON.parse(batchTableString);
|
|
8444
8474
|
byteOffset += batchTableJsonByteLength;
|
|
8445
|
-
if (batchTableBinaryByteLength > 0) {
|
|
8475
|
+
if (batchTableBinaryByteLength && batchTableBinaryByteLength > 0) {
|
|
8446
8476
|
tile.batchTableBinary = new Uint8Array(arrayBuffer, byteOffset, batchTableBinaryByteLength);
|
|
8447
8477
|
tile.batchTableBinary = new Uint8Array(tile.batchTableBinary);
|
|
8448
8478
|
byteOffset += batchTableBinaryByteLength;
|
|
@@ -8464,7 +8494,7 @@
|
|
|
8464
8494
|
if (!colors && (!tile || !tile.batchIds || !batchTable)) {
|
|
8465
8495
|
return null;
|
|
8466
8496
|
}
|
|
8467
|
-
const { batchIds, isRGB565, pointCount } = tile;
|
|
8497
|
+
const { batchIds, isRGB565, pointCount = 0 } = tile;
|
|
8468
8498
|
if (batchIds && batchTable) {
|
|
8469
8499
|
const colorArray = new Uint8ClampedArray(pointCount * 3);
|
|
8470
8500
|
for (let i2 = 0; i2 < pointCount; i2++) {
|
|
@@ -8482,7 +8512,7 @@
|
|
|
8482
8512
|
normalized: true
|
|
8483
8513
|
};
|
|
8484
8514
|
}
|
|
8485
|
-
if (isRGB565) {
|
|
8515
|
+
if (colors && isRGB565) {
|
|
8486
8516
|
const colorArray = new Uint8ClampedArray(pointCount * 3);
|
|
8487
8517
|
for (let i2 = 0; i2 < pointCount; i2++) {
|
|
8488
8518
|
const color = decodeRGB565(colors[i2]);
|
|
@@ -8507,7 +8537,7 @@
|
|
|
8507
8537
|
}
|
|
8508
8538
|
return {
|
|
8509
8539
|
type: GL2.UNSIGNED_BYTE,
|
|
8510
|
-
value: colors,
|
|
8540
|
+
value: colors || new Uint8ClampedArray(),
|
|
8511
8541
|
size: 4,
|
|
8512
8542
|
normalized: true
|
|
8513
8543
|
};
|
|
@@ -8524,8 +8554,8 @@
|
|
|
8524
8554
|
return null;
|
|
8525
8555
|
}
|
|
8526
8556
|
if (tile.isOctEncoded16P) {
|
|
8527
|
-
const decodedArray = new Float32Array(tile.pointsLength * 3);
|
|
8528
|
-
for (let i2 = 0; i2 < tile.pointsLength; i2++) {
|
|
8557
|
+
const decodedArray = new Float32Array((tile.pointsLength || 0) * 3);
|
|
8558
|
+
for (let i2 = 0; i2 < (tile.pointsLength || 0); i2++) {
|
|
8529
8559
|
octDecode(normals[i2 * 2], normals[i2 * 2 + 1], scratchNormal4);
|
|
8530
8560
|
scratchNormal4.toArray(decodedArray, i2 * 3);
|
|
8531
8561
|
}
|
|
@@ -8621,6 +8651,12 @@
|
|
|
8621
8651
|
return { featureTable, batchTable };
|
|
8622
8652
|
}
|
|
8623
8653
|
function parsePositions(tile, featureTable, options) {
|
|
8654
|
+
tile.attributes = tile.attributes || {
|
|
8655
|
+
positions: null,
|
|
8656
|
+
colors: null,
|
|
8657
|
+
normals: null,
|
|
8658
|
+
batchIds: null
|
|
8659
|
+
};
|
|
8624
8660
|
if (!tile.attributes.positions) {
|
|
8625
8661
|
if (featureTable.hasProperty("POSITION")) {
|
|
8626
8662
|
tile.attributes.positions = featureTable.getPropertyArray("POSITION", GL2.FLOAT, 3);
|
|
@@ -8644,6 +8680,12 @@
|
|
|
8644
8680
|
}
|
|
8645
8681
|
}
|
|
8646
8682
|
function parseColors(tile, featureTable, batchTable) {
|
|
8683
|
+
tile.attributes = tile.attributes || {
|
|
8684
|
+
positions: null,
|
|
8685
|
+
colors: null,
|
|
8686
|
+
normals: null,
|
|
8687
|
+
batchIds: null
|
|
8688
|
+
};
|
|
8647
8689
|
if (!tile.attributes.colors) {
|
|
8648
8690
|
let colors = null;
|
|
8649
8691
|
if (featureTable.hasProperty("RGBA")) {
|
|
@@ -8662,6 +8704,12 @@
|
|
|
8662
8704
|
}
|
|
8663
8705
|
}
|
|
8664
8706
|
function parseNormals(tile, featureTable) {
|
|
8707
|
+
tile.attributes = tile.attributes || {
|
|
8708
|
+
positions: null,
|
|
8709
|
+
colors: null,
|
|
8710
|
+
normals: null,
|
|
8711
|
+
batchIds: null
|
|
8712
|
+
};
|
|
8665
8713
|
if (!tile.attributes.normals) {
|
|
8666
8714
|
let normals = null;
|
|
8667
8715
|
if (featureTable.hasProperty("NORMAL")) {
|
|
@@ -8704,7 +8752,7 @@
|
|
|
8704
8752
|
if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {
|
|
8705
8753
|
throw new Error("Draco properties, byteOffset, and byteLength must be defined");
|
|
8706
8754
|
}
|
|
8707
|
-
dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
|
|
8755
|
+
dracoBuffer = (tile.featureTableBinary || []).slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
|
|
8708
8756
|
tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
|
|
8709
8757
|
tile.hasColors = Number.isFinite(dracoFeatureTableProperties.RGB) || Number.isFinite(dracoFeatureTableProperties.RGBA);
|
|
8710
8758
|
tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);
|
|
@@ -8724,11 +8772,14 @@
|
|
|
8724
8772
|
return await loadDraco(tile, dracoData, options, context);
|
|
8725
8773
|
}
|
|
8726
8774
|
async function loadDraco(tile, dracoData, options, context) {
|
|
8775
|
+
if (!context) {
|
|
8776
|
+
return;
|
|
8777
|
+
}
|
|
8727
8778
|
const { parse: parse5 } = context;
|
|
8728
8779
|
const dracoOptions = {
|
|
8729
8780
|
...options,
|
|
8730
8781
|
draco: {
|
|
8731
|
-
...options
|
|
8782
|
+
...options?.draco,
|
|
8732
8783
|
extraAttributes: dracoData.batchTableProperties || {}
|
|
8733
8784
|
}
|
|
8734
8785
|
};
|
|
@@ -8791,977 +8842,977 @@
|
|
|
8791
8842
|
}
|
|
8792
8843
|
});
|
|
8793
8844
|
|
|
8794
|
-
// ../
|
|
8845
|
+
// ../images/src/lib/utils/version.ts
|
|
8795
8846
|
var VERSION7;
|
|
8796
8847
|
var init_version5 = __esm({
|
|
8797
|
-
"../
|
|
8798
|
-
VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "
|
|
8848
|
+
"../images/src/lib/utils/version.ts"() {
|
|
8849
|
+
VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
8799
8850
|
}
|
|
8800
8851
|
});
|
|
8801
8852
|
|
|
8802
|
-
// ../
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8853
|
+
// ../images/src/lib/category-api/image-type.ts
|
|
8854
|
+
function isImageTypeSupported(type) {
|
|
8855
|
+
switch (type) {
|
|
8856
|
+
case "auto":
|
|
8857
|
+
return IMAGE_BITMAP_SUPPORTED || IMAGE_SUPPORTED || DATA_SUPPORTED;
|
|
8858
|
+
case "imagebitmap":
|
|
8859
|
+
return IMAGE_BITMAP_SUPPORTED;
|
|
8860
|
+
case "image":
|
|
8861
|
+
return IMAGE_SUPPORTED;
|
|
8862
|
+
case "data":
|
|
8863
|
+
return DATA_SUPPORTED;
|
|
8864
|
+
default:
|
|
8865
|
+
throw new Error(`@loaders.gl/images: image ${type} not supported in this environment`);
|
|
8807
8866
|
}
|
|
8808
|
-
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTrascoder(options);
|
|
8809
|
-
return await loadBasisTranscoderPromise;
|
|
8810
8867
|
}
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8868
|
+
function getDefaultImageType() {
|
|
8869
|
+
if (IMAGE_BITMAP_SUPPORTED) {
|
|
8870
|
+
return "imagebitmap";
|
|
8871
|
+
}
|
|
8872
|
+
if (IMAGE_SUPPORTED) {
|
|
8873
|
+
return "image";
|
|
8874
|
+
}
|
|
8875
|
+
if (DATA_SUPPORTED) {
|
|
8876
|
+
return "data";
|
|
8877
|
+
}
|
|
8878
|
+
throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");
|
|
8820
8879
|
}
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8880
|
+
var _parseImageNode, IMAGE_SUPPORTED, IMAGE_BITMAP_SUPPORTED, NODE_IMAGE_SUPPORTED, DATA_SUPPORTED;
|
|
8881
|
+
var init_image_type = __esm({
|
|
8882
|
+
"../images/src/lib/category-api/image-type.ts"() {
|
|
8883
|
+
init_src2();
|
|
8884
|
+
({ _parseImageNode } = globalThis);
|
|
8885
|
+
IMAGE_SUPPORTED = typeof Image !== "undefined";
|
|
8886
|
+
IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
|
|
8887
|
+
NODE_IMAGE_SUPPORTED = Boolean(_parseImageNode);
|
|
8888
|
+
DATA_SUPPORTED = isBrowser ? true : NODE_IMAGE_SUPPORTED;
|
|
8825
8889
|
}
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8890
|
+
});
|
|
8891
|
+
|
|
8892
|
+
// ../images/src/lib/category-api/parsed-image-api.ts
|
|
8893
|
+
function getImageType(image) {
|
|
8894
|
+
const format = getImageTypeOrNull(image);
|
|
8895
|
+
if (!format) {
|
|
8896
|
+
throw new Error("Not an image");
|
|
8897
|
+
}
|
|
8898
|
+
return format;
|
|
8833
8899
|
}
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8900
|
+
function getImageData(image) {
|
|
8901
|
+
switch (getImageType(image)) {
|
|
8902
|
+
case "data":
|
|
8903
|
+
return image;
|
|
8904
|
+
case "image":
|
|
8905
|
+
case "imagebitmap":
|
|
8906
|
+
const canvas = document.createElement("canvas");
|
|
8907
|
+
const context = canvas.getContext("2d");
|
|
8908
|
+
if (!context) {
|
|
8909
|
+
throw new Error("getImageData");
|
|
8910
|
+
}
|
|
8911
|
+
canvas.width = image.width;
|
|
8912
|
+
canvas.height = image.height;
|
|
8913
|
+
context.drawImage(image, 0, 0);
|
|
8914
|
+
return context.getImageData(0, 0, image.width, image.height);
|
|
8915
|
+
default:
|
|
8916
|
+
throw new Error("getImageData");
|
|
8838
8917
|
}
|
|
8839
|
-
loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
|
|
8840
|
-
return await loadBasisEncoderPromise;
|
|
8841
8918
|
}
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8919
|
+
function getImageTypeOrNull(image) {
|
|
8920
|
+
if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
|
|
8921
|
+
return "imagebitmap";
|
|
8922
|
+
}
|
|
8923
|
+
if (typeof Image !== "undefined" && image instanceof Image) {
|
|
8924
|
+
return "image";
|
|
8925
|
+
}
|
|
8926
|
+
if (image && typeof image === "object" && image.data && image.width && image.height) {
|
|
8927
|
+
return "data";
|
|
8928
|
+
}
|
|
8929
|
+
return null;
|
|
8851
8930
|
}
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
if (wasmBinary) {
|
|
8855
|
-
options.wasmBinary = wasmBinary;
|
|
8931
|
+
var init_parsed_image_api = __esm({
|
|
8932
|
+
"../images/src/lib/category-api/parsed-image-api.ts"() {
|
|
8856
8933
|
}
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8934
|
+
});
|
|
8935
|
+
|
|
8936
|
+
// ../images/src/lib/parsers/svg-utils.ts
|
|
8937
|
+
function isSVG(url) {
|
|
8938
|
+
return url && (SVG_DATA_URL_PATTERN.test(url) || SVG_URL_PATTERN.test(url));
|
|
8939
|
+
}
|
|
8940
|
+
function getBlobOrSVGDataUrl(arrayBuffer, url) {
|
|
8941
|
+
if (isSVG(url)) {
|
|
8942
|
+
const textDecoder = new TextDecoder();
|
|
8943
|
+
let xmlText = textDecoder.decode(arrayBuffer);
|
|
8944
|
+
try {
|
|
8945
|
+
if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
|
|
8946
|
+
xmlText = unescape(encodeURIComponent(xmlText));
|
|
8947
|
+
}
|
|
8948
|
+
} catch (error) {
|
|
8949
|
+
throw new Error(error.message);
|
|
8950
|
+
}
|
|
8951
|
+
const src = `data:image/svg+xml;base64,${btoa(xmlText)}`;
|
|
8952
|
+
return src;
|
|
8953
|
+
}
|
|
8954
|
+
return getBlob(arrayBuffer, url);
|
|
8955
|
+
}
|
|
8956
|
+
function getBlob(arrayBuffer, url) {
|
|
8957
|
+
if (isSVG(url)) {
|
|
8958
|
+
throw new Error("SVG cannot be parsed directly to imagebitmap");
|
|
8959
|
+
}
|
|
8960
|
+
return new Blob([new Uint8Array(arrayBuffer)]);
|
|
8961
|
+
}
|
|
8962
|
+
var SVG_DATA_URL_PATTERN, SVG_URL_PATTERN;
|
|
8963
|
+
var init_svg_utils = __esm({
|
|
8964
|
+
"../images/src/lib/parsers/svg-utils.ts"() {
|
|
8965
|
+
SVG_DATA_URL_PATTERN = /^data:image\/svg\+xml/;
|
|
8966
|
+
SVG_URL_PATTERN = /\.svg((\?|#).*)?$/;
|
|
8967
|
+
}
|
|
8968
|
+
});
|
|
8969
|
+
|
|
8970
|
+
// ../images/src/lib/parsers/parse-to-image.ts
|
|
8971
|
+
async function parseToImage(arrayBuffer, options, url) {
|
|
8972
|
+
const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);
|
|
8973
|
+
const URL2 = self.URL || self.webkitURL;
|
|
8974
|
+
const objectUrl = typeof blobOrDataUrl !== "string" && URL2.createObjectURL(blobOrDataUrl);
|
|
8975
|
+
try {
|
|
8976
|
+
return await loadToImage(objectUrl || blobOrDataUrl, options);
|
|
8977
|
+
} finally {
|
|
8978
|
+
if (objectUrl) {
|
|
8979
|
+
URL2.revokeObjectURL(objectUrl);
|
|
8980
|
+
}
|
|
8981
|
+
}
|
|
8982
|
+
}
|
|
8983
|
+
async function loadToImage(url, options) {
|
|
8984
|
+
const image = new Image();
|
|
8985
|
+
image.src = url;
|
|
8986
|
+
if (options.image && options.image.decode && image.decode) {
|
|
8987
|
+
await image.decode();
|
|
8988
|
+
return image;
|
|
8989
|
+
}
|
|
8990
|
+
return await new Promise((resolve2, reject) => {
|
|
8991
|
+
try {
|
|
8992
|
+
image.onload = () => resolve2(image);
|
|
8993
|
+
image.onerror = (err) => reject(new Error(`Could not load image ${url}: ${err}`));
|
|
8994
|
+
} catch (error) {
|
|
8995
|
+
reject(error);
|
|
8996
|
+
}
|
|
8863
8997
|
});
|
|
8864
8998
|
}
|
|
8865
|
-
var
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
init_src();
|
|
8869
|
-
VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
8870
|
-
BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION8}/dist/libs/basis_encoder.wasm`;
|
|
8871
|
-
BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION8}/dist/libs/basis_encoder.js`;
|
|
8999
|
+
var init_parse_to_image = __esm({
|
|
9000
|
+
"../images/src/lib/parsers/parse-to-image.ts"() {
|
|
9001
|
+
init_svg_utils();
|
|
8872
9002
|
}
|
|
8873
9003
|
});
|
|
8874
9004
|
|
|
8875
|
-
// ../
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
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
|
-
};
|
|
9005
|
+
// ../images/src/lib/parsers/parse-to-image-bitmap.ts
|
|
9006
|
+
async function parseToImageBitmap(arrayBuffer, options, url) {
|
|
9007
|
+
let blob;
|
|
9008
|
+
if (isSVG(url)) {
|
|
9009
|
+
const image = await parseToImage(arrayBuffer, options, url);
|
|
9010
|
+
blob = image;
|
|
9011
|
+
} else {
|
|
9012
|
+
blob = getBlob(arrayBuffer, url);
|
|
8939
9013
|
}
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
function
|
|
8944
|
-
if (!
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
}
|
|
9014
|
+
const imagebitmapOptions = options && options.imagebitmap;
|
|
9015
|
+
return await safeCreateImageBitmap(blob, imagebitmapOptions);
|
|
9016
|
+
}
|
|
9017
|
+
async function safeCreateImageBitmap(blob, imagebitmapOptions = null) {
|
|
9018
|
+
if (isEmptyObject(imagebitmapOptions) || !imagebitmapOptionsSupported) {
|
|
9019
|
+
imagebitmapOptions = null;
|
|
9020
|
+
}
|
|
9021
|
+
if (imagebitmapOptions) {
|
|
9022
|
+
try {
|
|
9023
|
+
return await createImageBitmap(blob, imagebitmapOptions);
|
|
9024
|
+
} catch (error) {
|
|
9025
|
+
console.warn(error);
|
|
9026
|
+
imagebitmapOptionsSupported = false;
|
|
8954
9027
|
}
|
|
8955
9028
|
}
|
|
8956
|
-
return
|
|
9029
|
+
return await createImageBitmap(blob);
|
|
8957
9030
|
}
|
|
8958
|
-
function
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
return canvas.getContext("webgl");
|
|
8962
|
-
} catch (error) {
|
|
8963
|
-
return null;
|
|
9031
|
+
function isEmptyObject(object) {
|
|
9032
|
+
for (const key in object || EMPTY_OBJECT) {
|
|
9033
|
+
return false;
|
|
8964
9034
|
}
|
|
9035
|
+
return true;
|
|
8965
9036
|
}
|
|
8966
|
-
var
|
|
8967
|
-
var
|
|
8968
|
-
"../
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
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;
|
|
8981
|
-
}
|
|
8982
|
-
});
|
|
8983
|
-
|
|
8984
|
-
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
8985
|
-
var t, n, i, s, a, r, o, l, f;
|
|
8986
|
-
var init_ktx_parse_modern = __esm({
|
|
8987
|
-
"../../node_modules/ktx-parse/dist/ktx-parse.modern.js"() {
|
|
8988
|
-
t = new Uint8Array([0]);
|
|
8989
|
-
!function(t2) {
|
|
8990
|
-
t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
|
|
8991
|
-
}(n || (n = {})), function(t2) {
|
|
8992
|
-
t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
|
|
8993
|
-
}(i || (i = {})), function(t2) {
|
|
8994
|
-
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
|
|
8995
|
-
}(s || (s = {})), function(t2) {
|
|
8996
|
-
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
|
|
8997
|
-
}(a || (a = {})), function(t2) {
|
|
8998
|
-
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";
|
|
8999
|
-
}(r || (r = {})), function(t2) {
|
|
9000
|
-
t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
|
|
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 = {}));
|
|
9037
|
+
var EMPTY_OBJECT, imagebitmapOptionsSupported;
|
|
9038
|
+
var init_parse_to_image_bitmap = __esm({
|
|
9039
|
+
"../images/src/lib/parsers/parse-to-image-bitmap.ts"() {
|
|
9040
|
+
init_svg_utils();
|
|
9041
|
+
init_parse_to_image();
|
|
9042
|
+
EMPTY_OBJECT = {};
|
|
9043
|
+
imagebitmapOptionsSupported = true;
|
|
9006
9044
|
}
|
|
9007
9045
|
});
|
|
9008
9046
|
|
|
9009
|
-
// ../
|
|
9010
|
-
function
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
return !notKTX;
|
|
9014
|
-
}
|
|
9015
|
-
var KTX2_ID;
|
|
9016
|
-
var init_parse_ktx = __esm({
|
|
9017
|
-
"../textures/src/lib/parsers/parse-ktx.ts"() {
|
|
9018
|
-
init_ktx_parse_modern();
|
|
9019
|
-
KTX2_ID = [
|
|
9020
|
-
171,
|
|
9021
|
-
75,
|
|
9022
|
-
84,
|
|
9023
|
-
88,
|
|
9024
|
-
32,
|
|
9025
|
-
50,
|
|
9026
|
-
48,
|
|
9027
|
-
187,
|
|
9028
|
-
13,
|
|
9029
|
-
10,
|
|
9030
|
-
26,
|
|
9031
|
-
10
|
|
9032
|
-
];
|
|
9047
|
+
// ../images/src/lib/category-api/parse-isobmff-binary.ts
|
|
9048
|
+
function getISOBMFFMediaType(buffer) {
|
|
9049
|
+
if (!checkString(buffer, "ftyp", 4)) {
|
|
9050
|
+
return null;
|
|
9033
9051
|
}
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
// ../textures/src/lib/parsers/parse-basis.ts
|
|
9037
|
-
async function parseBasis(data, options) {
|
|
9038
|
-
if (options.basis.containerFormat === "auto") {
|
|
9039
|
-
if (isKTX(data)) {
|
|
9040
|
-
const fileConstructors = await loadBasisEncoderModule(options);
|
|
9041
|
-
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
9042
|
-
}
|
|
9043
|
-
const { BasisFile } = await loadBasisTrascoderModule(options);
|
|
9044
|
-
return parseBasisFile(BasisFile, data, options);
|
|
9052
|
+
if ((buffer[8] & 96) === 0) {
|
|
9053
|
+
return null;
|
|
9045
9054
|
}
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
9055
|
-
}
|
|
9056
|
-
case "transcoder":
|
|
9055
|
+
return decodeMajorBrand(buffer);
|
|
9056
|
+
}
|
|
9057
|
+
function decodeMajorBrand(buffer) {
|
|
9058
|
+
const brandMajor = getUTF8String(buffer, 8, 12).replace("\0", " ").trim();
|
|
9059
|
+
switch (brandMajor) {
|
|
9060
|
+
case "avif":
|
|
9061
|
+
case "avis":
|
|
9062
|
+
return { extension: "avif", mimeType: "image/avif" };
|
|
9057
9063
|
default:
|
|
9058
|
-
|
|
9059
|
-
return parseBasisFile(BasisFile, data, options);
|
|
9064
|
+
return null;
|
|
9060
9065
|
}
|
|
9061
9066
|
}
|
|
9062
|
-
function
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
9074
|
-
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
9075
|
-
}
|
|
9076
|
-
images.push(levels);
|
|
9067
|
+
function getUTF8String(array, start, end) {
|
|
9068
|
+
return String.fromCharCode(...array.slice(start, end));
|
|
9069
|
+
}
|
|
9070
|
+
function stringToBytes(string) {
|
|
9071
|
+
return [...string].map((character) => character.charCodeAt(0));
|
|
9072
|
+
}
|
|
9073
|
+
function checkString(buffer, header, offset = 0) {
|
|
9074
|
+
const headerBytes = stringToBytes(header);
|
|
9075
|
+
for (let i2 = 0; i2 < headerBytes.length; ++i2) {
|
|
9076
|
+
if (headerBytes[i2] !== buffer[i2 + offset]) {
|
|
9077
|
+
return false;
|
|
9077
9078
|
}
|
|
9078
|
-
return images;
|
|
9079
|
-
} finally {
|
|
9080
|
-
basisFile.close();
|
|
9081
|
-
basisFile.delete();
|
|
9082
9079
|
}
|
|
9080
|
+
return true;
|
|
9083
9081
|
}
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9082
|
+
var init_parse_isobmff_binary = __esm({
|
|
9083
|
+
"../images/src/lib/category-api/parse-isobmff-binary.ts"() {
|
|
9084
|
+
}
|
|
9085
|
+
});
|
|
9086
|
+
|
|
9087
|
+
// ../images/src/lib/category-api/binary-image-api.ts
|
|
9088
|
+
function getBinaryImageMetadata(binaryData) {
|
|
9089
|
+
const dataView = toDataView(binaryData);
|
|
9090
|
+
return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView) || getISOBMFFMetadata(dataView);
|
|
9091
|
+
}
|
|
9092
|
+
function getISOBMFFMetadata(binaryData) {
|
|
9093
|
+
const buffer = new Uint8Array(binaryData instanceof DataView ? binaryData.buffer : binaryData);
|
|
9094
|
+
const mediaType = getISOBMFFMediaType(buffer);
|
|
9095
|
+
if (!mediaType) {
|
|
9096
|
+
return null;
|
|
9093
9097
|
}
|
|
9094
9098
|
return {
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
compressed,
|
|
9099
|
-
format,
|
|
9100
|
-
hasAlpha
|
|
9099
|
+
mimeType: mediaType.mimeType,
|
|
9100
|
+
width: 0,
|
|
9101
|
+
height: 0
|
|
9101
9102
|
};
|
|
9102
9103
|
}
|
|
9103
|
-
function
|
|
9104
|
-
const
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
}
|
|
9109
|
-
const levelsCount = ktx2File.getLevels();
|
|
9110
|
-
const levels = [];
|
|
9111
|
-
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
9112
|
-
levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
|
|
9113
|
-
break;
|
|
9114
|
-
}
|
|
9115
|
-
return [levels];
|
|
9116
|
-
} finally {
|
|
9117
|
-
ktx2File.close();
|
|
9118
|
-
ktx2File.delete();
|
|
9104
|
+
function getPngMetadata(binaryData) {
|
|
9105
|
+
const dataView = toDataView(binaryData);
|
|
9106
|
+
const isPng = dataView.byteLength >= 24 && dataView.getUint32(0, BIG_ENDIAN) === 2303741511;
|
|
9107
|
+
if (!isPng) {
|
|
9108
|
+
return null;
|
|
9119
9109
|
}
|
|
9110
|
+
return {
|
|
9111
|
+
mimeType: "image/png",
|
|
9112
|
+
width: dataView.getUint32(16, BIG_ENDIAN),
|
|
9113
|
+
height: dataView.getUint32(20, BIG_ENDIAN)
|
|
9114
|
+
};
|
|
9120
9115
|
}
|
|
9121
|
-
function
|
|
9122
|
-
const
|
|
9123
|
-
const
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
|
|
9127
|
-
throw new Error("Failed to transcode KTX2 image");
|
|
9116
|
+
function getGifMetadata(binaryData) {
|
|
9117
|
+
const dataView = toDataView(binaryData);
|
|
9118
|
+
const isGif = dataView.byteLength >= 10 && dataView.getUint32(0, BIG_ENDIAN) === 1195984440;
|
|
9119
|
+
if (!isGif) {
|
|
9120
|
+
return null;
|
|
9128
9121
|
}
|
|
9129
9122
|
return {
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
compressed,
|
|
9134
|
-
levelSize: decodedSize,
|
|
9135
|
-
hasAlpha: alphaFlag,
|
|
9136
|
-
format
|
|
9123
|
+
mimeType: "image/gif",
|
|
9124
|
+
width: dataView.getUint16(6, LITTLE_ENDIAN),
|
|
9125
|
+
height: dataView.getUint16(8, LITTLE_ENDIAN)
|
|
9137
9126
|
};
|
|
9138
9127
|
}
|
|
9139
|
-
function
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9128
|
+
function getBmpMetadata(binaryData) {
|
|
9129
|
+
const dataView = toDataView(binaryData);
|
|
9130
|
+
const isBmp = dataView.byteLength >= 14 && dataView.getUint16(0, BIG_ENDIAN) === 16973 && dataView.getUint32(2, LITTLE_ENDIAN) === dataView.byteLength;
|
|
9131
|
+
if (!isBmp) {
|
|
9132
|
+
return null;
|
|
9143
9133
|
}
|
|
9144
|
-
|
|
9145
|
-
|
|
9134
|
+
return {
|
|
9135
|
+
mimeType: "image/bmp",
|
|
9136
|
+
width: dataView.getUint32(18, LITTLE_ENDIAN),
|
|
9137
|
+
height: dataView.getUint32(22, LITTLE_ENDIAN)
|
|
9138
|
+
};
|
|
9139
|
+
}
|
|
9140
|
+
function getJpegMetadata(binaryData) {
|
|
9141
|
+
const dataView = toDataView(binaryData);
|
|
9142
|
+
const isJpeg = dataView.byteLength >= 3 && dataView.getUint16(0, BIG_ENDIAN) === 65496 && dataView.getUint8(2) === 255;
|
|
9143
|
+
if (!isJpeg) {
|
|
9144
|
+
return null;
|
|
9146
9145
|
}
|
|
9147
|
-
|
|
9148
|
-
|
|
9146
|
+
const { tableMarkers, sofMarkers } = getJpegMarkers();
|
|
9147
|
+
let i2 = 2;
|
|
9148
|
+
while (i2 + 9 < dataView.byteLength) {
|
|
9149
|
+
const marker2 = dataView.getUint16(i2, BIG_ENDIAN);
|
|
9150
|
+
if (sofMarkers.has(marker2)) {
|
|
9151
|
+
return {
|
|
9152
|
+
mimeType: "image/jpeg",
|
|
9153
|
+
height: dataView.getUint16(i2 + 5, BIG_ENDIAN),
|
|
9154
|
+
width: dataView.getUint16(i2 + 7, BIG_ENDIAN)
|
|
9155
|
+
};
|
|
9156
|
+
}
|
|
9157
|
+
if (!tableMarkers.has(marker2)) {
|
|
9158
|
+
return null;
|
|
9159
|
+
}
|
|
9160
|
+
i2 += 2;
|
|
9161
|
+
i2 += dataView.getUint16(i2, BIG_ENDIAN);
|
|
9162
|
+
}
|
|
9163
|
+
return null;
|
|
9149
9164
|
}
|
|
9150
|
-
function
|
|
9151
|
-
const
|
|
9152
|
-
|
|
9153
|
-
|
|
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";
|
|
9165
|
+
function getJpegMarkers() {
|
|
9166
|
+
const tableMarkers = new Set([65499, 65476, 65484, 65501, 65534]);
|
|
9167
|
+
for (let i2 = 65504; i2 < 65520; ++i2) {
|
|
9168
|
+
tableMarkers.add(i2);
|
|
9168
9169
|
}
|
|
9169
|
-
|
|
9170
|
+
const sofMarkers = new Set([
|
|
9171
|
+
65472,
|
|
9172
|
+
65473,
|
|
9173
|
+
65474,
|
|
9174
|
+
65475,
|
|
9175
|
+
65477,
|
|
9176
|
+
65478,
|
|
9177
|
+
65479,
|
|
9178
|
+
65481,
|
|
9179
|
+
65482,
|
|
9180
|
+
65483,
|
|
9181
|
+
65485,
|
|
9182
|
+
65486,
|
|
9183
|
+
65487,
|
|
9184
|
+
65502
|
|
9185
|
+
]);
|
|
9186
|
+
return { tableMarkers, sofMarkers };
|
|
9170
9187
|
}
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
init_basis_module_loader();
|
|
9175
|
-
init_gl_extensions();
|
|
9176
|
-
init_texture_formats();
|
|
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
|
-
};
|
|
9188
|
+
function toDataView(data) {
|
|
9189
|
+
if (data instanceof DataView) {
|
|
9190
|
+
return data;
|
|
9221
9191
|
}
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
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
|
-
};
|
|
9192
|
+
if (ArrayBuffer.isView(data)) {
|
|
9193
|
+
return new DataView(data.buffer);
|
|
9194
|
+
}
|
|
9195
|
+
if (data instanceof ArrayBuffer) {
|
|
9196
|
+
return new DataView(data);
|
|
9197
|
+
}
|
|
9198
|
+
throw new Error("toDataView");
|
|
9199
|
+
}
|
|
9200
|
+
var BIG_ENDIAN, LITTLE_ENDIAN;
|
|
9201
|
+
var init_binary_image_api = __esm({
|
|
9202
|
+
"../images/src/lib/category-api/binary-image-api.ts"() {
|
|
9203
|
+
init_parse_isobmff_binary();
|
|
9204
|
+
BIG_ENDIAN = false;
|
|
9205
|
+
LITTLE_ENDIAN = true;
|
|
9254
9206
|
}
|
|
9255
9207
|
});
|
|
9256
9208
|
|
|
9257
|
-
// ../images/src/lib/
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9209
|
+
// ../images/src/lib/parsers/parse-to-node-image.ts
|
|
9210
|
+
async function parseToNodeImage(arrayBuffer, options) {
|
|
9211
|
+
const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
|
|
9212
|
+
const _parseImageNode2 = globalThis._parseImageNode;
|
|
9213
|
+
assert2(_parseImageNode2);
|
|
9214
|
+
return await _parseImageNode2(arrayBuffer, mimeType);
|
|
9215
|
+
}
|
|
9216
|
+
var init_parse_to_node_image = __esm({
|
|
9217
|
+
"../images/src/lib/parsers/parse-to-node-image.ts"() {
|
|
9218
|
+
init_src2();
|
|
9219
|
+
init_binary_image_api();
|
|
9262
9220
|
}
|
|
9263
9221
|
});
|
|
9264
9222
|
|
|
9265
|
-
// ../images/src/lib/
|
|
9266
|
-
function
|
|
9267
|
-
|
|
9268
|
-
|
|
9269
|
-
|
|
9223
|
+
// ../images/src/lib/parsers/parse-image.ts
|
|
9224
|
+
async function parseImage(arrayBuffer, options, context) {
|
|
9225
|
+
options = options || {};
|
|
9226
|
+
const imageOptions = options.image || {};
|
|
9227
|
+
const imageType = imageOptions.type || "auto";
|
|
9228
|
+
const { url } = context || {};
|
|
9229
|
+
const loadType = getLoadableImageType(imageType);
|
|
9230
|
+
let image;
|
|
9231
|
+
switch (loadType) {
|
|
9270
9232
|
case "imagebitmap":
|
|
9271
|
-
|
|
9233
|
+
image = await parseToImageBitmap(arrayBuffer, options, url);
|
|
9234
|
+
break;
|
|
9272
9235
|
case "image":
|
|
9273
|
-
|
|
9236
|
+
image = await parseToImage(arrayBuffer, options, url);
|
|
9237
|
+
break;
|
|
9274
9238
|
case "data":
|
|
9275
|
-
|
|
9239
|
+
image = await parseToNodeImage(arrayBuffer, options);
|
|
9240
|
+
break;
|
|
9276
9241
|
default:
|
|
9277
|
-
|
|
9278
|
-
}
|
|
9279
|
-
}
|
|
9280
|
-
function getDefaultImageType() {
|
|
9281
|
-
if (IMAGE_BITMAP_SUPPORTED) {
|
|
9282
|
-
return "imagebitmap";
|
|
9242
|
+
assert2(false);
|
|
9283
9243
|
}
|
|
9284
|
-
if (
|
|
9285
|
-
|
|
9244
|
+
if (imageType === "data") {
|
|
9245
|
+
image = getImageData(image);
|
|
9286
9246
|
}
|
|
9287
|
-
|
|
9288
|
-
|
|
9247
|
+
return image;
|
|
9248
|
+
}
|
|
9249
|
+
function getLoadableImageType(type) {
|
|
9250
|
+
switch (type) {
|
|
9251
|
+
case "auto":
|
|
9252
|
+
case "data":
|
|
9253
|
+
return getDefaultImageType();
|
|
9254
|
+
default:
|
|
9255
|
+
isImageTypeSupported(type);
|
|
9256
|
+
return type;
|
|
9289
9257
|
}
|
|
9290
|
-
throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");
|
|
9291
9258
|
}
|
|
9292
|
-
var
|
|
9293
|
-
|
|
9294
|
-
"../images/src/lib/category-api/image-type.ts"() {
|
|
9259
|
+
var init_parse_image = __esm({
|
|
9260
|
+
"../images/src/lib/parsers/parse-image.ts"() {
|
|
9295
9261
|
init_src2();
|
|
9296
|
-
(
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9262
|
+
init_image_type();
|
|
9263
|
+
init_parsed_image_api();
|
|
9264
|
+
init_parse_to_image();
|
|
9265
|
+
init_parse_to_image_bitmap();
|
|
9266
|
+
init_parse_to_node_image();
|
|
9301
9267
|
}
|
|
9302
9268
|
});
|
|
9303
9269
|
|
|
9304
|
-
// ../images/src/
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9270
|
+
// ../images/src/image-loader.ts
|
|
9271
|
+
var EXTENSIONS, MIME_TYPES, DEFAULT_IMAGE_LOADER_OPTIONS, ImageLoader;
|
|
9272
|
+
var init_image_loader = __esm({
|
|
9273
|
+
"../images/src/image-loader.ts"() {
|
|
9274
|
+
init_version5();
|
|
9275
|
+
init_parse_image();
|
|
9276
|
+
init_binary_image_api();
|
|
9277
|
+
EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
|
|
9278
|
+
MIME_TYPES = [
|
|
9279
|
+
"image/png",
|
|
9280
|
+
"image/jpeg",
|
|
9281
|
+
"image/gif",
|
|
9282
|
+
"image/webp",
|
|
9283
|
+
"image/avif",
|
|
9284
|
+
"image/bmp",
|
|
9285
|
+
"image/vnd.microsoft.icon",
|
|
9286
|
+
"image/svg+xml"
|
|
9287
|
+
];
|
|
9288
|
+
DEFAULT_IMAGE_LOADER_OPTIONS = {
|
|
9289
|
+
image: {
|
|
9290
|
+
type: "auto",
|
|
9291
|
+
decode: true
|
|
9322
9292
|
}
|
|
9323
|
-
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
if (typeof Image !== "undefined" && image instanceof Image) {
|
|
9336
|
-
return "image";
|
|
9337
|
-
}
|
|
9338
|
-
if (image && typeof image === "object" && image.data && image.width && image.height) {
|
|
9339
|
-
return "data";
|
|
9340
|
-
}
|
|
9341
|
-
return null;
|
|
9342
|
-
}
|
|
9343
|
-
var init_parsed_image_api = __esm({
|
|
9344
|
-
"../images/src/lib/category-api/parsed-image-api.ts"() {
|
|
9293
|
+
};
|
|
9294
|
+
ImageLoader = {
|
|
9295
|
+
id: "image",
|
|
9296
|
+
module: "images",
|
|
9297
|
+
name: "Images",
|
|
9298
|
+
version: VERSION7,
|
|
9299
|
+
mimeTypes: MIME_TYPES,
|
|
9300
|
+
extensions: EXTENSIONS,
|
|
9301
|
+
parse: parseImage,
|
|
9302
|
+
tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
|
|
9303
|
+
options: DEFAULT_IMAGE_LOADER_OPTIONS
|
|
9304
|
+
};
|
|
9345
9305
|
}
|
|
9346
9306
|
});
|
|
9347
9307
|
|
|
9348
|
-
// ../images/src/lib/
|
|
9349
|
-
function
|
|
9350
|
-
|
|
9308
|
+
// ../images/src/lib/category-api/image-format.ts
|
|
9309
|
+
function isImageFormatSupported(mimeType) {
|
|
9310
|
+
if (mimeTypeSupportedSync[mimeType] === void 0) {
|
|
9311
|
+
const supported = isBrowser ? checkBrowserImageFormatSupport(mimeType) : checkNodeImageFormatSupport(mimeType);
|
|
9312
|
+
mimeTypeSupportedSync[mimeType] = supported;
|
|
9313
|
+
}
|
|
9314
|
+
return mimeTypeSupportedSync[mimeType];
|
|
9351
9315
|
}
|
|
9352
|
-
function
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
return src;
|
|
9316
|
+
function checkNodeImageFormatSupport(mimeType) {
|
|
9317
|
+
const NODE_FORMAT_SUPPORT = ["image/png", "image/jpeg", "image/gif"];
|
|
9318
|
+
const { _parseImageNode: _parseImageNode2, _imageFormatsNode = NODE_FORMAT_SUPPORT } = globalThis;
|
|
9319
|
+
return Boolean(_parseImageNode2) && _imageFormatsNode.includes(mimeType);
|
|
9320
|
+
}
|
|
9321
|
+
function checkBrowserImageFormatSupport(mimeType) {
|
|
9322
|
+
switch (mimeType) {
|
|
9323
|
+
case "image/avif":
|
|
9324
|
+
case "image/webp":
|
|
9325
|
+
return testBrowserImageFormatSupport(mimeType);
|
|
9326
|
+
default:
|
|
9327
|
+
return true;
|
|
9365
9328
|
}
|
|
9366
|
-
return getBlob(arrayBuffer, url);
|
|
9367
9329
|
}
|
|
9368
|
-
function
|
|
9369
|
-
|
|
9370
|
-
|
|
9330
|
+
function testBrowserImageFormatSupport(mimeType) {
|
|
9331
|
+
try {
|
|
9332
|
+
const element = document.createElement("canvas");
|
|
9333
|
+
const dataURL = element.toDataURL(mimeType);
|
|
9334
|
+
return dataURL.indexOf(`data:${mimeType}`) === 0;
|
|
9335
|
+
} catch {
|
|
9336
|
+
return false;
|
|
9371
9337
|
}
|
|
9372
|
-
return new Blob([new Uint8Array(arrayBuffer)]);
|
|
9373
9338
|
}
|
|
9374
|
-
var
|
|
9375
|
-
var
|
|
9376
|
-
"../images/src/lib/
|
|
9377
|
-
|
|
9378
|
-
|
|
9339
|
+
var mimeTypeSupportedSync;
|
|
9340
|
+
var init_image_format = __esm({
|
|
9341
|
+
"../images/src/lib/category-api/image-format.ts"() {
|
|
9342
|
+
init_src2();
|
|
9343
|
+
mimeTypeSupportedSync = {};
|
|
9379
9344
|
}
|
|
9380
9345
|
});
|
|
9381
9346
|
|
|
9382
|
-
// ../images/src/
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
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;
|
|
9347
|
+
// ../images/src/index.ts
|
|
9348
|
+
var init_src8 = __esm({
|
|
9349
|
+
"../images/src/index.ts"() {
|
|
9350
|
+
init_image_loader();
|
|
9351
|
+
init_binary_image_api();
|
|
9352
|
+
init_parsed_image_api();
|
|
9353
|
+
init_image_format();
|
|
9401
9354
|
}
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
});
|
|
9410
|
-
}
|
|
9411
|
-
var init_parse_to_image = __esm({
|
|
9412
|
-
"../images/src/lib/parsers/parse-to-image.ts"() {
|
|
9413
|
-
init_svg_utils();
|
|
9355
|
+
});
|
|
9356
|
+
|
|
9357
|
+
// ../textures/src/lib/utils/version.ts
|
|
9358
|
+
var VERSION8;
|
|
9359
|
+
var init_version6 = __esm({
|
|
9360
|
+
"../textures/src/lib/utils/version.ts"() {
|
|
9361
|
+
VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
9414
9362
|
}
|
|
9415
9363
|
});
|
|
9416
9364
|
|
|
9417
|
-
// ../
|
|
9418
|
-
async function
|
|
9419
|
-
|
|
9420
|
-
if (
|
|
9421
|
-
|
|
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
|
-
}
|
|
9365
|
+
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
9366
|
+
async function loadBasisTrascoderModule(options) {
|
|
9367
|
+
const modules = options.modules || {};
|
|
9368
|
+
if (modules.basis) {
|
|
9369
|
+
return modules.basis;
|
|
9440
9370
|
}
|
|
9441
|
-
|
|
9371
|
+
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTrascoder(options);
|
|
9372
|
+
return await loadBasisTranscoderPromise;
|
|
9442
9373
|
}
|
|
9443
|
-
function
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9374
|
+
async function loadBasisTrascoder(options) {
|
|
9375
|
+
let BASIS = null;
|
|
9376
|
+
let wasmBinary = null;
|
|
9377
|
+
[BASIS, wasmBinary] = await Promise.all([
|
|
9378
|
+
await loadLibrary("basis_transcoder.js", "textures", options),
|
|
9379
|
+
await loadLibrary("basis_transcoder.wasm", "textures", options)
|
|
9380
|
+
]);
|
|
9381
|
+
BASIS = BASIS || globalThis.BASIS;
|
|
9382
|
+
return await initializeBasisTrascoderModule(BASIS, wasmBinary);
|
|
9448
9383
|
}
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
|
|
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;
|
|
9384
|
+
function initializeBasisTrascoderModule(BasisModule, wasmBinary) {
|
|
9385
|
+
const options = {};
|
|
9386
|
+
if (wasmBinary) {
|
|
9387
|
+
options.wasmBinary = wasmBinary;
|
|
9466
9388
|
}
|
|
9467
|
-
return
|
|
9389
|
+
return new Promise((resolve2) => {
|
|
9390
|
+
BasisModule(options).then((module) => {
|
|
9391
|
+
const { BasisFile, initializeBasis } = module;
|
|
9392
|
+
initializeBasis();
|
|
9393
|
+
resolve2({ BasisFile });
|
|
9394
|
+
});
|
|
9395
|
+
});
|
|
9468
9396
|
}
|
|
9469
|
-
function
|
|
9470
|
-
const
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
case "avis":
|
|
9474
|
-
return { extension: "avif", mimeType: "image/avif" };
|
|
9475
|
-
default:
|
|
9476
|
-
return null;
|
|
9397
|
+
async function loadBasisEncoderModule(options) {
|
|
9398
|
+
const modules = options.modules || {};
|
|
9399
|
+
if (modules.basisEncoder) {
|
|
9400
|
+
return modules.basisEncoder;
|
|
9477
9401
|
}
|
|
9402
|
+
loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
|
|
9403
|
+
return await loadBasisEncoderPromise;
|
|
9478
9404
|
}
|
|
9479
|
-
function
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9405
|
+
async function loadBasisEncoder(options) {
|
|
9406
|
+
let BASIS_ENCODER = null;
|
|
9407
|
+
let wasmBinary = null;
|
|
9408
|
+
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
9409
|
+
await loadLibrary(BASIS_CDN_ENCODER_JS, "textures", options),
|
|
9410
|
+
await loadLibrary(BASIS_CDN_ENCODER_WASM, "textures", options)
|
|
9411
|
+
]);
|
|
9412
|
+
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
9413
|
+
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
9484
9414
|
}
|
|
9485
|
-
function
|
|
9486
|
-
const
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
return false;
|
|
9490
|
-
}
|
|
9415
|
+
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
9416
|
+
const options = {};
|
|
9417
|
+
if (wasmBinary) {
|
|
9418
|
+
options.wasmBinary = wasmBinary;
|
|
9491
9419
|
}
|
|
9492
|
-
return
|
|
9420
|
+
return new Promise((resolve2) => {
|
|
9421
|
+
BasisEncoderModule(options).then((module) => {
|
|
9422
|
+
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
9423
|
+
initializeBasis();
|
|
9424
|
+
resolve2({ BasisFile, KTX2File, BasisEncoder });
|
|
9425
|
+
});
|
|
9426
|
+
});
|
|
9493
9427
|
}
|
|
9494
|
-
var
|
|
9495
|
-
|
|
9428
|
+
var VERSION9, BASIS_CDN_ENCODER_WASM, BASIS_CDN_ENCODER_JS, loadBasisTranscoderPromise, loadBasisEncoderPromise;
|
|
9429
|
+
var init_basis_module_loader = __esm({
|
|
9430
|
+
"../textures/src/lib/parsers/basis-module-loader.ts"() {
|
|
9431
|
+
init_src();
|
|
9432
|
+
VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
9433
|
+
BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION9}/dist/libs/basis_encoder.wasm`;
|
|
9434
|
+
BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION9}/dist/libs/basis_encoder.js`;
|
|
9496
9435
|
}
|
|
9497
9436
|
});
|
|
9498
9437
|
|
|
9499
|
-
// ../
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9438
|
+
// ../textures/src/lib/gl-extensions.ts
|
|
9439
|
+
var GL_EXTENSIONS_CONSTANTS;
|
|
9440
|
+
var init_gl_extensions = __esm({
|
|
9441
|
+
"../textures/src/lib/gl-extensions.ts"() {
|
|
9442
|
+
GL_EXTENSIONS_CONSTANTS = {
|
|
9443
|
+
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
|
|
9444
|
+
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
|
|
9445
|
+
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
|
|
9446
|
+
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
|
|
9447
|
+
COMPRESSED_R11_EAC: 37488,
|
|
9448
|
+
COMPRESSED_SIGNED_R11_EAC: 37489,
|
|
9449
|
+
COMPRESSED_RG11_EAC: 37490,
|
|
9450
|
+
COMPRESSED_SIGNED_RG11_EAC: 37491,
|
|
9451
|
+
COMPRESSED_RGB8_ETC2: 37492,
|
|
9452
|
+
COMPRESSED_RGBA8_ETC2_EAC: 37493,
|
|
9453
|
+
COMPRESSED_SRGB8_ETC2: 37494,
|
|
9454
|
+
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
9455
|
+
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
9456
|
+
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
9457
|
+
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
9458
|
+
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
9459
|
+
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
9460
|
+
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
9461
|
+
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
9462
|
+
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
9463
|
+
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
9464
|
+
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
9465
|
+
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
9466
|
+
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
9467
|
+
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
9468
|
+
COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
|
|
9469
|
+
COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
|
|
9470
|
+
COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
|
|
9471
|
+
COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
|
|
9472
|
+
COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
|
|
9473
|
+
COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
|
|
9474
|
+
COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
|
|
9475
|
+
COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
|
|
9476
|
+
COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
|
|
9477
|
+
COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
|
|
9478
|
+
COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
|
|
9479
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
|
|
9480
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
|
|
9481
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
|
|
9482
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
|
|
9483
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
|
|
9484
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
|
|
9485
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
|
|
9486
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
|
|
9487
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
|
|
9488
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
|
|
9489
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
|
|
9490
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
9491
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
9492
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
9493
|
+
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
9494
|
+
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
9495
|
+
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
9496
|
+
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
9497
|
+
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
9498
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
9499
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
9500
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
|
|
9501
|
+
};
|
|
9557
9502
|
}
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9503
|
+
});
|
|
9504
|
+
|
|
9505
|
+
// ../textures/src/lib/utils/texture-formats.ts
|
|
9506
|
+
function getSupportedGPUTextureFormats(gl) {
|
|
9507
|
+
if (!formats) {
|
|
9508
|
+
gl = gl || getWebGLContext() || void 0;
|
|
9509
|
+
formats = new Set();
|
|
9510
|
+
for (const prefix of BROWSER_PREFIXES) {
|
|
9511
|
+
for (const extension in WEBGL_EXTENSIONS) {
|
|
9512
|
+
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
9513
|
+
const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
|
|
9514
|
+
formats.add(gpuTextureFormat);
|
|
9515
|
+
}
|
|
9516
|
+
}
|
|
9571
9517
|
}
|
|
9572
|
-
i2 += 2;
|
|
9573
|
-
i2 += dataView.getUint16(i2, BIG_ENDIAN);
|
|
9574
9518
|
}
|
|
9575
|
-
return
|
|
9519
|
+
return formats;
|
|
9576
9520
|
}
|
|
9577
|
-
function
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9521
|
+
function getWebGLContext() {
|
|
9522
|
+
try {
|
|
9523
|
+
const canvas = document.createElement("canvas");
|
|
9524
|
+
return canvas.getContext("webgl");
|
|
9525
|
+
} catch (error) {
|
|
9526
|
+
return null;
|
|
9581
9527
|
}
|
|
9582
|
-
const sofMarkers = new Set([
|
|
9583
|
-
65472,
|
|
9584
|
-
65473,
|
|
9585
|
-
65474,
|
|
9586
|
-
65475,
|
|
9587
|
-
65477,
|
|
9588
|
-
65478,
|
|
9589
|
-
65479,
|
|
9590
|
-
65481,
|
|
9591
|
-
65482,
|
|
9592
|
-
65483,
|
|
9593
|
-
65485,
|
|
9594
|
-
65486,
|
|
9595
|
-
65487,
|
|
9596
|
-
65502
|
|
9597
|
-
]);
|
|
9598
|
-
return { tableMarkers, sofMarkers };
|
|
9599
9528
|
}
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9529
|
+
var BROWSER_PREFIXES, WEBGL_EXTENSIONS, formats;
|
|
9530
|
+
var init_texture_formats = __esm({
|
|
9531
|
+
"../textures/src/lib/utils/texture-formats.ts"() {
|
|
9532
|
+
BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
9533
|
+
WEBGL_EXTENSIONS = {
|
|
9534
|
+
WEBGL_compressed_texture_s3tc: "dxt",
|
|
9535
|
+
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
9536
|
+
WEBGL_compressed_texture_etc1: "etc1",
|
|
9537
|
+
WEBGL_compressed_texture_etc: "etc2",
|
|
9538
|
+
WEBGL_compressed_texture_pvrtc: "pvrtc",
|
|
9539
|
+
WEBGL_compressed_texture_atc: "atc",
|
|
9540
|
+
WEBGL_compressed_texture_astc: "astc",
|
|
9541
|
+
EXT_texture_compression_rgtc: "rgtc"
|
|
9542
|
+
};
|
|
9543
|
+
formats = null;
|
|
9606
9544
|
}
|
|
9607
|
-
|
|
9608
|
-
|
|
9545
|
+
});
|
|
9546
|
+
|
|
9547
|
+
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
9548
|
+
var t, n, i, s, a, r, o, l, f;
|
|
9549
|
+
var init_ktx_parse_modern = __esm({
|
|
9550
|
+
"../../node_modules/ktx-parse/dist/ktx-parse.modern.js"() {
|
|
9551
|
+
t = new Uint8Array([0]);
|
|
9552
|
+
!function(t2) {
|
|
9553
|
+
t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
|
|
9554
|
+
}(n || (n = {})), function(t2) {
|
|
9555
|
+
t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
|
|
9556
|
+
}(i || (i = {})), function(t2) {
|
|
9557
|
+
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
|
|
9558
|
+
}(s || (s = {})), function(t2) {
|
|
9559
|
+
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
|
|
9560
|
+
}(a || (a = {})), function(t2) {
|
|
9561
|
+
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";
|
|
9562
|
+
}(r || (r = {})), function(t2) {
|
|
9563
|
+
t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
|
|
9564
|
+
}(o || (o = {})), function(t2) {
|
|
9565
|
+
t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
|
|
9566
|
+
}(l || (l = {})), function(t2) {
|
|
9567
|
+
t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
|
|
9568
|
+
}(f || (f = {}));
|
|
9609
9569
|
}
|
|
9610
|
-
|
|
9570
|
+
});
|
|
9571
|
+
|
|
9572
|
+
// ../textures/src/lib/parsers/parse-ktx.ts
|
|
9573
|
+
function isKTX(data) {
|
|
9574
|
+
const id = new Uint8Array(data);
|
|
9575
|
+
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];
|
|
9576
|
+
return !notKTX;
|
|
9611
9577
|
}
|
|
9612
|
-
var
|
|
9613
|
-
var
|
|
9614
|
-
"../
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9578
|
+
var KTX2_ID;
|
|
9579
|
+
var init_parse_ktx = __esm({
|
|
9580
|
+
"../textures/src/lib/parsers/parse-ktx.ts"() {
|
|
9581
|
+
init_ktx_parse_modern();
|
|
9582
|
+
KTX2_ID = [
|
|
9583
|
+
171,
|
|
9584
|
+
75,
|
|
9585
|
+
84,
|
|
9586
|
+
88,
|
|
9587
|
+
32,
|
|
9588
|
+
50,
|
|
9589
|
+
48,
|
|
9590
|
+
187,
|
|
9591
|
+
13,
|
|
9592
|
+
10,
|
|
9593
|
+
26,
|
|
9594
|
+
10
|
|
9595
|
+
];
|
|
9618
9596
|
}
|
|
9619
9597
|
});
|
|
9620
9598
|
|
|
9621
|
-
// ../
|
|
9622
|
-
async function
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
init_src2();
|
|
9631
|
-
init_binary_image_api();
|
|
9599
|
+
// ../textures/src/lib/parsers/parse-basis.ts
|
|
9600
|
+
async function parseBasis(data, options) {
|
|
9601
|
+
if (options.basis.containerFormat === "auto") {
|
|
9602
|
+
if (isKTX(data)) {
|
|
9603
|
+
const fileConstructors = await loadBasisEncoderModule(options);
|
|
9604
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
9605
|
+
}
|
|
9606
|
+
const { BasisFile } = await loadBasisTrascoderModule(options);
|
|
9607
|
+
return parseBasisFile(BasisFile, data, options);
|
|
9632
9608
|
}
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
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;
|
|
9609
|
+
switch (options.basis.module) {
|
|
9610
|
+
case "encoder":
|
|
9611
|
+
const fileConstructors = await loadBasisEncoderModule(options);
|
|
9612
|
+
switch (options.basis.containerFormat) {
|
|
9613
|
+
case "ktx2":
|
|
9614
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
9615
|
+
case "basis":
|
|
9616
|
+
default:
|
|
9617
|
+
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
9618
|
+
}
|
|
9619
|
+
case "transcoder":
|
|
9653
9620
|
default:
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
if (imageType === "data") {
|
|
9657
|
-
image = getImageData(image);
|
|
9621
|
+
const { BasisFile } = await loadBasisTrascoderModule(options);
|
|
9622
|
+
return parseBasisFile(BasisFile, data, options);
|
|
9658
9623
|
}
|
|
9659
|
-
return image;
|
|
9660
9624
|
}
|
|
9661
|
-
function
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9625
|
+
function parseBasisFile(BasisFile, data, options) {
|
|
9626
|
+
const basisFile = new BasisFile(new Uint8Array(data));
|
|
9627
|
+
try {
|
|
9628
|
+
if (!basisFile.startTranscoding()) {
|
|
9629
|
+
throw new Error("Failed to start basis transcoding");
|
|
9630
|
+
}
|
|
9631
|
+
const imageCount = basisFile.getNumImages();
|
|
9632
|
+
const images = [];
|
|
9633
|
+
for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
|
|
9634
|
+
const levelsCount = basisFile.getNumLevels(imageIndex);
|
|
9635
|
+
const levels = [];
|
|
9636
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
9637
|
+
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
9638
|
+
}
|
|
9639
|
+
images.push(levels);
|
|
9640
|
+
}
|
|
9641
|
+
return images;
|
|
9642
|
+
} finally {
|
|
9643
|
+
basisFile.close();
|
|
9644
|
+
basisFile.delete();
|
|
9669
9645
|
}
|
|
9670
9646
|
}
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
});
|
|
9681
|
-
|
|
9682
|
-
// ../images/src/image-loader.ts
|
|
9683
|
-
var EXTENSIONS, MIME_TYPES, DEFAULT_IMAGE_LOADER_OPTIONS, ImageLoader;
|
|
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
|
|
9704
|
-
}
|
|
9705
|
-
};
|
|
9706
|
-
ImageLoader = {
|
|
9707
|
-
id: "image",
|
|
9708
|
-
module: "images",
|
|
9709
|
-
name: "Images",
|
|
9710
|
-
version: VERSION9,
|
|
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
|
-
};
|
|
9647
|
+
function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
9648
|
+
const width = basisFile.getImageWidth(imageIndex, levelIndex);
|
|
9649
|
+
const height = basisFile.getImageHeight(imageIndex, levelIndex);
|
|
9650
|
+
const hasAlpha = basisFile.getHasAlpha();
|
|
9651
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
9652
|
+
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
9653
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
9654
|
+
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
9655
|
+
throw new Error("failed to start Basis transcoding");
|
|
9717
9656
|
}
|
|
9718
|
-
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9657
|
+
return {
|
|
9658
|
+
width,
|
|
9659
|
+
height,
|
|
9660
|
+
data: decodedData,
|
|
9661
|
+
compressed,
|
|
9662
|
+
format,
|
|
9663
|
+
hasAlpha
|
|
9664
|
+
};
|
|
9665
|
+
}
|
|
9666
|
+
function parseKTX2File(KTX2File, data, options) {
|
|
9667
|
+
const ktx2File = new KTX2File(new Uint8Array(data));
|
|
9668
|
+
try {
|
|
9669
|
+
if (!ktx2File.startTranscoding()) {
|
|
9670
|
+
throw new Error("failed to start KTX2 transcoding");
|
|
9671
|
+
}
|
|
9672
|
+
const levelsCount = ktx2File.getLevels();
|
|
9673
|
+
const levels = [];
|
|
9674
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
9675
|
+
levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
|
|
9676
|
+
break;
|
|
9677
|
+
}
|
|
9678
|
+
return [levels];
|
|
9679
|
+
} finally {
|
|
9680
|
+
ktx2File.close();
|
|
9681
|
+
ktx2File.delete();
|
|
9725
9682
|
}
|
|
9726
|
-
return mimeTypeSupportedSync[mimeType];
|
|
9727
9683
|
}
|
|
9728
|
-
function
|
|
9729
|
-
const
|
|
9730
|
-
const {
|
|
9731
|
-
|
|
9684
|
+
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
9685
|
+
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
9686
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
|
|
9687
|
+
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
9688
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
9689
|
+
if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
|
|
9690
|
+
throw new Error("Failed to transcode KTX2 image");
|
|
9691
|
+
}
|
|
9692
|
+
return {
|
|
9693
|
+
width,
|
|
9694
|
+
height,
|
|
9695
|
+
data: decodedData,
|
|
9696
|
+
compressed,
|
|
9697
|
+
levelSize: decodedSize,
|
|
9698
|
+
hasAlpha: alphaFlag,
|
|
9699
|
+
format
|
|
9700
|
+
};
|
|
9732
9701
|
}
|
|
9733
|
-
function
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9702
|
+
function getBasisOptions(options, hasAlpha) {
|
|
9703
|
+
let format = options && options.basis && options.basis.format;
|
|
9704
|
+
if (format === "auto") {
|
|
9705
|
+
format = selectSupportedBasisFormat();
|
|
9706
|
+
}
|
|
9707
|
+
if (typeof format === "object") {
|
|
9708
|
+
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
9740
9709
|
}
|
|
9710
|
+
format = format.toLowerCase();
|
|
9711
|
+
return OutputFormat[format];
|
|
9741
9712
|
}
|
|
9742
|
-
function
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9713
|
+
function selectSupportedBasisFormat() {
|
|
9714
|
+
const supportedFormats = getSupportedGPUTextureFormats();
|
|
9715
|
+
if (supportedFormats.has("astc")) {
|
|
9716
|
+
return "astc-4x4";
|
|
9717
|
+
} else if (supportedFormats.has("dxt")) {
|
|
9718
|
+
return {
|
|
9719
|
+
alpha: "bc3",
|
|
9720
|
+
noAlpha: "bc1"
|
|
9721
|
+
};
|
|
9722
|
+
} else if (supportedFormats.has("pvrtc")) {
|
|
9723
|
+
return {
|
|
9724
|
+
alpha: "pvrtc1-4-rgba",
|
|
9725
|
+
noAlpha: "pvrtc1-4-rgb"
|
|
9726
|
+
};
|
|
9727
|
+
} else if (supportedFormats.has("etc1")) {
|
|
9728
|
+
return "etc1";
|
|
9729
|
+
} else if (supportedFormats.has("etc2")) {
|
|
9730
|
+
return "etc2";
|
|
9749
9731
|
}
|
|
9732
|
+
return "rgb565";
|
|
9750
9733
|
}
|
|
9751
|
-
var
|
|
9752
|
-
var
|
|
9753
|
-
"../
|
|
9754
|
-
|
|
9755
|
-
|
|
9734
|
+
var OutputFormat;
|
|
9735
|
+
var init_parse_basis = __esm({
|
|
9736
|
+
"../textures/src/lib/parsers/parse-basis.ts"() {
|
|
9737
|
+
init_basis_module_loader();
|
|
9738
|
+
init_gl_extensions();
|
|
9739
|
+
init_texture_formats();
|
|
9740
|
+
init_parse_ktx();
|
|
9741
|
+
OutputFormat = {
|
|
9742
|
+
etc1: {
|
|
9743
|
+
basisFormat: 0,
|
|
9744
|
+
compressed: true,
|
|
9745
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
9746
|
+
},
|
|
9747
|
+
etc2: { basisFormat: 1, compressed: true },
|
|
9748
|
+
bc1: {
|
|
9749
|
+
basisFormat: 2,
|
|
9750
|
+
compressed: true,
|
|
9751
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
|
|
9752
|
+
},
|
|
9753
|
+
bc3: {
|
|
9754
|
+
basisFormat: 3,
|
|
9755
|
+
compressed: true,
|
|
9756
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
9757
|
+
},
|
|
9758
|
+
bc4: { basisFormat: 4, compressed: true },
|
|
9759
|
+
bc5: { basisFormat: 5, compressed: true },
|
|
9760
|
+
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
9761
|
+
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
9762
|
+
"pvrtc1-4-rgb": {
|
|
9763
|
+
basisFormat: 8,
|
|
9764
|
+
compressed: true,
|
|
9765
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
|
9766
|
+
},
|
|
9767
|
+
"pvrtc1-4-rgba": {
|
|
9768
|
+
basisFormat: 9,
|
|
9769
|
+
compressed: true,
|
|
9770
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
|
9771
|
+
},
|
|
9772
|
+
"astc-4x4": {
|
|
9773
|
+
basisFormat: 10,
|
|
9774
|
+
compressed: true,
|
|
9775
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
9776
|
+
},
|
|
9777
|
+
"atc-rgb": { basisFormat: 11, compressed: true },
|
|
9778
|
+
"atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
|
|
9779
|
+
rgba32: { basisFormat: 13, compressed: false },
|
|
9780
|
+
rgb565: { basisFormat: 14, compressed: false },
|
|
9781
|
+
bgr565: { basisFormat: 15, compressed: false },
|
|
9782
|
+
rgba4444: { basisFormat: 16, compressed: false }
|
|
9783
|
+
};
|
|
9756
9784
|
}
|
|
9757
9785
|
});
|
|
9758
9786
|
|
|
9759
|
-
// ../
|
|
9760
|
-
var
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9787
|
+
// ../textures/src/basis-loader.ts
|
|
9788
|
+
var BasisWorkerLoader, BasisLoader;
|
|
9789
|
+
var init_basis_loader = __esm({
|
|
9790
|
+
"../textures/src/basis-loader.ts"() {
|
|
9791
|
+
init_version6();
|
|
9792
|
+
init_parse_basis();
|
|
9793
|
+
BasisWorkerLoader = {
|
|
9794
|
+
name: "Basis",
|
|
9795
|
+
id: "basis",
|
|
9796
|
+
module: "textures",
|
|
9797
|
+
version: VERSION8,
|
|
9798
|
+
worker: true,
|
|
9799
|
+
extensions: ["basis", "ktx2"],
|
|
9800
|
+
mimeTypes: ["application/octet-stream", "image/ktx2"],
|
|
9801
|
+
tests: ["sB"],
|
|
9802
|
+
binary: true,
|
|
9803
|
+
options: {
|
|
9804
|
+
basis: {
|
|
9805
|
+
format: "auto",
|
|
9806
|
+
libraryPath: "libs/",
|
|
9807
|
+
containerFormat: "auto",
|
|
9808
|
+
module: "transcoder"
|
|
9809
|
+
}
|
|
9810
|
+
}
|
|
9811
|
+
};
|
|
9812
|
+
BasisLoader = {
|
|
9813
|
+
...BasisWorkerLoader,
|
|
9814
|
+
parse: parseBasis
|
|
9815
|
+
};
|
|
9765
9816
|
}
|
|
9766
9817
|
});
|
|
9767
9818
|
|
|
@@ -9784,6 +9835,119 @@
|
|
|
9784
9835
|
}
|
|
9785
9836
|
});
|
|
9786
9837
|
|
|
9838
|
+
// ../gltf/src/lib/parsers/parse-glb.ts
|
|
9839
|
+
function getMagicString4(dataView, byteOffset = 0) {
|
|
9840
|
+
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))}`;
|
|
9841
|
+
}
|
|
9842
|
+
function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
|
|
9843
|
+
const dataView = new DataView(arrayBuffer);
|
|
9844
|
+
const { magic = MAGIC_glTF } = options;
|
|
9845
|
+
const magic1 = dataView.getUint32(byteOffset, false);
|
|
9846
|
+
return magic1 === magic || magic1 === MAGIC_glTF;
|
|
9847
|
+
}
|
|
9848
|
+
function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
|
|
9849
|
+
const dataView = new DataView(arrayBuffer);
|
|
9850
|
+
const type = getMagicString4(dataView, byteOffset + 0);
|
|
9851
|
+
const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
9852
|
+
const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
|
|
9853
|
+
Object.assign(glb, {
|
|
9854
|
+
header: {
|
|
9855
|
+
byteOffset,
|
|
9856
|
+
byteLength,
|
|
9857
|
+
hasBinChunk: false
|
|
9858
|
+
},
|
|
9859
|
+
type,
|
|
9860
|
+
version,
|
|
9861
|
+
json: {},
|
|
9862
|
+
binChunks: []
|
|
9863
|
+
});
|
|
9864
|
+
byteOffset += GLB_FILE_HEADER_SIZE;
|
|
9865
|
+
switch (glb.version) {
|
|
9866
|
+
case 1:
|
|
9867
|
+
return parseGLBV1(glb, dataView, byteOffset);
|
|
9868
|
+
case 2:
|
|
9869
|
+
return parseGLBV2(glb, dataView, byteOffset, options = {});
|
|
9870
|
+
default:
|
|
9871
|
+
throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);
|
|
9872
|
+
}
|
|
9873
|
+
}
|
|
9874
|
+
function parseGLBV1(glb, dataView, byteOffset) {
|
|
9875
|
+
assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
9876
|
+
const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
|
|
9877
|
+
const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
9878
|
+
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
9879
|
+
assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
|
|
9880
|
+
parseJSONChunk(glb, dataView, byteOffset, contentLength);
|
|
9881
|
+
byteOffset += contentLength;
|
|
9882
|
+
byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
|
|
9883
|
+
return byteOffset;
|
|
9884
|
+
}
|
|
9885
|
+
function parseGLBV2(glb, dataView, byteOffset, options) {
|
|
9886
|
+
assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
9887
|
+
parseGLBChunksSync(glb, dataView, byteOffset, options);
|
|
9888
|
+
return byteOffset + glb.header.byteLength;
|
|
9889
|
+
}
|
|
9890
|
+
function parseGLBChunksSync(glb, dataView, byteOffset, options) {
|
|
9891
|
+
while (byteOffset + 8 <= glb.header.byteLength) {
|
|
9892
|
+
const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
|
|
9893
|
+
const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
9894
|
+
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
9895
|
+
switch (chunkFormat) {
|
|
9896
|
+
case GLB_CHUNK_TYPE_JSON:
|
|
9897
|
+
parseJSONChunk(glb, dataView, byteOffset, chunkLength);
|
|
9898
|
+
break;
|
|
9899
|
+
case GLB_CHUNK_TYPE_BIN:
|
|
9900
|
+
parseBINChunk(glb, dataView, byteOffset, chunkLength);
|
|
9901
|
+
break;
|
|
9902
|
+
case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
|
|
9903
|
+
if (!options.strict) {
|
|
9904
|
+
parseJSONChunk(glb, dataView, byteOffset, chunkLength);
|
|
9905
|
+
}
|
|
9906
|
+
break;
|
|
9907
|
+
case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:
|
|
9908
|
+
if (!options.strict) {
|
|
9909
|
+
parseBINChunk(glb, dataView, byteOffset, chunkLength);
|
|
9910
|
+
}
|
|
9911
|
+
break;
|
|
9912
|
+
default:
|
|
9913
|
+
break;
|
|
9914
|
+
}
|
|
9915
|
+
byteOffset += padToNBytes(chunkLength, 4);
|
|
9916
|
+
}
|
|
9917
|
+
return byteOffset;
|
|
9918
|
+
}
|
|
9919
|
+
function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
|
|
9920
|
+
const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
|
|
9921
|
+
const textDecoder = new TextDecoder("utf8");
|
|
9922
|
+
const jsonText = textDecoder.decode(jsonChunk);
|
|
9923
|
+
glb.json = JSON.parse(jsonText);
|
|
9924
|
+
return padToNBytes(chunkLength, 4);
|
|
9925
|
+
}
|
|
9926
|
+
function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
|
|
9927
|
+
glb.header.hasBinChunk = true;
|
|
9928
|
+
glb.binChunks.push({
|
|
9929
|
+
byteOffset,
|
|
9930
|
+
byteLength: chunkLength,
|
|
9931
|
+
arrayBuffer: dataView.buffer
|
|
9932
|
+
});
|
|
9933
|
+
return padToNBytes(chunkLength, 4);
|
|
9934
|
+
}
|
|
9935
|
+
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;
|
|
9936
|
+
var init_parse_glb = __esm({
|
|
9937
|
+
"../gltf/src/lib/parsers/parse-glb.ts"() {
|
|
9938
|
+
init_src2();
|
|
9939
|
+
LITTLE_ENDIAN2 = true;
|
|
9940
|
+
MAGIC_glTF = 1735152710;
|
|
9941
|
+
GLB_FILE_HEADER_SIZE = 12;
|
|
9942
|
+
GLB_CHUNK_HEADER_SIZE = 8;
|
|
9943
|
+
GLB_CHUNK_TYPE_JSON = 1313821514;
|
|
9944
|
+
GLB_CHUNK_TYPE_BIN = 5130562;
|
|
9945
|
+
GLB_V1_CONTENT_FORMAT_JSON = 0;
|
|
9946
|
+
GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
|
|
9947
|
+
GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
|
|
9948
|
+
}
|
|
9949
|
+
});
|
|
9950
|
+
|
|
9787
9951
|
// ../gltf/src/lib/gltf-utils/resolve-url.ts
|
|
9788
9952
|
function resolveUrl(url, options) {
|
|
9789
9953
|
const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
|
|
@@ -9838,10 +10002,24 @@
|
|
|
9838
10002
|
assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
|
|
9839
10003
|
return { ArrayType, length: length4, byteLength };
|
|
9840
10004
|
}
|
|
9841
|
-
|
|
10005
|
+
function getMemoryUsageGLTF(gltf) {
|
|
10006
|
+
let { images, bufferViews } = gltf;
|
|
10007
|
+
images = images || [];
|
|
10008
|
+
bufferViews = bufferViews || [];
|
|
10009
|
+
const imageBufferViews = images.map((i2) => i2.bufferView);
|
|
10010
|
+
bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
|
|
10011
|
+
const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
|
|
10012
|
+
const pixelCount = images.reduce((acc, image) => {
|
|
10013
|
+
const { width, height } = image.image;
|
|
10014
|
+
return acc + width * height;
|
|
10015
|
+
}, 0);
|
|
10016
|
+
return bufferMemory + Math.ceil(4 * pixelCount * MIPMAP_FACTOR);
|
|
10017
|
+
}
|
|
10018
|
+
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
10019
|
var init_gltf_utils = __esm({
|
|
9843
10020
|
"../gltf/src/lib/gltf-utils/gltf-utils.ts"() {
|
|
9844
10021
|
init_assert6();
|
|
10022
|
+
MIPMAP_FACTOR = 1.33;
|
|
9845
10023
|
TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
|
|
9846
10024
|
ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
|
|
9847
10025
|
[Int8Array, 5120],
|
|
@@ -9882,25 +10060,31 @@
|
|
|
9882
10060
|
});
|
|
9883
10061
|
|
|
9884
10062
|
// ../gltf/src/lib/api/gltf-scenegraph.ts
|
|
9885
|
-
|
|
10063
|
+
function makeDefaultGLTFJson() {
|
|
10064
|
+
return {
|
|
10065
|
+
asset: {
|
|
10066
|
+
version: "2.0",
|
|
10067
|
+
generator: "loaders.gl"
|
|
10068
|
+
},
|
|
10069
|
+
buffers: [],
|
|
10070
|
+
extensions: {},
|
|
10071
|
+
extensionsRequired: [],
|
|
10072
|
+
extensionsUsed: []
|
|
10073
|
+
};
|
|
10074
|
+
}
|
|
10075
|
+
var GLTFScenegraph;
|
|
9886
10076
|
var init_gltf_scenegraph = __esm({
|
|
9887
10077
|
"../gltf/src/lib/api/gltf-scenegraph.ts"() {
|
|
9888
10078
|
init_src8();
|
|
9889
10079
|
init_src2();
|
|
9890
10080
|
init_assert6();
|
|
9891
10081
|
init_gltf_utils();
|
|
9892
|
-
DEFAULT_GLTF_JSON = {
|
|
9893
|
-
asset: {
|
|
9894
|
-
version: "2.0",
|
|
9895
|
-
generator: "loaders.gl"
|
|
9896
|
-
},
|
|
9897
|
-
buffers: []
|
|
9898
|
-
};
|
|
9899
10082
|
GLTFScenegraph = class {
|
|
9900
10083
|
constructor(gltf) {
|
|
9901
|
-
this.gltf =
|
|
9902
|
-
json:
|
|
9903
|
-
buffers: []
|
|
10084
|
+
this.gltf = {
|
|
10085
|
+
json: gltf?.json || makeDefaultGLTFJson(),
|
|
10086
|
+
buffers: gltf?.buffers || [],
|
|
10087
|
+
images: gltf?.images || []
|
|
9904
10088
|
};
|
|
9905
10089
|
this.sourceBuffers = [];
|
|
9906
10090
|
this.byteLength = 0;
|
|
@@ -9920,10 +10104,15 @@
|
|
|
9920
10104
|
const extras = this.json.extras || {};
|
|
9921
10105
|
return extras[key];
|
|
9922
10106
|
}
|
|
10107
|
+
hasExtension(extensionName) {
|
|
10108
|
+
const isUsedExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
|
|
10109
|
+
const isRequiredExtension = this.getRequiredExtensions().find((name10) => name10 === extensionName);
|
|
10110
|
+
return typeof isUsedExtension === "string" || typeof isRequiredExtension === "string";
|
|
10111
|
+
}
|
|
9923
10112
|
getExtension(extensionName) {
|
|
9924
10113
|
const isExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
|
|
9925
10114
|
const extensions = this.json.extensions || {};
|
|
9926
|
-
return isExtension ? extensions[extensionName]
|
|
10115
|
+
return isExtension ? extensions[extensionName] : null;
|
|
9927
10116
|
}
|
|
9928
10117
|
getRequiredExtension(extensionName) {
|
|
9929
10118
|
const isRequired = this.getRequiredExtensions().find((name10) => name10 === extensionName);
|
|
@@ -10030,10 +10219,15 @@
|
|
|
10030
10219
|
extensions[extensionName] = data;
|
|
10031
10220
|
}
|
|
10032
10221
|
removeObjectExtension(object, extensionName) {
|
|
10033
|
-
const extensions = object
|
|
10034
|
-
|
|
10222
|
+
const extensions = object?.extensions || {};
|
|
10223
|
+
if (extensions[extensionName]) {
|
|
10224
|
+
this.json.extensionsRemoved = this.json.extensionsRemoved || [];
|
|
10225
|
+
const extensionsRemoved = this.json.extensionsRemoved;
|
|
10226
|
+
if (!extensionsRemoved.includes(extensionName)) {
|
|
10227
|
+
extensionsRemoved.push(extensionName);
|
|
10228
|
+
}
|
|
10229
|
+
}
|
|
10035
10230
|
delete extensions[extensionName];
|
|
10036
|
-
return extension;
|
|
10037
10231
|
}
|
|
10038
10232
|
addExtension(extensionName, extensionData = {}) {
|
|
10039
10233
|
assert7(extensionData);
|
|
@@ -10062,8 +10256,15 @@
|
|
|
10062
10256
|
}
|
|
10063
10257
|
}
|
|
10064
10258
|
removeExtension(extensionName) {
|
|
10065
|
-
if (
|
|
10066
|
-
|
|
10259
|
+
if (this.json.extensions?.[extensionName]) {
|
|
10260
|
+
this.json.extensionsRemoved = this.json.extensionsRemoved || [];
|
|
10261
|
+
const extensionsRemoved = this.json.extensionsRemoved;
|
|
10262
|
+
if (!extensionsRemoved.includes(extensionName)) {
|
|
10263
|
+
extensionsRemoved.push(extensionName);
|
|
10264
|
+
}
|
|
10265
|
+
}
|
|
10266
|
+
if (this.json.extensions) {
|
|
10267
|
+
delete this.json.extensions[extensionName];
|
|
10067
10268
|
}
|
|
10068
10269
|
if (this.json.extensionsRequired) {
|
|
10069
10270
|
this._removeStringFromArray(this.json.extensionsRequired, extensionName);
|
|
@@ -10071,16 +10272,6 @@
|
|
|
10071
10272
|
if (this.json.extensionsUsed) {
|
|
10072
10273
|
this._removeStringFromArray(this.json.extensionsUsed, extensionName);
|
|
10073
10274
|
}
|
|
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
10275
|
}
|
|
10085
10276
|
setDefaultScene(sceneIndex) {
|
|
10086
10277
|
this.json.scene = sceneIndex;
|
|
@@ -10149,14 +10340,14 @@
|
|
|
10149
10340
|
this.json.images.push(glTFImage);
|
|
10150
10341
|
return this.json.images.length - 1;
|
|
10151
10342
|
}
|
|
10152
|
-
addBufferView(buffer) {
|
|
10343
|
+
addBufferView(buffer, bufferIndex = 0, byteOffset = this.byteLength) {
|
|
10153
10344
|
const byteLength = buffer.byteLength;
|
|
10154
10345
|
assert7(Number.isFinite(byteLength));
|
|
10155
10346
|
this.sourceBuffers = this.sourceBuffers || [];
|
|
10156
10347
|
this.sourceBuffers.push(buffer);
|
|
10157
10348
|
const glTFBufferView = {
|
|
10158
|
-
buffer:
|
|
10159
|
-
byteOffset
|
|
10349
|
+
buffer: bufferIndex,
|
|
10350
|
+
byteOffset,
|
|
10160
10351
|
byteLength
|
|
10161
10352
|
};
|
|
10162
10353
|
this.byteLength += padToNBytes(byteLength, 4);
|
|
@@ -10515,9 +10706,8 @@
|
|
|
10515
10706
|
const source = new Uint8Array(buffer.arrayBuffer, buffer.byteOffset + byteOffset, byteLength);
|
|
10516
10707
|
const result = new Uint8Array(scenegraph.gltf.buffers[bufferView.buffer].arrayBuffer, bufferView.byteOffset, bufferView.byteLength);
|
|
10517
10708
|
await meshoptDecodeGltfBuffer(result, count, byteStride, source, mode, filter);
|
|
10518
|
-
|
|
10709
|
+
scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION);
|
|
10519
10710
|
}
|
|
10520
|
-
return null;
|
|
10521
10711
|
}
|
|
10522
10712
|
var EXT_MESHOPT_COMPRESSION, name;
|
|
10523
10713
|
var init_EXT_meshopt_compression = __esm({
|
|
@@ -10576,8 +10766,8 @@
|
|
|
10576
10766
|
const extension = scene.getObjectExtension(texture, KHR_TEXTURE_BASISU);
|
|
10577
10767
|
if (extension) {
|
|
10578
10768
|
texture.source = extension.source;
|
|
10769
|
+
scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU);
|
|
10579
10770
|
}
|
|
10580
|
-
scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU);
|
|
10581
10771
|
}
|
|
10582
10772
|
scene.removeExtension(KHR_TEXTURE_BASISU);
|
|
10583
10773
|
}
|
|
@@ -10710,6 +10900,7 @@
|
|
|
10710
10900
|
if (decodedData.indices) {
|
|
10711
10901
|
primitive.indices = getGLTFAccessor(decodedData.indices);
|
|
10712
10902
|
}
|
|
10903
|
+
scenegraph.removeObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION);
|
|
10713
10904
|
checkPrimitive(primitive);
|
|
10714
10905
|
}
|
|
10715
10906
|
function compressMesh(attributes, indices, mode = 4, options, context) {
|
|
@@ -10792,8 +10983,8 @@
|
|
|
10792
10983
|
});
|
|
10793
10984
|
async function decode4(gltfData, options) {
|
|
10794
10985
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
10795
|
-
const
|
|
10796
|
-
if (!
|
|
10986
|
+
const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);
|
|
10987
|
+
if (!hasExtension) {
|
|
10797
10988
|
return;
|
|
10798
10989
|
}
|
|
10799
10990
|
const materials = gltfData.json.materials || [];
|
|
@@ -10927,10 +11118,10 @@
|
|
|
10927
11118
|
}
|
|
10928
11119
|
function makeTransformationMatrix(extensionData) {
|
|
10929
11120
|
const { offset = [0, 0], rotation = 0, scale: scale5 = [1, 1] } = extensionData;
|
|
10930
|
-
const
|
|
10931
|
-
const
|
|
11121
|
+
const translationMatrix = new Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);
|
|
11122
|
+
const rotationMatrix = scratchRotationMatrix.set(Math.cos(rotation), Math.sin(rotation), 0, -Math.sin(rotation), Math.cos(rotation), 0, 0, 0, 1);
|
|
10932
11123
|
const scaleMatrix = scratchScaleMatrix.set(scale5[0], 0, 0, 0, scale5[1], 0, 0, 0, 1);
|
|
10933
|
-
return
|
|
11124
|
+
return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);
|
|
10934
11125
|
}
|
|
10935
11126
|
var EXT_MESHOPT_TRANSFORM, name5, scratchVector7, scratchRotationMatrix, scratchScaleMatrix;
|
|
10936
11127
|
var init_KHR_texture_transform = __esm({
|
|
@@ -11112,18 +11303,16 @@
|
|
|
11112
11303
|
decode: () => decode8,
|
|
11113
11304
|
name: () => name9
|
|
11114
11305
|
});
|
|
11115
|
-
async function decode8(gltfData) {
|
|
11306
|
+
async function decode8(gltfData, options) {
|
|
11116
11307
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
11117
|
-
decodeExtFeatureMetadata(scenegraph);
|
|
11308
|
+
decodeExtFeatureMetadata(scenegraph, options);
|
|
11118
11309
|
}
|
|
11119
|
-
function decodeExtFeatureMetadata(scenegraph) {
|
|
11310
|
+
function decodeExtFeatureMetadata(scenegraph, options) {
|
|
11120
11311
|
const extension = scenegraph.getExtension(EXT_FEATURE_METADATA);
|
|
11121
|
-
|
|
11122
|
-
|
|
11123
|
-
const
|
|
11124
|
-
|
|
11125
|
-
console.warn('featureTextures is not yet supported in the "EXT_feature_metadata" extension.');
|
|
11126
|
-
}
|
|
11312
|
+
if (!extension)
|
|
11313
|
+
return;
|
|
11314
|
+
const schemaClasses = extension.schema?.classes;
|
|
11315
|
+
const { featureTables } = extension;
|
|
11127
11316
|
if (schemaClasses && featureTables) {
|
|
11128
11317
|
for (const schemaName in schemaClasses) {
|
|
11129
11318
|
const schemaClass = schemaClasses[schemaName];
|
|
@@ -11133,6 +11322,16 @@
|
|
|
11133
11322
|
}
|
|
11134
11323
|
}
|
|
11135
11324
|
}
|
|
11325
|
+
const { featureTextures } = extension;
|
|
11326
|
+
if (schemaClasses && featureTextures && options.gltf?.loadImages) {
|
|
11327
|
+
for (const schemaName in schemaClasses) {
|
|
11328
|
+
const schemaClass = schemaClasses[schemaName];
|
|
11329
|
+
const featureTexture = findFeatureTextureByName(featureTextures, schemaName);
|
|
11330
|
+
if (featureTexture) {
|
|
11331
|
+
handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);
|
|
11332
|
+
}
|
|
11333
|
+
}
|
|
11334
|
+
}
|
|
11136
11335
|
}
|
|
11137
11336
|
function handleFeatureTableProperties(scenegraph, featureTable, schemaClass) {
|
|
11138
11337
|
for (const propertyName in schemaClass.properties) {
|
|
@@ -11145,19 +11344,128 @@
|
|
|
11145
11344
|
}
|
|
11146
11345
|
}
|
|
11147
11346
|
}
|
|
11347
|
+
function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass) {
|
|
11348
|
+
const attributeName = featureTexture.class;
|
|
11349
|
+
for (const propertyName in schemaClass.properties) {
|
|
11350
|
+
const featureTextureProperty = featureTexture?.properties?.[propertyName];
|
|
11351
|
+
if (featureTextureProperty) {
|
|
11352
|
+
const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);
|
|
11353
|
+
featureTextureProperty.data = data;
|
|
11354
|
+
}
|
|
11355
|
+
}
|
|
11356
|
+
}
|
|
11148
11357
|
function getPropertyDataFromBinarySource(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty) {
|
|
11149
11358
|
const bufferView = featureTableProperty.bufferView;
|
|
11150
|
-
|
|
11359
|
+
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
11151
11360
|
switch (schemaProperty.type) {
|
|
11152
11361
|
case "STRING": {
|
|
11153
11362
|
const stringOffsetBufferView = featureTableProperty.stringOffsetBufferView;
|
|
11154
11363
|
const offsetsData = scenegraph.getTypedArrayForBufferView(stringOffsetBufferView);
|
|
11155
|
-
|
|
11156
|
-
break;
|
|
11364
|
+
return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
|
|
11157
11365
|
}
|
|
11158
11366
|
default:
|
|
11159
11367
|
}
|
|
11160
|
-
return
|
|
11368
|
+
return dataArray;
|
|
11369
|
+
}
|
|
11370
|
+
function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
|
|
11371
|
+
const json = scenegraph.gltf.json;
|
|
11372
|
+
if (!json.meshes) {
|
|
11373
|
+
return [];
|
|
11374
|
+
}
|
|
11375
|
+
const featureTextureTable = [];
|
|
11376
|
+
for (const mesh of json.meshes) {
|
|
11377
|
+
for (const primitive of mesh.primitives) {
|
|
11378
|
+
processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive);
|
|
11379
|
+
}
|
|
11380
|
+
}
|
|
11381
|
+
return featureTextureTable;
|
|
11382
|
+
}
|
|
11383
|
+
function processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive) {
|
|
11384
|
+
const json = scenegraph.gltf.json;
|
|
11385
|
+
const textureData = [];
|
|
11386
|
+
const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;
|
|
11387
|
+
const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
|
|
11388
|
+
const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
|
|
11389
|
+
const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
|
|
11390
|
+
const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
|
|
11391
|
+
const textureIndex = featureTextureProperty.texture.index;
|
|
11392
|
+
const texture = json.textures?.[textureIndex];
|
|
11393
|
+
const imageIndex = texture?.source;
|
|
11394
|
+
if (typeof imageIndex !== "undefined") {
|
|
11395
|
+
const image = json.images?.[imageIndex];
|
|
11396
|
+
const mimeType = image?.mimeType;
|
|
11397
|
+
const parsedImage = scenegraph.gltf.images?.[imageIndex];
|
|
11398
|
+
if (parsedImage) {
|
|
11399
|
+
for (let index = 0; index < textureCoordinates.length; index += 2) {
|
|
11400
|
+
const value = getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, featureTextureProperty.channels);
|
|
11401
|
+
textureData.push(value);
|
|
11402
|
+
}
|
|
11403
|
+
}
|
|
11404
|
+
}
|
|
11405
|
+
const featureIndices = [];
|
|
11406
|
+
for (const texelData of textureData) {
|
|
11407
|
+
let index = featureTextureTable.findIndex((item) => item === texelData);
|
|
11408
|
+
if (index === -1) {
|
|
11409
|
+
index = featureTextureTable.push(texelData) - 1;
|
|
11410
|
+
}
|
|
11411
|
+
featureIndices.push(index);
|
|
11412
|
+
}
|
|
11413
|
+
const typedArray = new Uint32Array(featureIndices);
|
|
11414
|
+
const bufferIndex = scenegraph.gltf.buffers.push({
|
|
11415
|
+
arrayBuffer: typedArray.buffer,
|
|
11416
|
+
byteOffset: 0,
|
|
11417
|
+
byteLength: typedArray.byteLength
|
|
11418
|
+
}) - 1;
|
|
11419
|
+
const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
|
|
11420
|
+
const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
|
|
11421
|
+
size: 1,
|
|
11422
|
+
componentType: getComponentTypeFromArray(typedArray),
|
|
11423
|
+
count: typedArray.length
|
|
11424
|
+
});
|
|
11425
|
+
primitive.attributes[attributeName] = accessorIndex;
|
|
11426
|
+
}
|
|
11427
|
+
function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels) {
|
|
11428
|
+
const CHANNELS_MAP = {
|
|
11429
|
+
r: { offset: 0, shift: 0 },
|
|
11430
|
+
g: { offset: 1, shift: 8 },
|
|
11431
|
+
b: { offset: 2, shift: 16 },
|
|
11432
|
+
a: { offset: 3, shift: 24 }
|
|
11433
|
+
};
|
|
11434
|
+
const u = textureCoordinates[index];
|
|
11435
|
+
const v = textureCoordinates[index + 1];
|
|
11436
|
+
let components = 1;
|
|
11437
|
+
if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1))
|
|
11438
|
+
components = 4;
|
|
11439
|
+
const offset = coordinatesToOffset(u, v, parsedImage, components);
|
|
11440
|
+
let value = 0;
|
|
11441
|
+
for (const c of channels) {
|
|
11442
|
+
const map2 = CHANNELS_MAP[c];
|
|
11443
|
+
const val = getVal(parsedImage, offset + map2.offset);
|
|
11444
|
+
value |= val << map2.shift;
|
|
11445
|
+
}
|
|
11446
|
+
return value;
|
|
11447
|
+
}
|
|
11448
|
+
function getVal(parsedImage, offset) {
|
|
11449
|
+
const imageData = getImageData(parsedImage);
|
|
11450
|
+
if (imageData.data.length <= offset) {
|
|
11451
|
+
throw new Error(`${imageData.data.length} <= ${offset}`);
|
|
11452
|
+
}
|
|
11453
|
+
return imageData.data[offset];
|
|
11454
|
+
}
|
|
11455
|
+
function coordinatesToOffset(u, v, parsedImage, componentsCount = 1) {
|
|
11456
|
+
const w = parsedImage.width;
|
|
11457
|
+
const iX = emod(u) * (w - 1);
|
|
11458
|
+
const indX = Math.round(iX);
|
|
11459
|
+
const h = parsedImage.height;
|
|
11460
|
+
const iY = emod(v) * (h - 1);
|
|
11461
|
+
const indY = Math.round(iY);
|
|
11462
|
+
const components = parsedImage.components ? parsedImage.components : componentsCount;
|
|
11463
|
+
const offset = (indY * w + indX) * components;
|
|
11464
|
+
return offset;
|
|
11465
|
+
}
|
|
11466
|
+
function emod(n2) {
|
|
11467
|
+
const a2 = (n2 % 1 + 1) % 1;
|
|
11468
|
+
return a2;
|
|
11161
11469
|
}
|
|
11162
11470
|
function findFeatureTableByName(featureTables, schemaClassName) {
|
|
11163
11471
|
for (const featureTableName in featureTables) {
|
|
@@ -11168,6 +11476,15 @@
|
|
|
11168
11476
|
}
|
|
11169
11477
|
return null;
|
|
11170
11478
|
}
|
|
11479
|
+
function findFeatureTextureByName(featureTextures, schemaClassName) {
|
|
11480
|
+
for (const featureTexturesName in featureTextures) {
|
|
11481
|
+
const featureTable = featureTextures[featureTexturesName];
|
|
11482
|
+
if (featureTable.class === schemaClassName) {
|
|
11483
|
+
return featureTable;
|
|
11484
|
+
}
|
|
11485
|
+
}
|
|
11486
|
+
return null;
|
|
11487
|
+
}
|
|
11171
11488
|
function getStringAttributes(data, offsetsData, stringsCount) {
|
|
11172
11489
|
const stringsArray = [];
|
|
11173
11490
|
const textDecoder = new TextDecoder("utf8");
|
|
@@ -11186,6 +11503,8 @@
|
|
|
11186
11503
|
var init_EXT_feature_metadata = __esm({
|
|
11187
11504
|
"../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts"() {
|
|
11188
11505
|
init_gltf_scenegraph();
|
|
11506
|
+
init_src8();
|
|
11507
|
+
init_gltf_utils();
|
|
11189
11508
|
EXT_FEATURE_METADATA = "EXT_feature_metadata";
|
|
11190
11509
|
name9 = EXT_FEATURE_METADATA;
|
|
11191
11510
|
}
|
|
@@ -11459,7 +11778,193 @@
|
|
|
11459
11778
|
}
|
|
11460
11779
|
});
|
|
11461
11780
|
|
|
11781
|
+
// ../gltf/src/lib/parsers/parse-gltf.ts
|
|
11782
|
+
async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, context) {
|
|
11783
|
+
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);
|
|
11784
|
+
normalizeGLTFV1(gltf, { normalize: options?.gltf?.normalize });
|
|
11785
|
+
preprocessExtensions(gltf, options, context);
|
|
11786
|
+
if (options?.gltf?.loadBuffers && gltf.json.buffers) {
|
|
11787
|
+
await loadBuffers(gltf, options, context);
|
|
11788
|
+
}
|
|
11789
|
+
if (options?.gltf?.loadImages) {
|
|
11790
|
+
await loadImages(gltf, options, context);
|
|
11791
|
+
}
|
|
11792
|
+
await decodeExtensions(gltf, options, context);
|
|
11793
|
+
return gltf;
|
|
11794
|
+
}
|
|
11795
|
+
function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
11796
|
+
if (options.uri) {
|
|
11797
|
+
gltf.baseUri = options.uri;
|
|
11798
|
+
}
|
|
11799
|
+
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) {
|
|
11800
|
+
const textDecoder = new TextDecoder();
|
|
11801
|
+
data = textDecoder.decode(data);
|
|
11802
|
+
}
|
|
11803
|
+
if (typeof data === "string") {
|
|
11804
|
+
gltf.json = parseJSON(data);
|
|
11805
|
+
} else if (data instanceof ArrayBuffer) {
|
|
11806
|
+
const glb = {};
|
|
11807
|
+
byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);
|
|
11808
|
+
assert7(glb.type === "glTF", `Invalid GLB magic string ${glb.type}`);
|
|
11809
|
+
gltf._glb = glb;
|
|
11810
|
+
gltf.json = glb.json;
|
|
11811
|
+
} else {
|
|
11812
|
+
assert7(false, "GLTF: must be ArrayBuffer or string");
|
|
11813
|
+
}
|
|
11814
|
+
const buffers = gltf.json.buffers || [];
|
|
11815
|
+
gltf.buffers = new Array(buffers.length).fill(null);
|
|
11816
|
+
if (gltf._glb && gltf._glb.header.hasBinChunk) {
|
|
11817
|
+
const { binChunks } = gltf._glb;
|
|
11818
|
+
gltf.buffers[0] = {
|
|
11819
|
+
arrayBuffer: binChunks[0].arrayBuffer,
|
|
11820
|
+
byteOffset: binChunks[0].byteOffset,
|
|
11821
|
+
byteLength: binChunks[0].byteLength
|
|
11822
|
+
};
|
|
11823
|
+
}
|
|
11824
|
+
const images = gltf.json.images || [];
|
|
11825
|
+
gltf.images = new Array(images.length).fill({});
|
|
11826
|
+
}
|
|
11827
|
+
async function loadBuffers(gltf, options, context) {
|
|
11828
|
+
const buffers = gltf.json.buffers || [];
|
|
11829
|
+
for (let i2 = 0; i2 < buffers.length; ++i2) {
|
|
11830
|
+
const buffer = buffers[i2];
|
|
11831
|
+
if (buffer.uri) {
|
|
11832
|
+
const { fetch: fetch2 } = context;
|
|
11833
|
+
assert7(fetch2);
|
|
11834
|
+
const uri = resolveUrl(buffer.uri, options);
|
|
11835
|
+
const response = await context?.fetch?.(uri);
|
|
11836
|
+
const arrayBuffer = await response?.arrayBuffer?.();
|
|
11837
|
+
gltf.buffers[i2] = {
|
|
11838
|
+
arrayBuffer,
|
|
11839
|
+
byteOffset: 0,
|
|
11840
|
+
byteLength: arrayBuffer.byteLength
|
|
11841
|
+
};
|
|
11842
|
+
delete buffer.uri;
|
|
11843
|
+
} else if (gltf.buffers[i2] === null) {
|
|
11844
|
+
gltf.buffers[i2] = {
|
|
11845
|
+
arrayBuffer: new ArrayBuffer(buffer.byteLength),
|
|
11846
|
+
byteOffset: 0,
|
|
11847
|
+
byteLength: buffer.byteLength
|
|
11848
|
+
};
|
|
11849
|
+
}
|
|
11850
|
+
}
|
|
11851
|
+
}
|
|
11852
|
+
async function loadImages(gltf, options, context) {
|
|
11853
|
+
const imageIndices = getReferencesImageIndices(gltf);
|
|
11854
|
+
const images = gltf.json.images || [];
|
|
11855
|
+
const promises = [];
|
|
11856
|
+
for (const imageIndex of imageIndices) {
|
|
11857
|
+
promises.push(loadImage(gltf, images[imageIndex], imageIndex, options, context));
|
|
11858
|
+
}
|
|
11859
|
+
return await Promise.all(promises);
|
|
11860
|
+
}
|
|
11861
|
+
function getReferencesImageIndices(gltf) {
|
|
11862
|
+
const imageIndices = new Set();
|
|
11863
|
+
const textures = gltf.json.textures || [];
|
|
11864
|
+
for (const texture of textures) {
|
|
11865
|
+
if (texture.source !== void 0) {
|
|
11866
|
+
imageIndices.add(texture.source);
|
|
11867
|
+
}
|
|
11868
|
+
}
|
|
11869
|
+
return Array.from(imageIndices).sort();
|
|
11870
|
+
}
|
|
11871
|
+
async function loadImage(gltf, image, index, options, context) {
|
|
11872
|
+
const { fetch: fetch2, parse: parse5 } = context;
|
|
11873
|
+
let arrayBuffer;
|
|
11874
|
+
if (image.uri && !image.hasOwnProperty("bufferView")) {
|
|
11875
|
+
const uri = resolveUrl(image.uri, options);
|
|
11876
|
+
const response = await fetch2(uri);
|
|
11877
|
+
arrayBuffer = await response.arrayBuffer();
|
|
11878
|
+
image.bufferView = {
|
|
11879
|
+
data: arrayBuffer
|
|
11880
|
+
};
|
|
11881
|
+
}
|
|
11882
|
+
if (Number.isFinite(image.bufferView)) {
|
|
11883
|
+
const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);
|
|
11884
|
+
arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
|
|
11885
|
+
}
|
|
11886
|
+
assert7(arrayBuffer, "glTF image has no data");
|
|
11887
|
+
let parsedImage = await parse5(arrayBuffer, [ImageLoader, BasisLoader], { mimeType: image.mimeType, basis: options.basis || { format: selectSupportedBasisFormat() } }, context);
|
|
11888
|
+
if (parsedImage && parsedImage[0]) {
|
|
11889
|
+
parsedImage = {
|
|
11890
|
+
compressed: true,
|
|
11891
|
+
mipmaps: false,
|
|
11892
|
+
width: parsedImage[0].width,
|
|
11893
|
+
height: parsedImage[0].height,
|
|
11894
|
+
data: parsedImage[0]
|
|
11895
|
+
};
|
|
11896
|
+
}
|
|
11897
|
+
gltf.images = gltf.images || [];
|
|
11898
|
+
gltf.images[index] = parsedImage;
|
|
11899
|
+
}
|
|
11900
|
+
var init_parse_gltf = __esm({
|
|
11901
|
+
"../gltf/src/lib/parsers/parse-gltf.ts"() {
|
|
11902
|
+
init_src2();
|
|
11903
|
+
init_src8();
|
|
11904
|
+
init_src9();
|
|
11905
|
+
init_assert6();
|
|
11906
|
+
init_parse_glb();
|
|
11907
|
+
init_resolve_url();
|
|
11908
|
+
init_get_typed_array();
|
|
11909
|
+
init_gltf_extensions();
|
|
11910
|
+
init_normalize_gltf_v1();
|
|
11911
|
+
}
|
|
11912
|
+
});
|
|
11913
|
+
|
|
11914
|
+
// ../gltf/src/gltf-loader.ts
|
|
11915
|
+
async function parse3(arrayBuffer, options = {}, context) {
|
|
11916
|
+
options = { ...GLTFLoader.options, ...options };
|
|
11917
|
+
options.gltf = { ...GLTFLoader.options.gltf, ...options.gltf };
|
|
11918
|
+
const { byteOffset = 0 } = options;
|
|
11919
|
+
const gltf = {};
|
|
11920
|
+
return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
|
|
11921
|
+
}
|
|
11922
|
+
var GLTFLoader;
|
|
11923
|
+
var init_gltf_loader = __esm({
|
|
11924
|
+
"../gltf/src/gltf-loader.ts"() {
|
|
11925
|
+
init_version4();
|
|
11926
|
+
init_parse_gltf();
|
|
11927
|
+
GLTFLoader = {
|
|
11928
|
+
name: "glTF",
|
|
11929
|
+
id: "gltf",
|
|
11930
|
+
module: "gltf",
|
|
11931
|
+
version: VERSION6,
|
|
11932
|
+
extensions: ["gltf", "glb"],
|
|
11933
|
+
mimeTypes: ["model/gltf+json", "model/gltf-binary"],
|
|
11934
|
+
text: true,
|
|
11935
|
+
binary: true,
|
|
11936
|
+
tests: ["glTF"],
|
|
11937
|
+
parse: parse3,
|
|
11938
|
+
options: {
|
|
11939
|
+
gltf: {
|
|
11940
|
+
normalize: true,
|
|
11941
|
+
loadBuffers: true,
|
|
11942
|
+
loadImages: true,
|
|
11943
|
+
decompressMeshes: true
|
|
11944
|
+
},
|
|
11945
|
+
log: console
|
|
11946
|
+
},
|
|
11947
|
+
deprecatedOptions: {
|
|
11948
|
+
fetchImages: "gltf.loadImages",
|
|
11949
|
+
createImages: "gltf.loadImages",
|
|
11950
|
+
decompress: "gltf.decompressMeshes",
|
|
11951
|
+
postProcess: "gltf.postProcess",
|
|
11952
|
+
gltf: {
|
|
11953
|
+
decompress: "gltf.decompressMeshes",
|
|
11954
|
+
postProcess: "removed in v4"
|
|
11955
|
+
}
|
|
11956
|
+
}
|
|
11957
|
+
};
|
|
11958
|
+
}
|
|
11959
|
+
});
|
|
11960
|
+
|
|
11462
11961
|
// ../gltf/src/lib/api/post-process-gltf.ts
|
|
11962
|
+
function makeDefaultSampler() {
|
|
11963
|
+
return {
|
|
11964
|
+
id: "default-sampler",
|
|
11965
|
+
parameters: DEFAULT_SAMPLER_PARAMETERS
|
|
11966
|
+
};
|
|
11967
|
+
}
|
|
11463
11968
|
function getBytesFromComponentType(componentType) {
|
|
11464
11969
|
return BYTES2[componentType];
|
|
11465
11970
|
}
|
|
@@ -11469,7 +11974,7 @@
|
|
|
11469
11974
|
function postProcessGLTF(gltf, options) {
|
|
11470
11975
|
return new GLTFPostProcessor().postProcess(gltf, options);
|
|
11471
11976
|
}
|
|
11472
|
-
var COMPONENTS2, BYTES2, GL_SAMPLER, SAMPLER_PARAMETER_GLTF_TO_GL,
|
|
11977
|
+
var COMPONENTS2, BYTES2, GL_SAMPLER, SAMPLER_PARAMETER_GLTF_TO_GL, DEFAULT_SAMPLER_PARAMETERS, GLTFPostProcessor;
|
|
11473
11978
|
var init_post_process_gltf = __esm({
|
|
11474
11979
|
"../gltf/src/lib/api/post-process-gltf.ts"() {
|
|
11475
11980
|
init_assert6();
|
|
@@ -11506,7 +12011,7 @@
|
|
|
11506
12011
|
wrapS: GL_SAMPLER.TEXTURE_WRAP_S,
|
|
11507
12012
|
wrapT: GL_SAMPLER.TEXTURE_WRAP_T
|
|
11508
12013
|
};
|
|
11509
|
-
|
|
12014
|
+
DEFAULT_SAMPLER_PARAMETERS = {
|
|
11510
12015
|
[GL_SAMPLER.TEXTURE_MAG_FILTER]: GL_SAMPLER.LINEAR,
|
|
11511
12016
|
[GL_SAMPLER.TEXTURE_MIN_FILTER]: GL_SAMPLER.NEAREST_MIPMAP_LINEAR,
|
|
11512
12017
|
[GL_SAMPLER.TEXTURE_WRAP_S]: GL_SAMPLER.REPEAT,
|
|
@@ -11515,171 +12020,198 @@
|
|
|
11515
12020
|
GLTFPostProcessor = class {
|
|
11516
12021
|
constructor() {
|
|
11517
12022
|
this.baseUri = "";
|
|
11518
|
-
this.json = {};
|
|
11519
12023
|
this.buffers = [];
|
|
11520
12024
|
this.images = [];
|
|
11521
12025
|
}
|
|
11522
12026
|
postProcess(gltf, options = {}) {
|
|
11523
|
-
const { json, buffers = [], images = []
|
|
12027
|
+
const { json, buffers = [], images = [] } = gltf;
|
|
12028
|
+
const { baseUri = "" } = gltf;
|
|
11524
12029
|
assert7(json);
|
|
11525
12030
|
this.baseUri = baseUri;
|
|
11526
|
-
this.json = json;
|
|
11527
12031
|
this.buffers = buffers;
|
|
11528
12032
|
this.images = images;
|
|
11529
|
-
this.
|
|
12033
|
+
this.jsonUnprocessed = json;
|
|
12034
|
+
this.json = this._resolveTree(gltf.json, options);
|
|
11530
12035
|
return this.json;
|
|
11531
12036
|
}
|
|
11532
|
-
_resolveTree(
|
|
11533
|
-
|
|
11534
|
-
|
|
12037
|
+
_resolveTree(gltf, options = {}) {
|
|
12038
|
+
const json = { ...gltf };
|
|
12039
|
+
this.json = json;
|
|
12040
|
+
if (gltf.bufferViews) {
|
|
12041
|
+
json.bufferViews = gltf.bufferViews.map((bufView, i2) => this._resolveBufferView(bufView, i2));
|
|
11535
12042
|
}
|
|
11536
|
-
if (
|
|
11537
|
-
json.images =
|
|
12043
|
+
if (gltf.images) {
|
|
12044
|
+
json.images = gltf.images.map((image, i2) => this._resolveImage(image, i2));
|
|
11538
12045
|
}
|
|
11539
|
-
if (
|
|
11540
|
-
json.samplers =
|
|
12046
|
+
if (gltf.samplers) {
|
|
12047
|
+
json.samplers = gltf.samplers.map((sampler, i2) => this._resolveSampler(sampler, i2));
|
|
11541
12048
|
}
|
|
11542
|
-
if (
|
|
11543
|
-
json.textures =
|
|
12049
|
+
if (gltf.textures) {
|
|
12050
|
+
json.textures = gltf.textures.map((texture, i2) => this._resolveTexture(texture, i2));
|
|
11544
12051
|
}
|
|
11545
|
-
if (
|
|
11546
|
-
json.accessors =
|
|
12052
|
+
if (gltf.accessors) {
|
|
12053
|
+
json.accessors = gltf.accessors.map((accessor, i2) => this._resolveAccessor(accessor, i2));
|
|
11547
12054
|
}
|
|
11548
|
-
if (
|
|
11549
|
-
json.materials =
|
|
12055
|
+
if (gltf.materials) {
|
|
12056
|
+
json.materials = gltf.materials.map((material, i2) => this._resolveMaterial(material, i2));
|
|
11550
12057
|
}
|
|
11551
|
-
if (
|
|
11552
|
-
json.meshes =
|
|
12058
|
+
if (gltf.meshes) {
|
|
12059
|
+
json.meshes = gltf.meshes.map((mesh, i2) => this._resolveMesh(mesh, i2));
|
|
11553
12060
|
}
|
|
11554
|
-
if (
|
|
11555
|
-
json.nodes =
|
|
12061
|
+
if (gltf.nodes) {
|
|
12062
|
+
json.nodes = gltf.nodes.map((node3, i2) => this._resolveNode(node3, i2));
|
|
12063
|
+
json.nodes = json.nodes.map((node3, i2) => this._resolveNodeChildren(node3));
|
|
11556
12064
|
}
|
|
11557
|
-
if (
|
|
11558
|
-
json.skins =
|
|
12065
|
+
if (gltf.skins) {
|
|
12066
|
+
json.skins = gltf.skins.map((skin, i2) => this._resolveSkin(skin, i2));
|
|
11559
12067
|
}
|
|
11560
|
-
if (
|
|
11561
|
-
json.scenes =
|
|
12068
|
+
if (gltf.scenes) {
|
|
12069
|
+
json.scenes = gltf.scenes.map((scene, i2) => this._resolveScene(scene, i2));
|
|
11562
12070
|
}
|
|
11563
|
-
if (json.scene
|
|
12071
|
+
if (typeof this.json.scene === "number" && json.scenes) {
|
|
11564
12072
|
json.scene = json.scenes[this.json.scene];
|
|
11565
12073
|
}
|
|
12074
|
+
return json;
|
|
11566
12075
|
}
|
|
11567
12076
|
getScene(index) {
|
|
11568
|
-
return this._get(
|
|
12077
|
+
return this._get(this.json.scenes, index);
|
|
11569
12078
|
}
|
|
11570
12079
|
getNode(index) {
|
|
11571
|
-
return this._get(
|
|
12080
|
+
return this._get(this.json.nodes, index);
|
|
11572
12081
|
}
|
|
11573
12082
|
getSkin(index) {
|
|
11574
|
-
return this._get(
|
|
12083
|
+
return this._get(this.json.skins, index);
|
|
11575
12084
|
}
|
|
11576
12085
|
getMesh(index) {
|
|
11577
|
-
return this._get(
|
|
12086
|
+
return this._get(this.json.meshes, index);
|
|
11578
12087
|
}
|
|
11579
12088
|
getMaterial(index) {
|
|
11580
|
-
return this._get(
|
|
12089
|
+
return this._get(this.json.materials, index);
|
|
11581
12090
|
}
|
|
11582
12091
|
getAccessor(index) {
|
|
11583
|
-
return this._get(
|
|
12092
|
+
return this._get(this.json.accessors, index);
|
|
11584
12093
|
}
|
|
11585
12094
|
getCamera(index) {
|
|
11586
|
-
return
|
|
12095
|
+
return this._get(this.json.cameras, index);
|
|
11587
12096
|
}
|
|
11588
12097
|
getTexture(index) {
|
|
11589
|
-
return this._get(
|
|
12098
|
+
return this._get(this.json.textures, index);
|
|
11590
12099
|
}
|
|
11591
12100
|
getSampler(index) {
|
|
11592
|
-
return this._get(
|
|
12101
|
+
return this._get(this.json.samplers, index);
|
|
11593
12102
|
}
|
|
11594
12103
|
getImage(index) {
|
|
11595
|
-
return this._get(
|
|
12104
|
+
return this._get(this.json.images, index);
|
|
11596
12105
|
}
|
|
11597
12106
|
getBufferView(index) {
|
|
11598
|
-
return this._get(
|
|
12107
|
+
return this._get(this.json.bufferViews, index);
|
|
11599
12108
|
}
|
|
11600
12109
|
getBuffer(index) {
|
|
11601
|
-
return this._get(
|
|
12110
|
+
return this._get(this.json.buffers, index);
|
|
11602
12111
|
}
|
|
11603
12112
|
_get(array, index) {
|
|
11604
12113
|
if (typeof index === "object") {
|
|
11605
12114
|
return index;
|
|
11606
12115
|
}
|
|
11607
|
-
const object =
|
|
12116
|
+
const object = array && array[index];
|
|
11608
12117
|
if (!object) {
|
|
11609
12118
|
console.warn(`glTF file error: Could not find ${array}[${index}]`);
|
|
11610
12119
|
}
|
|
11611
12120
|
return object;
|
|
11612
12121
|
}
|
|
11613
12122
|
_resolveScene(scene, index) {
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
12123
|
+
return {
|
|
12124
|
+
...scene,
|
|
12125
|
+
id: scene.id || `scene-${index}`,
|
|
12126
|
+
nodes: (scene.nodes || []).map((node3) => this.getNode(node3))
|
|
12127
|
+
};
|
|
11617
12128
|
}
|
|
11618
|
-
_resolveNode(
|
|
11619
|
-
node3
|
|
11620
|
-
|
|
11621
|
-
|
|
12129
|
+
_resolveNode(gltfNode, index) {
|
|
12130
|
+
const node3 = {
|
|
12131
|
+
...gltfNode,
|
|
12132
|
+
id: gltfNode?.id || `node-${index}`
|
|
12133
|
+
};
|
|
12134
|
+
if (gltfNode.mesh !== void 0) {
|
|
12135
|
+
node3.mesh = this.getMesh(gltfNode.mesh);
|
|
12136
|
+
}
|
|
12137
|
+
if (gltfNode.camera !== void 0) {
|
|
12138
|
+
node3.camera = this.getCamera(gltfNode.camera);
|
|
11622
12139
|
}
|
|
11623
|
-
if (
|
|
11624
|
-
node3.
|
|
11625
|
-
}
|
|
11626
|
-
|
|
12140
|
+
if (gltfNode.skin !== void 0) {
|
|
12141
|
+
node3.skin = this.getSkin(gltfNode.skin);
|
|
12142
|
+
}
|
|
12143
|
+
if (gltfNode.meshes !== void 0 && gltfNode.meshes.length) {
|
|
12144
|
+
node3.mesh = gltfNode.meshes.reduce((accum, meshIndex) => {
|
|
11627
12145
|
const mesh = this.getMesh(meshIndex);
|
|
11628
12146
|
accum.id = mesh.id;
|
|
11629
12147
|
accum.primitives = accum.primitives.concat(mesh.primitives);
|
|
11630
12148
|
return accum;
|
|
11631
12149
|
}, { primitives: [] });
|
|
11632
12150
|
}
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
if (node3.
|
|
11637
|
-
node3.
|
|
12151
|
+
return node3;
|
|
12152
|
+
}
|
|
12153
|
+
_resolveNodeChildren(node3) {
|
|
12154
|
+
if (node3.children) {
|
|
12155
|
+
node3.children = node3.children.map((child) => this.getNode(child));
|
|
11638
12156
|
}
|
|
11639
12157
|
return node3;
|
|
11640
12158
|
}
|
|
11641
|
-
_resolveSkin(
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
12159
|
+
_resolveSkin(gltfSkin, index) {
|
|
12160
|
+
const inverseBindMatrices = typeof gltfSkin.inverseBindMatrices === "number" ? this.getAccessor(gltfSkin.inverseBindMatrices) : void 0;
|
|
12161
|
+
return {
|
|
12162
|
+
...gltfSkin,
|
|
12163
|
+
id: gltfSkin.id || `skin-${index}`,
|
|
12164
|
+
inverseBindMatrices
|
|
12165
|
+
};
|
|
12166
|
+
}
|
|
12167
|
+
_resolveMesh(gltfMesh, index) {
|
|
12168
|
+
const mesh = {
|
|
12169
|
+
...gltfMesh,
|
|
12170
|
+
id: gltfMesh.id || `mesh-${index}`,
|
|
12171
|
+
primitives: []
|
|
12172
|
+
};
|
|
12173
|
+
if (gltfMesh.primitives) {
|
|
12174
|
+
mesh.primitives = gltfMesh.primitives.map((gltfPrimitive) => {
|
|
12175
|
+
const primitive = {
|
|
12176
|
+
...gltfPrimitive,
|
|
12177
|
+
attributes: {},
|
|
12178
|
+
indices: void 0,
|
|
12179
|
+
material: void 0
|
|
12180
|
+
};
|
|
12181
|
+
const attributes = gltfPrimitive.attributes;
|
|
11653
12182
|
for (const attribute in attributes) {
|
|
11654
12183
|
primitive.attributes[attribute] = this.getAccessor(attributes[attribute]);
|
|
11655
12184
|
}
|
|
11656
|
-
if (
|
|
11657
|
-
primitive.indices = this.getAccessor(
|
|
12185
|
+
if (gltfPrimitive.indices !== void 0) {
|
|
12186
|
+
primitive.indices = this.getAccessor(gltfPrimitive.indices);
|
|
11658
12187
|
}
|
|
11659
|
-
if (
|
|
11660
|
-
primitive.material = this.getMaterial(
|
|
12188
|
+
if (gltfPrimitive.material !== void 0) {
|
|
12189
|
+
primitive.material = this.getMaterial(gltfPrimitive.material);
|
|
11661
12190
|
}
|
|
11662
12191
|
return primitive;
|
|
11663
12192
|
});
|
|
11664
12193
|
}
|
|
11665
12194
|
return mesh;
|
|
11666
12195
|
}
|
|
11667
|
-
_resolveMaterial(
|
|
11668
|
-
material
|
|
12196
|
+
_resolveMaterial(gltfMaterial, index) {
|
|
12197
|
+
const material = {
|
|
12198
|
+
...gltfMaterial,
|
|
12199
|
+
id: gltfMaterial.id || `material-${index}`
|
|
12200
|
+
};
|
|
11669
12201
|
if (material.normalTexture) {
|
|
11670
12202
|
material.normalTexture = { ...material.normalTexture };
|
|
11671
12203
|
material.normalTexture.texture = this.getTexture(material.normalTexture.index);
|
|
11672
12204
|
}
|
|
11673
12205
|
if (material.occlusionTexture) {
|
|
11674
|
-
material.
|
|
12206
|
+
material.occlusionTexture = { ...material.occlusionTexture };
|
|
11675
12207
|
material.occlusionTexture.texture = this.getTexture(material.occlusionTexture.index);
|
|
11676
12208
|
}
|
|
11677
12209
|
if (material.emissiveTexture) {
|
|
11678
|
-
material.
|
|
12210
|
+
material.emissiveTexture = { ...material.emissiveTexture };
|
|
11679
12211
|
material.emissiveTexture.texture = this.getTexture(material.emissiveTexture.index);
|
|
11680
12212
|
}
|
|
11681
12213
|
if (!material.emissiveFactor) {
|
|
11682
|
-
material.emissiveFactor = material.
|
|
12214
|
+
material.emissiveFactor = material.emissiveTexture ? [1, 1, 1] : [0, 0, 0];
|
|
11683
12215
|
}
|
|
11684
12216
|
if (material.pbrMetallicRoughness) {
|
|
11685
12217
|
material.pbrMetallicRoughness = { ...material.pbrMetallicRoughness };
|
|
@@ -11695,14 +12227,23 @@
|
|
|
11695
12227
|
}
|
|
11696
12228
|
return material;
|
|
11697
12229
|
}
|
|
11698
|
-
_resolveAccessor(
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
12230
|
+
_resolveAccessor(gltfAccessor, index) {
|
|
12231
|
+
const bytesPerComponent = getBytesFromComponentType(gltfAccessor.componentType);
|
|
12232
|
+
const components = getSizeFromAccessorType(gltfAccessor.type);
|
|
12233
|
+
const bytesPerElement = bytesPerComponent * components;
|
|
12234
|
+
const accessor = {
|
|
12235
|
+
...gltfAccessor,
|
|
12236
|
+
id: gltfAccessor.id || `accessor-${index}`,
|
|
12237
|
+
bytesPerComponent,
|
|
12238
|
+
components,
|
|
12239
|
+
bytesPerElement,
|
|
12240
|
+
value: void 0,
|
|
12241
|
+
bufferView: void 0,
|
|
12242
|
+
sparse: void 0
|
|
12243
|
+
};
|
|
12244
|
+
if (gltfAccessor.bufferView !== void 0) {
|
|
12245
|
+
accessor.bufferView = this.getBufferView(gltfAccessor.bufferView);
|
|
11702
12246
|
}
|
|
11703
|
-
accessor.bytesPerComponent = getBytesFromComponentType(accessor.componentType);
|
|
11704
|
-
accessor.components = getSizeFromAccessorType(accessor.type);
|
|
11705
|
-
accessor.bytesPerElement = accessor.bytesPerComponent * accessor.components;
|
|
11706
12247
|
if (accessor.bufferView) {
|
|
11707
12248
|
const buffer = accessor.bufferView.buffer;
|
|
11708
12249
|
const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
|
|
@@ -11723,15 +12264,20 @@
|
|
|
11723
12264
|
}
|
|
11724
12265
|
return result.buffer;
|
|
11725
12266
|
}
|
|
11726
|
-
_resolveTexture(
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
12267
|
+
_resolveTexture(gltfTexture, index) {
|
|
12268
|
+
return {
|
|
12269
|
+
...gltfTexture,
|
|
12270
|
+
id: gltfTexture.id || `texture-${index}`,
|
|
12271
|
+
sampler: typeof gltfTexture.sampler === "number" ? this.getSampler(gltfTexture.sampler) : makeDefaultSampler(),
|
|
12272
|
+
source: typeof gltfTexture.source === "number" ? this.getImage(gltfTexture.source) : void 0
|
|
12273
|
+
};
|
|
11731
12274
|
}
|
|
11732
|
-
_resolveSampler(
|
|
11733
|
-
sampler
|
|
11734
|
-
|
|
12275
|
+
_resolveSampler(gltfSampler, index) {
|
|
12276
|
+
const sampler = {
|
|
12277
|
+
id: gltfSampler.id || `sampler-${index}`,
|
|
12278
|
+
...gltfSampler,
|
|
12279
|
+
parameters: {}
|
|
12280
|
+
};
|
|
11735
12281
|
for (const key in sampler) {
|
|
11736
12282
|
const glEnum = this._enumSamplerParameter(key);
|
|
11737
12283
|
if (glEnum !== void 0) {
|
|
@@ -11743,337 +12289,44 @@
|
|
|
11743
12289
|
_enumSamplerParameter(key) {
|
|
11744
12290
|
return SAMPLER_PARAMETER_GLTF_TO_GL[key];
|
|
11745
12291
|
}
|
|
11746
|
-
_resolveImage(
|
|
11747
|
-
image
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
12292
|
+
_resolveImage(gltfImage, index) {
|
|
12293
|
+
const image = {
|
|
12294
|
+
...gltfImage,
|
|
12295
|
+
id: gltfImage.id || `image-${index}`,
|
|
12296
|
+
image: null,
|
|
12297
|
+
bufferView: gltfImage.bufferView !== void 0 ? this.getBufferView(gltfImage.bufferView) : void 0
|
|
12298
|
+
};
|
|
11751
12299
|
const preloadedImage = this.images[index];
|
|
11752
12300
|
if (preloadedImage) {
|
|
11753
12301
|
image.image = preloadedImage;
|
|
11754
12302
|
}
|
|
11755
12303
|
return image;
|
|
11756
12304
|
}
|
|
11757
|
-
_resolveBufferView(
|
|
11758
|
-
const bufferIndex =
|
|
11759
|
-
const result = {
|
|
11760
|
-
id: `bufferView-${index}`,
|
|
11761
|
-
...bufferView,
|
|
11762
|
-
buffer: this.buffers[bufferIndex]
|
|
11763
|
-
};
|
|
12305
|
+
_resolveBufferView(gltfBufferView, index) {
|
|
12306
|
+
const bufferIndex = gltfBufferView.buffer;
|
|
11764
12307
|
const arrayBuffer = this.buffers[bufferIndex].arrayBuffer;
|
|
11765
12308
|
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);
|
|
11851
|
-
}
|
|
11852
|
-
break;
|
|
11853
|
-
case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:
|
|
11854
|
-
if (!options.strict) {
|
|
11855
|
-
parseBINChunk(glb, dataView, byteOffset, chunkLength);
|
|
12309
|
+
if (gltfBufferView.byteOffset) {
|
|
12310
|
+
byteOffset += gltfBufferView.byteOffset;
|
|
11856
12311
|
}
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
|
|
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"
|
|
12312
|
+
const bufferView = {
|
|
12313
|
+
id: `bufferView-${index}`,
|
|
12314
|
+
...gltfBufferView,
|
|
12315
|
+
buffer: this.buffers[bufferIndex],
|
|
12316
|
+
data: new Uint8Array(arrayBuffer, byteOffset, gltfBufferView.byteLength)
|
|
12317
|
+
};
|
|
12318
|
+
return bufferView;
|
|
12319
|
+
}
|
|
12320
|
+
_resolveCamera(gltfCamera, index) {
|
|
12321
|
+
const camera = {
|
|
12322
|
+
...gltfCamera,
|
|
12323
|
+
id: gltfCamera.id || `camera-${index}`
|
|
12324
|
+
};
|
|
12325
|
+
if (camera.perspective) {
|
|
12326
|
+
}
|
|
12327
|
+
if (camera.orthographic) {
|
|
12076
12328
|
}
|
|
12329
|
+
return camera;
|
|
12077
12330
|
}
|
|
12078
12331
|
};
|
|
12079
12332
|
}
|
|
@@ -12083,17 +12336,19 @@
|
|
|
12083
12336
|
var init_src10 = __esm({
|
|
12084
12337
|
"../gltf/src/index.ts"() {
|
|
12085
12338
|
init_gltf_loader();
|
|
12339
|
+
init_post_process_gltf();
|
|
12340
|
+
init_gltf_utils();
|
|
12086
12341
|
}
|
|
12087
12342
|
});
|
|
12088
12343
|
|
|
12089
12344
|
// src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts
|
|
12090
12345
|
function parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options) {
|
|
12091
12346
|
tile.rotateYtoZ = true;
|
|
12092
|
-
const gltfByteLength = tile.byteOffset + tile.byteLength - byteOffset;
|
|
12347
|
+
const gltfByteLength = (tile.byteOffset || 0) + (tile.byteLength || 0) - byteOffset;
|
|
12093
12348
|
if (gltfByteLength === 0) {
|
|
12094
12349
|
throw new Error("glTF byte length must be greater than 0.");
|
|
12095
12350
|
}
|
|
12096
|
-
tile.gltfUpAxis = options["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
|
|
12351
|
+
tile.gltfUpAxis = options?.["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
|
|
12097
12352
|
tile.gltfArrayBuffer = sliceArrayBuffer(arrayBuffer, byteOffset, gltfByteLength);
|
|
12098
12353
|
tile.gltfByteOffset = 0;
|
|
12099
12354
|
tile.gltfByteLength = gltfByteLength;
|
|
@@ -12101,19 +12356,25 @@
|
|
|
12101
12356
|
} else {
|
|
12102
12357
|
console.warn(`${tile.type}: embedded glb is not aligned to a 4-byte boundary.`);
|
|
12103
12358
|
}
|
|
12104
|
-
return tile.byteOffset + tile.byteLength;
|
|
12359
|
+
return (tile.byteOffset || 0) + (tile.byteLength || 0);
|
|
12105
12360
|
}
|
|
12106
12361
|
async function extractGLTF(tile, gltfFormat, options, context) {
|
|
12107
|
-
const tile3DOptions = options["3d-tiles"] || {};
|
|
12362
|
+
const tile3DOptions = options?.["3d-tiles"] || {};
|
|
12108
12363
|
extractGLTFBufferOrURL(tile, gltfFormat, options);
|
|
12109
12364
|
if (tile3DOptions.loadGLTF) {
|
|
12365
|
+
if (!context) {
|
|
12366
|
+
return;
|
|
12367
|
+
}
|
|
12110
12368
|
const { parse: parse5, fetch: fetch2 } = context;
|
|
12111
12369
|
if (tile.gltfUrl) {
|
|
12112
|
-
|
|
12370
|
+
const response = await fetch2(tile.gltfUrl, options);
|
|
12371
|
+
tile.gltfArrayBuffer = await response.arrayBuffer();
|
|
12113
12372
|
tile.gltfByteOffset = 0;
|
|
12114
12373
|
}
|
|
12115
12374
|
if (tile.gltfArrayBuffer) {
|
|
12116
|
-
|
|
12375
|
+
const gltfWithBuffers = await parse5(tile.gltfArrayBuffer, GLTFLoader, options, context);
|
|
12376
|
+
tile.gltf = postProcessGLTF(gltfWithBuffers);
|
|
12377
|
+
tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
|
|
12117
12378
|
delete tile.gltfArrayBuffer;
|
|
12118
12379
|
delete tile.gltfByteOffset;
|
|
12119
12380
|
delete tile.gltfByteLength;
|
|
@@ -12123,10 +12384,12 @@
|
|
|
12123
12384
|
function extractGLTFBufferOrURL(tile, gltfFormat, options) {
|
|
12124
12385
|
switch (gltfFormat) {
|
|
12125
12386
|
case GLTF_FORMAT.URI:
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12387
|
+
if (tile.gltfArrayBuffer) {
|
|
12388
|
+
const gltfUrlBytes = new Uint8Array(tile.gltfArrayBuffer, tile.gltfByteOffset);
|
|
12389
|
+
const textDecoder = new TextDecoder();
|
|
12390
|
+
const gltfUrl = textDecoder.decode(gltfUrlBytes);
|
|
12391
|
+
tile.gltfUrl = gltfUrl.replace(/[\s\0]+$/, "");
|
|
12392
|
+
}
|
|
12130
12393
|
delete tile.gltfArrayBuffer;
|
|
12131
12394
|
delete tile.gltfByteOffset;
|
|
12132
12395
|
delete tile.gltfByteLength;
|
|
@@ -12181,7 +12444,7 @@
|
|
|
12181
12444
|
// src/lib/parsers/parse-3d-tile-instanced-model.ts
|
|
12182
12445
|
async function parseInstancedModel3DTile(tile, arrayBuffer, byteOffset, options, context) {
|
|
12183
12446
|
byteOffset = parseInstancedModel(tile, arrayBuffer, byteOffset, options, context);
|
|
12184
|
-
await extractGLTF(tile, tile.gltfFormat, options, context);
|
|
12447
|
+
await extractGLTF(tile, tile.gltfFormat || 0, options, context);
|
|
12185
12448
|
return byteOffset;
|
|
12186
12449
|
}
|
|
12187
12450
|
function parseInstancedModel(tile, arrayBuffer, byteOffset, options, context) {
|
|
@@ -12195,7 +12458,7 @@
|
|
|
12195
12458
|
byteOffset += 4;
|
|
12196
12459
|
byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);
|
|
12197
12460
|
byteOffset = parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options);
|
|
12198
|
-
if (tile.featureTableJsonByteLength === 0) {
|
|
12461
|
+
if (!tile?.header?.featureTableJsonByteLength || tile.header.featureTableJsonByteLength === 0) {
|
|
12199
12462
|
throw new Error("i3dm parser: featureTableJsonByteLength is zero.");
|
|
12200
12463
|
}
|
|
12201
12464
|
const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);
|
|
@@ -12211,17 +12474,7 @@
|
|
|
12211
12474
|
return byteOffset;
|
|
12212
12475
|
}
|
|
12213
12476
|
function extractInstancedAttributes(tile, featureTable, batchTable, instancesLength) {
|
|
12214
|
-
const
|
|
12215
|
-
instances: new Array(instancesLength),
|
|
12216
|
-
batchTable: tile._batchTable,
|
|
12217
|
-
cull: false,
|
|
12218
|
-
url: void 0,
|
|
12219
|
-
gltf: void 0,
|
|
12220
|
-
basePath: void 0,
|
|
12221
|
-
incrementallyLoadTextures: false,
|
|
12222
|
-
forwardAxis: [1, 0, 0]
|
|
12223
|
-
};
|
|
12224
|
-
const instances = collectionOptions.instances;
|
|
12477
|
+
const instances = new Array(instancesLength);
|
|
12225
12478
|
const instancePosition = new Vector3();
|
|
12226
12479
|
const instanceNormalRight = new Vector3();
|
|
12227
12480
|
const instanceNormalUp = new Vector3();
|
|
@@ -12233,19 +12486,19 @@
|
|
|
12233
12486
|
const instanceTransform = new Matrix4();
|
|
12234
12487
|
const scratch1 = [];
|
|
12235
12488
|
const scratch2 = [];
|
|
12236
|
-
const
|
|
12237
|
-
const
|
|
12489
|
+
const scratch3 = [];
|
|
12490
|
+
const scratch4 = [];
|
|
12238
12491
|
for (let i2 = 0; i2 < instancesLength; i2++) {
|
|
12239
12492
|
let position;
|
|
12240
12493
|
if (featureTable.hasProperty("POSITION")) {
|
|
12241
12494
|
position = featureTable.getProperty("POSITION", GL2.FLOAT, 3, i2, instancePosition);
|
|
12242
12495
|
} else if (featureTable.hasProperty("POSITION_QUANTIZED")) {
|
|
12243
12496
|
position = featureTable.getProperty("POSITION_QUANTIZED", GL2.UNSIGNED_SHORT, 3, i2, instancePosition);
|
|
12244
|
-
const quantizedVolumeOffset = featureTable.getGlobalProperty("QUANTIZED_VOLUME_OFFSET", GL2.FLOAT, 3
|
|
12497
|
+
const quantizedVolumeOffset = featureTable.getGlobalProperty("QUANTIZED_VOLUME_OFFSET", GL2.FLOAT, 3);
|
|
12245
12498
|
if (!quantizedVolumeOffset) {
|
|
12246
12499
|
throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");
|
|
12247
12500
|
}
|
|
12248
|
-
const quantizedVolumeScale = featureTable.getGlobalProperty("QUANTIZED_VOLUME_SCALE", GL2.FLOAT, 3
|
|
12501
|
+
const quantizedVolumeScale = featureTable.getGlobalProperty("QUANTIZED_VOLUME_SCALE", GL2.FLOAT, 3);
|
|
12249
12502
|
if (!quantizedVolumeScale) {
|
|
12250
12503
|
throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");
|
|
12251
12504
|
}
|
|
@@ -12268,8 +12521,8 @@
|
|
|
12268
12521
|
}
|
|
12269
12522
|
tile.hasCustomOrientation = true;
|
|
12270
12523
|
} else {
|
|
12271
|
-
tile.octNormalUp = featureTable.getProperty("NORMAL_UP_OCT32P", GL2.UNSIGNED_SHORT, 2, scratch1);
|
|
12272
|
-
tile.octNormalRight = featureTable.getProperty("NORMAL_RIGHT_OCT32P", GL2.UNSIGNED_SHORT, 2, scratch2);
|
|
12524
|
+
tile.octNormalUp = featureTable.getProperty("NORMAL_UP_OCT32P", GL2.UNSIGNED_SHORT, 2, i2, scratch1);
|
|
12525
|
+
tile.octNormalRight = featureTable.getProperty("NORMAL_RIGHT_OCT32P", GL2.UNSIGNED_SHORT, 2, i2, scratch2);
|
|
12273
12526
|
if (tile.octNormalUp) {
|
|
12274
12527
|
if (!tile.octNormalRight) {
|
|
12275
12528
|
throw new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");
|
|
@@ -12291,7 +12544,7 @@
|
|
|
12291
12544
|
instanceQuaternion.fromMatrix3(instanceRotation);
|
|
12292
12545
|
instanceTranslationRotationScale.rotation = instanceQuaternion;
|
|
12293
12546
|
instanceScale.set(1, 1, 1);
|
|
12294
|
-
const scale5 = featureTable.getProperty("SCALE", GL2.FLOAT, 1, i2);
|
|
12547
|
+
const scale5 = featureTable.getProperty("SCALE", GL2.FLOAT, 1, i2, scratch3);
|
|
12295
12548
|
if (Number.isFinite(scale5)) {
|
|
12296
12549
|
instanceScale.multiplyByScalar(scale5);
|
|
12297
12550
|
}
|
|
@@ -12300,7 +12553,7 @@
|
|
|
12300
12553
|
instanceScale.scale(nonUniformScale);
|
|
12301
12554
|
}
|
|
12302
12555
|
instanceTranslationRotationScale.scale = instanceScale;
|
|
12303
|
-
let batchId = featureTable.getProperty("BATCH_ID", GL2.UNSIGNED_SHORT, 1, i2);
|
|
12556
|
+
let batchId = featureTable.getProperty("BATCH_ID", GL2.UNSIGNED_SHORT, 1, i2, scratch4);
|
|
12304
12557
|
if (batchId === void 0) {
|
|
12305
12558
|
batchId = i2;
|
|
12306
12559
|
}
|
|
@@ -12337,7 +12590,7 @@
|
|
|
12337
12590
|
tile.tilesLength = view.getUint32(byteOffset, true);
|
|
12338
12591
|
byteOffset += 4;
|
|
12339
12592
|
tile.tiles = [];
|
|
12340
|
-
while (tile.tiles.length < tile.tilesLength && tile.byteLength - byteOffset > 12) {
|
|
12593
|
+
while (tile.tiles.length < tile.tilesLength && (tile.byteLength || 0) - byteOffset > 12) {
|
|
12341
12594
|
const subtile = {};
|
|
12342
12595
|
tile.tiles.push(subtile);
|
|
12343
12596
|
byteOffset = await parse3DTile2(arrayBuffer, byteOffset, options, context, subtile);
|
|
@@ -12353,9 +12606,18 @@
|
|
|
12353
12606
|
// src/lib/parsers/parse-3d-tile-gltf.ts
|
|
12354
12607
|
async function parseGltf3DTile(tile, arrayBuffer, options, context) {
|
|
12355
12608
|
tile.rotateYtoZ = true;
|
|
12356
|
-
tile.gltfUpAxis = options["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
|
|
12357
|
-
|
|
12358
|
-
|
|
12609
|
+
tile.gltfUpAxis = options?.["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
|
|
12610
|
+
if (options?.["3d-tiles"]?.loadGLTF) {
|
|
12611
|
+
if (!context) {
|
|
12612
|
+
return;
|
|
12613
|
+
}
|
|
12614
|
+
const { parse: parse5 } = context;
|
|
12615
|
+
const gltfWithBuffers = await parse5(arrayBuffer, GLTFLoader, options, context);
|
|
12616
|
+
tile.gltf = postProcessGLTF(gltfWithBuffers);
|
|
12617
|
+
tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
|
|
12618
|
+
} else {
|
|
12619
|
+
tile.gltfArrayBuffer = arrayBuffer;
|
|
12620
|
+
}
|
|
12359
12621
|
}
|
|
12360
12622
|
var init_parse_3d_tile_gltf = __esm({
|
|
12361
12623
|
"src/lib/parsers/parse-3d-tile-gltf.ts"() {
|
|
@@ -13932,11 +14194,11 @@
|
|
|
13932
14194
|
});
|
|
13933
14195
|
|
|
13934
14196
|
// src/lib/parsers/parse-3d-tile-header.ts
|
|
13935
|
-
function getTileType(tile) {
|
|
13936
|
-
if (!
|
|
14197
|
+
function getTileType(tile, tileContentUrl = "") {
|
|
14198
|
+
if (!tileContentUrl) {
|
|
13937
14199
|
return TILE_TYPE.EMPTY;
|
|
13938
14200
|
}
|
|
13939
|
-
const contentUrl =
|
|
14201
|
+
const contentUrl = tileContentUrl.split("?")[0];
|
|
13940
14202
|
const fileExtension = contentUrl.split(".").pop();
|
|
13941
14203
|
switch (fileExtension) {
|
|
13942
14204
|
case "pnts":
|
|
@@ -13947,7 +14209,7 @@
|
|
|
13947
14209
|
case "gltf":
|
|
13948
14210
|
return TILE_TYPE.SCENEGRAPH;
|
|
13949
14211
|
default:
|
|
13950
|
-
return fileExtension;
|
|
14212
|
+
return fileExtension || TILE_TYPE.EMPTY;
|
|
13951
14213
|
}
|
|
13952
14214
|
}
|
|
13953
14215
|
function getRefine(refine) {
|
|
@@ -13962,7 +14224,7 @@
|
|
|
13962
14224
|
return refine;
|
|
13963
14225
|
}
|
|
13964
14226
|
}
|
|
13965
|
-
function resolveUri(uri, basePath) {
|
|
14227
|
+
function resolveUri(uri = "", basePath) {
|
|
13966
14228
|
const urlSchemeRegex = /^[a-z][0-9a-z+.-]*:/i;
|
|
13967
14229
|
if (urlSchemeRegex.test(basePath)) {
|
|
13968
14230
|
const url = new URL(uri, `${basePath}/`);
|
|
@@ -13972,50 +14234,59 @@
|
|
|
13972
14234
|
}
|
|
13973
14235
|
return `${basePath}/${uri}`;
|
|
13974
14236
|
}
|
|
13975
|
-
function normalizeTileData(tile,
|
|
14237
|
+
function normalizeTileData(tile, basePath) {
|
|
13976
14238
|
if (!tile) {
|
|
13977
14239
|
return null;
|
|
13978
14240
|
}
|
|
14241
|
+
let tileContentUrl;
|
|
13979
14242
|
if (tile.content) {
|
|
13980
|
-
const contentUri = tile.content.uri || tile.content
|
|
13981
|
-
|
|
13982
|
-
}
|
|
13983
|
-
|
|
13984
|
-
|
|
13985
|
-
|
|
13986
|
-
|
|
13987
|
-
|
|
13988
|
-
|
|
13989
|
-
|
|
14243
|
+
const contentUri = tile.content.uri || tile.content?.url;
|
|
14244
|
+
tileContentUrl = resolveUri(contentUri, basePath);
|
|
14245
|
+
}
|
|
14246
|
+
const tilePostprocessed = {
|
|
14247
|
+
...tile,
|
|
14248
|
+
id: tileContentUrl,
|
|
14249
|
+
contentUrl: tileContentUrl,
|
|
14250
|
+
lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
14251
|
+
lodMetricValue: tile.geometricError,
|
|
14252
|
+
transformMatrix: tile.transform,
|
|
14253
|
+
type: getTileType(tile, tileContentUrl),
|
|
14254
|
+
refine: getRefine(tile.refine)
|
|
14255
|
+
};
|
|
14256
|
+
return tilePostprocessed;
|
|
13990
14257
|
}
|
|
13991
|
-
async function normalizeTileHeaders(tileset, options) {
|
|
13992
|
-
|
|
13993
|
-
|
|
13994
|
-
const rootImplicitTilingExtension = getImplicitTilingExtensionData(tileset?.root);
|
|
14258
|
+
async function normalizeTileHeaders(tileset, basePath, options) {
|
|
14259
|
+
let root = null;
|
|
14260
|
+
const rootImplicitTilingExtension = getImplicitTilingExtensionData(tileset.root);
|
|
13995
14261
|
if (rootImplicitTilingExtension && tileset.root) {
|
|
13996
|
-
root = await normalizeImplicitTileHeaders(tileset.root, tileset, rootImplicitTilingExtension, options);
|
|
14262
|
+
root = await normalizeImplicitTileHeaders(tileset.root, tileset, basePath, rootImplicitTilingExtension, options);
|
|
13997
14263
|
} else {
|
|
13998
|
-
root = normalizeTileData(tileset.root,
|
|
14264
|
+
root = normalizeTileData(tileset.root, basePath);
|
|
13999
14265
|
}
|
|
14000
14266
|
const stack2 = [];
|
|
14001
14267
|
stack2.push(root);
|
|
14002
14268
|
while (stack2.length > 0) {
|
|
14003
14269
|
const tile = stack2.pop() || {};
|
|
14004
14270
|
const children = tile.children || [];
|
|
14005
|
-
|
|
14271
|
+
const childrenPostprocessed = [];
|
|
14272
|
+
for (const childHeader of children) {
|
|
14006
14273
|
const childImplicitTilingExtension = getImplicitTilingExtensionData(childHeader);
|
|
14274
|
+
let childHeaderPostprocessed;
|
|
14007
14275
|
if (childImplicitTilingExtension) {
|
|
14008
|
-
|
|
14276
|
+
childHeaderPostprocessed = await normalizeImplicitTileHeaders(childHeader, tileset, basePath, childImplicitTilingExtension, options);
|
|
14009
14277
|
} else {
|
|
14010
|
-
normalizeTileData(childHeader,
|
|
14278
|
+
childHeaderPostprocessed = normalizeTileData(childHeader, basePath);
|
|
14279
|
+
}
|
|
14280
|
+
if (childHeaderPostprocessed) {
|
|
14281
|
+
childrenPostprocessed.push(childHeaderPostprocessed);
|
|
14282
|
+
stack2.push(childHeaderPostprocessed);
|
|
14011
14283
|
}
|
|
14012
|
-
stack2.push(childHeader);
|
|
14013
14284
|
}
|
|
14285
|
+
tile.children = childrenPostprocessed;
|
|
14014
14286
|
}
|
|
14015
14287
|
return root;
|
|
14016
14288
|
}
|
|
14017
|
-
async function normalizeImplicitTileHeaders(tile, tileset, implicitTilingExtension, options) {
|
|
14018
|
-
const basePath = tileset.basePath;
|
|
14289
|
+
async function normalizeImplicitTileHeaders(tile, tileset, basePath, implicitTilingExtension, options) {
|
|
14019
14290
|
const {
|
|
14020
14291
|
subdivisionScheme,
|
|
14021
14292
|
maximumLevel,
|
|
@@ -14025,7 +14296,7 @@
|
|
|
14025
14296
|
const replacedUrlTemplate = replaceContentUrlTemplate(subtreesUriTemplate, 0, 0, 0, 0);
|
|
14026
14297
|
const subtreeUrl = resolveUri(replacedUrlTemplate, basePath);
|
|
14027
14298
|
const subtree = await load(subtreeUrl, Tile3DSubtreeLoader, options);
|
|
14028
|
-
const contentUrlTemplate = resolveUri(tile.content
|
|
14299
|
+
const contentUrlTemplate = resolveUri(tile.content?.uri, basePath);
|
|
14029
14300
|
const refine = tileset?.root?.refine;
|
|
14030
14301
|
const rootLodMetricValue = tile.geometricError;
|
|
14031
14302
|
const s2VolumeInfo = tile.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];
|
|
@@ -14049,29 +14320,35 @@
|
|
|
14049
14320
|
getTileType,
|
|
14050
14321
|
getRefine
|
|
14051
14322
|
};
|
|
14052
|
-
return await normalizeImplicitTileData(tile, subtree, implicitOptions);
|
|
14323
|
+
return await normalizeImplicitTileData(tile, basePath, subtree, implicitOptions);
|
|
14053
14324
|
}
|
|
14054
|
-
async function normalizeImplicitTileData(tile, rootSubtree, options) {
|
|
14325
|
+
async function normalizeImplicitTileData(tile, basePath, rootSubtree, options) {
|
|
14055
14326
|
if (!tile) {
|
|
14056
14327
|
return null;
|
|
14057
14328
|
}
|
|
14058
|
-
tile.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
|
|
14059
|
-
tile.lodMetricValue = tile.geometricError;
|
|
14060
|
-
tile.transformMatrix = tile.transform;
|
|
14061
14329
|
const { children, contentUrl } = await parseImplicitTiles({
|
|
14062
14330
|
subtree: rootSubtree,
|
|
14063
|
-
options
|
|
14064
|
-
s2VolumeBox: tile
|
|
14331
|
+
options
|
|
14065
14332
|
});
|
|
14333
|
+
let tileContentUrl;
|
|
14334
|
+
let tileContent = null;
|
|
14066
14335
|
if (contentUrl) {
|
|
14067
|
-
|
|
14068
|
-
|
|
14336
|
+
tileContentUrl = contentUrl;
|
|
14337
|
+
tileContent = { uri: contentUrl.replace(`${basePath}/`, "") };
|
|
14069
14338
|
}
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14339
|
+
const tilePostprocessed = {
|
|
14340
|
+
...tile,
|
|
14341
|
+
id: tileContentUrl,
|
|
14342
|
+
contentUrl: tileContentUrl,
|
|
14343
|
+
lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
14344
|
+
lodMetricValue: tile.geometricError,
|
|
14345
|
+
transformMatrix: tile.transform,
|
|
14346
|
+
type: getTileType(tile, tileContentUrl),
|
|
14347
|
+
refine: getRefine(tile.refine),
|
|
14348
|
+
content: tileContent || tile.content,
|
|
14349
|
+
children
|
|
14350
|
+
};
|
|
14351
|
+
return tilePostprocessed;
|
|
14075
14352
|
}
|
|
14076
14353
|
function getImplicitTilingExtensionData(tile) {
|
|
14077
14354
|
return tile?.extensions?.["3DTILES_implicit_tiling"] || tile?.implicitTiling;
|
|
@@ -14087,8 +14364,33 @@
|
|
|
14087
14364
|
});
|
|
14088
14365
|
|
|
14089
14366
|
// src/tiles-3d-loader.ts
|
|
14090
|
-
function
|
|
14091
|
-
|
|
14367
|
+
async function parse4(data, options = {}, context) {
|
|
14368
|
+
const loaderOptions = options["3d-tiles"] || {};
|
|
14369
|
+
let isTileset;
|
|
14370
|
+
if (loaderOptions.isTileset === "auto") {
|
|
14371
|
+
isTileset = context?.url && context.url.indexOf(".json") !== -1;
|
|
14372
|
+
} else {
|
|
14373
|
+
isTileset = loaderOptions.isTileset;
|
|
14374
|
+
}
|
|
14375
|
+
return isTileset ? parseTileset(data, options, context) : parseTile(data, options, context);
|
|
14376
|
+
}
|
|
14377
|
+
async function parseTileset(data, options, context) {
|
|
14378
|
+
const tilesetJson = JSON.parse(new TextDecoder().decode(data));
|
|
14379
|
+
const tilesetUrl = context?.url || "";
|
|
14380
|
+
const basePath = getBaseUri(tilesetUrl);
|
|
14381
|
+
const normalizedRoot = await normalizeTileHeaders(tilesetJson, basePath, options || {});
|
|
14382
|
+
const tilesetJsonPostprocessed = {
|
|
14383
|
+
...tilesetJson,
|
|
14384
|
+
loader: Tiles3DLoader,
|
|
14385
|
+
url: tilesetUrl,
|
|
14386
|
+
queryString: context?.queryString || "",
|
|
14387
|
+
basePath,
|
|
14388
|
+
root: normalizedRoot || tilesetJson.root,
|
|
14389
|
+
type: TILESET_TYPE.TILES3D,
|
|
14390
|
+
lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
14391
|
+
lodMetricValue: tilesetJson.root?.geometricError || 0
|
|
14392
|
+
};
|
|
14393
|
+
return tilesetJsonPostprocessed;
|
|
14092
14394
|
}
|
|
14093
14395
|
async function parseTile(arrayBuffer, options, context) {
|
|
14094
14396
|
const tile = {
|
|
@@ -14100,31 +14402,8 @@
|
|
|
14100
14402
|
await parse3DTile(arrayBuffer, byteOffset, options, context, tile.content);
|
|
14101
14403
|
return tile.content;
|
|
14102
14404
|
}
|
|
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;
|
|
14405
|
+
function getBaseUri(tilesetUrl) {
|
|
14406
|
+
return path_exports.dirname(tilesetUrl);
|
|
14128
14407
|
}
|
|
14129
14408
|
var Tiles3DLoader;
|
|
14130
14409
|
var init_tiles_3d_loader = __esm({
|