@loaders.gl/tiles-3d 5.0.0-beta.4 → 5.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/3d-tiles/3d-tiles-archive-loader.js +1 -1
- package/dist/3d-tiles/dist.dev.js +941 -621
- package/dist/3d-tiles/dist.min.js +37 -37
- package/dist/3d-tiles/index.cjs +876 -947
- package/dist/3d-tiles/index.cjs.map +3 -3
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js +5 -1
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/3d-tiles/lib/utils/version.js +1 -1
- package/dist/3d-tiles-archive-writer.cjs +1 -1
- package/dist/cesium-ion-loader-with-parser.cjs +821 -942
- package/dist/cesium-ion-loader-with-parser.cjs.map +3 -3
- package/dist/copc/copc-source-loader.js +2 -2
- package/dist/copc/copc-source-loader.js.map +1 -1
- package/dist/copc/copc-writer.js +1 -1
- package/dist/copc/index.cjs +121 -181
- package/dist/copc/index.cjs.map +3 -3
- package/dist/dist.dev.js +323 -40
- package/dist/dist.min.js +10 -10
- package/dist/i3s/arcgis-webscene-loader.js +1 -1
- package/dist/i3s/dist.dev.js +3173 -712
- package/dist/i3s/dist.min.js +47 -47
- package/dist/i3s/i3s-attribute-loader.js +1 -1
- package/dist/i3s/i3s-building-scene-layer-loader.js +1 -1
- package/dist/i3s/i3s-content-loader.js +1 -1
- package/dist/i3s/i3s-lepcc-loader-types.js +1 -1
- package/dist/i3s/i3s-loader.js +1 -1
- package/dist/i3s/i3s-node-page-loader.js +1 -1
- package/dist/i3s/i3s-slpk-loader.js +1 -1
- package/dist/i3s/i3s-slpk-writer.js +1 -1
- package/dist/i3s/index.cjs +2097 -544
- package/dist/i3s/index.cjs.map +3 -3
- package/dist/i3s-content-worker-node.js +11 -11
- package/dist/i3s-content-worker-node.js.map +4 -4
- package/dist/i3s-content-worker.js +768 -346
- package/dist/i3s-lepcc-worker-node.js +245 -12
- package/dist/i3s-lepcc-worker-node.js.map +4 -4
- package/dist/i3s-lepcc-worker.js +240 -12
- package/dist/i3s-mesh-writer.cjs +1749 -290
- package/dist/i3s-mesh-writer.cjs.map +3 -3
- package/dist/i3s-slpk-writer.cjs +1 -1
- package/dist/index.cjs +98 -4
- package/dist/index.cjs.map +2 -2
- package/dist/point-cloud-tile-source-loader-types.js +1 -1
- package/dist/point-cloud-tile-source-loader.cjs +46 -2
- package/dist/point-cloud-tile-source-loader.cjs.map +2 -2
- package/dist/point-cloud-tile-source.cjs +45 -1
- package/dist/point-cloud-tile-source.cjs.map +1 -1
- package/dist/potree/dist.dev.js +325 -91
- package/dist/potree/dist.min.js +30 -30
- package/dist/potree/index.cjs +115 -176
- package/dist/potree/index.cjs.map +3 -3
- package/dist/potree/potree-bin-loader.js +1 -1
- package/dist/potree/potree-hierarchy-chunk-loader.js +1 -1
- package/dist/potree/potree-loader-types.js +1 -1
- package/dist/potree/potree-source-loader.js +1 -1
- package/dist/potree/potree-writer.js +1 -1
- package/dist/potree/potree2-source.d.ts.map +1 -1
- package/dist/potree/potree2-source.js +3 -13
- package/dist/potree/potree2-source.js.map +1 -1
- package/dist/potree-loader.cjs +1 -1
- package/package.json +13 -13
- package/src/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.ts +4 -1
- package/src/copc/copc-source-loader.ts +1 -1
- package/src/potree/potree2-source.ts +3 -14
package/dist/i3s/index.cjs
CHANGED
|
@@ -784,18 +784,6 @@ var init_globals2 = __esm({
|
|
|
784
784
|
}
|
|
785
785
|
});
|
|
786
786
|
|
|
787
|
-
// ../core/src/worker-utils/lib/worker-api/task-runtime.ts
|
|
788
|
-
function normalizeTaskProgress(progress) {
|
|
789
|
-
return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
|
|
790
|
-
}
|
|
791
|
-
var import_tasks;
|
|
792
|
-
var init_task_runtime = __esm({
|
|
793
|
-
"../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
|
|
794
|
-
"use strict";
|
|
795
|
-
import_tasks = require("@math.gl/core/tasks");
|
|
796
|
-
}
|
|
797
|
-
});
|
|
798
|
-
|
|
799
787
|
// ../core/src/worker-utils/lib/worker-api/get-worker-url.ts
|
|
800
788
|
function getCustomWorkerURL(worker, options = {}) {
|
|
801
789
|
var _a, _b;
|
|
@@ -861,6 +849,18 @@ var init_get_worker_url = __esm({
|
|
|
861
849
|
}
|
|
862
850
|
});
|
|
863
851
|
|
|
852
|
+
// ../core/src/worker-utils/lib/worker-api/task-runtime.ts
|
|
853
|
+
function normalizeTaskProgress(progress) {
|
|
854
|
+
return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
|
|
855
|
+
}
|
|
856
|
+
var import_tasks;
|
|
857
|
+
var init_task_runtime = __esm({
|
|
858
|
+
"../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
|
|
859
|
+
"use strict";
|
|
860
|
+
import_tasks = require("@math.gl/tasks");
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
|
|
864
864
|
// ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
|
|
865
865
|
function getTransferList(object, recursive = true, transfers) {
|
|
866
866
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
@@ -1117,7 +1117,7 @@ var import_tasks2, runners, activeRunners, moduleWorkerUrls;
|
|
|
1117
1117
|
var init_process_on_worker = __esm({
|
|
1118
1118
|
"../core/src/worker-utils/lib/worker-api/process-on-worker.ts"() {
|
|
1119
1119
|
"use strict";
|
|
1120
|
-
import_tasks2 = require("@math.gl/
|
|
1120
|
+
import_tasks2 = require("@math.gl/tasks");
|
|
1121
1121
|
init_get_worker_url();
|
|
1122
1122
|
init_task_runtime();
|
|
1123
1123
|
init_get_transfer_list();
|
|
@@ -1232,6 +1232,7 @@ async function loadLibraryInWorker(libraryUrl, moduleLibraryUrl = libraryUrl) {
|
|
|
1232
1232
|
} catch {
|
|
1233
1233
|
const moduleUrl = new URL(moduleLibraryUrl, globalThis.location.href).href;
|
|
1234
1234
|
const library = await import(
|
|
1235
|
+
/* webpackIgnore: true */
|
|
1235
1236
|
/* @vite-ignore */
|
|
1236
1237
|
moduleUrl
|
|
1237
1238
|
);
|
|
@@ -1292,12 +1293,10 @@ var init_library_utils = __esm({
|
|
|
1292
1293
|
});
|
|
1293
1294
|
|
|
1294
1295
|
// ../core/src/worker-utils/index.ts
|
|
1295
|
-
var import_tasks3;
|
|
1296
1296
|
var init_worker_utils = __esm({
|
|
1297
1297
|
"../core/src/worker-utils/index.ts"() {
|
|
1298
1298
|
"use strict";
|
|
1299
1299
|
init_globals2();
|
|
1300
|
-
import_tasks3 = require("@math.gl/core/tasks");
|
|
1301
1300
|
init_process_on_worker();
|
|
1302
1301
|
init_library_utils();
|
|
1303
1302
|
}
|
|
@@ -1473,9 +1472,9 @@ var init_encode_array_buffer_to_base64 = __esm({
|
|
|
1473
1472
|
|
|
1474
1473
|
// ../core/src/loader-utils/lib/iterators/text-iterators.ts
|
|
1475
1474
|
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
1476
|
-
const
|
|
1475
|
+
const textDecoder2 = new TextDecoder(void 0, options);
|
|
1477
1476
|
for await (const arrayBuffer of arrayBufferIterator) {
|
|
1478
|
-
yield typeof arrayBuffer === "string" ? arrayBuffer :
|
|
1477
|
+
yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder2.decode(arrayBuffer, { stream: true });
|
|
1479
1478
|
}
|
|
1480
1479
|
}
|
|
1481
1480
|
async function* makeLineIterator(textIterator) {
|
|
@@ -2844,6 +2843,8 @@ var init_http_file_transport = __esm({
|
|
|
2844
2843
|
identityHints;
|
|
2845
2844
|
/** Failure objects already included in telemetry. */
|
|
2846
2845
|
countedFailures = /* @__PURE__ */ new WeakSet();
|
|
2846
|
+
/** Observer for cumulative transport counters, including asynchronous cancellation. */
|
|
2847
|
+
onTelemetry;
|
|
2847
2848
|
/** Mutable counters backing immutable telemetry snapshots. */
|
|
2848
2849
|
telemetry = {
|
|
2849
2850
|
requestedBytes: 0,
|
|
@@ -2857,6 +2858,7 @@ var init_http_file_transport = __esm({
|
|
|
2857
2858
|
constructor(url, options) {
|
|
2858
2859
|
validateKnownByteLength(options.byteLength);
|
|
2859
2860
|
this.url = url;
|
|
2861
|
+
this.onTelemetry = options.onTelemetry;
|
|
2860
2862
|
this.fetchFunction = options.fetch || ((input, init) => globalThis.fetch(input, init));
|
|
2861
2863
|
this.fetchOptions = options.fetchOptions ? { ...options.fetchOptions, headers: new Headers(options.fetchOptions.headers) } : void 0;
|
|
2862
2864
|
this.consistency = options.consistency || "best-effort";
|
|
@@ -2883,6 +2885,7 @@ var init_http_file_transport = __esm({
|
|
|
2883
2885
|
}
|
|
2884
2886
|
/** Counts each failure object once even when it passes through several async layers. */
|
|
2885
2887
|
trackFailure(error) {
|
|
2888
|
+
var _a;
|
|
2886
2889
|
if (typeof error === "object" && error !== null) {
|
|
2887
2890
|
if (this.countedFailures.has(error)) {
|
|
2888
2891
|
return;
|
|
@@ -2894,10 +2897,11 @@ var init_http_file_transport = __esm({
|
|
|
2894
2897
|
} else {
|
|
2895
2898
|
this.telemetry.errorCount++;
|
|
2896
2899
|
}
|
|
2900
|
+
(_a = this.onTelemetry) == null ? void 0 : _a.call(this, this.getTelemetry(), error);
|
|
2897
2901
|
}
|
|
2898
2902
|
/** Performs and validates one exact HTTP range request. */
|
|
2899
2903
|
async requestRange(offset, length, signal, expectedIdentity) {
|
|
2900
|
-
var _a;
|
|
2904
|
+
var _a, _b;
|
|
2901
2905
|
const requestStartTime = getTimestamp2();
|
|
2902
2906
|
const abortContext = createCombinedAbortContext(signal, (_a = this.fetchOptions) == null ? void 0 : _a.signal);
|
|
2903
2907
|
this.telemetry.requestCount++;
|
|
@@ -2914,7 +2918,13 @@ var init_http_file_transport = __esm({
|
|
|
2914
2918
|
await cancelResponse(response);
|
|
2915
2919
|
throw new Error(`HTTP byte-range request expected 206, received ${response.status}`);
|
|
2916
2920
|
}
|
|
2917
|
-
const contentRange = await readContentRange(response)
|
|
2921
|
+
const contentRange = response.headers.has("Content-Range") ? await readContentRange(response) : await this.inferContentRange(
|
|
2922
|
+
response,
|
|
2923
|
+
offset,
|
|
2924
|
+
length,
|
|
2925
|
+
expectedIdentity,
|
|
2926
|
+
abortContext.signal
|
|
2927
|
+
);
|
|
2918
2928
|
const responseIdentity = getResponseIdentity(response, contentRange.byteLength);
|
|
2919
2929
|
const responseError = getIdentityError(
|
|
2920
2930
|
expectedIdentity,
|
|
@@ -2948,6 +2958,45 @@ var init_http_file_transport = __esm({
|
|
|
2948
2958
|
} finally {
|
|
2949
2959
|
abortContext.removeAbortListeners();
|
|
2950
2960
|
this.telemetry.networkTimeMs += getTimestamp2() - requestStartTime;
|
|
2961
|
+
(_b = this.onTelemetry) == null ? void 0 : _b.call(this, this.getTelemetry());
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
/** Infers bounds for a CORS-filtered 206; the caller still validates the body length. */
|
|
2965
|
+
async inferContentRange(response, offset, length, expectedIdentity, signal) {
|
|
2966
|
+
var _a;
|
|
2967
|
+
try {
|
|
2968
|
+
let byteLength = (expectedIdentity == null ? void 0 : expectedIdentity.byteLength) ?? this.identityHints.byteLength;
|
|
2969
|
+
if (byteLength === void 0) {
|
|
2970
|
+
const headers = new Headers((_a = this.fetchOptions) == null ? void 0 : _a.headers);
|
|
2971
|
+
headers.delete("Range");
|
|
2972
|
+
this.telemetry.requestCount++;
|
|
2973
|
+
const metadata3 = await this.fetchFunction(this.url, {
|
|
2974
|
+
...this.fetchOptions,
|
|
2975
|
+
method: "HEAD",
|
|
2976
|
+
body: void 0,
|
|
2977
|
+
headers,
|
|
2978
|
+
signal
|
|
2979
|
+
});
|
|
2980
|
+
await cancelResponse(metadata3);
|
|
2981
|
+
const value = metadata3.headers.get("Content-Length");
|
|
2982
|
+
byteLength = value && /^\d+$/.test(value) ? Number(value) : NaN;
|
|
2983
|
+
if (metadata3.status !== 200 || !Number.isSafeInteger(byteLength) || byteLength < offset + length) {
|
|
2984
|
+
throw new Error(
|
|
2985
|
+
"HTTP byte-range response is missing Content-Range and HEAD did not provide a valid file length"
|
|
2986
|
+
);
|
|
2987
|
+
}
|
|
2988
|
+
const identityError = getIdentityError(
|
|
2989
|
+
getResponseIdentity(metadata3, byteLength),
|
|
2990
|
+
getResponseIdentity(response, byteLength),
|
|
2991
|
+
this.identityHints,
|
|
2992
|
+
this.consistency
|
|
2993
|
+
);
|
|
2994
|
+
if (identityError) throw new Error(identityError);
|
|
2995
|
+
}
|
|
2996
|
+
return { offset, endOffset: offset + length - 1, byteLength };
|
|
2997
|
+
} catch (error) {
|
|
2998
|
+
await cancelResponse(response);
|
|
2999
|
+
throw error;
|
|
2951
3000
|
}
|
|
2952
3001
|
}
|
|
2953
3002
|
/** Validates and consumes the special empty-object identity response. */
|
|
@@ -3197,7 +3246,7 @@ function getSourceLoaderOptions(options) {
|
|
|
3197
3246
|
if (options == null ? void 0 : options.core) {
|
|
3198
3247
|
loadOptions.core = { ...options.core };
|
|
3199
3248
|
const parserCore = loadOptions.core;
|
|
3200
|
-
for (const key of ["type", "attributions", "loaders", "onError", "loadOptions"]) {
|
|
3249
|
+
for (const key of ["type", "name", "attributions", "loaders", "onError", "loadOptions"]) {
|
|
3201
3250
|
delete parserCore[key];
|
|
3202
3251
|
}
|
|
3203
3252
|
if (Object.keys(parserCore).length === 0) {
|
|
@@ -3232,6 +3281,44 @@ function unavailableCoreApiMethod(methodName) {
|
|
|
3232
3281
|
);
|
|
3233
3282
|
};
|
|
3234
3283
|
}
|
|
3284
|
+
function getDataSourceName(data, options) {
|
|
3285
|
+
var _a, _b, _c;
|
|
3286
|
+
const explicitName = (_a = options.core) == null ? void 0 : _a.name;
|
|
3287
|
+
if (explicitName !== void 0) {
|
|
3288
|
+
if (typeof explicitName !== "string" || !explicitName.trim())
|
|
3289
|
+
throw new Error("Data source name must be a non-empty string.");
|
|
3290
|
+
return explicitName;
|
|
3291
|
+
}
|
|
3292
|
+
if (data && typeof data === "object") {
|
|
3293
|
+
const named = data;
|
|
3294
|
+
if (typeof named.name === "string" && named.name.trim())
|
|
3295
|
+
return data instanceof Blob ? removeFileExtension(named.name) : named.name;
|
|
3296
|
+
const metadata3 = (_b = named.schema) == null ? void 0 : _b.metadata;
|
|
3297
|
+
const embeddedName = metadata3 instanceof Map ? metadata3.get("name") : metadata3 == null ? void 0 : metadata3.name;
|
|
3298
|
+
if (typeof embeddedName === "string" && embeddedName.trim()) return embeddedName;
|
|
3299
|
+
}
|
|
3300
|
+
if (typeof data === "string") {
|
|
3301
|
+
try {
|
|
3302
|
+
const url = new URL(data.replace(/\\/g, "/"), "https://source.invalid/");
|
|
3303
|
+
if (!["data:", "blob:"].includes(url.protocol)) {
|
|
3304
|
+
let basename = url.pathname.split("/").filter(Boolean).pop();
|
|
3305
|
+
if (basename) {
|
|
3306
|
+
try {
|
|
3307
|
+
basename = decodeURIComponent(basename);
|
|
3308
|
+
} catch {
|
|
3309
|
+
}
|
|
3310
|
+
return removeFileExtension(basename);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
} catch {
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
return ((_c = options.core) == null ? void 0 : _c.type) && options.core.type !== "auto" ? options.core.type : "source";
|
|
3317
|
+
}
|
|
3318
|
+
function removeFileExtension(name22) {
|
|
3319
|
+
const extension = name22.lastIndexOf(".");
|
|
3320
|
+
return extension > 0 ? name22.slice(0, extension) : name22;
|
|
3321
|
+
}
|
|
3235
3322
|
var UNAVAILABLE_CORE_API, DataSource;
|
|
3236
3323
|
var init_data_source = __esm({
|
|
3237
3324
|
"../core/src/loader-utils/lib/sources/data-source.ts"() {
|
|
@@ -3263,6 +3350,8 @@ var init_data_source = __esm({
|
|
|
3263
3350
|
options;
|
|
3264
3351
|
data;
|
|
3265
3352
|
url;
|
|
3353
|
+
/** Stable query-visible name, resolved without fetching source data. */
|
|
3354
|
+
name;
|
|
3266
3355
|
/** Shared parser options derived from the source options, excluding source-only core controls. */
|
|
3267
3356
|
loadOptions;
|
|
3268
3357
|
/** A resolved fetch function extracted from the shared core options. */
|
|
@@ -3279,6 +3368,7 @@ var init_data_source = __esm({
|
|
|
3279
3368
|
);
|
|
3280
3369
|
this.data = data;
|
|
3281
3370
|
this.url = typeof data === "string" ? resolvePath(data) : "";
|
|
3371
|
+
this.name = getDataSourceName(data, this.options);
|
|
3282
3372
|
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
|
|
3283
3373
|
this.loadOptions = loadOptions;
|
|
3284
3374
|
const fetch2 = getFetchFunction(loadOptions);
|
|
@@ -3287,6 +3377,9 @@ var init_data_source = __esm({
|
|
|
3287
3377
|
this.fetch = fetch2;
|
|
3288
3378
|
}
|
|
3289
3379
|
setProps(options) {
|
|
3380
|
+
var _a;
|
|
3381
|
+
if (((_a = options.core) == null ? void 0 : _a.name) !== void 0 && options.core.name !== this.name)
|
|
3382
|
+
throw new Error("Data source names are fixed at creation.");
|
|
3290
3383
|
const mergedOptions = mergeOptions(this.options, options);
|
|
3291
3384
|
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
|
|
3292
3385
|
this.options = mergedOptions;
|
|
@@ -3379,8 +3472,8 @@ function isSVG(url) {
|
|
|
3379
3472
|
}
|
|
3380
3473
|
function getBlobOrSVGDataUrl(arrayBuffer, url) {
|
|
3381
3474
|
if (isSVG(url)) {
|
|
3382
|
-
const
|
|
3383
|
-
let xmlText =
|
|
3475
|
+
const textDecoder2 = new TextDecoder();
|
|
3476
|
+
let xmlText = textDecoder2.decode(arrayBuffer);
|
|
3384
3477
|
try {
|
|
3385
3478
|
if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
|
|
3386
3479
|
xmlText = unescape(encodeURIComponent(xmlText));
|
|
@@ -5484,6 +5577,1418 @@ var init_src = __esm({
|
|
|
5484
5577
|
}
|
|
5485
5578
|
});
|
|
5486
5579
|
|
|
5580
|
+
// ../scene/src/usd/libs/usdc-parser.js
|
|
5581
|
+
function checkedLength(length, bytesPerElement = 8) {
|
|
5582
|
+
const byteLength = length * bytesPerElement;
|
|
5583
|
+
if (!Number.isSafeInteger(length) || length < 0 || !Number.isSafeInteger(byteLength) || byteLength > 256 * 1024 * 1024 - allocationBytes)
|
|
5584
|
+
throw new Error("USDC: decoded allocation limit exceeded");
|
|
5585
|
+
allocationBytes += byteLength;
|
|
5586
|
+
return length;
|
|
5587
|
+
}
|
|
5588
|
+
function checkedCount(count) {
|
|
5589
|
+
if (!Number.isSafeInteger(count) || count < 0 || count > 4e6)
|
|
5590
|
+
throw new Error("USDC: decoded allocation limit exceeded");
|
|
5591
|
+
return checkedLength(count);
|
|
5592
|
+
}
|
|
5593
|
+
function lz4DecompressBlock(input, inputOffset, inputEnd, output, outputOffset, outputEnd) {
|
|
5594
|
+
while (inputOffset < inputEnd) {
|
|
5595
|
+
const token = input[inputOffset++];
|
|
5596
|
+
if (inputOffset > inputEnd) throw new Error("USDC: truncated LZ4 token");
|
|
5597
|
+
let literalLength = token >> 4;
|
|
5598
|
+
if (literalLength === 15) {
|
|
5599
|
+
let b;
|
|
5600
|
+
do {
|
|
5601
|
+
if (inputOffset >= inputEnd) throw new Error("USDC: truncated LZ4 length");
|
|
5602
|
+
b = input[inputOffset++];
|
|
5603
|
+
literalLength += b;
|
|
5604
|
+
} while (b === 255);
|
|
5605
|
+
}
|
|
5606
|
+
if (literalLength > 0) {
|
|
5607
|
+
if (inputOffset + literalLength > inputEnd) {
|
|
5608
|
+
throw new Error("USDC: truncated LZ4 literal");
|
|
5609
|
+
}
|
|
5610
|
+
for (let i = 0; i < literalLength; i++) {
|
|
5611
|
+
if (outputOffset >= outputEnd) throw new Error("USDC: LZ4 output overflow");
|
|
5612
|
+
output[outputOffset++] = input[inputOffset++];
|
|
5613
|
+
}
|
|
5614
|
+
}
|
|
5615
|
+
if (inputOffset >= inputEnd) break;
|
|
5616
|
+
if (inputOffset + 2 > inputEnd) throw new Error("USDC: truncated LZ4 offset");
|
|
5617
|
+
const matchOffset = input[inputOffset++] | input[inputOffset++] << 8;
|
|
5618
|
+
if (matchOffset === 0) {
|
|
5619
|
+
throw new Error("USDC: invalid LZ4 match offset");
|
|
5620
|
+
}
|
|
5621
|
+
let matchLength = (token & 15) + 4;
|
|
5622
|
+
if (matchLength === 19) {
|
|
5623
|
+
let b;
|
|
5624
|
+
do {
|
|
5625
|
+
if (inputOffset >= inputEnd) throw new Error("USDC: truncated LZ4 length");
|
|
5626
|
+
b = input[inputOffset++];
|
|
5627
|
+
matchLength += b;
|
|
5628
|
+
} while (b === 255);
|
|
5629
|
+
}
|
|
5630
|
+
const matchPos = outputOffset - matchOffset;
|
|
5631
|
+
if (matchPos < 0) {
|
|
5632
|
+
throw new Error("USDC: invalid LZ4 match position");
|
|
5633
|
+
}
|
|
5634
|
+
for (let i = 0; i < matchLength; i++) {
|
|
5635
|
+
if (outputOffset >= outputEnd) throw new Error("USDC: LZ4 output overflow");
|
|
5636
|
+
output[outputOffset++] = output[matchPos + i];
|
|
5637
|
+
}
|
|
5638
|
+
}
|
|
5639
|
+
return outputOffset;
|
|
5640
|
+
}
|
|
5641
|
+
function decompressLZ4(input, uncompressedSize, allowShortOutput = false) {
|
|
5642
|
+
const output = new Uint8Array(checkedLength(uncompressedSize, 1));
|
|
5643
|
+
if (!input.length) throw new Error("USDC: missing LZ4 chunk header");
|
|
5644
|
+
const numChunks = input[0];
|
|
5645
|
+
if (numChunks === 0) {
|
|
5646
|
+
const written = lz4DecompressBlock(input, 1, input.length, output, 0, uncompressedSize);
|
|
5647
|
+
if (!allowShortOutput && written !== uncompressedSize)
|
|
5648
|
+
throw new Error("USDC: incomplete LZ4 output");
|
|
5649
|
+
return output.subarray(0, written);
|
|
5650
|
+
} else {
|
|
5651
|
+
const CHUNK_SIZE = 65536;
|
|
5652
|
+
if (1 + numChunks * 4 > input.length) throw new Error("USDC: truncated LZ4 chunk sizes");
|
|
5653
|
+
let headerOffset = 1;
|
|
5654
|
+
const compressedSizes = [];
|
|
5655
|
+
for (let i = 0; i < numChunks; i++) {
|
|
5656
|
+
const size = (input[headerOffset] | input[headerOffset + 1] << 8 | input[headerOffset + 2] << 16 | input[headerOffset + 3] << 24) >>> 0;
|
|
5657
|
+
compressedSizes.push(size);
|
|
5658
|
+
headerOffset += 4;
|
|
5659
|
+
}
|
|
5660
|
+
let inputOffset = headerOffset;
|
|
5661
|
+
let outputOffset = 0;
|
|
5662
|
+
for (let i = 0; i < numChunks; i++) {
|
|
5663
|
+
const chunkCompressedSize = compressedSizes[i];
|
|
5664
|
+
const chunkOutputSize = Math.min(CHUNK_SIZE, uncompressedSize - outputOffset);
|
|
5665
|
+
if (chunkCompressedSize > input.length - inputOffset)
|
|
5666
|
+
throw new Error("USDC: truncated LZ4 chunk");
|
|
5667
|
+
const written = lz4DecompressBlock(
|
|
5668
|
+
input,
|
|
5669
|
+
inputOffset,
|
|
5670
|
+
inputOffset + chunkCompressedSize,
|
|
5671
|
+
output,
|
|
5672
|
+
outputOffset,
|
|
5673
|
+
outputOffset + chunkOutputSize
|
|
5674
|
+
);
|
|
5675
|
+
inputOffset += chunkCompressedSize;
|
|
5676
|
+
if (i < numChunks - 1 && written !== outputOffset + chunkOutputSize)
|
|
5677
|
+
throw new Error("USDC: incomplete LZ4 chunk");
|
|
5678
|
+
outputOffset = written;
|
|
5679
|
+
}
|
|
5680
|
+
if (inputOffset !== input.length || !allowShortOutput && outputOffset !== uncompressedSize)
|
|
5681
|
+
throw new Error("USDC: incomplete LZ4 output");
|
|
5682
|
+
return output.subarray(0, outputOffset);
|
|
5683
|
+
}
|
|
5684
|
+
}
|
|
5685
|
+
function decompressIntegers32(compressedData, numInts) {
|
|
5686
|
+
const encodedSize = numInts * 4 + (numInts * 2 + 7 >> 3) + 4;
|
|
5687
|
+
const encoded = decompressLZ4(new Uint8Array(compressedData), encodedSize, true);
|
|
5688
|
+
return decodeIntegers32(encoded, numInts);
|
|
5689
|
+
}
|
|
5690
|
+
function decodeIntegers32(data, numInts) {
|
|
5691
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
5692
|
+
let offset = 0;
|
|
5693
|
+
const commonValue = view.getInt32(offset, true);
|
|
5694
|
+
offset += 4;
|
|
5695
|
+
const numCodesBytes = numInts * 2 + 7 >> 3;
|
|
5696
|
+
if (data.length < offset + numCodesBytes) throw new Error("USDC: truncated integer codes");
|
|
5697
|
+
const codesStart = offset;
|
|
5698
|
+
const vintsStart = offset + numCodesBytes;
|
|
5699
|
+
const result = new Int32Array(checkedLength(numInts));
|
|
5700
|
+
let prevVal = 0;
|
|
5701
|
+
let codesOffset = codesStart;
|
|
5702
|
+
let vintsOffset = vintsStart;
|
|
5703
|
+
for (let i = 0; i < numInts; ) {
|
|
5704
|
+
const codeByte = data[codesOffset++];
|
|
5705
|
+
for (let j = 0; j < 4 && i < numInts; j++, i++) {
|
|
5706
|
+
const code = codeByte >> j * 2 & 3;
|
|
5707
|
+
let delta = 0;
|
|
5708
|
+
switch (code) {
|
|
5709
|
+
case 0:
|
|
5710
|
+
delta = commonValue;
|
|
5711
|
+
break;
|
|
5712
|
+
case 1:
|
|
5713
|
+
delta = view.getInt8(vintsOffset);
|
|
5714
|
+
vintsOffset += 1;
|
|
5715
|
+
break;
|
|
5716
|
+
case 2:
|
|
5717
|
+
delta = view.getInt16(vintsOffset, true);
|
|
5718
|
+
vintsOffset += 2;
|
|
5719
|
+
break;
|
|
5720
|
+
case 3:
|
|
5721
|
+
delta = view.getInt32(vintsOffset, true);
|
|
5722
|
+
vintsOffset += 4;
|
|
5723
|
+
break;
|
|
5724
|
+
}
|
|
5725
|
+
prevVal += delta;
|
|
5726
|
+
result[i] = prevVal;
|
|
5727
|
+
}
|
|
5728
|
+
}
|
|
5729
|
+
return result;
|
|
5730
|
+
}
|
|
5731
|
+
var allocationBytes, textDecoder, HALF_EXPONENT_TABLE, HALF_DENORM_SCALE, TypeEnum, DICTIONARY_ARRAY_TYPES, FIELD_SET_TERMINATOR, FLOAT_COMPRESSION_INT, FLOAT_COMPRESSION_LUT, BinaryReader, ValueRep, USDCParser;
|
|
5732
|
+
var init_usdc_parser = __esm({
|
|
5733
|
+
"../scene/src/usd/libs/usdc-parser.js"() {
|
|
5734
|
+
"use strict";
|
|
5735
|
+
allocationBytes = 0;
|
|
5736
|
+
textDecoder = new TextDecoder();
|
|
5737
|
+
HALF_EXPONENT_TABLE = new Float32Array(32);
|
|
5738
|
+
for (let i = 0; i < 32; i++) {
|
|
5739
|
+
HALF_EXPONENT_TABLE[i] = Math.pow(2, i - 15);
|
|
5740
|
+
}
|
|
5741
|
+
HALF_DENORM_SCALE = Math.pow(2, -14);
|
|
5742
|
+
TypeEnum = {
|
|
5743
|
+
Invalid: 0,
|
|
5744
|
+
Bool: 1,
|
|
5745
|
+
UChar: 2,
|
|
5746
|
+
Int: 3,
|
|
5747
|
+
UInt: 4,
|
|
5748
|
+
Int64: 5,
|
|
5749
|
+
UInt64: 6,
|
|
5750
|
+
Half: 7,
|
|
5751
|
+
Float: 8,
|
|
5752
|
+
Double: 9,
|
|
5753
|
+
String: 10,
|
|
5754
|
+
Token: 11,
|
|
5755
|
+
AssetPath: 12,
|
|
5756
|
+
Matrix2d: 13,
|
|
5757
|
+
Matrix3d: 14,
|
|
5758
|
+
Matrix4d: 15,
|
|
5759
|
+
Quatd: 16,
|
|
5760
|
+
Quatf: 17,
|
|
5761
|
+
Quath: 18,
|
|
5762
|
+
Vec2d: 19,
|
|
5763
|
+
Vec2f: 20,
|
|
5764
|
+
Vec2h: 21,
|
|
5765
|
+
Vec2i: 22,
|
|
5766
|
+
Vec3d: 23,
|
|
5767
|
+
Vec3f: 24,
|
|
5768
|
+
Vec3h: 25,
|
|
5769
|
+
Vec3i: 26,
|
|
5770
|
+
Vec4d: 27,
|
|
5771
|
+
Vec4f: 28,
|
|
5772
|
+
Vec4h: 29,
|
|
5773
|
+
Vec4i: 30,
|
|
5774
|
+
Dictionary: 31,
|
|
5775
|
+
TokenListOp: 32,
|
|
5776
|
+
StringListOp: 33,
|
|
5777
|
+
PathListOp: 34,
|
|
5778
|
+
ReferenceListOp: 35,
|
|
5779
|
+
IntListOp: 36,
|
|
5780
|
+
Int64ListOp: 37,
|
|
5781
|
+
UIntListOp: 38,
|
|
5782
|
+
UInt64ListOp: 39,
|
|
5783
|
+
PathVector: 40,
|
|
5784
|
+
TokenVector: 41,
|
|
5785
|
+
Specifier: 42,
|
|
5786
|
+
Permission: 43,
|
|
5787
|
+
Variability: 44,
|
|
5788
|
+
VariantSelectionMap: 45,
|
|
5789
|
+
TimeSamples: 46,
|
|
5790
|
+
Payload: 47,
|
|
5791
|
+
DoubleVector: 48,
|
|
5792
|
+
LayerOffsetVector: 49,
|
|
5793
|
+
StringVector: 50,
|
|
5794
|
+
ValueBlock: 51,
|
|
5795
|
+
Value: 52,
|
|
5796
|
+
UnregisteredValue: 53,
|
|
5797
|
+
UnregisteredValueListOp: 54,
|
|
5798
|
+
PayloadListOp: 55,
|
|
5799
|
+
TimeCode: 56,
|
|
5800
|
+
PathExpression: 57,
|
|
5801
|
+
Relocates: 58,
|
|
5802
|
+
Spline: 59,
|
|
5803
|
+
AnimationBlock: 60
|
|
5804
|
+
};
|
|
5805
|
+
DICTIONARY_ARRAY_TYPES = /* @__PURE__ */ new Set([
|
|
5806
|
+
TypeEnum.Int,
|
|
5807
|
+
TypeEnum.UInt,
|
|
5808
|
+
TypeEnum.Float,
|
|
5809
|
+
TypeEnum.Double,
|
|
5810
|
+
TypeEnum.Half,
|
|
5811
|
+
TypeEnum.String,
|
|
5812
|
+
TypeEnum.Token
|
|
5813
|
+
]);
|
|
5814
|
+
FIELD_SET_TERMINATOR = 4294967295;
|
|
5815
|
+
FLOAT_COMPRESSION_INT = 105;
|
|
5816
|
+
FLOAT_COMPRESSION_LUT = 116;
|
|
5817
|
+
BinaryReader = class {
|
|
5818
|
+
constructor(buffer) {
|
|
5819
|
+
this.buffer = buffer;
|
|
5820
|
+
this.view = new DataView(buffer);
|
|
5821
|
+
this.offset = 0;
|
|
5822
|
+
}
|
|
5823
|
+
seek(offset) {
|
|
5824
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset > this.buffer.byteLength)
|
|
5825
|
+
throw new Error("USDC: invalid seek");
|
|
5826
|
+
this.offset = offset;
|
|
5827
|
+
}
|
|
5828
|
+
tell() {
|
|
5829
|
+
return this.offset;
|
|
5830
|
+
}
|
|
5831
|
+
readUint8() {
|
|
5832
|
+
const value = this.view.getUint8(this.offset);
|
|
5833
|
+
this.offset += 1;
|
|
5834
|
+
return value;
|
|
5835
|
+
}
|
|
5836
|
+
readInt8() {
|
|
5837
|
+
const value = this.view.getInt8(this.offset);
|
|
5838
|
+
this.offset += 1;
|
|
5839
|
+
return value;
|
|
5840
|
+
}
|
|
5841
|
+
readUint16() {
|
|
5842
|
+
const value = this.view.getUint16(this.offset, true);
|
|
5843
|
+
this.offset += 2;
|
|
5844
|
+
return value;
|
|
5845
|
+
}
|
|
5846
|
+
readInt16() {
|
|
5847
|
+
const value = this.view.getInt16(this.offset, true);
|
|
5848
|
+
this.offset += 2;
|
|
5849
|
+
return value;
|
|
5850
|
+
}
|
|
5851
|
+
readUint32() {
|
|
5852
|
+
const value = this.view.getUint32(this.offset, true);
|
|
5853
|
+
this.offset += 4;
|
|
5854
|
+
return value;
|
|
5855
|
+
}
|
|
5856
|
+
readInt32() {
|
|
5857
|
+
const value = this.view.getInt32(this.offset, true);
|
|
5858
|
+
this.offset += 4;
|
|
5859
|
+
return value;
|
|
5860
|
+
}
|
|
5861
|
+
readUint64() {
|
|
5862
|
+
const lo = this.view.getUint32(this.offset, true);
|
|
5863
|
+
const hi = this.view.getUint32(this.offset + 4, true);
|
|
5864
|
+
this.offset += 8;
|
|
5865
|
+
const result = hi * 4294967296 + lo;
|
|
5866
|
+
if (!Number.isSafeInteger(result)) throw new Error("USDC: integer exceeds safe precision");
|
|
5867
|
+
return result;
|
|
5868
|
+
}
|
|
5869
|
+
readInt64() {
|
|
5870
|
+
const lo = this.view.getUint32(this.offset, true);
|
|
5871
|
+
const hi = this.view.getInt32(this.offset + 4, true);
|
|
5872
|
+
this.offset += 8;
|
|
5873
|
+
const result = hi * 4294967296 + lo;
|
|
5874
|
+
if (!Number.isSafeInteger(result)) throw new Error("USDC: integer exceeds safe precision");
|
|
5875
|
+
return result;
|
|
5876
|
+
}
|
|
5877
|
+
readFloat32() {
|
|
5878
|
+
const value = this.view.getFloat32(this.offset, true);
|
|
5879
|
+
this.offset += 4;
|
|
5880
|
+
return value;
|
|
5881
|
+
}
|
|
5882
|
+
readFloat64() {
|
|
5883
|
+
const value = this.view.getFloat64(this.offset, true);
|
|
5884
|
+
this.offset += 8;
|
|
5885
|
+
return value;
|
|
5886
|
+
}
|
|
5887
|
+
readBytes(length) {
|
|
5888
|
+
const bytes = new Uint8Array(this.buffer, this.offset, length);
|
|
5889
|
+
this.offset += length;
|
|
5890
|
+
return bytes;
|
|
5891
|
+
}
|
|
5892
|
+
readString(length) {
|
|
5893
|
+
const bytes = this.readBytes(length);
|
|
5894
|
+
let end = 0;
|
|
5895
|
+
while (end < length && bytes[end] !== 0) end++;
|
|
5896
|
+
return textDecoder.decode(bytes.subarray(0, end));
|
|
5897
|
+
}
|
|
5898
|
+
};
|
|
5899
|
+
ValueRep = class {
|
|
5900
|
+
constructor(lo, hi) {
|
|
5901
|
+
this.lo = lo;
|
|
5902
|
+
this.hi = hi;
|
|
5903
|
+
}
|
|
5904
|
+
get isArray() {
|
|
5905
|
+
return (this.hi & 2147483648) !== 0;
|
|
5906
|
+
}
|
|
5907
|
+
get isInlined() {
|
|
5908
|
+
return (this.hi & 1073741824) !== 0;
|
|
5909
|
+
}
|
|
5910
|
+
get isCompressed() {
|
|
5911
|
+
return (this.hi & 536870912) !== 0;
|
|
5912
|
+
}
|
|
5913
|
+
get typeEnum() {
|
|
5914
|
+
return this.hi >> 16 & 255;
|
|
5915
|
+
}
|
|
5916
|
+
get payload() {
|
|
5917
|
+
return this.lo + (this.hi & 65535) * 4294967296;
|
|
5918
|
+
}
|
|
5919
|
+
getInlinedValue() {
|
|
5920
|
+
return this.lo;
|
|
5921
|
+
}
|
|
5922
|
+
};
|
|
5923
|
+
USDCParser = class {
|
|
5924
|
+
/**
|
|
5925
|
+
* Parse USDC file and return raw spec data without building Three.js scene.
|
|
5926
|
+
* Used by USDComposer for unified scene composition.
|
|
5927
|
+
*/
|
|
5928
|
+
parseData(buffer) {
|
|
5929
|
+
allocationBytes = 0;
|
|
5930
|
+
this._valueReadCount = 0;
|
|
5931
|
+
this._activeDictionaries = /* @__PURE__ */ new Set();
|
|
5932
|
+
this.buffer = buffer instanceof ArrayBuffer ? buffer : buffer.buffer;
|
|
5933
|
+
this.reader = new BinaryReader(this.buffer);
|
|
5934
|
+
this.version = { major: 0, minor: 0, patch: 0 };
|
|
5935
|
+
this._conversionBuffer = new ArrayBuffer(4);
|
|
5936
|
+
this._conversionView = new DataView(this._conversionBuffer);
|
|
5937
|
+
this._readBootstrap();
|
|
5938
|
+
this._readTOC();
|
|
5939
|
+
this._readTokens();
|
|
5940
|
+
this._readStrings();
|
|
5941
|
+
this._readFields();
|
|
5942
|
+
this._readFieldSets();
|
|
5943
|
+
this._readPaths();
|
|
5944
|
+
this._readSpecs();
|
|
5945
|
+
this.specsByPath = /* @__PURE__ */ Object.create(null);
|
|
5946
|
+
for (const spec of this.specs) {
|
|
5947
|
+
const path = this.paths[spec.pathIndex];
|
|
5948
|
+
if (!path) continue;
|
|
5949
|
+
const fields = this._getFieldsForSpec(spec);
|
|
5950
|
+
this.specsByPath[path] = { specType: spec.specType, fields };
|
|
5951
|
+
}
|
|
5952
|
+
return { specsByPath: this.specsByPath };
|
|
5953
|
+
}
|
|
5954
|
+
_readBootstrap() {
|
|
5955
|
+
const reader = this.reader;
|
|
5956
|
+
reader.seek(0);
|
|
5957
|
+
const magic = reader.readString(8);
|
|
5958
|
+
if (magic !== "PXR-USDC") {
|
|
5959
|
+
throw new Error("THREE.USDCParser: Not a valid USDC file.");
|
|
5960
|
+
}
|
|
5961
|
+
this.version.major = reader.readUint8();
|
|
5962
|
+
this.version.minor = reader.readUint8();
|
|
5963
|
+
this.version.patch = reader.readUint8();
|
|
5964
|
+
reader.readBytes(5);
|
|
5965
|
+
this.tocOffset = reader.readUint64();
|
|
5966
|
+
}
|
|
5967
|
+
_readTOC() {
|
|
5968
|
+
const reader = this.reader;
|
|
5969
|
+
reader.seek(this.tocOffset);
|
|
5970
|
+
const numSections = reader.readUint64();
|
|
5971
|
+
if (numSections > 16) throw new Error("USDC: invalid section count");
|
|
5972
|
+
this.sections = /* @__PURE__ */ Object.create(null);
|
|
5973
|
+
for (let i = 0; i < numSections; i++) {
|
|
5974
|
+
const name22 = reader.readString(16);
|
|
5975
|
+
const start = reader.readUint64();
|
|
5976
|
+
const size = reader.readUint64();
|
|
5977
|
+
this.sections[name22] = { start, size };
|
|
5978
|
+
}
|
|
5979
|
+
}
|
|
5980
|
+
_readTokens() {
|
|
5981
|
+
const section = this.sections["TOKENS"];
|
|
5982
|
+
if (!section) return;
|
|
5983
|
+
const reader = this.reader;
|
|
5984
|
+
reader.seek(section.start);
|
|
5985
|
+
const numTokens = checkedCount(reader.readUint64());
|
|
5986
|
+
this.tokens = [];
|
|
5987
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
5988
|
+
const tokensNumBytes = reader.readUint64();
|
|
5989
|
+
const tokensData = reader.readBytes(tokensNumBytes);
|
|
5990
|
+
let strStart = 0;
|
|
5991
|
+
for (let i = 0; i < numTokens; i++) {
|
|
5992
|
+
let strEnd = strStart;
|
|
5993
|
+
while (strEnd < tokensData.length && tokensData[strEnd] !== 0) strEnd++;
|
|
5994
|
+
if (strEnd >= tokensData.length) throw new Error("USDC: unterminated token data");
|
|
5995
|
+
this.tokens.push(textDecoder.decode(tokensData.subarray(strStart, strEnd)));
|
|
5996
|
+
strStart = strEnd + 1;
|
|
5997
|
+
}
|
|
5998
|
+
} else {
|
|
5999
|
+
const uncompressedSize = reader.readUint64();
|
|
6000
|
+
const compressedSize = reader.readUint64();
|
|
6001
|
+
const compressedData = reader.readBytes(compressedSize);
|
|
6002
|
+
const tokensData = decompressLZ4(compressedData, uncompressedSize);
|
|
6003
|
+
checkedLength(tokensData.length, 2);
|
|
6004
|
+
let strStart = 0;
|
|
6005
|
+
for (let i = 0; i < numTokens; i++) {
|
|
6006
|
+
let strEnd = strStart;
|
|
6007
|
+
while (strEnd < tokensData.length && tokensData[strEnd] !== 0) strEnd++;
|
|
6008
|
+
if (strEnd >= tokensData.length) throw new Error("USDC: unterminated token data");
|
|
6009
|
+
this.tokens.push(textDecoder.decode(tokensData.subarray(strStart, strEnd)));
|
|
6010
|
+
strStart = strEnd + 1;
|
|
6011
|
+
}
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
_readStrings() {
|
|
6015
|
+
const section = this.sections["STRINGS"];
|
|
6016
|
+
if (!section) {
|
|
6017
|
+
this.strings = [];
|
|
6018
|
+
return;
|
|
6019
|
+
}
|
|
6020
|
+
const reader = this.reader;
|
|
6021
|
+
reader.seek(section.start);
|
|
6022
|
+
const numStrings = checkedCount(reader.readUint64());
|
|
6023
|
+
this.strings = [];
|
|
6024
|
+
for (let i = 0; i < numStrings; i++) {
|
|
6025
|
+
this.strings.push(reader.readUint32());
|
|
6026
|
+
}
|
|
6027
|
+
}
|
|
6028
|
+
_readFields() {
|
|
6029
|
+
const section = this.sections["FIELDS"];
|
|
6030
|
+
if (!section) return;
|
|
6031
|
+
const reader = this.reader;
|
|
6032
|
+
reader.seek(section.start);
|
|
6033
|
+
this.fields = [];
|
|
6034
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
6035
|
+
const numFields = Math.floor(section.size / 12);
|
|
6036
|
+
for (let i = 0; i < numFields; i++) {
|
|
6037
|
+
const tokenIndex = reader.readUint32();
|
|
6038
|
+
const repLo = reader.readUint32();
|
|
6039
|
+
const repHi = reader.readUint32();
|
|
6040
|
+
this.fields.push({
|
|
6041
|
+
tokenIndex,
|
|
6042
|
+
valueRep: new ValueRep(repLo, repHi)
|
|
6043
|
+
});
|
|
6044
|
+
}
|
|
6045
|
+
} else {
|
|
6046
|
+
const numFields = checkedCount(reader.readUint64());
|
|
6047
|
+
const tokenIndicesCompressedSize = reader.readUint64();
|
|
6048
|
+
const tokenIndicesCompressed = reader.readBytes(tokenIndicesCompressedSize);
|
|
6049
|
+
const tokenIndices = decompressIntegers32(
|
|
6050
|
+
tokenIndicesCompressed.buffer.slice(
|
|
6051
|
+
tokenIndicesCompressed.byteOffset,
|
|
6052
|
+
tokenIndicesCompressed.byteOffset + tokenIndicesCompressedSize
|
|
6053
|
+
),
|
|
6054
|
+
numFields
|
|
6055
|
+
);
|
|
6056
|
+
const repsCompressedSize = reader.readUint64();
|
|
6057
|
+
const repsCompressed = reader.readBytes(repsCompressedSize);
|
|
6058
|
+
const repsData = decompressLZ4(repsCompressed, numFields * 8);
|
|
6059
|
+
const repsView = new DataView(repsData.buffer, repsData.byteOffset, repsData.byteLength);
|
|
6060
|
+
for (let i = 0; i < numFields; i++) {
|
|
6061
|
+
const repLo = repsView.getUint32(i * 8, true);
|
|
6062
|
+
const repHi = repsView.getUint32(i * 8 + 4, true);
|
|
6063
|
+
this.fields.push({
|
|
6064
|
+
tokenIndex: tokenIndices[i],
|
|
6065
|
+
valueRep: new ValueRep(repLo, repHi)
|
|
6066
|
+
});
|
|
6067
|
+
}
|
|
6068
|
+
}
|
|
6069
|
+
}
|
|
6070
|
+
_readFieldSets() {
|
|
6071
|
+
const section = this.sections["FIELDSETS"];
|
|
6072
|
+
if (!section) return;
|
|
6073
|
+
const reader = this.reader;
|
|
6074
|
+
reader.seek(section.start);
|
|
6075
|
+
this.fieldSets = [];
|
|
6076
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
6077
|
+
const numFieldSets = Math.floor(section.size / 4);
|
|
6078
|
+
for (let i = 0; i < numFieldSets; i++) {
|
|
6079
|
+
this.fieldSets.push(reader.readUint32());
|
|
6080
|
+
}
|
|
6081
|
+
} else {
|
|
6082
|
+
const numFieldSets = checkedCount(reader.readUint64());
|
|
6083
|
+
const compressedSize = reader.readUint64();
|
|
6084
|
+
const compressed = reader.readBytes(compressedSize);
|
|
6085
|
+
const indices = decompressIntegers32(
|
|
6086
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
6087
|
+
numFieldSets
|
|
6088
|
+
);
|
|
6089
|
+
for (let i = 0; i < numFieldSets; i++) {
|
|
6090
|
+
this.fieldSets.push(indices[i]);
|
|
6091
|
+
}
|
|
6092
|
+
}
|
|
6093
|
+
}
|
|
6094
|
+
_readPaths() {
|
|
6095
|
+
const section = this.sections["PATHS"];
|
|
6096
|
+
if (!section) return;
|
|
6097
|
+
const reader = this.reader;
|
|
6098
|
+
reader.seek(section.start);
|
|
6099
|
+
const numPaths = checkedCount(reader.readUint64());
|
|
6100
|
+
this.paths = new Array(checkedLength(numPaths)).fill("");
|
|
6101
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
6102
|
+
this._readPathsRecursive("");
|
|
6103
|
+
} else {
|
|
6104
|
+
reader.readUint64();
|
|
6105
|
+
const compressedSize1 = reader.readUint64();
|
|
6106
|
+
const pathIndicesCompressed = reader.readBytes(compressedSize1);
|
|
6107
|
+
const pathIndices = decompressIntegers32(
|
|
6108
|
+
pathIndicesCompressed.buffer.slice(
|
|
6109
|
+
pathIndicesCompressed.byteOffset,
|
|
6110
|
+
pathIndicesCompressed.byteOffset + compressedSize1
|
|
6111
|
+
),
|
|
6112
|
+
numPaths
|
|
6113
|
+
);
|
|
6114
|
+
const compressedSize2 = reader.readUint64();
|
|
6115
|
+
const elementTokenIndicesCompressed = reader.readBytes(compressedSize2);
|
|
6116
|
+
const elementTokenIndices = decompressIntegers32(
|
|
6117
|
+
elementTokenIndicesCompressed.buffer.slice(
|
|
6118
|
+
elementTokenIndicesCompressed.byteOffset,
|
|
6119
|
+
elementTokenIndicesCompressed.byteOffset + compressedSize2
|
|
6120
|
+
),
|
|
6121
|
+
numPaths
|
|
6122
|
+
);
|
|
6123
|
+
const compressedSize3 = reader.readUint64();
|
|
6124
|
+
const jumpsCompressed = reader.readBytes(compressedSize3);
|
|
6125
|
+
const jumps = decompressIntegers32(
|
|
6126
|
+
jumpsCompressed.buffer.slice(
|
|
6127
|
+
jumpsCompressed.byteOffset,
|
|
6128
|
+
jumpsCompressed.byteOffset + compressedSize3
|
|
6129
|
+
),
|
|
6130
|
+
numPaths
|
|
6131
|
+
);
|
|
6132
|
+
this._buildPathsFromCompressed(pathIndices, elementTokenIndices, jumps);
|
|
6133
|
+
}
|
|
6134
|
+
}
|
|
6135
|
+
_readPathsRecursive(parentPath, depth = 0) {
|
|
6136
|
+
const reader = this.reader;
|
|
6137
|
+
if (depth > 1e3) return;
|
|
6138
|
+
const index = reader.readUint32();
|
|
6139
|
+
const elementTokenIndex = reader.readUint32();
|
|
6140
|
+
const bits = reader.readUint8();
|
|
6141
|
+
const hasChild = (bits & 1) !== 0;
|
|
6142
|
+
const hasSibling = (bits & 2) !== 0;
|
|
6143
|
+
const isPrimProperty = (bits & 4) !== 0;
|
|
6144
|
+
let path;
|
|
6145
|
+
if (parentPath === "") {
|
|
6146
|
+
path = "/";
|
|
6147
|
+
} else {
|
|
6148
|
+
const elemToken = this.tokens[elementTokenIndex] || "";
|
|
6149
|
+
if (isPrimProperty) {
|
|
6150
|
+
path = parentPath + "." + elemToken;
|
|
6151
|
+
} else {
|
|
6152
|
+
path = parentPath === "/" ? "/" + elemToken : parentPath + "/" + elemToken;
|
|
6153
|
+
}
|
|
6154
|
+
}
|
|
6155
|
+
checkedLength(path.length, 2);
|
|
6156
|
+
this.paths[index] = path;
|
|
6157
|
+
if (hasChild && hasSibling) {
|
|
6158
|
+
const siblingOffset = reader.readUint64();
|
|
6159
|
+
this._readPathsRecursive(path, depth + 1);
|
|
6160
|
+
reader.seek(siblingOffset);
|
|
6161
|
+
this._readPathsRecursive(parentPath, depth + 1);
|
|
6162
|
+
} else if (hasChild) {
|
|
6163
|
+
this._readPathsRecursive(path, depth + 1);
|
|
6164
|
+
} else if (hasSibling) {
|
|
6165
|
+
this._readPathsRecursive(parentPath, depth + 1);
|
|
6166
|
+
}
|
|
6167
|
+
}
|
|
6168
|
+
/** Rebuilds compressed paths with an explicit stack instead of sibling recursion. */
|
|
6169
|
+
_buildPathsFromCompressed(pathIndices, elementTokenIndices, jumps) {
|
|
6170
|
+
let traversalCount = 0;
|
|
6171
|
+
const pendingPaths = [{ startIndex: 0, parentPath: "" }];
|
|
6172
|
+
while (pendingPaths.length) {
|
|
6173
|
+
const pendingPath = pendingPaths.pop();
|
|
6174
|
+
let currentIndex = pendingPath.startIndex;
|
|
6175
|
+
let parentPath = pendingPath.parentPath;
|
|
6176
|
+
while (currentIndex < pathIndices.length) {
|
|
6177
|
+
if (++traversalCount > pathIndices.length * 2)
|
|
6178
|
+
throw new Error("USDC: path traversal limit exceeded");
|
|
6179
|
+
const nodeIndex = currentIndex++;
|
|
6180
|
+
const pathIndex = pathIndices[nodeIndex];
|
|
6181
|
+
const elementTokenIndex = elementTokenIndices[nodeIndex];
|
|
6182
|
+
const jump = jumps[nodeIndex];
|
|
6183
|
+
if (pathIndex < 0 || pathIndex >= this.paths.length || Math.abs(elementTokenIndex) >= this.tokens.length || jump < -2)
|
|
6184
|
+
throw new Error("USDC: invalid compressed path index");
|
|
6185
|
+
let path;
|
|
6186
|
+
if (parentPath === "") {
|
|
6187
|
+
path = "/";
|
|
6188
|
+
parentPath = path;
|
|
6189
|
+
} else {
|
|
6190
|
+
const elementToken = this.tokens[Math.abs(elementTokenIndex)];
|
|
6191
|
+
path = elementTokenIndex < 0 ? parentPath + "." + elementToken : parentPath === "/" ? "/" + elementToken : parentPath + "/" + elementToken;
|
|
6192
|
+
}
|
|
6193
|
+
checkedLength(path.length, 2);
|
|
6194
|
+
this.paths[pathIndex] = path;
|
|
6195
|
+
const hasChild = jump > 0 || jump === -1;
|
|
6196
|
+
const hasSibling = jump >= 0;
|
|
6197
|
+
if ((hasChild || hasSibling) && currentIndex >= pathIndices.length)
|
|
6198
|
+
throw new Error("USDC: missing compressed path entry");
|
|
6199
|
+
if (hasChild && hasSibling) {
|
|
6200
|
+
const siblingIndex = nodeIndex + jump;
|
|
6201
|
+
if (siblingIndex <= currentIndex || siblingIndex >= pathIndices.length)
|
|
6202
|
+
throw new Error("USDC: invalid compressed path jump");
|
|
6203
|
+
pendingPaths.push({ startIndex: siblingIndex, parentPath });
|
|
6204
|
+
}
|
|
6205
|
+
if (hasChild) parentPath = path;
|
|
6206
|
+
else if (!hasSibling) break;
|
|
6207
|
+
}
|
|
6208
|
+
}
|
|
6209
|
+
}
|
|
6210
|
+
_readSpecs() {
|
|
6211
|
+
const section = this.sections["SPECS"];
|
|
6212
|
+
if (!section) return;
|
|
6213
|
+
const reader = this.reader;
|
|
6214
|
+
reader.seek(section.start);
|
|
6215
|
+
this.specs = [];
|
|
6216
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
6217
|
+
const specSize = this.version.minor === 0 && this.version.patch === 1 ? 16 : 12;
|
|
6218
|
+
const numSpecs = Math.floor(section.size / specSize);
|
|
6219
|
+
for (let i = 0; i < numSpecs; i++) {
|
|
6220
|
+
const pathIndex = reader.readUint32();
|
|
6221
|
+
const fieldSetIndex = reader.readUint32();
|
|
6222
|
+
const specType = reader.readUint32();
|
|
6223
|
+
if (specSize === 16) reader.readUint32();
|
|
6224
|
+
this.specs.push({ pathIndex, fieldSetIndex, specType });
|
|
6225
|
+
}
|
|
6226
|
+
} else {
|
|
6227
|
+
const numSpecs = checkedCount(reader.readUint64());
|
|
6228
|
+
const compressedSize1 = reader.readUint64();
|
|
6229
|
+
const pathIndicesCompressed = reader.readBytes(compressedSize1);
|
|
6230
|
+
const pathIndices = decompressIntegers32(
|
|
6231
|
+
pathIndicesCompressed.buffer.slice(
|
|
6232
|
+
pathIndicesCompressed.byteOffset,
|
|
6233
|
+
pathIndicesCompressed.byteOffset + compressedSize1
|
|
6234
|
+
),
|
|
6235
|
+
numSpecs
|
|
6236
|
+
);
|
|
6237
|
+
const compressedSize2 = reader.readUint64();
|
|
6238
|
+
const fieldSetIndicesCompressed = reader.readBytes(compressedSize2);
|
|
6239
|
+
const fieldSetIndices = decompressIntegers32(
|
|
6240
|
+
fieldSetIndicesCompressed.buffer.slice(
|
|
6241
|
+
fieldSetIndicesCompressed.byteOffset,
|
|
6242
|
+
fieldSetIndicesCompressed.byteOffset + compressedSize2
|
|
6243
|
+
),
|
|
6244
|
+
numSpecs
|
|
6245
|
+
);
|
|
6246
|
+
const compressedSize3 = reader.readUint64();
|
|
6247
|
+
const specTypesCompressed = reader.readBytes(compressedSize3);
|
|
6248
|
+
const specTypes = decompressIntegers32(
|
|
6249
|
+
specTypesCompressed.buffer.slice(
|
|
6250
|
+
specTypesCompressed.byteOffset,
|
|
6251
|
+
specTypesCompressed.byteOffset + compressedSize3
|
|
6252
|
+
),
|
|
6253
|
+
numSpecs
|
|
6254
|
+
);
|
|
6255
|
+
for (let i = 0; i < numSpecs; i++) {
|
|
6256
|
+
this.specs.push({
|
|
6257
|
+
pathIndex: pathIndices[i],
|
|
6258
|
+
fieldSetIndex: fieldSetIndices[i],
|
|
6259
|
+
specType: specTypes[i]
|
|
6260
|
+
});
|
|
6261
|
+
}
|
|
6262
|
+
}
|
|
6263
|
+
}
|
|
6264
|
+
// ========================================================================
|
|
6265
|
+
// Value Reading
|
|
6266
|
+
// ========================================================================
|
|
6267
|
+
_readValue(valueRep) {
|
|
6268
|
+
this._valueReadCount = (this._valueReadCount || 0) + 1;
|
|
6269
|
+
if (this._valueReadCount > 1e6) throw new Error("USDC: value traversal limit exceeded");
|
|
6270
|
+
const type = valueRep.typeEnum;
|
|
6271
|
+
const isArray = valueRep.isArray;
|
|
6272
|
+
const isInlined = valueRep.isInlined;
|
|
6273
|
+
if (type === TypeEnum.TimeSamples) {
|
|
6274
|
+
return this._readTimeSamples(valueRep);
|
|
6275
|
+
}
|
|
6276
|
+
if (isInlined) {
|
|
6277
|
+
return this._readInlinedValue(valueRep);
|
|
6278
|
+
}
|
|
6279
|
+
const offset = valueRep.payload;
|
|
6280
|
+
if (offset === 0 && isArray) {
|
|
6281
|
+
return [];
|
|
6282
|
+
}
|
|
6283
|
+
if (offset < 0 || offset >= this.buffer.byteLength) {
|
|
6284
|
+
throw new RangeError(
|
|
6285
|
+
"USDCParser: Invalid payload offset " + offset + " for type " + type + "."
|
|
6286
|
+
);
|
|
6287
|
+
}
|
|
6288
|
+
const savedOffset = this.reader.tell();
|
|
6289
|
+
this.reader.seek(offset);
|
|
6290
|
+
let value;
|
|
6291
|
+
if (isArray) {
|
|
6292
|
+
value = this._readArrayValue(valueRep);
|
|
6293
|
+
} else {
|
|
6294
|
+
value = this._readScalarValue(type);
|
|
6295
|
+
}
|
|
6296
|
+
this.reader.seek(savedOffset);
|
|
6297
|
+
return value;
|
|
6298
|
+
}
|
|
6299
|
+
_readInlinedValue(valueRep) {
|
|
6300
|
+
const type = valueRep.typeEnum;
|
|
6301
|
+
const payload = valueRep.getInlinedValue();
|
|
6302
|
+
const view = this._conversionView;
|
|
6303
|
+
switch (type) {
|
|
6304
|
+
case TypeEnum.Dictionary:
|
|
6305
|
+
if (payload !== 0) throw new Error("USDC: invalid inline dictionary");
|
|
6306
|
+
return /* @__PURE__ */ Object.create(null);
|
|
6307
|
+
case TypeEnum.Bool:
|
|
6308
|
+
return payload !== 0;
|
|
6309
|
+
case TypeEnum.UChar:
|
|
6310
|
+
return payload & 255;
|
|
6311
|
+
case TypeEnum.Int:
|
|
6312
|
+
case TypeEnum.Int64:
|
|
6313
|
+
return payload | 0;
|
|
6314
|
+
case TypeEnum.UInt:
|
|
6315
|
+
case TypeEnum.UInt64:
|
|
6316
|
+
return payload >>> 0;
|
|
6317
|
+
case TypeEnum.Half:
|
|
6318
|
+
return this._halfToFloat(payload & 65535);
|
|
6319
|
+
case TypeEnum.Float: {
|
|
6320
|
+
view.setUint32(0, payload, true);
|
|
6321
|
+
return view.getFloat32(0, true);
|
|
6322
|
+
}
|
|
6323
|
+
case TypeEnum.Double: {
|
|
6324
|
+
view.setUint32(0, payload, true);
|
|
6325
|
+
return view.getFloat32(0, true);
|
|
6326
|
+
}
|
|
6327
|
+
case TypeEnum.Token:
|
|
6328
|
+
return this.tokens[payload] || "";
|
|
6329
|
+
case TypeEnum.String:
|
|
6330
|
+
return this.tokens[this.strings[payload]] || "";
|
|
6331
|
+
case TypeEnum.AssetPath:
|
|
6332
|
+
return this.tokens[payload] || "";
|
|
6333
|
+
case TypeEnum.Specifier:
|
|
6334
|
+
return payload;
|
|
6335
|
+
// 0=def, 1=over, 2=class
|
|
6336
|
+
case TypeEnum.Permission:
|
|
6337
|
+
case TypeEnum.Variability:
|
|
6338
|
+
return payload;
|
|
6339
|
+
// Vec2h: Two half-floats fit in 4 bytes, stored directly
|
|
6340
|
+
case TypeEnum.Vec2h: {
|
|
6341
|
+
view.setUint32(0, payload, true);
|
|
6342
|
+
return [
|
|
6343
|
+
this._halfToFloat(view.getUint16(0, true)),
|
|
6344
|
+
this._halfToFloat(view.getUint16(2, true))
|
|
6345
|
+
];
|
|
6346
|
+
}
|
|
6347
|
+
// Inlined vectors that don't fit in 4 bytes are encoded as signed 8-bit integers
|
|
6348
|
+
// Vec2f = 8 bytes (2x float32), Vec3f = 12 bytes, Vec4f = 16 bytes, etc.
|
|
6349
|
+
case TypeEnum.Vec2f:
|
|
6350
|
+
case TypeEnum.Vec2i: {
|
|
6351
|
+
view.setUint32(0, payload, true);
|
|
6352
|
+
return [view.getInt8(0), view.getInt8(1)];
|
|
6353
|
+
}
|
|
6354
|
+
case TypeEnum.Vec3f:
|
|
6355
|
+
case TypeEnum.Vec3i: {
|
|
6356
|
+
view.setUint32(0, payload, true);
|
|
6357
|
+
return [view.getInt8(0), view.getInt8(1), view.getInt8(2)];
|
|
6358
|
+
}
|
|
6359
|
+
case TypeEnum.Vec4f:
|
|
6360
|
+
case TypeEnum.Vec4i: {
|
|
6361
|
+
view.setUint32(0, payload, true);
|
|
6362
|
+
return [view.getInt8(0), view.getInt8(1), view.getInt8(2), view.getInt8(3)];
|
|
6363
|
+
}
|
|
6364
|
+
case TypeEnum.Matrix2d: {
|
|
6365
|
+
view.setUint32(0, payload, true);
|
|
6366
|
+
const d0 = view.getInt8(0), d1 = view.getInt8(1);
|
|
6367
|
+
return [d0, 0, 0, d1];
|
|
6368
|
+
}
|
|
6369
|
+
case TypeEnum.Matrix3d: {
|
|
6370
|
+
view.setUint32(0, payload, true);
|
|
6371
|
+
const d0 = view.getInt8(0), d1 = view.getInt8(1), d2 = view.getInt8(2);
|
|
6372
|
+
return [d0, 0, 0, 0, d1, 0, 0, 0, d2];
|
|
6373
|
+
}
|
|
6374
|
+
case TypeEnum.Matrix4d: {
|
|
6375
|
+
view.setUint32(0, payload, true);
|
|
6376
|
+
const d0 = view.getInt8(0), d1 = view.getInt8(1), d2 = view.getInt8(2), d3 = view.getInt8(3);
|
|
6377
|
+
return [d0, 0, 0, 0, 0, d1, 0, 0, 0, 0, d2, 0, 0, 0, 0, d3];
|
|
6378
|
+
}
|
|
6379
|
+
default:
|
|
6380
|
+
throw new Error("USDC: unsupported inline value type " + type);
|
|
6381
|
+
}
|
|
6382
|
+
}
|
|
6383
|
+
_readTimeSamples(valueRep) {
|
|
6384
|
+
const reader = this.reader;
|
|
6385
|
+
const offset = valueRep.payload;
|
|
6386
|
+
const savedOffset = reader.tell();
|
|
6387
|
+
reader.seek(offset);
|
|
6388
|
+
const timesStart = reader.tell();
|
|
6389
|
+
const timesRelOffset = reader.readInt64();
|
|
6390
|
+
reader.seek(timesStart + timesRelOffset);
|
|
6391
|
+
const timesRepLo = reader.readUint32();
|
|
6392
|
+
const timesRepHi = reader.readUint32();
|
|
6393
|
+
const timesRep = new ValueRep(timesRepLo, timesRepHi);
|
|
6394
|
+
const times = this._readValue(timesRep);
|
|
6395
|
+
const afterTimesRep = timesStart + timesRelOffset + 8;
|
|
6396
|
+
reader.seek(afterTimesRep);
|
|
6397
|
+
const valuesStart = reader.tell();
|
|
6398
|
+
const valuesRelOffset = reader.readInt64();
|
|
6399
|
+
reader.seek(valuesStart + valuesRelOffset);
|
|
6400
|
+
const numValues = checkedCount(reader.readUint64());
|
|
6401
|
+
const valueReps = [];
|
|
6402
|
+
for (let i = 0; i < numValues; i++) {
|
|
6403
|
+
const repLo = reader.readUint32();
|
|
6404
|
+
const repHi = reader.readUint32();
|
|
6405
|
+
valueReps.push(new ValueRep(repLo, repHi));
|
|
6406
|
+
}
|
|
6407
|
+
const values = [];
|
|
6408
|
+
for (let i = 0; i < numValues; i++) {
|
|
6409
|
+
values.push(this._readValue(valueReps[i]));
|
|
6410
|
+
}
|
|
6411
|
+
reader.seek(savedOffset);
|
|
6412
|
+
const timesArray = times instanceof Float64Array ? Array.from(times) : Array.isArray(times) ? times : [times];
|
|
6413
|
+
return { times: timesArray, values };
|
|
6414
|
+
}
|
|
6415
|
+
_readScalarValue(type) {
|
|
6416
|
+
const reader = this.reader;
|
|
6417
|
+
switch (type) {
|
|
6418
|
+
case TypeEnum.Invalid:
|
|
6419
|
+
return null;
|
|
6420
|
+
case TypeEnum.Bool:
|
|
6421
|
+
return reader.readUint8() !== 0;
|
|
6422
|
+
case TypeEnum.UChar:
|
|
6423
|
+
return reader.readUint8();
|
|
6424
|
+
case TypeEnum.Int:
|
|
6425
|
+
return reader.readInt32();
|
|
6426
|
+
case TypeEnum.UInt:
|
|
6427
|
+
return reader.readUint32();
|
|
6428
|
+
case TypeEnum.Int64:
|
|
6429
|
+
return reader.readInt64();
|
|
6430
|
+
case TypeEnum.UInt64:
|
|
6431
|
+
return reader.readUint64();
|
|
6432
|
+
case TypeEnum.Half:
|
|
6433
|
+
return this._readHalf();
|
|
6434
|
+
case TypeEnum.Float:
|
|
6435
|
+
return reader.readFloat32();
|
|
6436
|
+
case TypeEnum.Double:
|
|
6437
|
+
return reader.readFloat64();
|
|
6438
|
+
case TypeEnum.String:
|
|
6439
|
+
case TypeEnum.Token: {
|
|
6440
|
+
const index = reader.readUint32();
|
|
6441
|
+
return this.tokens[index] || "";
|
|
6442
|
+
}
|
|
6443
|
+
case TypeEnum.AssetPath: {
|
|
6444
|
+
const index = reader.readUint32();
|
|
6445
|
+
return this.tokens[index] || "";
|
|
6446
|
+
}
|
|
6447
|
+
case TypeEnum.Vec2f:
|
|
6448
|
+
return [reader.readFloat32(), reader.readFloat32()];
|
|
6449
|
+
case TypeEnum.Vec2d:
|
|
6450
|
+
return [reader.readFloat64(), reader.readFloat64()];
|
|
6451
|
+
case TypeEnum.Vec2i:
|
|
6452
|
+
return [reader.readInt32(), reader.readInt32()];
|
|
6453
|
+
case TypeEnum.Vec3f:
|
|
6454
|
+
return [reader.readFloat32(), reader.readFloat32(), reader.readFloat32()];
|
|
6455
|
+
case TypeEnum.Vec3d:
|
|
6456
|
+
return [reader.readFloat64(), reader.readFloat64(), reader.readFloat64()];
|
|
6457
|
+
case TypeEnum.Vec3i:
|
|
6458
|
+
return [reader.readInt32(), reader.readInt32(), reader.readInt32()];
|
|
6459
|
+
case TypeEnum.Vec4f:
|
|
6460
|
+
return [
|
|
6461
|
+
reader.readFloat32(),
|
|
6462
|
+
reader.readFloat32(),
|
|
6463
|
+
reader.readFloat32(),
|
|
6464
|
+
reader.readFloat32()
|
|
6465
|
+
];
|
|
6466
|
+
case TypeEnum.Vec4d:
|
|
6467
|
+
return [
|
|
6468
|
+
reader.readFloat64(),
|
|
6469
|
+
reader.readFloat64(),
|
|
6470
|
+
reader.readFloat64(),
|
|
6471
|
+
reader.readFloat64()
|
|
6472
|
+
];
|
|
6473
|
+
case TypeEnum.Quatf:
|
|
6474
|
+
return [
|
|
6475
|
+
reader.readFloat32(),
|
|
6476
|
+
reader.readFloat32(),
|
|
6477
|
+
reader.readFloat32(),
|
|
6478
|
+
reader.readFloat32()
|
|
6479
|
+
];
|
|
6480
|
+
case TypeEnum.Quatd:
|
|
6481
|
+
return [
|
|
6482
|
+
reader.readFloat64(),
|
|
6483
|
+
reader.readFloat64(),
|
|
6484
|
+
reader.readFloat64(),
|
|
6485
|
+
reader.readFloat64()
|
|
6486
|
+
];
|
|
6487
|
+
case TypeEnum.Matrix4d: {
|
|
6488
|
+
const m = [];
|
|
6489
|
+
for (let i = 0; i < 16; i++) m.push(reader.readFloat64());
|
|
6490
|
+
return m;
|
|
6491
|
+
}
|
|
6492
|
+
case TypeEnum.TokenVector: {
|
|
6493
|
+
const count = checkedCount(reader.readUint64());
|
|
6494
|
+
const tokens = [];
|
|
6495
|
+
for (let i = 0; i < count; i++) {
|
|
6496
|
+
const index = reader.readUint32();
|
|
6497
|
+
tokens.push(this.tokens[index] || "");
|
|
6498
|
+
}
|
|
6499
|
+
return tokens;
|
|
6500
|
+
}
|
|
6501
|
+
case TypeEnum.PathVector: {
|
|
6502
|
+
const count = checkedCount(reader.readUint64());
|
|
6503
|
+
const paths = [];
|
|
6504
|
+
for (let i = 0; i < count; i++) {
|
|
6505
|
+
const index = reader.readUint32();
|
|
6506
|
+
paths.push(this.paths[index] || "");
|
|
6507
|
+
}
|
|
6508
|
+
return paths;
|
|
6509
|
+
}
|
|
6510
|
+
case TypeEnum.DoubleVector: {
|
|
6511
|
+
const count = checkedCount(reader.readUint64());
|
|
6512
|
+
const arr = new Float64Array(checkedLength(count));
|
|
6513
|
+
for (let i = 0; i < count; i++) arr[i] = reader.readFloat64();
|
|
6514
|
+
return arr;
|
|
6515
|
+
}
|
|
6516
|
+
case TypeEnum.Dictionary:
|
|
6517
|
+
return this._readDictionary();
|
|
6518
|
+
case TypeEnum.TokenListOp:
|
|
6519
|
+
case TypeEnum.StringListOp:
|
|
6520
|
+
case TypeEnum.IntListOp:
|
|
6521
|
+
case TypeEnum.Int64ListOp:
|
|
6522
|
+
case TypeEnum.UIntListOp:
|
|
6523
|
+
case TypeEnum.UInt64ListOp:
|
|
6524
|
+
throw new Error("USDC: value list operations are unsupported");
|
|
6525
|
+
case TypeEnum.PathListOp: {
|
|
6526
|
+
const flags = reader.readUint8();
|
|
6527
|
+
if (flags & 24 || (flags & 102).toString(2).replaceAll("0", "").length > 1)
|
|
6528
|
+
throw new Error("USDC: compound path list operations are unsupported");
|
|
6529
|
+
const hasExplicitItems = (flags & 2) !== 0;
|
|
6530
|
+
const hasAddItems = (flags & 4) !== 0;
|
|
6531
|
+
const hasDeleteItems = (flags & 8) !== 0;
|
|
6532
|
+
const hasReorderItems = (flags & 16) !== 0;
|
|
6533
|
+
const hasPrependItems = (flags & 32) !== 0;
|
|
6534
|
+
const hasAppendItems = (flags & 64) !== 0;
|
|
6535
|
+
const readPathList = () => {
|
|
6536
|
+
const itemCount = checkedCount(reader.readUint64());
|
|
6537
|
+
const paths = [];
|
|
6538
|
+
for (let i = 0; i < itemCount; i++) {
|
|
6539
|
+
const pathIdx = reader.readUint32();
|
|
6540
|
+
paths.push(this.paths[pathIdx]);
|
|
6541
|
+
}
|
|
6542
|
+
return paths;
|
|
6543
|
+
};
|
|
6544
|
+
let explicitPaths = null;
|
|
6545
|
+
let addPaths = null;
|
|
6546
|
+
let prependPaths = null;
|
|
6547
|
+
let appendPaths = null;
|
|
6548
|
+
if (hasExplicitItems) explicitPaths = readPathList();
|
|
6549
|
+
if (hasAddItems) addPaths = readPathList();
|
|
6550
|
+
if (hasPrependItems) prependPaths = readPathList();
|
|
6551
|
+
if (hasAppendItems) appendPaths = readPathList();
|
|
6552
|
+
if (hasDeleteItems) readPathList();
|
|
6553
|
+
if (hasReorderItems) readPathList();
|
|
6554
|
+
if (prependPaths && prependPaths.length > 0) return prependPaths;
|
|
6555
|
+
if (explicitPaths && explicitPaths.length > 0) return explicitPaths;
|
|
6556
|
+
if (appendPaths && appendPaths.length > 0) return appendPaths;
|
|
6557
|
+
if (addPaths && addPaths.length > 0) return addPaths;
|
|
6558
|
+
return null;
|
|
6559
|
+
}
|
|
6560
|
+
case TypeEnum.VariantSelectionMap: {
|
|
6561
|
+
const elementCount = checkedCount(reader.readUint64());
|
|
6562
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
6563
|
+
for (let i = 0; i < elementCount; i++) {
|
|
6564
|
+
const keyIdx = reader.readUint32();
|
|
6565
|
+
const valueIdx = reader.readUint32();
|
|
6566
|
+
const key = this.tokens[this.strings[keyIdx]];
|
|
6567
|
+
const value = this.tokens[this.strings[valueIdx]];
|
|
6568
|
+
if (key && value) map[key] = value;
|
|
6569
|
+
}
|
|
6570
|
+
return map;
|
|
6571
|
+
}
|
|
6572
|
+
default:
|
|
6573
|
+
throw new Error(
|
|
6574
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unsupported scalar type", type].join(" ")
|
|
6575
|
+
);
|
|
6576
|
+
}
|
|
6577
|
+
}
|
|
6578
|
+
/** Reads bounded string-keyed dictionary entries and their recursive value representations. */
|
|
6579
|
+
_readDictionary() {
|
|
6580
|
+
const reader = this.reader;
|
|
6581
|
+
const dictionaryOffset = reader.tell();
|
|
6582
|
+
this._activeDictionaries ||= /* @__PURE__ */ new Set();
|
|
6583
|
+
if (this._activeDictionaries.has(dictionaryOffset))
|
|
6584
|
+
throw new Error("USDC: cyclic dictionary value");
|
|
6585
|
+
if (this._activeDictionaries.size >= 64)
|
|
6586
|
+
throw new Error("USDC: dictionary depth limit exceeded");
|
|
6587
|
+
this._activeDictionaries.add(dictionaryOffset);
|
|
6588
|
+
try {
|
|
6589
|
+
const count = checkedCount(reader.readUint64());
|
|
6590
|
+
if (count > Math.floor((this.buffer.byteLength - reader.tell()) / 20))
|
|
6591
|
+
throw new Error("USDC: truncated dictionary entries");
|
|
6592
|
+
const dictionary = /* @__PURE__ */ Object.create(null);
|
|
6593
|
+
for (let index = 0; index < count; index++) {
|
|
6594
|
+
const stringIndex = reader.readUint32();
|
|
6595
|
+
const key = this.tokens[this.strings[stringIndex]];
|
|
6596
|
+
if (typeof key !== "string" || Object.hasOwn(dictionary, key))
|
|
6597
|
+
throw new Error("USDC: invalid dictionary key");
|
|
6598
|
+
const offsetLocation = reader.tell();
|
|
6599
|
+
const relativeOffset = reader.readInt64();
|
|
6600
|
+
if (relativeOffset < 8) throw new Error("USDC: invalid dictionary value offset");
|
|
6601
|
+
reader.seek(offsetLocation + relativeOffset);
|
|
6602
|
+
const representation = new ValueRep(reader.readUint32(), reader.readUint32());
|
|
6603
|
+
if (representation.typeEnum < TypeEnum.Bool || representation.typeEnum > TypeEnum.AssetPath && representation.typeEnum !== TypeEnum.Dictionary || representation.isArray && !DICTIONARY_ARRAY_TYPES.has(representation.typeEnum))
|
|
6604
|
+
throw new Error("USDC: unsupported dictionary value type");
|
|
6605
|
+
const nextEntry = reader.tell();
|
|
6606
|
+
const value = this._readValue(representation);
|
|
6607
|
+
dictionary[key] = representation.typeEnum === TypeEnum.AssetPath ? { assetPath: value } : value;
|
|
6608
|
+
reader.seek(nextEntry);
|
|
6609
|
+
}
|
|
6610
|
+
return dictionary;
|
|
6611
|
+
} finally {
|
|
6612
|
+
this._activeDictionaries.delete(dictionaryOffset);
|
|
6613
|
+
}
|
|
6614
|
+
}
|
|
6615
|
+
_readArrayValue(valueRep) {
|
|
6616
|
+
const reader = this.reader;
|
|
6617
|
+
const type = valueRep.typeEnum;
|
|
6618
|
+
const isCompressed = valueRep.isCompressed;
|
|
6619
|
+
let size;
|
|
6620
|
+
if (this.version.major === 0 && this.version.minor < 7) {
|
|
6621
|
+
size = reader.readUint32();
|
|
6622
|
+
} else {
|
|
6623
|
+
size = reader.readUint64();
|
|
6624
|
+
}
|
|
6625
|
+
if (!Number.isSafeInteger(size) || size < 0) {
|
|
6626
|
+
throw new RangeError("USDCParser: Invalid array size " + size + " for type " + type + ".");
|
|
6627
|
+
}
|
|
6628
|
+
if (size > 2147483647) {
|
|
6629
|
+
throw new RangeError("USDCParser: Array size " + size + " exceeds implementation limits.");
|
|
6630
|
+
}
|
|
6631
|
+
size = checkedCount(size);
|
|
6632
|
+
if (size === 0) return [];
|
|
6633
|
+
if (isCompressed) {
|
|
6634
|
+
return this._readCompressedArray(type, size);
|
|
6635
|
+
}
|
|
6636
|
+
switch (type) {
|
|
6637
|
+
case TypeEnum.Int: {
|
|
6638
|
+
const arr = new Int32Array(checkedLength(size));
|
|
6639
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readInt32();
|
|
6640
|
+
return arr;
|
|
6641
|
+
}
|
|
6642
|
+
case TypeEnum.UInt: {
|
|
6643
|
+
const arr = new Uint32Array(checkedLength(size));
|
|
6644
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readUint32();
|
|
6645
|
+
return arr;
|
|
6646
|
+
}
|
|
6647
|
+
case TypeEnum.Float: {
|
|
6648
|
+
const arr = new Float32Array(checkedLength(size));
|
|
6649
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readFloat32();
|
|
6650
|
+
return arr;
|
|
6651
|
+
}
|
|
6652
|
+
case TypeEnum.Double: {
|
|
6653
|
+
const arr = new Float64Array(checkedLength(size));
|
|
6654
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readFloat64();
|
|
6655
|
+
return arr;
|
|
6656
|
+
}
|
|
6657
|
+
case TypeEnum.Vec2f: {
|
|
6658
|
+
const arr = new Float32Array(checkedLength(size * 2));
|
|
6659
|
+
for (let i = 0; i < size * 2; i++) arr[i] = reader.readFloat32();
|
|
6660
|
+
return arr;
|
|
6661
|
+
}
|
|
6662
|
+
case TypeEnum.Vec3f: {
|
|
6663
|
+
const arr = new Float32Array(checkedLength(size * 3));
|
|
6664
|
+
for (let i = 0; i < size * 3; i++) arr[i] = reader.readFloat32();
|
|
6665
|
+
return arr;
|
|
6666
|
+
}
|
|
6667
|
+
case TypeEnum.Vec4f: {
|
|
6668
|
+
const arr = new Float32Array(checkedLength(size * 4));
|
|
6669
|
+
for (let i = 0; i < size * 4; i++) arr[i] = reader.readFloat32();
|
|
6670
|
+
return arr;
|
|
6671
|
+
}
|
|
6672
|
+
case TypeEnum.Vec3h: {
|
|
6673
|
+
const arr = new Float32Array(checkedLength(size * 3));
|
|
6674
|
+
for (let i = 0; i < size * 3; i++) arr[i] = this._readHalf();
|
|
6675
|
+
return arr;
|
|
6676
|
+
}
|
|
6677
|
+
case TypeEnum.Quatf: {
|
|
6678
|
+
const arr = new Float32Array(checkedLength(size * 4));
|
|
6679
|
+
for (let i = 0; i < size * 4; i++) arr[i] = reader.readFloat32();
|
|
6680
|
+
return arr;
|
|
6681
|
+
}
|
|
6682
|
+
case TypeEnum.Quath: {
|
|
6683
|
+
const arr = new Float32Array(checkedLength(size * 4));
|
|
6684
|
+
for (let i = 0; i < size * 4; i++) arr[i] = this._readHalf();
|
|
6685
|
+
return arr;
|
|
6686
|
+
}
|
|
6687
|
+
case TypeEnum.Matrix4d: {
|
|
6688
|
+
const arr = new Float64Array(checkedLength(size * 16));
|
|
6689
|
+
for (let i = 0; i < size * 16; i++) arr[i] = reader.readFloat64();
|
|
6690
|
+
return arr;
|
|
6691
|
+
}
|
|
6692
|
+
case TypeEnum.String:
|
|
6693
|
+
case TypeEnum.Token: {
|
|
6694
|
+
const arr = [];
|
|
6695
|
+
for (let i = 0; i < size; i++) {
|
|
6696
|
+
const index = reader.readUint32();
|
|
6697
|
+
const tokenIndex = type === TypeEnum.String ? this.strings[index] : index;
|
|
6698
|
+
const value = this.tokens[tokenIndex];
|
|
6699
|
+
if (typeof value !== "string") throw new Error("USDC: invalid string array index");
|
|
6700
|
+
arr.push(value);
|
|
6701
|
+
}
|
|
6702
|
+
return arr;
|
|
6703
|
+
}
|
|
6704
|
+
case TypeEnum.Half: {
|
|
6705
|
+
const arr = new Float32Array(checkedLength(size));
|
|
6706
|
+
for (let i = 0; i < size; i++) arr[i] = this._readHalf();
|
|
6707
|
+
return arr;
|
|
6708
|
+
}
|
|
6709
|
+
default:
|
|
6710
|
+
throw new Error(
|
|
6711
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unsupported array type", type].join(" ")
|
|
6712
|
+
);
|
|
6713
|
+
}
|
|
6714
|
+
}
|
|
6715
|
+
_readCompressedArray(type, size) {
|
|
6716
|
+
const reader = this.reader;
|
|
6717
|
+
switch (type) {
|
|
6718
|
+
case TypeEnum.Int:
|
|
6719
|
+
case TypeEnum.UInt: {
|
|
6720
|
+
const compressedSize = reader.readUint64();
|
|
6721
|
+
const compressed = reader.readBytes(compressedSize);
|
|
6722
|
+
const values = decompressIntegers32(
|
|
6723
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
6724
|
+
size
|
|
6725
|
+
);
|
|
6726
|
+
return type === TypeEnum.UInt ? new Uint32Array(values.buffer, values.byteOffset, values.length) : values;
|
|
6727
|
+
}
|
|
6728
|
+
case TypeEnum.Half:
|
|
6729
|
+
case TypeEnum.Double:
|
|
6730
|
+
case TypeEnum.Float: {
|
|
6731
|
+
const code = reader.readInt8();
|
|
6732
|
+
if (code === FLOAT_COMPRESSION_INT) {
|
|
6733
|
+
const compressedSize = reader.readUint64();
|
|
6734
|
+
const compressed = reader.readBytes(compressedSize);
|
|
6735
|
+
const ints = decompressIntegers32(
|
|
6736
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
6737
|
+
size
|
|
6738
|
+
);
|
|
6739
|
+
const floats = type === TypeEnum.Double ? new Float64Array(checkedLength(size)) : new Float32Array(checkedLength(size));
|
|
6740
|
+
for (let i = 0; i < size; i++)
|
|
6741
|
+
floats[i] = type === TypeEnum.Half ? this._convertHalfInteger(ints[i]) : ints[i];
|
|
6742
|
+
return floats;
|
|
6743
|
+
} else if (code === FLOAT_COMPRESSION_LUT) {
|
|
6744
|
+
const lutSize = checkedCount(reader.readUint32());
|
|
6745
|
+
if (lutSize === 0) throw new Error("USDC: invalid float lookup table");
|
|
6746
|
+
const lut = type === TypeEnum.Double ? new Float64Array(checkedLength(lutSize)) : new Float32Array(checkedLength(lutSize));
|
|
6747
|
+
for (let i = 0; i < lutSize; i++)
|
|
6748
|
+
lut[i] = type === TypeEnum.Half ? this._readHalf() : type === TypeEnum.Double ? reader.readFloat64() : reader.readFloat32();
|
|
6749
|
+
const compressedSize = reader.readUint64();
|
|
6750
|
+
const compressed = reader.readBytes(compressedSize);
|
|
6751
|
+
const indices = decompressIntegers32(
|
|
6752
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
6753
|
+
size
|
|
6754
|
+
);
|
|
6755
|
+
const floats = type === TypeEnum.Double ? new Float64Array(checkedLength(size)) : new Float32Array(checkedLength(size));
|
|
6756
|
+
for (let i = 0; i < size; i++) {
|
|
6757
|
+
if (indices[i] < 0 || indices[i] >= lutSize)
|
|
6758
|
+
throw new Error("USDC: invalid float lookup index");
|
|
6759
|
+
floats[i] = lut[indices[i]];
|
|
6760
|
+
}
|
|
6761
|
+
return floats;
|
|
6762
|
+
}
|
|
6763
|
+
throw new Error(
|
|
6764
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unknown float compression code", code].join(" ")
|
|
6765
|
+
);
|
|
6766
|
+
}
|
|
6767
|
+
default:
|
|
6768
|
+
throw new Error(
|
|
6769
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unsupported compressed array type", type].join(" ")
|
|
6770
|
+
);
|
|
6771
|
+
}
|
|
6772
|
+
}
|
|
6773
|
+
/** Rounds integer-compressed half samples using IEEE ties-to-even semantics. */
|
|
6774
|
+
_convertHalfInteger(value) {
|
|
6775
|
+
const absoluteValue = Math.abs(value);
|
|
6776
|
+
if (absoluteValue <= 2048) return value;
|
|
6777
|
+
if (absoluteValue >= 65520) return Math.sign(value) * Infinity;
|
|
6778
|
+
const spacing = 2 ** (Math.floor(Math.log2(absoluteValue)) - 10);
|
|
6779
|
+
const scaledValue = absoluteValue / spacing;
|
|
6780
|
+
const lowerValue = Math.floor(scaledValue);
|
|
6781
|
+
const fractionValue = scaledValue - lowerValue;
|
|
6782
|
+
const roundedValue = fractionValue > 0.5 || fractionValue === 0.5 && lowerValue % 2 !== 0 ? lowerValue + 1 : lowerValue;
|
|
6783
|
+
return Math.sign(value) * roundedValue * spacing;
|
|
6784
|
+
}
|
|
6785
|
+
_readHalf() {
|
|
6786
|
+
return this._halfToFloat(this.reader.readUint16());
|
|
6787
|
+
}
|
|
6788
|
+
_halfToFloat(h) {
|
|
6789
|
+
const sign = (h & 32768) >> 15;
|
|
6790
|
+
const exp = (h & 31744) >> 10;
|
|
6791
|
+
const frac = h & 1023;
|
|
6792
|
+
if (exp === 0) {
|
|
6793
|
+
if (frac === 0) {
|
|
6794
|
+
return sign ? -0 : 0;
|
|
6795
|
+
}
|
|
6796
|
+
return (sign ? -1 : 1) * HALF_DENORM_SCALE * (frac / 1024);
|
|
6797
|
+
} else if (exp === 31) {
|
|
6798
|
+
return frac ? NaN : sign ? -Infinity : Infinity;
|
|
6799
|
+
}
|
|
6800
|
+
return (sign ? -1 : 1) * HALF_EXPONENT_TABLE[exp] * (1 + frac / 1024);
|
|
6801
|
+
}
|
|
6802
|
+
_getFieldsForSpec(spec) {
|
|
6803
|
+
const fields = /* @__PURE__ */ Object.create(null);
|
|
6804
|
+
let fieldSetIndex = spec.fieldSetIndex;
|
|
6805
|
+
const maxIterations = 1e4;
|
|
6806
|
+
let iterations = 0;
|
|
6807
|
+
while (fieldSetIndex < this.fieldSets.length && iterations < maxIterations) {
|
|
6808
|
+
const fieldIndex = this.fieldSets[fieldSetIndex];
|
|
6809
|
+
if (fieldIndex === FIELD_SET_TERMINATOR || fieldIndex === -1) break;
|
|
6810
|
+
const field = this.fields[fieldIndex];
|
|
6811
|
+
if (!field) throw new Error("USDC: invalid field index");
|
|
6812
|
+
if (field) {
|
|
6813
|
+
const name22 = this.tokens[field.tokenIndex];
|
|
6814
|
+
const value = this._readValue(field.valueRep);
|
|
6815
|
+
fields[name22] = value;
|
|
6816
|
+
}
|
|
6817
|
+
fieldSetIndex++;
|
|
6818
|
+
iterations++;
|
|
6819
|
+
}
|
|
6820
|
+
if (iterations >= maxIterations) throw new Error("USDC: field traversal limit exceeded");
|
|
6821
|
+
return fields;
|
|
6822
|
+
}
|
|
6823
|
+
};
|
|
6824
|
+
}
|
|
6825
|
+
});
|
|
6826
|
+
|
|
6827
|
+
// ../scene/src/usd/lib/parse-usdc.ts
|
|
6828
|
+
function parseUSDC(data, url) {
|
|
6829
|
+
var _a, _b, _c;
|
|
6830
|
+
if (data.byteLength < 88 || data.byteLength > 64 * 1024 * 1024)
|
|
6831
|
+
throw new Error("USDC: invalid input size");
|
|
6832
|
+
const bytes = new Uint8Array(data);
|
|
6833
|
+
if (bytes[8] !== 0 || bytes[9] !== 8 || bytes[10] !== 0)
|
|
6834
|
+
throw new Error("USDC: initial decoder requires crate version 0.8.0");
|
|
6835
|
+
const reader = new DataView(data);
|
|
6836
|
+
const table = reader.getBigUint64(16, true);
|
|
6837
|
+
if (table > BigInt(data.byteLength - 8)) throw new Error("USDC: invalid section table");
|
|
6838
|
+
const offset = Number(table), count = reader.getBigUint64(offset, true);
|
|
6839
|
+
if (count > 16n || offset + 8 + Number(count) * 32 > data.byteLength)
|
|
6840
|
+
throw new Error("USDC: invalid section table length");
|
|
6841
|
+
const sectionNames = /* @__PURE__ */ new Set();
|
|
6842
|
+
for (let index = 0; index < Number(count); index++) {
|
|
6843
|
+
const entry = offset + 8 + index * 32;
|
|
6844
|
+
const nameBytes = bytes.subarray(entry, entry + 16);
|
|
6845
|
+
const terminator = nameBytes.indexOf(0);
|
|
6846
|
+
const name22 = new TextDecoder().decode(
|
|
6847
|
+
nameBytes.subarray(0, terminator < 0 ? nameBytes.length : terminator)
|
|
6848
|
+
);
|
|
6849
|
+
if (sectionNames.has(name22)) throw new Error("USDC: duplicate section");
|
|
6850
|
+
sectionNames.add(name22);
|
|
6851
|
+
const start = reader.getBigUint64(entry + 16, true), size = reader.getBigUint64(entry + 24, true);
|
|
6852
|
+
if (start < 88n || start + size > BigInt(data.byteLength))
|
|
6853
|
+
throw new Error("USDC: section out of bounds");
|
|
6854
|
+
}
|
|
6855
|
+
for (const name22 of ["TOKENS", "STRINGS", "FIELDS", "FIELDSETS", "PATHS", "SPECS"])
|
|
6856
|
+
if (!sectionNames.has(name22)) throw new Error("USDC: missing required section");
|
|
6857
|
+
const { specsByPath } = new USDCParser().parseData(data);
|
|
6858
|
+
const prims = /* @__PURE__ */ new Map();
|
|
6859
|
+
for (const [path, specification] of Object.entries(specsByPath)) {
|
|
6860
|
+
if (specification.specType === 7 && path === "/") continue;
|
|
6861
|
+
if (specification.specType === 1 || specification.specType === 8) continue;
|
|
6862
|
+
if (specification.specType !== 6 || !/^\/(?:[A-Za-z_][\w:]*\/)*[A-Za-z_][\w:]*$/.test(path))
|
|
6863
|
+
throw new Error("USDC: unsupported prim specification");
|
|
6864
|
+
const fields = specification.fields;
|
|
6865
|
+
const specifier = fields.specifier ?? 0;
|
|
6866
|
+
if (specifier !== 0 && specifier !== 1 && specifier !== 2)
|
|
6867
|
+
throw new Error("USDC: invalid prim specifier");
|
|
6868
|
+
const metadata3 = convertFields(
|
|
6869
|
+
fields,
|
|
6870
|
+
/* @__PURE__ */ new Set(["specifier", "typeName", "primChildren", "properties"])
|
|
6871
|
+
);
|
|
6872
|
+
prims.set(path, {
|
|
6873
|
+
name: path.slice(path.lastIndexOf("/") + 1),
|
|
6874
|
+
path,
|
|
6875
|
+
sourceUrl: url,
|
|
6876
|
+
type: String(fields.typeName || ""),
|
|
6877
|
+
specifier: ["def", "over", "class"][specifier],
|
|
6878
|
+
attributes: /* @__PURE__ */ Object.create(null),
|
|
6879
|
+
metadata: metadata3,
|
|
6880
|
+
variants: /* @__PURE__ */ Object.create(null),
|
|
6881
|
+
children: []
|
|
6882
|
+
});
|
|
6883
|
+
}
|
|
6884
|
+
const roots = [];
|
|
6885
|
+
for (const prim of prims.values()) {
|
|
6886
|
+
const parentPath = prim.path.slice(0, prim.path.lastIndexOf("/"));
|
|
6887
|
+
if (!parentPath) roots.push(prim);
|
|
6888
|
+
else {
|
|
6889
|
+
const parent = prims.get(parentPath);
|
|
6890
|
+
if (!parent) throw new Error("USDC: missing parent prim");
|
|
6891
|
+
parent.children.push(prim);
|
|
6892
|
+
}
|
|
6893
|
+
}
|
|
6894
|
+
orderPrims(roots, (_a = specsByPath["/"]) == null ? void 0 : _a.fields.primChildren);
|
|
6895
|
+
for (const prim of prims.values())
|
|
6896
|
+
orderPrims(prim.children, (_b = specsByPath[prim.path]) == null ? void 0 : _b.fields.primChildren);
|
|
6897
|
+
for (const [path, specification] of Object.entries(specsByPath)) {
|
|
6898
|
+
if (specification.specType !== 1 && specification.specType !== 8) continue;
|
|
6899
|
+
const separator = path.indexOf(".");
|
|
6900
|
+
const prim = prims.get(path.slice(0, separator));
|
|
6901
|
+
if (separator < 0 || !prim) throw new Error("USDC: property has no owning prim");
|
|
6902
|
+
const name22 = path.slice(separator + 1), fields = specification.fields;
|
|
6903
|
+
const type = specification.specType === 8 ? "rel" : String(fields.typeName || "");
|
|
6904
|
+
const value = convertAttributeValue(
|
|
6905
|
+
specification.specType === 8 ? fields.targetPaths : fields.default,
|
|
6906
|
+
type
|
|
6907
|
+
);
|
|
6908
|
+
const metadata3 = convertFields(
|
|
6909
|
+
fields,
|
|
6910
|
+
/* @__PURE__ */ new Set(["typeName", "default", "targetPaths", "timeSamples"])
|
|
6911
|
+
);
|
|
6912
|
+
if (fields.timeSamples !== void 0)
|
|
6913
|
+
metadata3.timeSamples = convertTimeSamples(fields.timeSamples, type);
|
|
6914
|
+
prim.attributes[name22] = {
|
|
6915
|
+
name: name22,
|
|
6916
|
+
type,
|
|
6917
|
+
value,
|
|
6918
|
+
metadata: metadata3
|
|
6919
|
+
};
|
|
6920
|
+
}
|
|
6921
|
+
return {
|
|
6922
|
+
format: "usdc",
|
|
6923
|
+
url,
|
|
6924
|
+
metadata: convertFields(((_c = specsByPath["/"]) == null ? void 0 : _c.fields) || {}, /* @__PURE__ */ new Set(["primChildren"])),
|
|
6925
|
+
rootPrims: roots,
|
|
6926
|
+
layers: []
|
|
6927
|
+
};
|
|
6928
|
+
}
|
|
6929
|
+
function convertFields(fields, excluded) {
|
|
6930
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
6931
|
+
for (const [name22, value] of Object.entries(fields))
|
|
6932
|
+
if (!excluded.has(name22)) result[name22] = convertValue(value);
|
|
6933
|
+
return result;
|
|
6934
|
+
}
|
|
6935
|
+
function convertValue(value) {
|
|
6936
|
+
if (value === void 0 || value === null) return null;
|
|
6937
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean")
|
|
6938
|
+
return value;
|
|
6939
|
+
if (Array.isArray(value)) return value.map(convertValue);
|
|
6940
|
+
if (ArrayBuffer.isView(value) && !(value instanceof DataView))
|
|
6941
|
+
return Array.from(value);
|
|
6942
|
+
if (typeof value === "object") return convertFields(value, /* @__PURE__ */ new Set());
|
|
6943
|
+
throw new Error("USDC: unsupported decoded value");
|
|
6944
|
+
}
|
|
6945
|
+
function convertAttributeValue(raw, type) {
|
|
6946
|
+
const value = convertValue(raw);
|
|
6947
|
+
if (type === "asset" && typeof value === "string") return { assetPath: value };
|
|
6948
|
+
if (type === "rel" && Array.isArray(value))
|
|
6949
|
+
return value.map((path) => typeof path === "string" ? { path } : path);
|
|
6950
|
+
const tuple = /^(?:(?:point|normal|vector|color|texCoord)([234])[fdh]|(?:float|double|half|int)([234]))\[\]$/.exec(
|
|
6951
|
+
type
|
|
6952
|
+
);
|
|
6953
|
+
if (tuple && Array.isArray(value)) {
|
|
6954
|
+
const components = Number(tuple[1] || tuple[2]);
|
|
6955
|
+
if (value.length % components) throw new Error("USDC: incomplete vector tuple");
|
|
6956
|
+
const tuples = [];
|
|
6957
|
+
for (let offset = 0; offset < value.length; offset += components)
|
|
6958
|
+
tuples.push(value.slice(offset, offset + components));
|
|
6959
|
+
return tuples;
|
|
6960
|
+
}
|
|
6961
|
+
return value;
|
|
6962
|
+
}
|
|
6963
|
+
function orderPrims(prims, names) {
|
|
6964
|
+
if (names === void 0) return;
|
|
6965
|
+
if (!Array.isArray(names)) throw new Error("USDC: invalid primChildren order");
|
|
6966
|
+
const remaining = new Map(prims.map((prim) => [prim.name, prim]));
|
|
6967
|
+
const ordered = [];
|
|
6968
|
+
for (const name22 of names) {
|
|
6969
|
+
const prim = typeof name22 === "string" ? remaining.get(name22) : void 0;
|
|
6970
|
+
if (!prim) throw new Error("USDC: invalid primChildren reference");
|
|
6971
|
+
ordered.push(prim);
|
|
6972
|
+
remaining.delete(name22);
|
|
6973
|
+
}
|
|
6974
|
+
for (const prim of remaining.values()) ordered.push(prim);
|
|
6975
|
+
for (let index = 0; index < ordered.length; index++) prims[index] = ordered[index];
|
|
6976
|
+
}
|
|
6977
|
+
function convertTimeSamples(raw, type) {
|
|
6978
|
+
if (!raw || typeof raw !== "object") throw new Error("USDC: invalid time samples");
|
|
6979
|
+
const samples = raw;
|
|
6980
|
+
const times = convertValue(samples.times);
|
|
6981
|
+
if (!Array.isArray(times) || !Array.isArray(samples.values) || times.length !== samples.values.length)
|
|
6982
|
+
throw new Error("USDC: invalid time samples");
|
|
6983
|
+
return { times, values: samples.values.map((value) => convertAttributeValue(value, type)) };
|
|
6984
|
+
}
|
|
6985
|
+
var init_parse_usdc = __esm({
|
|
6986
|
+
"../scene/src/usd/lib/parse-usdc.ts"() {
|
|
6987
|
+
"use strict";
|
|
6988
|
+
init_usdc_parser();
|
|
6989
|
+
}
|
|
6990
|
+
});
|
|
6991
|
+
|
|
5487
6992
|
// ../scene/src/usd/lib/parse-usda.ts
|
|
5488
6993
|
function parseUSDA(source, url) {
|
|
5489
6994
|
if (!source.trimStart().startsWith("#usda")) {
|
|
@@ -5518,7 +7023,7 @@ var init_parse_usda = __esm({
|
|
|
5518
7023
|
}
|
|
5519
7024
|
/** Parses the complete USDA layer. */
|
|
5520
7025
|
parse() {
|
|
5521
|
-
const
|
|
7026
|
+
const metadata3 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
|
|
5522
7027
|
const rootPrims = [];
|
|
5523
7028
|
while (!this.tokenizer.isAtEnd()) {
|
|
5524
7029
|
if (this.isPrimDeclaration()) {
|
|
@@ -5530,7 +7035,7 @@ var init_parse_usda = __esm({
|
|
|
5530
7035
|
return {
|
|
5531
7036
|
format: "usda",
|
|
5532
7037
|
url: this.url,
|
|
5533
|
-
metadata:
|
|
7038
|
+
metadata: metadata3,
|
|
5534
7039
|
rootPrims,
|
|
5535
7040
|
layers: this.url ? [this.url] : []
|
|
5536
7041
|
};
|
|
@@ -5544,7 +7049,7 @@ var init_parse_usda = __esm({
|
|
|
5544
7049
|
const type = hasExplicitType ? firstToken.value : "";
|
|
5545
7050
|
const name22 = hasExplicitType ? this.tokenizer.read().value : firstToken.value;
|
|
5546
7051
|
const path = `${parentPath}/${name22}`;
|
|
5547
|
-
const
|
|
7052
|
+
const metadata3 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
|
|
5548
7053
|
this.tokenizer.expect("{");
|
|
5549
7054
|
const contents = this.parsePrimContents(path);
|
|
5550
7055
|
return {
|
|
@@ -5554,7 +7059,7 @@ var init_parse_usda = __esm({
|
|
|
5554
7059
|
type,
|
|
5555
7060
|
specifier,
|
|
5556
7061
|
attributes: contents.attributes,
|
|
5557
|
-
metadata: { ...
|
|
7062
|
+
metadata: { ...metadata3, ...contents.metadata },
|
|
5558
7063
|
variants: contents.variants,
|
|
5559
7064
|
children: contents.children
|
|
5560
7065
|
};
|
|
@@ -5562,7 +7067,7 @@ var init_parse_usda = __esm({
|
|
|
5562
7067
|
/** Parses the attributes, variants, and child prims inside a prim body. */
|
|
5563
7068
|
parsePrimContents(parentPath) {
|
|
5564
7069
|
const attributes = {};
|
|
5565
|
-
const
|
|
7070
|
+
const metadata3 = {};
|
|
5566
7071
|
const children = [];
|
|
5567
7072
|
const variants = {};
|
|
5568
7073
|
while (!this.tokenizer.isAtEnd() && !this.tokenizer.match("}")) {
|
|
@@ -5577,7 +7082,7 @@ var init_parse_usda = __esm({
|
|
|
5577
7082
|
}
|
|
5578
7083
|
}
|
|
5579
7084
|
}
|
|
5580
|
-
return { attributes, metadata:
|
|
7085
|
+
return { attributes, metadata: metadata3, children, variants };
|
|
5581
7086
|
}
|
|
5582
7087
|
/** Parses one named variant set. */
|
|
5583
7088
|
parseVariantSet(parentPath, variants) {
|
|
@@ -5627,12 +7132,12 @@ var init_parse_usda = __esm({
|
|
|
5627
7132
|
const name22 = significantTokens[significantTokens.length - 1].value;
|
|
5628
7133
|
const type = significantTokens.slice(0, -1).map((token) => token.value).join("");
|
|
5629
7134
|
const value = this.parseValue();
|
|
5630
|
-
const
|
|
5631
|
-
return { name: name22, type, value, metadata:
|
|
7135
|
+
const metadata3 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
|
|
7136
|
+
return { name: name22, type, value, metadata: metadata3 };
|
|
5632
7137
|
}
|
|
5633
7138
|
/** Parses a metadata dictionary through the requested terminator. */
|
|
5634
7139
|
parseMetadata(terminator) {
|
|
5635
|
-
const
|
|
7140
|
+
const metadata3 = {};
|
|
5636
7141
|
while (!this.tokenizer.isAtEnd() && !this.tokenizer.match(terminator)) {
|
|
5637
7142
|
this.tokenizer.match(",");
|
|
5638
7143
|
if (this.tokenizer.peek().value === terminator) {
|
|
@@ -5655,10 +7160,10 @@ var init_parse_usda = __esm({
|
|
|
5655
7160
|
continue;
|
|
5656
7161
|
}
|
|
5657
7162
|
const name22 = declarationTokens[declarationTokens.length - 1].value;
|
|
5658
|
-
|
|
7163
|
+
metadata3[name22] = this.parseValue();
|
|
5659
7164
|
this.tokenizer.match(",");
|
|
5660
7165
|
}
|
|
5661
|
-
return
|
|
7166
|
+
return metadata3;
|
|
5662
7167
|
}
|
|
5663
7168
|
/** Parses one scalar, list, tuple, dictionary, asset path, or scene path value. */
|
|
5664
7169
|
parseValue() {
|
|
@@ -5874,30 +7379,52 @@ function parseUSDZArchive(arrayBuffer) {
|
|
|
5874
7379
|
const directoryOffset = findCentralDirectory(view);
|
|
5875
7380
|
const entryCount = view.getUint16(directoryOffset + 10, true);
|
|
5876
7381
|
let entryOffset = view.getUint32(directoryOffset + 16, true);
|
|
7382
|
+
const dataLimit = entryOffset;
|
|
5877
7383
|
const files = /* @__PURE__ */ new Map();
|
|
5878
|
-
const
|
|
7384
|
+
const textDecoder2 = new TextDecoder();
|
|
7385
|
+
let extractedByteLength = 0;
|
|
5879
7386
|
for (let entryIndex = 0; entryIndex < entryCount; entryIndex++) {
|
|
7387
|
+
if (entryOffset + 46 > directoryOffset) {
|
|
7388
|
+
throw new Error("USDZ archive contains a truncated ZIP central-directory entry.");
|
|
7389
|
+
}
|
|
5880
7390
|
if (view.getUint32(entryOffset, true) !== CENTRAL_DIRECTORY_ENTRY) {
|
|
5881
7391
|
throw new Error("USDZ archive contains an invalid ZIP central-directory entry.");
|
|
5882
7392
|
}
|
|
5883
7393
|
const compression = view.getUint16(entryOffset + 10, true);
|
|
5884
7394
|
const compressedLength = view.getUint32(entryOffset + 20, true);
|
|
7395
|
+
const uncompressedLength = view.getUint32(entryOffset + 24, true);
|
|
5885
7396
|
const filenameLength = view.getUint16(entryOffset + 28, true);
|
|
5886
7397
|
const extraLength = view.getUint16(entryOffset + 30, true);
|
|
5887
7398
|
const commentLength = view.getUint16(entryOffset + 32, true);
|
|
5888
7399
|
const localOffset = view.getUint32(entryOffset + 42, true);
|
|
5889
|
-
|
|
7400
|
+
if (entryOffset + 46 + filenameLength + extraLength + commentLength > directoryOffset) {
|
|
7401
|
+
throw new Error("USDZ archive contains a truncated ZIP filename or extra field.");
|
|
7402
|
+
}
|
|
7403
|
+
const filename2 = textDecoder2.decode(
|
|
5890
7404
|
new Uint8Array(arrayBuffer, entryOffset + 46, filenameLength)
|
|
5891
7405
|
);
|
|
5892
7406
|
if (compression !== 0) {
|
|
5893
7407
|
throw new Error(`USDZ entry "${filename2}" is compressed; USDZ requires stored ZIP entries.`);
|
|
5894
7408
|
}
|
|
7409
|
+
if (localOffset + 30 > dataLimit || compressedLength !== uncompressedLength) {
|
|
7410
|
+
throw new Error(`USDZ entry "${filename2}" has invalid stored ZIP bounds.`);
|
|
7411
|
+
}
|
|
5895
7412
|
if (view.getUint32(localOffset, true) !== LOCAL_FILE_HEADER) {
|
|
5896
7413
|
throw new Error(`USDZ entry "${filename2}" has an invalid local ZIP header.`);
|
|
5897
7414
|
}
|
|
5898
7415
|
const localNameLength = view.getUint16(localOffset + 26, true);
|
|
5899
7416
|
const localExtraLength = view.getUint16(localOffset + 28, true);
|
|
5900
7417
|
const contentOffset = localOffset + 30 + localNameLength + localExtraLength;
|
|
7418
|
+
if ((view.getUint16(entryOffset + 8, true) | view.getUint16(localOffset + 6, true)) & 1) {
|
|
7419
|
+
throw new Error(`USDZ entry "${filename2}" is encrypted.`);
|
|
7420
|
+
}
|
|
7421
|
+
if (contentOffset + compressedLength > dataLimit || view.getUint16(localOffset + 8, true) !== 0 || textDecoder2.decode(new Uint8Array(arrayBuffer, localOffset + 30, localNameLength)) !== filename2 || files.has(filename2)) {
|
|
7422
|
+
throw new Error(`USDZ entry "${filename2}" has invalid or duplicate stored ZIP data.`);
|
|
7423
|
+
}
|
|
7424
|
+
extractedByteLength += compressedLength;
|
|
7425
|
+
if (extractedByteLength > arrayBuffer.byteLength) {
|
|
7426
|
+
throw new Error("USDZ archive exceeds its stored data budget.");
|
|
7427
|
+
}
|
|
5901
7428
|
files.set(filename2, arrayBuffer.slice(contentOffset, contentOffset + compressedLength));
|
|
5902
7429
|
entryOffset += 46 + filenameLength + extraLength + commentLength;
|
|
5903
7430
|
}
|
|
@@ -5948,21 +7475,32 @@ async function parseUSD(data, options = {}, context) {
|
|
|
5948
7475
|
let stage;
|
|
5949
7476
|
if (isZIPArchive(data)) {
|
|
5950
7477
|
const archive = parseUSDZArchive(data);
|
|
5951
|
-
const rootFilename =
|
|
5952
|
-
if (!rootFilename) {
|
|
5953
|
-
throw new Error("USDZ
|
|
7478
|
+
const rootFilename = archive.keys().next().value;
|
|
7479
|
+
if (!rootFilename || !/\.(?:usd[ac]?)$/i.test(rootFilename)) {
|
|
7480
|
+
throw new Error("USDZ archive has no supported USD root layer.");
|
|
5954
7481
|
}
|
|
5955
7482
|
const archiveBase = "https://usd.archive/";
|
|
7483
|
+
const assets = /* @__PURE__ */ Object.create(null);
|
|
5956
7484
|
for (const [filename2, content] of archive) {
|
|
5957
|
-
|
|
7485
|
+
const assetUrl = new URL(filename2, archiveBase);
|
|
7486
|
+
if (filename2.startsWith("/") || /^[a-z][a-z\d+.-]*:/i.test(filename2) || filename2.includes("\\") || /[\u0000-\u001f\u007f]/.test(filename2) || filename2.trim() !== filename2 || filename2.split("/").some((segment) => {
|
|
7487
|
+
const normalizedSegment = segment.replace(/%2e/gi, ".");
|
|
7488
|
+
return normalizedSegment === "." || normalizedSegment === "..";
|
|
7489
|
+
}) || assetUrl.origin !== new URL(archiveBase).origin || assetUrl.search || assetUrl.hash || assets[assetUrl.href]) {
|
|
7490
|
+
throw new Error(`USDZ entry "${filename2}" has an ambiguous package URL.`);
|
|
7491
|
+
}
|
|
7492
|
+
environment.archiveFiles.set(assetUrl.href, content);
|
|
7493
|
+
assets[assetUrl.href] = createEmbeddedAsset(filename2, content);
|
|
5958
7494
|
}
|
|
5959
7495
|
const rootUrl = new URL(rootFilename, archiveBase).href;
|
|
5960
7496
|
stage = parseUSDLayer(archive.get(rootFilename), rootUrl);
|
|
5961
7497
|
stage.format = "usdz";
|
|
7498
|
+
stage.assets = assets;
|
|
5962
7499
|
} else {
|
|
5963
7500
|
stage = parseUSDLayer(data, url);
|
|
5964
7501
|
}
|
|
5965
7502
|
if (stage.url) {
|
|
7503
|
+
setAttributeSourceUrls(stage, stage.url);
|
|
5966
7504
|
environment.layers.add(stage.url);
|
|
5967
7505
|
}
|
|
5968
7506
|
if (((_b = environment.options.usd) == null ? void 0 : _b.compose) !== false) {
|
|
@@ -5974,6 +7512,11 @@ async function parseUSD(data, options = {}, context) {
|
|
|
5974
7512
|
}
|
|
5975
7513
|
return stage;
|
|
5976
7514
|
}
|
|
7515
|
+
function createEmbeddedAsset(path, data) {
|
|
7516
|
+
const extension = path.slice(path.lastIndexOf(".") + 1).toLowerCase();
|
|
7517
|
+
const mimeType = extension === "png" ? "image/png" : /^(?:jpe?g)$/.test(extension) ? "image/jpeg" : void 0;
|
|
7518
|
+
return mimeType ? { path, data, mimeType } : { path, data };
|
|
7519
|
+
}
|
|
5977
7520
|
function getSourceLocation(configuredLocation, contextLocation) {
|
|
5978
7521
|
const configuredUrl = getAbsoluteUrl(configuredLocation);
|
|
5979
7522
|
if (configuredUrl) {
|
|
@@ -6000,10 +7543,29 @@ function resolveAssetPath(assetPath, sourceLocation) {
|
|
|
6000
7543
|
function parseUSDLayer(data, url) {
|
|
6001
7544
|
const signature = TEXT_DECODER.decode(data.slice(0, 8));
|
|
6002
7545
|
if (signature === CRATE_SIGNATURE) {
|
|
6003
|
-
|
|
7546
|
+
return parseUSDC(data, url);
|
|
6004
7547
|
}
|
|
6005
7548
|
return parseUSDA(TEXT_DECODER.decode(data), url);
|
|
6006
7549
|
}
|
|
7550
|
+
function setAttributeSourceUrls(stage, sourceUrl) {
|
|
7551
|
+
const pendingContents = [...stage.rootPrims];
|
|
7552
|
+
while (pendingContents.length) {
|
|
7553
|
+
const contents = pendingContents.pop();
|
|
7554
|
+
for (const attribute of Object.values(contents.attributes)) {
|
|
7555
|
+
attribute.sourceUrl = sourceUrl;
|
|
7556
|
+
}
|
|
7557
|
+
for (const child of contents.children) {
|
|
7558
|
+
pendingContents.push(child);
|
|
7559
|
+
}
|
|
7560
|
+
if ("variants" in contents) {
|
|
7561
|
+
for (const variants of Object.values(contents.variants)) {
|
|
7562
|
+
for (const variant of Object.values(variants)) {
|
|
7563
|
+
pendingContents.push(variant);
|
|
7564
|
+
}
|
|
7565
|
+
}
|
|
7566
|
+
}
|
|
7567
|
+
}
|
|
7568
|
+
}
|
|
6007
7569
|
async function composePrims(prims, sourceUrl, inheritedVariants, environment, depth) {
|
|
6008
7570
|
var _a, _b, _c;
|
|
6009
7571
|
if (depth > (((_a = environment.options.usd) == null ? void 0 : _a.maxReferenceDepth) ?? 12)) {
|
|
@@ -6083,6 +7645,7 @@ async function loadReferencedStage(url, environment) {
|
|
|
6083
7645
|
content = response.arrayBuffer();
|
|
6084
7646
|
}
|
|
6085
7647
|
const stage = parseUSDLayer(await content, url);
|
|
7648
|
+
setAttributeSourceUrls(stage, url);
|
|
6086
7649
|
environment.layers.add(url);
|
|
6087
7650
|
return stage;
|
|
6088
7651
|
})();
|
|
@@ -6182,6 +7745,7 @@ var TEXT_DECODER, CRATE_SIGNATURE, ZIP_SIGNATURE, USD_LOADER_DEFAULT_OPTIONS;
|
|
|
6182
7745
|
var init_parse_usd = __esm({
|
|
6183
7746
|
"../scene/src/usd/lib/parse-usd.ts"() {
|
|
6184
7747
|
"use strict";
|
|
7748
|
+
init_parse_usdc();
|
|
6185
7749
|
init_parse_usda();
|
|
6186
7750
|
init_parse_usdz();
|
|
6187
7751
|
TEXT_DECODER = new TextDecoder();
|
|
@@ -6236,11 +7800,11 @@ var init_usd_loader_types = __esm({
|
|
|
6236
7800
|
id: "usd",
|
|
6237
7801
|
module: "scene",
|
|
6238
7802
|
version: VERSION4,
|
|
6239
|
-
extensions: ["usd", "usda", "usdz"],
|
|
6240
|
-
mimeTypes: ["model/vnd.usd", "model/vnd.usda", "model/vnd.usdz+zip"],
|
|
7803
|
+
extensions: ["usd", "usda", "usdc", "usdz"],
|
|
7804
|
+
mimeTypes: ["model/vnd.usd", "model/vnd.usda", "model/vnd.usdc", "model/vnd.usdz+zip"],
|
|
6241
7805
|
text: true,
|
|
6242
7806
|
binary: true,
|
|
6243
|
-
tests: ["#usda", "PK"],
|
|
7807
|
+
tests: ["#usda", "PXR-USDC", "PK"],
|
|
6244
7808
|
options: {
|
|
6245
7809
|
usd: {
|
|
6246
7810
|
compose: true,
|
|
@@ -6260,22 +7824,145 @@ var init_usd = __esm({
|
|
|
6260
7824
|
"use strict";
|
|
6261
7825
|
init_usd_loader_types();
|
|
6262
7826
|
}
|
|
6263
|
-
});
|
|
6264
|
-
|
|
6265
|
-
// ../scene/src/obj/obj-format.ts
|
|
6266
|
-
var OBJFormat;
|
|
6267
|
-
var init_obj_format = __esm({
|
|
6268
|
-
"../scene/src/obj/obj-format.ts"() {
|
|
7827
|
+
});
|
|
7828
|
+
|
|
7829
|
+
// ../scene/src/obj/obj-format.ts
|
|
7830
|
+
var OBJFormat;
|
|
7831
|
+
var init_obj_format = __esm({
|
|
7832
|
+
"../scene/src/obj/obj-format.ts"() {
|
|
7833
|
+
"use strict";
|
|
7834
|
+
OBJFormat = {
|
|
7835
|
+
name: "OBJ",
|
|
7836
|
+
id: "obj",
|
|
7837
|
+
module: "scene",
|
|
7838
|
+
encoding: "text",
|
|
7839
|
+
format: "obj",
|
|
7840
|
+
extensions: ["obj"],
|
|
7841
|
+
mimeTypes: ["text/plain"]
|
|
7842
|
+
};
|
|
7843
|
+
}
|
|
7844
|
+
});
|
|
7845
|
+
|
|
7846
|
+
// ../core/src/arrow-worker-transport.ts
|
|
7847
|
+
function serializeArrowWorkerTable(result) {
|
|
7848
|
+
if (!isArrowTableWrapper(result)) {
|
|
7849
|
+
throw new Error("Workers require Arrow table output");
|
|
7850
|
+
}
|
|
7851
|
+
const { data, ...metadata3 } = result;
|
|
7852
|
+
return {
|
|
7853
|
+
...structuredClone(metadata3),
|
|
7854
|
+
data: (0, import_arrow.dehydrateArrowTable)(data, { copy: "all" })
|
|
7855
|
+
};
|
|
7856
|
+
}
|
|
7857
|
+
function deserializeArrowWorkerTable(result) {
|
|
7858
|
+
if (!isDehydratedArrowTableWrapper(result)) {
|
|
7859
|
+
throw new Error("Workers require Arrow column transport");
|
|
7860
|
+
}
|
|
7861
|
+
return { ...result, data: (0, import_arrow.hydrateArrowTable)(result.data) };
|
|
7862
|
+
}
|
|
7863
|
+
function serializeArrowWorkerResult(result, options) {
|
|
7864
|
+
var _a;
|
|
7865
|
+
if (!isArrowTableWrapper(result)) {
|
|
7866
|
+
return result;
|
|
7867
|
+
}
|
|
7868
|
+
const workerOptions = options;
|
|
7869
|
+
const bufferCopyMode = ((_a = workerOptions == null ? void 0 : workerOptions.core) == null ? void 0 : _a.workerTransferBufferCopy) ?? (workerOptions == null ? void 0 : workerOptions.workerTransferBufferCopy);
|
|
7870
|
+
return {
|
|
7871
|
+
...result,
|
|
7872
|
+
data: (0, import_arrow.dehydrateArrowTable)(result.data, bufferCopyMode ? { copy: bufferCopyMode } : void 0)
|
|
7873
|
+
};
|
|
7874
|
+
}
|
|
7875
|
+
function deserializeArrowWorkerResult(result) {
|
|
7876
|
+
if (!isDehydratedArrowTableWrapper(result)) {
|
|
7877
|
+
return result;
|
|
7878
|
+
}
|
|
7879
|
+
return { ...result, data: (0, import_arrow.hydrateArrowTable)(result.data) };
|
|
7880
|
+
}
|
|
7881
|
+
function isArrowTableWrapper(value) {
|
|
7882
|
+
const table = value;
|
|
7883
|
+
return Boolean(
|
|
7884
|
+
table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
|
|
7885
|
+
);
|
|
7886
|
+
}
|
|
7887
|
+
function isDehydratedArrowTableWrapper(value) {
|
|
7888
|
+
const table = value;
|
|
7889
|
+
return Boolean(
|
|
7890
|
+
table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
|
|
7891
|
+
);
|
|
7892
|
+
}
|
|
7893
|
+
var import_arrow;
|
|
7894
|
+
var init_arrow_worker_transport = __esm({
|
|
7895
|
+
"../core/src/arrow-worker-transport.ts"() {
|
|
7896
|
+
"use strict";
|
|
7897
|
+
import_arrow = require("@math.gl/arrow");
|
|
7898
|
+
}
|
|
7899
|
+
});
|
|
7900
|
+
|
|
7901
|
+
// ../core/src/schema-utils/lib/schema/data-type.ts
|
|
7902
|
+
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
7903
|
+
if (value instanceof Date) {
|
|
7904
|
+
return "date-millisecond";
|
|
7905
|
+
}
|
|
7906
|
+
if (typeof value === "number") {
|
|
7907
|
+
return defaultNumberType;
|
|
7908
|
+
}
|
|
7909
|
+
if (typeof value === "boolean") {
|
|
7910
|
+
return "bool";
|
|
7911
|
+
}
|
|
7912
|
+
if (typeof value === "string") {
|
|
7913
|
+
return "utf8";
|
|
7914
|
+
}
|
|
7915
|
+
if (value === null || value === "undefined") {
|
|
7916
|
+
return "null";
|
|
7917
|
+
}
|
|
7918
|
+
return "null";
|
|
7919
|
+
}
|
|
7920
|
+
function getDataTypeFromArray(array) {
|
|
7921
|
+
let type = getDataTypeFromTypedArray(array);
|
|
7922
|
+
if (type !== "null") {
|
|
7923
|
+
return { type, nullable: false };
|
|
7924
|
+
}
|
|
7925
|
+
if (array.length > 0) {
|
|
7926
|
+
type = getDataTypeFromValue(array[0]);
|
|
7927
|
+
return { type, nullable: true };
|
|
7928
|
+
}
|
|
7929
|
+
return { type: "null", nullable: true };
|
|
7930
|
+
}
|
|
7931
|
+
function getDataTypeFromTypedArray(array) {
|
|
7932
|
+
if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
|
|
7933
|
+
return "float16";
|
|
7934
|
+
}
|
|
7935
|
+
switch (array.constructor) {
|
|
7936
|
+
case Int8Array:
|
|
7937
|
+
return "int8";
|
|
7938
|
+
case Uint8Array:
|
|
7939
|
+
case Uint8ClampedArray:
|
|
7940
|
+
return "uint8";
|
|
7941
|
+
case Int16Array:
|
|
7942
|
+
return "int16";
|
|
7943
|
+
case Uint16Array:
|
|
7944
|
+
return "uint16";
|
|
7945
|
+
case Int32Array:
|
|
7946
|
+
return "int32";
|
|
7947
|
+
case Uint32Array:
|
|
7948
|
+
return "uint32";
|
|
7949
|
+
case BigInt64Array:
|
|
7950
|
+
return "int64";
|
|
7951
|
+
case BigUint64Array:
|
|
7952
|
+
return "uint64";
|
|
7953
|
+
case Float32Array:
|
|
7954
|
+
return "float32";
|
|
7955
|
+
case Float64Array:
|
|
7956
|
+
return "float64";
|
|
7957
|
+
default:
|
|
7958
|
+
return "null";
|
|
7959
|
+
}
|
|
7960
|
+
}
|
|
7961
|
+
var import_core;
|
|
7962
|
+
var init_data_type = __esm({
|
|
7963
|
+
"../core/src/schema-utils/lib/schema/data-type.ts"() {
|
|
6269
7964
|
"use strict";
|
|
6270
|
-
|
|
6271
|
-
name: "OBJ",
|
|
6272
|
-
id: "obj",
|
|
6273
|
-
module: "scene",
|
|
6274
|
-
encoding: "text",
|
|
6275
|
-
format: "obj",
|
|
6276
|
-
extensions: ["obj"],
|
|
6277
|
-
mimeTypes: ["text/plain"]
|
|
6278
|
-
};
|
|
7965
|
+
import_core = require("@math.gl/core");
|
|
6279
7966
|
}
|
|
6280
7967
|
});
|
|
6281
7968
|
|
|
@@ -6289,17 +7976,11 @@ function serializeArrowSchema(arrowSchema) {
|
|
|
6289
7976
|
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
6290
7977
|
};
|
|
6291
7978
|
}
|
|
6292
|
-
function deserializeArrowSchema(schema, options) {
|
|
6293
|
-
return new arrow.Schema(
|
|
6294
|
-
schema.fields.map((field) => deserializeArrowField(field, options)),
|
|
6295
|
-
deserializeArrowMetadata(schema.metadata)
|
|
6296
|
-
);
|
|
6297
|
-
}
|
|
6298
7979
|
function serializeArrowMetadata(arrowMetadata) {
|
|
6299
7980
|
return Object.fromEntries(arrowMetadata);
|
|
6300
7981
|
}
|
|
6301
|
-
function deserializeArrowMetadata(
|
|
6302
|
-
return
|
|
7982
|
+
function deserializeArrowMetadata(metadata3) {
|
|
7983
|
+
return metadata3 ? new Map(Object.entries(metadata3)) : /* @__PURE__ */ new Map();
|
|
6303
7984
|
}
|
|
6304
7985
|
function serializeArrowField(field) {
|
|
6305
7986
|
return {
|
|
@@ -6718,281 +8399,6 @@ var init_convert_arrow_schema = __esm({
|
|
|
6718
8399
|
}
|
|
6719
8400
|
});
|
|
6720
8401
|
|
|
6721
|
-
// ../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts
|
|
6722
|
-
function splitArrowBuffers(input, options = {}) {
|
|
6723
|
-
const context = { ...options, copies: /* @__PURE__ */ new WeakMap() };
|
|
6724
|
-
if (isArrowTable(input)) {
|
|
6725
|
-
return splitArrowTableBuffersInternal(input, context);
|
|
6726
|
-
}
|
|
6727
|
-
if (isArrowRecordBatch(input)) {
|
|
6728
|
-
return splitArrowRecordBatchBuffers(input, context);
|
|
6729
|
-
}
|
|
6730
|
-
if (isArrowVector(input)) {
|
|
6731
|
-
return splitArrowVectorBuffers(input, context);
|
|
6732
|
-
}
|
|
6733
|
-
return splitArrowDataBuffers(input, context);
|
|
6734
|
-
}
|
|
6735
|
-
function isArrowTable(input) {
|
|
6736
|
-
return "batches" in input;
|
|
6737
|
-
}
|
|
6738
|
-
function isArrowRecordBatch(input) {
|
|
6739
|
-
return "schema" in input && "data" in input && !Array.isArray(input.data);
|
|
6740
|
-
}
|
|
6741
|
-
function isArrowVector(input) {
|
|
6742
|
-
return "data" in input && Array.isArray(input.data);
|
|
6743
|
-
}
|
|
6744
|
-
function splitArrowTableBuffersInternal(table, options) {
|
|
6745
|
-
const recordBatches = table.batches.map(
|
|
6746
|
-
(recordBatch) => splitArrowRecordBatchBuffers(recordBatch, options)
|
|
6747
|
-
);
|
|
6748
|
-
return new arrow2.Table(table.schema, recordBatches);
|
|
6749
|
-
}
|
|
6750
|
-
function splitArrowRecordBatchBuffers(recordBatch, options) {
|
|
6751
|
-
return new arrow2.RecordBatch(
|
|
6752
|
-
recordBatch.schema,
|
|
6753
|
-
splitArrowDataBuffers(recordBatch.data, options)
|
|
6754
|
-
);
|
|
6755
|
-
}
|
|
6756
|
-
function splitArrowDataBuffers(data, options) {
|
|
6757
|
-
const children = data.children.map((childData) => splitArrowDataBuffers(childData, options));
|
|
6758
|
-
const dictionary = data.dictionary ? splitArrowVectorBuffers(data.dictionary, options) : void 0;
|
|
6759
|
-
const buffers = {
|
|
6760
|
-
[arrow2.BufferType.OFFSET]: splitArrowBuffer(data.buffers[arrow2.BufferType.OFFSET], options),
|
|
6761
|
-
[arrow2.BufferType.DATA]: splitArrowBuffer(data.buffers[arrow2.BufferType.DATA], options),
|
|
6762
|
-
[arrow2.BufferType.VALIDITY]: splitArrowBuffer(data.buffers[arrow2.BufferType.VALIDITY], options),
|
|
6763
|
-
[arrow2.BufferType.TYPE]: splitArrowBuffer(data.buffers[arrow2.BufferType.TYPE], options)
|
|
6764
|
-
};
|
|
6765
|
-
return new arrow2.Data(
|
|
6766
|
-
data.type,
|
|
6767
|
-
data.offset,
|
|
6768
|
-
data.length,
|
|
6769
|
-
// @ts-expect-error _nullCount is protected. Reuse it to preserve lazy null-count state.
|
|
6770
|
-
data._nullCount,
|
|
6771
|
-
buffers,
|
|
6772
|
-
children,
|
|
6773
|
-
dictionary
|
|
6774
|
-
);
|
|
6775
|
-
}
|
|
6776
|
-
function splitArrowVectorBuffers(vector, options) {
|
|
6777
|
-
return new arrow2.Vector(vector.data.map((data) => splitArrowDataBuffers(data, options)));
|
|
6778
|
-
}
|
|
6779
|
-
function splitArrowBuffer(array, options) {
|
|
6780
|
-
if (!isArrowTypedArray(array)) {
|
|
6781
|
-
return array;
|
|
6782
|
-
}
|
|
6783
|
-
if (options.copy === "none") {
|
|
6784
|
-
return array;
|
|
6785
|
-
}
|
|
6786
|
-
if (options.copy !== "all" && array.byteOffset === 0 && array.byteLength === array.buffer.byteLength) {
|
|
6787
|
-
return array;
|
|
6788
|
-
}
|
|
6789
|
-
let copy = options.copies.get(array);
|
|
6790
|
-
if (!copy) {
|
|
6791
|
-
copy = array.slice();
|
|
6792
|
-
options.copies.set(array, copy);
|
|
6793
|
-
}
|
|
6794
|
-
return copy;
|
|
6795
|
-
}
|
|
6796
|
-
function isArrowTypedArray(value) {
|
|
6797
|
-
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
6798
|
-
}
|
|
6799
|
-
var arrow2;
|
|
6800
|
-
var init_split_arrow_buffers = __esm({
|
|
6801
|
-
"../core/src/schema-utils/lib/arrow/split-arrow-buffers.ts"() {
|
|
6802
|
-
"use strict";
|
|
6803
|
-
arrow2 = __toESM(require("apache-arrow"), 1);
|
|
6804
|
-
}
|
|
6805
|
-
});
|
|
6806
|
-
|
|
6807
|
-
// ../core/src/schema-utils/lib/arrow/arrow-table-transport.ts
|
|
6808
|
-
function dehydrateArrowTable(table, options) {
|
|
6809
|
-
const splitTable = splitArrowBuffers(table, options);
|
|
6810
|
-
return {
|
|
6811
|
-
shape: "arrow-table",
|
|
6812
|
-
transport: "arrow-js",
|
|
6813
|
-
schema: serializeArrowSchema(splitTable.schema),
|
|
6814
|
-
batches: splitTable.batches.map((recordBatch) => dehydrateArrowRecordBatch(recordBatch))
|
|
6815
|
-
};
|
|
6816
|
-
}
|
|
6817
|
-
function hydrateArrowTable(table) {
|
|
6818
|
-
const schema = deserializeArrowSchema(table.schema);
|
|
6819
|
-
const recordBatches = table.batches.map(
|
|
6820
|
-
(recordBatch) => new arrow3.RecordBatch(schema, hydrateArrowData(recordBatch.data))
|
|
6821
|
-
);
|
|
6822
|
-
return new arrow3.Table(schema, recordBatches);
|
|
6823
|
-
}
|
|
6824
|
-
function serializeArrowWorkerTable(result) {
|
|
6825
|
-
if (!isArrowTableWrapper(result)) {
|
|
6826
|
-
throw new Error("Workers require Arrow table output");
|
|
6827
|
-
}
|
|
6828
|
-
const { data, ...metadata2 } = result;
|
|
6829
|
-
return {
|
|
6830
|
-
...structuredClone(metadata2),
|
|
6831
|
-
data: dehydrateArrowTable(data, { copy: "all" })
|
|
6832
|
-
};
|
|
6833
|
-
}
|
|
6834
|
-
function deserializeArrowWorkerTable(result) {
|
|
6835
|
-
if (!isDehydratedArrowTableWrapper(result)) {
|
|
6836
|
-
throw new Error("Workers require Arrow column transport");
|
|
6837
|
-
}
|
|
6838
|
-
return { ...result, data: hydrateArrowTable(result.data) };
|
|
6839
|
-
}
|
|
6840
|
-
function serializeArrowWorkerResult(result, options) {
|
|
6841
|
-
var _a;
|
|
6842
|
-
if (!isArrowTableWrapper(result)) {
|
|
6843
|
-
return result;
|
|
6844
|
-
}
|
|
6845
|
-
const workerOptions = options;
|
|
6846
|
-
const bufferCopyMode = ((_a = workerOptions == null ? void 0 : workerOptions.core) == null ? void 0 : _a.workerTransferBufferCopy) ?? (workerOptions == null ? void 0 : workerOptions.workerTransferBufferCopy);
|
|
6847
|
-
return {
|
|
6848
|
-
...result,
|
|
6849
|
-
data: dehydrateArrowTable(result.data, bufferCopyMode ? { copy: bufferCopyMode } : void 0)
|
|
6850
|
-
};
|
|
6851
|
-
}
|
|
6852
|
-
function deserializeArrowWorkerResult(result) {
|
|
6853
|
-
if (!isDehydratedArrowTableWrapper(result)) {
|
|
6854
|
-
return result;
|
|
6855
|
-
}
|
|
6856
|
-
return { ...result, data: hydrateArrowTable(result.data) };
|
|
6857
|
-
}
|
|
6858
|
-
function isArrowTableWrapper(value) {
|
|
6859
|
-
const table = value;
|
|
6860
|
-
return Boolean(
|
|
6861
|
-
table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
|
|
6862
|
-
);
|
|
6863
|
-
}
|
|
6864
|
-
function isDehydratedArrowTableWrapper(value) {
|
|
6865
|
-
const table = value;
|
|
6866
|
-
return Boolean(
|
|
6867
|
-
table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
|
|
6868
|
-
);
|
|
6869
|
-
}
|
|
6870
|
-
function dehydrateArrowRecordBatch(recordBatch) {
|
|
6871
|
-
return { data: dehydrateArrowData(recordBatch.data) };
|
|
6872
|
-
}
|
|
6873
|
-
function dehydrateArrowData(data) {
|
|
6874
|
-
return {
|
|
6875
|
-
type: serializeArrowType(data.type),
|
|
6876
|
-
offset: data.offset,
|
|
6877
|
-
length: data.length,
|
|
6878
|
-
// @ts-expect-error _nullCount is protected. Preserve the Arrow lazy null-count state.
|
|
6879
|
-
nullCount: data._nullCount,
|
|
6880
|
-
buffers: {
|
|
6881
|
-
[arrow3.BufferType.OFFSET]: data.buffers[arrow3.BufferType.OFFSET],
|
|
6882
|
-
[arrow3.BufferType.DATA]: data.buffers[arrow3.BufferType.DATA],
|
|
6883
|
-
[arrow3.BufferType.VALIDITY]: data.buffers[arrow3.BufferType.VALIDITY],
|
|
6884
|
-
[arrow3.BufferType.TYPE]: data.buffers[arrow3.BufferType.TYPE]
|
|
6885
|
-
},
|
|
6886
|
-
children: data.children.map((childData) => dehydrateArrowData(childData)),
|
|
6887
|
-
dictionary: data.dictionary ? dehydrateArrowVector(data.dictionary) : void 0
|
|
6888
|
-
};
|
|
6889
|
-
}
|
|
6890
|
-
function dehydrateArrowVector(vector) {
|
|
6891
|
-
return { data: vector.data.map((data) => dehydrateArrowData(data)) };
|
|
6892
|
-
}
|
|
6893
|
-
function hydrateArrowData(data) {
|
|
6894
|
-
const children = data.children.map((childData) => hydrateArrowData(childData));
|
|
6895
|
-
const dictionary = data.dictionary ? hydrateArrowVector(data.dictionary) : void 0;
|
|
6896
|
-
return new arrow3.Data(
|
|
6897
|
-
deserializeArrowType(data.type),
|
|
6898
|
-
data.offset,
|
|
6899
|
-
data.length,
|
|
6900
|
-
data.nullCount,
|
|
6901
|
-
data.buffers,
|
|
6902
|
-
children,
|
|
6903
|
-
dictionary
|
|
6904
|
-
);
|
|
6905
|
-
}
|
|
6906
|
-
function hydrateArrowVector(vector) {
|
|
6907
|
-
return new arrow3.Vector(vector.data.map((data) => hydrateArrowData(data)));
|
|
6908
|
-
}
|
|
6909
|
-
var arrow3;
|
|
6910
|
-
var init_arrow_table_transport = __esm({
|
|
6911
|
-
"../core/src/schema-utils/lib/arrow/arrow-table-transport.ts"() {
|
|
6912
|
-
"use strict";
|
|
6913
|
-
arrow3 = __toESM(require("apache-arrow"), 1);
|
|
6914
|
-
init_convert_arrow_schema();
|
|
6915
|
-
init_split_arrow_buffers();
|
|
6916
|
-
}
|
|
6917
|
-
});
|
|
6918
|
-
|
|
6919
|
-
// ../core/src/schema-utils/arrow-transport.ts
|
|
6920
|
-
var init_arrow_transport = __esm({
|
|
6921
|
-
"../core/src/schema-utils/arrow-transport.ts"() {
|
|
6922
|
-
"use strict";
|
|
6923
|
-
init_arrow_table_transport();
|
|
6924
|
-
init_split_arrow_buffers();
|
|
6925
|
-
}
|
|
6926
|
-
});
|
|
6927
|
-
|
|
6928
|
-
// ../core/src/schema-utils/lib/schema/data-type.ts
|
|
6929
|
-
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
6930
|
-
if (value instanceof Date) {
|
|
6931
|
-
return "date-millisecond";
|
|
6932
|
-
}
|
|
6933
|
-
if (typeof value === "number") {
|
|
6934
|
-
return defaultNumberType;
|
|
6935
|
-
}
|
|
6936
|
-
if (typeof value === "boolean") {
|
|
6937
|
-
return "bool";
|
|
6938
|
-
}
|
|
6939
|
-
if (typeof value === "string") {
|
|
6940
|
-
return "utf8";
|
|
6941
|
-
}
|
|
6942
|
-
if (value === null || value === "undefined") {
|
|
6943
|
-
return "null";
|
|
6944
|
-
}
|
|
6945
|
-
return "null";
|
|
6946
|
-
}
|
|
6947
|
-
function getDataTypeFromArray(array) {
|
|
6948
|
-
let type = getDataTypeFromTypedArray(array);
|
|
6949
|
-
if (type !== "null") {
|
|
6950
|
-
return { type, nullable: false };
|
|
6951
|
-
}
|
|
6952
|
-
if (array.length > 0) {
|
|
6953
|
-
type = getDataTypeFromValue(array[0]);
|
|
6954
|
-
return { type, nullable: true };
|
|
6955
|
-
}
|
|
6956
|
-
return { type: "null", nullable: true };
|
|
6957
|
-
}
|
|
6958
|
-
function getDataTypeFromTypedArray(array) {
|
|
6959
|
-
if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
|
|
6960
|
-
return "float16";
|
|
6961
|
-
}
|
|
6962
|
-
switch (array.constructor) {
|
|
6963
|
-
case Int8Array:
|
|
6964
|
-
return "int8";
|
|
6965
|
-
case Uint8Array:
|
|
6966
|
-
case Uint8ClampedArray:
|
|
6967
|
-
return "uint8";
|
|
6968
|
-
case Int16Array:
|
|
6969
|
-
return "int16";
|
|
6970
|
-
case Uint16Array:
|
|
6971
|
-
return "uint16";
|
|
6972
|
-
case Int32Array:
|
|
6973
|
-
return "int32";
|
|
6974
|
-
case Uint32Array:
|
|
6975
|
-
return "uint32";
|
|
6976
|
-
case BigInt64Array:
|
|
6977
|
-
return "int64";
|
|
6978
|
-
case BigUint64Array:
|
|
6979
|
-
return "uint64";
|
|
6980
|
-
case Float32Array:
|
|
6981
|
-
return "float32";
|
|
6982
|
-
case Float64Array:
|
|
6983
|
-
return "float64";
|
|
6984
|
-
default:
|
|
6985
|
-
return "null";
|
|
6986
|
-
}
|
|
6987
|
-
}
|
|
6988
|
-
var import_core;
|
|
6989
|
-
var init_data_type = __esm({
|
|
6990
|
-
"../core/src/schema-utils/lib/schema/data-type.ts"() {
|
|
6991
|
-
"use strict";
|
|
6992
|
-
import_core = require("@math.gl/core");
|
|
6993
|
-
}
|
|
6994
|
-
});
|
|
6995
|
-
|
|
6996
8402
|
// ../core/src/schema-utils/lib/mesh/mesh-utils.ts
|
|
6997
8403
|
function getMeshBoundingBox(attributes) {
|
|
6998
8404
|
const positionAttribute = attributes == null ? void 0 : attributes.POSITION;
|
|
@@ -7107,23 +8513,23 @@ var init_float16 = __esm({
|
|
|
7107
8513
|
});
|
|
7108
8514
|
|
|
7109
8515
|
// ../core/src/schema/categories/category-mesh.ts
|
|
7110
|
-
var
|
|
8516
|
+
var arrow2, meshArrowSchema, indexedMeshArrowSchema;
|
|
7111
8517
|
var init_category_mesh = __esm({
|
|
7112
8518
|
"../core/src/schema/categories/category-mesh.ts"() {
|
|
7113
8519
|
"use strict";
|
|
7114
|
-
|
|
7115
|
-
meshArrowSchema = new
|
|
7116
|
-
new
|
|
8520
|
+
arrow2 = __toESM(require("apache-arrow"), 1);
|
|
8521
|
+
meshArrowSchema = new arrow2.Schema([
|
|
8522
|
+
new arrow2.Field(
|
|
7117
8523
|
"POSITION",
|
|
7118
|
-
new
|
|
8524
|
+
new arrow2.FixedSizeList(3, new arrow2.Field("value", new arrow2.Float32(), false)),
|
|
7119
8525
|
false
|
|
7120
8526
|
)
|
|
7121
8527
|
]);
|
|
7122
|
-
indexedMeshArrowSchema = new
|
|
8528
|
+
indexedMeshArrowSchema = new arrow2.Schema([
|
|
7123
8529
|
...meshArrowSchema.fields,
|
|
7124
|
-
new
|
|
8530
|
+
new arrow2.Field(
|
|
7125
8531
|
"indices",
|
|
7126
|
-
new
|
|
8532
|
+
new arrow2.List(new arrow2.Field("item", new arrow2.Uint32(), false)),
|
|
7127
8533
|
true
|
|
7128
8534
|
)
|
|
7129
8535
|
]);
|
|
@@ -7141,11 +8547,11 @@ var init_schema = __esm({
|
|
|
7141
8547
|
|
|
7142
8548
|
// ../core/src/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.ts
|
|
7143
8549
|
function getFixedSizeListSize(vector) {
|
|
7144
|
-
return vector.type instanceof
|
|
8550
|
+
return vector.type instanceof arrow3.FixedSizeList ? vector.type.listSize : 1;
|
|
7145
8551
|
}
|
|
7146
8552
|
function getFixedSizeListVector(typedArray, stride, logicalType) {
|
|
7147
8553
|
const data = getFixedSizeListData(typedArray, stride, logicalType);
|
|
7148
|
-
return new
|
|
8554
|
+
return new arrow3.Vector([data]);
|
|
7149
8555
|
}
|
|
7150
8556
|
function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
7151
8557
|
const listType = getFixedSizeListType(typedArray, stride, logicalType);
|
|
@@ -7153,13 +8559,13 @@ function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
|
7153
8559
|
const storage = logicalType === "float16" && isNativeFloat16Array(typedArray) ? getFloat16Storage(typedArray) : typedArray;
|
|
7154
8560
|
const buffers = {
|
|
7155
8561
|
// valueOffsets: undefined,
|
|
7156
|
-
[
|
|
8562
|
+
[arrow3.BufferType.DATA]: storage
|
|
7157
8563
|
// values
|
|
7158
8564
|
// nullBitmap: undefined,
|
|
7159
8565
|
// typeIds: undefined
|
|
7160
8566
|
};
|
|
7161
|
-
const nestedData = new
|
|
7162
|
-
const data = new
|
|
8567
|
+
const nestedData = new arrow3.Data(nestedType, 0, storage.length, 0, buffers);
|
|
8568
|
+
const data = new arrow3.Data(
|
|
7163
8569
|
listType,
|
|
7164
8570
|
0,
|
|
7165
8571
|
storage.length / stride,
|
|
@@ -7172,15 +8578,15 @@ function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
|
7172
8578
|
function getFixedSizeListType(typedArray, stride, logicalType) {
|
|
7173
8579
|
const type = logicalType || getDataTypeFromArray(typedArray).type;
|
|
7174
8580
|
const arrowType = deserializeArrowType(type);
|
|
7175
|
-
const listType = new
|
|
8581
|
+
const listType = new arrow3.FixedSizeList(stride, new arrow3.Field("value", arrowType, false));
|
|
7176
8582
|
return listType;
|
|
7177
8583
|
}
|
|
7178
|
-
var
|
|
8584
|
+
var arrow3;
|
|
7179
8585
|
var init_arrow_fixed_size_list_utils = __esm({
|
|
7180
8586
|
"../core/src/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.ts"() {
|
|
7181
8587
|
"use strict";
|
|
7182
8588
|
init_schema();
|
|
7183
|
-
|
|
8589
|
+
arrow3 = __toESM(require("apache-arrow"), 1);
|
|
7184
8590
|
init_data_type();
|
|
7185
8591
|
init_convert_arrow_schema();
|
|
7186
8592
|
}
|
|
@@ -7240,8 +8646,8 @@ function makeMeshArrowTable(attributes, options = {}) {
|
|
|
7240
8646
|
fields.push(indicesField);
|
|
7241
8647
|
}
|
|
7242
8648
|
}
|
|
7243
|
-
const arrowSchema = new
|
|
7244
|
-
const table = ((_c = columns[attributeNames[0]]) == null ? void 0 : _c.length) === 0 ? new
|
|
8649
|
+
const arrowSchema = new arrow4.Schema(fields, getMeshArrowMetadata(options));
|
|
8650
|
+
const table = ((_c = columns[attributeNames[0]]) == null ? void 0 : _c.length) === 0 ? new arrow4.Table(arrowSchema) : new arrow4.Table(arrowSchema, columns);
|
|
7245
8651
|
const schema = serializeArrowSchema(table.schema);
|
|
7246
8652
|
return {
|
|
7247
8653
|
shape: "arrow-table",
|
|
@@ -7255,14 +8661,14 @@ function getAttributeArrowVector(value, size, componentType) {
|
|
|
7255
8661
|
if (componentType === "float16") {
|
|
7256
8662
|
const storage = isNativeFloat16Array(value) ? getFloat16Storage(value) : value;
|
|
7257
8663
|
if (size === 1) {
|
|
7258
|
-
const data = new
|
|
7259
|
-
[
|
|
8664
|
+
const data = new arrow4.Data(new arrow4.Float16(), 0, storage.length, 0, {
|
|
8665
|
+
[arrow4.BufferType.DATA]: storage
|
|
7260
8666
|
});
|
|
7261
|
-
return new
|
|
8667
|
+
return new arrow4.Vector([data]);
|
|
7262
8668
|
}
|
|
7263
8669
|
return getFixedSizeListVector(value, size, componentType);
|
|
7264
8670
|
}
|
|
7265
|
-
return size === 1 ?
|
|
8671
|
+
return size === 1 ? arrow4.makeVector(value) : getFixedSizeListVector(value, size);
|
|
7266
8672
|
}
|
|
7267
8673
|
function getOrderedAttributeNames(attributes) {
|
|
7268
8674
|
const attributeNames = Object.keys(attributes);
|
|
@@ -7285,36 +8691,36 @@ function getAttributeArrowField(schema, attributeName, column, componentType) {
|
|
|
7285
8691
|
if (!(suppliedField == null ? void 0 : suppliedField.metadata)) {
|
|
7286
8692
|
return canonicalField;
|
|
7287
8693
|
}
|
|
7288
|
-
const
|
|
8694
|
+
const metadata3 = new Map(canonicalField.metadata);
|
|
7289
8695
|
for (const [key, value] of Object.entries(suppliedField.metadata)) {
|
|
7290
|
-
|
|
8696
|
+
metadata3.set(key, value);
|
|
7291
8697
|
}
|
|
7292
|
-
return new
|
|
8698
|
+
return new arrow4.Field(
|
|
7293
8699
|
canonicalField.name,
|
|
7294
8700
|
canonicalField.type,
|
|
7295
8701
|
canonicalField.nullable,
|
|
7296
|
-
|
|
8702
|
+
metadata3
|
|
7297
8703
|
);
|
|
7298
8704
|
}
|
|
7299
8705
|
const field = schema == null ? void 0 : schema.fields.find((schemaField) => schemaField.name === attributeName);
|
|
7300
8706
|
if (componentType === "float16") {
|
|
7301
|
-
const
|
|
7302
|
-
|
|
7303
|
-
return new
|
|
8707
|
+
const metadata3 = new Map(Object.entries((field == null ? void 0 : field.metadata) || {}));
|
|
8708
|
+
metadata3.set("componentType", "float16");
|
|
8709
|
+
return new arrow4.Field(attributeName, column.type, false, metadata3);
|
|
7304
8710
|
}
|
|
7305
8711
|
if (field && field.type.toString() !== column.type.toString()) {
|
|
7306
8712
|
const deserializedField = deserializeArrowField(field);
|
|
7307
|
-
return new
|
|
8713
|
+
return new arrow4.Field(
|
|
7308
8714
|
attributeName,
|
|
7309
8715
|
column.type,
|
|
7310
8716
|
deserializedField.nullable,
|
|
7311
8717
|
deserializedField.metadata
|
|
7312
8718
|
);
|
|
7313
8719
|
}
|
|
7314
|
-
return field ? deserializeArrowField(field) : new
|
|
8720
|
+
return field ? deserializeArrowField(field) : new arrow4.Field(attributeName, column.type, false);
|
|
7315
8721
|
}
|
|
7316
8722
|
function isMeshPositionColumn(column) {
|
|
7317
|
-
return column.type instanceof
|
|
8723
|
+
return column.type instanceof arrow4.FixedSizeList && column.type.listSize === 3 && column.type.children[0].type instanceof arrow4.Float32;
|
|
7318
8724
|
}
|
|
7319
8725
|
function getIndicesVector(indices, vertexCount, type) {
|
|
7320
8726
|
const indicesType = type;
|
|
@@ -7327,47 +8733,47 @@ function getIndicesVector(indices, vertexCount, type) {
|
|
|
7327
8733
|
if (vertexCount > 0) {
|
|
7328
8734
|
nullBitmap[0] = 1;
|
|
7329
8735
|
}
|
|
7330
|
-
const valuesData = new
|
|
8736
|
+
const valuesData = new arrow4.Data(
|
|
7331
8737
|
indicesType.children[0].type,
|
|
7332
8738
|
0,
|
|
7333
8739
|
values.length,
|
|
7334
8740
|
0,
|
|
7335
|
-
{ [
|
|
8741
|
+
{ [arrow4.BufferType.DATA]: values }
|
|
7336
8742
|
);
|
|
7337
|
-
const indicesData = new
|
|
8743
|
+
const indicesData = new arrow4.Data(
|
|
7338
8744
|
indicesType,
|
|
7339
8745
|
0,
|
|
7340
8746
|
vertexCount,
|
|
7341
8747
|
Math.max(0, vertexCount - 1),
|
|
7342
8748
|
{
|
|
7343
|
-
[
|
|
7344
|
-
[
|
|
8749
|
+
[arrow4.BufferType.OFFSET]: valueOffsets,
|
|
8750
|
+
[arrow4.BufferType.VALIDITY]: nullBitmap
|
|
7345
8751
|
},
|
|
7346
8752
|
[valuesData]
|
|
7347
8753
|
);
|
|
7348
|
-
return new
|
|
8754
|
+
return new arrow4.Vector([indicesData]);
|
|
7349
8755
|
}
|
|
7350
8756
|
function getMeshArrowMetadata(options) {
|
|
7351
8757
|
var _a;
|
|
7352
|
-
const
|
|
8758
|
+
const metadata3 = { ...(_a = options.schema) == null ? void 0 : _a.metadata };
|
|
7353
8759
|
if (options.topology) {
|
|
7354
|
-
|
|
8760
|
+
metadata3.topology ||= options.topology;
|
|
7355
8761
|
}
|
|
7356
8762
|
if (Number.isFinite(options.mode)) {
|
|
7357
|
-
|
|
8763
|
+
metadata3.mode ||= String(options.mode);
|
|
7358
8764
|
}
|
|
7359
8765
|
if (options.boundingBox) {
|
|
7360
|
-
|
|
8766
|
+
metadata3.boundingBox ||= JSON.stringify(options.boundingBox);
|
|
7361
8767
|
}
|
|
7362
|
-
return deserializeArrowMetadata(
|
|
8768
|
+
return deserializeArrowMetadata(metadata3);
|
|
7363
8769
|
}
|
|
7364
|
-
var
|
|
8770
|
+
var arrow4, MESH_ARROW_ATTRIBUTE_ORDER;
|
|
7365
8771
|
var init_convert_mesh_to_table = __esm({
|
|
7366
8772
|
"../core/src/schema-utils/lib/mesh/convert-mesh-to-table.ts"() {
|
|
7367
8773
|
"use strict";
|
|
7368
8774
|
init_schema();
|
|
7369
8775
|
init_schema();
|
|
7370
|
-
|
|
8776
|
+
arrow4 = __toESM(require("apache-arrow"), 1);
|
|
7371
8777
|
init_arrow_fixed_size_list_utils();
|
|
7372
8778
|
init_convert_arrow_schema();
|
|
7373
8779
|
MESH_ARROW_ATTRIBUTE_ORDER = ["POSITION"];
|
|
@@ -7400,15 +8806,15 @@ function convertArrowTableToMesh(table) {
|
|
|
7400
8806
|
const attributeData = arrowTable.getChild(name22);
|
|
7401
8807
|
const size = getFixedSizeListSize(attributeData);
|
|
7402
8808
|
const typedArray = getAttributeTypedArray(attributeData, size);
|
|
7403
|
-
const
|
|
7404
|
-
const value =
|
|
8809
|
+
const metadata3 = getMeshAttributeMetadata(field.metadata);
|
|
8810
|
+
const value = metadata3.componentType === "float16" ? restoreFloat16Array(typedArray) : typedArray;
|
|
7405
8811
|
const shared = columns.find(
|
|
7406
8812
|
(column) => column.data.length === attributeData.data.length && attributes[column.name].value.constructor === value.constructor && column.data.every((chunk, index) => shareArrowStorage(chunk, attributeData.data[index]))
|
|
7407
8813
|
);
|
|
7408
8814
|
attributes[name22] = {
|
|
7409
8815
|
value: shared ? attributes[shared.name].value : value,
|
|
7410
8816
|
size,
|
|
7411
|
-
...
|
|
8817
|
+
...metadata3
|
|
7412
8818
|
};
|
|
7413
8819
|
if (!shared) columns.push({ name: name22, data: attributeData.data });
|
|
7414
8820
|
}
|
|
@@ -7446,23 +8852,23 @@ function getMeshBoundingBoxFromSchema(schema) {
|
|
|
7446
8852
|
}
|
|
7447
8853
|
return null;
|
|
7448
8854
|
}
|
|
7449
|
-
function getMeshAttributeMetadata(
|
|
8855
|
+
function getMeshAttributeMetadata(metadata3 = {}) {
|
|
7450
8856
|
const result = {};
|
|
7451
|
-
if (
|
|
7452
|
-
result.byteOffset = Number(
|
|
8857
|
+
if (metadata3.byteOffset !== void 0) {
|
|
8858
|
+
result.byteOffset = Number(metadata3.byteOffset);
|
|
7453
8859
|
}
|
|
7454
|
-
if (
|
|
7455
|
-
result.byteStride = Number(
|
|
8860
|
+
if (metadata3.byteStride !== void 0) {
|
|
8861
|
+
result.byteStride = Number(metadata3.byteStride);
|
|
7456
8862
|
}
|
|
7457
|
-
if (
|
|
7458
|
-
result.normalized =
|
|
8863
|
+
if (metadata3.normalized !== void 0) {
|
|
8864
|
+
result.normalized = metadata3.normalized === "true";
|
|
7459
8865
|
}
|
|
7460
|
-
if (
|
|
8866
|
+
if (metadata3.componentType === "float16") {
|
|
7461
8867
|
result.componentType = "float16";
|
|
7462
8868
|
}
|
|
7463
|
-
if (
|
|
8869
|
+
if (metadata3["loaders.gl.transform"]) {
|
|
7464
8870
|
try {
|
|
7465
|
-
const transform = JSON.parse(
|
|
8871
|
+
const transform = JSON.parse(metadata3["loaders.gl.transform"]);
|
|
7466
8872
|
if (isMeshAttributeTransform(transform)) {
|
|
7467
8873
|
result.transform = transform;
|
|
7468
8874
|
}
|
|
@@ -7487,7 +8893,7 @@ function fixMetadata(schema) {
|
|
|
7487
8893
|
schema.metadata.mode ||= "0";
|
|
7488
8894
|
}
|
|
7489
8895
|
function getAttributeTypedArray(attributeData, size) {
|
|
7490
|
-
if (!(attributeData.type instanceof
|
|
8896
|
+
if (!(attributeData.type instanceof arrow5.FixedSizeList)) {
|
|
7491
8897
|
return attributeData.toArray();
|
|
7492
8898
|
}
|
|
7493
8899
|
const values = attributeData.data[0].children[0].values;
|
|
@@ -7538,12 +8944,12 @@ function shareArrowStorage(left, right) {
|
|
|
7538
8944
|
);
|
|
7539
8945
|
}) && left.children.length === right.children.length && left.children.every((child, index) => shareArrowStorage(child, right.children[index]));
|
|
7540
8946
|
}
|
|
7541
|
-
var
|
|
8947
|
+
var arrow5;
|
|
7542
8948
|
var init_convert_table_to_mesh = __esm({
|
|
7543
8949
|
"../core/src/schema-utils/lib/mesh/convert-table-to-mesh.ts"() {
|
|
7544
8950
|
"use strict";
|
|
7545
8951
|
init_schema();
|
|
7546
|
-
|
|
8952
|
+
arrow5 = __toESM(require("apache-arrow"), 1);
|
|
7547
8953
|
init_arrow_fixed_size_list_utils();
|
|
7548
8954
|
init_convert_arrow_schema();
|
|
7549
8955
|
init_mesh_utils();
|
|
@@ -7551,17 +8957,29 @@ var init_convert_table_to_mesh = __esm({
|
|
|
7551
8957
|
});
|
|
7552
8958
|
|
|
7553
8959
|
// ../core/src/schema-utils/lib/mesh/deduce-mesh-schema.ts
|
|
8960
|
+
function deduceMeshSchema(attributes, metadata3 = {}) {
|
|
8961
|
+
const fields = deduceMeshFields(attributes);
|
|
8962
|
+
return { fields, metadata: metadata3 };
|
|
8963
|
+
}
|
|
7554
8964
|
function deduceMeshField(name22, attribute, optionalMetadata) {
|
|
7555
8965
|
const type = attribute.componentType || getDataTypeFromTypedArray(attribute.value);
|
|
7556
|
-
const
|
|
8966
|
+
const metadata3 = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
7557
8967
|
const dataType = attribute.size === 1 ? type : { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] };
|
|
7558
8968
|
return {
|
|
7559
8969
|
name: name22,
|
|
7560
8970
|
type: dataType,
|
|
7561
8971
|
nullable: false,
|
|
7562
|
-
metadata:
|
|
8972
|
+
metadata: metadata3
|
|
7563
8973
|
};
|
|
7564
8974
|
}
|
|
8975
|
+
function deduceMeshFields(attributes) {
|
|
8976
|
+
const fields = [];
|
|
8977
|
+
for (const attributeName in attributes) {
|
|
8978
|
+
const attribute = attributes[attributeName];
|
|
8979
|
+
fields.push(deduceMeshField(attributeName, attribute));
|
|
8980
|
+
}
|
|
8981
|
+
return fields;
|
|
8982
|
+
}
|
|
7565
8983
|
function makeMeshAttributeMetadata(attribute) {
|
|
7566
8984
|
const result = {};
|
|
7567
8985
|
if ("byteOffset" in attribute) {
|
|
@@ -7602,11 +9020,11 @@ var init_schema_utils = __esm({
|
|
|
7602
9020
|
});
|
|
7603
9021
|
|
|
7604
9022
|
// ../scene/src/obj/lib/get-obj-schema.ts
|
|
7605
|
-
function getOBJSchema(attributes,
|
|
9023
|
+
function getOBJSchema(attributes, metadata3 = {}) {
|
|
7606
9024
|
const stringMetadata = {};
|
|
7607
|
-
for (const key in
|
|
9025
|
+
for (const key in metadata3) {
|
|
7608
9026
|
if (key !== "value") {
|
|
7609
|
-
stringMetadata[key] = JSON.stringify(
|
|
9027
|
+
stringMetadata[key] = JSON.stringify(metadata3[key]);
|
|
7610
9028
|
}
|
|
7611
9029
|
}
|
|
7612
9030
|
const fields = [];
|
|
@@ -7618,10 +9036,10 @@ function getOBJSchema(attributes, metadata2 = {}) {
|
|
|
7618
9036
|
return { fields, metadata: stringMetadata };
|
|
7619
9037
|
}
|
|
7620
9038
|
function getFieldFromAttribute(name22, attribute) {
|
|
7621
|
-
const
|
|
9039
|
+
const metadata3 = {};
|
|
7622
9040
|
for (const key in attribute) {
|
|
7623
9041
|
if (key !== "value") {
|
|
7624
|
-
|
|
9042
|
+
metadata3[key] = JSON.stringify(attribute[key]);
|
|
7625
9043
|
}
|
|
7626
9044
|
}
|
|
7627
9045
|
let { type } = getDataTypeFromArray(attribute.value);
|
|
@@ -7629,7 +9047,7 @@ function getFieldFromAttribute(name22, attribute) {
|
|
|
7629
9047
|
if (!isSingleValue) {
|
|
7630
9048
|
type = { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "values", type }] };
|
|
7631
9049
|
}
|
|
7632
|
-
return { name: name22, type, nullable: false, metadata:
|
|
9050
|
+
return { name: name22, type, nullable: false, metadata: metadata3 };
|
|
7633
9051
|
}
|
|
7634
9052
|
var init_get_obj_schema = __esm({
|
|
7635
9053
|
"../scene/src/obj/lib/get-obj-schema.ts"() {
|
|
@@ -8192,7 +9610,7 @@ var init_obj_loader = __esm({
|
|
|
8192
9610
|
"../scene/src/obj/obj-loader.ts"() {
|
|
8193
9611
|
"use strict";
|
|
8194
9612
|
init_loader_utils();
|
|
8195
|
-
|
|
9613
|
+
init_arrow_worker_transport();
|
|
8196
9614
|
init_schema_utils();
|
|
8197
9615
|
init_get_obj_schema();
|
|
8198
9616
|
init_parse_obj();
|
|
@@ -8240,7 +9658,7 @@ var init_obj_loader_types = __esm({
|
|
|
8240
9658
|
"../scene/src/obj/obj-loader-types.ts"() {
|
|
8241
9659
|
"use strict";
|
|
8242
9660
|
init_obj_format();
|
|
8243
|
-
|
|
9661
|
+
init_arrow_worker_transport();
|
|
8244
9662
|
VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
8245
9663
|
OBJLoader = {
|
|
8246
9664
|
...OBJFormat,
|
|
@@ -8719,8 +10137,8 @@ function parseGLBChunksSync(glb, dataView, byteOffset, chunkHeaderSize, options)
|
|
|
8719
10137
|
}
|
|
8720
10138
|
function parseJSONChunk(glb, dataView, byteOffset, chunkLength, chunkIndex) {
|
|
8721
10139
|
const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
|
|
8722
|
-
const
|
|
8723
|
-
const jsonText =
|
|
10140
|
+
const textDecoder2 = new TextDecoder("utf8");
|
|
10141
|
+
const jsonText = textDecoder2.decode(jsonChunk);
|
|
8724
10142
|
glb.json = JSON.parse(jsonText);
|
|
8725
10143
|
glb.jsonChunkIndex = chunkIndex;
|
|
8726
10144
|
return padToFourBytes(chunkLength);
|
|
@@ -9510,8 +10928,8 @@ var init_gltf_scenegraph = __esm({
|
|
|
9510
10928
|
* @param mimeType
|
|
9511
10929
|
*/
|
|
9512
10930
|
addImage(imageData, mimeTypeOpt) {
|
|
9513
|
-
const
|
|
9514
|
-
const mimeType = mimeTypeOpt || (
|
|
10931
|
+
const metadata3 = getBinaryImageMetadata(imageData);
|
|
10932
|
+
const mimeType = mimeTypeOpt || (metadata3 == null ? void 0 : metadata3.mimeType);
|
|
9515
10933
|
const bufferViewIndex = this.addBufferView(imageData);
|
|
9516
10934
|
const glTFImage = {
|
|
9517
10935
|
bufferView: bufferViewIndex,
|
|
@@ -10394,8 +11812,8 @@ var init_gltf_iterator = __esm({
|
|
|
10394
11812
|
}
|
|
10395
11813
|
/** Return the loaded buffer companion for a raw buffer definition. */
|
|
10396
11814
|
getLoadedBuffer(buffer) {
|
|
10397
|
-
const
|
|
10398
|
-
return this.gltf.buffers[
|
|
11815
|
+
const metadata3 = this.getMetadata(buffer);
|
|
11816
|
+
return this.gltf.buffers[metadata3.index];
|
|
10399
11817
|
}
|
|
10400
11818
|
/** Return the loaded byte range for a raw buffer-view definition. */
|
|
10401
11819
|
getLoadedBufferView(bufferView) {
|
|
@@ -10950,7 +12368,7 @@ function parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount,
|
|
|
10950
12368
|
return attributeValueArray;
|
|
10951
12369
|
}
|
|
10952
12370
|
function getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets, fixedArrayCount) {
|
|
10953
|
-
const
|
|
12371
|
+
const textDecoder2 = new TextDecoder("utf8");
|
|
10954
12372
|
if (arrayOffsets) {
|
|
10955
12373
|
if (!stringOffsets) {
|
|
10956
12374
|
throw new Error("stringOffsets is required for variable-length string arrays");
|
|
@@ -10964,7 +12382,7 @@ function getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets,
|
|
|
10964
12382
|
const startByte = stringOffsets[stringIndex];
|
|
10965
12383
|
const endByte = stringOffsets[stringIndex + 1];
|
|
10966
12384
|
const stringData = valuesDataBytes.subarray(startByte, endByte);
|
|
10967
|
-
strings.push(
|
|
12385
|
+
strings.push(textDecoder2.decode(stringData));
|
|
10968
12386
|
}
|
|
10969
12387
|
result.push(strings);
|
|
10970
12388
|
}
|
|
@@ -10977,7 +12395,7 @@ function getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets,
|
|
|
10977
12395
|
const startByte = Number(stringOffsets[index]);
|
|
10978
12396
|
const endByte = Number(stringOffsets[index + 1]);
|
|
10979
12397
|
if (startByte >= 0 && endByte >= startByte && endByte <= valuesDataBytes.length) {
|
|
10980
|
-
stringsArray.push(
|
|
12398
|
+
stringsArray.push(textDecoder2.decode(valuesDataBytes.subarray(startByte, endByte)));
|
|
10981
12399
|
}
|
|
10982
12400
|
}
|
|
10983
12401
|
return fixedArrayCount ? Array.from(
|
|
@@ -11870,7 +13288,7 @@ __export(KHR_gaussian_splatting_exports, {
|
|
|
11870
13288
|
name: () => name4
|
|
11871
13289
|
});
|
|
11872
13290
|
async function decode3(gltfData, options, context) {
|
|
11873
|
-
var _a, _b, _c, _d, _e;
|
|
13291
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
11874
13292
|
const loader = (_a = context == null ? void 0 : context.loaders) == null ? void 0 : _a.find((candidate) => {
|
|
11875
13293
|
var _a2;
|
|
11876
13294
|
return (_a2 = candidate.extensions) == null ? void 0 : _a2.includes("spz");
|
|
@@ -11881,22 +13299,29 @@ async function decode3(gltfData, options, context) {
|
|
|
11881
13299
|
for (const [primitiveIndex, primitive] of mesh.primitives.entries()) {
|
|
11882
13300
|
const extension = (_b = primitive.extensions) == null ? void 0 : _b[name4];
|
|
11883
13301
|
if (!extension) continue;
|
|
13302
|
+
const descriptor = descriptors.find(
|
|
13303
|
+
(item) => item.meshIndex === meshIndex && item.primitiveIndex === primitiveIndex
|
|
13304
|
+
);
|
|
13305
|
+
const legacyColorSpace = (_c = options == null ? void 0 : options.gltf) == null ? void 0 : _c.legacyGaussianSplatColorSpace;
|
|
13306
|
+
const normalizedExtension = legacyColorSpace && ((_d = extension.extensions) == null ? void 0 : _d[SPZ_COMPRESSION_EXTENSION_NAME]) ? {
|
|
13307
|
+
...extension,
|
|
13308
|
+
kernel: extension.kernel ?? "ellipse",
|
|
13309
|
+
colorSpace: extension.colorSpace ?? legacyColorSpace
|
|
13310
|
+
} : extension;
|
|
13311
|
+
if (descriptor) descriptor.extension = normalizedExtension;
|
|
11884
13312
|
validateGaussianSplatPrimitive(
|
|
11885
13313
|
gltfData.json,
|
|
11886
13314
|
primitive,
|
|
11887
|
-
|
|
13315
|
+
normalizedExtension,
|
|
11888
13316
|
meshIndex,
|
|
11889
13317
|
primitiveIndex,
|
|
11890
13318
|
iterator
|
|
11891
13319
|
);
|
|
11892
|
-
const compression = (
|
|
13320
|
+
const compression = (_e = extension.extensions) == null ? void 0 : _e[SPZ_COMPRESSION_EXTENSION_NAME];
|
|
11893
13321
|
if (compression) {
|
|
11894
|
-
const descriptor = descriptors.find(
|
|
11895
|
-
(item) => item.meshIndex === meshIndex && item.primitiveIndex === primitiveIndex
|
|
11896
|
-
);
|
|
11897
13322
|
if (descriptor) {
|
|
11898
|
-
const decoder = (
|
|
11899
|
-
const bufferView = (
|
|
13323
|
+
const decoder = (_f = options == null ? void 0 : options.gltf) == null ? void 0 : _f.splatDecoder;
|
|
13324
|
+
const bufferView = (_g = gltfData.json.bufferViews) == null ? void 0 : _g[compression.bufferView];
|
|
11900
13325
|
if (bufferView && gltfData.buffers[bufferView.buffer]) {
|
|
11901
13326
|
descriptor.compressedBytes = getBufferViewBytes(gltfData, compression.bufferView);
|
|
11902
13327
|
} else if (decoder || loader) {
|
|
@@ -13473,7 +14898,7 @@ var init_draco_module_loader = __esm({
|
|
|
13473
14898
|
|
|
13474
14899
|
// ../scene/src/draco/lib/utils/get-draco-schema.ts
|
|
13475
14900
|
function getDracoSchema(attributes, loaderData, indices) {
|
|
13476
|
-
const
|
|
14901
|
+
const metadata3 = makeMetadata(loaderData.metadata);
|
|
13477
14902
|
const fields = [];
|
|
13478
14903
|
const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes);
|
|
13479
14904
|
for (const attributeName in attributes) {
|
|
@@ -13489,7 +14914,7 @@ function getDracoSchema(attributes, loaderData, indices) {
|
|
|
13489
14914
|
const indicesField = getArrowFieldFromAttribute("indices", indices);
|
|
13490
14915
|
fields.push(indicesField);
|
|
13491
14916
|
}
|
|
13492
|
-
return { fields, metadata:
|
|
14917
|
+
return { fields, metadata: metadata3 };
|
|
13493
14918
|
}
|
|
13494
14919
|
function transformAttributesLoaderData(loaderData) {
|
|
13495
14920
|
const result = {};
|
|
@@ -13507,11 +14932,11 @@ function getArrowFieldFromAttribute(attributeName, attribute, loaderData) {
|
|
|
13507
14932
|
const field = deduceMeshField(attributeName, attribute, metadataMap);
|
|
13508
14933
|
return field;
|
|
13509
14934
|
}
|
|
13510
|
-
function makeMetadata(
|
|
13511
|
-
Object.entries(
|
|
14935
|
+
function makeMetadata(metadata3) {
|
|
14936
|
+
Object.entries(metadata3);
|
|
13512
14937
|
const serializedMetadata = {};
|
|
13513
|
-
for (const key in
|
|
13514
|
-
serializedMetadata[`${key}.string`] = JSON.stringify(
|
|
14938
|
+
for (const key in metadata3) {
|
|
14939
|
+
serializedMetadata[`${key}.string`] = JSON.stringify(metadata3[key]);
|
|
13515
14940
|
}
|
|
13516
14941
|
return serializedMetadata;
|
|
13517
14942
|
}
|
|
@@ -13730,14 +15155,14 @@ var init_draco_parser = __esm({
|
|
|
13730
15155
|
* @returns
|
|
13731
15156
|
*/
|
|
13732
15157
|
_getDracoLoaderData(dracoGeometry, geometry_type, options) {
|
|
13733
|
-
const
|
|
15158
|
+
const metadata3 = this._getTopLevelMetadata(dracoGeometry);
|
|
13734
15159
|
const attributes = this._getDracoAttributes(dracoGeometry, options);
|
|
13735
15160
|
return {
|
|
13736
15161
|
geometry_type,
|
|
13737
15162
|
num_attributes: dracoGeometry.num_attributes(),
|
|
13738
15163
|
num_points: dracoGeometry.num_points(),
|
|
13739
15164
|
num_faces: dracoGeometry instanceof this.draco.Mesh ? dracoGeometry.num_faces() : 0,
|
|
13740
|
-
metadata:
|
|
15165
|
+
metadata: metadata3,
|
|
13741
15166
|
attributes
|
|
13742
15167
|
};
|
|
13743
15168
|
}
|
|
@@ -13751,7 +15176,7 @@ var init_draco_parser = __esm({
|
|
|
13751
15176
|
const dracoAttributes = {};
|
|
13752
15177
|
for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
|
|
13753
15178
|
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
|
|
13754
|
-
const
|
|
15179
|
+
const metadata3 = this._getAttributeMetadata(dracoGeometry, attributeId);
|
|
13755
15180
|
dracoAttributes[dracoAttribute.unique_id()] = {
|
|
13756
15181
|
unique_id: dracoAttribute.unique_id(),
|
|
13757
15182
|
attribute_type: dracoAttribute.attribute_type(),
|
|
@@ -13761,7 +15186,7 @@ var init_draco_parser = __esm({
|
|
|
13761
15186
|
byte_stride: dracoAttribute.byte_stride(),
|
|
13762
15187
|
normalized: dracoAttribute.normalized(),
|
|
13763
15188
|
attribute_index: attributeId,
|
|
13764
|
-
metadata:
|
|
15189
|
+
metadata: metadata3
|
|
13765
15190
|
};
|
|
13766
15191
|
const quantization = this._getQuantizationTransform(dracoAttribute, options);
|
|
13767
15192
|
if (quantization) {
|
|
@@ -14280,7 +15705,7 @@ var DracoLoader, DracoWorkerLoader;
|
|
|
14280
15705
|
var init_draco_loader_types = __esm({
|
|
14281
15706
|
"../scene/src/draco/draco-loader-types.ts"() {
|
|
14282
15707
|
"use strict";
|
|
14283
|
-
|
|
15708
|
+
init_arrow_worker_transport();
|
|
14284
15709
|
init_version4();
|
|
14285
15710
|
init_draco_format();
|
|
14286
15711
|
init_draco_loader_options();
|
|
@@ -14860,10 +16285,10 @@ async function encode5(gltfData, options) {
|
|
|
14860
16285
|
}
|
|
14861
16286
|
function resolveTechniques(techniquesExtension, iterator) {
|
|
14862
16287
|
const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
|
|
14863
|
-
const
|
|
16288
|
+
const textDecoder2 = new TextDecoder();
|
|
14864
16289
|
shaders.forEach((shader) => {
|
|
14865
16290
|
if (Number.isFinite(shader.bufferView)) {
|
|
14866
|
-
shader.code =
|
|
16291
|
+
shader.code = textDecoder2.decode(
|
|
14867
16292
|
getTypedArrayForBufferView(iterator.data, iterator.gltf.buffers, shader.bufferView)
|
|
14868
16293
|
);
|
|
14869
16294
|
} else {
|
|
@@ -17520,8 +18945,8 @@ function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
|
17520
18945
|
gltf.baseUri = (_b = options.core) == null ? void 0 : _b.baseUrl;
|
|
17521
18946
|
}
|
|
17522
18947
|
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options.glb)) {
|
|
17523
|
-
const
|
|
17524
|
-
data =
|
|
18948
|
+
const textDecoder2 = new TextDecoder();
|
|
18949
|
+
data = textDecoder2.decode(data);
|
|
17525
18950
|
}
|
|
17526
18951
|
if (typeof data === "string") {
|
|
17527
18952
|
gltf.json = parseJSON(data);
|
|
@@ -18649,9 +20074,9 @@ var init_draco_builder = __esm({
|
|
|
18649
20074
|
* @param dracoGeometry - WASM Draco Object
|
|
18650
20075
|
* @param metadata
|
|
18651
20076
|
*/
|
|
18652
|
-
_addGeometryMetadata(dracoGeometry,
|
|
20077
|
+
_addGeometryMetadata(dracoGeometry, metadata3) {
|
|
18653
20078
|
const dracoMetadata = new this.draco.Metadata();
|
|
18654
|
-
this._populateDracoMetadata(dracoMetadata,
|
|
20079
|
+
this._populateDracoMetadata(dracoMetadata, metadata3);
|
|
18655
20080
|
this.dracoMeshBuilder.AddMetadata(dracoGeometry, dracoMetadata);
|
|
18656
20081
|
}
|
|
18657
20082
|
/**
|
|
@@ -18660,9 +20085,9 @@ var init_draco_builder = __esm({
|
|
|
18660
20085
|
* @param uniqueAttributeId
|
|
18661
20086
|
* @param metadata
|
|
18662
20087
|
*/
|
|
18663
|
-
_addAttributeMetadata(dracoGeometry, uniqueAttributeId,
|
|
20088
|
+
_addAttributeMetadata(dracoGeometry, uniqueAttributeId, metadata3) {
|
|
18664
20089
|
const dracoAttributeMetadata = new this.draco.Metadata();
|
|
18665
|
-
this._populateDracoMetadata(dracoAttributeMetadata,
|
|
20090
|
+
this._populateDracoMetadata(dracoAttributeMetadata, metadata3);
|
|
18666
20091
|
this.dracoMeshBuilder.SetMetadataForAttribute(
|
|
18667
20092
|
dracoGeometry,
|
|
18668
20093
|
uniqueAttributeId,
|
|
@@ -18674,8 +20099,8 @@ var init_draco_builder = __esm({
|
|
|
18674
20099
|
* @param dracoMetadata - WASM Draco Object
|
|
18675
20100
|
* @param metadata
|
|
18676
20101
|
*/
|
|
18677
|
-
_populateDracoMetadata(dracoMetadata,
|
|
18678
|
-
for (const [key, value] of getEntries(
|
|
20102
|
+
_populateDracoMetadata(dracoMetadata, metadata3) {
|
|
20103
|
+
for (const [key, value] of getEntries(metadata3)) {
|
|
18679
20104
|
switch (typeof value) {
|
|
18680
20105
|
case "number":
|
|
18681
20106
|
if (Math.trunc(value) === value) {
|
|
@@ -20889,6 +22314,132 @@ var init_materialx_loader_types = __esm({
|
|
|
20889
22314
|
}
|
|
20890
22315
|
});
|
|
20891
22316
|
|
|
22317
|
+
// ../scene/src/stl/parse-stl.ts
|
|
22318
|
+
function parseSTL(data) {
|
|
22319
|
+
const view = new DataView(data);
|
|
22320
|
+
const binary2 = data.byteLength >= 84 && 84 + view.getUint32(80, true) * 50 === data.byteLength;
|
|
22321
|
+
let positions;
|
|
22322
|
+
let normals;
|
|
22323
|
+
let header;
|
|
22324
|
+
if (binary2) {
|
|
22325
|
+
const triangleCount = view.getUint32(80, true);
|
|
22326
|
+
positions = new Float32Array(triangleCount * 9);
|
|
22327
|
+
normals = new Float32Array(triangleCount * 9);
|
|
22328
|
+
header = new TextDecoder().decode(data.slice(0, 80));
|
|
22329
|
+
for (let triangle = 0; triangle < triangleCount; triangle++) {
|
|
22330
|
+
const offset = 84 + triangle * 50;
|
|
22331
|
+
for (let component = 0; component < 9; component++) {
|
|
22332
|
+
positions[triangle * 9 + component] = view.getFloat32(offset + 12 + component * 4, true);
|
|
22333
|
+
normals[triangle * 9 + component] = view.getFloat32(offset + component % 3 * 4, true);
|
|
22334
|
+
}
|
|
22335
|
+
}
|
|
22336
|
+
} else {
|
|
22337
|
+
const lines = new TextDecoder().decode(data).trim().split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
22338
|
+
const vertices = [];
|
|
22339
|
+
const normalValues = [];
|
|
22340
|
+
header = lines[0] || "";
|
|
22341
|
+
let lineIndex = 0;
|
|
22342
|
+
while (lineIndex < lines.length) {
|
|
22343
|
+
if (!/^solid(?:\s|$)/i.test(lines[lineIndex++]))
|
|
22344
|
+
throw new Error("STL: expected solid header or exact binary length");
|
|
22345
|
+
while (lineIndex < lines.length && !/^endsolid(?:\s|$)/i.test(lines[lineIndex])) {
|
|
22346
|
+
const normal = parseVector(lines[lineIndex++], "facet normal");
|
|
22347
|
+
if (!/^outer\s+loop$/i.test(lines[lineIndex++] || ""))
|
|
22348
|
+
throw new Error("STL: expected outer loop");
|
|
22349
|
+
for (let vertex = 0; vertex < 3; vertex++) {
|
|
22350
|
+
vertices.push(...parseVector(lines[lineIndex++], "vertex"));
|
|
22351
|
+
normalValues.push(...normal);
|
|
22352
|
+
}
|
|
22353
|
+
if (!/^endloop$/i.test(lines[lineIndex++] || "") || !/^endfacet$/i.test(lines[lineIndex++] || ""))
|
|
22354
|
+
throw new Error("STL: incomplete facet");
|
|
22355
|
+
}
|
|
22356
|
+
if (lineIndex >= lines.length) throw new Error("STL: missing endsolid");
|
|
22357
|
+
lineIndex++;
|
|
22358
|
+
}
|
|
22359
|
+
if (!lines.length) throw new Error("STL: empty input");
|
|
22360
|
+
positions = new Float32Array(vertices);
|
|
22361
|
+
normals = new Float32Array(normalValues);
|
|
22362
|
+
}
|
|
22363
|
+
if (!positions.every(Number.isFinite) || !normals.every(Number.isFinite))
|
|
22364
|
+
throw new Error("STL: non-finite coordinates");
|
|
22365
|
+
const attributes = { POSITION: { value: positions, size: 3 }, NORMAL: { value: normals, size: 3 } };
|
|
22366
|
+
return {
|
|
22367
|
+
topology: "triangle-list",
|
|
22368
|
+
mode: 4,
|
|
22369
|
+
attributes,
|
|
22370
|
+
schema: deduceMeshSchema(attributes),
|
|
22371
|
+
header: {
|
|
22372
|
+
vertexCount: positions.length / 3,
|
|
22373
|
+
boundingBox: getMeshBoundingBox(attributes) ?? void 0
|
|
22374
|
+
},
|
|
22375
|
+
loaderData: { header, format: binary2 ? "binary" : "ascii" }
|
|
22376
|
+
};
|
|
22377
|
+
}
|
|
22378
|
+
function parseVector(line, prefix) {
|
|
22379
|
+
const tokens = (line == null ? void 0 : line.split(/\s+/)) || [];
|
|
22380
|
+
const prefixTokens = prefix.split(" ");
|
|
22381
|
+
const components = tokens.slice(prefixTokens.length);
|
|
22382
|
+
if (prefixTokens.some((token, index) => {
|
|
22383
|
+
var _a;
|
|
22384
|
+
return ((_a = tokens[index]) == null ? void 0 : _a.toLowerCase()) !== token;
|
|
22385
|
+
}) || components.length !== 3 || components.some((value) => !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(value))) {
|
|
22386
|
+
throw new Error(`STL: invalid ${prefix} record`);
|
|
22387
|
+
}
|
|
22388
|
+
return components.map(Number);
|
|
22389
|
+
}
|
|
22390
|
+
var init_parse_stl = __esm({
|
|
22391
|
+
"../scene/src/stl/parse-stl.ts"() {
|
|
22392
|
+
"use strict";
|
|
22393
|
+
init_schema_utils();
|
|
22394
|
+
}
|
|
22395
|
+
});
|
|
22396
|
+
|
|
22397
|
+
// ../scene/src/stl-loader.ts
|
|
22398
|
+
var stl_loader_exports = {};
|
|
22399
|
+
__export(stl_loader_exports, {
|
|
22400
|
+
STLLoaderWithParser: () => STLLoaderWithParser
|
|
22401
|
+
});
|
|
22402
|
+
var _preload2, metadata2, STLLoaderWithParser;
|
|
22403
|
+
var init_stl_loader = __esm({
|
|
22404
|
+
"../scene/src/stl-loader.ts"() {
|
|
22405
|
+
"use strict";
|
|
22406
|
+
init_stl_loader_types();
|
|
22407
|
+
init_parse_stl();
|
|
22408
|
+
({ preload: _preload2, ...metadata2 } = STLLoader);
|
|
22409
|
+
STLLoaderWithParser = {
|
|
22410
|
+
...metadata2,
|
|
22411
|
+
parse: async (data) => parseSTL(data),
|
|
22412
|
+
parseSync: parseSTL
|
|
22413
|
+
};
|
|
22414
|
+
}
|
|
22415
|
+
});
|
|
22416
|
+
|
|
22417
|
+
// ../scene/src/stl-loader-types.ts
|
|
22418
|
+
async function preload11() {
|
|
22419
|
+
const { STLLoaderWithParser: STLLoaderWithParser2 } = await Promise.resolve().then(() => (init_stl_loader(), stl_loader_exports));
|
|
22420
|
+
return STLLoaderWithParser2;
|
|
22421
|
+
}
|
|
22422
|
+
var VERSION10, STLLoader;
|
|
22423
|
+
var init_stl_loader_types = __esm({
|
|
22424
|
+
"../scene/src/stl-loader-types.ts"() {
|
|
22425
|
+
"use strict";
|
|
22426
|
+
VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
22427
|
+
STLLoader = {
|
|
22428
|
+
name: "STL",
|
|
22429
|
+
id: "stl",
|
|
22430
|
+
module: "scene",
|
|
22431
|
+
version: VERSION10,
|
|
22432
|
+
extensions: ["stl"],
|
|
22433
|
+
mimeTypes: ["model/stl"],
|
|
22434
|
+
binary: true,
|
|
22435
|
+
dataType: null,
|
|
22436
|
+
batchType: null,
|
|
22437
|
+
options: {},
|
|
22438
|
+
preload: preload11
|
|
22439
|
+
};
|
|
22440
|
+
}
|
|
22441
|
+
});
|
|
22442
|
+
|
|
20892
22443
|
// ../scene/src/index.ts
|
|
20893
22444
|
var src_exports = {};
|
|
20894
22445
|
__export(src_exports, {
|
|
@@ -20911,6 +22462,7 @@ __export(src_exports, {
|
|
|
20911
22462
|
OBJLoader: () => OBJLoader,
|
|
20912
22463
|
OBJWorkerLoader: () => OBJWorkerLoader,
|
|
20913
22464
|
OBJWriter: () => OBJWriter,
|
|
22465
|
+
STLLoader: () => STLLoader,
|
|
20914
22466
|
USDLoader: () => USDLoader
|
|
20915
22467
|
});
|
|
20916
22468
|
var init_src2 = __esm({
|
|
@@ -20931,6 +22483,7 @@ var init_src2 = __esm({
|
|
|
20931
22483
|
init_draco_format();
|
|
20932
22484
|
init_draco_libraries();
|
|
20933
22485
|
init_materialx_loader_types();
|
|
22486
|
+
init_stl_loader_types();
|
|
20934
22487
|
}
|
|
20935
22488
|
});
|
|
20936
22489
|
|
|
@@ -24960,7 +26513,7 @@ var init_i3s_source = __esm({
|
|
|
24960
26513
|
const contentUrl = this.getTileUrl(tile.contentUrl);
|
|
24961
26514
|
const loaderId = this.loader.id;
|
|
24962
26515
|
const loaderOptions = this.loadOptions[loaderId] || {};
|
|
24963
|
-
const
|
|
26516
|
+
const metadata3 = this.getMetadata();
|
|
24964
26517
|
const options = {
|
|
24965
26518
|
...this.loadOptions,
|
|
24966
26519
|
[loaderId]: {
|
|
@@ -24980,9 +26533,9 @@ var init_i3s_source = __esm({
|
|
|
24980
26533
|
mbs: tile.header.mbs
|
|
24981
26534
|
},
|
|
24982
26535
|
_tilesetOptions: {
|
|
24983
|
-
store:
|
|
24984
|
-
attributeStorageInfo:
|
|
24985
|
-
fields:
|
|
26536
|
+
store: metadata3.tileset.store,
|
|
26537
|
+
attributeStorageInfo: metadata3.tileset.attributeStorageInfo,
|
|
26538
|
+
fields: metadata3.tileset.fields,
|
|
24986
26539
|
spatialReference: tile.tileset.spatialReference,
|
|
24987
26540
|
spatialOptions: tile.tileset.options.spatial
|
|
24988
26541
|
},
|
|
@@ -25006,9 +26559,9 @@ var init_i3s_source = __esm({
|
|
|
25006
26559
|
* Loads child tile metadata on demand from node pages or `/nodes/{id}` resources.
|
|
25007
26560
|
*/
|
|
25008
26561
|
async loadChildTileHeader(_parentTile, childId, _frameState) {
|
|
25009
|
-
const
|
|
25010
|
-
if (
|
|
25011
|
-
const header2 = await
|
|
26562
|
+
const metadata3 = this.getMetadata();
|
|
26563
|
+
if (metadata3.tileset.nodePages || metadata3.tileset.pointNodePages) {
|
|
26564
|
+
const header2 = await metadata3.tileset.nodePagesTile.formTileFromNodePages(childId);
|
|
25012
26565
|
return await this.transformTileHeader(header2);
|
|
25013
26566
|
}
|
|
25014
26567
|
const nodeUrl = this.getTileUrl(`${this.url}/nodes/${childId}`);
|
|
@@ -25111,8 +26664,8 @@ var init_i3s_source = __esm({
|
|
|
25111
26664
|
zoom: 1
|
|
25112
26665
|
};
|
|
25113
26666
|
}
|
|
25114
|
-
const
|
|
25115
|
-
const fullExtent =
|
|
26667
|
+
const metadata3 = this.getMetadata();
|
|
26668
|
+
const fullExtent = metadata3.tileset.fullExtent;
|
|
25116
26669
|
if (fullExtent) {
|
|
25117
26670
|
const { xmin, xmax, ymin, ymax, zmin, zmax } = fullExtent;
|
|
25118
26671
|
const cartographicCenter = new import_core13.Vector3(
|
|
@@ -25128,7 +26681,7 @@ var init_i3s_source = __esm({
|
|
|
25128
26681
|
zoom: getZoomFromFullExtent(fullExtent, cartographicCenter, cartesianCenter)
|
|
25129
26682
|
};
|
|
25130
26683
|
}
|
|
25131
|
-
const extent = (_a =
|
|
26684
|
+
const extent = (_a = metadata3.tileset.store) == null ? void 0 : _a.extent;
|
|
25132
26685
|
if (extent) {
|
|
25133
26686
|
const [xmin, ymin, xmax, ymax] = extent;
|
|
25134
26687
|
const cartographicCenter = new import_core13.Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0);
|
|
@@ -25168,8 +26721,8 @@ var init_i3s_source = __esm({
|
|
|
25168
26721
|
*/
|
|
25169
26722
|
getTilesTotalCount() {
|
|
25170
26723
|
var _a, _b;
|
|
25171
|
-
const
|
|
25172
|
-
return ((_b = (_a =
|
|
26724
|
+
const metadata3 = this.getMetadata();
|
|
26725
|
+
return ((_b = (_a = metadata3.tileset) == null ? void 0 : _a.nodePagesTile) == null ? void 0 : _b.nodesInNodePages) || null;
|
|
25173
26726
|
}
|
|
25174
26727
|
/**
|
|
25175
26728
|
* Loads data through injected core APIs so this module stays independent from `@loaders.gl/core`.
|
|
@@ -25749,20 +27302,20 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
|
25749
27302
|
function parsePositions(attribute, options) {
|
|
25750
27303
|
const mbs = options.mbs;
|
|
25751
27304
|
const value = attribute.value;
|
|
25752
|
-
const
|
|
27305
|
+
const metadata3 = attribute.metadata;
|
|
25753
27306
|
const enuMatrix = new import_core14.Matrix4();
|
|
25754
27307
|
const cartographicOrigin = new import_core14.Vector3(mbs[0], mbs[1], mbs[2]);
|
|
25755
27308
|
const cartesianOrigin = new import_core14.Vector3();
|
|
25756
27309
|
import_geospatial8.Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);
|
|
25757
27310
|
(0, import_geospatial9.eastNorthUpToFixedFrame)(import_geospatial8.Ellipsoid.WGS84, cartesianOrigin, enuMatrix);
|
|
25758
|
-
attribute.value = offsetsToCartesians(value,
|
|
27311
|
+
attribute.value = offsetsToCartesians(value, metadata3, cartographicOrigin);
|
|
25759
27312
|
return enuMatrix;
|
|
25760
27313
|
}
|
|
25761
|
-
function offsetsToSourcePositions(vertices,
|
|
27314
|
+
function offsetsToSourcePositions(vertices, metadata3 = {}, sourceOrigin) {
|
|
25762
27315
|
var _a, _b;
|
|
25763
27316
|
const positions = new Float64Array(vertices.length);
|
|
25764
|
-
const scaleX = ((_a =
|
|
25765
|
-
const scaleY = ((_b =
|
|
27317
|
+
const scaleX = ((_a = metadata3["i3s-scale_x"]) == null ? void 0 : _a.double) ?? 1;
|
|
27318
|
+
const scaleY = ((_b = metadata3["i3s-scale_y"]) == null ? void 0 : _b.double) ?? 1;
|
|
25766
27319
|
for (let index = 0; index < positions.length; index += 3) {
|
|
25767
27320
|
positions[index] = vertices[index] * scaleX + sourceOrigin[0];
|
|
25768
27321
|
positions[index + 1] = vertices[index + 1] * scaleY + sourceOrigin[1];
|
|
@@ -25770,8 +27323,8 @@ function offsetsToSourcePositions(vertices, metadata2 = {}, sourceOrigin) {
|
|
|
25770
27323
|
}
|
|
25771
27324
|
return positions;
|
|
25772
27325
|
}
|
|
25773
|
-
function offsetsToCartesians(vertices,
|
|
25774
|
-
const positions = offsetsToSourcePositions(vertices,
|
|
27326
|
+
function offsetsToCartesians(vertices, metadata3 = {}, cartographicOrigin) {
|
|
27327
|
+
const positions = offsetsToSourcePositions(vertices, metadata3, cartographicOrigin);
|
|
25775
27328
|
for (let i = 0; i < positions.length; i += 3) {
|
|
25776
27329
|
import_geospatial8.Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector4);
|
|
25777
27330
|
positions[i] = scratchVector4.x;
|
|
@@ -25782,9 +27335,9 @@ function offsetsToCartesians(vertices, metadata2 = {}, cartographicOrigin) {
|
|
|
25782
27335
|
}
|
|
25783
27336
|
function getModelMatrix(positions) {
|
|
25784
27337
|
var _a, _b;
|
|
25785
|
-
const
|
|
25786
|
-
const scaleX = ((_a =
|
|
25787
|
-
const scaleY = ((_b =
|
|
27338
|
+
const metadata3 = positions.metadata;
|
|
27339
|
+
const scaleX = ((_a = metadata3 == null ? void 0 : metadata3["i3s-scale_x"]) == null ? void 0 : _a.double) || 1;
|
|
27340
|
+
const scaleY = ((_b = metadata3 == null ? void 0 : metadata3["i3s-scale_y"]) == null ? void 0 : _b.double) || 1;
|
|
25788
27341
|
const modelMatrix = new import_core14.Matrix4();
|
|
25789
27342
|
modelMatrix[0] = scaleX;
|
|
25790
27343
|
modelMatrix[5] = scaleY;
|
|
@@ -26010,13 +27563,13 @@ var init_i3s_content_loader_with_parser = __esm({
|
|
|
26010
27563
|
});
|
|
26011
27564
|
|
|
26012
27565
|
// dist/i3s/i3s-content-loader.js
|
|
26013
|
-
var
|
|
27566
|
+
var VERSION11, I3SContentLoader;
|
|
26014
27567
|
var init_i3s_content_loader = __esm({
|
|
26015
27568
|
"dist/i3s/i3s-content-loader.js"() {
|
|
26016
27569
|
"use strict";
|
|
26017
27570
|
init_i3s_format();
|
|
26018
27571
|
init_i3s_loader_options();
|
|
26019
|
-
|
|
27572
|
+
VERSION11 = true ? "5.0.0-beta.6" : "latest";
|
|
26020
27573
|
I3SContentLoader = {
|
|
26021
27574
|
...I3SContentFormat,
|
|
26022
27575
|
dataType: null,
|
|
@@ -26026,7 +27579,7 @@ var init_i3s_content_loader = __esm({
|
|
|
26026
27579
|
module: "tiles-3d",
|
|
26027
27580
|
worker: true,
|
|
26028
27581
|
workerSourceNode: "i3s/workers/i3s-content-worker-node.ts",
|
|
26029
|
-
version:
|
|
27582
|
+
version: VERSION11,
|
|
26030
27583
|
mimeTypes: ["application/octet-stream"],
|
|
26031
27584
|
/** Loads the parser-bearing I3S content loader implementation. */
|
|
26032
27585
|
preload: async () => (await Promise.resolve().then(() => (init_i3s_content_loader_with_parser(), i3s_content_loader_with_parser_exports))).I3SContentLoaderWithParser,
|
|
@@ -26040,12 +27593,12 @@ var init_i3s_content_loader = __esm({
|
|
|
26040
27593
|
});
|
|
26041
27594
|
|
|
26042
27595
|
// dist/i3s/i3s-node-page-loader.js
|
|
26043
|
-
var
|
|
27596
|
+
var VERSION12, I3SNodePageLoader;
|
|
26044
27597
|
var init_i3s_node_page_loader = __esm({
|
|
26045
27598
|
"dist/i3s/i3s-node-page-loader.js"() {
|
|
26046
27599
|
"use strict";
|
|
26047
27600
|
init_i3s_format();
|
|
26048
|
-
|
|
27601
|
+
VERSION12 = true ? "5.0.0-beta.6" : "latest";
|
|
26049
27602
|
I3SNodePageLoader = {
|
|
26050
27603
|
...I3SNodePageFormat,
|
|
26051
27604
|
dataType: null,
|
|
@@ -26053,7 +27606,7 @@ var init_i3s_node_page_loader = __esm({
|
|
|
26053
27606
|
name: "I3S Node Page",
|
|
26054
27607
|
id: "i3s-node-page",
|
|
26055
27608
|
module: "tiles-3d",
|
|
26056
|
-
version:
|
|
27609
|
+
version: VERSION12,
|
|
26057
27610
|
mimeTypes: ["application/json"],
|
|
26058
27611
|
/** Loads the parser-bearing I3S node page loader implementation. */
|
|
26059
27612
|
preload: async () => (await Promise.resolve().then(() => (init_i3s_node_page_loader_with_parser(), i3s_node_page_loader_with_parser_exports))).I3SNodePageLoaderWithParser,
|
|
@@ -26735,14 +28288,14 @@ var init_i3s_loader_with_parser = __esm({
|
|
|
26735
28288
|
});
|
|
26736
28289
|
|
|
26737
28290
|
// dist/i3s/i3s-loader.js
|
|
26738
|
-
var
|
|
28291
|
+
var VERSION13, I3SLoader;
|
|
26739
28292
|
var init_i3s_loader = __esm({
|
|
26740
28293
|
"dist/i3s/i3s-loader.js"() {
|
|
26741
28294
|
"use strict";
|
|
26742
28295
|
init_i3s_format();
|
|
26743
28296
|
init_i3s_content_loader();
|
|
26744
28297
|
init_i3s_loader_options();
|
|
26745
|
-
|
|
28298
|
+
VERSION13 = true ? "5.0.0-beta.6" : "latest";
|
|
26746
28299
|
I3SLoader = {
|
|
26747
28300
|
...I3SFormat,
|
|
26748
28301
|
dataType: null,
|
|
@@ -26752,7 +28305,7 @@ var init_i3s_loader = __esm({
|
|
|
26752
28305
|
module: "tiles-3d",
|
|
26753
28306
|
/** Worker-capable loader used by I3S sources for binary tile content. */
|
|
26754
28307
|
contentLoader: I3SContentLoader,
|
|
26755
|
-
version:
|
|
28308
|
+
version: VERSION13,
|
|
26756
28309
|
mimeTypes: ["application/octet-stream"],
|
|
26757
28310
|
/** Loads the parser-bearing I3S loader implementation. */
|
|
26758
28311
|
preload: async () => (await Promise.resolve().then(() => (init_i3s_loader_with_parser(), i3s_loader_with_parser_exports))).I3SLoaderWithParser,
|
|
@@ -28147,11 +29700,11 @@ var init_compress_utils_compression = __esm({
|
|
|
28147
29700
|
/** Shared import and WASM initialization for concurrent callers. */
|
|
28148
29701
|
modulePromise = null;
|
|
28149
29702
|
/** Creates a format-specific compress-utils encoder. */
|
|
28150
|
-
constructor(
|
|
29703
|
+
constructor(metadata3, loadModule, options = {}) {
|
|
28151
29704
|
super(options);
|
|
28152
|
-
this.name =
|
|
28153
|
-
this.extensions =
|
|
28154
|
-
this.contentEncodings =
|
|
29705
|
+
this.name = metadata3.name;
|
|
29706
|
+
this.extensions = metadata3.extensions || [];
|
|
29707
|
+
this.contentEncodings = metadata3.contentEncodings || [];
|
|
28155
29708
|
this.loadModule = loadModule;
|
|
28156
29709
|
this.options = options;
|
|
28157
29710
|
}
|
|
@@ -28210,11 +29763,11 @@ var init_compress_utils_compression = __esm({
|
|
|
28210
29763
|
/** Shared import and WASM initialization for concurrent callers. */
|
|
28211
29764
|
modulePromise = null;
|
|
28212
29765
|
/** Creates a format-specific compress-utils decoder. */
|
|
28213
|
-
constructor(
|
|
29766
|
+
constructor(metadata3, loadModule, options = {}) {
|
|
28214
29767
|
super(options);
|
|
28215
|
-
this.name =
|
|
28216
|
-
this.extensions =
|
|
28217
|
-
this.contentEncodings =
|
|
29768
|
+
this.name = metadata3.name;
|
|
29769
|
+
this.extensions = metadata3.extensions || [];
|
|
29770
|
+
this.contentEncodings = metadata3.contentEncodings || [];
|
|
28218
29771
|
this.loadModule = loadModule;
|
|
28219
29772
|
this.options = options;
|
|
28220
29773
|
}
|
|
@@ -28862,17 +30415,17 @@ var init_zip_archive = __esm({
|
|
|
28862
30415
|
const headers = [...(await this.getDirectory()).values()];
|
|
28863
30416
|
return await this.getEntry(headers[headers.length - 1].path);
|
|
28864
30417
|
}
|
|
28865
|
-
const
|
|
28866
|
-
return await this.getValidatedEntry(
|
|
30418
|
+
const metadata3 = decodeZipHeader(bytes.subarray(positions[0]), true);
|
|
30419
|
+
return await this.getValidatedEntry(metadata3.localHeaderOffset, metadata3);
|
|
28867
30420
|
}
|
|
28868
30421
|
/** Looks up a canonical path; returns undefined when the entry is absent. */
|
|
28869
30422
|
async getEntry(path) {
|
|
28870
30423
|
this.signal.throwIfAborted();
|
|
28871
|
-
const
|
|
28872
|
-
if (!
|
|
30424
|
+
const metadata3 = (await this.getDirectory()).get(path);
|
|
30425
|
+
if (!metadata3) return void 0;
|
|
28873
30426
|
let promise = this.entriesByPath.get(path);
|
|
28874
30427
|
if (!promise) {
|
|
28875
|
-
promise = this.getValidatedEntry(
|
|
30428
|
+
promise = this.getValidatedEntry(metadata3.localHeaderOffset, metadata3).catch((error) => {
|
|
28876
30429
|
this.entriesByPath.delete(path);
|
|
28877
30430
|
throw error;
|
|
28878
30431
|
});
|
|
@@ -28889,14 +30442,14 @@ var init_zip_archive = __esm({
|
|
|
28889
30442
|
this.signal.throwIfAborted();
|
|
28890
30443
|
const existing = this.entriesByOffset.get(localHeaderOffset);
|
|
28891
30444
|
if (existing) return await existing;
|
|
28892
|
-
const
|
|
28893
|
-
if (
|
|
30445
|
+
const metadata3 = await this.readLocalHeader(localHeaderOffset);
|
|
30446
|
+
if (metadata3.header.flags & 8) {
|
|
28894
30447
|
for (const header of (await this.getDirectory()).values())
|
|
28895
30448
|
if (header.localHeaderOffset === localHeaderOffset)
|
|
28896
30449
|
return await this.getEntry(header.path);
|
|
28897
30450
|
throw new Error("Invalid ZIP archive: indexed offset missing from directory");
|
|
28898
30451
|
}
|
|
28899
|
-
return await this.getValidatedEntry(localHeaderOffset, void 0,
|
|
30452
|
+
return await this.getValidatedEntry(localHeaderOffset, void 0, metadata3);
|
|
28900
30453
|
}
|
|
28901
30454
|
/** Reads one complete entry and verifies its decoded size and CRC-32. */
|
|
28902
30455
|
async read(entryOrPath, options = {}) {
|
|
@@ -29146,31 +30699,31 @@ var init_zip_archive = __esm({
|
|
|
29146
30699
|
/** Validates local/central identity, payload bounds and signed or unsigned descriptors. */
|
|
29147
30700
|
async validateEntry(offset, central, localMetadata) {
|
|
29148
30701
|
const { header: local, dataOffset } = localMetadata ?? await this.readLocalHeader(offset);
|
|
29149
|
-
const
|
|
30702
|
+
const metadata3 = central || local;
|
|
29150
30703
|
const descriptor = Boolean(local.flags & 8);
|
|
29151
30704
|
if (central && (central.flags !== local.flags || central.method !== local.method || central.nameBytes.length !== local.nameBytes.length || central.nameBytes.some((value, index) => value !== local.nameBytes[index]) || !descriptor && (central.crc32 !== local.crc32 || central.size !== local.size || central.compressedSize !== local.compressedSize)))
|
|
29152
30705
|
throw new Error("Invalid ZIP archive: local/central metadata mismatch");
|
|
29153
|
-
if (
|
|
30706
|
+
if (metadata3.method === 0 && metadata3.size !== metadata3.compressedSize)
|
|
29154
30707
|
throw new Error("Invalid ZIP archive: STORE sizes mismatch");
|
|
29155
30708
|
if (central && descriptor && (local.crc32 !== 0 && local.crc32 !== central.crc32 || local.size !== 0n && local.size !== central.size || local.compressedSize !== 0n && local.compressedSize !== central.compressedSize))
|
|
29156
30709
|
throw new Error("Invalid ZIP archive: descriptor local/central metadata mismatch");
|
|
29157
|
-
const payloadEnd = dataOffset +
|
|
30710
|
+
const payloadEnd = dataOffset + metadata3.compressedSize;
|
|
29158
30711
|
const entryEnd = central ? this.nextOffsets.get(offset) ?? this.directory.offset : this.directory.offset;
|
|
29159
30712
|
if (payloadEnd > entryEnd) throw new Error("Invalid ZIP archive: payload overlaps directory");
|
|
29160
30713
|
if (descriptor)
|
|
29161
30714
|
await this.validateDescriptor(
|
|
29162
30715
|
payloadEnd,
|
|
29163
|
-
|
|
30716
|
+
metadata3,
|
|
29164
30717
|
local.zip64 || Boolean(central == null ? void 0 : central.zip64),
|
|
29165
30718
|
entryEnd
|
|
29166
30719
|
);
|
|
29167
30720
|
const entry = Object.freeze({
|
|
29168
|
-
path:
|
|
29169
|
-
directory:
|
|
29170
|
-
compression:
|
|
29171
|
-
size:
|
|
29172
|
-
compressedSize:
|
|
29173
|
-
crc32:
|
|
30721
|
+
path: metadata3.path,
|
|
30722
|
+
directory: metadata3.path.endsWith("/"),
|
|
30723
|
+
compression: metadata3.method === 0 ? "store" : "deflate",
|
|
30724
|
+
size: metadata3.size,
|
|
30725
|
+
compressedSize: metadata3.compressedSize,
|
|
30726
|
+
crc32: metadata3.crc32,
|
|
29174
30727
|
localHeaderOffset: offset,
|
|
29175
30728
|
dataOffset,
|
|
29176
30729
|
comment: (central == null ? void 0 : central.comment) || ""
|
|
@@ -29179,18 +30732,18 @@ var init_zip_archive = __esm({
|
|
|
29179
30732
|
return entry;
|
|
29180
30733
|
}
|
|
29181
30734
|
/** Resolves the optional descriptor signature using the expected CRC and sizes. */
|
|
29182
|
-
async validateDescriptor(offset,
|
|
30735
|
+
async validateDescriptor(offset, metadata3, zip64, entryEnd) {
|
|
29183
30736
|
const length = Number(minimumBigInt(24n, entryEnd - offset));
|
|
29184
30737
|
const bytes = new DataView(await this.readExact(offset, length));
|
|
29185
30738
|
for (const wide of zip64 ? [true, false] : [false, true]) {
|
|
29186
|
-
if (!wide && (
|
|
30739
|
+
if (!wide && (metadata3.size > 0xffffffffn || metadata3.compressedSize > 0xffffffffn)) continue;
|
|
29187
30740
|
const descriptorLength = wide ? 20 : 12;
|
|
29188
30741
|
for (const prefix of [4, 0]) {
|
|
29189
30742
|
if (length < prefix + descriptorLength || prefix && bytes.getUint32(0, true) !== 134695760)
|
|
29190
30743
|
continue;
|
|
29191
30744
|
const compressed = wide ? bytes.getBigUint64(prefix + 4, true) : BigInt(bytes.getUint32(prefix + 4, true));
|
|
29192
30745
|
const decoded = wide ? bytes.getBigUint64(prefix + 12, true) : BigInt(bytes.getUint32(prefix + 8, true));
|
|
29193
|
-
if (bytes.getUint32(prefix, true) ===
|
|
30746
|
+
if (bytes.getUint32(prefix, true) === metadata3.crc32 && compressed === metadata3.compressedSize && decoded === metadata3.size)
|
|
29194
30747
|
return;
|
|
29195
30748
|
}
|
|
29196
30749
|
}
|
|
@@ -29342,11 +30895,11 @@ var init_native_decompressor = __esm({
|
|
|
29342
30895
|
isSupported = true;
|
|
29343
30896
|
/** Runtime stream format used for every operation. */
|
|
29344
30897
|
format;
|
|
29345
|
-
constructor(
|
|
30898
|
+
constructor(metadata3, format, options = {}) {
|
|
29346
30899
|
super(options);
|
|
29347
|
-
this.name =
|
|
29348
|
-
this.extensions = [...
|
|
29349
|
-
this.contentEncodings = [...
|
|
30900
|
+
this.name = metadata3.name;
|
|
30901
|
+
this.extensions = [...metadata3.extensions];
|
|
30902
|
+
this.contentEncodings = [...metadata3.contentEncodings];
|
|
29350
30903
|
this.format = format;
|
|
29351
30904
|
}
|
|
29352
30905
|
/** Decompresses one buffer with the runtime-provided stream. */
|
|
@@ -29392,11 +30945,11 @@ var init_lazy_compression = __esm({
|
|
|
29392
30945
|
implementation = null;
|
|
29393
30946
|
/** Shared in-flight selection used by concurrent asynchronous calls. */
|
|
29394
30947
|
implementationPromise = null;
|
|
29395
|
-
constructor(
|
|
30948
|
+
constructor(metadata3, loadFallback, options = {}, nativeFormat = null, shouldUseNative = () => true) {
|
|
29396
30949
|
super(options);
|
|
29397
|
-
this.name =
|
|
29398
|
-
this.extensions = [...
|
|
29399
|
-
this.contentEncodings = [...
|
|
30950
|
+
this.name = metadata3.name;
|
|
30951
|
+
this.extensions = [...metadata3.extensions];
|
|
30952
|
+
this.contentEncodings = [...metadata3.contentEncodings];
|
|
29400
30953
|
this.options = options;
|
|
29401
30954
|
this.nativeFormat = nativeFormat;
|
|
29402
30955
|
this.shouldUseNative = shouldUseNative;
|
|
@@ -29704,12 +31257,12 @@ var init_i3s_slpk_loader_with_parser = __esm({
|
|
|
29704
31257
|
});
|
|
29705
31258
|
|
|
29706
31259
|
// dist/i3s/i3s-slpk-loader.js
|
|
29707
|
-
var
|
|
31260
|
+
var VERSION15, SLPKLoader;
|
|
29708
31261
|
var init_i3s_slpk_loader = __esm({
|
|
29709
31262
|
"dist/i3s/i3s-slpk-loader.js"() {
|
|
29710
31263
|
"use strict";
|
|
29711
31264
|
init_i3s_format();
|
|
29712
|
-
|
|
31265
|
+
VERSION15 = true ? "5.0.0-beta.6" : "latest";
|
|
29713
31266
|
SLPKLoader = {
|
|
29714
31267
|
...SLPKFormat,
|
|
29715
31268
|
dataType: null,
|
|
@@ -29717,7 +31270,7 @@ var init_i3s_slpk_loader = __esm({
|
|
|
29717
31270
|
name: "I3S SLPK (Scene Layer Package)",
|
|
29718
31271
|
id: "slpk",
|
|
29719
31272
|
module: "tiles-3d",
|
|
29720
|
-
version:
|
|
31273
|
+
version: VERSION15,
|
|
29721
31274
|
mimeTypes: ["application/octet-stream"],
|
|
29722
31275
|
extensions: ["slpk"],
|
|
29723
31276
|
options: {
|
|
@@ -29848,7 +31401,7 @@ function parseStringsAttribute(arrayBuffer, exactStrings = false) {
|
|
|
29848
31401
|
const stringSizes = new Uint32Array(arrayBuffer, dataOffset, stringsCount);
|
|
29849
31402
|
let stringOffset = dataOffset + stringsCount * bytesPerStringSize;
|
|
29850
31403
|
for (const stringByteSize of stringSizes) {
|
|
29851
|
-
const
|
|
31404
|
+
const textDecoder2 = new TextDecoder("utf-8");
|
|
29852
31405
|
const stringAttribute = new Uint8Array(arrayBuffer, stringOffset, stringByteSize);
|
|
29853
31406
|
if (exactStrings) {
|
|
29854
31407
|
if (stringByteSize === 0)
|
|
@@ -29859,7 +31412,7 @@ function parseStringsAttribute(arrayBuffer, exactStrings = false) {
|
|
|
29859
31412
|
stringsArray.push(new TextDecoder("utf-8", { fatal: true }).decode(stringAttribute.subarray(0, -1)));
|
|
29860
31413
|
}
|
|
29861
31414
|
} else
|
|
29862
|
-
stringsArray.push(
|
|
31415
|
+
stringsArray.push(textDecoder2.decode(stringAttribute));
|
|
29863
31416
|
stringOffset += stringByteSize;
|
|
29864
31417
|
}
|
|
29865
31418
|
if (exactStrings && (stringOffset !== arrayBuffer.byteLength || new DataView(arrayBuffer).getUint32(4, true) !== arrayBuffer.byteLength - dataOffset - stringsCount * bytesPerStringSize))
|
|
@@ -30045,12 +31598,12 @@ function getAttributeValueType2(attribute) {
|
|
|
30045
31598
|
}
|
|
30046
31599
|
return "";
|
|
30047
31600
|
}
|
|
30048
|
-
var
|
|
31601
|
+
var VERSION17, I3SAttributeLoader;
|
|
30049
31602
|
var init_i3s_attribute_loader = __esm({
|
|
30050
31603
|
"dist/i3s/i3s-attribute-loader.js"() {
|
|
30051
31604
|
"use strict";
|
|
30052
31605
|
init_i3s_format();
|
|
30053
|
-
|
|
31606
|
+
VERSION17 = true ? "5.0.0-beta.6" : "latest";
|
|
30054
31607
|
I3SAttributeLoader = {
|
|
30055
31608
|
...I3SAttributeFormat,
|
|
30056
31609
|
dataType: null,
|
|
@@ -30058,7 +31611,7 @@ var init_i3s_attribute_loader = __esm({
|
|
|
30058
31611
|
name: "I3S Attribute",
|
|
30059
31612
|
id: "i3s-attribute",
|
|
30060
31613
|
module: "tiles-3d",
|
|
30061
|
-
version:
|
|
31614
|
+
version: VERSION17,
|
|
30062
31615
|
mimeTypes: ["application/binary"],
|
|
30063
31616
|
/** Loads the parser-bearing I3S attribute loader implementation. */
|
|
30064
31617
|
preload: async () => (await Promise.resolve().then(() => (init_i3s_attribute_loader_with_parser(), i3s_attribute_loader_with_parser_exports))).I3SAttributeLoaderWithParser,
|
|
@@ -30137,12 +31690,12 @@ var init_i3s_building_scene_layer_loader_with_parser = __esm({
|
|
|
30137
31690
|
});
|
|
30138
31691
|
|
|
30139
31692
|
// dist/i3s/i3s-building-scene-layer-loader.js
|
|
30140
|
-
var
|
|
31693
|
+
var VERSION18, I3SBuildingSceneLayerLoader;
|
|
30141
31694
|
var init_i3s_building_scene_layer_loader = __esm({
|
|
30142
31695
|
"dist/i3s/i3s-building-scene-layer-loader.js"() {
|
|
30143
31696
|
"use strict";
|
|
30144
31697
|
init_i3s_format();
|
|
30145
|
-
|
|
31698
|
+
VERSION18 = true ? "5.0.0-beta.6" : "latest";
|
|
30146
31699
|
I3SBuildingSceneLayerLoader = {
|
|
30147
31700
|
...I3SBuildingSceneLayerFormat,
|
|
30148
31701
|
dataType: null,
|
|
@@ -30150,7 +31703,7 @@ var init_i3s_building_scene_layer_loader = __esm({
|
|
|
30150
31703
|
name: "I3S Building Scene Layer",
|
|
30151
31704
|
id: "i3s-building-scene-layer",
|
|
30152
31705
|
module: "tiles-3d",
|
|
30153
|
-
version:
|
|
31706
|
+
version: VERSION18,
|
|
30154
31707
|
mimeTypes: ["application/json"],
|
|
30155
31708
|
/** Loads the parser-bearing I3S building scene layer loader implementation. */
|
|
30156
31709
|
preload: async () => (await Promise.resolve().then(() => (init_i3s_building_scene_layer_loader_with_parser(), i3s_building_scene_layer_loader_with_parser_exports))).I3SBuildingSceneLayerLoaderWithParser,
|
|
@@ -30275,12 +31828,12 @@ var init_arcgis_webscene_loader_with_parser = __esm({
|
|
|
30275
31828
|
});
|
|
30276
31829
|
|
|
30277
31830
|
// dist/i3s/arcgis-webscene-loader.js
|
|
30278
|
-
var
|
|
31831
|
+
var VERSION19, ArcGISWebSceneLoader;
|
|
30279
31832
|
var init_arcgis_webscene_loader = __esm({
|
|
30280
31833
|
"dist/i3s/arcgis-webscene-loader.js"() {
|
|
30281
31834
|
"use strict";
|
|
30282
31835
|
init_i3s_format();
|
|
30283
|
-
|
|
31836
|
+
VERSION19 = true ? "5.0.0-beta.6" : "latest";
|
|
30284
31837
|
ArcGISWebSceneLoader = {
|
|
30285
31838
|
...ArcGISWebSceneFormat,
|
|
30286
31839
|
dataType: null,
|
|
@@ -30288,7 +31841,7 @@ var init_arcgis_webscene_loader = __esm({
|
|
|
30288
31841
|
name: "ArcGIS Web Scene Loader",
|
|
30289
31842
|
id: "arcgis-web-scene",
|
|
30290
31843
|
module: "tiles-3d",
|
|
30291
|
-
version:
|
|
31844
|
+
version: VERSION19,
|
|
30292
31845
|
mimeTypes: ["application/json"],
|
|
30293
31846
|
/** Loads the parser-bearing ArcGIS WebScene loader implementation. */
|
|
30294
31847
|
preload: async () => (await Promise.resolve().then(() => (init_arcgis_webscene_loader_with_parser(), arcgis_webscene_loader_with_parser_exports))).ArcGISWebSceneLoaderWithParser,
|
|
@@ -30460,11 +32013,11 @@ init_i3s_loader();
|
|
|
30460
32013
|
// dist/i3s/i3s-slpk-writer.js
|
|
30461
32014
|
init_indexed_zip_writer();
|
|
30462
32015
|
init_i3s_format();
|
|
30463
|
-
var
|
|
32016
|
+
var VERSION14 = true ? "5.0.0-beta.6" : "latest";
|
|
30464
32017
|
var MAX_ARCHIVE_BYTES = 2147483647;
|
|
30465
32018
|
var SLPKWriter = {
|
|
30466
32019
|
...SLPKFormat,
|
|
30467
|
-
version:
|
|
32020
|
+
version: VERSION14,
|
|
30468
32021
|
options: { slpk: { maxArchiveBytes: MAX_ARCHIVE_BYTES } },
|
|
30469
32022
|
encode: encodeArchive
|
|
30470
32023
|
};
|
|
@@ -30532,12 +32085,12 @@ init_i3s_content_loader();
|
|
|
30532
32085
|
|
|
30533
32086
|
// dist/i3s/i3s-lepcc-loader-types.js
|
|
30534
32087
|
init_i3s_format();
|
|
30535
|
-
var
|
|
32088
|
+
var VERSION16 = true ? "5.0.0-beta.6" : "latest";
|
|
30536
32089
|
var I3SLEPCCLoader = {
|
|
30537
32090
|
...I3SLEPCCFormat,
|
|
30538
32091
|
dataType: null,
|
|
30539
32092
|
batchType: null,
|
|
30540
|
-
version:
|
|
32093
|
+
version: VERSION16,
|
|
30541
32094
|
worker: true,
|
|
30542
32095
|
workerSourceNode: "i3s/workers/i3s-lepcc-worker-node.ts",
|
|
30543
32096
|
options: {
|
|
@@ -30740,7 +32293,7 @@ var I3SLEPCCDecoder = class {
|
|
|
30740
32293
|
* @returns Interleaved longitude, latitude, and elevation values.
|
|
30741
32294
|
*/
|
|
30742
32295
|
decodeXyz(bytes) {
|
|
30743
|
-
const reader = new
|
|
32296
|
+
const reader = new BinaryReader2(bytes);
|
|
30744
32297
|
const header = readHeader(reader, "LEPCC ", 104, this.verifyChecksum);
|
|
30745
32298
|
const extent = {
|
|
30746
32299
|
lower: [reader.readFloat64(), reader.readFloat64(), reader.readFloat64()],
|
|
@@ -30785,7 +32338,7 @@ var I3SLEPCCDecoder = class {
|
|
|
30785
32338
|
* @returns Interleaved 8-bit red, green, and blue values.
|
|
30786
32339
|
*/
|
|
30787
32340
|
decodeRgb(bytes) {
|
|
30788
|
-
const reader = new
|
|
32341
|
+
const reader = new BinaryReader2(bytes);
|
|
30789
32342
|
const header = readHeader(reader, "ClusterRGB", 32, this.verifyChecksum);
|
|
30790
32343
|
const pointCount = reader.readUint32();
|
|
30791
32344
|
const colorCount = reader.readUint16();
|
|
@@ -30834,7 +32387,7 @@ var I3SLEPCCDecoder = class {
|
|
|
30834
32387
|
* @returns One unsigned 16-bit intensity value per point.
|
|
30835
32388
|
*/
|
|
30836
32389
|
decodeIntensity(bytes) {
|
|
30837
|
-
const reader = new
|
|
32390
|
+
const reader = new BinaryReader2(bytes);
|
|
30838
32391
|
const header = readHeader(reader, "Intensity ", 32, this.verifyChecksum);
|
|
30839
32392
|
const pointCount = reader.readUint32();
|
|
30840
32393
|
const scaleFactor = reader.readUint16();
|
|
@@ -30871,7 +32424,7 @@ var I3SLEPCCDecoder = class {
|
|
|
30871
32424
|
* @returns One packed flag byte per point.
|
|
30872
32425
|
*/
|
|
30873
32426
|
decodeFlagBytes(bytes) {
|
|
30874
|
-
const reader = new
|
|
32427
|
+
const reader = new BinaryReader2(bytes);
|
|
30875
32428
|
const header = readHeader(reader, "FlagBytes ", 32, this.verifyChecksum);
|
|
30876
32429
|
const pointCount = reader.readUint32();
|
|
30877
32430
|
const compressionMethod = reader.readUint8();
|
|
@@ -30907,7 +32460,7 @@ var I3SLEPCCDecoder = class {
|
|
|
30907
32460
|
}
|
|
30908
32461
|
}
|
|
30909
32462
|
};
|
|
30910
|
-
var
|
|
32463
|
+
var BinaryReader2 = class {
|
|
30911
32464
|
bytes;
|
|
30912
32465
|
offset = 0;
|
|
30913
32466
|
constructor(bytes) {
|
|
@@ -31804,12 +33357,12 @@ function prepareI3SMeshTexture(attribute, vertexCount, texture) {
|
|
|
31804
33357
|
if (texture) {
|
|
31805
33358
|
if (!(texture.data instanceof Uint8Array) || Object.keys(texture).some((name22) => !["data", "mimeType", "sampler", "transform"].includes(name22)))
|
|
31806
33359
|
throw new Error("Invalid I3S base-color texture");
|
|
31807
|
-
let
|
|
33360
|
+
let metadata3;
|
|
31808
33361
|
try {
|
|
31809
|
-
|
|
33362
|
+
metadata3 = getBinaryImageMetadata(new DataView(texture.data.buffer, texture.data.byteOffset, texture.data.byteLength));
|
|
31810
33363
|
} catch {
|
|
31811
33364
|
}
|
|
31812
|
-
if (!
|
|
33365
|
+
if (!metadata3 || metadata3.mimeType !== texture.mimeType || !["image/png", "image/jpeg"].includes(texture.mimeType) || metadata3.width <= 0 || metadata3.height <= 0)
|
|
31813
33366
|
throw new Error("I3S texture header must match a PNG/JPEG mimeType and positive dimensions");
|
|
31814
33367
|
const sampler = texture.sampler;
|
|
31815
33368
|
if (sampler && (Object.keys(sampler).some((name22) => !["wrapS", "wrapT", "magFilter", "minFilter"].includes(name22)) || sampler.magFilter !== void 0 || sampler.minFilter !== void 0 || [sampler.wrapS, sampler.wrapT].some((value) => value !== void 0 && ![33071, 33648, 10497].includes(value))))
|