@loaders.gl/splats 5.0.0-beta.1 → 5.0.0-beta.10
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 +532 -396
- package/dist/dist.min.js +20 -20
- package/dist/index.cjs +422 -337
- 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 +2 -2
- package/dist/ksplat-loader.js.map +1 -1
- package/dist/lib/splats-arrow-table.d.ts.map +1 -1
- package/dist/lib/splats-arrow-table.js +8 -0
- 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 +2 -33
- package/dist/rad-source-loader.d.ts.map +1 -1
- package/dist/rad-source-loader.js +9 -32
- 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 +2 -2
- 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 +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 +4 -4
- package/src/lib/splats-arrow-table.ts +11 -0
- package/src/rad-loader-types.ts +2 -0
- package/src/rad-loader.ts +2 -0
- package/src/rad-source-loader.ts +15 -41
- package/src/splat-loader-types.ts +6 -4
- package/src/splat-loader.ts +4 -4
- package/src/spz-loader-types.ts +6 -4
- package/src/spz-loader.ts +3 -3
- 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
|
}
|
|
@@ -1272,6 +1355,13 @@ function makeGaussianSplatsArrowTable(splats) {
|
|
|
1272
1355
|
["topology", "point-list"],
|
|
1273
1356
|
["mode", "0"]
|
|
1274
1357
|
]);
|
|
1358
|
+
if (splats.format !== "rad" && splats.loaderData) {
|
|
1359
|
+
const { extensionBytes, ...header } = splats.loaderData;
|
|
1360
|
+
metadata.set("loaders_gl.gaussian_splats.loader_data", JSON.stringify(header));
|
|
1361
|
+
if (extensionBytes instanceof Uint8Array) {
|
|
1362
|
+
metadata.set("loaders_gl.gaussian_splats.extension_bytes", encodeArrayBufferToBase64(extensionBytes.slice().buffer));
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1275
1365
|
const arrowSchema = new arrow.Schema(fields, metadata);
|
|
1276
1366
|
const schema = {
|
|
1277
1367
|
fields: schemaFields,
|
|
@@ -1348,6 +1438,7 @@ var init_splats_arrow_table = __esm({
|
|
|
1348
1438
|
"dist/lib/splats-arrow-table.js"() {
|
|
1349
1439
|
"use strict";
|
|
1350
1440
|
arrow = __toESM(require("apache-arrow"), 1);
|
|
1441
|
+
init_loader_utils();
|
|
1351
1442
|
init_splat_utils();
|
|
1352
1443
|
}
|
|
1353
1444
|
});
|
|
@@ -1805,8 +1896,8 @@ var init_splat_loader = __esm({
|
|
|
1805
1896
|
({ preload: _SPLATLoaderPreload, ...SPLATLoaderMetadataWithoutPreload } = SPLATLoader);
|
|
1806
1897
|
SPLATLoaderWithParser = {
|
|
1807
1898
|
...SPLATLoaderMetadataWithoutPreload,
|
|
1808
|
-
parse: async (arrayBuffer) => parseSPLAT(arrayBuffer),
|
|
1809
|
-
parseSync: (arrayBuffer) => parseSPLAT(arrayBuffer)
|
|
1899
|
+
parse: async (arrayBuffer) => parseSPLAT(arrayBuffer).data,
|
|
1900
|
+
parseSync: (arrayBuffer) => parseSPLAT(arrayBuffer).data
|
|
1810
1901
|
};
|
|
1811
1902
|
}
|
|
1812
1903
|
});
|
|
@@ -1821,15 +1912,17 @@ var init_splat_loader_types = __esm({
|
|
|
1821
1912
|
"dist/splat-loader-types.js"() {
|
|
1822
1913
|
"use strict";
|
|
1823
1914
|
init_splats_format();
|
|
1824
|
-
VERSION2 = true ? "5.0.0-beta.
|
|
1915
|
+
VERSION2 = true ? "5.0.0-beta.10" : "latest";
|
|
1825
1916
|
SPLATLoader = {
|
|
1917
|
+
defaultShape: "arrow",
|
|
1918
|
+
supportsNativeArrow: true,
|
|
1826
1919
|
dataType: null,
|
|
1827
1920
|
batchType: null,
|
|
1828
1921
|
...SPLATFormat,
|
|
1829
1922
|
version: VERSION2,
|
|
1830
1923
|
options: {
|
|
1831
1924
|
splats: {
|
|
1832
|
-
shape: "arrow
|
|
1925
|
+
shape: "arrow"
|
|
1833
1926
|
}
|
|
1834
1927
|
},
|
|
1835
1928
|
preload
|
|
@@ -2130,8 +2223,8 @@ var init_ksplat_loader = __esm({
|
|
|
2130
2223
|
({ preload: _KSPLATLoaderPreload, ...KSPLATLoaderMetadataWithoutPreload } = KSPLATLoader);
|
|
2131
2224
|
KSPLATLoaderWithParser = {
|
|
2132
2225
|
...KSPLATLoaderMetadataWithoutPreload,
|
|
2133
|
-
parse: async (arrayBuffer) => parseKSPLAT(arrayBuffer),
|
|
2134
|
-
parseSync: (arrayBuffer) => parseKSPLAT(arrayBuffer)
|
|
2226
|
+
parse: async (arrayBuffer) => parseKSPLAT(arrayBuffer).data,
|
|
2227
|
+
parseSync: (arrayBuffer) => parseKSPLAT(arrayBuffer).data
|
|
2135
2228
|
};
|
|
2136
2229
|
}
|
|
2137
2230
|
});
|
|
@@ -2146,15 +2239,17 @@ var init_ksplat_loader_types = __esm({
|
|
|
2146
2239
|
"dist/ksplat-loader-types.js"() {
|
|
2147
2240
|
"use strict";
|
|
2148
2241
|
init_splats_format();
|
|
2149
|
-
VERSION3 = true ? "5.0.0-beta.
|
|
2242
|
+
VERSION3 = true ? "5.0.0-beta.10" : "latest";
|
|
2150
2243
|
KSPLATLoader = {
|
|
2244
|
+
defaultShape: "arrow",
|
|
2245
|
+
supportsNativeArrow: true,
|
|
2151
2246
|
dataType: null,
|
|
2152
2247
|
batchType: null,
|
|
2153
2248
|
...KSPLATFormat,
|
|
2154
2249
|
version: VERSION3,
|
|
2155
2250
|
options: {
|
|
2156
2251
|
splats: {
|
|
2157
|
-
shape: "arrow
|
|
2252
|
+
shape: "arrow"
|
|
2158
2253
|
}
|
|
2159
2254
|
},
|
|
2160
2255
|
preload: preload2
|
|
@@ -2176,7 +2271,7 @@ var init_spz_loader = __esm({
|
|
|
2176
2271
|
({ preload: _SPZLoaderPreload, ...SPZLoaderMetadataWithoutPreload } = SPZLoader);
|
|
2177
2272
|
SPZLoaderWithParser = {
|
|
2178
2273
|
...SPZLoaderMetadataWithoutPreload,
|
|
2179
|
-
parse: async (arrayBuffer, options) => parseSPZ(arrayBuffer, options)
|
|
2274
|
+
parse: async (arrayBuffer, options) => (await parseSPZ(arrayBuffer, options)).data
|
|
2180
2275
|
};
|
|
2181
2276
|
}
|
|
2182
2277
|
});
|
|
@@ -2191,15 +2286,17 @@ var init_spz_loader_types = __esm({
|
|
|
2191
2286
|
"dist/spz-loader-types.js"() {
|
|
2192
2287
|
"use strict";
|
|
2193
2288
|
init_splats_format();
|
|
2194
|
-
VERSION4 = true ? "5.0.0-beta.
|
|
2289
|
+
VERSION4 = true ? "5.0.0-beta.10" : "latest";
|
|
2195
2290
|
SPZLoader = {
|
|
2291
|
+
defaultShape: "arrow",
|
|
2292
|
+
supportsNativeArrow: true,
|
|
2196
2293
|
dataType: null,
|
|
2197
2294
|
batchType: null,
|
|
2198
2295
|
...SPZFormat,
|
|
2199
2296
|
version: VERSION4,
|
|
2200
2297
|
options: {
|
|
2201
2298
|
splats: {
|
|
2202
|
-
shape: "arrow
|
|
2299
|
+
shape: "arrow"
|
|
2203
2300
|
}
|
|
2204
2301
|
},
|
|
2205
2302
|
preload: preload3
|
|
@@ -2894,318 +2991,10 @@ var init_parse_rad_chunk = __esm({
|
|
|
2894
2991
|
}
|
|
2895
2992
|
});
|
|
2896
2993
|
|
|
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
2994
|
// 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
|
-
};
|
|
2995
|
+
function createRADSource(data, options, coreApi) {
|
|
2996
|
+
return new RADSource(data, options, coreApi);
|
|
2997
|
+
}
|
|
3209
2998
|
function getRADChunkTableIteratorIndices(metadata, startChunkIndex, maxChunks, maxSplats) {
|
|
3210
2999
|
const chunkIndices = [];
|
|
3211
3000
|
let estimatedSplatCount = 0;
|
|
@@ -3288,4 +3077,300 @@ function resolveRADChunkUrl(rootUrl, chunkFilename) {
|
|
|
3288
3077
|
return `${rootDirectory}${chunkFilename}${suffix}`;
|
|
3289
3078
|
}
|
|
3290
3079
|
}
|
|
3080
|
+
var DEFAULT_RAD_HEADER_BYTE_LENGTHS, DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS, RAD_SOURCE_DEFAULT_OPTIONS, RADSource;
|
|
3081
|
+
var init_rad_source_loader = __esm({
|
|
3082
|
+
"dist/rad-source-loader.js"() {
|
|
3083
|
+
"use strict";
|
|
3084
|
+
init_loader_utils();
|
|
3085
|
+
init_parse_rad();
|
|
3086
|
+
init_parse_rad_chunk();
|
|
3087
|
+
init_splats_arrow_table();
|
|
3088
|
+
DEFAULT_RAD_HEADER_BYTE_LENGTHS = [64 * 1024, 256 * 1024, 1024 * 1024];
|
|
3089
|
+
DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS = 4;
|
|
3090
|
+
RAD_SOURCE_DEFAULT_OPTIONS = {
|
|
3091
|
+
rad: { headers: void 0, withCredentials: false, headerByteLengths: void 0 }
|
|
3092
|
+
};
|
|
3093
|
+
RADSource = class extends DataSource {
|
|
3094
|
+
/** Shared metadata promise exposed for source-style integrations. */
|
|
3095
|
+
metadata;
|
|
3096
|
+
/** Lazily initialized RAD header promise. */
|
|
3097
|
+
_metadataPromise = null;
|
|
3098
|
+
/** Lazily initialized per-chunk metadata promises. */
|
|
3099
|
+
_chunkMetadataPromises = /* @__PURE__ */ new Map();
|
|
3100
|
+
constructor(data, options, coreApi) {
|
|
3101
|
+
super(data, options, RAD_SOURCE_DEFAULT_OPTIONS, coreApi);
|
|
3102
|
+
this.metadata = this.getMetadata();
|
|
3103
|
+
}
|
|
3104
|
+
/** Ensures the RAD header metadata has been loaded. */
|
|
3105
|
+
async initialize() {
|
|
3106
|
+
await this.getMetadata();
|
|
3107
|
+
}
|
|
3108
|
+
/** Returns parsed Spark RAD top-level metadata. */
|
|
3109
|
+
async getMetadata() {
|
|
3110
|
+
if (!this._metadataPromise) {
|
|
3111
|
+
this._metadataPromise = this._loadMetadata();
|
|
3112
|
+
}
|
|
3113
|
+
return await this._metadataPromise;
|
|
3114
|
+
}
|
|
3115
|
+
/** Returns the number of chunks declared by the RAD metadata. */
|
|
3116
|
+
async getChunkCount() {
|
|
3117
|
+
const metadata = await this.getMetadata();
|
|
3118
|
+
return metadata.chunks.length;
|
|
3119
|
+
}
|
|
3120
|
+
/** Returns the URL used for a chunk, or `null` for Blob-backed inline chunks. */
|
|
3121
|
+
async getChunkUrl(chunkIndex) {
|
|
3122
|
+
const metadata = await this.getMetadata();
|
|
3123
|
+
const chunk = this._getChunkRange(metadata, chunkIndex);
|
|
3124
|
+
if (chunk.filename) {
|
|
3125
|
+
return resolveRADChunkUrl(this.url, chunk.filename);
|
|
3126
|
+
}
|
|
3127
|
+
return typeof this.data === "string" ? this.url : null;
|
|
3128
|
+
}
|
|
3129
|
+
/** Fetches one raw RADC chunk by index. */
|
|
3130
|
+
async getChunk(chunkIndex, options = {}) {
|
|
3131
|
+
const metadata = await this.getMetadata();
|
|
3132
|
+
const chunk = this._getChunkRange(metadata, chunkIndex);
|
|
3133
|
+
if (chunk.filename) {
|
|
3134
|
+
if (typeof this.data !== "string") {
|
|
3135
|
+
throw new Error("RADSource: sidecar RADC chunks require a URL-backed RAD source.");
|
|
3136
|
+
}
|
|
3137
|
+
return await this._fetchArrayBuffer(resolveRADChunkUrl(this.url, chunk.filename), void 0, {
|
|
3138
|
+
signal: options.signal
|
|
3139
|
+
});
|
|
3140
|
+
}
|
|
3141
|
+
if (chunk.bytes === 0) {
|
|
3142
|
+
return new ArrayBuffer(0);
|
|
3143
|
+
}
|
|
3144
|
+
const byteOffset = metadata.chunksByteOffset + chunk.offset;
|
|
3145
|
+
if (typeof this.data !== "string") {
|
|
3146
|
+
return await this.data.slice(byteOffset, byteOffset + chunk.bytes).arrayBuffer();
|
|
3147
|
+
}
|
|
3148
|
+
return await this._fetchArrayBuffer(this.url, { offset: byteOffset, bytes: chunk.bytes }, { signal: options.signal });
|
|
3149
|
+
}
|
|
3150
|
+
/** Fetches and parses metadata for one RADC chunk. */
|
|
3151
|
+
async getChunkMetadata(chunkIndex, options = {}) {
|
|
3152
|
+
let chunkMetadataPromise = this._chunkMetadataPromises.get(chunkIndex);
|
|
3153
|
+
if (!chunkMetadataPromise) {
|
|
3154
|
+
chunkMetadataPromise = this.getChunk(chunkIndex, options).then((chunk) => parseRADChunkHeader(chunk));
|
|
3155
|
+
this._chunkMetadataPromises.set(chunkIndex, chunkMetadataPromise);
|
|
3156
|
+
}
|
|
3157
|
+
return await chunkMetadataPromise;
|
|
3158
|
+
}
|
|
3159
|
+
/** Fetches and decodes one RADC chunk into raw Gaussian splat arrays. */
|
|
3160
|
+
async getChunkSplats(chunkIndex, options = {}) {
|
|
3161
|
+
const metadata = await this.getMetadata();
|
|
3162
|
+
await preloadRADCompression();
|
|
3163
|
+
return parseRADChunkToGaussianSplats(await this.getChunk(chunkIndex, options), this._getChunkDecodeOptions(metadata, options));
|
|
3164
|
+
}
|
|
3165
|
+
/** Fetches and decodes one RADC chunk into a Mesh Arrow table. */
|
|
3166
|
+
async getChunkTable(chunkIndex, options = {}) {
|
|
3167
|
+
const metadata = await this.getMetadata();
|
|
3168
|
+
await preloadRADCompression();
|
|
3169
|
+
return parseRADChunk(await this.getChunk(chunkIndex, options), this._getChunkDecodeOptions(metadata, options));
|
|
3170
|
+
}
|
|
3171
|
+
/** Iterates decoded RADC chunks as Mesh Arrow tables. */
|
|
3172
|
+
async *getChunkTables(options = {}) {
|
|
3173
|
+
const metadata = await this.getMetadata();
|
|
3174
|
+
const startChunkIndex = options.startChunkIndex ?? 0;
|
|
3175
|
+
const maxChunks = options.maxChunks ?? Number.POSITIVE_INFINITY;
|
|
3176
|
+
const maxSplats = options.maxSplats ?? Number.POSITIVE_INFINITY;
|
|
3177
|
+
let chunkCount = 0;
|
|
3178
|
+
let splatCount = 0;
|
|
3179
|
+
if (options.pruneLoadedLoDParents) {
|
|
3180
|
+
const chunkIndices = getRADChunkTableIteratorIndices(metadata, startChunkIndex, maxChunks, maxSplats);
|
|
3181
|
+
const splatChunks = await this._getChunkSplatsConcurrently(chunkIndices, options);
|
|
3182
|
+
let loadedGlobalSplatEnd = 0;
|
|
3183
|
+
for (const splats of splatChunks) {
|
|
3184
|
+
chunkCount++;
|
|
3185
|
+
splatCount += splats.splatCount;
|
|
3186
|
+
const base = getRADChunkSplatBase(splats);
|
|
3187
|
+
loadedGlobalSplatEnd = Math.max(loadedGlobalSplatEnd, base + splats.splatCount);
|
|
3188
|
+
}
|
|
3189
|
+
for (const splats of splatChunks) {
|
|
3190
|
+
yield makeGaussianSplatsArrowTable(pruneLoadedLoDParents(splats, loadedGlobalSplatEnd));
|
|
3191
|
+
}
|
|
3192
|
+
return;
|
|
3193
|
+
}
|
|
3194
|
+
for (let chunkIndex = startChunkIndex; chunkIndex < metadata.chunks.length && chunkCount < maxChunks && splatCount < maxSplats; chunkIndex++) {
|
|
3195
|
+
const table = await this.getChunkTable(chunkIndex, options);
|
|
3196
|
+
chunkCount++;
|
|
3197
|
+
splatCount += table.data.numRows;
|
|
3198
|
+
yield table;
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
/** Fetches and decodes RAD chunks with bounded concurrency while preserving chunk order. */
|
|
3202
|
+
async _getChunkSplatsConcurrently(chunkIndices, options) {
|
|
3203
|
+
const splatChunks = new Array(chunkIndices.length);
|
|
3204
|
+
const maxConcurrentChunkRequests = getRADMaxConcurrentChunkRequests(options.maxConcurrentChunkRequests);
|
|
3205
|
+
let nextResultIndex = 0;
|
|
3206
|
+
async function loadNextChunk(source) {
|
|
3207
|
+
while (nextResultIndex < chunkIndices.length) {
|
|
3208
|
+
const resultIndex = nextResultIndex++;
|
|
3209
|
+
const chunkIndex = chunkIndices[resultIndex];
|
|
3210
|
+
splatChunks[resultIndex] = await source.getChunkSplats(chunkIndex, options);
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
const workerCount = Math.min(maxConcurrentChunkRequests, chunkIndices.length);
|
|
3214
|
+
await Promise.all(Array.from({ length: workerCount }, () => loadNextChunk(this)));
|
|
3215
|
+
return splatChunks;
|
|
3216
|
+
}
|
|
3217
|
+
/** Adds source-level RAD decode metadata to chunk decode options. */
|
|
3218
|
+
_getChunkDecodeOptions(metadata, options) {
|
|
3219
|
+
return {
|
|
3220
|
+
...options,
|
|
3221
|
+
radChunk: {
|
|
3222
|
+
splatEncoding: metadata.splatEncoding,
|
|
3223
|
+
...options.radChunk
|
|
3224
|
+
}
|
|
3225
|
+
};
|
|
3226
|
+
}
|
|
3227
|
+
/** Loads and parses the top-level RAD metadata. */
|
|
3228
|
+
async _loadMetadata() {
|
|
3229
|
+
var _a, _b;
|
|
3230
|
+
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;
|
|
3231
|
+
if (typeof this.data !== "string") {
|
|
3232
|
+
const byteLength = Math.min(this.data.size, Math.max(...headerByteLengths));
|
|
3233
|
+
const metadata = tryParseRADHeader(await this.data.slice(0, byteLength).arrayBuffer());
|
|
3234
|
+
if (metadata) {
|
|
3235
|
+
return metadata;
|
|
3236
|
+
}
|
|
3237
|
+
throw new Error("RADSource: Blob does not contain a complete RAD metadata header.");
|
|
3238
|
+
}
|
|
3239
|
+
for (const byteLength of headerByteLengths) {
|
|
3240
|
+
const metadata = tryParseRADHeader(await this._fetchArrayBuffer(this.url, { offset: 0, bytes: byteLength }));
|
|
3241
|
+
if (metadata) {
|
|
3242
|
+
return metadata;
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
throw new Error("RADSource: failed to load a complete RAD metadata header.");
|
|
3246
|
+
}
|
|
3247
|
+
/** Returns a validated chunk table entry. */
|
|
3248
|
+
_getChunkRange(metadata, chunkIndex) {
|
|
3249
|
+
if (!Number.isInteger(chunkIndex) || chunkIndex < 0 || chunkIndex >= metadata.chunks.length) {
|
|
3250
|
+
throw new Error(`RADSource: chunk index ${chunkIndex} is outside 0-${metadata.chunks.length - 1}.`);
|
|
3251
|
+
}
|
|
3252
|
+
return metadata.chunks[chunkIndex];
|
|
3253
|
+
}
|
|
3254
|
+
/** Fetches a full or ranged ArrayBuffer while tolerating non-206 range fallbacks. */
|
|
3255
|
+
async _fetchArrayBuffer(url, range, options = {}) {
|
|
3256
|
+
const response = await this._fetchResponse(url, this._getRequestInit(range, options));
|
|
3257
|
+
if (!response.ok) {
|
|
3258
|
+
throw new Error(`RADSource: failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
|
3259
|
+
}
|
|
3260
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
3261
|
+
if (range && response.status !== 206 && arrayBuffer.byteLength >= range.offset + range.bytes) {
|
|
3262
|
+
return arrayBuffer.slice(range.offset, range.offset + range.bytes);
|
|
3263
|
+
}
|
|
3264
|
+
if (range && arrayBuffer.byteLength > range.bytes) {
|
|
3265
|
+
return arrayBuffer.slice(0, range.bytes);
|
|
3266
|
+
}
|
|
3267
|
+
return arrayBuffer;
|
|
3268
|
+
}
|
|
3269
|
+
/** Fetches through custom source fetch hooks or the injected core fetchFile helper. */
|
|
3270
|
+
async _fetchResponse(url, requestInit) {
|
|
3271
|
+
if (this._hasCustomFetch()) {
|
|
3272
|
+
return await this.fetch(url, requestInit);
|
|
3273
|
+
}
|
|
3274
|
+
return this.hasCoreApi ? await this.coreApi.fetchFile(url, requestInit) : await this.fetch(url, requestInit);
|
|
3275
|
+
}
|
|
3276
|
+
/** Returns true when source options supplied an explicit fetch override. */
|
|
3277
|
+
_hasCustomFetch() {
|
|
3278
|
+
var _a, _b;
|
|
3279
|
+
return Boolean((_b = (_a = this.loadOptions) == null ? void 0 : _a.core) == null ? void 0 : _b.fetch);
|
|
3280
|
+
}
|
|
3281
|
+
/** Builds request options for RAD fetches. */
|
|
3282
|
+
_getRequestInit(range, options = {}) {
|
|
3283
|
+
var _a, _b;
|
|
3284
|
+
const headers = new Headers((_a = this.options.rad) == null ? void 0 : _a.headers);
|
|
3285
|
+
if (range && range.bytes > 0) {
|
|
3286
|
+
headers.set("Range", `bytes=${range.offset}-${range.offset + range.bytes - 1}`);
|
|
3287
|
+
}
|
|
3288
|
+
return {
|
|
3289
|
+
headers,
|
|
3290
|
+
credentials: ((_b = this.options.rad) == null ? void 0 : _b.withCredentials) ? "include" : "same-origin",
|
|
3291
|
+
signal: options.signal
|
|
3292
|
+
};
|
|
3293
|
+
}
|
|
3294
|
+
};
|
|
3295
|
+
}
|
|
3296
|
+
});
|
|
3297
|
+
|
|
3298
|
+
// dist/rad-loader.js
|
|
3299
|
+
var rad_loader_exports = {};
|
|
3300
|
+
__export(rad_loader_exports, {
|
|
3301
|
+
RADLoaderWithParser: () => RADLoaderWithParser,
|
|
3302
|
+
parseRADChunk: () => parseRADChunk,
|
|
3303
|
+
parseRADChunkHeader: () => parseRADChunkHeader,
|
|
3304
|
+
parseRADChunkToGaussianSplats: () => parseRADChunkToGaussianSplats,
|
|
3305
|
+
parseRADHeader: () => parseRADHeader,
|
|
3306
|
+
preloadRADCompression: () => preloadRADCompression,
|
|
3307
|
+
tryParseRADHeader: () => tryParseRADHeader
|
|
3308
|
+
});
|
|
3309
|
+
var _RADLoaderPreload, RADLoaderMetadataWithoutPreload, RADLoaderWithParser;
|
|
3310
|
+
var init_rad_loader = __esm({
|
|
3311
|
+
"dist/rad-loader.js"() {
|
|
3312
|
+
"use strict";
|
|
3313
|
+
init_rad_source_loader();
|
|
3314
|
+
init_parse_rad();
|
|
3315
|
+
init_rad_loader_types();
|
|
3316
|
+
init_parse_rad();
|
|
3317
|
+
init_parse_rad_chunk();
|
|
3318
|
+
({ preload: _RADLoaderPreload, ...RADLoaderMetadataWithoutPreload } = RADLoader);
|
|
3319
|
+
RADLoaderWithParser = {
|
|
3320
|
+
createDataSourceSync: createRADSource,
|
|
3321
|
+
...RADLoaderMetadataWithoutPreload,
|
|
3322
|
+
parse: async (arrayBuffer) => parseRADHeader(arrayBuffer),
|
|
3323
|
+
parseSync: (arrayBuffer) => parseRADHeader(arrayBuffer)
|
|
3324
|
+
};
|
|
3325
|
+
}
|
|
3326
|
+
});
|
|
3327
|
+
|
|
3328
|
+
// dist/rad-loader-types.js
|
|
3329
|
+
async function preload4() {
|
|
3330
|
+
const { RADLoaderWithParser: RADLoaderWithParser2 } = await Promise.resolve().then(() => (init_rad_loader(), rad_loader_exports));
|
|
3331
|
+
return RADLoaderWithParser2;
|
|
3332
|
+
}
|
|
3333
|
+
var VERSION5, RADLoader;
|
|
3334
|
+
var init_rad_loader_types = __esm({
|
|
3335
|
+
"dist/rad-loader-types.js"() {
|
|
3336
|
+
"use strict";
|
|
3337
|
+
init_splats_format();
|
|
3338
|
+
VERSION5 = true ? "5.0.0-beta.10" : "latest";
|
|
3339
|
+
RADLoader = {
|
|
3340
|
+
dataType: null,
|
|
3341
|
+
batchType: null,
|
|
3342
|
+
...RADFormat,
|
|
3343
|
+
version: VERSION5,
|
|
3344
|
+
options: {},
|
|
3345
|
+
fromUrl: true,
|
|
3346
|
+
fromBlob: true,
|
|
3347
|
+
preload: preload4
|
|
3348
|
+
};
|
|
3349
|
+
}
|
|
3350
|
+
});
|
|
3351
|
+
|
|
3352
|
+
// dist/index.js
|
|
3353
|
+
var index_exports = {};
|
|
3354
|
+
__export(index_exports, {
|
|
3355
|
+
KSPLATFormat: () => KSPLATFormat,
|
|
3356
|
+
KSPLATLoader: () => KSPLATLoader,
|
|
3357
|
+
RADFormat: () => RADFormat,
|
|
3358
|
+
RADLoader: () => RADLoader,
|
|
3359
|
+
RADSource: () => RADSource,
|
|
3360
|
+
SPLATFormat: () => SPLATFormat,
|
|
3361
|
+
SPLATLoader: () => SPLATLoader,
|
|
3362
|
+
SPZFormat: () => SPZFormat,
|
|
3363
|
+
SPZLoader: () => SPZLoader,
|
|
3364
|
+
parseSPZ: () => parseSPZ,
|
|
3365
|
+
parseSPZToGaussianSplats: () => parseSPZToGaussianSplats,
|
|
3366
|
+
resolveRADChunkUrl: () => resolveRADChunkUrl
|
|
3367
|
+
});
|
|
3368
|
+
module.exports = __toCommonJS(index_exports);
|
|
3369
|
+
init_splats_format();
|
|
3370
|
+
init_parse_spz();
|
|
3371
|
+
init_splat_loader_types();
|
|
3372
|
+
init_ksplat_loader_types();
|
|
3373
|
+
init_spz_loader_types();
|
|
3374
|
+
init_rad_loader_types();
|
|
3375
|
+
init_rad_source_loader();
|
|
3291
3376
|
//# sourceMappingURL=index.cjs.map
|