@loaders.gl/tiles-3d 5.0.0-beta.4 → 5.0.0-beta.5
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 +891 -620
- package/dist/3d-tiles/dist.min.js +37 -37
- package/dist/3d-tiles/index.cjs +821 -943
- 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 +820 -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 +24 -178
- package/dist/copc/index.cjs.map +3 -3
- package/dist/dist.dev.js +231 -38
- package/dist/dist.min.js +10 -10
- package/dist/i3s/arcgis-webscene-loader.js +1 -1
- package/dist/i3s/dist.dev.js +3080 -710
- 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 +1999 -541
- 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 +767 -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 +1748 -290
- package/dist/i3s-mesh-writer.cjs.map +3 -3
- package/dist/i3s-slpk-writer.cjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/point-cloud-tile-source-loader-types.js +1 -1
- package/dist/point-cloud-tile-source-loader.cjs +1 -1
- package/dist/potree/dist.dev.js +226 -82
- package/dist/potree/dist.min.js +30 -30
- package/dist/potree/index.cjs +13 -165
- 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-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/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();
|
|
@@ -1292,12 +1292,10 @@ var init_library_utils = __esm({
|
|
|
1292
1292
|
});
|
|
1293
1293
|
|
|
1294
1294
|
// ../core/src/worker-utils/index.ts
|
|
1295
|
-
var import_tasks3;
|
|
1296
1295
|
var init_worker_utils = __esm({
|
|
1297
1296
|
"../core/src/worker-utils/index.ts"() {
|
|
1298
1297
|
"use strict";
|
|
1299
1298
|
init_globals2();
|
|
1300
|
-
import_tasks3 = require("@math.gl/core/tasks");
|
|
1301
1299
|
init_process_on_worker();
|
|
1302
1300
|
init_library_utils();
|
|
1303
1301
|
}
|
|
@@ -1473,9 +1471,9 @@ var init_encode_array_buffer_to_base64 = __esm({
|
|
|
1473
1471
|
|
|
1474
1472
|
// ../core/src/loader-utils/lib/iterators/text-iterators.ts
|
|
1475
1473
|
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
1476
|
-
const
|
|
1474
|
+
const textDecoder2 = new TextDecoder(void 0, options);
|
|
1477
1475
|
for await (const arrayBuffer of arrayBufferIterator) {
|
|
1478
|
-
yield typeof arrayBuffer === "string" ? arrayBuffer :
|
|
1476
|
+
yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder2.decode(arrayBuffer, { stream: true });
|
|
1479
1477
|
}
|
|
1480
1478
|
}
|
|
1481
1479
|
async function* makeLineIterator(textIterator) {
|
|
@@ -3379,8 +3377,8 @@ function isSVG(url) {
|
|
|
3379
3377
|
}
|
|
3380
3378
|
function getBlobOrSVGDataUrl(arrayBuffer, url) {
|
|
3381
3379
|
if (isSVG(url)) {
|
|
3382
|
-
const
|
|
3383
|
-
let xmlText =
|
|
3380
|
+
const textDecoder2 = new TextDecoder();
|
|
3381
|
+
let xmlText = textDecoder2.decode(arrayBuffer);
|
|
3384
3382
|
try {
|
|
3385
3383
|
if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
|
|
3386
3384
|
xmlText = unescape(encodeURIComponent(xmlText));
|
|
@@ -5484,6 +5482,1418 @@ var init_src = __esm({
|
|
|
5484
5482
|
}
|
|
5485
5483
|
});
|
|
5486
5484
|
|
|
5485
|
+
// ../scene/src/usd/libs/usdc-parser.js
|
|
5486
|
+
function checkedLength(length, bytesPerElement = 8) {
|
|
5487
|
+
const byteLength = length * bytesPerElement;
|
|
5488
|
+
if (!Number.isSafeInteger(length) || length < 0 || !Number.isSafeInteger(byteLength) || byteLength > 256 * 1024 * 1024 - allocationBytes)
|
|
5489
|
+
throw new Error("USDC: decoded allocation limit exceeded");
|
|
5490
|
+
allocationBytes += byteLength;
|
|
5491
|
+
return length;
|
|
5492
|
+
}
|
|
5493
|
+
function checkedCount(count) {
|
|
5494
|
+
if (!Number.isSafeInteger(count) || count < 0 || count > 4e6)
|
|
5495
|
+
throw new Error("USDC: decoded allocation limit exceeded");
|
|
5496
|
+
return checkedLength(count);
|
|
5497
|
+
}
|
|
5498
|
+
function lz4DecompressBlock(input, inputOffset, inputEnd, output, outputOffset, outputEnd) {
|
|
5499
|
+
while (inputOffset < inputEnd) {
|
|
5500
|
+
const token = input[inputOffset++];
|
|
5501
|
+
if (inputOffset > inputEnd) throw new Error("USDC: truncated LZ4 token");
|
|
5502
|
+
let literalLength = token >> 4;
|
|
5503
|
+
if (literalLength === 15) {
|
|
5504
|
+
let b;
|
|
5505
|
+
do {
|
|
5506
|
+
if (inputOffset >= inputEnd) throw new Error("USDC: truncated LZ4 length");
|
|
5507
|
+
b = input[inputOffset++];
|
|
5508
|
+
literalLength += b;
|
|
5509
|
+
} while (b === 255);
|
|
5510
|
+
}
|
|
5511
|
+
if (literalLength > 0) {
|
|
5512
|
+
if (inputOffset + literalLength > inputEnd) {
|
|
5513
|
+
throw new Error("USDC: truncated LZ4 literal");
|
|
5514
|
+
}
|
|
5515
|
+
for (let i = 0; i < literalLength; i++) {
|
|
5516
|
+
if (outputOffset >= outputEnd) throw new Error("USDC: LZ4 output overflow");
|
|
5517
|
+
output[outputOffset++] = input[inputOffset++];
|
|
5518
|
+
}
|
|
5519
|
+
}
|
|
5520
|
+
if (inputOffset >= inputEnd) break;
|
|
5521
|
+
if (inputOffset + 2 > inputEnd) throw new Error("USDC: truncated LZ4 offset");
|
|
5522
|
+
const matchOffset = input[inputOffset++] | input[inputOffset++] << 8;
|
|
5523
|
+
if (matchOffset === 0) {
|
|
5524
|
+
throw new Error("USDC: invalid LZ4 match offset");
|
|
5525
|
+
}
|
|
5526
|
+
let matchLength = (token & 15) + 4;
|
|
5527
|
+
if (matchLength === 19) {
|
|
5528
|
+
let b;
|
|
5529
|
+
do {
|
|
5530
|
+
if (inputOffset >= inputEnd) throw new Error("USDC: truncated LZ4 length");
|
|
5531
|
+
b = input[inputOffset++];
|
|
5532
|
+
matchLength += b;
|
|
5533
|
+
} while (b === 255);
|
|
5534
|
+
}
|
|
5535
|
+
const matchPos = outputOffset - matchOffset;
|
|
5536
|
+
if (matchPos < 0) {
|
|
5537
|
+
throw new Error("USDC: invalid LZ4 match position");
|
|
5538
|
+
}
|
|
5539
|
+
for (let i = 0; i < matchLength; i++) {
|
|
5540
|
+
if (outputOffset >= outputEnd) throw new Error("USDC: LZ4 output overflow");
|
|
5541
|
+
output[outputOffset++] = output[matchPos + i];
|
|
5542
|
+
}
|
|
5543
|
+
}
|
|
5544
|
+
return outputOffset;
|
|
5545
|
+
}
|
|
5546
|
+
function decompressLZ4(input, uncompressedSize, allowShortOutput = false) {
|
|
5547
|
+
const output = new Uint8Array(checkedLength(uncompressedSize, 1));
|
|
5548
|
+
if (!input.length) throw new Error("USDC: missing LZ4 chunk header");
|
|
5549
|
+
const numChunks = input[0];
|
|
5550
|
+
if (numChunks === 0) {
|
|
5551
|
+
const written = lz4DecompressBlock(input, 1, input.length, output, 0, uncompressedSize);
|
|
5552
|
+
if (!allowShortOutput && written !== uncompressedSize)
|
|
5553
|
+
throw new Error("USDC: incomplete LZ4 output");
|
|
5554
|
+
return output.subarray(0, written);
|
|
5555
|
+
} else {
|
|
5556
|
+
const CHUNK_SIZE = 65536;
|
|
5557
|
+
if (1 + numChunks * 4 > input.length) throw new Error("USDC: truncated LZ4 chunk sizes");
|
|
5558
|
+
let headerOffset = 1;
|
|
5559
|
+
const compressedSizes = [];
|
|
5560
|
+
for (let i = 0; i < numChunks; i++) {
|
|
5561
|
+
const size = (input[headerOffset] | input[headerOffset + 1] << 8 | input[headerOffset + 2] << 16 | input[headerOffset + 3] << 24) >>> 0;
|
|
5562
|
+
compressedSizes.push(size);
|
|
5563
|
+
headerOffset += 4;
|
|
5564
|
+
}
|
|
5565
|
+
let inputOffset = headerOffset;
|
|
5566
|
+
let outputOffset = 0;
|
|
5567
|
+
for (let i = 0; i < numChunks; i++) {
|
|
5568
|
+
const chunkCompressedSize = compressedSizes[i];
|
|
5569
|
+
const chunkOutputSize = Math.min(CHUNK_SIZE, uncompressedSize - outputOffset);
|
|
5570
|
+
if (chunkCompressedSize > input.length - inputOffset)
|
|
5571
|
+
throw new Error("USDC: truncated LZ4 chunk");
|
|
5572
|
+
const written = lz4DecompressBlock(
|
|
5573
|
+
input,
|
|
5574
|
+
inputOffset,
|
|
5575
|
+
inputOffset + chunkCompressedSize,
|
|
5576
|
+
output,
|
|
5577
|
+
outputOffset,
|
|
5578
|
+
outputOffset + chunkOutputSize
|
|
5579
|
+
);
|
|
5580
|
+
inputOffset += chunkCompressedSize;
|
|
5581
|
+
if (i < numChunks - 1 && written !== outputOffset + chunkOutputSize)
|
|
5582
|
+
throw new Error("USDC: incomplete LZ4 chunk");
|
|
5583
|
+
outputOffset = written;
|
|
5584
|
+
}
|
|
5585
|
+
if (inputOffset !== input.length || !allowShortOutput && outputOffset !== uncompressedSize)
|
|
5586
|
+
throw new Error("USDC: incomplete LZ4 output");
|
|
5587
|
+
return output.subarray(0, outputOffset);
|
|
5588
|
+
}
|
|
5589
|
+
}
|
|
5590
|
+
function decompressIntegers32(compressedData, numInts) {
|
|
5591
|
+
const encodedSize = numInts * 4 + (numInts * 2 + 7 >> 3) + 4;
|
|
5592
|
+
const encoded = decompressLZ4(new Uint8Array(compressedData), encodedSize, true);
|
|
5593
|
+
return decodeIntegers32(encoded, numInts);
|
|
5594
|
+
}
|
|
5595
|
+
function decodeIntegers32(data, numInts) {
|
|
5596
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
5597
|
+
let offset = 0;
|
|
5598
|
+
const commonValue = view.getInt32(offset, true);
|
|
5599
|
+
offset += 4;
|
|
5600
|
+
const numCodesBytes = numInts * 2 + 7 >> 3;
|
|
5601
|
+
if (data.length < offset + numCodesBytes) throw new Error("USDC: truncated integer codes");
|
|
5602
|
+
const codesStart = offset;
|
|
5603
|
+
const vintsStart = offset + numCodesBytes;
|
|
5604
|
+
const result = new Int32Array(checkedLength(numInts));
|
|
5605
|
+
let prevVal = 0;
|
|
5606
|
+
let codesOffset = codesStart;
|
|
5607
|
+
let vintsOffset = vintsStart;
|
|
5608
|
+
for (let i = 0; i < numInts; ) {
|
|
5609
|
+
const codeByte = data[codesOffset++];
|
|
5610
|
+
for (let j = 0; j < 4 && i < numInts; j++, i++) {
|
|
5611
|
+
const code = codeByte >> j * 2 & 3;
|
|
5612
|
+
let delta = 0;
|
|
5613
|
+
switch (code) {
|
|
5614
|
+
case 0:
|
|
5615
|
+
delta = commonValue;
|
|
5616
|
+
break;
|
|
5617
|
+
case 1:
|
|
5618
|
+
delta = view.getInt8(vintsOffset);
|
|
5619
|
+
vintsOffset += 1;
|
|
5620
|
+
break;
|
|
5621
|
+
case 2:
|
|
5622
|
+
delta = view.getInt16(vintsOffset, true);
|
|
5623
|
+
vintsOffset += 2;
|
|
5624
|
+
break;
|
|
5625
|
+
case 3:
|
|
5626
|
+
delta = view.getInt32(vintsOffset, true);
|
|
5627
|
+
vintsOffset += 4;
|
|
5628
|
+
break;
|
|
5629
|
+
}
|
|
5630
|
+
prevVal += delta;
|
|
5631
|
+
result[i] = prevVal;
|
|
5632
|
+
}
|
|
5633
|
+
}
|
|
5634
|
+
return result;
|
|
5635
|
+
}
|
|
5636
|
+
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;
|
|
5637
|
+
var init_usdc_parser = __esm({
|
|
5638
|
+
"../scene/src/usd/libs/usdc-parser.js"() {
|
|
5639
|
+
"use strict";
|
|
5640
|
+
allocationBytes = 0;
|
|
5641
|
+
textDecoder = new TextDecoder();
|
|
5642
|
+
HALF_EXPONENT_TABLE = new Float32Array(32);
|
|
5643
|
+
for (let i = 0; i < 32; i++) {
|
|
5644
|
+
HALF_EXPONENT_TABLE[i] = Math.pow(2, i - 15);
|
|
5645
|
+
}
|
|
5646
|
+
HALF_DENORM_SCALE = Math.pow(2, -14);
|
|
5647
|
+
TypeEnum = {
|
|
5648
|
+
Invalid: 0,
|
|
5649
|
+
Bool: 1,
|
|
5650
|
+
UChar: 2,
|
|
5651
|
+
Int: 3,
|
|
5652
|
+
UInt: 4,
|
|
5653
|
+
Int64: 5,
|
|
5654
|
+
UInt64: 6,
|
|
5655
|
+
Half: 7,
|
|
5656
|
+
Float: 8,
|
|
5657
|
+
Double: 9,
|
|
5658
|
+
String: 10,
|
|
5659
|
+
Token: 11,
|
|
5660
|
+
AssetPath: 12,
|
|
5661
|
+
Matrix2d: 13,
|
|
5662
|
+
Matrix3d: 14,
|
|
5663
|
+
Matrix4d: 15,
|
|
5664
|
+
Quatd: 16,
|
|
5665
|
+
Quatf: 17,
|
|
5666
|
+
Quath: 18,
|
|
5667
|
+
Vec2d: 19,
|
|
5668
|
+
Vec2f: 20,
|
|
5669
|
+
Vec2h: 21,
|
|
5670
|
+
Vec2i: 22,
|
|
5671
|
+
Vec3d: 23,
|
|
5672
|
+
Vec3f: 24,
|
|
5673
|
+
Vec3h: 25,
|
|
5674
|
+
Vec3i: 26,
|
|
5675
|
+
Vec4d: 27,
|
|
5676
|
+
Vec4f: 28,
|
|
5677
|
+
Vec4h: 29,
|
|
5678
|
+
Vec4i: 30,
|
|
5679
|
+
Dictionary: 31,
|
|
5680
|
+
TokenListOp: 32,
|
|
5681
|
+
StringListOp: 33,
|
|
5682
|
+
PathListOp: 34,
|
|
5683
|
+
ReferenceListOp: 35,
|
|
5684
|
+
IntListOp: 36,
|
|
5685
|
+
Int64ListOp: 37,
|
|
5686
|
+
UIntListOp: 38,
|
|
5687
|
+
UInt64ListOp: 39,
|
|
5688
|
+
PathVector: 40,
|
|
5689
|
+
TokenVector: 41,
|
|
5690
|
+
Specifier: 42,
|
|
5691
|
+
Permission: 43,
|
|
5692
|
+
Variability: 44,
|
|
5693
|
+
VariantSelectionMap: 45,
|
|
5694
|
+
TimeSamples: 46,
|
|
5695
|
+
Payload: 47,
|
|
5696
|
+
DoubleVector: 48,
|
|
5697
|
+
LayerOffsetVector: 49,
|
|
5698
|
+
StringVector: 50,
|
|
5699
|
+
ValueBlock: 51,
|
|
5700
|
+
Value: 52,
|
|
5701
|
+
UnregisteredValue: 53,
|
|
5702
|
+
UnregisteredValueListOp: 54,
|
|
5703
|
+
PayloadListOp: 55,
|
|
5704
|
+
TimeCode: 56,
|
|
5705
|
+
PathExpression: 57,
|
|
5706
|
+
Relocates: 58,
|
|
5707
|
+
Spline: 59,
|
|
5708
|
+
AnimationBlock: 60
|
|
5709
|
+
};
|
|
5710
|
+
DICTIONARY_ARRAY_TYPES = /* @__PURE__ */ new Set([
|
|
5711
|
+
TypeEnum.Int,
|
|
5712
|
+
TypeEnum.UInt,
|
|
5713
|
+
TypeEnum.Float,
|
|
5714
|
+
TypeEnum.Double,
|
|
5715
|
+
TypeEnum.Half,
|
|
5716
|
+
TypeEnum.String,
|
|
5717
|
+
TypeEnum.Token
|
|
5718
|
+
]);
|
|
5719
|
+
FIELD_SET_TERMINATOR = 4294967295;
|
|
5720
|
+
FLOAT_COMPRESSION_INT = 105;
|
|
5721
|
+
FLOAT_COMPRESSION_LUT = 116;
|
|
5722
|
+
BinaryReader = class {
|
|
5723
|
+
constructor(buffer) {
|
|
5724
|
+
this.buffer = buffer;
|
|
5725
|
+
this.view = new DataView(buffer);
|
|
5726
|
+
this.offset = 0;
|
|
5727
|
+
}
|
|
5728
|
+
seek(offset) {
|
|
5729
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset > this.buffer.byteLength)
|
|
5730
|
+
throw new Error("USDC: invalid seek");
|
|
5731
|
+
this.offset = offset;
|
|
5732
|
+
}
|
|
5733
|
+
tell() {
|
|
5734
|
+
return this.offset;
|
|
5735
|
+
}
|
|
5736
|
+
readUint8() {
|
|
5737
|
+
const value = this.view.getUint8(this.offset);
|
|
5738
|
+
this.offset += 1;
|
|
5739
|
+
return value;
|
|
5740
|
+
}
|
|
5741
|
+
readInt8() {
|
|
5742
|
+
const value = this.view.getInt8(this.offset);
|
|
5743
|
+
this.offset += 1;
|
|
5744
|
+
return value;
|
|
5745
|
+
}
|
|
5746
|
+
readUint16() {
|
|
5747
|
+
const value = this.view.getUint16(this.offset, true);
|
|
5748
|
+
this.offset += 2;
|
|
5749
|
+
return value;
|
|
5750
|
+
}
|
|
5751
|
+
readInt16() {
|
|
5752
|
+
const value = this.view.getInt16(this.offset, true);
|
|
5753
|
+
this.offset += 2;
|
|
5754
|
+
return value;
|
|
5755
|
+
}
|
|
5756
|
+
readUint32() {
|
|
5757
|
+
const value = this.view.getUint32(this.offset, true);
|
|
5758
|
+
this.offset += 4;
|
|
5759
|
+
return value;
|
|
5760
|
+
}
|
|
5761
|
+
readInt32() {
|
|
5762
|
+
const value = this.view.getInt32(this.offset, true);
|
|
5763
|
+
this.offset += 4;
|
|
5764
|
+
return value;
|
|
5765
|
+
}
|
|
5766
|
+
readUint64() {
|
|
5767
|
+
const lo = this.view.getUint32(this.offset, true);
|
|
5768
|
+
const hi = this.view.getUint32(this.offset + 4, true);
|
|
5769
|
+
this.offset += 8;
|
|
5770
|
+
const result = hi * 4294967296 + lo;
|
|
5771
|
+
if (!Number.isSafeInteger(result)) throw new Error("USDC: integer exceeds safe precision");
|
|
5772
|
+
return result;
|
|
5773
|
+
}
|
|
5774
|
+
readInt64() {
|
|
5775
|
+
const lo = this.view.getUint32(this.offset, true);
|
|
5776
|
+
const hi = this.view.getInt32(this.offset + 4, true);
|
|
5777
|
+
this.offset += 8;
|
|
5778
|
+
const result = hi * 4294967296 + lo;
|
|
5779
|
+
if (!Number.isSafeInteger(result)) throw new Error("USDC: integer exceeds safe precision");
|
|
5780
|
+
return result;
|
|
5781
|
+
}
|
|
5782
|
+
readFloat32() {
|
|
5783
|
+
const value = this.view.getFloat32(this.offset, true);
|
|
5784
|
+
this.offset += 4;
|
|
5785
|
+
return value;
|
|
5786
|
+
}
|
|
5787
|
+
readFloat64() {
|
|
5788
|
+
const value = this.view.getFloat64(this.offset, true);
|
|
5789
|
+
this.offset += 8;
|
|
5790
|
+
return value;
|
|
5791
|
+
}
|
|
5792
|
+
readBytes(length) {
|
|
5793
|
+
const bytes = new Uint8Array(this.buffer, this.offset, length);
|
|
5794
|
+
this.offset += length;
|
|
5795
|
+
return bytes;
|
|
5796
|
+
}
|
|
5797
|
+
readString(length) {
|
|
5798
|
+
const bytes = this.readBytes(length);
|
|
5799
|
+
let end = 0;
|
|
5800
|
+
while (end < length && bytes[end] !== 0) end++;
|
|
5801
|
+
return textDecoder.decode(bytes.subarray(0, end));
|
|
5802
|
+
}
|
|
5803
|
+
};
|
|
5804
|
+
ValueRep = class {
|
|
5805
|
+
constructor(lo, hi) {
|
|
5806
|
+
this.lo = lo;
|
|
5807
|
+
this.hi = hi;
|
|
5808
|
+
}
|
|
5809
|
+
get isArray() {
|
|
5810
|
+
return (this.hi & 2147483648) !== 0;
|
|
5811
|
+
}
|
|
5812
|
+
get isInlined() {
|
|
5813
|
+
return (this.hi & 1073741824) !== 0;
|
|
5814
|
+
}
|
|
5815
|
+
get isCompressed() {
|
|
5816
|
+
return (this.hi & 536870912) !== 0;
|
|
5817
|
+
}
|
|
5818
|
+
get typeEnum() {
|
|
5819
|
+
return this.hi >> 16 & 255;
|
|
5820
|
+
}
|
|
5821
|
+
get payload() {
|
|
5822
|
+
return this.lo + (this.hi & 65535) * 4294967296;
|
|
5823
|
+
}
|
|
5824
|
+
getInlinedValue() {
|
|
5825
|
+
return this.lo;
|
|
5826
|
+
}
|
|
5827
|
+
};
|
|
5828
|
+
USDCParser = class {
|
|
5829
|
+
/**
|
|
5830
|
+
* Parse USDC file and return raw spec data without building Three.js scene.
|
|
5831
|
+
* Used by USDComposer for unified scene composition.
|
|
5832
|
+
*/
|
|
5833
|
+
parseData(buffer) {
|
|
5834
|
+
allocationBytes = 0;
|
|
5835
|
+
this._valueReadCount = 0;
|
|
5836
|
+
this._activeDictionaries = /* @__PURE__ */ new Set();
|
|
5837
|
+
this.buffer = buffer instanceof ArrayBuffer ? buffer : buffer.buffer;
|
|
5838
|
+
this.reader = new BinaryReader(this.buffer);
|
|
5839
|
+
this.version = { major: 0, minor: 0, patch: 0 };
|
|
5840
|
+
this._conversionBuffer = new ArrayBuffer(4);
|
|
5841
|
+
this._conversionView = new DataView(this._conversionBuffer);
|
|
5842
|
+
this._readBootstrap();
|
|
5843
|
+
this._readTOC();
|
|
5844
|
+
this._readTokens();
|
|
5845
|
+
this._readStrings();
|
|
5846
|
+
this._readFields();
|
|
5847
|
+
this._readFieldSets();
|
|
5848
|
+
this._readPaths();
|
|
5849
|
+
this._readSpecs();
|
|
5850
|
+
this.specsByPath = /* @__PURE__ */ Object.create(null);
|
|
5851
|
+
for (const spec of this.specs) {
|
|
5852
|
+
const path = this.paths[spec.pathIndex];
|
|
5853
|
+
if (!path) continue;
|
|
5854
|
+
const fields = this._getFieldsForSpec(spec);
|
|
5855
|
+
this.specsByPath[path] = { specType: spec.specType, fields };
|
|
5856
|
+
}
|
|
5857
|
+
return { specsByPath: this.specsByPath };
|
|
5858
|
+
}
|
|
5859
|
+
_readBootstrap() {
|
|
5860
|
+
const reader = this.reader;
|
|
5861
|
+
reader.seek(0);
|
|
5862
|
+
const magic = reader.readString(8);
|
|
5863
|
+
if (magic !== "PXR-USDC") {
|
|
5864
|
+
throw new Error("THREE.USDCParser: Not a valid USDC file.");
|
|
5865
|
+
}
|
|
5866
|
+
this.version.major = reader.readUint8();
|
|
5867
|
+
this.version.minor = reader.readUint8();
|
|
5868
|
+
this.version.patch = reader.readUint8();
|
|
5869
|
+
reader.readBytes(5);
|
|
5870
|
+
this.tocOffset = reader.readUint64();
|
|
5871
|
+
}
|
|
5872
|
+
_readTOC() {
|
|
5873
|
+
const reader = this.reader;
|
|
5874
|
+
reader.seek(this.tocOffset);
|
|
5875
|
+
const numSections = reader.readUint64();
|
|
5876
|
+
if (numSections > 16) throw new Error("USDC: invalid section count");
|
|
5877
|
+
this.sections = /* @__PURE__ */ Object.create(null);
|
|
5878
|
+
for (let i = 0; i < numSections; i++) {
|
|
5879
|
+
const name22 = reader.readString(16);
|
|
5880
|
+
const start = reader.readUint64();
|
|
5881
|
+
const size = reader.readUint64();
|
|
5882
|
+
this.sections[name22] = { start, size };
|
|
5883
|
+
}
|
|
5884
|
+
}
|
|
5885
|
+
_readTokens() {
|
|
5886
|
+
const section = this.sections["TOKENS"];
|
|
5887
|
+
if (!section) return;
|
|
5888
|
+
const reader = this.reader;
|
|
5889
|
+
reader.seek(section.start);
|
|
5890
|
+
const numTokens = checkedCount(reader.readUint64());
|
|
5891
|
+
this.tokens = [];
|
|
5892
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
5893
|
+
const tokensNumBytes = reader.readUint64();
|
|
5894
|
+
const tokensData = reader.readBytes(tokensNumBytes);
|
|
5895
|
+
let strStart = 0;
|
|
5896
|
+
for (let i = 0; i < numTokens; i++) {
|
|
5897
|
+
let strEnd = strStart;
|
|
5898
|
+
while (strEnd < tokensData.length && tokensData[strEnd] !== 0) strEnd++;
|
|
5899
|
+
if (strEnd >= tokensData.length) throw new Error("USDC: unterminated token data");
|
|
5900
|
+
this.tokens.push(textDecoder.decode(tokensData.subarray(strStart, strEnd)));
|
|
5901
|
+
strStart = strEnd + 1;
|
|
5902
|
+
}
|
|
5903
|
+
} else {
|
|
5904
|
+
const uncompressedSize = reader.readUint64();
|
|
5905
|
+
const compressedSize = reader.readUint64();
|
|
5906
|
+
const compressedData = reader.readBytes(compressedSize);
|
|
5907
|
+
const tokensData = decompressLZ4(compressedData, uncompressedSize);
|
|
5908
|
+
checkedLength(tokensData.length, 2);
|
|
5909
|
+
let strStart = 0;
|
|
5910
|
+
for (let i = 0; i < numTokens; i++) {
|
|
5911
|
+
let strEnd = strStart;
|
|
5912
|
+
while (strEnd < tokensData.length && tokensData[strEnd] !== 0) strEnd++;
|
|
5913
|
+
if (strEnd >= tokensData.length) throw new Error("USDC: unterminated token data");
|
|
5914
|
+
this.tokens.push(textDecoder.decode(tokensData.subarray(strStart, strEnd)));
|
|
5915
|
+
strStart = strEnd + 1;
|
|
5916
|
+
}
|
|
5917
|
+
}
|
|
5918
|
+
}
|
|
5919
|
+
_readStrings() {
|
|
5920
|
+
const section = this.sections["STRINGS"];
|
|
5921
|
+
if (!section) {
|
|
5922
|
+
this.strings = [];
|
|
5923
|
+
return;
|
|
5924
|
+
}
|
|
5925
|
+
const reader = this.reader;
|
|
5926
|
+
reader.seek(section.start);
|
|
5927
|
+
const numStrings = checkedCount(reader.readUint64());
|
|
5928
|
+
this.strings = [];
|
|
5929
|
+
for (let i = 0; i < numStrings; i++) {
|
|
5930
|
+
this.strings.push(reader.readUint32());
|
|
5931
|
+
}
|
|
5932
|
+
}
|
|
5933
|
+
_readFields() {
|
|
5934
|
+
const section = this.sections["FIELDS"];
|
|
5935
|
+
if (!section) return;
|
|
5936
|
+
const reader = this.reader;
|
|
5937
|
+
reader.seek(section.start);
|
|
5938
|
+
this.fields = [];
|
|
5939
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
5940
|
+
const numFields = Math.floor(section.size / 12);
|
|
5941
|
+
for (let i = 0; i < numFields; i++) {
|
|
5942
|
+
const tokenIndex = reader.readUint32();
|
|
5943
|
+
const repLo = reader.readUint32();
|
|
5944
|
+
const repHi = reader.readUint32();
|
|
5945
|
+
this.fields.push({
|
|
5946
|
+
tokenIndex,
|
|
5947
|
+
valueRep: new ValueRep(repLo, repHi)
|
|
5948
|
+
});
|
|
5949
|
+
}
|
|
5950
|
+
} else {
|
|
5951
|
+
const numFields = checkedCount(reader.readUint64());
|
|
5952
|
+
const tokenIndicesCompressedSize = reader.readUint64();
|
|
5953
|
+
const tokenIndicesCompressed = reader.readBytes(tokenIndicesCompressedSize);
|
|
5954
|
+
const tokenIndices = decompressIntegers32(
|
|
5955
|
+
tokenIndicesCompressed.buffer.slice(
|
|
5956
|
+
tokenIndicesCompressed.byteOffset,
|
|
5957
|
+
tokenIndicesCompressed.byteOffset + tokenIndicesCompressedSize
|
|
5958
|
+
),
|
|
5959
|
+
numFields
|
|
5960
|
+
);
|
|
5961
|
+
const repsCompressedSize = reader.readUint64();
|
|
5962
|
+
const repsCompressed = reader.readBytes(repsCompressedSize);
|
|
5963
|
+
const repsData = decompressLZ4(repsCompressed, numFields * 8);
|
|
5964
|
+
const repsView = new DataView(repsData.buffer, repsData.byteOffset, repsData.byteLength);
|
|
5965
|
+
for (let i = 0; i < numFields; i++) {
|
|
5966
|
+
const repLo = repsView.getUint32(i * 8, true);
|
|
5967
|
+
const repHi = repsView.getUint32(i * 8 + 4, true);
|
|
5968
|
+
this.fields.push({
|
|
5969
|
+
tokenIndex: tokenIndices[i],
|
|
5970
|
+
valueRep: new ValueRep(repLo, repHi)
|
|
5971
|
+
});
|
|
5972
|
+
}
|
|
5973
|
+
}
|
|
5974
|
+
}
|
|
5975
|
+
_readFieldSets() {
|
|
5976
|
+
const section = this.sections["FIELDSETS"];
|
|
5977
|
+
if (!section) return;
|
|
5978
|
+
const reader = this.reader;
|
|
5979
|
+
reader.seek(section.start);
|
|
5980
|
+
this.fieldSets = [];
|
|
5981
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
5982
|
+
const numFieldSets = Math.floor(section.size / 4);
|
|
5983
|
+
for (let i = 0; i < numFieldSets; i++) {
|
|
5984
|
+
this.fieldSets.push(reader.readUint32());
|
|
5985
|
+
}
|
|
5986
|
+
} else {
|
|
5987
|
+
const numFieldSets = checkedCount(reader.readUint64());
|
|
5988
|
+
const compressedSize = reader.readUint64();
|
|
5989
|
+
const compressed = reader.readBytes(compressedSize);
|
|
5990
|
+
const indices = decompressIntegers32(
|
|
5991
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
5992
|
+
numFieldSets
|
|
5993
|
+
);
|
|
5994
|
+
for (let i = 0; i < numFieldSets; i++) {
|
|
5995
|
+
this.fieldSets.push(indices[i]);
|
|
5996
|
+
}
|
|
5997
|
+
}
|
|
5998
|
+
}
|
|
5999
|
+
_readPaths() {
|
|
6000
|
+
const section = this.sections["PATHS"];
|
|
6001
|
+
if (!section) return;
|
|
6002
|
+
const reader = this.reader;
|
|
6003
|
+
reader.seek(section.start);
|
|
6004
|
+
const numPaths = checkedCount(reader.readUint64());
|
|
6005
|
+
this.paths = new Array(checkedLength(numPaths)).fill("");
|
|
6006
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
6007
|
+
this._readPathsRecursive("");
|
|
6008
|
+
} else {
|
|
6009
|
+
reader.readUint64();
|
|
6010
|
+
const compressedSize1 = reader.readUint64();
|
|
6011
|
+
const pathIndicesCompressed = reader.readBytes(compressedSize1);
|
|
6012
|
+
const pathIndices = decompressIntegers32(
|
|
6013
|
+
pathIndicesCompressed.buffer.slice(
|
|
6014
|
+
pathIndicesCompressed.byteOffset,
|
|
6015
|
+
pathIndicesCompressed.byteOffset + compressedSize1
|
|
6016
|
+
),
|
|
6017
|
+
numPaths
|
|
6018
|
+
);
|
|
6019
|
+
const compressedSize2 = reader.readUint64();
|
|
6020
|
+
const elementTokenIndicesCompressed = reader.readBytes(compressedSize2);
|
|
6021
|
+
const elementTokenIndices = decompressIntegers32(
|
|
6022
|
+
elementTokenIndicesCompressed.buffer.slice(
|
|
6023
|
+
elementTokenIndicesCompressed.byteOffset,
|
|
6024
|
+
elementTokenIndicesCompressed.byteOffset + compressedSize2
|
|
6025
|
+
),
|
|
6026
|
+
numPaths
|
|
6027
|
+
);
|
|
6028
|
+
const compressedSize3 = reader.readUint64();
|
|
6029
|
+
const jumpsCompressed = reader.readBytes(compressedSize3);
|
|
6030
|
+
const jumps = decompressIntegers32(
|
|
6031
|
+
jumpsCompressed.buffer.slice(
|
|
6032
|
+
jumpsCompressed.byteOffset,
|
|
6033
|
+
jumpsCompressed.byteOffset + compressedSize3
|
|
6034
|
+
),
|
|
6035
|
+
numPaths
|
|
6036
|
+
);
|
|
6037
|
+
this._buildPathsFromCompressed(pathIndices, elementTokenIndices, jumps);
|
|
6038
|
+
}
|
|
6039
|
+
}
|
|
6040
|
+
_readPathsRecursive(parentPath, depth = 0) {
|
|
6041
|
+
const reader = this.reader;
|
|
6042
|
+
if (depth > 1e3) return;
|
|
6043
|
+
const index = reader.readUint32();
|
|
6044
|
+
const elementTokenIndex = reader.readUint32();
|
|
6045
|
+
const bits = reader.readUint8();
|
|
6046
|
+
const hasChild = (bits & 1) !== 0;
|
|
6047
|
+
const hasSibling = (bits & 2) !== 0;
|
|
6048
|
+
const isPrimProperty = (bits & 4) !== 0;
|
|
6049
|
+
let path;
|
|
6050
|
+
if (parentPath === "") {
|
|
6051
|
+
path = "/";
|
|
6052
|
+
} else {
|
|
6053
|
+
const elemToken = this.tokens[elementTokenIndex] || "";
|
|
6054
|
+
if (isPrimProperty) {
|
|
6055
|
+
path = parentPath + "." + elemToken;
|
|
6056
|
+
} else {
|
|
6057
|
+
path = parentPath === "/" ? "/" + elemToken : parentPath + "/" + elemToken;
|
|
6058
|
+
}
|
|
6059
|
+
}
|
|
6060
|
+
checkedLength(path.length, 2);
|
|
6061
|
+
this.paths[index] = path;
|
|
6062
|
+
if (hasChild && hasSibling) {
|
|
6063
|
+
const siblingOffset = reader.readUint64();
|
|
6064
|
+
this._readPathsRecursive(path, depth + 1);
|
|
6065
|
+
reader.seek(siblingOffset);
|
|
6066
|
+
this._readPathsRecursive(parentPath, depth + 1);
|
|
6067
|
+
} else if (hasChild) {
|
|
6068
|
+
this._readPathsRecursive(path, depth + 1);
|
|
6069
|
+
} else if (hasSibling) {
|
|
6070
|
+
this._readPathsRecursive(parentPath, depth + 1);
|
|
6071
|
+
}
|
|
6072
|
+
}
|
|
6073
|
+
/** Rebuilds compressed paths with an explicit stack instead of sibling recursion. */
|
|
6074
|
+
_buildPathsFromCompressed(pathIndices, elementTokenIndices, jumps) {
|
|
6075
|
+
let traversalCount = 0;
|
|
6076
|
+
const pendingPaths = [{ startIndex: 0, parentPath: "" }];
|
|
6077
|
+
while (pendingPaths.length) {
|
|
6078
|
+
const pendingPath = pendingPaths.pop();
|
|
6079
|
+
let currentIndex = pendingPath.startIndex;
|
|
6080
|
+
let parentPath = pendingPath.parentPath;
|
|
6081
|
+
while (currentIndex < pathIndices.length) {
|
|
6082
|
+
if (++traversalCount > pathIndices.length * 2)
|
|
6083
|
+
throw new Error("USDC: path traversal limit exceeded");
|
|
6084
|
+
const nodeIndex = currentIndex++;
|
|
6085
|
+
const pathIndex = pathIndices[nodeIndex];
|
|
6086
|
+
const elementTokenIndex = elementTokenIndices[nodeIndex];
|
|
6087
|
+
const jump = jumps[nodeIndex];
|
|
6088
|
+
if (pathIndex < 0 || pathIndex >= this.paths.length || Math.abs(elementTokenIndex) >= this.tokens.length || jump < -2)
|
|
6089
|
+
throw new Error("USDC: invalid compressed path index");
|
|
6090
|
+
let path;
|
|
6091
|
+
if (parentPath === "") {
|
|
6092
|
+
path = "/";
|
|
6093
|
+
parentPath = path;
|
|
6094
|
+
} else {
|
|
6095
|
+
const elementToken = this.tokens[Math.abs(elementTokenIndex)];
|
|
6096
|
+
path = elementTokenIndex < 0 ? parentPath + "." + elementToken : parentPath === "/" ? "/" + elementToken : parentPath + "/" + elementToken;
|
|
6097
|
+
}
|
|
6098
|
+
checkedLength(path.length, 2);
|
|
6099
|
+
this.paths[pathIndex] = path;
|
|
6100
|
+
const hasChild = jump > 0 || jump === -1;
|
|
6101
|
+
const hasSibling = jump >= 0;
|
|
6102
|
+
if ((hasChild || hasSibling) && currentIndex >= pathIndices.length)
|
|
6103
|
+
throw new Error("USDC: missing compressed path entry");
|
|
6104
|
+
if (hasChild && hasSibling) {
|
|
6105
|
+
const siblingIndex = nodeIndex + jump;
|
|
6106
|
+
if (siblingIndex <= currentIndex || siblingIndex >= pathIndices.length)
|
|
6107
|
+
throw new Error("USDC: invalid compressed path jump");
|
|
6108
|
+
pendingPaths.push({ startIndex: siblingIndex, parentPath });
|
|
6109
|
+
}
|
|
6110
|
+
if (hasChild) parentPath = path;
|
|
6111
|
+
else if (!hasSibling) break;
|
|
6112
|
+
}
|
|
6113
|
+
}
|
|
6114
|
+
}
|
|
6115
|
+
_readSpecs() {
|
|
6116
|
+
const section = this.sections["SPECS"];
|
|
6117
|
+
if (!section) return;
|
|
6118
|
+
const reader = this.reader;
|
|
6119
|
+
reader.seek(section.start);
|
|
6120
|
+
this.specs = [];
|
|
6121
|
+
if (this.version.major === 0 && this.version.minor < 4) {
|
|
6122
|
+
const specSize = this.version.minor === 0 && this.version.patch === 1 ? 16 : 12;
|
|
6123
|
+
const numSpecs = Math.floor(section.size / specSize);
|
|
6124
|
+
for (let i = 0; i < numSpecs; i++) {
|
|
6125
|
+
const pathIndex = reader.readUint32();
|
|
6126
|
+
const fieldSetIndex = reader.readUint32();
|
|
6127
|
+
const specType = reader.readUint32();
|
|
6128
|
+
if (specSize === 16) reader.readUint32();
|
|
6129
|
+
this.specs.push({ pathIndex, fieldSetIndex, specType });
|
|
6130
|
+
}
|
|
6131
|
+
} else {
|
|
6132
|
+
const numSpecs = checkedCount(reader.readUint64());
|
|
6133
|
+
const compressedSize1 = reader.readUint64();
|
|
6134
|
+
const pathIndicesCompressed = reader.readBytes(compressedSize1);
|
|
6135
|
+
const pathIndices = decompressIntegers32(
|
|
6136
|
+
pathIndicesCompressed.buffer.slice(
|
|
6137
|
+
pathIndicesCompressed.byteOffset,
|
|
6138
|
+
pathIndicesCompressed.byteOffset + compressedSize1
|
|
6139
|
+
),
|
|
6140
|
+
numSpecs
|
|
6141
|
+
);
|
|
6142
|
+
const compressedSize2 = reader.readUint64();
|
|
6143
|
+
const fieldSetIndicesCompressed = reader.readBytes(compressedSize2);
|
|
6144
|
+
const fieldSetIndices = decompressIntegers32(
|
|
6145
|
+
fieldSetIndicesCompressed.buffer.slice(
|
|
6146
|
+
fieldSetIndicesCompressed.byteOffset,
|
|
6147
|
+
fieldSetIndicesCompressed.byteOffset + compressedSize2
|
|
6148
|
+
),
|
|
6149
|
+
numSpecs
|
|
6150
|
+
);
|
|
6151
|
+
const compressedSize3 = reader.readUint64();
|
|
6152
|
+
const specTypesCompressed = reader.readBytes(compressedSize3);
|
|
6153
|
+
const specTypes = decompressIntegers32(
|
|
6154
|
+
specTypesCompressed.buffer.slice(
|
|
6155
|
+
specTypesCompressed.byteOffset,
|
|
6156
|
+
specTypesCompressed.byteOffset + compressedSize3
|
|
6157
|
+
),
|
|
6158
|
+
numSpecs
|
|
6159
|
+
);
|
|
6160
|
+
for (let i = 0; i < numSpecs; i++) {
|
|
6161
|
+
this.specs.push({
|
|
6162
|
+
pathIndex: pathIndices[i],
|
|
6163
|
+
fieldSetIndex: fieldSetIndices[i],
|
|
6164
|
+
specType: specTypes[i]
|
|
6165
|
+
});
|
|
6166
|
+
}
|
|
6167
|
+
}
|
|
6168
|
+
}
|
|
6169
|
+
// ========================================================================
|
|
6170
|
+
// Value Reading
|
|
6171
|
+
// ========================================================================
|
|
6172
|
+
_readValue(valueRep) {
|
|
6173
|
+
this._valueReadCount = (this._valueReadCount || 0) + 1;
|
|
6174
|
+
if (this._valueReadCount > 1e6) throw new Error("USDC: value traversal limit exceeded");
|
|
6175
|
+
const type = valueRep.typeEnum;
|
|
6176
|
+
const isArray = valueRep.isArray;
|
|
6177
|
+
const isInlined = valueRep.isInlined;
|
|
6178
|
+
if (type === TypeEnum.TimeSamples) {
|
|
6179
|
+
return this._readTimeSamples(valueRep);
|
|
6180
|
+
}
|
|
6181
|
+
if (isInlined) {
|
|
6182
|
+
return this._readInlinedValue(valueRep);
|
|
6183
|
+
}
|
|
6184
|
+
const offset = valueRep.payload;
|
|
6185
|
+
if (offset === 0 && isArray) {
|
|
6186
|
+
return [];
|
|
6187
|
+
}
|
|
6188
|
+
if (offset < 0 || offset >= this.buffer.byteLength) {
|
|
6189
|
+
throw new RangeError(
|
|
6190
|
+
"USDCParser: Invalid payload offset " + offset + " for type " + type + "."
|
|
6191
|
+
);
|
|
6192
|
+
}
|
|
6193
|
+
const savedOffset = this.reader.tell();
|
|
6194
|
+
this.reader.seek(offset);
|
|
6195
|
+
let value;
|
|
6196
|
+
if (isArray) {
|
|
6197
|
+
value = this._readArrayValue(valueRep);
|
|
6198
|
+
} else {
|
|
6199
|
+
value = this._readScalarValue(type);
|
|
6200
|
+
}
|
|
6201
|
+
this.reader.seek(savedOffset);
|
|
6202
|
+
return value;
|
|
6203
|
+
}
|
|
6204
|
+
_readInlinedValue(valueRep) {
|
|
6205
|
+
const type = valueRep.typeEnum;
|
|
6206
|
+
const payload = valueRep.getInlinedValue();
|
|
6207
|
+
const view = this._conversionView;
|
|
6208
|
+
switch (type) {
|
|
6209
|
+
case TypeEnum.Dictionary:
|
|
6210
|
+
if (payload !== 0) throw new Error("USDC: invalid inline dictionary");
|
|
6211
|
+
return /* @__PURE__ */ Object.create(null);
|
|
6212
|
+
case TypeEnum.Bool:
|
|
6213
|
+
return payload !== 0;
|
|
6214
|
+
case TypeEnum.UChar:
|
|
6215
|
+
return payload & 255;
|
|
6216
|
+
case TypeEnum.Int:
|
|
6217
|
+
case TypeEnum.Int64:
|
|
6218
|
+
return payload | 0;
|
|
6219
|
+
case TypeEnum.UInt:
|
|
6220
|
+
case TypeEnum.UInt64:
|
|
6221
|
+
return payload >>> 0;
|
|
6222
|
+
case TypeEnum.Half:
|
|
6223
|
+
return this._halfToFloat(payload & 65535);
|
|
6224
|
+
case TypeEnum.Float: {
|
|
6225
|
+
view.setUint32(0, payload, true);
|
|
6226
|
+
return view.getFloat32(0, true);
|
|
6227
|
+
}
|
|
6228
|
+
case TypeEnum.Double: {
|
|
6229
|
+
view.setUint32(0, payload, true);
|
|
6230
|
+
return view.getFloat32(0, true);
|
|
6231
|
+
}
|
|
6232
|
+
case TypeEnum.Token:
|
|
6233
|
+
return this.tokens[payload] || "";
|
|
6234
|
+
case TypeEnum.String:
|
|
6235
|
+
return this.tokens[this.strings[payload]] || "";
|
|
6236
|
+
case TypeEnum.AssetPath:
|
|
6237
|
+
return this.tokens[payload] || "";
|
|
6238
|
+
case TypeEnum.Specifier:
|
|
6239
|
+
return payload;
|
|
6240
|
+
// 0=def, 1=over, 2=class
|
|
6241
|
+
case TypeEnum.Permission:
|
|
6242
|
+
case TypeEnum.Variability:
|
|
6243
|
+
return payload;
|
|
6244
|
+
// Vec2h: Two half-floats fit in 4 bytes, stored directly
|
|
6245
|
+
case TypeEnum.Vec2h: {
|
|
6246
|
+
view.setUint32(0, payload, true);
|
|
6247
|
+
return [
|
|
6248
|
+
this._halfToFloat(view.getUint16(0, true)),
|
|
6249
|
+
this._halfToFloat(view.getUint16(2, true))
|
|
6250
|
+
];
|
|
6251
|
+
}
|
|
6252
|
+
// Inlined vectors that don't fit in 4 bytes are encoded as signed 8-bit integers
|
|
6253
|
+
// Vec2f = 8 bytes (2x float32), Vec3f = 12 bytes, Vec4f = 16 bytes, etc.
|
|
6254
|
+
case TypeEnum.Vec2f:
|
|
6255
|
+
case TypeEnum.Vec2i: {
|
|
6256
|
+
view.setUint32(0, payload, true);
|
|
6257
|
+
return [view.getInt8(0), view.getInt8(1)];
|
|
6258
|
+
}
|
|
6259
|
+
case TypeEnum.Vec3f:
|
|
6260
|
+
case TypeEnum.Vec3i: {
|
|
6261
|
+
view.setUint32(0, payload, true);
|
|
6262
|
+
return [view.getInt8(0), view.getInt8(1), view.getInt8(2)];
|
|
6263
|
+
}
|
|
6264
|
+
case TypeEnum.Vec4f:
|
|
6265
|
+
case TypeEnum.Vec4i: {
|
|
6266
|
+
view.setUint32(0, payload, true);
|
|
6267
|
+
return [view.getInt8(0), view.getInt8(1), view.getInt8(2), view.getInt8(3)];
|
|
6268
|
+
}
|
|
6269
|
+
case TypeEnum.Matrix2d: {
|
|
6270
|
+
view.setUint32(0, payload, true);
|
|
6271
|
+
const d0 = view.getInt8(0), d1 = view.getInt8(1);
|
|
6272
|
+
return [d0, 0, 0, d1];
|
|
6273
|
+
}
|
|
6274
|
+
case TypeEnum.Matrix3d: {
|
|
6275
|
+
view.setUint32(0, payload, true);
|
|
6276
|
+
const d0 = view.getInt8(0), d1 = view.getInt8(1), d2 = view.getInt8(2);
|
|
6277
|
+
return [d0, 0, 0, 0, d1, 0, 0, 0, d2];
|
|
6278
|
+
}
|
|
6279
|
+
case TypeEnum.Matrix4d: {
|
|
6280
|
+
view.setUint32(0, payload, true);
|
|
6281
|
+
const d0 = view.getInt8(0), d1 = view.getInt8(1), d2 = view.getInt8(2), d3 = view.getInt8(3);
|
|
6282
|
+
return [d0, 0, 0, 0, 0, d1, 0, 0, 0, 0, d2, 0, 0, 0, 0, d3];
|
|
6283
|
+
}
|
|
6284
|
+
default:
|
|
6285
|
+
throw new Error("USDC: unsupported inline value type " + type);
|
|
6286
|
+
}
|
|
6287
|
+
}
|
|
6288
|
+
_readTimeSamples(valueRep) {
|
|
6289
|
+
const reader = this.reader;
|
|
6290
|
+
const offset = valueRep.payload;
|
|
6291
|
+
const savedOffset = reader.tell();
|
|
6292
|
+
reader.seek(offset);
|
|
6293
|
+
const timesStart = reader.tell();
|
|
6294
|
+
const timesRelOffset = reader.readInt64();
|
|
6295
|
+
reader.seek(timesStart + timesRelOffset);
|
|
6296
|
+
const timesRepLo = reader.readUint32();
|
|
6297
|
+
const timesRepHi = reader.readUint32();
|
|
6298
|
+
const timesRep = new ValueRep(timesRepLo, timesRepHi);
|
|
6299
|
+
const times = this._readValue(timesRep);
|
|
6300
|
+
const afterTimesRep = timesStart + timesRelOffset + 8;
|
|
6301
|
+
reader.seek(afterTimesRep);
|
|
6302
|
+
const valuesStart = reader.tell();
|
|
6303
|
+
const valuesRelOffset = reader.readInt64();
|
|
6304
|
+
reader.seek(valuesStart + valuesRelOffset);
|
|
6305
|
+
const numValues = checkedCount(reader.readUint64());
|
|
6306
|
+
const valueReps = [];
|
|
6307
|
+
for (let i = 0; i < numValues; i++) {
|
|
6308
|
+
const repLo = reader.readUint32();
|
|
6309
|
+
const repHi = reader.readUint32();
|
|
6310
|
+
valueReps.push(new ValueRep(repLo, repHi));
|
|
6311
|
+
}
|
|
6312
|
+
const values = [];
|
|
6313
|
+
for (let i = 0; i < numValues; i++) {
|
|
6314
|
+
values.push(this._readValue(valueReps[i]));
|
|
6315
|
+
}
|
|
6316
|
+
reader.seek(savedOffset);
|
|
6317
|
+
const timesArray = times instanceof Float64Array ? Array.from(times) : Array.isArray(times) ? times : [times];
|
|
6318
|
+
return { times: timesArray, values };
|
|
6319
|
+
}
|
|
6320
|
+
_readScalarValue(type) {
|
|
6321
|
+
const reader = this.reader;
|
|
6322
|
+
switch (type) {
|
|
6323
|
+
case TypeEnum.Invalid:
|
|
6324
|
+
return null;
|
|
6325
|
+
case TypeEnum.Bool:
|
|
6326
|
+
return reader.readUint8() !== 0;
|
|
6327
|
+
case TypeEnum.UChar:
|
|
6328
|
+
return reader.readUint8();
|
|
6329
|
+
case TypeEnum.Int:
|
|
6330
|
+
return reader.readInt32();
|
|
6331
|
+
case TypeEnum.UInt:
|
|
6332
|
+
return reader.readUint32();
|
|
6333
|
+
case TypeEnum.Int64:
|
|
6334
|
+
return reader.readInt64();
|
|
6335
|
+
case TypeEnum.UInt64:
|
|
6336
|
+
return reader.readUint64();
|
|
6337
|
+
case TypeEnum.Half:
|
|
6338
|
+
return this._readHalf();
|
|
6339
|
+
case TypeEnum.Float:
|
|
6340
|
+
return reader.readFloat32();
|
|
6341
|
+
case TypeEnum.Double:
|
|
6342
|
+
return reader.readFloat64();
|
|
6343
|
+
case TypeEnum.String:
|
|
6344
|
+
case TypeEnum.Token: {
|
|
6345
|
+
const index = reader.readUint32();
|
|
6346
|
+
return this.tokens[index] || "";
|
|
6347
|
+
}
|
|
6348
|
+
case TypeEnum.AssetPath: {
|
|
6349
|
+
const index = reader.readUint32();
|
|
6350
|
+
return this.tokens[index] || "";
|
|
6351
|
+
}
|
|
6352
|
+
case TypeEnum.Vec2f:
|
|
6353
|
+
return [reader.readFloat32(), reader.readFloat32()];
|
|
6354
|
+
case TypeEnum.Vec2d:
|
|
6355
|
+
return [reader.readFloat64(), reader.readFloat64()];
|
|
6356
|
+
case TypeEnum.Vec2i:
|
|
6357
|
+
return [reader.readInt32(), reader.readInt32()];
|
|
6358
|
+
case TypeEnum.Vec3f:
|
|
6359
|
+
return [reader.readFloat32(), reader.readFloat32(), reader.readFloat32()];
|
|
6360
|
+
case TypeEnum.Vec3d:
|
|
6361
|
+
return [reader.readFloat64(), reader.readFloat64(), reader.readFloat64()];
|
|
6362
|
+
case TypeEnum.Vec3i:
|
|
6363
|
+
return [reader.readInt32(), reader.readInt32(), reader.readInt32()];
|
|
6364
|
+
case TypeEnum.Vec4f:
|
|
6365
|
+
return [
|
|
6366
|
+
reader.readFloat32(),
|
|
6367
|
+
reader.readFloat32(),
|
|
6368
|
+
reader.readFloat32(),
|
|
6369
|
+
reader.readFloat32()
|
|
6370
|
+
];
|
|
6371
|
+
case TypeEnum.Vec4d:
|
|
6372
|
+
return [
|
|
6373
|
+
reader.readFloat64(),
|
|
6374
|
+
reader.readFloat64(),
|
|
6375
|
+
reader.readFloat64(),
|
|
6376
|
+
reader.readFloat64()
|
|
6377
|
+
];
|
|
6378
|
+
case TypeEnum.Quatf:
|
|
6379
|
+
return [
|
|
6380
|
+
reader.readFloat32(),
|
|
6381
|
+
reader.readFloat32(),
|
|
6382
|
+
reader.readFloat32(),
|
|
6383
|
+
reader.readFloat32()
|
|
6384
|
+
];
|
|
6385
|
+
case TypeEnum.Quatd:
|
|
6386
|
+
return [
|
|
6387
|
+
reader.readFloat64(),
|
|
6388
|
+
reader.readFloat64(),
|
|
6389
|
+
reader.readFloat64(),
|
|
6390
|
+
reader.readFloat64()
|
|
6391
|
+
];
|
|
6392
|
+
case TypeEnum.Matrix4d: {
|
|
6393
|
+
const m = [];
|
|
6394
|
+
for (let i = 0; i < 16; i++) m.push(reader.readFloat64());
|
|
6395
|
+
return m;
|
|
6396
|
+
}
|
|
6397
|
+
case TypeEnum.TokenVector: {
|
|
6398
|
+
const count = checkedCount(reader.readUint64());
|
|
6399
|
+
const tokens = [];
|
|
6400
|
+
for (let i = 0; i < count; i++) {
|
|
6401
|
+
const index = reader.readUint32();
|
|
6402
|
+
tokens.push(this.tokens[index] || "");
|
|
6403
|
+
}
|
|
6404
|
+
return tokens;
|
|
6405
|
+
}
|
|
6406
|
+
case TypeEnum.PathVector: {
|
|
6407
|
+
const count = checkedCount(reader.readUint64());
|
|
6408
|
+
const paths = [];
|
|
6409
|
+
for (let i = 0; i < count; i++) {
|
|
6410
|
+
const index = reader.readUint32();
|
|
6411
|
+
paths.push(this.paths[index] || "");
|
|
6412
|
+
}
|
|
6413
|
+
return paths;
|
|
6414
|
+
}
|
|
6415
|
+
case TypeEnum.DoubleVector: {
|
|
6416
|
+
const count = checkedCount(reader.readUint64());
|
|
6417
|
+
const arr = new Float64Array(checkedLength(count));
|
|
6418
|
+
for (let i = 0; i < count; i++) arr[i] = reader.readFloat64();
|
|
6419
|
+
return arr;
|
|
6420
|
+
}
|
|
6421
|
+
case TypeEnum.Dictionary:
|
|
6422
|
+
return this._readDictionary();
|
|
6423
|
+
case TypeEnum.TokenListOp:
|
|
6424
|
+
case TypeEnum.StringListOp:
|
|
6425
|
+
case TypeEnum.IntListOp:
|
|
6426
|
+
case TypeEnum.Int64ListOp:
|
|
6427
|
+
case TypeEnum.UIntListOp:
|
|
6428
|
+
case TypeEnum.UInt64ListOp:
|
|
6429
|
+
throw new Error("USDC: value list operations are unsupported");
|
|
6430
|
+
case TypeEnum.PathListOp: {
|
|
6431
|
+
const flags = reader.readUint8();
|
|
6432
|
+
if (flags & 24 || (flags & 102).toString(2).replaceAll("0", "").length > 1)
|
|
6433
|
+
throw new Error("USDC: compound path list operations are unsupported");
|
|
6434
|
+
const hasExplicitItems = (flags & 2) !== 0;
|
|
6435
|
+
const hasAddItems = (flags & 4) !== 0;
|
|
6436
|
+
const hasDeleteItems = (flags & 8) !== 0;
|
|
6437
|
+
const hasReorderItems = (flags & 16) !== 0;
|
|
6438
|
+
const hasPrependItems = (flags & 32) !== 0;
|
|
6439
|
+
const hasAppendItems = (flags & 64) !== 0;
|
|
6440
|
+
const readPathList = () => {
|
|
6441
|
+
const itemCount = checkedCount(reader.readUint64());
|
|
6442
|
+
const paths = [];
|
|
6443
|
+
for (let i = 0; i < itemCount; i++) {
|
|
6444
|
+
const pathIdx = reader.readUint32();
|
|
6445
|
+
paths.push(this.paths[pathIdx]);
|
|
6446
|
+
}
|
|
6447
|
+
return paths;
|
|
6448
|
+
};
|
|
6449
|
+
let explicitPaths = null;
|
|
6450
|
+
let addPaths = null;
|
|
6451
|
+
let prependPaths = null;
|
|
6452
|
+
let appendPaths = null;
|
|
6453
|
+
if (hasExplicitItems) explicitPaths = readPathList();
|
|
6454
|
+
if (hasAddItems) addPaths = readPathList();
|
|
6455
|
+
if (hasPrependItems) prependPaths = readPathList();
|
|
6456
|
+
if (hasAppendItems) appendPaths = readPathList();
|
|
6457
|
+
if (hasDeleteItems) readPathList();
|
|
6458
|
+
if (hasReorderItems) readPathList();
|
|
6459
|
+
if (prependPaths && prependPaths.length > 0) return prependPaths;
|
|
6460
|
+
if (explicitPaths && explicitPaths.length > 0) return explicitPaths;
|
|
6461
|
+
if (appendPaths && appendPaths.length > 0) return appendPaths;
|
|
6462
|
+
if (addPaths && addPaths.length > 0) return addPaths;
|
|
6463
|
+
return null;
|
|
6464
|
+
}
|
|
6465
|
+
case TypeEnum.VariantSelectionMap: {
|
|
6466
|
+
const elementCount = checkedCount(reader.readUint64());
|
|
6467
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
6468
|
+
for (let i = 0; i < elementCount; i++) {
|
|
6469
|
+
const keyIdx = reader.readUint32();
|
|
6470
|
+
const valueIdx = reader.readUint32();
|
|
6471
|
+
const key = this.tokens[this.strings[keyIdx]];
|
|
6472
|
+
const value = this.tokens[this.strings[valueIdx]];
|
|
6473
|
+
if (key && value) map[key] = value;
|
|
6474
|
+
}
|
|
6475
|
+
return map;
|
|
6476
|
+
}
|
|
6477
|
+
default:
|
|
6478
|
+
throw new Error(
|
|
6479
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unsupported scalar type", type].join(" ")
|
|
6480
|
+
);
|
|
6481
|
+
}
|
|
6482
|
+
}
|
|
6483
|
+
/** Reads bounded string-keyed dictionary entries and their recursive value representations. */
|
|
6484
|
+
_readDictionary() {
|
|
6485
|
+
const reader = this.reader;
|
|
6486
|
+
const dictionaryOffset = reader.tell();
|
|
6487
|
+
this._activeDictionaries ||= /* @__PURE__ */ new Set();
|
|
6488
|
+
if (this._activeDictionaries.has(dictionaryOffset))
|
|
6489
|
+
throw new Error("USDC: cyclic dictionary value");
|
|
6490
|
+
if (this._activeDictionaries.size >= 64)
|
|
6491
|
+
throw new Error("USDC: dictionary depth limit exceeded");
|
|
6492
|
+
this._activeDictionaries.add(dictionaryOffset);
|
|
6493
|
+
try {
|
|
6494
|
+
const count = checkedCount(reader.readUint64());
|
|
6495
|
+
if (count > Math.floor((this.buffer.byteLength - reader.tell()) / 20))
|
|
6496
|
+
throw new Error("USDC: truncated dictionary entries");
|
|
6497
|
+
const dictionary = /* @__PURE__ */ Object.create(null);
|
|
6498
|
+
for (let index = 0; index < count; index++) {
|
|
6499
|
+
const stringIndex = reader.readUint32();
|
|
6500
|
+
const key = this.tokens[this.strings[stringIndex]];
|
|
6501
|
+
if (typeof key !== "string" || Object.hasOwn(dictionary, key))
|
|
6502
|
+
throw new Error("USDC: invalid dictionary key");
|
|
6503
|
+
const offsetLocation = reader.tell();
|
|
6504
|
+
const relativeOffset = reader.readInt64();
|
|
6505
|
+
if (relativeOffset < 8) throw new Error("USDC: invalid dictionary value offset");
|
|
6506
|
+
reader.seek(offsetLocation + relativeOffset);
|
|
6507
|
+
const representation = new ValueRep(reader.readUint32(), reader.readUint32());
|
|
6508
|
+
if (representation.typeEnum < TypeEnum.Bool || representation.typeEnum > TypeEnum.AssetPath && representation.typeEnum !== TypeEnum.Dictionary || representation.isArray && !DICTIONARY_ARRAY_TYPES.has(representation.typeEnum))
|
|
6509
|
+
throw new Error("USDC: unsupported dictionary value type");
|
|
6510
|
+
const nextEntry = reader.tell();
|
|
6511
|
+
const value = this._readValue(representation);
|
|
6512
|
+
dictionary[key] = representation.typeEnum === TypeEnum.AssetPath ? { assetPath: value } : value;
|
|
6513
|
+
reader.seek(nextEntry);
|
|
6514
|
+
}
|
|
6515
|
+
return dictionary;
|
|
6516
|
+
} finally {
|
|
6517
|
+
this._activeDictionaries.delete(dictionaryOffset);
|
|
6518
|
+
}
|
|
6519
|
+
}
|
|
6520
|
+
_readArrayValue(valueRep) {
|
|
6521
|
+
const reader = this.reader;
|
|
6522
|
+
const type = valueRep.typeEnum;
|
|
6523
|
+
const isCompressed = valueRep.isCompressed;
|
|
6524
|
+
let size;
|
|
6525
|
+
if (this.version.major === 0 && this.version.minor < 7) {
|
|
6526
|
+
size = reader.readUint32();
|
|
6527
|
+
} else {
|
|
6528
|
+
size = reader.readUint64();
|
|
6529
|
+
}
|
|
6530
|
+
if (!Number.isSafeInteger(size) || size < 0) {
|
|
6531
|
+
throw new RangeError("USDCParser: Invalid array size " + size + " for type " + type + ".");
|
|
6532
|
+
}
|
|
6533
|
+
if (size > 2147483647) {
|
|
6534
|
+
throw new RangeError("USDCParser: Array size " + size + " exceeds implementation limits.");
|
|
6535
|
+
}
|
|
6536
|
+
size = checkedCount(size);
|
|
6537
|
+
if (size === 0) return [];
|
|
6538
|
+
if (isCompressed) {
|
|
6539
|
+
return this._readCompressedArray(type, size);
|
|
6540
|
+
}
|
|
6541
|
+
switch (type) {
|
|
6542
|
+
case TypeEnum.Int: {
|
|
6543
|
+
const arr = new Int32Array(checkedLength(size));
|
|
6544
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readInt32();
|
|
6545
|
+
return arr;
|
|
6546
|
+
}
|
|
6547
|
+
case TypeEnum.UInt: {
|
|
6548
|
+
const arr = new Uint32Array(checkedLength(size));
|
|
6549
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readUint32();
|
|
6550
|
+
return arr;
|
|
6551
|
+
}
|
|
6552
|
+
case TypeEnum.Float: {
|
|
6553
|
+
const arr = new Float32Array(checkedLength(size));
|
|
6554
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readFloat32();
|
|
6555
|
+
return arr;
|
|
6556
|
+
}
|
|
6557
|
+
case TypeEnum.Double: {
|
|
6558
|
+
const arr = new Float64Array(checkedLength(size));
|
|
6559
|
+
for (let i = 0; i < size; i++) arr[i] = reader.readFloat64();
|
|
6560
|
+
return arr;
|
|
6561
|
+
}
|
|
6562
|
+
case TypeEnum.Vec2f: {
|
|
6563
|
+
const arr = new Float32Array(checkedLength(size * 2));
|
|
6564
|
+
for (let i = 0; i < size * 2; i++) arr[i] = reader.readFloat32();
|
|
6565
|
+
return arr;
|
|
6566
|
+
}
|
|
6567
|
+
case TypeEnum.Vec3f: {
|
|
6568
|
+
const arr = new Float32Array(checkedLength(size * 3));
|
|
6569
|
+
for (let i = 0; i < size * 3; i++) arr[i] = reader.readFloat32();
|
|
6570
|
+
return arr;
|
|
6571
|
+
}
|
|
6572
|
+
case TypeEnum.Vec4f: {
|
|
6573
|
+
const arr = new Float32Array(checkedLength(size * 4));
|
|
6574
|
+
for (let i = 0; i < size * 4; i++) arr[i] = reader.readFloat32();
|
|
6575
|
+
return arr;
|
|
6576
|
+
}
|
|
6577
|
+
case TypeEnum.Vec3h: {
|
|
6578
|
+
const arr = new Float32Array(checkedLength(size * 3));
|
|
6579
|
+
for (let i = 0; i < size * 3; i++) arr[i] = this._readHalf();
|
|
6580
|
+
return arr;
|
|
6581
|
+
}
|
|
6582
|
+
case TypeEnum.Quatf: {
|
|
6583
|
+
const arr = new Float32Array(checkedLength(size * 4));
|
|
6584
|
+
for (let i = 0; i < size * 4; i++) arr[i] = reader.readFloat32();
|
|
6585
|
+
return arr;
|
|
6586
|
+
}
|
|
6587
|
+
case TypeEnum.Quath: {
|
|
6588
|
+
const arr = new Float32Array(checkedLength(size * 4));
|
|
6589
|
+
for (let i = 0; i < size * 4; i++) arr[i] = this._readHalf();
|
|
6590
|
+
return arr;
|
|
6591
|
+
}
|
|
6592
|
+
case TypeEnum.Matrix4d: {
|
|
6593
|
+
const arr = new Float64Array(checkedLength(size * 16));
|
|
6594
|
+
for (let i = 0; i < size * 16; i++) arr[i] = reader.readFloat64();
|
|
6595
|
+
return arr;
|
|
6596
|
+
}
|
|
6597
|
+
case TypeEnum.String:
|
|
6598
|
+
case TypeEnum.Token: {
|
|
6599
|
+
const arr = [];
|
|
6600
|
+
for (let i = 0; i < size; i++) {
|
|
6601
|
+
const index = reader.readUint32();
|
|
6602
|
+
const tokenIndex = type === TypeEnum.String ? this.strings[index] : index;
|
|
6603
|
+
const value = this.tokens[tokenIndex];
|
|
6604
|
+
if (typeof value !== "string") throw new Error("USDC: invalid string array index");
|
|
6605
|
+
arr.push(value);
|
|
6606
|
+
}
|
|
6607
|
+
return arr;
|
|
6608
|
+
}
|
|
6609
|
+
case TypeEnum.Half: {
|
|
6610
|
+
const arr = new Float32Array(checkedLength(size));
|
|
6611
|
+
for (let i = 0; i < size; i++) arr[i] = this._readHalf();
|
|
6612
|
+
return arr;
|
|
6613
|
+
}
|
|
6614
|
+
default:
|
|
6615
|
+
throw new Error(
|
|
6616
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unsupported array type", type].join(" ")
|
|
6617
|
+
);
|
|
6618
|
+
}
|
|
6619
|
+
}
|
|
6620
|
+
_readCompressedArray(type, size) {
|
|
6621
|
+
const reader = this.reader;
|
|
6622
|
+
switch (type) {
|
|
6623
|
+
case TypeEnum.Int:
|
|
6624
|
+
case TypeEnum.UInt: {
|
|
6625
|
+
const compressedSize = reader.readUint64();
|
|
6626
|
+
const compressed = reader.readBytes(compressedSize);
|
|
6627
|
+
const values = decompressIntegers32(
|
|
6628
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
6629
|
+
size
|
|
6630
|
+
);
|
|
6631
|
+
return type === TypeEnum.UInt ? new Uint32Array(values.buffer, values.byteOffset, values.length) : values;
|
|
6632
|
+
}
|
|
6633
|
+
case TypeEnum.Half:
|
|
6634
|
+
case TypeEnum.Double:
|
|
6635
|
+
case TypeEnum.Float: {
|
|
6636
|
+
const code = reader.readInt8();
|
|
6637
|
+
if (code === FLOAT_COMPRESSION_INT) {
|
|
6638
|
+
const compressedSize = reader.readUint64();
|
|
6639
|
+
const compressed = reader.readBytes(compressedSize);
|
|
6640
|
+
const ints = decompressIntegers32(
|
|
6641
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
6642
|
+
size
|
|
6643
|
+
);
|
|
6644
|
+
const floats = type === TypeEnum.Double ? new Float64Array(checkedLength(size)) : new Float32Array(checkedLength(size));
|
|
6645
|
+
for (let i = 0; i < size; i++)
|
|
6646
|
+
floats[i] = type === TypeEnum.Half ? this._convertHalfInteger(ints[i]) : ints[i];
|
|
6647
|
+
return floats;
|
|
6648
|
+
} else if (code === FLOAT_COMPRESSION_LUT) {
|
|
6649
|
+
const lutSize = checkedCount(reader.readUint32());
|
|
6650
|
+
if (lutSize === 0) throw new Error("USDC: invalid float lookup table");
|
|
6651
|
+
const lut = type === TypeEnum.Double ? new Float64Array(checkedLength(lutSize)) : new Float32Array(checkedLength(lutSize));
|
|
6652
|
+
for (let i = 0; i < lutSize; i++)
|
|
6653
|
+
lut[i] = type === TypeEnum.Half ? this._readHalf() : type === TypeEnum.Double ? reader.readFloat64() : reader.readFloat32();
|
|
6654
|
+
const compressedSize = reader.readUint64();
|
|
6655
|
+
const compressed = reader.readBytes(compressedSize);
|
|
6656
|
+
const indices = decompressIntegers32(
|
|
6657
|
+
compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressedSize),
|
|
6658
|
+
size
|
|
6659
|
+
);
|
|
6660
|
+
const floats = type === TypeEnum.Double ? new Float64Array(checkedLength(size)) : new Float32Array(checkedLength(size));
|
|
6661
|
+
for (let i = 0; i < size; i++) {
|
|
6662
|
+
if (indices[i] < 0 || indices[i] >= lutSize)
|
|
6663
|
+
throw new Error("USDC: invalid float lookup index");
|
|
6664
|
+
floats[i] = lut[indices[i]];
|
|
6665
|
+
}
|
|
6666
|
+
return floats;
|
|
6667
|
+
}
|
|
6668
|
+
throw new Error(
|
|
6669
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unknown float compression code", code].join(" ")
|
|
6670
|
+
);
|
|
6671
|
+
}
|
|
6672
|
+
default:
|
|
6673
|
+
throw new Error(
|
|
6674
|
+
"USDC: unsupported encoding: " + ["USDCParser: Unsupported compressed array type", type].join(" ")
|
|
6675
|
+
);
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
/** Rounds integer-compressed half samples using IEEE ties-to-even semantics. */
|
|
6679
|
+
_convertHalfInteger(value) {
|
|
6680
|
+
const absoluteValue = Math.abs(value);
|
|
6681
|
+
if (absoluteValue <= 2048) return value;
|
|
6682
|
+
if (absoluteValue >= 65520) return Math.sign(value) * Infinity;
|
|
6683
|
+
const spacing = 2 ** (Math.floor(Math.log2(absoluteValue)) - 10);
|
|
6684
|
+
const scaledValue = absoluteValue / spacing;
|
|
6685
|
+
const lowerValue = Math.floor(scaledValue);
|
|
6686
|
+
const fractionValue = scaledValue - lowerValue;
|
|
6687
|
+
const roundedValue = fractionValue > 0.5 || fractionValue === 0.5 && lowerValue % 2 !== 0 ? lowerValue + 1 : lowerValue;
|
|
6688
|
+
return Math.sign(value) * roundedValue * spacing;
|
|
6689
|
+
}
|
|
6690
|
+
_readHalf() {
|
|
6691
|
+
return this._halfToFloat(this.reader.readUint16());
|
|
6692
|
+
}
|
|
6693
|
+
_halfToFloat(h) {
|
|
6694
|
+
const sign = (h & 32768) >> 15;
|
|
6695
|
+
const exp = (h & 31744) >> 10;
|
|
6696
|
+
const frac = h & 1023;
|
|
6697
|
+
if (exp === 0) {
|
|
6698
|
+
if (frac === 0) {
|
|
6699
|
+
return sign ? -0 : 0;
|
|
6700
|
+
}
|
|
6701
|
+
return (sign ? -1 : 1) * HALF_DENORM_SCALE * (frac / 1024);
|
|
6702
|
+
} else if (exp === 31) {
|
|
6703
|
+
return frac ? NaN : sign ? -Infinity : Infinity;
|
|
6704
|
+
}
|
|
6705
|
+
return (sign ? -1 : 1) * HALF_EXPONENT_TABLE[exp] * (1 + frac / 1024);
|
|
6706
|
+
}
|
|
6707
|
+
_getFieldsForSpec(spec) {
|
|
6708
|
+
const fields = /* @__PURE__ */ Object.create(null);
|
|
6709
|
+
let fieldSetIndex = spec.fieldSetIndex;
|
|
6710
|
+
const maxIterations = 1e4;
|
|
6711
|
+
let iterations = 0;
|
|
6712
|
+
while (fieldSetIndex < this.fieldSets.length && iterations < maxIterations) {
|
|
6713
|
+
const fieldIndex = this.fieldSets[fieldSetIndex];
|
|
6714
|
+
if (fieldIndex === FIELD_SET_TERMINATOR || fieldIndex === -1) break;
|
|
6715
|
+
const field = this.fields[fieldIndex];
|
|
6716
|
+
if (!field) throw new Error("USDC: invalid field index");
|
|
6717
|
+
if (field) {
|
|
6718
|
+
const name22 = this.tokens[field.tokenIndex];
|
|
6719
|
+
const value = this._readValue(field.valueRep);
|
|
6720
|
+
fields[name22] = value;
|
|
6721
|
+
}
|
|
6722
|
+
fieldSetIndex++;
|
|
6723
|
+
iterations++;
|
|
6724
|
+
}
|
|
6725
|
+
if (iterations >= maxIterations) throw new Error("USDC: field traversal limit exceeded");
|
|
6726
|
+
return fields;
|
|
6727
|
+
}
|
|
6728
|
+
};
|
|
6729
|
+
}
|
|
6730
|
+
});
|
|
6731
|
+
|
|
6732
|
+
// ../scene/src/usd/lib/parse-usdc.ts
|
|
6733
|
+
function parseUSDC(data, url) {
|
|
6734
|
+
var _a, _b, _c;
|
|
6735
|
+
if (data.byteLength < 88 || data.byteLength > 64 * 1024 * 1024)
|
|
6736
|
+
throw new Error("USDC: invalid input size");
|
|
6737
|
+
const bytes = new Uint8Array(data);
|
|
6738
|
+
if (bytes[8] !== 0 || bytes[9] !== 8 || bytes[10] !== 0)
|
|
6739
|
+
throw new Error("USDC: initial decoder requires crate version 0.8.0");
|
|
6740
|
+
const reader = new DataView(data);
|
|
6741
|
+
const table = reader.getBigUint64(16, true);
|
|
6742
|
+
if (table > BigInt(data.byteLength - 8)) throw new Error("USDC: invalid section table");
|
|
6743
|
+
const offset = Number(table), count = reader.getBigUint64(offset, true);
|
|
6744
|
+
if (count > 16n || offset + 8 + Number(count) * 32 > data.byteLength)
|
|
6745
|
+
throw new Error("USDC: invalid section table length");
|
|
6746
|
+
const sectionNames = /* @__PURE__ */ new Set();
|
|
6747
|
+
for (let index = 0; index < Number(count); index++) {
|
|
6748
|
+
const entry = offset + 8 + index * 32;
|
|
6749
|
+
const nameBytes = bytes.subarray(entry, entry + 16);
|
|
6750
|
+
const terminator = nameBytes.indexOf(0);
|
|
6751
|
+
const name22 = new TextDecoder().decode(
|
|
6752
|
+
nameBytes.subarray(0, terminator < 0 ? nameBytes.length : terminator)
|
|
6753
|
+
);
|
|
6754
|
+
if (sectionNames.has(name22)) throw new Error("USDC: duplicate section");
|
|
6755
|
+
sectionNames.add(name22);
|
|
6756
|
+
const start = reader.getBigUint64(entry + 16, true), size = reader.getBigUint64(entry + 24, true);
|
|
6757
|
+
if (start < 88n || start + size > BigInt(data.byteLength))
|
|
6758
|
+
throw new Error("USDC: section out of bounds");
|
|
6759
|
+
}
|
|
6760
|
+
for (const name22 of ["TOKENS", "STRINGS", "FIELDS", "FIELDSETS", "PATHS", "SPECS"])
|
|
6761
|
+
if (!sectionNames.has(name22)) throw new Error("USDC: missing required section");
|
|
6762
|
+
const { specsByPath } = new USDCParser().parseData(data);
|
|
6763
|
+
const prims = /* @__PURE__ */ new Map();
|
|
6764
|
+
for (const [path, specification] of Object.entries(specsByPath)) {
|
|
6765
|
+
if (specification.specType === 7 && path === "/") continue;
|
|
6766
|
+
if (specification.specType === 1 || specification.specType === 8) continue;
|
|
6767
|
+
if (specification.specType !== 6 || !/^\/(?:[A-Za-z_][\w:]*\/)*[A-Za-z_][\w:]*$/.test(path))
|
|
6768
|
+
throw new Error("USDC: unsupported prim specification");
|
|
6769
|
+
const fields = specification.fields;
|
|
6770
|
+
const specifier = fields.specifier ?? 0;
|
|
6771
|
+
if (specifier !== 0 && specifier !== 1 && specifier !== 2)
|
|
6772
|
+
throw new Error("USDC: invalid prim specifier");
|
|
6773
|
+
const metadata3 = convertFields(
|
|
6774
|
+
fields,
|
|
6775
|
+
/* @__PURE__ */ new Set(["specifier", "typeName", "primChildren", "properties"])
|
|
6776
|
+
);
|
|
6777
|
+
prims.set(path, {
|
|
6778
|
+
name: path.slice(path.lastIndexOf("/") + 1),
|
|
6779
|
+
path,
|
|
6780
|
+
sourceUrl: url,
|
|
6781
|
+
type: String(fields.typeName || ""),
|
|
6782
|
+
specifier: ["def", "over", "class"][specifier],
|
|
6783
|
+
attributes: /* @__PURE__ */ Object.create(null),
|
|
6784
|
+
metadata: metadata3,
|
|
6785
|
+
variants: /* @__PURE__ */ Object.create(null),
|
|
6786
|
+
children: []
|
|
6787
|
+
});
|
|
6788
|
+
}
|
|
6789
|
+
const roots = [];
|
|
6790
|
+
for (const prim of prims.values()) {
|
|
6791
|
+
const parentPath = prim.path.slice(0, prim.path.lastIndexOf("/"));
|
|
6792
|
+
if (!parentPath) roots.push(prim);
|
|
6793
|
+
else {
|
|
6794
|
+
const parent = prims.get(parentPath);
|
|
6795
|
+
if (!parent) throw new Error("USDC: missing parent prim");
|
|
6796
|
+
parent.children.push(prim);
|
|
6797
|
+
}
|
|
6798
|
+
}
|
|
6799
|
+
orderPrims(roots, (_a = specsByPath["/"]) == null ? void 0 : _a.fields.primChildren);
|
|
6800
|
+
for (const prim of prims.values())
|
|
6801
|
+
orderPrims(prim.children, (_b = specsByPath[prim.path]) == null ? void 0 : _b.fields.primChildren);
|
|
6802
|
+
for (const [path, specification] of Object.entries(specsByPath)) {
|
|
6803
|
+
if (specification.specType !== 1 && specification.specType !== 8) continue;
|
|
6804
|
+
const separator = path.indexOf(".");
|
|
6805
|
+
const prim = prims.get(path.slice(0, separator));
|
|
6806
|
+
if (separator < 0 || !prim) throw new Error("USDC: property has no owning prim");
|
|
6807
|
+
const name22 = path.slice(separator + 1), fields = specification.fields;
|
|
6808
|
+
const type = specification.specType === 8 ? "rel" : String(fields.typeName || "");
|
|
6809
|
+
const value = convertAttributeValue(
|
|
6810
|
+
specification.specType === 8 ? fields.targetPaths : fields.default,
|
|
6811
|
+
type
|
|
6812
|
+
);
|
|
6813
|
+
const metadata3 = convertFields(
|
|
6814
|
+
fields,
|
|
6815
|
+
/* @__PURE__ */ new Set(["typeName", "default", "targetPaths", "timeSamples"])
|
|
6816
|
+
);
|
|
6817
|
+
if (fields.timeSamples !== void 0)
|
|
6818
|
+
metadata3.timeSamples = convertTimeSamples(fields.timeSamples, type);
|
|
6819
|
+
prim.attributes[name22] = {
|
|
6820
|
+
name: name22,
|
|
6821
|
+
type,
|
|
6822
|
+
value,
|
|
6823
|
+
metadata: metadata3
|
|
6824
|
+
};
|
|
6825
|
+
}
|
|
6826
|
+
return {
|
|
6827
|
+
format: "usdc",
|
|
6828
|
+
url,
|
|
6829
|
+
metadata: convertFields(((_c = specsByPath["/"]) == null ? void 0 : _c.fields) || {}, /* @__PURE__ */ new Set(["primChildren"])),
|
|
6830
|
+
rootPrims: roots,
|
|
6831
|
+
layers: []
|
|
6832
|
+
};
|
|
6833
|
+
}
|
|
6834
|
+
function convertFields(fields, excluded) {
|
|
6835
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
6836
|
+
for (const [name22, value] of Object.entries(fields))
|
|
6837
|
+
if (!excluded.has(name22)) result[name22] = convertValue(value);
|
|
6838
|
+
return result;
|
|
6839
|
+
}
|
|
6840
|
+
function convertValue(value) {
|
|
6841
|
+
if (value === void 0 || value === null) return null;
|
|
6842
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean")
|
|
6843
|
+
return value;
|
|
6844
|
+
if (Array.isArray(value)) return value.map(convertValue);
|
|
6845
|
+
if (ArrayBuffer.isView(value) && !(value instanceof DataView))
|
|
6846
|
+
return Array.from(value);
|
|
6847
|
+
if (typeof value === "object") return convertFields(value, /* @__PURE__ */ new Set());
|
|
6848
|
+
throw new Error("USDC: unsupported decoded value");
|
|
6849
|
+
}
|
|
6850
|
+
function convertAttributeValue(raw, type) {
|
|
6851
|
+
const value = convertValue(raw);
|
|
6852
|
+
if (type === "asset" && typeof value === "string") return { assetPath: value };
|
|
6853
|
+
if (type === "rel" && Array.isArray(value))
|
|
6854
|
+
return value.map((path) => typeof path === "string" ? { path } : path);
|
|
6855
|
+
const tuple = /^(?:(?:point|normal|vector|color|texCoord)([234])[fdh]|(?:float|double|half|int)([234]))\[\]$/.exec(
|
|
6856
|
+
type
|
|
6857
|
+
);
|
|
6858
|
+
if (tuple && Array.isArray(value)) {
|
|
6859
|
+
const components = Number(tuple[1] || tuple[2]);
|
|
6860
|
+
if (value.length % components) throw new Error("USDC: incomplete vector tuple");
|
|
6861
|
+
const tuples = [];
|
|
6862
|
+
for (let offset = 0; offset < value.length; offset += components)
|
|
6863
|
+
tuples.push(value.slice(offset, offset + components));
|
|
6864
|
+
return tuples;
|
|
6865
|
+
}
|
|
6866
|
+
return value;
|
|
6867
|
+
}
|
|
6868
|
+
function orderPrims(prims, names) {
|
|
6869
|
+
if (names === void 0) return;
|
|
6870
|
+
if (!Array.isArray(names)) throw new Error("USDC: invalid primChildren order");
|
|
6871
|
+
const remaining = new Map(prims.map((prim) => [prim.name, prim]));
|
|
6872
|
+
const ordered = [];
|
|
6873
|
+
for (const name22 of names) {
|
|
6874
|
+
const prim = typeof name22 === "string" ? remaining.get(name22) : void 0;
|
|
6875
|
+
if (!prim) throw new Error("USDC: invalid primChildren reference");
|
|
6876
|
+
ordered.push(prim);
|
|
6877
|
+
remaining.delete(name22);
|
|
6878
|
+
}
|
|
6879
|
+
for (const prim of remaining.values()) ordered.push(prim);
|
|
6880
|
+
for (let index = 0; index < ordered.length; index++) prims[index] = ordered[index];
|
|
6881
|
+
}
|
|
6882
|
+
function convertTimeSamples(raw, type) {
|
|
6883
|
+
if (!raw || typeof raw !== "object") throw new Error("USDC: invalid time samples");
|
|
6884
|
+
const samples = raw;
|
|
6885
|
+
const times = convertValue(samples.times);
|
|
6886
|
+
if (!Array.isArray(times) || !Array.isArray(samples.values) || times.length !== samples.values.length)
|
|
6887
|
+
throw new Error("USDC: invalid time samples");
|
|
6888
|
+
return { times, values: samples.values.map((value) => convertAttributeValue(value, type)) };
|
|
6889
|
+
}
|
|
6890
|
+
var init_parse_usdc = __esm({
|
|
6891
|
+
"../scene/src/usd/lib/parse-usdc.ts"() {
|
|
6892
|
+
"use strict";
|
|
6893
|
+
init_usdc_parser();
|
|
6894
|
+
}
|
|
6895
|
+
});
|
|
6896
|
+
|
|
5487
6897
|
// ../scene/src/usd/lib/parse-usda.ts
|
|
5488
6898
|
function parseUSDA(source, url) {
|
|
5489
6899
|
if (!source.trimStart().startsWith("#usda")) {
|
|
@@ -5518,7 +6928,7 @@ var init_parse_usda = __esm({
|
|
|
5518
6928
|
}
|
|
5519
6929
|
/** Parses the complete USDA layer. */
|
|
5520
6930
|
parse() {
|
|
5521
|
-
const
|
|
6931
|
+
const metadata3 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
|
|
5522
6932
|
const rootPrims = [];
|
|
5523
6933
|
while (!this.tokenizer.isAtEnd()) {
|
|
5524
6934
|
if (this.isPrimDeclaration()) {
|
|
@@ -5530,7 +6940,7 @@ var init_parse_usda = __esm({
|
|
|
5530
6940
|
return {
|
|
5531
6941
|
format: "usda",
|
|
5532
6942
|
url: this.url,
|
|
5533
|
-
metadata:
|
|
6943
|
+
metadata: metadata3,
|
|
5534
6944
|
rootPrims,
|
|
5535
6945
|
layers: this.url ? [this.url] : []
|
|
5536
6946
|
};
|
|
@@ -5544,7 +6954,7 @@ var init_parse_usda = __esm({
|
|
|
5544
6954
|
const type = hasExplicitType ? firstToken.value : "";
|
|
5545
6955
|
const name22 = hasExplicitType ? this.tokenizer.read().value : firstToken.value;
|
|
5546
6956
|
const path = `${parentPath}/${name22}`;
|
|
5547
|
-
const
|
|
6957
|
+
const metadata3 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
|
|
5548
6958
|
this.tokenizer.expect("{");
|
|
5549
6959
|
const contents = this.parsePrimContents(path);
|
|
5550
6960
|
return {
|
|
@@ -5554,7 +6964,7 @@ var init_parse_usda = __esm({
|
|
|
5554
6964
|
type,
|
|
5555
6965
|
specifier,
|
|
5556
6966
|
attributes: contents.attributes,
|
|
5557
|
-
metadata: { ...
|
|
6967
|
+
metadata: { ...metadata3, ...contents.metadata },
|
|
5558
6968
|
variants: contents.variants,
|
|
5559
6969
|
children: contents.children
|
|
5560
6970
|
};
|
|
@@ -5562,7 +6972,7 @@ var init_parse_usda = __esm({
|
|
|
5562
6972
|
/** Parses the attributes, variants, and child prims inside a prim body. */
|
|
5563
6973
|
parsePrimContents(parentPath) {
|
|
5564
6974
|
const attributes = {};
|
|
5565
|
-
const
|
|
6975
|
+
const metadata3 = {};
|
|
5566
6976
|
const children = [];
|
|
5567
6977
|
const variants = {};
|
|
5568
6978
|
while (!this.tokenizer.isAtEnd() && !this.tokenizer.match("}")) {
|
|
@@ -5577,7 +6987,7 @@ var init_parse_usda = __esm({
|
|
|
5577
6987
|
}
|
|
5578
6988
|
}
|
|
5579
6989
|
}
|
|
5580
|
-
return { attributes, metadata:
|
|
6990
|
+
return { attributes, metadata: metadata3, children, variants };
|
|
5581
6991
|
}
|
|
5582
6992
|
/** Parses one named variant set. */
|
|
5583
6993
|
parseVariantSet(parentPath, variants) {
|
|
@@ -5627,12 +7037,12 @@ var init_parse_usda = __esm({
|
|
|
5627
7037
|
const name22 = significantTokens[significantTokens.length - 1].value;
|
|
5628
7038
|
const type = significantTokens.slice(0, -1).map((token) => token.value).join("");
|
|
5629
7039
|
const value = this.parseValue();
|
|
5630
|
-
const
|
|
5631
|
-
return { name: name22, type, value, metadata:
|
|
7040
|
+
const metadata3 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
|
|
7041
|
+
return { name: name22, type, value, metadata: metadata3 };
|
|
5632
7042
|
}
|
|
5633
7043
|
/** Parses a metadata dictionary through the requested terminator. */
|
|
5634
7044
|
parseMetadata(terminator) {
|
|
5635
|
-
const
|
|
7045
|
+
const metadata3 = {};
|
|
5636
7046
|
while (!this.tokenizer.isAtEnd() && !this.tokenizer.match(terminator)) {
|
|
5637
7047
|
this.tokenizer.match(",");
|
|
5638
7048
|
if (this.tokenizer.peek().value === terminator) {
|
|
@@ -5655,10 +7065,10 @@ var init_parse_usda = __esm({
|
|
|
5655
7065
|
continue;
|
|
5656
7066
|
}
|
|
5657
7067
|
const name22 = declarationTokens[declarationTokens.length - 1].value;
|
|
5658
|
-
|
|
7068
|
+
metadata3[name22] = this.parseValue();
|
|
5659
7069
|
this.tokenizer.match(",");
|
|
5660
7070
|
}
|
|
5661
|
-
return
|
|
7071
|
+
return metadata3;
|
|
5662
7072
|
}
|
|
5663
7073
|
/** Parses one scalar, list, tuple, dictionary, asset path, or scene path value. */
|
|
5664
7074
|
parseValue() {
|
|
@@ -5874,30 +7284,52 @@ function parseUSDZArchive(arrayBuffer) {
|
|
|
5874
7284
|
const directoryOffset = findCentralDirectory(view);
|
|
5875
7285
|
const entryCount = view.getUint16(directoryOffset + 10, true);
|
|
5876
7286
|
let entryOffset = view.getUint32(directoryOffset + 16, true);
|
|
7287
|
+
const dataLimit = entryOffset;
|
|
5877
7288
|
const files = /* @__PURE__ */ new Map();
|
|
5878
|
-
const
|
|
7289
|
+
const textDecoder2 = new TextDecoder();
|
|
7290
|
+
let extractedByteLength = 0;
|
|
5879
7291
|
for (let entryIndex = 0; entryIndex < entryCount; entryIndex++) {
|
|
7292
|
+
if (entryOffset + 46 > directoryOffset) {
|
|
7293
|
+
throw new Error("USDZ archive contains a truncated ZIP central-directory entry.");
|
|
7294
|
+
}
|
|
5880
7295
|
if (view.getUint32(entryOffset, true) !== CENTRAL_DIRECTORY_ENTRY) {
|
|
5881
7296
|
throw new Error("USDZ archive contains an invalid ZIP central-directory entry.");
|
|
5882
7297
|
}
|
|
5883
7298
|
const compression = view.getUint16(entryOffset + 10, true);
|
|
5884
7299
|
const compressedLength = view.getUint32(entryOffset + 20, true);
|
|
7300
|
+
const uncompressedLength = view.getUint32(entryOffset + 24, true);
|
|
5885
7301
|
const filenameLength = view.getUint16(entryOffset + 28, true);
|
|
5886
7302
|
const extraLength = view.getUint16(entryOffset + 30, true);
|
|
5887
7303
|
const commentLength = view.getUint16(entryOffset + 32, true);
|
|
5888
7304
|
const localOffset = view.getUint32(entryOffset + 42, true);
|
|
5889
|
-
|
|
7305
|
+
if (entryOffset + 46 + filenameLength + extraLength + commentLength > directoryOffset) {
|
|
7306
|
+
throw new Error("USDZ archive contains a truncated ZIP filename or extra field.");
|
|
7307
|
+
}
|
|
7308
|
+
const filename2 = textDecoder2.decode(
|
|
5890
7309
|
new Uint8Array(arrayBuffer, entryOffset + 46, filenameLength)
|
|
5891
7310
|
);
|
|
5892
7311
|
if (compression !== 0) {
|
|
5893
7312
|
throw new Error(`USDZ entry "${filename2}" is compressed; USDZ requires stored ZIP entries.`);
|
|
5894
7313
|
}
|
|
7314
|
+
if (localOffset + 30 > dataLimit || compressedLength !== uncompressedLength) {
|
|
7315
|
+
throw new Error(`USDZ entry "${filename2}" has invalid stored ZIP bounds.`);
|
|
7316
|
+
}
|
|
5895
7317
|
if (view.getUint32(localOffset, true) !== LOCAL_FILE_HEADER) {
|
|
5896
7318
|
throw new Error(`USDZ entry "${filename2}" has an invalid local ZIP header.`);
|
|
5897
7319
|
}
|
|
5898
7320
|
const localNameLength = view.getUint16(localOffset + 26, true);
|
|
5899
7321
|
const localExtraLength = view.getUint16(localOffset + 28, true);
|
|
5900
7322
|
const contentOffset = localOffset + 30 + localNameLength + localExtraLength;
|
|
7323
|
+
if ((view.getUint16(entryOffset + 8, true) | view.getUint16(localOffset + 6, true)) & 1) {
|
|
7324
|
+
throw new Error(`USDZ entry "${filename2}" is encrypted.`);
|
|
7325
|
+
}
|
|
7326
|
+
if (contentOffset + compressedLength > dataLimit || view.getUint16(localOffset + 8, true) !== 0 || textDecoder2.decode(new Uint8Array(arrayBuffer, localOffset + 30, localNameLength)) !== filename2 || files.has(filename2)) {
|
|
7327
|
+
throw new Error(`USDZ entry "${filename2}" has invalid or duplicate stored ZIP data.`);
|
|
7328
|
+
}
|
|
7329
|
+
extractedByteLength += compressedLength;
|
|
7330
|
+
if (extractedByteLength > arrayBuffer.byteLength) {
|
|
7331
|
+
throw new Error("USDZ archive exceeds its stored data budget.");
|
|
7332
|
+
}
|
|
5901
7333
|
files.set(filename2, arrayBuffer.slice(contentOffset, contentOffset + compressedLength));
|
|
5902
7334
|
entryOffset += 46 + filenameLength + extraLength + commentLength;
|
|
5903
7335
|
}
|
|
@@ -5948,21 +7380,32 @@ async function parseUSD(data, options = {}, context) {
|
|
|
5948
7380
|
let stage;
|
|
5949
7381
|
if (isZIPArchive(data)) {
|
|
5950
7382
|
const archive = parseUSDZArchive(data);
|
|
5951
|
-
const rootFilename =
|
|
5952
|
-
if (!rootFilename) {
|
|
5953
|
-
throw new Error("USDZ
|
|
7383
|
+
const rootFilename = archive.keys().next().value;
|
|
7384
|
+
if (!rootFilename || !/\.(?:usd[ac]?)$/i.test(rootFilename)) {
|
|
7385
|
+
throw new Error("USDZ archive has no supported USD root layer.");
|
|
5954
7386
|
}
|
|
5955
7387
|
const archiveBase = "https://usd.archive/";
|
|
7388
|
+
const assets = /* @__PURE__ */ Object.create(null);
|
|
5956
7389
|
for (const [filename2, content] of archive) {
|
|
5957
|
-
|
|
7390
|
+
const assetUrl = new URL(filename2, archiveBase);
|
|
7391
|
+
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) => {
|
|
7392
|
+
const normalizedSegment = segment.replace(/%2e/gi, ".");
|
|
7393
|
+
return normalizedSegment === "." || normalizedSegment === "..";
|
|
7394
|
+
}) || assetUrl.origin !== new URL(archiveBase).origin || assetUrl.search || assetUrl.hash || assets[assetUrl.href]) {
|
|
7395
|
+
throw new Error(`USDZ entry "${filename2}" has an ambiguous package URL.`);
|
|
7396
|
+
}
|
|
7397
|
+
environment.archiveFiles.set(assetUrl.href, content);
|
|
7398
|
+
assets[assetUrl.href] = createEmbeddedAsset(filename2, content);
|
|
5958
7399
|
}
|
|
5959
7400
|
const rootUrl = new URL(rootFilename, archiveBase).href;
|
|
5960
7401
|
stage = parseUSDLayer(archive.get(rootFilename), rootUrl);
|
|
5961
7402
|
stage.format = "usdz";
|
|
7403
|
+
stage.assets = assets;
|
|
5962
7404
|
} else {
|
|
5963
7405
|
stage = parseUSDLayer(data, url);
|
|
5964
7406
|
}
|
|
5965
7407
|
if (stage.url) {
|
|
7408
|
+
setAttributeSourceUrls(stage, stage.url);
|
|
5966
7409
|
environment.layers.add(stage.url);
|
|
5967
7410
|
}
|
|
5968
7411
|
if (((_b = environment.options.usd) == null ? void 0 : _b.compose) !== false) {
|
|
@@ -5974,6 +7417,11 @@ async function parseUSD(data, options = {}, context) {
|
|
|
5974
7417
|
}
|
|
5975
7418
|
return stage;
|
|
5976
7419
|
}
|
|
7420
|
+
function createEmbeddedAsset(path, data) {
|
|
7421
|
+
const extension = path.slice(path.lastIndexOf(".") + 1).toLowerCase();
|
|
7422
|
+
const mimeType = extension === "png" ? "image/png" : /^(?:jpe?g)$/.test(extension) ? "image/jpeg" : void 0;
|
|
7423
|
+
return mimeType ? { path, data, mimeType } : { path, data };
|
|
7424
|
+
}
|
|
5977
7425
|
function getSourceLocation(configuredLocation, contextLocation) {
|
|
5978
7426
|
const configuredUrl = getAbsoluteUrl(configuredLocation);
|
|
5979
7427
|
if (configuredUrl) {
|
|
@@ -6000,10 +7448,29 @@ function resolveAssetPath(assetPath, sourceLocation) {
|
|
|
6000
7448
|
function parseUSDLayer(data, url) {
|
|
6001
7449
|
const signature = TEXT_DECODER.decode(data.slice(0, 8));
|
|
6002
7450
|
if (signature === CRATE_SIGNATURE) {
|
|
6003
|
-
|
|
7451
|
+
return parseUSDC(data, url);
|
|
6004
7452
|
}
|
|
6005
7453
|
return parseUSDA(TEXT_DECODER.decode(data), url);
|
|
6006
7454
|
}
|
|
7455
|
+
function setAttributeSourceUrls(stage, sourceUrl) {
|
|
7456
|
+
const pendingContents = [...stage.rootPrims];
|
|
7457
|
+
while (pendingContents.length) {
|
|
7458
|
+
const contents = pendingContents.pop();
|
|
7459
|
+
for (const attribute of Object.values(contents.attributes)) {
|
|
7460
|
+
attribute.sourceUrl = sourceUrl;
|
|
7461
|
+
}
|
|
7462
|
+
for (const child of contents.children) {
|
|
7463
|
+
pendingContents.push(child);
|
|
7464
|
+
}
|
|
7465
|
+
if ("variants" in contents) {
|
|
7466
|
+
for (const variants of Object.values(contents.variants)) {
|
|
7467
|
+
for (const variant of Object.values(variants)) {
|
|
7468
|
+
pendingContents.push(variant);
|
|
7469
|
+
}
|
|
7470
|
+
}
|
|
7471
|
+
}
|
|
7472
|
+
}
|
|
7473
|
+
}
|
|
6007
7474
|
async function composePrims(prims, sourceUrl, inheritedVariants, environment, depth) {
|
|
6008
7475
|
var _a, _b, _c;
|
|
6009
7476
|
if (depth > (((_a = environment.options.usd) == null ? void 0 : _a.maxReferenceDepth) ?? 12)) {
|
|
@@ -6083,6 +7550,7 @@ async function loadReferencedStage(url, environment) {
|
|
|
6083
7550
|
content = response.arrayBuffer();
|
|
6084
7551
|
}
|
|
6085
7552
|
const stage = parseUSDLayer(await content, url);
|
|
7553
|
+
setAttributeSourceUrls(stage, url);
|
|
6086
7554
|
environment.layers.add(url);
|
|
6087
7555
|
return stage;
|
|
6088
7556
|
})();
|
|
@@ -6182,6 +7650,7 @@ var TEXT_DECODER, CRATE_SIGNATURE, ZIP_SIGNATURE, USD_LOADER_DEFAULT_OPTIONS;
|
|
|
6182
7650
|
var init_parse_usd = __esm({
|
|
6183
7651
|
"../scene/src/usd/lib/parse-usd.ts"() {
|
|
6184
7652
|
"use strict";
|
|
7653
|
+
init_parse_usdc();
|
|
6185
7654
|
init_parse_usda();
|
|
6186
7655
|
init_parse_usdz();
|
|
6187
7656
|
TEXT_DECODER = new TextDecoder();
|
|
@@ -6236,11 +7705,11 @@ var init_usd_loader_types = __esm({
|
|
|
6236
7705
|
id: "usd",
|
|
6237
7706
|
module: "scene",
|
|
6238
7707
|
version: VERSION4,
|
|
6239
|
-
extensions: ["usd", "usda", "usdz"],
|
|
6240
|
-
mimeTypes: ["model/vnd.usd", "model/vnd.usda", "model/vnd.usdz+zip"],
|
|
7708
|
+
extensions: ["usd", "usda", "usdc", "usdz"],
|
|
7709
|
+
mimeTypes: ["model/vnd.usd", "model/vnd.usda", "model/vnd.usdc", "model/vnd.usdz+zip"],
|
|
6241
7710
|
text: true,
|
|
6242
7711
|
binary: true,
|
|
6243
|
-
tests: ["#usda", "PK"],
|
|
7712
|
+
tests: ["#usda", "PXR-USDC", "PK"],
|
|
6244
7713
|
options: {
|
|
6245
7714
|
usd: {
|
|
6246
7715
|
compose: true,
|
|
@@ -6260,22 +7729,145 @@ var init_usd = __esm({
|
|
|
6260
7729
|
"use strict";
|
|
6261
7730
|
init_usd_loader_types();
|
|
6262
7731
|
}
|
|
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"() {
|
|
7732
|
+
});
|
|
7733
|
+
|
|
7734
|
+
// ../scene/src/obj/obj-format.ts
|
|
7735
|
+
var OBJFormat;
|
|
7736
|
+
var init_obj_format = __esm({
|
|
7737
|
+
"../scene/src/obj/obj-format.ts"() {
|
|
7738
|
+
"use strict";
|
|
7739
|
+
OBJFormat = {
|
|
7740
|
+
name: "OBJ",
|
|
7741
|
+
id: "obj",
|
|
7742
|
+
module: "scene",
|
|
7743
|
+
encoding: "text",
|
|
7744
|
+
format: "obj",
|
|
7745
|
+
extensions: ["obj"],
|
|
7746
|
+
mimeTypes: ["text/plain"]
|
|
7747
|
+
};
|
|
7748
|
+
}
|
|
7749
|
+
});
|
|
7750
|
+
|
|
7751
|
+
// ../core/src/arrow-worker-transport.ts
|
|
7752
|
+
function serializeArrowWorkerTable(result) {
|
|
7753
|
+
if (!isArrowTableWrapper(result)) {
|
|
7754
|
+
throw new Error("Workers require Arrow table output");
|
|
7755
|
+
}
|
|
7756
|
+
const { data, ...metadata3 } = result;
|
|
7757
|
+
return {
|
|
7758
|
+
...structuredClone(metadata3),
|
|
7759
|
+
data: (0, import_arrow.dehydrateArrowTable)(data, { copy: "all" })
|
|
7760
|
+
};
|
|
7761
|
+
}
|
|
7762
|
+
function deserializeArrowWorkerTable(result) {
|
|
7763
|
+
if (!isDehydratedArrowTableWrapper(result)) {
|
|
7764
|
+
throw new Error("Workers require Arrow column transport");
|
|
7765
|
+
}
|
|
7766
|
+
return { ...result, data: (0, import_arrow.hydrateArrowTable)(result.data) };
|
|
7767
|
+
}
|
|
7768
|
+
function serializeArrowWorkerResult(result, options) {
|
|
7769
|
+
var _a;
|
|
7770
|
+
if (!isArrowTableWrapper(result)) {
|
|
7771
|
+
return result;
|
|
7772
|
+
}
|
|
7773
|
+
const workerOptions = options;
|
|
7774
|
+
const bufferCopyMode = ((_a = workerOptions == null ? void 0 : workerOptions.core) == null ? void 0 : _a.workerTransferBufferCopy) ?? (workerOptions == null ? void 0 : workerOptions.workerTransferBufferCopy);
|
|
7775
|
+
return {
|
|
7776
|
+
...result,
|
|
7777
|
+
data: (0, import_arrow.dehydrateArrowTable)(result.data, bufferCopyMode ? { copy: bufferCopyMode } : void 0)
|
|
7778
|
+
};
|
|
7779
|
+
}
|
|
7780
|
+
function deserializeArrowWorkerResult(result) {
|
|
7781
|
+
if (!isDehydratedArrowTableWrapper(result)) {
|
|
7782
|
+
return result;
|
|
7783
|
+
}
|
|
7784
|
+
return { ...result, data: (0, import_arrow.hydrateArrowTable)(result.data) };
|
|
7785
|
+
}
|
|
7786
|
+
function isArrowTableWrapper(value) {
|
|
7787
|
+
const table = value;
|
|
7788
|
+
return Boolean(
|
|
7789
|
+
table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
|
|
7790
|
+
);
|
|
7791
|
+
}
|
|
7792
|
+
function isDehydratedArrowTableWrapper(value) {
|
|
7793
|
+
const table = value;
|
|
7794
|
+
return Boolean(
|
|
7795
|
+
table && table.shape === "arrow-table" && table.data && table.data.transport === "arrow-js" && Array.isArray(table.data.batches)
|
|
7796
|
+
);
|
|
7797
|
+
}
|
|
7798
|
+
var import_arrow;
|
|
7799
|
+
var init_arrow_worker_transport = __esm({
|
|
7800
|
+
"../core/src/arrow-worker-transport.ts"() {
|
|
7801
|
+
"use strict";
|
|
7802
|
+
import_arrow = require("@math.gl/arrow");
|
|
7803
|
+
}
|
|
7804
|
+
});
|
|
7805
|
+
|
|
7806
|
+
// ../core/src/schema-utils/lib/schema/data-type.ts
|
|
7807
|
+
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
7808
|
+
if (value instanceof Date) {
|
|
7809
|
+
return "date-millisecond";
|
|
7810
|
+
}
|
|
7811
|
+
if (typeof value === "number") {
|
|
7812
|
+
return defaultNumberType;
|
|
7813
|
+
}
|
|
7814
|
+
if (typeof value === "boolean") {
|
|
7815
|
+
return "bool";
|
|
7816
|
+
}
|
|
7817
|
+
if (typeof value === "string") {
|
|
7818
|
+
return "utf8";
|
|
7819
|
+
}
|
|
7820
|
+
if (value === null || value === "undefined") {
|
|
7821
|
+
return "null";
|
|
7822
|
+
}
|
|
7823
|
+
return "null";
|
|
7824
|
+
}
|
|
7825
|
+
function getDataTypeFromArray(array) {
|
|
7826
|
+
let type = getDataTypeFromTypedArray(array);
|
|
7827
|
+
if (type !== "null") {
|
|
7828
|
+
return { type, nullable: false };
|
|
7829
|
+
}
|
|
7830
|
+
if (array.length > 0) {
|
|
7831
|
+
type = getDataTypeFromValue(array[0]);
|
|
7832
|
+
return { type, nullable: true };
|
|
7833
|
+
}
|
|
7834
|
+
return { type: "null", nullable: true };
|
|
7835
|
+
}
|
|
7836
|
+
function getDataTypeFromTypedArray(array) {
|
|
7837
|
+
if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
|
|
7838
|
+
return "float16";
|
|
7839
|
+
}
|
|
7840
|
+
switch (array.constructor) {
|
|
7841
|
+
case Int8Array:
|
|
7842
|
+
return "int8";
|
|
7843
|
+
case Uint8Array:
|
|
7844
|
+
case Uint8ClampedArray:
|
|
7845
|
+
return "uint8";
|
|
7846
|
+
case Int16Array:
|
|
7847
|
+
return "int16";
|
|
7848
|
+
case Uint16Array:
|
|
7849
|
+
return "uint16";
|
|
7850
|
+
case Int32Array:
|
|
7851
|
+
return "int32";
|
|
7852
|
+
case Uint32Array:
|
|
7853
|
+
return "uint32";
|
|
7854
|
+
case BigInt64Array:
|
|
7855
|
+
return "int64";
|
|
7856
|
+
case BigUint64Array:
|
|
7857
|
+
return "uint64";
|
|
7858
|
+
case Float32Array:
|
|
7859
|
+
return "float32";
|
|
7860
|
+
case Float64Array:
|
|
7861
|
+
return "float64";
|
|
7862
|
+
default:
|
|
7863
|
+
return "null";
|
|
7864
|
+
}
|
|
7865
|
+
}
|
|
7866
|
+
var import_core;
|
|
7867
|
+
var init_data_type = __esm({
|
|
7868
|
+
"../core/src/schema-utils/lib/schema/data-type.ts"() {
|
|
6269
7869
|
"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
|
-
};
|
|
7870
|
+
import_core = require("@math.gl/core");
|
|
6279
7871
|
}
|
|
6280
7872
|
});
|
|
6281
7873
|
|
|
@@ -6289,17 +7881,11 @@ function serializeArrowSchema(arrowSchema) {
|
|
|
6289
7881
|
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
6290
7882
|
};
|
|
6291
7883
|
}
|
|
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
7884
|
function serializeArrowMetadata(arrowMetadata) {
|
|
6299
7885
|
return Object.fromEntries(arrowMetadata);
|
|
6300
7886
|
}
|
|
6301
|
-
function deserializeArrowMetadata(
|
|
6302
|
-
return
|
|
7887
|
+
function deserializeArrowMetadata(metadata3) {
|
|
7888
|
+
return metadata3 ? new Map(Object.entries(metadata3)) : /* @__PURE__ */ new Map();
|
|
6303
7889
|
}
|
|
6304
7890
|
function serializeArrowField(field) {
|
|
6305
7891
|
return {
|
|
@@ -6718,281 +8304,6 @@ var init_convert_arrow_schema = __esm({
|
|
|
6718
8304
|
}
|
|
6719
8305
|
});
|
|
6720
8306
|
|
|
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
8307
|
// ../core/src/schema-utils/lib/mesh/mesh-utils.ts
|
|
6997
8308
|
function getMeshBoundingBox(attributes) {
|
|
6998
8309
|
const positionAttribute = attributes == null ? void 0 : attributes.POSITION;
|
|
@@ -7107,23 +8418,23 @@ var init_float16 = __esm({
|
|
|
7107
8418
|
});
|
|
7108
8419
|
|
|
7109
8420
|
// ../core/src/schema/categories/category-mesh.ts
|
|
7110
|
-
var
|
|
8421
|
+
var arrow2, meshArrowSchema, indexedMeshArrowSchema;
|
|
7111
8422
|
var init_category_mesh = __esm({
|
|
7112
8423
|
"../core/src/schema/categories/category-mesh.ts"() {
|
|
7113
8424
|
"use strict";
|
|
7114
|
-
|
|
7115
|
-
meshArrowSchema = new
|
|
7116
|
-
new
|
|
8425
|
+
arrow2 = __toESM(require("apache-arrow"), 1);
|
|
8426
|
+
meshArrowSchema = new arrow2.Schema([
|
|
8427
|
+
new arrow2.Field(
|
|
7117
8428
|
"POSITION",
|
|
7118
|
-
new
|
|
8429
|
+
new arrow2.FixedSizeList(3, new arrow2.Field("value", new arrow2.Float32(), false)),
|
|
7119
8430
|
false
|
|
7120
8431
|
)
|
|
7121
8432
|
]);
|
|
7122
|
-
indexedMeshArrowSchema = new
|
|
8433
|
+
indexedMeshArrowSchema = new arrow2.Schema([
|
|
7123
8434
|
...meshArrowSchema.fields,
|
|
7124
|
-
new
|
|
8435
|
+
new arrow2.Field(
|
|
7125
8436
|
"indices",
|
|
7126
|
-
new
|
|
8437
|
+
new arrow2.List(new arrow2.Field("item", new arrow2.Uint32(), false)),
|
|
7127
8438
|
true
|
|
7128
8439
|
)
|
|
7129
8440
|
]);
|
|
@@ -7141,11 +8452,11 @@ var init_schema = __esm({
|
|
|
7141
8452
|
|
|
7142
8453
|
// ../core/src/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.ts
|
|
7143
8454
|
function getFixedSizeListSize(vector) {
|
|
7144
|
-
return vector.type instanceof
|
|
8455
|
+
return vector.type instanceof arrow3.FixedSizeList ? vector.type.listSize : 1;
|
|
7145
8456
|
}
|
|
7146
8457
|
function getFixedSizeListVector(typedArray, stride, logicalType) {
|
|
7147
8458
|
const data = getFixedSizeListData(typedArray, stride, logicalType);
|
|
7148
|
-
return new
|
|
8459
|
+
return new arrow3.Vector([data]);
|
|
7149
8460
|
}
|
|
7150
8461
|
function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
7151
8462
|
const listType = getFixedSizeListType(typedArray, stride, logicalType);
|
|
@@ -7153,13 +8464,13 @@ function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
|
7153
8464
|
const storage = logicalType === "float16" && isNativeFloat16Array(typedArray) ? getFloat16Storage(typedArray) : typedArray;
|
|
7154
8465
|
const buffers = {
|
|
7155
8466
|
// valueOffsets: undefined,
|
|
7156
|
-
[
|
|
8467
|
+
[arrow3.BufferType.DATA]: storage
|
|
7157
8468
|
// values
|
|
7158
8469
|
// nullBitmap: undefined,
|
|
7159
8470
|
// typeIds: undefined
|
|
7160
8471
|
};
|
|
7161
|
-
const nestedData = new
|
|
7162
|
-
const data = new
|
|
8472
|
+
const nestedData = new arrow3.Data(nestedType, 0, storage.length, 0, buffers);
|
|
8473
|
+
const data = new arrow3.Data(
|
|
7163
8474
|
listType,
|
|
7164
8475
|
0,
|
|
7165
8476
|
storage.length / stride,
|
|
@@ -7172,15 +8483,15 @@ function getFixedSizeListData(typedArray, stride, logicalType) {
|
|
|
7172
8483
|
function getFixedSizeListType(typedArray, stride, logicalType) {
|
|
7173
8484
|
const type = logicalType || getDataTypeFromArray(typedArray).type;
|
|
7174
8485
|
const arrowType = deserializeArrowType(type);
|
|
7175
|
-
const listType = new
|
|
8486
|
+
const listType = new arrow3.FixedSizeList(stride, new arrow3.Field("value", arrowType, false));
|
|
7176
8487
|
return listType;
|
|
7177
8488
|
}
|
|
7178
|
-
var
|
|
8489
|
+
var arrow3;
|
|
7179
8490
|
var init_arrow_fixed_size_list_utils = __esm({
|
|
7180
8491
|
"../core/src/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.ts"() {
|
|
7181
8492
|
"use strict";
|
|
7182
8493
|
init_schema();
|
|
7183
|
-
|
|
8494
|
+
arrow3 = __toESM(require("apache-arrow"), 1);
|
|
7184
8495
|
init_data_type();
|
|
7185
8496
|
init_convert_arrow_schema();
|
|
7186
8497
|
}
|
|
@@ -7240,8 +8551,8 @@ function makeMeshArrowTable(attributes, options = {}) {
|
|
|
7240
8551
|
fields.push(indicesField);
|
|
7241
8552
|
}
|
|
7242
8553
|
}
|
|
7243
|
-
const arrowSchema = new
|
|
7244
|
-
const table = ((_c = columns[attributeNames[0]]) == null ? void 0 : _c.length) === 0 ? new
|
|
8554
|
+
const arrowSchema = new arrow4.Schema(fields, getMeshArrowMetadata(options));
|
|
8555
|
+
const table = ((_c = columns[attributeNames[0]]) == null ? void 0 : _c.length) === 0 ? new arrow4.Table(arrowSchema) : new arrow4.Table(arrowSchema, columns);
|
|
7245
8556
|
const schema = serializeArrowSchema(table.schema);
|
|
7246
8557
|
return {
|
|
7247
8558
|
shape: "arrow-table",
|
|
@@ -7255,14 +8566,14 @@ function getAttributeArrowVector(value, size, componentType) {
|
|
|
7255
8566
|
if (componentType === "float16") {
|
|
7256
8567
|
const storage = isNativeFloat16Array(value) ? getFloat16Storage(value) : value;
|
|
7257
8568
|
if (size === 1) {
|
|
7258
|
-
const data = new
|
|
7259
|
-
[
|
|
8569
|
+
const data = new arrow4.Data(new arrow4.Float16(), 0, storage.length, 0, {
|
|
8570
|
+
[arrow4.BufferType.DATA]: storage
|
|
7260
8571
|
});
|
|
7261
|
-
return new
|
|
8572
|
+
return new arrow4.Vector([data]);
|
|
7262
8573
|
}
|
|
7263
8574
|
return getFixedSizeListVector(value, size, componentType);
|
|
7264
8575
|
}
|
|
7265
|
-
return size === 1 ?
|
|
8576
|
+
return size === 1 ? arrow4.makeVector(value) : getFixedSizeListVector(value, size);
|
|
7266
8577
|
}
|
|
7267
8578
|
function getOrderedAttributeNames(attributes) {
|
|
7268
8579
|
const attributeNames = Object.keys(attributes);
|
|
@@ -7285,36 +8596,36 @@ function getAttributeArrowField(schema, attributeName, column, componentType) {
|
|
|
7285
8596
|
if (!(suppliedField == null ? void 0 : suppliedField.metadata)) {
|
|
7286
8597
|
return canonicalField;
|
|
7287
8598
|
}
|
|
7288
|
-
const
|
|
8599
|
+
const metadata3 = new Map(canonicalField.metadata);
|
|
7289
8600
|
for (const [key, value] of Object.entries(suppliedField.metadata)) {
|
|
7290
|
-
|
|
8601
|
+
metadata3.set(key, value);
|
|
7291
8602
|
}
|
|
7292
|
-
return new
|
|
8603
|
+
return new arrow4.Field(
|
|
7293
8604
|
canonicalField.name,
|
|
7294
8605
|
canonicalField.type,
|
|
7295
8606
|
canonicalField.nullable,
|
|
7296
|
-
|
|
8607
|
+
metadata3
|
|
7297
8608
|
);
|
|
7298
8609
|
}
|
|
7299
8610
|
const field = schema == null ? void 0 : schema.fields.find((schemaField) => schemaField.name === attributeName);
|
|
7300
8611
|
if (componentType === "float16") {
|
|
7301
|
-
const
|
|
7302
|
-
|
|
7303
|
-
return new
|
|
8612
|
+
const metadata3 = new Map(Object.entries((field == null ? void 0 : field.metadata) || {}));
|
|
8613
|
+
metadata3.set("componentType", "float16");
|
|
8614
|
+
return new arrow4.Field(attributeName, column.type, false, metadata3);
|
|
7304
8615
|
}
|
|
7305
8616
|
if (field && field.type.toString() !== column.type.toString()) {
|
|
7306
8617
|
const deserializedField = deserializeArrowField(field);
|
|
7307
|
-
return new
|
|
8618
|
+
return new arrow4.Field(
|
|
7308
8619
|
attributeName,
|
|
7309
8620
|
column.type,
|
|
7310
8621
|
deserializedField.nullable,
|
|
7311
8622
|
deserializedField.metadata
|
|
7312
8623
|
);
|
|
7313
8624
|
}
|
|
7314
|
-
return field ? deserializeArrowField(field) : new
|
|
8625
|
+
return field ? deserializeArrowField(field) : new arrow4.Field(attributeName, column.type, false);
|
|
7315
8626
|
}
|
|
7316
8627
|
function isMeshPositionColumn(column) {
|
|
7317
|
-
return column.type instanceof
|
|
8628
|
+
return column.type instanceof arrow4.FixedSizeList && column.type.listSize === 3 && column.type.children[0].type instanceof arrow4.Float32;
|
|
7318
8629
|
}
|
|
7319
8630
|
function getIndicesVector(indices, vertexCount, type) {
|
|
7320
8631
|
const indicesType = type;
|
|
@@ -7327,47 +8638,47 @@ function getIndicesVector(indices, vertexCount, type) {
|
|
|
7327
8638
|
if (vertexCount > 0) {
|
|
7328
8639
|
nullBitmap[0] = 1;
|
|
7329
8640
|
}
|
|
7330
|
-
const valuesData = new
|
|
8641
|
+
const valuesData = new arrow4.Data(
|
|
7331
8642
|
indicesType.children[0].type,
|
|
7332
8643
|
0,
|
|
7333
8644
|
values.length,
|
|
7334
8645
|
0,
|
|
7335
|
-
{ [
|
|
8646
|
+
{ [arrow4.BufferType.DATA]: values }
|
|
7336
8647
|
);
|
|
7337
|
-
const indicesData = new
|
|
8648
|
+
const indicesData = new arrow4.Data(
|
|
7338
8649
|
indicesType,
|
|
7339
8650
|
0,
|
|
7340
8651
|
vertexCount,
|
|
7341
8652
|
Math.max(0, vertexCount - 1),
|
|
7342
8653
|
{
|
|
7343
|
-
[
|
|
7344
|
-
[
|
|
8654
|
+
[arrow4.BufferType.OFFSET]: valueOffsets,
|
|
8655
|
+
[arrow4.BufferType.VALIDITY]: nullBitmap
|
|
7345
8656
|
},
|
|
7346
8657
|
[valuesData]
|
|
7347
8658
|
);
|
|
7348
|
-
return new
|
|
8659
|
+
return new arrow4.Vector([indicesData]);
|
|
7349
8660
|
}
|
|
7350
8661
|
function getMeshArrowMetadata(options) {
|
|
7351
8662
|
var _a;
|
|
7352
|
-
const
|
|
8663
|
+
const metadata3 = { ...(_a = options.schema) == null ? void 0 : _a.metadata };
|
|
7353
8664
|
if (options.topology) {
|
|
7354
|
-
|
|
8665
|
+
metadata3.topology ||= options.topology;
|
|
7355
8666
|
}
|
|
7356
8667
|
if (Number.isFinite(options.mode)) {
|
|
7357
|
-
|
|
8668
|
+
metadata3.mode ||= String(options.mode);
|
|
7358
8669
|
}
|
|
7359
8670
|
if (options.boundingBox) {
|
|
7360
|
-
|
|
8671
|
+
metadata3.boundingBox ||= JSON.stringify(options.boundingBox);
|
|
7361
8672
|
}
|
|
7362
|
-
return deserializeArrowMetadata(
|
|
8673
|
+
return deserializeArrowMetadata(metadata3);
|
|
7363
8674
|
}
|
|
7364
|
-
var
|
|
8675
|
+
var arrow4, MESH_ARROW_ATTRIBUTE_ORDER;
|
|
7365
8676
|
var init_convert_mesh_to_table = __esm({
|
|
7366
8677
|
"../core/src/schema-utils/lib/mesh/convert-mesh-to-table.ts"() {
|
|
7367
8678
|
"use strict";
|
|
7368
8679
|
init_schema();
|
|
7369
8680
|
init_schema();
|
|
7370
|
-
|
|
8681
|
+
arrow4 = __toESM(require("apache-arrow"), 1);
|
|
7371
8682
|
init_arrow_fixed_size_list_utils();
|
|
7372
8683
|
init_convert_arrow_schema();
|
|
7373
8684
|
MESH_ARROW_ATTRIBUTE_ORDER = ["POSITION"];
|
|
@@ -7400,15 +8711,15 @@ function convertArrowTableToMesh(table) {
|
|
|
7400
8711
|
const attributeData = arrowTable.getChild(name22);
|
|
7401
8712
|
const size = getFixedSizeListSize(attributeData);
|
|
7402
8713
|
const typedArray = getAttributeTypedArray(attributeData, size);
|
|
7403
|
-
const
|
|
7404
|
-
const value =
|
|
8714
|
+
const metadata3 = getMeshAttributeMetadata(field.metadata);
|
|
8715
|
+
const value = metadata3.componentType === "float16" ? restoreFloat16Array(typedArray) : typedArray;
|
|
7405
8716
|
const shared = columns.find(
|
|
7406
8717
|
(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
8718
|
);
|
|
7408
8719
|
attributes[name22] = {
|
|
7409
8720
|
value: shared ? attributes[shared.name].value : value,
|
|
7410
8721
|
size,
|
|
7411
|
-
...
|
|
8722
|
+
...metadata3
|
|
7412
8723
|
};
|
|
7413
8724
|
if (!shared) columns.push({ name: name22, data: attributeData.data });
|
|
7414
8725
|
}
|
|
@@ -7446,23 +8757,23 @@ function getMeshBoundingBoxFromSchema(schema) {
|
|
|
7446
8757
|
}
|
|
7447
8758
|
return null;
|
|
7448
8759
|
}
|
|
7449
|
-
function getMeshAttributeMetadata(
|
|
8760
|
+
function getMeshAttributeMetadata(metadata3 = {}) {
|
|
7450
8761
|
const result = {};
|
|
7451
|
-
if (
|
|
7452
|
-
result.byteOffset = Number(
|
|
8762
|
+
if (metadata3.byteOffset !== void 0) {
|
|
8763
|
+
result.byteOffset = Number(metadata3.byteOffset);
|
|
7453
8764
|
}
|
|
7454
|
-
if (
|
|
7455
|
-
result.byteStride = Number(
|
|
8765
|
+
if (metadata3.byteStride !== void 0) {
|
|
8766
|
+
result.byteStride = Number(metadata3.byteStride);
|
|
7456
8767
|
}
|
|
7457
|
-
if (
|
|
7458
|
-
result.normalized =
|
|
8768
|
+
if (metadata3.normalized !== void 0) {
|
|
8769
|
+
result.normalized = metadata3.normalized === "true";
|
|
7459
8770
|
}
|
|
7460
|
-
if (
|
|
8771
|
+
if (metadata3.componentType === "float16") {
|
|
7461
8772
|
result.componentType = "float16";
|
|
7462
8773
|
}
|
|
7463
|
-
if (
|
|
8774
|
+
if (metadata3["loaders.gl.transform"]) {
|
|
7464
8775
|
try {
|
|
7465
|
-
const transform = JSON.parse(
|
|
8776
|
+
const transform = JSON.parse(metadata3["loaders.gl.transform"]);
|
|
7466
8777
|
if (isMeshAttributeTransform(transform)) {
|
|
7467
8778
|
result.transform = transform;
|
|
7468
8779
|
}
|
|
@@ -7487,7 +8798,7 @@ function fixMetadata(schema) {
|
|
|
7487
8798
|
schema.metadata.mode ||= "0";
|
|
7488
8799
|
}
|
|
7489
8800
|
function getAttributeTypedArray(attributeData, size) {
|
|
7490
|
-
if (!(attributeData.type instanceof
|
|
8801
|
+
if (!(attributeData.type instanceof arrow5.FixedSizeList)) {
|
|
7491
8802
|
return attributeData.toArray();
|
|
7492
8803
|
}
|
|
7493
8804
|
const values = attributeData.data[0].children[0].values;
|
|
@@ -7538,12 +8849,12 @@ function shareArrowStorage(left, right) {
|
|
|
7538
8849
|
);
|
|
7539
8850
|
}) && left.children.length === right.children.length && left.children.every((child, index) => shareArrowStorage(child, right.children[index]));
|
|
7540
8851
|
}
|
|
7541
|
-
var
|
|
8852
|
+
var arrow5;
|
|
7542
8853
|
var init_convert_table_to_mesh = __esm({
|
|
7543
8854
|
"../core/src/schema-utils/lib/mesh/convert-table-to-mesh.ts"() {
|
|
7544
8855
|
"use strict";
|
|
7545
8856
|
init_schema();
|
|
7546
|
-
|
|
8857
|
+
arrow5 = __toESM(require("apache-arrow"), 1);
|
|
7547
8858
|
init_arrow_fixed_size_list_utils();
|
|
7548
8859
|
init_convert_arrow_schema();
|
|
7549
8860
|
init_mesh_utils();
|
|
@@ -7551,17 +8862,29 @@ var init_convert_table_to_mesh = __esm({
|
|
|
7551
8862
|
});
|
|
7552
8863
|
|
|
7553
8864
|
// ../core/src/schema-utils/lib/mesh/deduce-mesh-schema.ts
|
|
8865
|
+
function deduceMeshSchema(attributes, metadata3 = {}) {
|
|
8866
|
+
const fields = deduceMeshFields(attributes);
|
|
8867
|
+
return { fields, metadata: metadata3 };
|
|
8868
|
+
}
|
|
7554
8869
|
function deduceMeshField(name22, attribute, optionalMetadata) {
|
|
7555
8870
|
const type = attribute.componentType || getDataTypeFromTypedArray(attribute.value);
|
|
7556
|
-
const
|
|
8871
|
+
const metadata3 = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
7557
8872
|
const dataType = attribute.size === 1 ? type : { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] };
|
|
7558
8873
|
return {
|
|
7559
8874
|
name: name22,
|
|
7560
8875
|
type: dataType,
|
|
7561
8876
|
nullable: false,
|
|
7562
|
-
metadata:
|
|
8877
|
+
metadata: metadata3
|
|
7563
8878
|
};
|
|
7564
8879
|
}
|
|
8880
|
+
function deduceMeshFields(attributes) {
|
|
8881
|
+
const fields = [];
|
|
8882
|
+
for (const attributeName in attributes) {
|
|
8883
|
+
const attribute = attributes[attributeName];
|
|
8884
|
+
fields.push(deduceMeshField(attributeName, attribute));
|
|
8885
|
+
}
|
|
8886
|
+
return fields;
|
|
8887
|
+
}
|
|
7565
8888
|
function makeMeshAttributeMetadata(attribute) {
|
|
7566
8889
|
const result = {};
|
|
7567
8890
|
if ("byteOffset" in attribute) {
|
|
@@ -7602,11 +8925,11 @@ var init_schema_utils = __esm({
|
|
|
7602
8925
|
});
|
|
7603
8926
|
|
|
7604
8927
|
// ../scene/src/obj/lib/get-obj-schema.ts
|
|
7605
|
-
function getOBJSchema(attributes,
|
|
8928
|
+
function getOBJSchema(attributes, metadata3 = {}) {
|
|
7606
8929
|
const stringMetadata = {};
|
|
7607
|
-
for (const key in
|
|
8930
|
+
for (const key in metadata3) {
|
|
7608
8931
|
if (key !== "value") {
|
|
7609
|
-
stringMetadata[key] = JSON.stringify(
|
|
8932
|
+
stringMetadata[key] = JSON.stringify(metadata3[key]);
|
|
7610
8933
|
}
|
|
7611
8934
|
}
|
|
7612
8935
|
const fields = [];
|
|
@@ -7618,10 +8941,10 @@ function getOBJSchema(attributes, metadata2 = {}) {
|
|
|
7618
8941
|
return { fields, metadata: stringMetadata };
|
|
7619
8942
|
}
|
|
7620
8943
|
function getFieldFromAttribute(name22, attribute) {
|
|
7621
|
-
const
|
|
8944
|
+
const metadata3 = {};
|
|
7622
8945
|
for (const key in attribute) {
|
|
7623
8946
|
if (key !== "value") {
|
|
7624
|
-
|
|
8947
|
+
metadata3[key] = JSON.stringify(attribute[key]);
|
|
7625
8948
|
}
|
|
7626
8949
|
}
|
|
7627
8950
|
let { type } = getDataTypeFromArray(attribute.value);
|
|
@@ -7629,7 +8952,7 @@ function getFieldFromAttribute(name22, attribute) {
|
|
|
7629
8952
|
if (!isSingleValue) {
|
|
7630
8953
|
type = { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "values", type }] };
|
|
7631
8954
|
}
|
|
7632
|
-
return { name: name22, type, nullable: false, metadata:
|
|
8955
|
+
return { name: name22, type, nullable: false, metadata: metadata3 };
|
|
7633
8956
|
}
|
|
7634
8957
|
var init_get_obj_schema = __esm({
|
|
7635
8958
|
"../scene/src/obj/lib/get-obj-schema.ts"() {
|
|
@@ -8192,7 +9515,7 @@ var init_obj_loader = __esm({
|
|
|
8192
9515
|
"../scene/src/obj/obj-loader.ts"() {
|
|
8193
9516
|
"use strict";
|
|
8194
9517
|
init_loader_utils();
|
|
8195
|
-
|
|
9518
|
+
init_arrow_worker_transport();
|
|
8196
9519
|
init_schema_utils();
|
|
8197
9520
|
init_get_obj_schema();
|
|
8198
9521
|
init_parse_obj();
|
|
@@ -8240,7 +9563,7 @@ var init_obj_loader_types = __esm({
|
|
|
8240
9563
|
"../scene/src/obj/obj-loader-types.ts"() {
|
|
8241
9564
|
"use strict";
|
|
8242
9565
|
init_obj_format();
|
|
8243
|
-
|
|
9566
|
+
init_arrow_worker_transport();
|
|
8244
9567
|
VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
8245
9568
|
OBJLoader = {
|
|
8246
9569
|
...OBJFormat,
|
|
@@ -8719,8 +10042,8 @@ function parseGLBChunksSync(glb, dataView, byteOffset, chunkHeaderSize, options)
|
|
|
8719
10042
|
}
|
|
8720
10043
|
function parseJSONChunk(glb, dataView, byteOffset, chunkLength, chunkIndex) {
|
|
8721
10044
|
const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
|
|
8722
|
-
const
|
|
8723
|
-
const jsonText =
|
|
10045
|
+
const textDecoder2 = new TextDecoder("utf8");
|
|
10046
|
+
const jsonText = textDecoder2.decode(jsonChunk);
|
|
8724
10047
|
glb.json = JSON.parse(jsonText);
|
|
8725
10048
|
glb.jsonChunkIndex = chunkIndex;
|
|
8726
10049
|
return padToFourBytes(chunkLength);
|
|
@@ -9510,8 +10833,8 @@ var init_gltf_scenegraph = __esm({
|
|
|
9510
10833
|
* @param mimeType
|
|
9511
10834
|
*/
|
|
9512
10835
|
addImage(imageData, mimeTypeOpt) {
|
|
9513
|
-
const
|
|
9514
|
-
const mimeType = mimeTypeOpt || (
|
|
10836
|
+
const metadata3 = getBinaryImageMetadata(imageData);
|
|
10837
|
+
const mimeType = mimeTypeOpt || (metadata3 == null ? void 0 : metadata3.mimeType);
|
|
9515
10838
|
const bufferViewIndex = this.addBufferView(imageData);
|
|
9516
10839
|
const glTFImage = {
|
|
9517
10840
|
bufferView: bufferViewIndex,
|
|
@@ -10394,8 +11717,8 @@ var init_gltf_iterator = __esm({
|
|
|
10394
11717
|
}
|
|
10395
11718
|
/** Return the loaded buffer companion for a raw buffer definition. */
|
|
10396
11719
|
getLoadedBuffer(buffer) {
|
|
10397
|
-
const
|
|
10398
|
-
return this.gltf.buffers[
|
|
11720
|
+
const metadata3 = this.getMetadata(buffer);
|
|
11721
|
+
return this.gltf.buffers[metadata3.index];
|
|
10399
11722
|
}
|
|
10400
11723
|
/** Return the loaded byte range for a raw buffer-view definition. */
|
|
10401
11724
|
getLoadedBufferView(bufferView) {
|
|
@@ -10950,7 +12273,7 @@ function parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount,
|
|
|
10950
12273
|
return attributeValueArray;
|
|
10951
12274
|
}
|
|
10952
12275
|
function getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets, fixedArrayCount) {
|
|
10953
|
-
const
|
|
12276
|
+
const textDecoder2 = new TextDecoder("utf8");
|
|
10954
12277
|
if (arrayOffsets) {
|
|
10955
12278
|
if (!stringOffsets) {
|
|
10956
12279
|
throw new Error("stringOffsets is required for variable-length string arrays");
|
|
@@ -10964,7 +12287,7 @@ function getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets,
|
|
|
10964
12287
|
const startByte = stringOffsets[stringIndex];
|
|
10965
12288
|
const endByte = stringOffsets[stringIndex + 1];
|
|
10966
12289
|
const stringData = valuesDataBytes.subarray(startByte, endByte);
|
|
10967
|
-
strings.push(
|
|
12290
|
+
strings.push(textDecoder2.decode(stringData));
|
|
10968
12291
|
}
|
|
10969
12292
|
result.push(strings);
|
|
10970
12293
|
}
|
|
@@ -10977,7 +12300,7 @@ function getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets,
|
|
|
10977
12300
|
const startByte = Number(stringOffsets[index]);
|
|
10978
12301
|
const endByte = Number(stringOffsets[index + 1]);
|
|
10979
12302
|
if (startByte >= 0 && endByte >= startByte && endByte <= valuesDataBytes.length) {
|
|
10980
|
-
stringsArray.push(
|
|
12303
|
+
stringsArray.push(textDecoder2.decode(valuesDataBytes.subarray(startByte, endByte)));
|
|
10981
12304
|
}
|
|
10982
12305
|
}
|
|
10983
12306
|
return fixedArrayCount ? Array.from(
|
|
@@ -11870,7 +13193,7 @@ __export(KHR_gaussian_splatting_exports, {
|
|
|
11870
13193
|
name: () => name4
|
|
11871
13194
|
});
|
|
11872
13195
|
async function decode3(gltfData, options, context) {
|
|
11873
|
-
var _a, _b, _c, _d, _e;
|
|
13196
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
11874
13197
|
const loader = (_a = context == null ? void 0 : context.loaders) == null ? void 0 : _a.find((candidate) => {
|
|
11875
13198
|
var _a2;
|
|
11876
13199
|
return (_a2 = candidate.extensions) == null ? void 0 : _a2.includes("spz");
|
|
@@ -11881,22 +13204,29 @@ async function decode3(gltfData, options, context) {
|
|
|
11881
13204
|
for (const [primitiveIndex, primitive] of mesh.primitives.entries()) {
|
|
11882
13205
|
const extension = (_b = primitive.extensions) == null ? void 0 : _b[name4];
|
|
11883
13206
|
if (!extension) continue;
|
|
13207
|
+
const descriptor = descriptors.find(
|
|
13208
|
+
(item) => item.meshIndex === meshIndex && item.primitiveIndex === primitiveIndex
|
|
13209
|
+
);
|
|
13210
|
+
const legacyColorSpace = (_c = options == null ? void 0 : options.gltf) == null ? void 0 : _c.legacyGaussianSplatColorSpace;
|
|
13211
|
+
const normalizedExtension = legacyColorSpace && ((_d = extension.extensions) == null ? void 0 : _d[SPZ_COMPRESSION_EXTENSION_NAME]) ? {
|
|
13212
|
+
...extension,
|
|
13213
|
+
kernel: extension.kernel ?? "ellipse",
|
|
13214
|
+
colorSpace: extension.colorSpace ?? legacyColorSpace
|
|
13215
|
+
} : extension;
|
|
13216
|
+
if (descriptor) descriptor.extension = normalizedExtension;
|
|
11884
13217
|
validateGaussianSplatPrimitive(
|
|
11885
13218
|
gltfData.json,
|
|
11886
13219
|
primitive,
|
|
11887
|
-
|
|
13220
|
+
normalizedExtension,
|
|
11888
13221
|
meshIndex,
|
|
11889
13222
|
primitiveIndex,
|
|
11890
13223
|
iterator
|
|
11891
13224
|
);
|
|
11892
|
-
const compression = (
|
|
13225
|
+
const compression = (_e = extension.extensions) == null ? void 0 : _e[SPZ_COMPRESSION_EXTENSION_NAME];
|
|
11893
13226
|
if (compression) {
|
|
11894
|
-
const descriptor = descriptors.find(
|
|
11895
|
-
(item) => item.meshIndex === meshIndex && item.primitiveIndex === primitiveIndex
|
|
11896
|
-
);
|
|
11897
13227
|
if (descriptor) {
|
|
11898
|
-
const decoder = (
|
|
11899
|
-
const bufferView = (
|
|
13228
|
+
const decoder = (_f = options == null ? void 0 : options.gltf) == null ? void 0 : _f.splatDecoder;
|
|
13229
|
+
const bufferView = (_g = gltfData.json.bufferViews) == null ? void 0 : _g[compression.bufferView];
|
|
11900
13230
|
if (bufferView && gltfData.buffers[bufferView.buffer]) {
|
|
11901
13231
|
descriptor.compressedBytes = getBufferViewBytes(gltfData, compression.bufferView);
|
|
11902
13232
|
} else if (decoder || loader) {
|
|
@@ -13473,7 +14803,7 @@ var init_draco_module_loader = __esm({
|
|
|
13473
14803
|
|
|
13474
14804
|
// ../scene/src/draco/lib/utils/get-draco-schema.ts
|
|
13475
14805
|
function getDracoSchema(attributes, loaderData, indices) {
|
|
13476
|
-
const
|
|
14806
|
+
const metadata3 = makeMetadata(loaderData.metadata);
|
|
13477
14807
|
const fields = [];
|
|
13478
14808
|
const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes);
|
|
13479
14809
|
for (const attributeName in attributes) {
|
|
@@ -13489,7 +14819,7 @@ function getDracoSchema(attributes, loaderData, indices) {
|
|
|
13489
14819
|
const indicesField = getArrowFieldFromAttribute("indices", indices);
|
|
13490
14820
|
fields.push(indicesField);
|
|
13491
14821
|
}
|
|
13492
|
-
return { fields, metadata:
|
|
14822
|
+
return { fields, metadata: metadata3 };
|
|
13493
14823
|
}
|
|
13494
14824
|
function transformAttributesLoaderData(loaderData) {
|
|
13495
14825
|
const result = {};
|
|
@@ -13507,11 +14837,11 @@ function getArrowFieldFromAttribute(attributeName, attribute, loaderData) {
|
|
|
13507
14837
|
const field = deduceMeshField(attributeName, attribute, metadataMap);
|
|
13508
14838
|
return field;
|
|
13509
14839
|
}
|
|
13510
|
-
function makeMetadata(
|
|
13511
|
-
Object.entries(
|
|
14840
|
+
function makeMetadata(metadata3) {
|
|
14841
|
+
Object.entries(metadata3);
|
|
13512
14842
|
const serializedMetadata = {};
|
|
13513
|
-
for (const key in
|
|
13514
|
-
serializedMetadata[`${key}.string`] = JSON.stringify(
|
|
14843
|
+
for (const key in metadata3) {
|
|
14844
|
+
serializedMetadata[`${key}.string`] = JSON.stringify(metadata3[key]);
|
|
13515
14845
|
}
|
|
13516
14846
|
return serializedMetadata;
|
|
13517
14847
|
}
|
|
@@ -13730,14 +15060,14 @@ var init_draco_parser = __esm({
|
|
|
13730
15060
|
* @returns
|
|
13731
15061
|
*/
|
|
13732
15062
|
_getDracoLoaderData(dracoGeometry, geometry_type, options) {
|
|
13733
|
-
const
|
|
15063
|
+
const metadata3 = this._getTopLevelMetadata(dracoGeometry);
|
|
13734
15064
|
const attributes = this._getDracoAttributes(dracoGeometry, options);
|
|
13735
15065
|
return {
|
|
13736
15066
|
geometry_type,
|
|
13737
15067
|
num_attributes: dracoGeometry.num_attributes(),
|
|
13738
15068
|
num_points: dracoGeometry.num_points(),
|
|
13739
15069
|
num_faces: dracoGeometry instanceof this.draco.Mesh ? dracoGeometry.num_faces() : 0,
|
|
13740
|
-
metadata:
|
|
15070
|
+
metadata: metadata3,
|
|
13741
15071
|
attributes
|
|
13742
15072
|
};
|
|
13743
15073
|
}
|
|
@@ -13751,7 +15081,7 @@ var init_draco_parser = __esm({
|
|
|
13751
15081
|
const dracoAttributes = {};
|
|
13752
15082
|
for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
|
|
13753
15083
|
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
|
|
13754
|
-
const
|
|
15084
|
+
const metadata3 = this._getAttributeMetadata(dracoGeometry, attributeId);
|
|
13755
15085
|
dracoAttributes[dracoAttribute.unique_id()] = {
|
|
13756
15086
|
unique_id: dracoAttribute.unique_id(),
|
|
13757
15087
|
attribute_type: dracoAttribute.attribute_type(),
|
|
@@ -13761,7 +15091,7 @@ var init_draco_parser = __esm({
|
|
|
13761
15091
|
byte_stride: dracoAttribute.byte_stride(),
|
|
13762
15092
|
normalized: dracoAttribute.normalized(),
|
|
13763
15093
|
attribute_index: attributeId,
|
|
13764
|
-
metadata:
|
|
15094
|
+
metadata: metadata3
|
|
13765
15095
|
};
|
|
13766
15096
|
const quantization = this._getQuantizationTransform(dracoAttribute, options);
|
|
13767
15097
|
if (quantization) {
|
|
@@ -14280,7 +15610,7 @@ var DracoLoader, DracoWorkerLoader;
|
|
|
14280
15610
|
var init_draco_loader_types = __esm({
|
|
14281
15611
|
"../scene/src/draco/draco-loader-types.ts"() {
|
|
14282
15612
|
"use strict";
|
|
14283
|
-
|
|
15613
|
+
init_arrow_worker_transport();
|
|
14284
15614
|
init_version4();
|
|
14285
15615
|
init_draco_format();
|
|
14286
15616
|
init_draco_loader_options();
|
|
@@ -14860,10 +16190,10 @@ async function encode5(gltfData, options) {
|
|
|
14860
16190
|
}
|
|
14861
16191
|
function resolveTechniques(techniquesExtension, iterator) {
|
|
14862
16192
|
const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
|
|
14863
|
-
const
|
|
16193
|
+
const textDecoder2 = new TextDecoder();
|
|
14864
16194
|
shaders.forEach((shader) => {
|
|
14865
16195
|
if (Number.isFinite(shader.bufferView)) {
|
|
14866
|
-
shader.code =
|
|
16196
|
+
shader.code = textDecoder2.decode(
|
|
14867
16197
|
getTypedArrayForBufferView(iterator.data, iterator.gltf.buffers, shader.bufferView)
|
|
14868
16198
|
);
|
|
14869
16199
|
} else {
|
|
@@ -17520,8 +18850,8 @@ function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
|
17520
18850
|
gltf.baseUri = (_b = options.core) == null ? void 0 : _b.baseUrl;
|
|
17521
18851
|
}
|
|
17522
18852
|
if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options.glb)) {
|
|
17523
|
-
const
|
|
17524
|
-
data =
|
|
18853
|
+
const textDecoder2 = new TextDecoder();
|
|
18854
|
+
data = textDecoder2.decode(data);
|
|
17525
18855
|
}
|
|
17526
18856
|
if (typeof data === "string") {
|
|
17527
18857
|
gltf.json = parseJSON(data);
|
|
@@ -18649,9 +19979,9 @@ var init_draco_builder = __esm({
|
|
|
18649
19979
|
* @param dracoGeometry - WASM Draco Object
|
|
18650
19980
|
* @param metadata
|
|
18651
19981
|
*/
|
|
18652
|
-
_addGeometryMetadata(dracoGeometry,
|
|
19982
|
+
_addGeometryMetadata(dracoGeometry, metadata3) {
|
|
18653
19983
|
const dracoMetadata = new this.draco.Metadata();
|
|
18654
|
-
this._populateDracoMetadata(dracoMetadata,
|
|
19984
|
+
this._populateDracoMetadata(dracoMetadata, metadata3);
|
|
18655
19985
|
this.dracoMeshBuilder.AddMetadata(dracoGeometry, dracoMetadata);
|
|
18656
19986
|
}
|
|
18657
19987
|
/**
|
|
@@ -18660,9 +19990,9 @@ var init_draco_builder = __esm({
|
|
|
18660
19990
|
* @param uniqueAttributeId
|
|
18661
19991
|
* @param metadata
|
|
18662
19992
|
*/
|
|
18663
|
-
_addAttributeMetadata(dracoGeometry, uniqueAttributeId,
|
|
19993
|
+
_addAttributeMetadata(dracoGeometry, uniqueAttributeId, metadata3) {
|
|
18664
19994
|
const dracoAttributeMetadata = new this.draco.Metadata();
|
|
18665
|
-
this._populateDracoMetadata(dracoAttributeMetadata,
|
|
19995
|
+
this._populateDracoMetadata(dracoAttributeMetadata, metadata3);
|
|
18666
19996
|
this.dracoMeshBuilder.SetMetadataForAttribute(
|
|
18667
19997
|
dracoGeometry,
|
|
18668
19998
|
uniqueAttributeId,
|
|
@@ -18674,8 +20004,8 @@ var init_draco_builder = __esm({
|
|
|
18674
20004
|
* @param dracoMetadata - WASM Draco Object
|
|
18675
20005
|
* @param metadata
|
|
18676
20006
|
*/
|
|
18677
|
-
_populateDracoMetadata(dracoMetadata,
|
|
18678
|
-
for (const [key, value] of getEntries(
|
|
20007
|
+
_populateDracoMetadata(dracoMetadata, metadata3) {
|
|
20008
|
+
for (const [key, value] of getEntries(metadata3)) {
|
|
18679
20009
|
switch (typeof value) {
|
|
18680
20010
|
case "number":
|
|
18681
20011
|
if (Math.trunc(value) === value) {
|
|
@@ -20889,6 +22219,132 @@ var init_materialx_loader_types = __esm({
|
|
|
20889
22219
|
}
|
|
20890
22220
|
});
|
|
20891
22221
|
|
|
22222
|
+
// ../scene/src/stl/parse-stl.ts
|
|
22223
|
+
function parseSTL(data) {
|
|
22224
|
+
const view = new DataView(data);
|
|
22225
|
+
const binary2 = data.byteLength >= 84 && 84 + view.getUint32(80, true) * 50 === data.byteLength;
|
|
22226
|
+
let positions;
|
|
22227
|
+
let normals;
|
|
22228
|
+
let header;
|
|
22229
|
+
if (binary2) {
|
|
22230
|
+
const triangleCount = view.getUint32(80, true);
|
|
22231
|
+
positions = new Float32Array(triangleCount * 9);
|
|
22232
|
+
normals = new Float32Array(triangleCount * 9);
|
|
22233
|
+
header = new TextDecoder().decode(data.slice(0, 80));
|
|
22234
|
+
for (let triangle = 0; triangle < triangleCount; triangle++) {
|
|
22235
|
+
const offset = 84 + triangle * 50;
|
|
22236
|
+
for (let component = 0; component < 9; component++) {
|
|
22237
|
+
positions[triangle * 9 + component] = view.getFloat32(offset + 12 + component * 4, true);
|
|
22238
|
+
normals[triangle * 9 + component] = view.getFloat32(offset + component % 3 * 4, true);
|
|
22239
|
+
}
|
|
22240
|
+
}
|
|
22241
|
+
} else {
|
|
22242
|
+
const lines = new TextDecoder().decode(data).trim().split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
22243
|
+
const vertices = [];
|
|
22244
|
+
const normalValues = [];
|
|
22245
|
+
header = lines[0] || "";
|
|
22246
|
+
let lineIndex = 0;
|
|
22247
|
+
while (lineIndex < lines.length) {
|
|
22248
|
+
if (!/^solid(?:\s|$)/i.test(lines[lineIndex++]))
|
|
22249
|
+
throw new Error("STL: expected solid header or exact binary length");
|
|
22250
|
+
while (lineIndex < lines.length && !/^endsolid(?:\s|$)/i.test(lines[lineIndex])) {
|
|
22251
|
+
const normal = parseVector(lines[lineIndex++], "facet normal");
|
|
22252
|
+
if (!/^outer\s+loop$/i.test(lines[lineIndex++] || ""))
|
|
22253
|
+
throw new Error("STL: expected outer loop");
|
|
22254
|
+
for (let vertex = 0; vertex < 3; vertex++) {
|
|
22255
|
+
vertices.push(...parseVector(lines[lineIndex++], "vertex"));
|
|
22256
|
+
normalValues.push(...normal);
|
|
22257
|
+
}
|
|
22258
|
+
if (!/^endloop$/i.test(lines[lineIndex++] || "") || !/^endfacet$/i.test(lines[lineIndex++] || ""))
|
|
22259
|
+
throw new Error("STL: incomplete facet");
|
|
22260
|
+
}
|
|
22261
|
+
if (lineIndex >= lines.length) throw new Error("STL: missing endsolid");
|
|
22262
|
+
lineIndex++;
|
|
22263
|
+
}
|
|
22264
|
+
if (!lines.length) throw new Error("STL: empty input");
|
|
22265
|
+
positions = new Float32Array(vertices);
|
|
22266
|
+
normals = new Float32Array(normalValues);
|
|
22267
|
+
}
|
|
22268
|
+
if (!positions.every(Number.isFinite) || !normals.every(Number.isFinite))
|
|
22269
|
+
throw new Error("STL: non-finite coordinates");
|
|
22270
|
+
const attributes = { POSITION: { value: positions, size: 3 }, NORMAL: { value: normals, size: 3 } };
|
|
22271
|
+
return {
|
|
22272
|
+
topology: "triangle-list",
|
|
22273
|
+
mode: 4,
|
|
22274
|
+
attributes,
|
|
22275
|
+
schema: deduceMeshSchema(attributes),
|
|
22276
|
+
header: {
|
|
22277
|
+
vertexCount: positions.length / 3,
|
|
22278
|
+
boundingBox: getMeshBoundingBox(attributes) ?? void 0
|
|
22279
|
+
},
|
|
22280
|
+
loaderData: { header, format: binary2 ? "binary" : "ascii" }
|
|
22281
|
+
};
|
|
22282
|
+
}
|
|
22283
|
+
function parseVector(line, prefix) {
|
|
22284
|
+
const tokens = (line == null ? void 0 : line.split(/\s+/)) || [];
|
|
22285
|
+
const prefixTokens = prefix.split(" ");
|
|
22286
|
+
const components = tokens.slice(prefixTokens.length);
|
|
22287
|
+
if (prefixTokens.some((token, index) => {
|
|
22288
|
+
var _a;
|
|
22289
|
+
return ((_a = tokens[index]) == null ? void 0 : _a.toLowerCase()) !== token;
|
|
22290
|
+
}) || components.length !== 3 || components.some((value) => !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(value))) {
|
|
22291
|
+
throw new Error(`STL: invalid ${prefix} record`);
|
|
22292
|
+
}
|
|
22293
|
+
return components.map(Number);
|
|
22294
|
+
}
|
|
22295
|
+
var init_parse_stl = __esm({
|
|
22296
|
+
"../scene/src/stl/parse-stl.ts"() {
|
|
22297
|
+
"use strict";
|
|
22298
|
+
init_schema_utils();
|
|
22299
|
+
}
|
|
22300
|
+
});
|
|
22301
|
+
|
|
22302
|
+
// ../scene/src/stl-loader.ts
|
|
22303
|
+
var stl_loader_exports = {};
|
|
22304
|
+
__export(stl_loader_exports, {
|
|
22305
|
+
STLLoaderWithParser: () => STLLoaderWithParser
|
|
22306
|
+
});
|
|
22307
|
+
var _preload2, metadata2, STLLoaderWithParser;
|
|
22308
|
+
var init_stl_loader = __esm({
|
|
22309
|
+
"../scene/src/stl-loader.ts"() {
|
|
22310
|
+
"use strict";
|
|
22311
|
+
init_stl_loader_types();
|
|
22312
|
+
init_parse_stl();
|
|
22313
|
+
({ preload: _preload2, ...metadata2 } = STLLoader);
|
|
22314
|
+
STLLoaderWithParser = {
|
|
22315
|
+
...metadata2,
|
|
22316
|
+
parse: async (data) => parseSTL(data),
|
|
22317
|
+
parseSync: parseSTL
|
|
22318
|
+
};
|
|
22319
|
+
}
|
|
22320
|
+
});
|
|
22321
|
+
|
|
22322
|
+
// ../scene/src/stl-loader-types.ts
|
|
22323
|
+
async function preload11() {
|
|
22324
|
+
const { STLLoaderWithParser: STLLoaderWithParser2 } = await Promise.resolve().then(() => (init_stl_loader(), stl_loader_exports));
|
|
22325
|
+
return STLLoaderWithParser2;
|
|
22326
|
+
}
|
|
22327
|
+
var VERSION10, STLLoader;
|
|
22328
|
+
var init_stl_loader_types = __esm({
|
|
22329
|
+
"../scene/src/stl-loader-types.ts"() {
|
|
22330
|
+
"use strict";
|
|
22331
|
+
VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
22332
|
+
STLLoader = {
|
|
22333
|
+
name: "STL",
|
|
22334
|
+
id: "stl",
|
|
22335
|
+
module: "scene",
|
|
22336
|
+
version: VERSION10,
|
|
22337
|
+
extensions: ["stl"],
|
|
22338
|
+
mimeTypes: ["model/stl"],
|
|
22339
|
+
binary: true,
|
|
22340
|
+
dataType: null,
|
|
22341
|
+
batchType: null,
|
|
22342
|
+
options: {},
|
|
22343
|
+
preload: preload11
|
|
22344
|
+
};
|
|
22345
|
+
}
|
|
22346
|
+
});
|
|
22347
|
+
|
|
20892
22348
|
// ../scene/src/index.ts
|
|
20893
22349
|
var src_exports = {};
|
|
20894
22350
|
__export(src_exports, {
|
|
@@ -20911,6 +22367,7 @@ __export(src_exports, {
|
|
|
20911
22367
|
OBJLoader: () => OBJLoader,
|
|
20912
22368
|
OBJWorkerLoader: () => OBJWorkerLoader,
|
|
20913
22369
|
OBJWriter: () => OBJWriter,
|
|
22370
|
+
STLLoader: () => STLLoader,
|
|
20914
22371
|
USDLoader: () => USDLoader
|
|
20915
22372
|
});
|
|
20916
22373
|
var init_src2 = __esm({
|
|
@@ -20931,6 +22388,7 @@ var init_src2 = __esm({
|
|
|
20931
22388
|
init_draco_format();
|
|
20932
22389
|
init_draco_libraries();
|
|
20933
22390
|
init_materialx_loader_types();
|
|
22391
|
+
init_stl_loader_types();
|
|
20934
22392
|
}
|
|
20935
22393
|
});
|
|
20936
22394
|
|
|
@@ -24960,7 +26418,7 @@ var init_i3s_source = __esm({
|
|
|
24960
26418
|
const contentUrl = this.getTileUrl(tile.contentUrl);
|
|
24961
26419
|
const loaderId = this.loader.id;
|
|
24962
26420
|
const loaderOptions = this.loadOptions[loaderId] || {};
|
|
24963
|
-
const
|
|
26421
|
+
const metadata3 = this.getMetadata();
|
|
24964
26422
|
const options = {
|
|
24965
26423
|
...this.loadOptions,
|
|
24966
26424
|
[loaderId]: {
|
|
@@ -24980,9 +26438,9 @@ var init_i3s_source = __esm({
|
|
|
24980
26438
|
mbs: tile.header.mbs
|
|
24981
26439
|
},
|
|
24982
26440
|
_tilesetOptions: {
|
|
24983
|
-
store:
|
|
24984
|
-
attributeStorageInfo:
|
|
24985
|
-
fields:
|
|
26441
|
+
store: metadata3.tileset.store,
|
|
26442
|
+
attributeStorageInfo: metadata3.tileset.attributeStorageInfo,
|
|
26443
|
+
fields: metadata3.tileset.fields,
|
|
24986
26444
|
spatialReference: tile.tileset.spatialReference,
|
|
24987
26445
|
spatialOptions: tile.tileset.options.spatial
|
|
24988
26446
|
},
|
|
@@ -25006,9 +26464,9 @@ var init_i3s_source = __esm({
|
|
|
25006
26464
|
* Loads child tile metadata on demand from node pages or `/nodes/{id}` resources.
|
|
25007
26465
|
*/
|
|
25008
26466
|
async loadChildTileHeader(_parentTile, childId, _frameState) {
|
|
25009
|
-
const
|
|
25010
|
-
if (
|
|
25011
|
-
const header2 = await
|
|
26467
|
+
const metadata3 = this.getMetadata();
|
|
26468
|
+
if (metadata3.tileset.nodePages || metadata3.tileset.pointNodePages) {
|
|
26469
|
+
const header2 = await metadata3.tileset.nodePagesTile.formTileFromNodePages(childId);
|
|
25012
26470
|
return await this.transformTileHeader(header2);
|
|
25013
26471
|
}
|
|
25014
26472
|
const nodeUrl = this.getTileUrl(`${this.url}/nodes/${childId}`);
|
|
@@ -25111,8 +26569,8 @@ var init_i3s_source = __esm({
|
|
|
25111
26569
|
zoom: 1
|
|
25112
26570
|
};
|
|
25113
26571
|
}
|
|
25114
|
-
const
|
|
25115
|
-
const fullExtent =
|
|
26572
|
+
const metadata3 = this.getMetadata();
|
|
26573
|
+
const fullExtent = metadata3.tileset.fullExtent;
|
|
25116
26574
|
if (fullExtent) {
|
|
25117
26575
|
const { xmin, xmax, ymin, ymax, zmin, zmax } = fullExtent;
|
|
25118
26576
|
const cartographicCenter = new import_core13.Vector3(
|
|
@@ -25128,7 +26586,7 @@ var init_i3s_source = __esm({
|
|
|
25128
26586
|
zoom: getZoomFromFullExtent(fullExtent, cartographicCenter, cartesianCenter)
|
|
25129
26587
|
};
|
|
25130
26588
|
}
|
|
25131
|
-
const extent = (_a =
|
|
26589
|
+
const extent = (_a = metadata3.tileset.store) == null ? void 0 : _a.extent;
|
|
25132
26590
|
if (extent) {
|
|
25133
26591
|
const [xmin, ymin, xmax, ymax] = extent;
|
|
25134
26592
|
const cartographicCenter = new import_core13.Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0);
|
|
@@ -25168,8 +26626,8 @@ var init_i3s_source = __esm({
|
|
|
25168
26626
|
*/
|
|
25169
26627
|
getTilesTotalCount() {
|
|
25170
26628
|
var _a, _b;
|
|
25171
|
-
const
|
|
25172
|
-
return ((_b = (_a =
|
|
26629
|
+
const metadata3 = this.getMetadata();
|
|
26630
|
+
return ((_b = (_a = metadata3.tileset) == null ? void 0 : _a.nodePagesTile) == null ? void 0 : _b.nodesInNodePages) || null;
|
|
25173
26631
|
}
|
|
25174
26632
|
/**
|
|
25175
26633
|
* Loads data through injected core APIs so this module stays independent from `@loaders.gl/core`.
|
|
@@ -25749,20 +27207,20 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
|
25749
27207
|
function parsePositions(attribute, options) {
|
|
25750
27208
|
const mbs = options.mbs;
|
|
25751
27209
|
const value = attribute.value;
|
|
25752
|
-
const
|
|
27210
|
+
const metadata3 = attribute.metadata;
|
|
25753
27211
|
const enuMatrix = new import_core14.Matrix4();
|
|
25754
27212
|
const cartographicOrigin = new import_core14.Vector3(mbs[0], mbs[1], mbs[2]);
|
|
25755
27213
|
const cartesianOrigin = new import_core14.Vector3();
|
|
25756
27214
|
import_geospatial8.Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);
|
|
25757
27215
|
(0, import_geospatial9.eastNorthUpToFixedFrame)(import_geospatial8.Ellipsoid.WGS84, cartesianOrigin, enuMatrix);
|
|
25758
|
-
attribute.value = offsetsToCartesians(value,
|
|
27216
|
+
attribute.value = offsetsToCartesians(value, metadata3, cartographicOrigin);
|
|
25759
27217
|
return enuMatrix;
|
|
25760
27218
|
}
|
|
25761
|
-
function offsetsToSourcePositions(vertices,
|
|
27219
|
+
function offsetsToSourcePositions(vertices, metadata3 = {}, sourceOrigin) {
|
|
25762
27220
|
var _a, _b;
|
|
25763
27221
|
const positions = new Float64Array(vertices.length);
|
|
25764
|
-
const scaleX = ((_a =
|
|
25765
|
-
const scaleY = ((_b =
|
|
27222
|
+
const scaleX = ((_a = metadata3["i3s-scale_x"]) == null ? void 0 : _a.double) ?? 1;
|
|
27223
|
+
const scaleY = ((_b = metadata3["i3s-scale_y"]) == null ? void 0 : _b.double) ?? 1;
|
|
25766
27224
|
for (let index = 0; index < positions.length; index += 3) {
|
|
25767
27225
|
positions[index] = vertices[index] * scaleX + sourceOrigin[0];
|
|
25768
27226
|
positions[index + 1] = vertices[index + 1] * scaleY + sourceOrigin[1];
|
|
@@ -25770,8 +27228,8 @@ function offsetsToSourcePositions(vertices, metadata2 = {}, sourceOrigin) {
|
|
|
25770
27228
|
}
|
|
25771
27229
|
return positions;
|
|
25772
27230
|
}
|
|
25773
|
-
function offsetsToCartesians(vertices,
|
|
25774
|
-
const positions = offsetsToSourcePositions(vertices,
|
|
27231
|
+
function offsetsToCartesians(vertices, metadata3 = {}, cartographicOrigin) {
|
|
27232
|
+
const positions = offsetsToSourcePositions(vertices, metadata3, cartographicOrigin);
|
|
25775
27233
|
for (let i = 0; i < positions.length; i += 3) {
|
|
25776
27234
|
import_geospatial8.Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector4);
|
|
25777
27235
|
positions[i] = scratchVector4.x;
|
|
@@ -25782,9 +27240,9 @@ function offsetsToCartesians(vertices, metadata2 = {}, cartographicOrigin) {
|
|
|
25782
27240
|
}
|
|
25783
27241
|
function getModelMatrix(positions) {
|
|
25784
27242
|
var _a, _b;
|
|
25785
|
-
const
|
|
25786
|
-
const scaleX = ((_a =
|
|
25787
|
-
const scaleY = ((_b =
|
|
27243
|
+
const metadata3 = positions.metadata;
|
|
27244
|
+
const scaleX = ((_a = metadata3 == null ? void 0 : metadata3["i3s-scale_x"]) == null ? void 0 : _a.double) || 1;
|
|
27245
|
+
const scaleY = ((_b = metadata3 == null ? void 0 : metadata3["i3s-scale_y"]) == null ? void 0 : _b.double) || 1;
|
|
25788
27246
|
const modelMatrix = new import_core14.Matrix4();
|
|
25789
27247
|
modelMatrix[0] = scaleX;
|
|
25790
27248
|
modelMatrix[5] = scaleY;
|
|
@@ -26010,13 +27468,13 @@ var init_i3s_content_loader_with_parser = __esm({
|
|
|
26010
27468
|
});
|
|
26011
27469
|
|
|
26012
27470
|
// dist/i3s/i3s-content-loader.js
|
|
26013
|
-
var
|
|
27471
|
+
var VERSION11, I3SContentLoader;
|
|
26014
27472
|
var init_i3s_content_loader = __esm({
|
|
26015
27473
|
"dist/i3s/i3s-content-loader.js"() {
|
|
26016
27474
|
"use strict";
|
|
26017
27475
|
init_i3s_format();
|
|
26018
27476
|
init_i3s_loader_options();
|
|
26019
|
-
|
|
27477
|
+
VERSION11 = true ? "5.0.0-beta.5" : "latest";
|
|
26020
27478
|
I3SContentLoader = {
|
|
26021
27479
|
...I3SContentFormat,
|
|
26022
27480
|
dataType: null,
|
|
@@ -26026,7 +27484,7 @@ var init_i3s_content_loader = __esm({
|
|
|
26026
27484
|
module: "tiles-3d",
|
|
26027
27485
|
worker: true,
|
|
26028
27486
|
workerSourceNode: "i3s/workers/i3s-content-worker-node.ts",
|
|
26029
|
-
version:
|
|
27487
|
+
version: VERSION11,
|
|
26030
27488
|
mimeTypes: ["application/octet-stream"],
|
|
26031
27489
|
/** Loads the parser-bearing I3S content loader implementation. */
|
|
26032
27490
|
preload: async () => (await Promise.resolve().then(() => (init_i3s_content_loader_with_parser(), i3s_content_loader_with_parser_exports))).I3SContentLoaderWithParser,
|
|
@@ -26040,12 +27498,12 @@ var init_i3s_content_loader = __esm({
|
|
|
26040
27498
|
});
|
|
26041
27499
|
|
|
26042
27500
|
// dist/i3s/i3s-node-page-loader.js
|
|
26043
|
-
var
|
|
27501
|
+
var VERSION12, I3SNodePageLoader;
|
|
26044
27502
|
var init_i3s_node_page_loader = __esm({
|
|
26045
27503
|
"dist/i3s/i3s-node-page-loader.js"() {
|
|
26046
27504
|
"use strict";
|
|
26047
27505
|
init_i3s_format();
|
|
26048
|
-
|
|
27506
|
+
VERSION12 = true ? "5.0.0-beta.5" : "latest";
|
|
26049
27507
|
I3SNodePageLoader = {
|
|
26050
27508
|
...I3SNodePageFormat,
|
|
26051
27509
|
dataType: null,
|
|
@@ -26053,7 +27511,7 @@ var init_i3s_node_page_loader = __esm({
|
|
|
26053
27511
|
name: "I3S Node Page",
|
|
26054
27512
|
id: "i3s-node-page",
|
|
26055
27513
|
module: "tiles-3d",
|
|
26056
|
-
version:
|
|
27514
|
+
version: VERSION12,
|
|
26057
27515
|
mimeTypes: ["application/json"],
|
|
26058
27516
|
/** Loads the parser-bearing I3S node page loader implementation. */
|
|
26059
27517
|
preload: async () => (await Promise.resolve().then(() => (init_i3s_node_page_loader_with_parser(), i3s_node_page_loader_with_parser_exports))).I3SNodePageLoaderWithParser,
|
|
@@ -26735,14 +28193,14 @@ var init_i3s_loader_with_parser = __esm({
|
|
|
26735
28193
|
});
|
|
26736
28194
|
|
|
26737
28195
|
// dist/i3s/i3s-loader.js
|
|
26738
|
-
var
|
|
28196
|
+
var VERSION13, I3SLoader;
|
|
26739
28197
|
var init_i3s_loader = __esm({
|
|
26740
28198
|
"dist/i3s/i3s-loader.js"() {
|
|
26741
28199
|
"use strict";
|
|
26742
28200
|
init_i3s_format();
|
|
26743
28201
|
init_i3s_content_loader();
|
|
26744
28202
|
init_i3s_loader_options();
|
|
26745
|
-
|
|
28203
|
+
VERSION13 = true ? "5.0.0-beta.5" : "latest";
|
|
26746
28204
|
I3SLoader = {
|
|
26747
28205
|
...I3SFormat,
|
|
26748
28206
|
dataType: null,
|
|
@@ -26752,7 +28210,7 @@ var init_i3s_loader = __esm({
|
|
|
26752
28210
|
module: "tiles-3d",
|
|
26753
28211
|
/** Worker-capable loader used by I3S sources for binary tile content. */
|
|
26754
28212
|
contentLoader: I3SContentLoader,
|
|
26755
|
-
version:
|
|
28213
|
+
version: VERSION13,
|
|
26756
28214
|
mimeTypes: ["application/octet-stream"],
|
|
26757
28215
|
/** Loads the parser-bearing I3S loader implementation. */
|
|
26758
28216
|
preload: async () => (await Promise.resolve().then(() => (init_i3s_loader_with_parser(), i3s_loader_with_parser_exports))).I3SLoaderWithParser,
|
|
@@ -28147,11 +29605,11 @@ var init_compress_utils_compression = __esm({
|
|
|
28147
29605
|
/** Shared import and WASM initialization for concurrent callers. */
|
|
28148
29606
|
modulePromise = null;
|
|
28149
29607
|
/** Creates a format-specific compress-utils encoder. */
|
|
28150
|
-
constructor(
|
|
29608
|
+
constructor(metadata3, loadModule, options = {}) {
|
|
28151
29609
|
super(options);
|
|
28152
|
-
this.name =
|
|
28153
|
-
this.extensions =
|
|
28154
|
-
this.contentEncodings =
|
|
29610
|
+
this.name = metadata3.name;
|
|
29611
|
+
this.extensions = metadata3.extensions || [];
|
|
29612
|
+
this.contentEncodings = metadata3.contentEncodings || [];
|
|
28155
29613
|
this.loadModule = loadModule;
|
|
28156
29614
|
this.options = options;
|
|
28157
29615
|
}
|
|
@@ -28210,11 +29668,11 @@ var init_compress_utils_compression = __esm({
|
|
|
28210
29668
|
/** Shared import and WASM initialization for concurrent callers. */
|
|
28211
29669
|
modulePromise = null;
|
|
28212
29670
|
/** Creates a format-specific compress-utils decoder. */
|
|
28213
|
-
constructor(
|
|
29671
|
+
constructor(metadata3, loadModule, options = {}) {
|
|
28214
29672
|
super(options);
|
|
28215
|
-
this.name =
|
|
28216
|
-
this.extensions =
|
|
28217
|
-
this.contentEncodings =
|
|
29673
|
+
this.name = metadata3.name;
|
|
29674
|
+
this.extensions = metadata3.extensions || [];
|
|
29675
|
+
this.contentEncodings = metadata3.contentEncodings || [];
|
|
28218
29676
|
this.loadModule = loadModule;
|
|
28219
29677
|
this.options = options;
|
|
28220
29678
|
}
|
|
@@ -28862,17 +30320,17 @@ var init_zip_archive = __esm({
|
|
|
28862
30320
|
const headers = [...(await this.getDirectory()).values()];
|
|
28863
30321
|
return await this.getEntry(headers[headers.length - 1].path);
|
|
28864
30322
|
}
|
|
28865
|
-
const
|
|
28866
|
-
return await this.getValidatedEntry(
|
|
30323
|
+
const metadata3 = decodeZipHeader(bytes.subarray(positions[0]), true);
|
|
30324
|
+
return await this.getValidatedEntry(metadata3.localHeaderOffset, metadata3);
|
|
28867
30325
|
}
|
|
28868
30326
|
/** Looks up a canonical path; returns undefined when the entry is absent. */
|
|
28869
30327
|
async getEntry(path) {
|
|
28870
30328
|
this.signal.throwIfAborted();
|
|
28871
|
-
const
|
|
28872
|
-
if (!
|
|
30329
|
+
const metadata3 = (await this.getDirectory()).get(path);
|
|
30330
|
+
if (!metadata3) return void 0;
|
|
28873
30331
|
let promise = this.entriesByPath.get(path);
|
|
28874
30332
|
if (!promise) {
|
|
28875
|
-
promise = this.getValidatedEntry(
|
|
30333
|
+
promise = this.getValidatedEntry(metadata3.localHeaderOffset, metadata3).catch((error) => {
|
|
28876
30334
|
this.entriesByPath.delete(path);
|
|
28877
30335
|
throw error;
|
|
28878
30336
|
});
|
|
@@ -28889,14 +30347,14 @@ var init_zip_archive = __esm({
|
|
|
28889
30347
|
this.signal.throwIfAborted();
|
|
28890
30348
|
const existing = this.entriesByOffset.get(localHeaderOffset);
|
|
28891
30349
|
if (existing) return await existing;
|
|
28892
|
-
const
|
|
28893
|
-
if (
|
|
30350
|
+
const metadata3 = await this.readLocalHeader(localHeaderOffset);
|
|
30351
|
+
if (metadata3.header.flags & 8) {
|
|
28894
30352
|
for (const header of (await this.getDirectory()).values())
|
|
28895
30353
|
if (header.localHeaderOffset === localHeaderOffset)
|
|
28896
30354
|
return await this.getEntry(header.path);
|
|
28897
30355
|
throw new Error("Invalid ZIP archive: indexed offset missing from directory");
|
|
28898
30356
|
}
|
|
28899
|
-
return await this.getValidatedEntry(localHeaderOffset, void 0,
|
|
30357
|
+
return await this.getValidatedEntry(localHeaderOffset, void 0, metadata3);
|
|
28900
30358
|
}
|
|
28901
30359
|
/** Reads one complete entry and verifies its decoded size and CRC-32. */
|
|
28902
30360
|
async read(entryOrPath, options = {}) {
|
|
@@ -29146,31 +30604,31 @@ var init_zip_archive = __esm({
|
|
|
29146
30604
|
/** Validates local/central identity, payload bounds and signed or unsigned descriptors. */
|
|
29147
30605
|
async validateEntry(offset, central, localMetadata) {
|
|
29148
30606
|
const { header: local, dataOffset } = localMetadata ?? await this.readLocalHeader(offset);
|
|
29149
|
-
const
|
|
30607
|
+
const metadata3 = central || local;
|
|
29150
30608
|
const descriptor = Boolean(local.flags & 8);
|
|
29151
30609
|
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
30610
|
throw new Error("Invalid ZIP archive: local/central metadata mismatch");
|
|
29153
|
-
if (
|
|
30611
|
+
if (metadata3.method === 0 && metadata3.size !== metadata3.compressedSize)
|
|
29154
30612
|
throw new Error("Invalid ZIP archive: STORE sizes mismatch");
|
|
29155
30613
|
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
30614
|
throw new Error("Invalid ZIP archive: descriptor local/central metadata mismatch");
|
|
29157
|
-
const payloadEnd = dataOffset +
|
|
30615
|
+
const payloadEnd = dataOffset + metadata3.compressedSize;
|
|
29158
30616
|
const entryEnd = central ? this.nextOffsets.get(offset) ?? this.directory.offset : this.directory.offset;
|
|
29159
30617
|
if (payloadEnd > entryEnd) throw new Error("Invalid ZIP archive: payload overlaps directory");
|
|
29160
30618
|
if (descriptor)
|
|
29161
30619
|
await this.validateDescriptor(
|
|
29162
30620
|
payloadEnd,
|
|
29163
|
-
|
|
30621
|
+
metadata3,
|
|
29164
30622
|
local.zip64 || Boolean(central == null ? void 0 : central.zip64),
|
|
29165
30623
|
entryEnd
|
|
29166
30624
|
);
|
|
29167
30625
|
const entry = Object.freeze({
|
|
29168
|
-
path:
|
|
29169
|
-
directory:
|
|
29170
|
-
compression:
|
|
29171
|
-
size:
|
|
29172
|
-
compressedSize:
|
|
29173
|
-
crc32:
|
|
30626
|
+
path: metadata3.path,
|
|
30627
|
+
directory: metadata3.path.endsWith("/"),
|
|
30628
|
+
compression: metadata3.method === 0 ? "store" : "deflate",
|
|
30629
|
+
size: metadata3.size,
|
|
30630
|
+
compressedSize: metadata3.compressedSize,
|
|
30631
|
+
crc32: metadata3.crc32,
|
|
29174
30632
|
localHeaderOffset: offset,
|
|
29175
30633
|
dataOffset,
|
|
29176
30634
|
comment: (central == null ? void 0 : central.comment) || ""
|
|
@@ -29179,18 +30637,18 @@ var init_zip_archive = __esm({
|
|
|
29179
30637
|
return entry;
|
|
29180
30638
|
}
|
|
29181
30639
|
/** Resolves the optional descriptor signature using the expected CRC and sizes. */
|
|
29182
|
-
async validateDescriptor(offset,
|
|
30640
|
+
async validateDescriptor(offset, metadata3, zip64, entryEnd) {
|
|
29183
30641
|
const length = Number(minimumBigInt(24n, entryEnd - offset));
|
|
29184
30642
|
const bytes = new DataView(await this.readExact(offset, length));
|
|
29185
30643
|
for (const wide of zip64 ? [true, false] : [false, true]) {
|
|
29186
|
-
if (!wide && (
|
|
30644
|
+
if (!wide && (metadata3.size > 0xffffffffn || metadata3.compressedSize > 0xffffffffn)) continue;
|
|
29187
30645
|
const descriptorLength = wide ? 20 : 12;
|
|
29188
30646
|
for (const prefix of [4, 0]) {
|
|
29189
30647
|
if (length < prefix + descriptorLength || prefix && bytes.getUint32(0, true) !== 134695760)
|
|
29190
30648
|
continue;
|
|
29191
30649
|
const compressed = wide ? bytes.getBigUint64(prefix + 4, true) : BigInt(bytes.getUint32(prefix + 4, true));
|
|
29192
30650
|
const decoded = wide ? bytes.getBigUint64(prefix + 12, true) : BigInt(bytes.getUint32(prefix + 8, true));
|
|
29193
|
-
if (bytes.getUint32(prefix, true) ===
|
|
30651
|
+
if (bytes.getUint32(prefix, true) === metadata3.crc32 && compressed === metadata3.compressedSize && decoded === metadata3.size)
|
|
29194
30652
|
return;
|
|
29195
30653
|
}
|
|
29196
30654
|
}
|
|
@@ -29342,11 +30800,11 @@ var init_native_decompressor = __esm({
|
|
|
29342
30800
|
isSupported = true;
|
|
29343
30801
|
/** Runtime stream format used for every operation. */
|
|
29344
30802
|
format;
|
|
29345
|
-
constructor(
|
|
30803
|
+
constructor(metadata3, format, options = {}) {
|
|
29346
30804
|
super(options);
|
|
29347
|
-
this.name =
|
|
29348
|
-
this.extensions = [...
|
|
29349
|
-
this.contentEncodings = [...
|
|
30805
|
+
this.name = metadata3.name;
|
|
30806
|
+
this.extensions = [...metadata3.extensions];
|
|
30807
|
+
this.contentEncodings = [...metadata3.contentEncodings];
|
|
29350
30808
|
this.format = format;
|
|
29351
30809
|
}
|
|
29352
30810
|
/** Decompresses one buffer with the runtime-provided stream. */
|
|
@@ -29392,11 +30850,11 @@ var init_lazy_compression = __esm({
|
|
|
29392
30850
|
implementation = null;
|
|
29393
30851
|
/** Shared in-flight selection used by concurrent asynchronous calls. */
|
|
29394
30852
|
implementationPromise = null;
|
|
29395
|
-
constructor(
|
|
30853
|
+
constructor(metadata3, loadFallback, options = {}, nativeFormat = null, shouldUseNative = () => true) {
|
|
29396
30854
|
super(options);
|
|
29397
|
-
this.name =
|
|
29398
|
-
this.extensions = [...
|
|
29399
|
-
this.contentEncodings = [...
|
|
30855
|
+
this.name = metadata3.name;
|
|
30856
|
+
this.extensions = [...metadata3.extensions];
|
|
30857
|
+
this.contentEncodings = [...metadata3.contentEncodings];
|
|
29400
30858
|
this.options = options;
|
|
29401
30859
|
this.nativeFormat = nativeFormat;
|
|
29402
30860
|
this.shouldUseNative = shouldUseNative;
|
|
@@ -29704,12 +31162,12 @@ var init_i3s_slpk_loader_with_parser = __esm({
|
|
|
29704
31162
|
});
|
|
29705
31163
|
|
|
29706
31164
|
// dist/i3s/i3s-slpk-loader.js
|
|
29707
|
-
var
|
|
31165
|
+
var VERSION15, SLPKLoader;
|
|
29708
31166
|
var init_i3s_slpk_loader = __esm({
|
|
29709
31167
|
"dist/i3s/i3s-slpk-loader.js"() {
|
|
29710
31168
|
"use strict";
|
|
29711
31169
|
init_i3s_format();
|
|
29712
|
-
|
|
31170
|
+
VERSION15 = true ? "5.0.0-beta.5" : "latest";
|
|
29713
31171
|
SLPKLoader = {
|
|
29714
31172
|
...SLPKFormat,
|
|
29715
31173
|
dataType: null,
|
|
@@ -29717,7 +31175,7 @@ var init_i3s_slpk_loader = __esm({
|
|
|
29717
31175
|
name: "I3S SLPK (Scene Layer Package)",
|
|
29718
31176
|
id: "slpk",
|
|
29719
31177
|
module: "tiles-3d",
|
|
29720
|
-
version:
|
|
31178
|
+
version: VERSION15,
|
|
29721
31179
|
mimeTypes: ["application/octet-stream"],
|
|
29722
31180
|
extensions: ["slpk"],
|
|
29723
31181
|
options: {
|
|
@@ -29848,7 +31306,7 @@ function parseStringsAttribute(arrayBuffer, exactStrings = false) {
|
|
|
29848
31306
|
const stringSizes = new Uint32Array(arrayBuffer, dataOffset, stringsCount);
|
|
29849
31307
|
let stringOffset = dataOffset + stringsCount * bytesPerStringSize;
|
|
29850
31308
|
for (const stringByteSize of stringSizes) {
|
|
29851
|
-
const
|
|
31309
|
+
const textDecoder2 = new TextDecoder("utf-8");
|
|
29852
31310
|
const stringAttribute = new Uint8Array(arrayBuffer, stringOffset, stringByteSize);
|
|
29853
31311
|
if (exactStrings) {
|
|
29854
31312
|
if (stringByteSize === 0)
|
|
@@ -29859,7 +31317,7 @@ function parseStringsAttribute(arrayBuffer, exactStrings = false) {
|
|
|
29859
31317
|
stringsArray.push(new TextDecoder("utf-8", { fatal: true }).decode(stringAttribute.subarray(0, -1)));
|
|
29860
31318
|
}
|
|
29861
31319
|
} else
|
|
29862
|
-
stringsArray.push(
|
|
31320
|
+
stringsArray.push(textDecoder2.decode(stringAttribute));
|
|
29863
31321
|
stringOffset += stringByteSize;
|
|
29864
31322
|
}
|
|
29865
31323
|
if (exactStrings && (stringOffset !== arrayBuffer.byteLength || new DataView(arrayBuffer).getUint32(4, true) !== arrayBuffer.byteLength - dataOffset - stringsCount * bytesPerStringSize))
|
|
@@ -30045,12 +31503,12 @@ function getAttributeValueType2(attribute) {
|
|
|
30045
31503
|
}
|
|
30046
31504
|
return "";
|
|
30047
31505
|
}
|
|
30048
|
-
var
|
|
31506
|
+
var VERSION17, I3SAttributeLoader;
|
|
30049
31507
|
var init_i3s_attribute_loader = __esm({
|
|
30050
31508
|
"dist/i3s/i3s-attribute-loader.js"() {
|
|
30051
31509
|
"use strict";
|
|
30052
31510
|
init_i3s_format();
|
|
30053
|
-
|
|
31511
|
+
VERSION17 = true ? "5.0.0-beta.5" : "latest";
|
|
30054
31512
|
I3SAttributeLoader = {
|
|
30055
31513
|
...I3SAttributeFormat,
|
|
30056
31514
|
dataType: null,
|
|
@@ -30058,7 +31516,7 @@ var init_i3s_attribute_loader = __esm({
|
|
|
30058
31516
|
name: "I3S Attribute",
|
|
30059
31517
|
id: "i3s-attribute",
|
|
30060
31518
|
module: "tiles-3d",
|
|
30061
|
-
version:
|
|
31519
|
+
version: VERSION17,
|
|
30062
31520
|
mimeTypes: ["application/binary"],
|
|
30063
31521
|
/** Loads the parser-bearing I3S attribute loader implementation. */
|
|
30064
31522
|
preload: async () => (await Promise.resolve().then(() => (init_i3s_attribute_loader_with_parser(), i3s_attribute_loader_with_parser_exports))).I3SAttributeLoaderWithParser,
|
|
@@ -30137,12 +31595,12 @@ var init_i3s_building_scene_layer_loader_with_parser = __esm({
|
|
|
30137
31595
|
});
|
|
30138
31596
|
|
|
30139
31597
|
// dist/i3s/i3s-building-scene-layer-loader.js
|
|
30140
|
-
var
|
|
31598
|
+
var VERSION18, I3SBuildingSceneLayerLoader;
|
|
30141
31599
|
var init_i3s_building_scene_layer_loader = __esm({
|
|
30142
31600
|
"dist/i3s/i3s-building-scene-layer-loader.js"() {
|
|
30143
31601
|
"use strict";
|
|
30144
31602
|
init_i3s_format();
|
|
30145
|
-
|
|
31603
|
+
VERSION18 = true ? "5.0.0-beta.5" : "latest";
|
|
30146
31604
|
I3SBuildingSceneLayerLoader = {
|
|
30147
31605
|
...I3SBuildingSceneLayerFormat,
|
|
30148
31606
|
dataType: null,
|
|
@@ -30150,7 +31608,7 @@ var init_i3s_building_scene_layer_loader = __esm({
|
|
|
30150
31608
|
name: "I3S Building Scene Layer",
|
|
30151
31609
|
id: "i3s-building-scene-layer",
|
|
30152
31610
|
module: "tiles-3d",
|
|
30153
|
-
version:
|
|
31611
|
+
version: VERSION18,
|
|
30154
31612
|
mimeTypes: ["application/json"],
|
|
30155
31613
|
/** Loads the parser-bearing I3S building scene layer loader implementation. */
|
|
30156
31614
|
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 +31733,12 @@ var init_arcgis_webscene_loader_with_parser = __esm({
|
|
|
30275
31733
|
});
|
|
30276
31734
|
|
|
30277
31735
|
// dist/i3s/arcgis-webscene-loader.js
|
|
30278
|
-
var
|
|
31736
|
+
var VERSION19, ArcGISWebSceneLoader;
|
|
30279
31737
|
var init_arcgis_webscene_loader = __esm({
|
|
30280
31738
|
"dist/i3s/arcgis-webscene-loader.js"() {
|
|
30281
31739
|
"use strict";
|
|
30282
31740
|
init_i3s_format();
|
|
30283
|
-
|
|
31741
|
+
VERSION19 = true ? "5.0.0-beta.5" : "latest";
|
|
30284
31742
|
ArcGISWebSceneLoader = {
|
|
30285
31743
|
...ArcGISWebSceneFormat,
|
|
30286
31744
|
dataType: null,
|
|
@@ -30288,7 +31746,7 @@ var init_arcgis_webscene_loader = __esm({
|
|
|
30288
31746
|
name: "ArcGIS Web Scene Loader",
|
|
30289
31747
|
id: "arcgis-web-scene",
|
|
30290
31748
|
module: "tiles-3d",
|
|
30291
|
-
version:
|
|
31749
|
+
version: VERSION19,
|
|
30292
31750
|
mimeTypes: ["application/json"],
|
|
30293
31751
|
/** Loads the parser-bearing ArcGIS WebScene loader implementation. */
|
|
30294
31752
|
preload: async () => (await Promise.resolve().then(() => (init_arcgis_webscene_loader_with_parser(), arcgis_webscene_loader_with_parser_exports))).ArcGISWebSceneLoaderWithParser,
|
|
@@ -30460,11 +31918,11 @@ init_i3s_loader();
|
|
|
30460
31918
|
// dist/i3s/i3s-slpk-writer.js
|
|
30461
31919
|
init_indexed_zip_writer();
|
|
30462
31920
|
init_i3s_format();
|
|
30463
|
-
var
|
|
31921
|
+
var VERSION14 = true ? "5.0.0-beta.5" : "latest";
|
|
30464
31922
|
var MAX_ARCHIVE_BYTES = 2147483647;
|
|
30465
31923
|
var SLPKWriter = {
|
|
30466
31924
|
...SLPKFormat,
|
|
30467
|
-
version:
|
|
31925
|
+
version: VERSION14,
|
|
30468
31926
|
options: { slpk: { maxArchiveBytes: MAX_ARCHIVE_BYTES } },
|
|
30469
31927
|
encode: encodeArchive
|
|
30470
31928
|
};
|
|
@@ -30532,12 +31990,12 @@ init_i3s_content_loader();
|
|
|
30532
31990
|
|
|
30533
31991
|
// dist/i3s/i3s-lepcc-loader-types.js
|
|
30534
31992
|
init_i3s_format();
|
|
30535
|
-
var
|
|
31993
|
+
var VERSION16 = true ? "5.0.0-beta.5" : "latest";
|
|
30536
31994
|
var I3SLEPCCLoader = {
|
|
30537
31995
|
...I3SLEPCCFormat,
|
|
30538
31996
|
dataType: null,
|
|
30539
31997
|
batchType: null,
|
|
30540
|
-
version:
|
|
31998
|
+
version: VERSION16,
|
|
30541
31999
|
worker: true,
|
|
30542
32000
|
workerSourceNode: "i3s/workers/i3s-lepcc-worker-node.ts",
|
|
30543
32001
|
options: {
|
|
@@ -30740,7 +32198,7 @@ var I3SLEPCCDecoder = class {
|
|
|
30740
32198
|
* @returns Interleaved longitude, latitude, and elevation values.
|
|
30741
32199
|
*/
|
|
30742
32200
|
decodeXyz(bytes) {
|
|
30743
|
-
const reader = new
|
|
32201
|
+
const reader = new BinaryReader2(bytes);
|
|
30744
32202
|
const header = readHeader(reader, "LEPCC ", 104, this.verifyChecksum);
|
|
30745
32203
|
const extent = {
|
|
30746
32204
|
lower: [reader.readFloat64(), reader.readFloat64(), reader.readFloat64()],
|
|
@@ -30785,7 +32243,7 @@ var I3SLEPCCDecoder = class {
|
|
|
30785
32243
|
* @returns Interleaved 8-bit red, green, and blue values.
|
|
30786
32244
|
*/
|
|
30787
32245
|
decodeRgb(bytes) {
|
|
30788
|
-
const reader = new
|
|
32246
|
+
const reader = new BinaryReader2(bytes);
|
|
30789
32247
|
const header = readHeader(reader, "ClusterRGB", 32, this.verifyChecksum);
|
|
30790
32248
|
const pointCount = reader.readUint32();
|
|
30791
32249
|
const colorCount = reader.readUint16();
|
|
@@ -30834,7 +32292,7 @@ var I3SLEPCCDecoder = class {
|
|
|
30834
32292
|
* @returns One unsigned 16-bit intensity value per point.
|
|
30835
32293
|
*/
|
|
30836
32294
|
decodeIntensity(bytes) {
|
|
30837
|
-
const reader = new
|
|
32295
|
+
const reader = new BinaryReader2(bytes);
|
|
30838
32296
|
const header = readHeader(reader, "Intensity ", 32, this.verifyChecksum);
|
|
30839
32297
|
const pointCount = reader.readUint32();
|
|
30840
32298
|
const scaleFactor = reader.readUint16();
|
|
@@ -30871,7 +32329,7 @@ var I3SLEPCCDecoder = class {
|
|
|
30871
32329
|
* @returns One packed flag byte per point.
|
|
30872
32330
|
*/
|
|
30873
32331
|
decodeFlagBytes(bytes) {
|
|
30874
|
-
const reader = new
|
|
32332
|
+
const reader = new BinaryReader2(bytes);
|
|
30875
32333
|
const header = readHeader(reader, "FlagBytes ", 32, this.verifyChecksum);
|
|
30876
32334
|
const pointCount = reader.readUint32();
|
|
30877
32335
|
const compressionMethod = reader.readUint8();
|
|
@@ -30907,7 +32365,7 @@ var I3SLEPCCDecoder = class {
|
|
|
30907
32365
|
}
|
|
30908
32366
|
}
|
|
30909
32367
|
};
|
|
30910
|
-
var
|
|
32368
|
+
var BinaryReader2 = class {
|
|
30911
32369
|
bytes;
|
|
30912
32370
|
offset = 0;
|
|
30913
32371
|
constructor(bytes) {
|
|
@@ -31804,12 +33262,12 @@ function prepareI3SMeshTexture(attribute, vertexCount, texture) {
|
|
|
31804
33262
|
if (texture) {
|
|
31805
33263
|
if (!(texture.data instanceof Uint8Array) || Object.keys(texture).some((name22) => !["data", "mimeType", "sampler", "transform"].includes(name22)))
|
|
31806
33264
|
throw new Error("Invalid I3S base-color texture");
|
|
31807
|
-
let
|
|
33265
|
+
let metadata3;
|
|
31808
33266
|
try {
|
|
31809
|
-
|
|
33267
|
+
metadata3 = getBinaryImageMetadata(new DataView(texture.data.buffer, texture.data.byteOffset, texture.data.byteLength));
|
|
31810
33268
|
} catch {
|
|
31811
33269
|
}
|
|
31812
|
-
if (!
|
|
33270
|
+
if (!metadata3 || metadata3.mimeType !== texture.mimeType || !["image/png", "image/jpeg"].includes(texture.mimeType) || metadata3.width <= 0 || metadata3.height <= 0)
|
|
31813
33271
|
throw new Error("I3S texture header must match a PNG/JPEG mimeType and positive dimensions");
|
|
31814
33272
|
const sampler = texture.sampler;
|
|
31815
33273
|
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))))
|