@loaders.gl/splats 5.0.0-beta.1 → 5.0.0-beta.11
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 +4 -2
- package/dist/bundled.d.ts +1 -1
- package/dist/bundled.d.ts.map +1 -1
- package/dist/bundled.js +1 -1
- package/dist/bundled.js.map +1 -1
- package/dist/dist.dev.js +550 -431
- package/dist/dist.min.js +20 -20
- package/dist/index.cjs +437 -365
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ksplat-loader-types.d.ts +11 -7
- package/dist/ksplat-loader-types.d.ts.map +1 -1
- package/dist/ksplat-loader-types.js +4 -2
- package/dist/ksplat-loader-types.js.map +1 -1
- package/dist/ksplat-loader.d.ts +7 -5
- package/dist/ksplat-loader.d.ts.map +1 -1
- package/dist/ksplat-loader.js.map +1 -1
- package/dist/lib/parse-ksplat.d.ts +2 -2
- package/dist/lib/parse-ksplat.d.ts.map +1 -1
- package/dist/lib/parse-rad-chunk.d.ts +2 -2
- package/dist/lib/parse-rad-chunk.d.ts.map +1 -1
- package/dist/lib/parse-splat.d.ts +2 -2
- package/dist/lib/parse-splat.d.ts.map +1 -1
- package/dist/lib/parse-spz.d.ts +2 -2
- package/dist/lib/parse-spz.d.ts.map +1 -1
- package/dist/lib/parse-spz.js.map +1 -1
- package/dist/lib/splats-arrow-table.d.ts +2 -2
- package/dist/lib/splats-arrow-table.d.ts.map +1 -1
- package/dist/lib/splats-arrow-table.js +30 -35
- package/dist/lib/splats-arrow-table.js.map +1 -1
- package/dist/rad-loader-types.d.ts +5 -0
- package/dist/rad-loader-types.d.ts.map +1 -1
- package/dist/rad-loader-types.js +3 -1
- package/dist/rad-loader-types.js.map +1 -1
- package/dist/rad-loader.d.ts +4 -0
- package/dist/rad-loader.d.ts.map +1 -1
- package/dist/rad-loader.js +2 -0
- package/dist/rad-loader.js.map +1 -1
- package/dist/rad-source-loader.d.ts +5 -36
- package/dist/rad-source-loader.d.ts.map +1 -1
- package/dist/rad-source-loader.js +10 -33
- package/dist/rad-source-loader.js.map +1 -1
- package/dist/splat-loader-types.d.ts +11 -7
- package/dist/splat-loader-types.d.ts.map +1 -1
- package/dist/splat-loader-types.js +4 -2
- package/dist/splat-loader-types.js.map +1 -1
- package/dist/splat-loader.d.ts +7 -5
- package/dist/splat-loader.d.ts.map +1 -1
- package/dist/splat-loader.js.map +1 -1
- package/dist/spz-loader-types.d.ts +10 -6
- package/dist/spz-loader-types.d.ts.map +1 -1
- package/dist/spz-loader-types.js +4 -2
- package/dist/spz-loader-types.js.map +1 -1
- package/dist/spz-loader.d.ts +6 -4
- package/dist/spz-loader.d.ts.map +1 -1
- package/dist/spz-loader.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/unbundled.d.ts +1 -1
- package/dist/unbundled.d.ts.map +1 -1
- package/dist/unbundled.js +1 -1
- package/dist/unbundled.js.map +1 -1
- package/package.json +8 -5
- package/src/bundled.ts +1 -1
- package/src/index.ts +1 -1
- package/src/ksplat-loader-types.ts +6 -4
- package/src/ksplat-loader.ts +2 -2
- package/src/lib/parse-ksplat.ts +2 -2
- package/src/lib/parse-rad-chunk.ts +2 -2
- package/src/lib/parse-splat.ts +2 -2
- package/src/lib/parse-spz.ts +2 -5
- package/src/lib/splats-arrow-table.ts +32 -46
- package/src/rad-loader-types.ts +2 -0
- package/src/rad-loader.ts +2 -0
- package/src/rad-source-loader.ts +19 -48
- package/src/splat-loader-types.ts +6 -4
- package/src/splat-loader.ts +2 -2
- package/src/spz-loader-types.ts +6 -4
- package/src/spz-loader.ts +2 -2
- package/src/types.ts +2 -2
- package/src/unbundled.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -91,7 +91,14 @@ function createLog() {
|
|
|
91
91
|
globalThis.probe.loaders = log2;
|
|
92
92
|
return log2;
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
function ignoreMessage() {
|
|
95
|
+
}
|
|
96
|
+
function getLoaderLog(options) {
|
|
97
|
+
var _a;
|
|
98
|
+
const logger = (_a = options == null ? void 0 : options.core) == null ? void 0 : _a.log;
|
|
99
|
+
return logger === null ? nullLog : logger || log;
|
|
100
|
+
}
|
|
101
|
+
var import_log, VERSION, version, log, NullLog, nullLog;
|
|
95
102
|
var init_log = __esm({
|
|
96
103
|
"../core/src/loader-utils/lib/log-utils/log.ts"() {
|
|
97
104
|
"use strict";
|
|
@@ -99,6 +106,29 @@ var init_log = __esm({
|
|
|
99
106
|
VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
100
107
|
version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
|
|
101
108
|
log = createLog();
|
|
109
|
+
NullLog = class {
|
|
110
|
+
/** Discards debug messages. */
|
|
111
|
+
log() {
|
|
112
|
+
return ignoreMessage;
|
|
113
|
+
}
|
|
114
|
+
/** Discards informational messages. */
|
|
115
|
+
info() {
|
|
116
|
+
return ignoreMessage;
|
|
117
|
+
}
|
|
118
|
+
/** Discards messages marked to be emitted once. */
|
|
119
|
+
once() {
|
|
120
|
+
return ignoreMessage;
|
|
121
|
+
}
|
|
122
|
+
/** Discards warnings. */
|
|
123
|
+
warn() {
|
|
124
|
+
return ignoreMessage;
|
|
125
|
+
}
|
|
126
|
+
/** Discards errors. */
|
|
127
|
+
error() {
|
|
128
|
+
return ignoreMessage;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
nullLog = new NullLog();
|
|
102
132
|
}
|
|
103
133
|
});
|
|
104
134
|
|
|
@@ -176,6 +206,24 @@ var init_array_buffer_utils = __esm({
|
|
|
176
206
|
}
|
|
177
207
|
});
|
|
178
208
|
|
|
209
|
+
// ../core/src/loader-utils/lib/binary-utils/encode-array-buffer-to-base64.ts
|
|
210
|
+
function encodeArrayBufferToBase64(arrayBuffer) {
|
|
211
|
+
const bytes = new Uint8Array(arrayBuffer);
|
|
212
|
+
const encodedChunks = [];
|
|
213
|
+
const chunkByteLength = 3 * 4096;
|
|
214
|
+
for (let byteOffset = 0; byteOffset < bytes.length; byteOffset += chunkByteLength) {
|
|
215
|
+
encodedChunks.push(
|
|
216
|
+
btoa(String.fromCharCode(...bytes.subarray(byteOffset, byteOffset + chunkByteLength)))
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
return encodedChunks.join("");
|
|
220
|
+
}
|
|
221
|
+
var init_encode_array_buffer_to_base64 = __esm({
|
|
222
|
+
"../core/src/loader-utils/lib/binary-utils/encode-array-buffer-to-base64.ts"() {
|
|
223
|
+
"use strict";
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
179
227
|
// ../core/src/loader-utils/lib/iterators/async-iteration.ts
|
|
180
228
|
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
181
229
|
const arrayBuffers = [];
|
|
@@ -339,7 +387,7 @@ function createAuthenticatedFetch(options) {
|
|
|
339
387
|
}
|
|
340
388
|
function getAuthenticatedFetch(options = {}) {
|
|
341
389
|
var _a, _b, _c;
|
|
342
|
-
const fetchOption =
|
|
390
|
+
const fetchOption = (_a = options.core) == null ? void 0 : _a.fetch;
|
|
343
391
|
let fetchFunction;
|
|
344
392
|
if (typeof fetchOption === "function") {
|
|
345
393
|
fetchFunction = fetchOption;
|
|
@@ -522,23 +570,13 @@ function getSourceLoaderOptions(options) {
|
|
|
522
570
|
if (options == null ? void 0 : options.core) {
|
|
523
571
|
loadOptions.core = { ...options.core };
|
|
524
572
|
const parserCore = loadOptions.core;
|
|
525
|
-
for (const key of ["type", "attributions", "loaders", "onError", "loadOptions"]) {
|
|
573
|
+
for (const key of ["type", "name", "attributions", "loaders", "onError", "loadOptions"]) {
|
|
526
574
|
delete parserCore[key];
|
|
527
575
|
}
|
|
528
576
|
if (Object.keys(parserCore).length === 0) {
|
|
529
577
|
delete loadOptions.core;
|
|
530
578
|
}
|
|
531
579
|
}
|
|
532
|
-
const topLevelBaseUri = typeof loadOptions.baseUri === "string" ? loadOptions.baseUri : void 0;
|
|
533
|
-
const topLevelBaseUrl = typeof loadOptions.baseUrl === "string" ? loadOptions.baseUrl : void 0;
|
|
534
|
-
if (topLevelBaseUri !== void 0 || topLevelBaseUrl !== void 0) {
|
|
535
|
-
loadOptions.core ||= {};
|
|
536
|
-
if (loadOptions.core.baseUrl === void 0) {
|
|
537
|
-
loadOptions.core.baseUrl = topLevelBaseUrl ?? topLevelBaseUri;
|
|
538
|
-
}
|
|
539
|
-
delete loadOptions.baseUri;
|
|
540
|
-
delete loadOptions.baseUrl;
|
|
541
|
-
}
|
|
542
580
|
return loadOptions;
|
|
543
581
|
}
|
|
544
582
|
function normalizeError(error, message) {
|
|
@@ -553,10 +591,48 @@ function normalizeError(error, message) {
|
|
|
553
591
|
function unavailableCoreApiMethod(methodName) {
|
|
554
592
|
return () => {
|
|
555
593
|
throw new Error(
|
|
556
|
-
`CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.
|
|
594
|
+
`CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.createDataSourceSync().`
|
|
557
595
|
);
|
|
558
596
|
};
|
|
559
597
|
}
|
|
598
|
+
function getDataSourceName(data, options) {
|
|
599
|
+
var _a, _b, _c;
|
|
600
|
+
const explicitName = (_a = options.core) == null ? void 0 : _a.name;
|
|
601
|
+
if (explicitName !== void 0) {
|
|
602
|
+
if (typeof explicitName !== "string" || !explicitName.trim())
|
|
603
|
+
throw new Error("Data source name must be a non-empty string.");
|
|
604
|
+
return explicitName;
|
|
605
|
+
}
|
|
606
|
+
if (data && typeof data === "object") {
|
|
607
|
+
const named = data;
|
|
608
|
+
if (typeof named.name === "string" && named.name.trim())
|
|
609
|
+
return data instanceof Blob ? removeFileExtension(named.name) : named.name;
|
|
610
|
+
const metadata = (_b = named.schema) == null ? void 0 : _b.metadata;
|
|
611
|
+
const embeddedName = metadata instanceof Map ? metadata.get("name") : metadata == null ? void 0 : metadata.name;
|
|
612
|
+
if (typeof embeddedName === "string" && embeddedName.trim()) return embeddedName;
|
|
613
|
+
}
|
|
614
|
+
if (typeof data === "string") {
|
|
615
|
+
try {
|
|
616
|
+
const url = new URL(data.replace(/\\/g, "/"), "https://source.invalid/");
|
|
617
|
+
if (!["data:", "blob:"].includes(url.protocol)) {
|
|
618
|
+
let basename = url.pathname.split("/").filter(Boolean).pop();
|
|
619
|
+
if (basename) {
|
|
620
|
+
try {
|
|
621
|
+
basename = decodeURIComponent(basename);
|
|
622
|
+
} catch {
|
|
623
|
+
}
|
|
624
|
+
return removeFileExtension(basename);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
} catch {
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return ((_c = options.core) == null ? void 0 : _c.type) && options.core.type !== "auto" ? options.core.type : "source";
|
|
631
|
+
}
|
|
632
|
+
function removeFileExtension(name) {
|
|
633
|
+
const extension = name.lastIndexOf(".");
|
|
634
|
+
return extension > 0 ? name.slice(0, extension) : name;
|
|
635
|
+
}
|
|
560
636
|
var UNAVAILABLE_CORE_API, DataSource;
|
|
561
637
|
var init_data_source = __esm({
|
|
562
638
|
"../core/src/loader-utils/lib/sources/data-source.ts"() {
|
|
@@ -588,6 +664,8 @@ var init_data_source = __esm({
|
|
|
588
664
|
options;
|
|
589
665
|
data;
|
|
590
666
|
url;
|
|
667
|
+
/** Stable query-visible name, resolved without fetching source data. */
|
|
668
|
+
name;
|
|
591
669
|
/** Shared parser options derived from the source options, excluding source-only core controls. */
|
|
592
670
|
loadOptions;
|
|
593
671
|
/** A resolved fetch function extracted from the shared core options. */
|
|
@@ -604,6 +682,7 @@ var init_data_source = __esm({
|
|
|
604
682
|
);
|
|
605
683
|
this.data = data;
|
|
606
684
|
this.url = typeof data === "string" ? resolvePath(data) : "";
|
|
685
|
+
this.name = getDataSourceName(data, this.options);
|
|
607
686
|
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
|
|
608
687
|
this.loadOptions = loadOptions;
|
|
609
688
|
const fetch2 = getFetchFunction(loadOptions);
|
|
@@ -612,6 +691,9 @@ var init_data_source = __esm({
|
|
|
612
691
|
this.fetch = fetch2;
|
|
613
692
|
}
|
|
614
693
|
setProps(options) {
|
|
694
|
+
var _a;
|
|
695
|
+
if (((_a = options.core) == null ? void 0 : _a.name) !== void 0 && options.core.name !== this.name)
|
|
696
|
+
throw new Error("Data source names are fixed at creation.");
|
|
615
697
|
const mergedOptions = mergeOptions(this.options, options);
|
|
616
698
|
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
|
|
617
699
|
this.options = mergedOptions;
|
|
@@ -642,7 +724,7 @@ var init_data_source = __esm({
|
|
|
642
724
|
if (callback) {
|
|
643
725
|
callback(normalizedError, this);
|
|
644
726
|
} else {
|
|
645
|
-
|
|
727
|
+
getLoaderLog(this.options).warn(`${this.constructor.name}: ${normalizedError.message}`)();
|
|
646
728
|
}
|
|
647
729
|
return normalizedError;
|
|
648
730
|
}
|
|
@@ -655,6 +737,7 @@ var init_loader_utils = __esm({
|
|
|
655
737
|
"../core/src/loader-utils/index.ts"() {
|
|
656
738
|
"use strict";
|
|
657
739
|
init_js_module_utils();
|
|
740
|
+
init_encode_array_buffer_to_base64();
|
|
658
741
|
init_async_iteration();
|
|
659
742
|
init_data_source();
|
|
660
743
|
}
|
|
@@ -1228,42 +1311,37 @@ var init_splat_utils = __esm({
|
|
|
1228
1311
|
function makeGaussianSplatsArrowTable(splats) {
|
|
1229
1312
|
const columns = {};
|
|
1230
1313
|
const fields = [];
|
|
1231
|
-
|
|
1232
|
-
addColumn(columns, fields, schemaFields, "POSITION", makeFixedSizeListVector(splats.positions, 3), {
|
|
1233
|
-
type: "fixed-size-list",
|
|
1234
|
-
listSize: 3,
|
|
1235
|
-
children: [{ name: "value", type: "float32" }]
|
|
1236
|
-
});
|
|
1314
|
+
addColumn(columns, fields, "POSITION", makeFixedSizeListVector(splats.positions, 3));
|
|
1237
1315
|
const colorCoefficients = getColorCoefficients(splats);
|
|
1238
|
-
addScalarColumn(columns, fields,
|
|
1316
|
+
addScalarColumn(columns, fields, "f_dc_0", colorCoefficients[0], {
|
|
1239
1317
|
"loaders_gl.gaussian_splats.semantic": "spherical_harmonic_dc",
|
|
1240
1318
|
"loaders_gl.gaussian_splats.component": "0",
|
|
1241
1319
|
"loaders_gl.gaussian_splats.encoding": "coefficient"
|
|
1242
1320
|
});
|
|
1243
|
-
addScalarColumn(columns, fields,
|
|
1321
|
+
addScalarColumn(columns, fields, "f_dc_1", colorCoefficients[1], {
|
|
1244
1322
|
"loaders_gl.gaussian_splats.semantic": "spherical_harmonic_dc",
|
|
1245
1323
|
"loaders_gl.gaussian_splats.component": "1",
|
|
1246
1324
|
"loaders_gl.gaussian_splats.encoding": "coefficient"
|
|
1247
1325
|
});
|
|
1248
|
-
addScalarColumn(columns, fields,
|
|
1326
|
+
addScalarColumn(columns, fields, "f_dc_2", colorCoefficients[2], {
|
|
1249
1327
|
"loaders_gl.gaussian_splats.semantic": "spherical_harmonic_dc",
|
|
1250
1328
|
"loaders_gl.gaussian_splats.component": "2",
|
|
1251
1329
|
"loaders_gl.gaussian_splats.encoding": "coefficient"
|
|
1252
1330
|
});
|
|
1253
|
-
addScalarColumn(columns, fields,
|
|
1331
|
+
addScalarColumn(columns, fields, "opacity", splats.opacities, {
|
|
1254
1332
|
"loaders_gl.gaussian_splats.semantic": "opacity",
|
|
1255
1333
|
"loaders_gl.gaussian_splats.encoding": "linear"
|
|
1256
1334
|
});
|
|
1257
|
-
addVectorComponents(columns, fields,
|
|
1335
|
+
addVectorComponents(columns, fields, "scale", splats.scales, 3, {
|
|
1258
1336
|
"loaders_gl.gaussian_splats.semantic": "scale",
|
|
1259
1337
|
"loaders_gl.gaussian_splats.encoding": "linear"
|
|
1260
1338
|
});
|
|
1261
|
-
addVectorComponents(columns, fields,
|
|
1339
|
+
addVectorComponents(columns, fields, "rot", splats.rotations, 4, {
|
|
1262
1340
|
"loaders_gl.gaussian_splats.semantic": "rotation",
|
|
1263
1341
|
"loaders_gl.gaussian_splats.encoding": "quaternion"
|
|
1264
1342
|
});
|
|
1265
1343
|
if (splats.sphericalHarmonics && splats.sphericalHarmonicsComponentCount) {
|
|
1266
|
-
addSphericalHarmonicRestColumns(columns, fields,
|
|
1344
|
+
addSphericalHarmonicRestColumns(columns, fields, splats.sphericalHarmonics, splats.sphericalHarmonicsComponentCount);
|
|
1267
1345
|
}
|
|
1268
1346
|
const metadata = /* @__PURE__ */ new Map([
|
|
1269
1347
|
["loaders_gl.semantic_type", "gaussian-splats"],
|
|
@@ -1272,51 +1350,50 @@ function makeGaussianSplatsArrowTable(splats) {
|
|
|
1272
1350
|
["topology", "point-list"],
|
|
1273
1351
|
["mode", "0"]
|
|
1274
1352
|
]);
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1353
|
+
if (splats.loaderData) {
|
|
1354
|
+
const { extensionBytes, childCounts, childStarts, ...header } = splats.loaderData;
|
|
1355
|
+
metadata.set("loaders_gl.gaussian_splats.loader_data", JSON.stringify({
|
|
1356
|
+
...header,
|
|
1357
|
+
childCounts: childCounts instanceof Uint16Array ? Array.from(childCounts) : childCounts,
|
|
1358
|
+
childStarts: childStarts instanceof Uint32Array ? Array.from(childStarts) : childStarts
|
|
1359
|
+
}));
|
|
1360
|
+
if (extensionBytes instanceof Uint8Array) {
|
|
1361
|
+
metadata.set("loaders_gl.gaussian_splats.extension_bytes", encodeArrayBufferToBase64(extensionBytes.slice().buffer));
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
return new arrow.Table(new arrow.Schema(fields, metadata), columns);
|
|
1287
1365
|
}
|
|
1288
|
-
function addVectorComponents(columns, fields,
|
|
1366
|
+
function addVectorComponents(columns, fields, prefix, values, size, metadata) {
|
|
1289
1367
|
for (let component = 0; component < size; component++) {
|
|
1290
1368
|
const componentValues = new Float32Array(values.length / size);
|
|
1291
1369
|
for (let rowIndex = 0; rowIndex < componentValues.length; rowIndex++) {
|
|
1292
1370
|
componentValues[rowIndex] = values[rowIndex * size + component];
|
|
1293
1371
|
}
|
|
1294
|
-
addScalarColumn(columns, fields,
|
|
1372
|
+
addScalarColumn(columns, fields, `${prefix}_${component}`, componentValues, {
|
|
1295
1373
|
...metadata,
|
|
1296
1374
|
"loaders_gl.gaussian_splats.component": String(component)
|
|
1297
1375
|
});
|
|
1298
1376
|
}
|
|
1299
1377
|
}
|
|
1300
|
-
function addSphericalHarmonicRestColumns(columns, fields,
|
|
1378
|
+
function addSphericalHarmonicRestColumns(columns, fields, sphericalHarmonics, componentCount) {
|
|
1301
1379
|
for (let component = 0; component < componentCount; component++) {
|
|
1302
1380
|
const componentValues = new Float32Array(sphericalHarmonics.length / componentCount);
|
|
1303
1381
|
for (let rowIndex = 0; rowIndex < componentValues.length; rowIndex++) {
|
|
1304
1382
|
componentValues[rowIndex] = sphericalHarmonics[rowIndex * componentCount + component];
|
|
1305
1383
|
}
|
|
1306
|
-
addScalarColumn(columns, fields,
|
|
1384
|
+
addScalarColumn(columns, fields, `f_rest_${component}`, componentValues, {
|
|
1307
1385
|
"loaders_gl.gaussian_splats.semantic": "spherical_harmonic_rest",
|
|
1308
1386
|
"loaders_gl.gaussian_splats.component": String(component),
|
|
1309
1387
|
"loaders_gl.gaussian_splats.encoding": "coefficient"
|
|
1310
1388
|
});
|
|
1311
1389
|
}
|
|
1312
1390
|
}
|
|
1313
|
-
function addScalarColumn(columns, fields,
|
|
1314
|
-
addColumn(columns, fields,
|
|
1391
|
+
function addScalarColumn(columns, fields, name, values, metadata) {
|
|
1392
|
+
addColumn(columns, fields, name, arrow.makeVector(values), metadata);
|
|
1315
1393
|
}
|
|
1316
|
-
function addColumn(columns, fields,
|
|
1394
|
+
function addColumn(columns, fields, name, column, metadata = {}) {
|
|
1317
1395
|
columns[name] = column;
|
|
1318
1396
|
fields.push(new arrow.Field(name, column.type, false, new Map(Object.entries(metadata))));
|
|
1319
|
-
schemaFields.push({ name, type: schemaType, nullable: false, metadata });
|
|
1320
1397
|
}
|
|
1321
1398
|
function makeFixedSizeListVector(value, size) {
|
|
1322
1399
|
const values = arrow.makeVector(value);
|
|
@@ -1348,6 +1425,7 @@ var init_splats_arrow_table = __esm({
|
|
|
1348
1425
|
"dist/lib/splats-arrow-table.js"() {
|
|
1349
1426
|
"use strict";
|
|
1350
1427
|
arrow = __toESM(require("apache-arrow"), 1);
|
|
1428
|
+
init_loader_utils();
|
|
1351
1429
|
init_splat_utils();
|
|
1352
1430
|
}
|
|
1353
1431
|
});
|
|
@@ -1821,15 +1899,17 @@ var init_splat_loader_types = __esm({
|
|
|
1821
1899
|
"dist/splat-loader-types.js"() {
|
|
1822
1900
|
"use strict";
|
|
1823
1901
|
init_splats_format();
|
|
1824
|
-
VERSION2 = true ? "5.0.0-beta.
|
|
1902
|
+
VERSION2 = true ? "5.0.0-beta.11" : "latest";
|
|
1825
1903
|
SPLATLoader = {
|
|
1904
|
+
defaultShape: "arrow",
|
|
1905
|
+
supportsNativeArrow: true,
|
|
1826
1906
|
dataType: null,
|
|
1827
1907
|
batchType: null,
|
|
1828
1908
|
...SPLATFormat,
|
|
1829
1909
|
version: VERSION2,
|
|
1830
1910
|
options: {
|
|
1831
1911
|
splats: {
|
|
1832
|
-
shape: "arrow
|
|
1912
|
+
shape: "arrow"
|
|
1833
1913
|
}
|
|
1834
1914
|
},
|
|
1835
1915
|
preload
|
|
@@ -2146,15 +2226,17 @@ var init_ksplat_loader_types = __esm({
|
|
|
2146
2226
|
"dist/ksplat-loader-types.js"() {
|
|
2147
2227
|
"use strict";
|
|
2148
2228
|
init_splats_format();
|
|
2149
|
-
VERSION3 = true ? "5.0.0-beta.
|
|
2229
|
+
VERSION3 = true ? "5.0.0-beta.11" : "latest";
|
|
2150
2230
|
KSPLATLoader = {
|
|
2231
|
+
defaultShape: "arrow",
|
|
2232
|
+
supportsNativeArrow: true,
|
|
2151
2233
|
dataType: null,
|
|
2152
2234
|
batchType: null,
|
|
2153
2235
|
...KSPLATFormat,
|
|
2154
2236
|
version: VERSION3,
|
|
2155
2237
|
options: {
|
|
2156
2238
|
splats: {
|
|
2157
|
-
shape: "arrow
|
|
2239
|
+
shape: "arrow"
|
|
2158
2240
|
}
|
|
2159
2241
|
},
|
|
2160
2242
|
preload: preload2
|
|
@@ -2191,15 +2273,17 @@ var init_spz_loader_types = __esm({
|
|
|
2191
2273
|
"dist/spz-loader-types.js"() {
|
|
2192
2274
|
"use strict";
|
|
2193
2275
|
init_splats_format();
|
|
2194
|
-
VERSION4 = true ? "5.0.0-beta.
|
|
2276
|
+
VERSION4 = true ? "5.0.0-beta.11" : "latest";
|
|
2195
2277
|
SPZLoader = {
|
|
2278
|
+
defaultShape: "arrow",
|
|
2279
|
+
supportsNativeArrow: true,
|
|
2196
2280
|
dataType: null,
|
|
2197
2281
|
batchType: null,
|
|
2198
2282
|
...SPZFormat,
|
|
2199
2283
|
version: VERSION4,
|
|
2200
2284
|
options: {
|
|
2201
2285
|
splats: {
|
|
2202
|
-
shape: "arrow
|
|
2286
|
+
shape: "arrow"
|
|
2203
2287
|
}
|
|
2204
2288
|
},
|
|
2205
2289
|
preload: preload3
|
|
@@ -2894,318 +2978,10 @@ var init_parse_rad_chunk = __esm({
|
|
|
2894
2978
|
}
|
|
2895
2979
|
});
|
|
2896
2980
|
|
|
2897
|
-
// dist/rad-loader.js
|
|
2898
|
-
var rad_loader_exports = {};
|
|
2899
|
-
__export(rad_loader_exports, {
|
|
2900
|
-
RADLoaderWithParser: () => RADLoaderWithParser,
|
|
2901
|
-
parseRADChunk: () => parseRADChunk,
|
|
2902
|
-
parseRADChunkHeader: () => parseRADChunkHeader,
|
|
2903
|
-
parseRADChunkToGaussianSplats: () => parseRADChunkToGaussianSplats,
|
|
2904
|
-
parseRADHeader: () => parseRADHeader,
|
|
2905
|
-
preloadRADCompression: () => preloadRADCompression,
|
|
2906
|
-
tryParseRADHeader: () => tryParseRADHeader
|
|
2907
|
-
});
|
|
2908
|
-
var _RADLoaderPreload, RADLoaderMetadataWithoutPreload, RADLoaderWithParser;
|
|
2909
|
-
var init_rad_loader = __esm({
|
|
2910
|
-
"dist/rad-loader.js"() {
|
|
2911
|
-
"use strict";
|
|
2912
|
-
init_parse_rad();
|
|
2913
|
-
init_rad_loader_types();
|
|
2914
|
-
init_parse_rad();
|
|
2915
|
-
init_parse_rad_chunk();
|
|
2916
|
-
({ preload: _RADLoaderPreload, ...RADLoaderMetadataWithoutPreload } = RADLoader);
|
|
2917
|
-
RADLoaderWithParser = {
|
|
2918
|
-
...RADLoaderMetadataWithoutPreload,
|
|
2919
|
-
parse: async (arrayBuffer) => parseRADHeader(arrayBuffer),
|
|
2920
|
-
parseSync: (arrayBuffer) => parseRADHeader(arrayBuffer)
|
|
2921
|
-
};
|
|
2922
|
-
}
|
|
2923
|
-
});
|
|
2924
|
-
|
|
2925
|
-
// dist/rad-loader-types.js
|
|
2926
|
-
async function preload4() {
|
|
2927
|
-
const { RADLoaderWithParser: RADLoaderWithParser2 } = await Promise.resolve().then(() => (init_rad_loader(), rad_loader_exports));
|
|
2928
|
-
return RADLoaderWithParser2;
|
|
2929
|
-
}
|
|
2930
|
-
var VERSION5, RADLoader;
|
|
2931
|
-
var init_rad_loader_types = __esm({
|
|
2932
|
-
"dist/rad-loader-types.js"() {
|
|
2933
|
-
"use strict";
|
|
2934
|
-
init_splats_format();
|
|
2935
|
-
VERSION5 = true ? "5.0.0-beta.1" : "latest";
|
|
2936
|
-
RADLoader = {
|
|
2937
|
-
dataType: null,
|
|
2938
|
-
batchType: null,
|
|
2939
|
-
...RADFormat,
|
|
2940
|
-
version: VERSION5,
|
|
2941
|
-
options: {},
|
|
2942
|
-
preload: preload4
|
|
2943
|
-
};
|
|
2944
|
-
}
|
|
2945
|
-
});
|
|
2946
|
-
|
|
2947
|
-
// dist/index.js
|
|
2948
|
-
var index_exports = {};
|
|
2949
|
-
__export(index_exports, {
|
|
2950
|
-
KSPLATFormat: () => KSPLATFormat,
|
|
2951
|
-
KSPLATLoader: () => KSPLATLoader,
|
|
2952
|
-
RADFormat: () => RADFormat,
|
|
2953
|
-
RADLoader: () => RADLoader,
|
|
2954
|
-
RADSource: () => RADSource,
|
|
2955
|
-
RADSourceLoader: () => RADSourceLoader,
|
|
2956
|
-
SPLATFormat: () => SPLATFormat,
|
|
2957
|
-
SPLATLoader: () => SPLATLoader,
|
|
2958
|
-
SPZFormat: () => SPZFormat,
|
|
2959
|
-
SPZLoader: () => SPZLoader,
|
|
2960
|
-
parseSPZ: () => parseSPZ,
|
|
2961
|
-
parseSPZToGaussianSplats: () => parseSPZToGaussianSplats,
|
|
2962
|
-
resolveRADChunkUrl: () => resolveRADChunkUrl
|
|
2963
|
-
});
|
|
2964
|
-
module.exports = __toCommonJS(index_exports);
|
|
2965
|
-
init_splats_format();
|
|
2966
|
-
init_parse_spz();
|
|
2967
|
-
init_splat_loader_types();
|
|
2968
|
-
init_ksplat_loader_types();
|
|
2969
|
-
init_spz_loader_types();
|
|
2970
|
-
init_rad_loader_types();
|
|
2971
|
-
|
|
2972
2981
|
// dist/rad-source-loader.js
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
init_parse_rad_chunk();
|
|
2977
|
-
init_splats_arrow_table();
|
|
2978
|
-
var DEFAULT_RAD_HEADER_BYTE_LENGTHS = [64 * 1024, 256 * 1024, 1024 * 1024];
|
|
2979
|
-
var DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS = 4;
|
|
2980
|
-
var VERSION6 = true ? "5.0.0-beta.1" : "latest";
|
|
2981
|
-
var RADSourceLoader = {
|
|
2982
|
-
dataType: null,
|
|
2983
|
-
batchType: null,
|
|
2984
|
-
...RADFormat,
|
|
2985
|
-
name: "RADSourceLoader",
|
|
2986
|
-
version: VERSION6,
|
|
2987
|
-
type: "rad",
|
|
2988
|
-
fromUrl: true,
|
|
2989
|
-
fromBlob: true,
|
|
2990
|
-
options: {
|
|
2991
|
-
rad: {
|
|
2992
|
-
headers: void 0,
|
|
2993
|
-
withCredentials: false,
|
|
2994
|
-
headerByteLengths: void 0
|
|
2995
|
-
}
|
|
2996
|
-
},
|
|
2997
|
-
defaultOptions: {
|
|
2998
|
-
rad: {
|
|
2999
|
-
headers: void 0,
|
|
3000
|
-
withCredentials: false,
|
|
3001
|
-
headerByteLengths: void 0
|
|
3002
|
-
}
|
|
3003
|
-
},
|
|
3004
|
-
testURL: (url) => /\.rad(?:$|[?#])/i.test(url),
|
|
3005
|
-
createDataSource: (data, options, coreApi) => new RADSource(data, options, coreApi)
|
|
3006
|
-
};
|
|
3007
|
-
var RADSource = class extends DataSource {
|
|
3008
|
-
/** Shared metadata promise exposed for source-style integrations. */
|
|
3009
|
-
metadata;
|
|
3010
|
-
/** Lazily initialized RAD header promise. */
|
|
3011
|
-
_metadataPromise = null;
|
|
3012
|
-
/** Lazily initialized per-chunk metadata promises. */
|
|
3013
|
-
_chunkMetadataPromises = /* @__PURE__ */ new Map();
|
|
3014
|
-
constructor(data, options, coreApi) {
|
|
3015
|
-
super(data, options, RADSourceLoader.defaultOptions, coreApi);
|
|
3016
|
-
this.metadata = this.getMetadata();
|
|
3017
|
-
}
|
|
3018
|
-
/** Ensures the RAD header metadata has been loaded. */
|
|
3019
|
-
async initialize() {
|
|
3020
|
-
await this.getMetadata();
|
|
3021
|
-
}
|
|
3022
|
-
/** Returns parsed Spark RAD top-level metadata. */
|
|
3023
|
-
async getMetadata() {
|
|
3024
|
-
if (!this._metadataPromise) {
|
|
3025
|
-
this._metadataPromise = this._loadMetadata();
|
|
3026
|
-
}
|
|
3027
|
-
return await this._metadataPromise;
|
|
3028
|
-
}
|
|
3029
|
-
/** Returns the number of chunks declared by the RAD metadata. */
|
|
3030
|
-
async getChunkCount() {
|
|
3031
|
-
const metadata = await this.getMetadata();
|
|
3032
|
-
return metadata.chunks.length;
|
|
3033
|
-
}
|
|
3034
|
-
/** Returns the URL used for a chunk, or `null` for Blob-backed inline chunks. */
|
|
3035
|
-
async getChunkUrl(chunkIndex) {
|
|
3036
|
-
const metadata = await this.getMetadata();
|
|
3037
|
-
const chunk = this._getChunkRange(metadata, chunkIndex);
|
|
3038
|
-
if (chunk.filename) {
|
|
3039
|
-
return resolveRADChunkUrl(this.url, chunk.filename);
|
|
3040
|
-
}
|
|
3041
|
-
return typeof this.data === "string" ? this.url : null;
|
|
3042
|
-
}
|
|
3043
|
-
/** Fetches one raw RADC chunk by index. */
|
|
3044
|
-
async getChunk(chunkIndex, options = {}) {
|
|
3045
|
-
const metadata = await this.getMetadata();
|
|
3046
|
-
const chunk = this._getChunkRange(metadata, chunkIndex);
|
|
3047
|
-
if (chunk.filename) {
|
|
3048
|
-
if (typeof this.data !== "string") {
|
|
3049
|
-
throw new Error("RADSource: sidecar RADC chunks require a URL-backed RAD source.");
|
|
3050
|
-
}
|
|
3051
|
-
return await this._fetchArrayBuffer(resolveRADChunkUrl(this.url, chunk.filename), void 0, {
|
|
3052
|
-
signal: options.signal
|
|
3053
|
-
});
|
|
3054
|
-
}
|
|
3055
|
-
if (chunk.bytes === 0) {
|
|
3056
|
-
return new ArrayBuffer(0);
|
|
3057
|
-
}
|
|
3058
|
-
const byteOffset = metadata.chunksByteOffset + chunk.offset;
|
|
3059
|
-
if (typeof this.data !== "string") {
|
|
3060
|
-
return await this.data.slice(byteOffset, byteOffset + chunk.bytes).arrayBuffer();
|
|
3061
|
-
}
|
|
3062
|
-
return await this._fetchArrayBuffer(this.url, { offset: byteOffset, bytes: chunk.bytes }, { signal: options.signal });
|
|
3063
|
-
}
|
|
3064
|
-
/** Fetches and parses metadata for one RADC chunk. */
|
|
3065
|
-
async getChunkMetadata(chunkIndex, options = {}) {
|
|
3066
|
-
let chunkMetadataPromise = this._chunkMetadataPromises.get(chunkIndex);
|
|
3067
|
-
if (!chunkMetadataPromise) {
|
|
3068
|
-
chunkMetadataPromise = this.getChunk(chunkIndex, options).then((chunk) => parseRADChunkHeader(chunk));
|
|
3069
|
-
this._chunkMetadataPromises.set(chunkIndex, chunkMetadataPromise);
|
|
3070
|
-
}
|
|
3071
|
-
return await chunkMetadataPromise;
|
|
3072
|
-
}
|
|
3073
|
-
/** Fetches and decodes one RADC chunk into raw Gaussian splat arrays. */
|
|
3074
|
-
async getChunkSplats(chunkIndex, options = {}) {
|
|
3075
|
-
const metadata = await this.getMetadata();
|
|
3076
|
-
await preloadRADCompression();
|
|
3077
|
-
return parseRADChunkToGaussianSplats(await this.getChunk(chunkIndex, options), this._getChunkDecodeOptions(metadata, options));
|
|
3078
|
-
}
|
|
3079
|
-
/** Fetches and decodes one RADC chunk into a Mesh Arrow table. */
|
|
3080
|
-
async getChunkTable(chunkIndex, options = {}) {
|
|
3081
|
-
const metadata = await this.getMetadata();
|
|
3082
|
-
await preloadRADCompression();
|
|
3083
|
-
return parseRADChunk(await this.getChunk(chunkIndex, options), this._getChunkDecodeOptions(metadata, options));
|
|
3084
|
-
}
|
|
3085
|
-
/** Iterates decoded RADC chunks as Mesh Arrow tables. */
|
|
3086
|
-
async *getChunkTables(options = {}) {
|
|
3087
|
-
const metadata = await this.getMetadata();
|
|
3088
|
-
const startChunkIndex = options.startChunkIndex ?? 0;
|
|
3089
|
-
const maxChunks = options.maxChunks ?? Number.POSITIVE_INFINITY;
|
|
3090
|
-
const maxSplats = options.maxSplats ?? Number.POSITIVE_INFINITY;
|
|
3091
|
-
let chunkCount = 0;
|
|
3092
|
-
let splatCount = 0;
|
|
3093
|
-
if (options.pruneLoadedLoDParents) {
|
|
3094
|
-
const chunkIndices = getRADChunkTableIteratorIndices(metadata, startChunkIndex, maxChunks, maxSplats);
|
|
3095
|
-
const splatChunks = await this._getChunkSplatsConcurrently(chunkIndices, options);
|
|
3096
|
-
let loadedGlobalSplatEnd = 0;
|
|
3097
|
-
for (const splats of splatChunks) {
|
|
3098
|
-
chunkCount++;
|
|
3099
|
-
splatCount += splats.splatCount;
|
|
3100
|
-
const base = getRADChunkSplatBase(splats);
|
|
3101
|
-
loadedGlobalSplatEnd = Math.max(loadedGlobalSplatEnd, base + splats.splatCount);
|
|
3102
|
-
}
|
|
3103
|
-
for (const splats of splatChunks) {
|
|
3104
|
-
yield makeGaussianSplatsArrowTable(pruneLoadedLoDParents(splats, loadedGlobalSplatEnd));
|
|
3105
|
-
}
|
|
3106
|
-
return;
|
|
3107
|
-
}
|
|
3108
|
-
for (let chunkIndex = startChunkIndex; chunkIndex < metadata.chunks.length && chunkCount < maxChunks && splatCount < maxSplats; chunkIndex++) {
|
|
3109
|
-
const table = await this.getChunkTable(chunkIndex, options);
|
|
3110
|
-
chunkCount++;
|
|
3111
|
-
splatCount += table.data.numRows;
|
|
3112
|
-
yield table;
|
|
3113
|
-
}
|
|
3114
|
-
}
|
|
3115
|
-
/** Fetches and decodes RAD chunks with bounded concurrency while preserving chunk order. */
|
|
3116
|
-
async _getChunkSplatsConcurrently(chunkIndices, options) {
|
|
3117
|
-
const splatChunks = new Array(chunkIndices.length);
|
|
3118
|
-
const maxConcurrentChunkRequests = getRADMaxConcurrentChunkRequests(options.maxConcurrentChunkRequests);
|
|
3119
|
-
let nextResultIndex = 0;
|
|
3120
|
-
async function loadNextChunk(source) {
|
|
3121
|
-
while (nextResultIndex < chunkIndices.length) {
|
|
3122
|
-
const resultIndex = nextResultIndex++;
|
|
3123
|
-
const chunkIndex = chunkIndices[resultIndex];
|
|
3124
|
-
splatChunks[resultIndex] = await source.getChunkSplats(chunkIndex, options);
|
|
3125
|
-
}
|
|
3126
|
-
}
|
|
3127
|
-
const workerCount = Math.min(maxConcurrentChunkRequests, chunkIndices.length);
|
|
3128
|
-
await Promise.all(Array.from({ length: workerCount }, () => loadNextChunk(this)));
|
|
3129
|
-
return splatChunks;
|
|
3130
|
-
}
|
|
3131
|
-
/** Adds source-level RAD decode metadata to chunk decode options. */
|
|
3132
|
-
_getChunkDecodeOptions(metadata, options) {
|
|
3133
|
-
return {
|
|
3134
|
-
...options,
|
|
3135
|
-
radChunk: {
|
|
3136
|
-
splatEncoding: metadata.splatEncoding,
|
|
3137
|
-
...options.radChunk
|
|
3138
|
-
}
|
|
3139
|
-
};
|
|
3140
|
-
}
|
|
3141
|
-
/** Loads and parses the top-level RAD metadata. */
|
|
3142
|
-
async _loadMetadata() {
|
|
3143
|
-
var _a, _b;
|
|
3144
|
-
const headerByteLengths = ((_b = (_a = this.options.rad) == null ? void 0 : _a.headerByteLengths) == null ? void 0 : _b.length) ? this.options.rad.headerByteLengths : DEFAULT_RAD_HEADER_BYTE_LENGTHS;
|
|
3145
|
-
if (typeof this.data !== "string") {
|
|
3146
|
-
const byteLength = Math.min(this.data.size, Math.max(...headerByteLengths));
|
|
3147
|
-
const metadata = tryParseRADHeader(await this.data.slice(0, byteLength).arrayBuffer());
|
|
3148
|
-
if (metadata) {
|
|
3149
|
-
return metadata;
|
|
3150
|
-
}
|
|
3151
|
-
throw new Error("RADSource: Blob does not contain a complete RAD metadata header.");
|
|
3152
|
-
}
|
|
3153
|
-
for (const byteLength of headerByteLengths) {
|
|
3154
|
-
const metadata = tryParseRADHeader(await this._fetchArrayBuffer(this.url, { offset: 0, bytes: byteLength }));
|
|
3155
|
-
if (metadata) {
|
|
3156
|
-
return metadata;
|
|
3157
|
-
}
|
|
3158
|
-
}
|
|
3159
|
-
throw new Error("RADSource: failed to load a complete RAD metadata header.");
|
|
3160
|
-
}
|
|
3161
|
-
/** Returns a validated chunk table entry. */
|
|
3162
|
-
_getChunkRange(metadata, chunkIndex) {
|
|
3163
|
-
if (!Number.isInteger(chunkIndex) || chunkIndex < 0 || chunkIndex >= metadata.chunks.length) {
|
|
3164
|
-
throw new Error(`RADSource: chunk index ${chunkIndex} is outside 0-${metadata.chunks.length - 1}.`);
|
|
3165
|
-
}
|
|
3166
|
-
return metadata.chunks[chunkIndex];
|
|
3167
|
-
}
|
|
3168
|
-
/** Fetches a full or ranged ArrayBuffer while tolerating non-206 range fallbacks. */
|
|
3169
|
-
async _fetchArrayBuffer(url, range, options = {}) {
|
|
3170
|
-
const response = await this._fetchResponse(url, this._getRequestInit(range, options));
|
|
3171
|
-
if (!response.ok) {
|
|
3172
|
-
throw new Error(`RADSource: failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
|
3173
|
-
}
|
|
3174
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
3175
|
-
if (range && response.status !== 206 && arrayBuffer.byteLength >= range.offset + range.bytes) {
|
|
3176
|
-
return arrayBuffer.slice(range.offset, range.offset + range.bytes);
|
|
3177
|
-
}
|
|
3178
|
-
if (range && arrayBuffer.byteLength > range.bytes) {
|
|
3179
|
-
return arrayBuffer.slice(0, range.bytes);
|
|
3180
|
-
}
|
|
3181
|
-
return arrayBuffer;
|
|
3182
|
-
}
|
|
3183
|
-
/** Fetches through custom source fetch hooks or the injected core fetchFile helper. */
|
|
3184
|
-
async _fetchResponse(url, requestInit) {
|
|
3185
|
-
if (this._hasCustomFetch()) {
|
|
3186
|
-
return await this.fetch(url, requestInit);
|
|
3187
|
-
}
|
|
3188
|
-
return this.hasCoreApi ? await this.coreApi.fetchFile(url, requestInit) : await this.fetch(url, requestInit);
|
|
3189
|
-
}
|
|
3190
|
-
/** Returns true when source options supplied an explicit fetch override. */
|
|
3191
|
-
_hasCustomFetch() {
|
|
3192
|
-
var _a, _b, _c;
|
|
3193
|
-
return Boolean(((_b = (_a = this.loadOptions) == null ? void 0 : _a.core) == null ? void 0 : _b.fetch) || ((_c = this.loadOptions) == null ? void 0 : _c.fetch));
|
|
3194
|
-
}
|
|
3195
|
-
/** Builds request options for RAD fetches. */
|
|
3196
|
-
_getRequestInit(range, options = {}) {
|
|
3197
|
-
var _a, _b;
|
|
3198
|
-
const headers = new Headers((_a = this.options.rad) == null ? void 0 : _a.headers);
|
|
3199
|
-
if (range && range.bytes > 0) {
|
|
3200
|
-
headers.set("Range", `bytes=${range.offset}-${range.offset + range.bytes - 1}`);
|
|
3201
|
-
}
|
|
3202
|
-
return {
|
|
3203
|
-
headers,
|
|
3204
|
-
credentials: ((_b = this.options.rad) == null ? void 0 : _b.withCredentials) ? "include" : "same-origin",
|
|
3205
|
-
signal: options.signal
|
|
3206
|
-
};
|
|
3207
|
-
}
|
|
3208
|
-
};
|
|
2982
|
+
function createRADSource(data, options, coreApi) {
|
|
2983
|
+
return new RADSource(data, options, coreApi);
|
|
2984
|
+
}
|
|
3209
2985
|
function getRADChunkTableIteratorIndices(metadata, startChunkIndex, maxChunks, maxSplats) {
|
|
3210
2986
|
const chunkIndices = [];
|
|
3211
2987
|
let estimatedSplatCount = 0;
|
|
@@ -3288,4 +3064,300 @@ function resolveRADChunkUrl(rootUrl, chunkFilename) {
|
|
|
3288
3064
|
return `${rootDirectory}${chunkFilename}${suffix}`;
|
|
3289
3065
|
}
|
|
3290
3066
|
}
|
|
3067
|
+
var DEFAULT_RAD_HEADER_BYTE_LENGTHS, DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS, RAD_SOURCE_DEFAULT_OPTIONS, RADSource;
|
|
3068
|
+
var init_rad_source_loader = __esm({
|
|
3069
|
+
"dist/rad-source-loader.js"() {
|
|
3070
|
+
"use strict";
|
|
3071
|
+
init_loader_utils();
|
|
3072
|
+
init_parse_rad();
|
|
3073
|
+
init_parse_rad_chunk();
|
|
3074
|
+
init_splats_arrow_table();
|
|
3075
|
+
DEFAULT_RAD_HEADER_BYTE_LENGTHS = [64 * 1024, 256 * 1024, 1024 * 1024];
|
|
3076
|
+
DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS = 4;
|
|
3077
|
+
RAD_SOURCE_DEFAULT_OPTIONS = {
|
|
3078
|
+
rad: { headers: void 0, withCredentials: false, headerByteLengths: void 0 }
|
|
3079
|
+
};
|
|
3080
|
+
RADSource = class extends DataSource {
|
|
3081
|
+
/** Shared metadata promise exposed for source-style integrations. */
|
|
3082
|
+
metadata;
|
|
3083
|
+
/** Lazily initialized RAD header promise. */
|
|
3084
|
+
_metadataPromise = null;
|
|
3085
|
+
/** Lazily initialized per-chunk metadata promises. */
|
|
3086
|
+
_chunkMetadataPromises = /* @__PURE__ */ new Map();
|
|
3087
|
+
constructor(data, options, coreApi) {
|
|
3088
|
+
super(data, options, RAD_SOURCE_DEFAULT_OPTIONS, coreApi);
|
|
3089
|
+
this.metadata = this.getMetadata();
|
|
3090
|
+
}
|
|
3091
|
+
/** Ensures the RAD header metadata has been loaded. */
|
|
3092
|
+
async initialize() {
|
|
3093
|
+
await this.getMetadata();
|
|
3094
|
+
}
|
|
3095
|
+
/** Returns parsed Spark RAD top-level metadata. */
|
|
3096
|
+
async getMetadata() {
|
|
3097
|
+
if (!this._metadataPromise) {
|
|
3098
|
+
this._metadataPromise = this._loadMetadata();
|
|
3099
|
+
}
|
|
3100
|
+
return await this._metadataPromise;
|
|
3101
|
+
}
|
|
3102
|
+
/** Returns the number of chunks declared by the RAD metadata. */
|
|
3103
|
+
async getChunkCount() {
|
|
3104
|
+
const metadata = await this.getMetadata();
|
|
3105
|
+
return metadata.chunks.length;
|
|
3106
|
+
}
|
|
3107
|
+
/** Returns the URL used for a chunk, or `null` for Blob-backed inline chunks. */
|
|
3108
|
+
async getChunkUrl(chunkIndex) {
|
|
3109
|
+
const metadata = await this.getMetadata();
|
|
3110
|
+
const chunk = this._getChunkRange(metadata, chunkIndex);
|
|
3111
|
+
if (chunk.filename) {
|
|
3112
|
+
return resolveRADChunkUrl(this.url, chunk.filename);
|
|
3113
|
+
}
|
|
3114
|
+
return typeof this.data === "string" ? this.url : null;
|
|
3115
|
+
}
|
|
3116
|
+
/** Fetches one raw RADC chunk by index. */
|
|
3117
|
+
async getChunk(chunkIndex, options = {}) {
|
|
3118
|
+
const metadata = await this.getMetadata();
|
|
3119
|
+
const chunk = this._getChunkRange(metadata, chunkIndex);
|
|
3120
|
+
if (chunk.filename) {
|
|
3121
|
+
if (typeof this.data !== "string") {
|
|
3122
|
+
throw new Error("RADSource: sidecar RADC chunks require a URL-backed RAD source.");
|
|
3123
|
+
}
|
|
3124
|
+
return await this._fetchArrayBuffer(resolveRADChunkUrl(this.url, chunk.filename), void 0, {
|
|
3125
|
+
signal: options.signal
|
|
3126
|
+
});
|
|
3127
|
+
}
|
|
3128
|
+
if (chunk.bytes === 0) {
|
|
3129
|
+
return new ArrayBuffer(0);
|
|
3130
|
+
}
|
|
3131
|
+
const byteOffset = metadata.chunksByteOffset + chunk.offset;
|
|
3132
|
+
if (typeof this.data !== "string") {
|
|
3133
|
+
return await this.data.slice(byteOffset, byteOffset + chunk.bytes).arrayBuffer();
|
|
3134
|
+
}
|
|
3135
|
+
return await this._fetchArrayBuffer(this.url, { offset: byteOffset, bytes: chunk.bytes }, { signal: options.signal });
|
|
3136
|
+
}
|
|
3137
|
+
/** Fetches and parses metadata for one RADC chunk. */
|
|
3138
|
+
async getChunkMetadata(chunkIndex, options = {}) {
|
|
3139
|
+
let chunkMetadataPromise = this._chunkMetadataPromises.get(chunkIndex);
|
|
3140
|
+
if (!chunkMetadataPromise) {
|
|
3141
|
+
chunkMetadataPromise = this.getChunk(chunkIndex, options).then((chunk) => parseRADChunkHeader(chunk));
|
|
3142
|
+
this._chunkMetadataPromises.set(chunkIndex, chunkMetadataPromise);
|
|
3143
|
+
}
|
|
3144
|
+
return await chunkMetadataPromise;
|
|
3145
|
+
}
|
|
3146
|
+
/** Fetches and decodes one RADC chunk into raw Gaussian splat arrays. */
|
|
3147
|
+
async getChunkSplats(chunkIndex, options = {}) {
|
|
3148
|
+
const metadata = await this.getMetadata();
|
|
3149
|
+
await preloadRADCompression();
|
|
3150
|
+
return parseRADChunkToGaussianSplats(await this.getChunk(chunkIndex, options), this._getChunkDecodeOptions(metadata, options));
|
|
3151
|
+
}
|
|
3152
|
+
/** Fetches and decodes one RADC chunk into a Mesh Arrow table. */
|
|
3153
|
+
async getChunkTable(chunkIndex, options = {}) {
|
|
3154
|
+
const metadata = await this.getMetadata();
|
|
3155
|
+
await preloadRADCompression();
|
|
3156
|
+
return parseRADChunk(await this.getChunk(chunkIndex, options), this._getChunkDecodeOptions(metadata, options));
|
|
3157
|
+
}
|
|
3158
|
+
/** Iterates decoded RADC chunks as Mesh Arrow tables. */
|
|
3159
|
+
async *getChunkTables(options = {}) {
|
|
3160
|
+
const metadata = await this.getMetadata();
|
|
3161
|
+
const startChunkIndex = options.startChunkIndex ?? 0;
|
|
3162
|
+
const maxChunks = options.maxChunks ?? Number.POSITIVE_INFINITY;
|
|
3163
|
+
const maxSplats = options.maxSplats ?? Number.POSITIVE_INFINITY;
|
|
3164
|
+
let chunkCount = 0;
|
|
3165
|
+
let splatCount = 0;
|
|
3166
|
+
if (options.pruneLoadedLoDParents) {
|
|
3167
|
+
const chunkIndices = getRADChunkTableIteratorIndices(metadata, startChunkIndex, maxChunks, maxSplats);
|
|
3168
|
+
const splatChunks = await this._getChunkSplatsConcurrently(chunkIndices, options);
|
|
3169
|
+
let loadedGlobalSplatEnd = 0;
|
|
3170
|
+
for (const splats of splatChunks) {
|
|
3171
|
+
chunkCount++;
|
|
3172
|
+
splatCount += splats.splatCount;
|
|
3173
|
+
const base = getRADChunkSplatBase(splats);
|
|
3174
|
+
loadedGlobalSplatEnd = Math.max(loadedGlobalSplatEnd, base + splats.splatCount);
|
|
3175
|
+
}
|
|
3176
|
+
for (const splats of splatChunks) {
|
|
3177
|
+
yield makeGaussianSplatsArrowTable(pruneLoadedLoDParents(splats, loadedGlobalSplatEnd));
|
|
3178
|
+
}
|
|
3179
|
+
return;
|
|
3180
|
+
}
|
|
3181
|
+
for (let chunkIndex = startChunkIndex; chunkIndex < metadata.chunks.length && chunkCount < maxChunks && splatCount < maxSplats; chunkIndex++) {
|
|
3182
|
+
const table = await this.getChunkTable(chunkIndex, options);
|
|
3183
|
+
chunkCount++;
|
|
3184
|
+
splatCount += table.numRows;
|
|
3185
|
+
yield table;
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
/** Fetches and decodes RAD chunks with bounded concurrency while preserving chunk order. */
|
|
3189
|
+
async _getChunkSplatsConcurrently(chunkIndices, options) {
|
|
3190
|
+
const splatChunks = new Array(chunkIndices.length);
|
|
3191
|
+
const maxConcurrentChunkRequests = getRADMaxConcurrentChunkRequests(options.maxConcurrentChunkRequests);
|
|
3192
|
+
let nextResultIndex = 0;
|
|
3193
|
+
async function loadNextChunk(source) {
|
|
3194
|
+
while (nextResultIndex < chunkIndices.length) {
|
|
3195
|
+
const resultIndex = nextResultIndex++;
|
|
3196
|
+
const chunkIndex = chunkIndices[resultIndex];
|
|
3197
|
+
splatChunks[resultIndex] = await source.getChunkSplats(chunkIndex, options);
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
const workerCount = Math.min(maxConcurrentChunkRequests, chunkIndices.length);
|
|
3201
|
+
await Promise.all(Array.from({ length: workerCount }, () => loadNextChunk(this)));
|
|
3202
|
+
return splatChunks;
|
|
3203
|
+
}
|
|
3204
|
+
/** Adds source-level RAD decode metadata to chunk decode options. */
|
|
3205
|
+
_getChunkDecodeOptions(metadata, options) {
|
|
3206
|
+
return {
|
|
3207
|
+
...options,
|
|
3208
|
+
radChunk: {
|
|
3209
|
+
splatEncoding: metadata.splatEncoding,
|
|
3210
|
+
...options.radChunk
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
3214
|
+
/** Loads and parses the top-level RAD metadata. */
|
|
3215
|
+
async _loadMetadata() {
|
|
3216
|
+
var _a, _b;
|
|
3217
|
+
const headerByteLengths = ((_b = (_a = this.options.rad) == null ? void 0 : _a.headerByteLengths) == null ? void 0 : _b.length) ? this.options.rad.headerByteLengths : DEFAULT_RAD_HEADER_BYTE_LENGTHS;
|
|
3218
|
+
if (typeof this.data !== "string") {
|
|
3219
|
+
const byteLength = Math.min(this.data.size, Math.max(...headerByteLengths));
|
|
3220
|
+
const metadata = tryParseRADHeader(await this.data.slice(0, byteLength).arrayBuffer());
|
|
3221
|
+
if (metadata) {
|
|
3222
|
+
return metadata;
|
|
3223
|
+
}
|
|
3224
|
+
throw new Error("RADSource: Blob does not contain a complete RAD metadata header.");
|
|
3225
|
+
}
|
|
3226
|
+
for (const byteLength of headerByteLengths) {
|
|
3227
|
+
const metadata = tryParseRADHeader(await this._fetchArrayBuffer(this.url, { offset: 0, bytes: byteLength }));
|
|
3228
|
+
if (metadata) {
|
|
3229
|
+
return metadata;
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
throw new Error("RADSource: failed to load a complete RAD metadata header.");
|
|
3233
|
+
}
|
|
3234
|
+
/** Returns a validated chunk table entry. */
|
|
3235
|
+
_getChunkRange(metadata, chunkIndex) {
|
|
3236
|
+
if (!Number.isInteger(chunkIndex) || chunkIndex < 0 || chunkIndex >= metadata.chunks.length) {
|
|
3237
|
+
throw new Error(`RADSource: chunk index ${chunkIndex} is outside 0-${metadata.chunks.length - 1}.`);
|
|
3238
|
+
}
|
|
3239
|
+
return metadata.chunks[chunkIndex];
|
|
3240
|
+
}
|
|
3241
|
+
/** Fetches a full or ranged ArrayBuffer while tolerating non-206 range fallbacks. */
|
|
3242
|
+
async _fetchArrayBuffer(url, range, options = {}) {
|
|
3243
|
+
const response = await this._fetchResponse(url, this._getRequestInit(range, options));
|
|
3244
|
+
if (!response.ok) {
|
|
3245
|
+
throw new Error(`RADSource: failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
|
3246
|
+
}
|
|
3247
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
3248
|
+
if (range && response.status !== 206 && arrayBuffer.byteLength >= range.offset + range.bytes) {
|
|
3249
|
+
return arrayBuffer.slice(range.offset, range.offset + range.bytes);
|
|
3250
|
+
}
|
|
3251
|
+
if (range && arrayBuffer.byteLength > range.bytes) {
|
|
3252
|
+
return arrayBuffer.slice(0, range.bytes);
|
|
3253
|
+
}
|
|
3254
|
+
return arrayBuffer;
|
|
3255
|
+
}
|
|
3256
|
+
/** Fetches through custom source fetch hooks or the injected core fetchFile helper. */
|
|
3257
|
+
async _fetchResponse(url, requestInit) {
|
|
3258
|
+
if (this._hasCustomFetch()) {
|
|
3259
|
+
return await this.fetch(url, requestInit);
|
|
3260
|
+
}
|
|
3261
|
+
return this.hasCoreApi ? await this.coreApi.fetchFile(url, requestInit) : await this.fetch(url, requestInit);
|
|
3262
|
+
}
|
|
3263
|
+
/** Returns true when source options supplied an explicit fetch override. */
|
|
3264
|
+
_hasCustomFetch() {
|
|
3265
|
+
var _a, _b;
|
|
3266
|
+
return Boolean((_b = (_a = this.loadOptions) == null ? void 0 : _a.core) == null ? void 0 : _b.fetch);
|
|
3267
|
+
}
|
|
3268
|
+
/** Builds request options for RAD fetches. */
|
|
3269
|
+
_getRequestInit(range, options = {}) {
|
|
3270
|
+
var _a, _b;
|
|
3271
|
+
const headers = new Headers((_a = this.options.rad) == null ? void 0 : _a.headers);
|
|
3272
|
+
if (range && range.bytes > 0) {
|
|
3273
|
+
headers.set("Range", `bytes=${range.offset}-${range.offset + range.bytes - 1}`);
|
|
3274
|
+
}
|
|
3275
|
+
return {
|
|
3276
|
+
headers,
|
|
3277
|
+
credentials: ((_b = this.options.rad) == null ? void 0 : _b.withCredentials) ? "include" : "same-origin",
|
|
3278
|
+
signal: options.signal
|
|
3279
|
+
};
|
|
3280
|
+
}
|
|
3281
|
+
};
|
|
3282
|
+
}
|
|
3283
|
+
});
|
|
3284
|
+
|
|
3285
|
+
// dist/rad-loader.js
|
|
3286
|
+
var rad_loader_exports = {};
|
|
3287
|
+
__export(rad_loader_exports, {
|
|
3288
|
+
RADLoaderWithParser: () => RADLoaderWithParser,
|
|
3289
|
+
parseRADChunk: () => parseRADChunk,
|
|
3290
|
+
parseRADChunkHeader: () => parseRADChunkHeader,
|
|
3291
|
+
parseRADChunkToGaussianSplats: () => parseRADChunkToGaussianSplats,
|
|
3292
|
+
parseRADHeader: () => parseRADHeader,
|
|
3293
|
+
preloadRADCompression: () => preloadRADCompression,
|
|
3294
|
+
tryParseRADHeader: () => tryParseRADHeader
|
|
3295
|
+
});
|
|
3296
|
+
var _RADLoaderPreload, RADLoaderMetadataWithoutPreload, RADLoaderWithParser;
|
|
3297
|
+
var init_rad_loader = __esm({
|
|
3298
|
+
"dist/rad-loader.js"() {
|
|
3299
|
+
"use strict";
|
|
3300
|
+
init_rad_source_loader();
|
|
3301
|
+
init_parse_rad();
|
|
3302
|
+
init_rad_loader_types();
|
|
3303
|
+
init_parse_rad();
|
|
3304
|
+
init_parse_rad_chunk();
|
|
3305
|
+
({ preload: _RADLoaderPreload, ...RADLoaderMetadataWithoutPreload } = RADLoader);
|
|
3306
|
+
RADLoaderWithParser = {
|
|
3307
|
+
createDataSourceSync: createRADSource,
|
|
3308
|
+
...RADLoaderMetadataWithoutPreload,
|
|
3309
|
+
parse: async (arrayBuffer) => parseRADHeader(arrayBuffer),
|
|
3310
|
+
parseSync: (arrayBuffer) => parseRADHeader(arrayBuffer)
|
|
3311
|
+
};
|
|
3312
|
+
}
|
|
3313
|
+
});
|
|
3314
|
+
|
|
3315
|
+
// dist/rad-loader-types.js
|
|
3316
|
+
async function preload4() {
|
|
3317
|
+
const { RADLoaderWithParser: RADLoaderWithParser2 } = await Promise.resolve().then(() => (init_rad_loader(), rad_loader_exports));
|
|
3318
|
+
return RADLoaderWithParser2;
|
|
3319
|
+
}
|
|
3320
|
+
var VERSION5, RADLoader;
|
|
3321
|
+
var init_rad_loader_types = __esm({
|
|
3322
|
+
"dist/rad-loader-types.js"() {
|
|
3323
|
+
"use strict";
|
|
3324
|
+
init_splats_format();
|
|
3325
|
+
VERSION5 = true ? "5.0.0-beta.11" : "latest";
|
|
3326
|
+
RADLoader = {
|
|
3327
|
+
dataType: null,
|
|
3328
|
+
batchType: null,
|
|
3329
|
+
...RADFormat,
|
|
3330
|
+
version: VERSION5,
|
|
3331
|
+
options: {},
|
|
3332
|
+
fromUrl: true,
|
|
3333
|
+
fromBlob: true,
|
|
3334
|
+
preload: preload4
|
|
3335
|
+
};
|
|
3336
|
+
}
|
|
3337
|
+
});
|
|
3338
|
+
|
|
3339
|
+
// dist/index.js
|
|
3340
|
+
var index_exports = {};
|
|
3341
|
+
__export(index_exports, {
|
|
3342
|
+
KSPLATFormat: () => KSPLATFormat,
|
|
3343
|
+
KSPLATLoader: () => KSPLATLoader,
|
|
3344
|
+
RADFormat: () => RADFormat,
|
|
3345
|
+
RADLoader: () => RADLoader,
|
|
3346
|
+
RADSource: () => RADSource,
|
|
3347
|
+
SPLATFormat: () => SPLATFormat,
|
|
3348
|
+
SPLATLoader: () => SPLATLoader,
|
|
3349
|
+
SPZFormat: () => SPZFormat,
|
|
3350
|
+
SPZLoader: () => SPZLoader,
|
|
3351
|
+
parseSPZ: () => parseSPZ,
|
|
3352
|
+
parseSPZToGaussianSplats: () => parseSPZToGaussianSplats,
|
|
3353
|
+
resolveRADChunkUrl: () => resolveRADChunkUrl
|
|
3354
|
+
});
|
|
3355
|
+
module.exports = __toCommonJS(index_exports);
|
|
3356
|
+
init_splats_format();
|
|
3357
|
+
init_parse_spz();
|
|
3358
|
+
init_splat_loader_types();
|
|
3359
|
+
init_ksplat_loader_types();
|
|
3360
|
+
init_spz_loader_types();
|
|
3361
|
+
init_rad_loader_types();
|
|
3362
|
+
init_rad_source_loader();
|
|
3291
3363
|
//# sourceMappingURL=index.cjs.map
|