@loaders.gl/splats 5.0.0-alpha.9 → 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/LICENSE +2 -30
- package/README.md +8 -1
- package/THIRD-PARTY-NOTICES.md +17 -0
- 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 +2552 -2842
- package/dist/dist.min.js +36 -36
- package/dist/index.cjs +645 -798
- 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/parse-ksplat.d.ts +1 -1
- package/dist/lib/parse-ksplat.d.ts.map +1 -1
- package/dist/lib/parse-rad-chunk.d.ts +3 -1
- package/dist/lib/parse-rad-chunk.d.ts.map +1 -1
- package/dist/lib/parse-rad-chunk.js +4 -0
- package/dist/lib/parse-rad-chunk.js.map +1 -1
- package/dist/lib/parse-splat.d.ts +1 -1
- package/dist/lib/parse-splat.d.ts.map +1 -1
- package/dist/lib/parse-spz.d.ts +1 -1
- package/dist/lib/parse-spz.d.ts.map +1 -1
- package/dist/lib/splats-arrow-table.d.ts +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 +5 -1
- package/dist/rad-loader.d.ts.map +1 -1
- package/dist/rad-loader.js +3 -1
- 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 +13 -34
- 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 +3 -3
- 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 +13 -10
- package/src/bundled.ts +1 -1
- package/src/index.ts +1 -1
- package/src/ksplat-loader-types.ts +7 -5
- package/src/ksplat-loader.ts +5 -5
- package/src/lib/parse-ksplat.ts +1 -1
- package/src/lib/parse-rad-chunk.ts +6 -1
- package/src/lib/parse-splat.ts +1 -1
- package/src/lib/parse-spz.ts +1 -1
- package/src/lib/splats-arrow-table.ts +12 -1
- package/src/rad-loader-types.ts +3 -1
- package/src/rad-loader.ts +4 -1
- package/src/rad-source-loader.ts +20 -43
- package/src/splat-loader-types.ts +7 -5
- package/src/splat-loader.ts +5 -5
- package/src/splats-format.ts +1 -1
- package/src/spz-loader-types.ts +7 -5
- package/src/spz-loader.ts +4 -4
- package/src/types.ts +3 -3
- package/src/unbundled.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -81,7 +81,7 @@ var init_splats_format = __esm({
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
// ../loader-utils/
|
|
84
|
+
// ../core/src/loader-utils/lib/log-utils/log.ts
|
|
85
85
|
function createLog() {
|
|
86
86
|
const log2 = new import_log.Log({ id: "loaders.gl" });
|
|
87
87
|
globalThis.loaders ||= {};
|
|
@@ -91,29 +91,58 @@ 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
|
-
"../loader-utils/
|
|
103
|
+
"../core/src/loader-utils/lib/log-utils/log.ts"() {
|
|
97
104
|
"use strict";
|
|
98
|
-
import_log = require("
|
|
105
|
+
import_log = require("probe.gl/log");
|
|
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
|
|
|
105
|
-
// ../loader-utils/
|
|
106
|
-
var isObject, isPureObject
|
|
135
|
+
// ../core/src/loader-utils/lib/javascript-utils/is-type.ts
|
|
136
|
+
var isObject, isPureObject;
|
|
107
137
|
var init_is_type = __esm({
|
|
108
|
-
"../loader-utils/
|
|
138
|
+
"../core/src/loader-utils/lib/javascript-utils/is-type.ts"() {
|
|
109
139
|
"use strict";
|
|
110
140
|
isObject = (value) => value !== null && typeof value === "object";
|
|
111
141
|
isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
|
|
112
|
-
isSharedArrayBuffer = (value) => typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
|
|
113
142
|
}
|
|
114
143
|
});
|
|
115
144
|
|
|
116
|
-
// ../loader-utils/
|
|
145
|
+
// ../core/src/loader-utils/lib/option-utils/merge-options.ts
|
|
117
146
|
function mergeOptions(baseOptions, newOptions) {
|
|
118
147
|
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
119
148
|
}
|
|
@@ -136,38 +165,25 @@ function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
|
|
|
136
165
|
return options;
|
|
137
166
|
}
|
|
138
167
|
var init_merge_options = __esm({
|
|
139
|
-
"../loader-utils/
|
|
168
|
+
"../core/src/loader-utils/lib/option-utils/merge-options.ts"() {
|
|
140
169
|
"use strict";
|
|
141
170
|
init_is_type();
|
|
142
171
|
}
|
|
143
172
|
});
|
|
144
173
|
|
|
145
|
-
// ../loader-utils/
|
|
174
|
+
// ../core/src/loader-utils/lib/module-utils/js-module-utils.ts
|
|
146
175
|
function registerJSModules(modules) {
|
|
147
176
|
globalThis.loaders ||= {};
|
|
148
177
|
globalThis.loaders.modules ||= {};
|
|
149
178
|
Object.assign(globalThis.loaders.modules, modules);
|
|
150
179
|
}
|
|
151
|
-
function getJSModule(name, caller) {
|
|
152
|
-
var _a, _b;
|
|
153
|
-
const module2 = (_b = (_a = globalThis.loaders) == null ? void 0 : _a.modules) == null ? void 0 : _b[name];
|
|
154
|
-
if (!module2) {
|
|
155
|
-
throw new Error(`${caller}: ${name} library not installed`);
|
|
156
|
-
}
|
|
157
|
-
return module2;
|
|
158
|
-
}
|
|
159
|
-
function getJSModuleOrNull(name) {
|
|
160
|
-
var _a, _b;
|
|
161
|
-
const module2 = (_b = (_a = globalThis.loaders) == null ? void 0 : _a.modules) == null ? void 0 : _b[name];
|
|
162
|
-
return module2 || null;
|
|
163
|
-
}
|
|
164
180
|
var init_js_module_utils = __esm({
|
|
165
|
-
"../loader-utils/
|
|
181
|
+
"../core/src/loader-utils/lib/module-utils/js-module-utils.ts"() {
|
|
166
182
|
"use strict";
|
|
167
183
|
}
|
|
168
184
|
});
|
|
169
185
|
|
|
170
|
-
// ../loader-utils/
|
|
186
|
+
// ../core/src/loader-utils/lib/binary-utils/array-buffer-utils.ts
|
|
171
187
|
function concatenateArrayBuffers(...sources) {
|
|
172
188
|
return concatenateArrayBuffersFromArray(sources);
|
|
173
189
|
}
|
|
@@ -185,12 +201,30 @@ function concatenateArrayBuffersFromArray(sources) {
|
|
|
185
201
|
return result.buffer;
|
|
186
202
|
}
|
|
187
203
|
var init_array_buffer_utils = __esm({
|
|
188
|
-
"../loader-utils/
|
|
204
|
+
"../core/src/loader-utils/lib/binary-utils/array-buffer-utils.ts"() {
|
|
205
|
+
"use strict";
|
|
206
|
+
}
|
|
207
|
+
});
|
|
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"() {
|
|
189
223
|
"use strict";
|
|
190
224
|
}
|
|
191
225
|
});
|
|
192
226
|
|
|
193
|
-
// ../loader-utils/
|
|
227
|
+
// ../core/src/loader-utils/lib/iterators/async-iteration.ts
|
|
194
228
|
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
195
229
|
const arrayBuffers = [];
|
|
196
230
|
for await (const chunk of asyncIterator) {
|
|
@@ -215,13 +249,13 @@ function copyFromBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength -
|
|
|
215
249
|
return copy.buffer;
|
|
216
250
|
}
|
|
217
251
|
var init_async_iteration = __esm({
|
|
218
|
-
"../loader-utils/
|
|
252
|
+
"../core/src/loader-utils/lib/iterators/async-iteration.ts"() {
|
|
219
253
|
"use strict";
|
|
220
254
|
init_array_buffer_utils();
|
|
221
255
|
}
|
|
222
256
|
});
|
|
223
257
|
|
|
224
|
-
// ../loader-utils/
|
|
258
|
+
// ../core/src/loader-utils/lib/request-utils/authentication.ts
|
|
225
259
|
function resolveCredentials(credentials, authentications = []) {
|
|
226
260
|
if (credentials.every(isAuthentication)) return credentials;
|
|
227
261
|
return credentials.map((credential, index) => {
|
|
@@ -258,12 +292,12 @@ function isAuthentication(credential) {
|
|
|
258
292
|
return (credential.type === "header" || credential.type === "query-parameter") && typeof credential.name === "string" && (typeof credential.token === "string" || typeof credential.token === "function") && Array.isArray(credential.refreshStatusCodes);
|
|
259
293
|
}
|
|
260
294
|
var init_authentication = __esm({
|
|
261
|
-
"../loader-utils/
|
|
295
|
+
"../core/src/loader-utils/lib/request-utils/authentication.ts"() {
|
|
262
296
|
"use strict";
|
|
263
297
|
}
|
|
264
298
|
});
|
|
265
299
|
|
|
266
|
-
// ../loader-utils/
|
|
300
|
+
// ../core/src/loader-utils/lib/request-utils/request-credentials.ts
|
|
267
301
|
function createAuthenticatedFetch(options) {
|
|
268
302
|
const suppliedFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
|
|
269
303
|
const existingMetadata = suppliedFetch[AUTHENTICATED_FETCH];
|
|
@@ -293,26 +327,28 @@ function createAuthenticatedFetch(options) {
|
|
|
293
327
|
);
|
|
294
328
|
for (const credential of requestCredentials) normalizeRequestOrigins(credential.origins);
|
|
295
329
|
const authenticatedFetch = async (url, requestOptions = {}) => {
|
|
296
|
-
var _a, _b, _c, _d;
|
|
330
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
297
331
|
requestOptions = mergeFetchOptions(fetchOptions, requestOptions);
|
|
298
|
-
|
|
332
|
+
(_a = requestOptions.signal) == null ? void 0 : _a.throwIfAborted();
|
|
299
333
|
if (!credentials.length) return baseFetch(url, requestOptions);
|
|
300
334
|
const resolvedURL = parseHTTPURL(url);
|
|
301
335
|
const authorization = resolvedURL ? await authorizeRequest(resolvedURL, requestOptions, tokenCredentials) : { url, options: requestOptions, credentials: [] };
|
|
302
336
|
const signedRequest = await authenticateRequest(authorization, requestCredentials, "request");
|
|
303
337
|
const response = await baseFetch(signedRequest.url, signedRequest.options);
|
|
304
|
-
const refreshableCredentials =
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
338
|
+
const refreshableCredentials = [];
|
|
339
|
+
for (const resolvedCredential of authorization.credentials) {
|
|
340
|
+
const { credential } = resolvedCredential;
|
|
341
|
+
if (typeof credential.token === "function" && (isReplayableRequest(requestOptions) || ((_b = credential.canReplayRequest) == null ? void 0 : _b.call(credential, url, requestOptions))) && (isReplayableRequest(signedRequest.options) || ((_c = credential.canReplayRequest) == null ? void 0 : _c.call(credential, signedRequest.url, signedRequest.options))) && (credential.refreshStatusCodes.includes(response.status) || await ((_d = credential.shouldRefresh) == null ? void 0 : _d.call(credential, response))))
|
|
342
|
+
refreshableCredentials.push(resolvedCredential);
|
|
343
|
+
}
|
|
344
|
+
const shouldRetrySignature = isReplayableRequest(requestOptions) && isReplayableRequest(signedRequest.options) && signedRequest.credentials.some(
|
|
308
345
|
(credential) => {
|
|
309
346
|
var _a2;
|
|
310
347
|
return (_a2 = credential.refreshStatusCodes) == null ? void 0 : _a2.includes(response.status);
|
|
311
348
|
}
|
|
312
349
|
);
|
|
313
|
-
if (!refreshableCredentials.length && !shouldRetrySignature
|
|
314
|
-
|
|
315
|
-
if ((_b = requestOptions.signal) == null ? void 0 : _b.aborted) throw createAbortError();
|
|
350
|
+
if (!refreshableCredentials.length && !shouldRetrySignature) return response;
|
|
351
|
+
(_e = requestOptions.signal) == null ? void 0 : _e.throwIfAborted();
|
|
316
352
|
const refreshedTokens = /* @__PURE__ */ new Map();
|
|
317
353
|
await Promise.all(
|
|
318
354
|
refreshableCredentials.map(async ({ credential }) => {
|
|
@@ -321,9 +357,9 @@ function createAuthenticatedFetch(options) {
|
|
|
321
357
|
})
|
|
322
358
|
);
|
|
323
359
|
if (!refreshedTokens.size && !shouldRetrySignature) return response;
|
|
324
|
-
await ((
|
|
360
|
+
await ((_f = response.body) == null ? void 0 : _f.cancel().catch(() => {
|
|
325
361
|
}));
|
|
326
|
-
|
|
362
|
+
(_g = requestOptions.signal) == null ? void 0 : _g.throwIfAborted();
|
|
327
363
|
const replayAuthorization = resolvedURL ? await authorizeRequest(
|
|
328
364
|
resolvedURL,
|
|
329
365
|
requestOptions,
|
|
@@ -351,16 +387,17 @@ function createAuthenticatedFetch(options) {
|
|
|
351
387
|
}
|
|
352
388
|
function getAuthenticatedFetch(options = {}) {
|
|
353
389
|
var _a, _b, _c;
|
|
354
|
-
const fetchOption =
|
|
390
|
+
const fetchOption = (_a = options.core) == null ? void 0 : _a.fetch;
|
|
355
391
|
let fetchFunction;
|
|
356
392
|
if (typeof fetchOption === "function") {
|
|
357
393
|
fetchFunction = fetchOption;
|
|
358
394
|
} else {
|
|
359
395
|
fetchFunction = (url, requestOptions) => fetch(url, requestOptions);
|
|
360
396
|
}
|
|
397
|
+
const fetchOptions = typeof fetchOption === "object" && fetchOption ? fetchOption : void 0;
|
|
361
398
|
return createAuthenticatedFetch({
|
|
362
399
|
fetch: fetchFunction,
|
|
363
|
-
fetchOptions:
|
|
400
|
+
fetchOptions: options.signal ? { ...fetchOptions, signal: options.signal } : fetchOptions,
|
|
364
401
|
credentials: ((_b = options.core) == null ? void 0 : _b.credentials) || [],
|
|
365
402
|
authentications: (_c = options.core) == null ? void 0 : _c.authentications
|
|
366
403
|
});
|
|
@@ -380,7 +417,7 @@ async function authenticateRequest(request, credentials, reason, response) {
|
|
|
380
417
|
for (const credential of credentials) {
|
|
381
418
|
const origin = getRequestOrigin(request.url);
|
|
382
419
|
if (!origin || !normalizeRequestOrigins(credential.origins).includes(origin)) continue;
|
|
383
|
-
|
|
420
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
384
421
|
const authenticatedRequest = await credential.authenticate({
|
|
385
422
|
url: request.url,
|
|
386
423
|
options: { ...request.options, headers: new Headers(request.options.headers) },
|
|
@@ -396,7 +433,7 @@ async function authenticateRequest(request, credentials, reason, response) {
|
|
|
396
433
|
};
|
|
397
434
|
appliedCredentials.push(credential);
|
|
398
435
|
}
|
|
399
|
-
|
|
436
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
400
437
|
return { ...request, credentials: appliedCredentials };
|
|
401
438
|
}
|
|
402
439
|
function getRequestOrigin(url) {
|
|
@@ -486,12 +523,9 @@ function isReplayableRequest(options) {
|
|
|
486
523
|
if (!["GET", "HEAD", "OPTIONS", "PUT", "DELETE"].includes(method)) return false;
|
|
487
524
|
return !(options.body && typeof ReadableStream !== "undefined" && options.body instanceof ReadableStream);
|
|
488
525
|
}
|
|
489
|
-
function createAbortError() {
|
|
490
|
-
return new DOMException("The operation was aborted.", "AbortError");
|
|
491
|
-
}
|
|
492
526
|
var AUTHENTICATED_FETCH, refreshPromises;
|
|
493
527
|
var init_request_credentials = __esm({
|
|
494
|
-
"../loader-utils/
|
|
528
|
+
"../core/src/loader-utils/lib/request-utils/request-credentials.ts"() {
|
|
495
529
|
"use strict";
|
|
496
530
|
init_authentication();
|
|
497
531
|
AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
|
|
@@ -499,7 +533,7 @@ var init_request_credentials = __esm({
|
|
|
499
533
|
}
|
|
500
534
|
});
|
|
501
535
|
|
|
502
|
-
// ../loader-utils/
|
|
536
|
+
// ../core/src/loader-utils/lib/path-utils/file-aliases.ts
|
|
503
537
|
function resolvePath(filename) {
|
|
504
538
|
for (const alias in fileAliases) {
|
|
505
539
|
if (filename.startsWith(alias)) {
|
|
@@ -514,41 +548,14 @@ function resolvePath(filename) {
|
|
|
514
548
|
}
|
|
515
549
|
var pathPrefix, fileAliases;
|
|
516
550
|
var init_file_aliases = __esm({
|
|
517
|
-
"../loader-utils/
|
|
551
|
+
"../core/src/loader-utils/lib/path-utils/file-aliases.ts"() {
|
|
518
552
|
"use strict";
|
|
519
553
|
pathPrefix = "";
|
|
520
554
|
fileAliases = {};
|
|
521
555
|
}
|
|
522
556
|
});
|
|
523
557
|
|
|
524
|
-
// ../loader-utils/
|
|
525
|
-
function ensureArrayBuffer(bufferSource) {
|
|
526
|
-
if (bufferSource instanceof ArrayBuffer) {
|
|
527
|
-
return bufferSource;
|
|
528
|
-
}
|
|
529
|
-
if (isSharedArrayBuffer(bufferSource)) {
|
|
530
|
-
return copyToArrayBuffer2(bufferSource);
|
|
531
|
-
}
|
|
532
|
-
const { buffer, byteOffset, byteLength } = bufferSource;
|
|
533
|
-
if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
|
|
534
|
-
return buffer;
|
|
535
|
-
}
|
|
536
|
-
return copyToArrayBuffer2(buffer, byteOffset, byteLength);
|
|
537
|
-
}
|
|
538
|
-
function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
539
|
-
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
540
|
-
const copy = new Uint8Array(view.length);
|
|
541
|
-
copy.set(view);
|
|
542
|
-
return copy.buffer;
|
|
543
|
-
}
|
|
544
|
-
var init_memory_conversion_utils = __esm({
|
|
545
|
-
"../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts"() {
|
|
546
|
-
"use strict";
|
|
547
|
-
init_is_type();
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
// ../loader-utils/src/lib/sources/data-source.ts
|
|
558
|
+
// ../core/src/loader-utils/lib/sources/data-source.ts
|
|
552
559
|
function getFetchFunction(options) {
|
|
553
560
|
return getAuthenticatedFetch(options);
|
|
554
561
|
}
|
|
@@ -563,23 +570,13 @@ function getSourceLoaderOptions(options) {
|
|
|
563
570
|
if (options == null ? void 0 : options.core) {
|
|
564
571
|
loadOptions.core = { ...options.core };
|
|
565
572
|
const parserCore = loadOptions.core;
|
|
566
|
-
for (const key of ["type", "attributions", "loaders", "onError", "loadOptions"]) {
|
|
573
|
+
for (const key of ["type", "name", "attributions", "loaders", "onError", "loadOptions"]) {
|
|
567
574
|
delete parserCore[key];
|
|
568
575
|
}
|
|
569
576
|
if (Object.keys(parserCore).length === 0) {
|
|
570
577
|
delete loadOptions.core;
|
|
571
578
|
}
|
|
572
579
|
}
|
|
573
|
-
const topLevelBaseUri = typeof loadOptions.baseUri === "string" ? loadOptions.baseUri : void 0;
|
|
574
|
-
const topLevelBaseUrl = typeof loadOptions.baseUrl === "string" ? loadOptions.baseUrl : void 0;
|
|
575
|
-
if (topLevelBaseUri !== void 0 || topLevelBaseUrl !== void 0) {
|
|
576
|
-
loadOptions.core ||= {};
|
|
577
|
-
if (loadOptions.core.baseUrl === void 0) {
|
|
578
|
-
loadOptions.core.baseUrl = topLevelBaseUrl ?? topLevelBaseUri;
|
|
579
|
-
}
|
|
580
|
-
delete loadOptions.baseUri;
|
|
581
|
-
delete loadOptions.baseUrl;
|
|
582
|
-
}
|
|
583
580
|
return loadOptions;
|
|
584
581
|
}
|
|
585
582
|
function normalizeError(error, message) {
|
|
@@ -594,13 +591,51 @@ function normalizeError(error, message) {
|
|
|
594
591
|
function unavailableCoreApiMethod(methodName) {
|
|
595
592
|
return () => {
|
|
596
593
|
throw new Error(
|
|
597
|
-
`CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.
|
|
594
|
+
`CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.createDataSourceSync().`
|
|
598
595
|
);
|
|
599
596
|
};
|
|
600
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
|
+
}
|
|
601
636
|
var UNAVAILABLE_CORE_API, DataSource;
|
|
602
637
|
var init_data_source = __esm({
|
|
603
|
-
"../loader-utils/
|
|
638
|
+
"../core/src/loader-utils/lib/sources/data-source.ts"() {
|
|
604
639
|
"use strict";
|
|
605
640
|
init_merge_options();
|
|
606
641
|
init_file_aliases();
|
|
@@ -629,6 +664,8 @@ var init_data_source = __esm({
|
|
|
629
664
|
options;
|
|
630
665
|
data;
|
|
631
666
|
url;
|
|
667
|
+
/** Stable query-visible name, resolved without fetching source data. */
|
|
668
|
+
name;
|
|
632
669
|
/** Shared parser options derived from the source options, excluding source-only core controls. */
|
|
633
670
|
loadOptions;
|
|
634
671
|
/** A resolved fetch function extracted from the shared core options. */
|
|
@@ -645,6 +682,7 @@ var init_data_source = __esm({
|
|
|
645
682
|
);
|
|
646
683
|
this.data = data;
|
|
647
684
|
this.url = typeof data === "string" ? resolvePath(data) : "";
|
|
685
|
+
this.name = getDataSourceName(data, this.options);
|
|
648
686
|
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
|
|
649
687
|
this.loadOptions = loadOptions;
|
|
650
688
|
const fetch2 = getFetchFunction(loadOptions);
|
|
@@ -653,6 +691,9 @@ var init_data_source = __esm({
|
|
|
653
691
|
this.fetch = fetch2;
|
|
654
692
|
}
|
|
655
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.");
|
|
656
697
|
const mergedOptions = mergeOptions(this.options, options);
|
|
657
698
|
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
|
|
658
699
|
this.options = mergedOptions;
|
|
@@ -683,7 +724,7 @@ var init_data_source = __esm({
|
|
|
683
724
|
if (callback) {
|
|
684
725
|
callback(normalizedError, this);
|
|
685
726
|
} else {
|
|
686
|
-
|
|
727
|
+
getLoaderLog(this.options).warn(`${this.constructor.name}: ${normalizedError.message}`)();
|
|
687
728
|
}
|
|
688
729
|
return normalizedError;
|
|
689
730
|
}
|
|
@@ -691,24 +732,23 @@ var init_data_source = __esm({
|
|
|
691
732
|
}
|
|
692
733
|
});
|
|
693
734
|
|
|
694
|
-
// ../loader-utils/
|
|
695
|
-
var
|
|
696
|
-
"../loader-utils/
|
|
735
|
+
// ../core/src/loader-utils/index.ts
|
|
736
|
+
var init_loader_utils = __esm({
|
|
737
|
+
"../core/src/loader-utils/index.ts"() {
|
|
697
738
|
"use strict";
|
|
698
739
|
init_js_module_utils();
|
|
699
|
-
|
|
740
|
+
init_encode_array_buffer_to_base64();
|
|
700
741
|
init_async_iteration();
|
|
701
|
-
init_memory_conversion_utils();
|
|
702
742
|
init_data_source();
|
|
703
743
|
}
|
|
704
744
|
});
|
|
705
745
|
|
|
706
746
|
// ../compression/src/lib/compression.ts
|
|
707
|
-
var CompressionTransform,
|
|
747
|
+
var CompressionTransform, Decompressor;
|
|
708
748
|
var init_compression = __esm({
|
|
709
749
|
"../compression/src/lib/compression.ts"() {
|
|
710
750
|
"use strict";
|
|
711
|
-
|
|
751
|
+
init_loader_utils();
|
|
712
752
|
CompressionTransform = class {
|
|
713
753
|
/** Preloads any dynamic libraries. May enable sync functions */
|
|
714
754
|
async preload(modules = {}) {
|
|
@@ -726,26 +766,6 @@ var init_compression = __esm({
|
|
|
726
766
|
return error;
|
|
727
767
|
}
|
|
728
768
|
};
|
|
729
|
-
Compressor = class extends CompressionTransform {
|
|
730
|
-
constructor(options) {
|
|
731
|
-
super();
|
|
732
|
-
this.compressBatches = this.compressBatches.bind(this);
|
|
733
|
-
}
|
|
734
|
-
/** Asynchronously compresses data. */
|
|
735
|
-
async compress(input) {
|
|
736
|
-
await this.preload();
|
|
737
|
-
return this.compressSync(input);
|
|
738
|
-
}
|
|
739
|
-
/** Synchronously compresses data. */
|
|
740
|
-
compressSync(input) {
|
|
741
|
-
throw new Error(`${this.name}: sync compression not supported`);
|
|
742
|
-
}
|
|
743
|
-
/** Compresses batches. */
|
|
744
|
-
async *compressBatches(asyncIterator) {
|
|
745
|
-
const input = await this.concatenate(asyncIterator);
|
|
746
|
-
yield this.compress(input);
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
769
|
Decompressor = class extends CompressionTransform {
|
|
750
770
|
constructor(options) {
|
|
751
771
|
super();
|
|
@@ -766,112 +786,6 @@ var init_compression = __esm({
|
|
|
766
786
|
yield this.decompress(input);
|
|
767
787
|
}
|
|
768
788
|
};
|
|
769
|
-
Compression = class extends Compressor {
|
|
770
|
-
constructor(options) {
|
|
771
|
-
super(options);
|
|
772
|
-
this.decompressBatches = this.decompressBatches.bind(this);
|
|
773
|
-
}
|
|
774
|
-
/** Asynchronously decompresses data. */
|
|
775
|
-
async decompress(input, size) {
|
|
776
|
-
await this.preload();
|
|
777
|
-
return this.decompressSync(input, size);
|
|
778
|
-
}
|
|
779
|
-
/** Synchronously decompresses data. */
|
|
780
|
-
decompressSync(input, size) {
|
|
781
|
-
throw new Error(`${this.name}: sync decompression not supported`);
|
|
782
|
-
}
|
|
783
|
-
/** Decompresses batches. */
|
|
784
|
-
async *decompressBatches(asyncIterator) {
|
|
785
|
-
const input = await this.concatenate(asyncIterator);
|
|
786
|
-
yield this.decompress(input);
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
// ../compression/src/lib/compression-stream.ts
|
|
793
|
-
async function compressWithNativeCompressionStream(input, format) {
|
|
794
|
-
const outputBatches = compressBatchesWithNativeCompressionStream([input], format);
|
|
795
|
-
return outputBatches ? await concatenateBatches(outputBatches) : null;
|
|
796
|
-
}
|
|
797
|
-
function compressBatchesWithNativeCompressionStream(inputBatches, format) {
|
|
798
|
-
const compressionStream = createNativeCompressionStream(format);
|
|
799
|
-
return compressionStream ? transformBatches(inputBatches, compressionStream) : null;
|
|
800
|
-
}
|
|
801
|
-
function createNativeCompressionStream(format) {
|
|
802
|
-
if (typeof globalThis.CompressionStream === "undefined") {
|
|
803
|
-
return null;
|
|
804
|
-
}
|
|
805
|
-
try {
|
|
806
|
-
const CompressionStreamConstructor = globalThis.CompressionStream;
|
|
807
|
-
return new CompressionStreamConstructor(format);
|
|
808
|
-
} catch (error) {
|
|
809
|
-
if (error instanceof TypeError || (error == null ? void 0 : error.name) === "TypeError") {
|
|
810
|
-
return null;
|
|
811
|
-
}
|
|
812
|
-
throw error;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
async function* transformBatches(inputBatches, compressionStream) {
|
|
816
|
-
const writer = compressionStream.writable.getWriter();
|
|
817
|
-
const reader = compressionStream.readable.getReader();
|
|
818
|
-
const writePromise = writeBatches(inputBatches, writer);
|
|
819
|
-
writePromise.catch(() => {
|
|
820
|
-
});
|
|
821
|
-
let outputCompleted = false;
|
|
822
|
-
try {
|
|
823
|
-
while (true) {
|
|
824
|
-
const { done, value } = await reader.read();
|
|
825
|
-
if (done) {
|
|
826
|
-
outputCompleted = true;
|
|
827
|
-
break;
|
|
828
|
-
}
|
|
829
|
-
yield new Uint8Array(value).buffer;
|
|
830
|
-
}
|
|
831
|
-
await writePromise;
|
|
832
|
-
} finally {
|
|
833
|
-
if (!outputCompleted) {
|
|
834
|
-
await reader.cancel().catch(() => {
|
|
835
|
-
});
|
|
836
|
-
await writer.abort().catch(() => {
|
|
837
|
-
});
|
|
838
|
-
await writePromise.catch(() => {
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
reader.releaseLock();
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
async function writeBatches(inputBatches, writer) {
|
|
845
|
-
try {
|
|
846
|
-
for await (const inputBatch of inputBatches) {
|
|
847
|
-
await writer.write(new Uint8Array(inputBatch));
|
|
848
|
-
}
|
|
849
|
-
await writer.close();
|
|
850
|
-
} catch (error) {
|
|
851
|
-
await writer.abort(error).catch(() => {
|
|
852
|
-
});
|
|
853
|
-
throw error;
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
async function concatenateBatches(batches) {
|
|
857
|
-
const output = [];
|
|
858
|
-
let byteLength = 0;
|
|
859
|
-
for await (const batch of batches) {
|
|
860
|
-
const bytes = new Uint8Array(batch);
|
|
861
|
-
output.push(bytes);
|
|
862
|
-
byteLength += bytes.byteLength;
|
|
863
|
-
}
|
|
864
|
-
const result = new Uint8Array(byteLength);
|
|
865
|
-
let offset = 0;
|
|
866
|
-
for (const batch of output) {
|
|
867
|
-
result.set(batch, offset);
|
|
868
|
-
offset += batch.byteLength;
|
|
869
|
-
}
|
|
870
|
-
return result.buffer;
|
|
871
|
-
}
|
|
872
|
-
var init_compression_stream = __esm({
|
|
873
|
-
"../compression/src/lib/compression-stream.ts"() {
|
|
874
|
-
"use strict";
|
|
875
789
|
}
|
|
876
790
|
});
|
|
877
791
|
|
|
@@ -1092,48 +1006,138 @@ var init_lazy_compression = __esm({
|
|
|
1092
1006
|
}
|
|
1093
1007
|
});
|
|
1094
1008
|
|
|
1095
|
-
// ../compression/src/lib/
|
|
1096
|
-
async function*
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1009
|
+
// ../compression/src/lib/compress-utils-compression.ts
|
|
1010
|
+
async function* transformBatches(stream, inputBatches, maximumOutputByteLength = Number.POSITIVE_INFINITY) {
|
|
1011
|
+
let outputByteLength = 0;
|
|
1012
|
+
try {
|
|
1013
|
+
for await (const input of inputBatches) {
|
|
1014
|
+
const output2 = stream.write(new Uint8Array(input));
|
|
1015
|
+
if (output2.byteLength > maximumOutputByteLength - outputByteLength)
|
|
1016
|
+
throw new RangeError("Decompressed output exceeds maxOutputByteLength");
|
|
1017
|
+
outputByteLength += output2.byteLength;
|
|
1018
|
+
if (output2.byteLength > 0) yield copyArrayBuffer(output2);
|
|
1019
|
+
}
|
|
1020
|
+
const output = stream.finish();
|
|
1021
|
+
if (output.byteLength > maximumOutputByteLength - outputByteLength)
|
|
1022
|
+
throw new RangeError("Decompressed output exceeds maxOutputByteLength");
|
|
1023
|
+
if (output.byteLength > 0) yield copyArrayBuffer(output);
|
|
1024
|
+
} finally {
|
|
1025
|
+
stream.destroy();
|
|
1104
1026
|
}
|
|
1105
|
-
processor.push(new Uint8Array(0), true);
|
|
1106
|
-
yield* chunks;
|
|
1107
1027
|
}
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1028
|
+
function copyArrayBuffer(bytes) {
|
|
1029
|
+
return bytes.slice().buffer;
|
|
1030
|
+
}
|
|
1031
|
+
function getDecompressOptions(options, size) {
|
|
1032
|
+
const decodeOptions = {
|
|
1033
|
+
...options.compressUtils,
|
|
1034
|
+
...size === void 0 ? {} : { expectedSize: size }
|
|
1035
|
+
};
|
|
1036
|
+
const capacity = decodeOptions.expectedSize;
|
|
1037
|
+
const maximum = getMaximumOutputByteLength(options);
|
|
1038
|
+
if (capacity !== void 0 && (!Number.isSafeInteger(capacity) || capacity < 0 || capacity > maximum)) {
|
|
1039
|
+
throw new RangeError("expectedSize exceeds the configured output capacity limit");
|
|
1040
|
+
}
|
|
1041
|
+
return decodeOptions;
|
|
1042
|
+
}
|
|
1043
|
+
function getMaximumOutputByteLength(options) {
|
|
1044
|
+
const maximum = options.maxOutputByteLength ?? 512 * 1024 * 1024;
|
|
1045
|
+
if (!Number.isSafeInteger(maximum) || maximum < 0 || maximum > 2147483647)
|
|
1046
|
+
throw new RangeError("Invalid maxOutputByteLength");
|
|
1047
|
+
return maximum;
|
|
1048
|
+
}
|
|
1049
|
+
function copyDecompressedOutput(bytes, options) {
|
|
1050
|
+
if (bytes.byteLength > getMaximumOutputByteLength(options))
|
|
1051
|
+
throw new RangeError("Decompressed output exceeds maxOutputByteLength");
|
|
1052
|
+
return copyArrayBuffer(bytes);
|
|
1053
|
+
}
|
|
1054
|
+
var CompressUtilsDecompressor;
|
|
1055
|
+
var init_compress_utils_compression = __esm({
|
|
1056
|
+
"../compression/src/lib/compress-utils-compression.ts"() {
|
|
1118
1057
|
"use strict";
|
|
1119
|
-
import_fflate = require("fflate");
|
|
1120
1058
|
init_compression();
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
contentEncodings = ["gzip", "x-gzip"];
|
|
1059
|
+
CompressUtilsDecompressor = class extends Decompressor {
|
|
1060
|
+
name;
|
|
1061
|
+
extensions;
|
|
1062
|
+
contentEncodings;
|
|
1126
1063
|
isSupported = true;
|
|
1127
|
-
|
|
1064
|
+
options;
|
|
1065
|
+
loadModule;
|
|
1066
|
+
/** Module initialized for synchronous operations. */
|
|
1067
|
+
module = null;
|
|
1068
|
+
/** Shared import and WASM initialization for concurrent callers. */
|
|
1069
|
+
modulePromise = null;
|
|
1070
|
+
/** Creates a format-specific compress-utils decoder. */
|
|
1071
|
+
constructor(metadata, loadModule, options = {}) {
|
|
1128
1072
|
super(options);
|
|
1073
|
+
this.name = metadata.name;
|
|
1074
|
+
this.extensions = metadata.extensions || [];
|
|
1075
|
+
this.contentEncodings = metadata.contentEncodings || [];
|
|
1076
|
+
this.loadModule = loadModule;
|
|
1077
|
+
this.options = options;
|
|
1078
|
+
}
|
|
1079
|
+
/** Imports and initializes the codec without loading the opposite direction. */
|
|
1080
|
+
async preload(modules = {}) {
|
|
1081
|
+
await super.preload(modules);
|
|
1082
|
+
this.modulePromise ||= this.loadModule().then(async (module2) => {
|
|
1083
|
+
var _a;
|
|
1084
|
+
await ((_a = module2.preload) == null ? void 0 : _a.call(module2));
|
|
1085
|
+
this.module = module2;
|
|
1086
|
+
});
|
|
1087
|
+
try {
|
|
1088
|
+
await this.modulePromise;
|
|
1089
|
+
} catch (error) {
|
|
1090
|
+
this.modulePromise = null;
|
|
1091
|
+
throw error;
|
|
1092
|
+
}
|
|
1129
1093
|
}
|
|
1130
|
-
/**
|
|
1131
|
-
decompressSync(input) {
|
|
1132
|
-
|
|
1094
|
+
/** Runs synchronously after preload has initialized the WASM codec. */
|
|
1095
|
+
decompressSync(input, size) {
|
|
1096
|
+
var _a;
|
|
1097
|
+
if (!((_a = this.module) == null ? void 0 : _a.decompressSync))
|
|
1098
|
+
throw new Error(`${this.name}: call preload() before decompressSync()`);
|
|
1099
|
+
return copyDecompressedOutput(
|
|
1100
|
+
this.module.decompressSync(new Uint8Array(input), getDecompressOptions(this.options, size)),
|
|
1101
|
+
this.options
|
|
1102
|
+
);
|
|
1133
1103
|
}
|
|
1134
|
-
/** Decompresses
|
|
1104
|
+
/** Decompresses one buffer with the selected compress-utils decoder. */
|
|
1105
|
+
async decompress(input, size) {
|
|
1106
|
+
const decodeOptions = getDecompressOptions(this.options, size);
|
|
1107
|
+
await this.preload();
|
|
1108
|
+
const module2 = this.module;
|
|
1109
|
+
const output = await module2.decompress(new Uint8Array(input), decodeOptions);
|
|
1110
|
+
return copyDecompressedOutput(output, this.options);
|
|
1111
|
+
}
|
|
1112
|
+
/** Incrementally decompresses input batches with compress-utils. */
|
|
1135
1113
|
async *decompressBatches(inputBatches) {
|
|
1136
|
-
|
|
1114
|
+
await this.preload();
|
|
1115
|
+
const module2 = this.module;
|
|
1116
|
+
if (!module2.createDecompressStream) {
|
|
1117
|
+
yield await this.decompress(await this.concatenate(inputBatches));
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
const maximum = getMaximumOutputByteLength(this.options);
|
|
1121
|
+
const stream = await module2.createDecompressStream();
|
|
1122
|
+
yield* transformBatches(stream, inputBatches, maximum);
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
// ../compression/src/gzip-decompressor-compress-utils.ts
|
|
1129
|
+
var GZipCompressUtilsDecompressor;
|
|
1130
|
+
var init_gzip_decompressor_compress_utils = __esm({
|
|
1131
|
+
"../compression/src/gzip-decompressor-compress-utils.ts"() {
|
|
1132
|
+
"use strict";
|
|
1133
|
+
init_compress_utils_compression();
|
|
1134
|
+
GZipCompressUtilsDecompressor = class extends CompressUtilsDecompressor {
|
|
1135
|
+
constructor(options = {}) {
|
|
1136
|
+
super(
|
|
1137
|
+
{ name: "gzip", extensions: ["gz", "gzip"], contentEncodings: ["gzip", "x-gzip"] },
|
|
1138
|
+
() => import("compress-utils/gzip/decompress"),
|
|
1139
|
+
options
|
|
1140
|
+
);
|
|
1137
1141
|
}
|
|
1138
1142
|
};
|
|
1139
1143
|
}
|
|
@@ -1148,23 +1152,18 @@ var GZipDecompressor;
|
|
|
1148
1152
|
var init_gzip_decompressor = __esm({
|
|
1149
1153
|
"../compression/src/gzip-decompressor.ts"() {
|
|
1150
1154
|
"use strict";
|
|
1151
|
-
|
|
1155
|
+
init_gzip_decompressor_compress_utils();
|
|
1152
1156
|
init_decompression_stream();
|
|
1153
|
-
GZipDecompressor = class extends
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
super(options);
|
|
1157
|
-
this.options = options;
|
|
1158
|
-
}
|
|
1159
|
-
/** Decompresses with the built-in stream when available, then falls back to fflate. */
|
|
1160
|
-
async decompress(input) {
|
|
1157
|
+
GZipDecompressor = class extends GZipCompressUtilsDecompressor {
|
|
1158
|
+
/** Decompresses with native streams when available, otherwise lazily initializes WASM. */
|
|
1159
|
+
async decompress(input, size) {
|
|
1161
1160
|
if (this.options.useNative !== false) {
|
|
1162
1161
|
const output = await decompressWithNativeDecompressionStream(input, "gzip");
|
|
1163
1162
|
if (output) return output;
|
|
1164
1163
|
}
|
|
1165
|
-
return
|
|
1164
|
+
return super.decompress(input, size);
|
|
1166
1165
|
}
|
|
1167
|
-
/**
|
|
1166
|
+
/** Streams native batches when available, otherwise uses the WASM stream. */
|
|
1168
1167
|
async *decompressBatches(inputBatches) {
|
|
1169
1168
|
if (this.options.useNative !== false) {
|
|
1170
1169
|
const output = decompressBatchesWithNativeDecompressionStream(inputBatches, "gzip");
|
|
@@ -1179,126 +1178,19 @@ var init_gzip_decompressor = __esm({
|
|
|
1179
1178
|
}
|
|
1180
1179
|
});
|
|
1181
1180
|
|
|
1182
|
-
// ../compression/src/zstd-decompressor-
|
|
1183
|
-
var
|
|
1184
|
-
var
|
|
1185
|
-
"../compression/src/zstd-decompressor-
|
|
1181
|
+
// ../compression/src/zstd-decompressor-compress-utils.ts
|
|
1182
|
+
var ZstdCompressUtilsDecompressor;
|
|
1183
|
+
var init_zstd_decompressor_compress_utils = __esm({
|
|
1184
|
+
"../compression/src/zstd-decompressor-compress-utils.ts"() {
|
|
1186
1185
|
"use strict";
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
ZstdFzstdDecompressor = class extends Decompressor {
|
|
1190
|
-
name = "zstd";
|
|
1191
|
-
extensions = ["zst"];
|
|
1192
|
-
contentEncodings = ["zstd"];
|
|
1193
|
-
isSupported = true;
|
|
1186
|
+
init_compress_utils_compression();
|
|
1187
|
+
ZstdCompressUtilsDecompressor = class extends CompressUtilsDecompressor {
|
|
1194
1188
|
constructor(options = {}) {
|
|
1195
|
-
super(
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
}
|
|
1201
|
-
};
|
|
1202
|
-
}
|
|
1203
|
-
});
|
|
1204
|
-
|
|
1205
|
-
// ../compression/src/zstd-fallback.ts
|
|
1206
|
-
var zstd_fallback_exports = {};
|
|
1207
|
-
__export(zstd_fallback_exports, {
|
|
1208
|
-
decompressZstd: () => decompressZstd
|
|
1209
|
-
});
|
|
1210
|
-
function decompressZstd(input) {
|
|
1211
|
-
return (0, import_fzstd2.decompress)(input);
|
|
1212
|
-
}
|
|
1213
|
-
var import_fzstd2;
|
|
1214
|
-
var init_zstd_fallback = __esm({
|
|
1215
|
-
"../compression/src/zstd-fallback.ts"() {
|
|
1216
|
-
"use strict";
|
|
1217
|
-
import_fzstd2 = require("fzstd");
|
|
1218
|
-
}
|
|
1219
|
-
});
|
|
1220
|
-
|
|
1221
|
-
// ../compression/src/lib/zstd-compression.ts
|
|
1222
|
-
var zstd_compression_exports = {};
|
|
1223
|
-
__export(zstd_compression_exports, {
|
|
1224
|
-
ZstdCompression: () => ZstdCompression
|
|
1225
|
-
});
|
|
1226
|
-
var CHUNK_SIZE, zstdPromise, zstd, ZstdCompression;
|
|
1227
|
-
var init_zstd_compression = __esm({
|
|
1228
|
-
"../compression/src/lib/zstd-compression.ts"() {
|
|
1229
|
-
"use strict";
|
|
1230
|
-
init_compression();
|
|
1231
|
-
init_src();
|
|
1232
|
-
init_compression_stream();
|
|
1233
|
-
init_decompression_stream();
|
|
1234
|
-
CHUNK_SIZE = 1e6;
|
|
1235
|
-
ZstdCompression = class extends Compression {
|
|
1236
|
-
name = "zstd";
|
|
1237
|
-
extensions = [];
|
|
1238
|
-
contentEncodings = [];
|
|
1239
|
-
isSupported = true;
|
|
1240
|
-
options;
|
|
1241
|
-
/**
|
|
1242
|
-
* zstd-codec is an injectable dependency due to big size
|
|
1243
|
-
* @param options
|
|
1244
|
-
*/
|
|
1245
|
-
constructor(options = {}) {
|
|
1246
|
-
super(options);
|
|
1247
|
-
this.options = options;
|
|
1248
|
-
registerJSModules(options == null ? void 0 : options.modules);
|
|
1249
|
-
}
|
|
1250
|
-
async preload(modules = {}) {
|
|
1251
|
-
registerJSModules(modules);
|
|
1252
|
-
const ZstdCodec = getJSModuleOrNull("zstd-codec");
|
|
1253
|
-
if (!zstdPromise && ZstdCodec) {
|
|
1254
|
-
zstdPromise = new Promise((resolve) => ZstdCodec.run((zstd2) => resolve(zstd2)));
|
|
1255
|
-
}
|
|
1256
|
-
if (zstdPromise) {
|
|
1257
|
-
zstd = await zstdPromise;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
compressSync(input) {
|
|
1261
|
-
getJSModule("zstd-codec", this.name);
|
|
1262
|
-
const simpleZstd = new zstd.Simple();
|
|
1263
|
-
const inputArray = new Uint8Array(input);
|
|
1264
|
-
return simpleZstd.compress(inputArray).buffer;
|
|
1265
|
-
}
|
|
1266
|
-
async compress(input) {
|
|
1267
|
-
var _a;
|
|
1268
|
-
if (this.options.useNative !== false && ((_a = this.options.zstd) == null ? void 0 : _a.useNative) !== false) {
|
|
1269
|
-
const nativeOutput = await compressWithNativeCompressionStream(input, "zstd");
|
|
1270
|
-
if (nativeOutput) return nativeOutput;
|
|
1271
|
-
}
|
|
1272
|
-
await this.preload();
|
|
1273
|
-
return this.compressSync(input);
|
|
1274
|
-
}
|
|
1275
|
-
decompressSync(input) {
|
|
1276
|
-
getJSModule("zstd-codec", this.name);
|
|
1277
|
-
const simpleZstd = new zstd.Simple();
|
|
1278
|
-
const inputArray = new Uint8Array(input);
|
|
1279
|
-
return simpleZstd.decompress(inputArray).buffer;
|
|
1280
|
-
}
|
|
1281
|
-
async decompress(input, size) {
|
|
1282
|
-
var _a;
|
|
1283
|
-
if (!getJSModuleOrNull("zstd-codec") && this.options.useNative !== false && ((_a = this.options.zstd) == null ? void 0 : _a.useNative) !== false) {
|
|
1284
|
-
const nativeOutput = await decompressWithNativeDecompressionStream(input, "zstd");
|
|
1285
|
-
if (nativeOutput) return nativeOutput;
|
|
1286
|
-
}
|
|
1287
|
-
await this.preload();
|
|
1288
|
-
const inputArray = new Uint8Array(input);
|
|
1289
|
-
if (!zstd) {
|
|
1290
|
-
const { decompressZstd: decompressZstd2 } = await Promise.resolve().then(() => (init_zstd_fallback(), zstd_fallback_exports));
|
|
1291
|
-
return ensureArrayBuffer(decompressZstd2(inputArray));
|
|
1292
|
-
}
|
|
1293
|
-
const simpleZstd = new zstd.Streaming();
|
|
1294
|
-
const chunks = [];
|
|
1295
|
-
for (let i = 0; i <= inputArray.length; i += CHUNK_SIZE) {
|
|
1296
|
-
const chunkView = inputArray.subarray(i, i + CHUNK_SIZE);
|
|
1297
|
-
const chunkArrayBuffer = ensureArrayBuffer(chunkView);
|
|
1298
|
-
chunks.push(new Uint8Array(chunkArrayBuffer));
|
|
1299
|
-
}
|
|
1300
|
-
const decompressResult = await simpleZstd.decompressChunks(chunks);
|
|
1301
|
-
return decompressResult.buffer;
|
|
1189
|
+
super(
|
|
1190
|
+
{ name: "zstd", extensions: ["zst"], contentEncodings: ["zstd"] },
|
|
1191
|
+
() => import("compress-utils/zstd/decompress"),
|
|
1192
|
+
options
|
|
1193
|
+
);
|
|
1302
1194
|
}
|
|
1303
1195
|
};
|
|
1304
1196
|
}
|
|
@@ -1313,48 +1205,18 @@ var ZstdDecompressor;
|
|
|
1313
1205
|
var init_zstd_decompressor = __esm({
|
|
1314
1206
|
"../compression/src/zstd-decompressor.ts"() {
|
|
1315
1207
|
"use strict";
|
|
1316
|
-
|
|
1208
|
+
init_zstd_decompressor_compress_utils();
|
|
1317
1209
|
init_decompression_stream();
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
compatibility = null;
|
|
1322
|
-
constructor(options = {}) {
|
|
1323
|
-
super(options);
|
|
1324
|
-
this.options = options;
|
|
1325
|
-
registerJSModules(options.modules);
|
|
1326
|
-
}
|
|
1327
|
-
/** Preloads an injected zstd-codec implementation when supplied. */
|
|
1328
|
-
async preload(modules = {}) {
|
|
1329
|
-
registerJSModules(modules);
|
|
1330
|
-
if (getJSModuleOrNull("zstd-codec")) {
|
|
1331
|
-
const { ZstdCompression: ZstdCompression2 } = await Promise.resolve().then(() => (init_zstd_compression(), zstd_compression_exports));
|
|
1332
|
-
this.compatibility ||= new ZstdCompression2(this.options);
|
|
1333
|
-
await this.compatibility.preload(modules);
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
/** Decompresses with the built-in stream when available, then falls back to fzstd. */
|
|
1337
|
-
async decompress(input) {
|
|
1210
|
+
ZstdDecompressor = class extends ZstdCompressUtilsDecompressor {
|
|
1211
|
+
/** Decompresses with native streams when available, otherwise lazily initializes WASM. */
|
|
1212
|
+
async decompress(input, size) {
|
|
1338
1213
|
if (this.options.useNative !== false) {
|
|
1339
1214
|
const output = await decompressWithNativeDecompressionStream(input, "zstd");
|
|
1340
1215
|
if (output) return output;
|
|
1341
1216
|
}
|
|
1342
|
-
|
|
1343
|
-
await this.preload(this.options.modules);
|
|
1344
|
-
}
|
|
1345
|
-
return this.decompressSync(input);
|
|
1346
|
-
}
|
|
1347
|
-
/** Decompresses with a preloaded zstd-codec implementation or compact fzstd. */
|
|
1348
|
-
decompressSync(input) {
|
|
1349
|
-
if (this.compatibility) {
|
|
1350
|
-
return this.compatibility.decompressSync(input);
|
|
1351
|
-
}
|
|
1352
|
-
if (getJSModuleOrNull("zstd-codec")) {
|
|
1353
|
-
throw new Error("zstd: call preload() before synchronous decompression with zstd-codec");
|
|
1354
|
-
}
|
|
1355
|
-
return super.decompressSync(input);
|
|
1217
|
+
return super.decompress(input, size);
|
|
1356
1218
|
}
|
|
1357
|
-
/**
|
|
1219
|
+
/** Streams native batches when available, otherwise uses the WASM stream. */
|
|
1358
1220
|
async *decompressBatches(inputBatches) {
|
|
1359
1221
|
if (this.options.useNative !== false) {
|
|
1360
1222
|
const output = decompressBatchesWithNativeDecompressionStream(inputBatches, "zstd");
|
|
@@ -1363,10 +1225,6 @@ var init_zstd_decompressor = __esm({
|
|
|
1363
1225
|
return;
|
|
1364
1226
|
}
|
|
1365
1227
|
}
|
|
1366
|
-
if (getJSModuleOrNull("zstd-codec")) {
|
|
1367
|
-
yield this.decompress(await this.concatenate(inputBatches));
|
|
1368
|
-
return;
|
|
1369
|
-
}
|
|
1370
1228
|
yield* super.decompressBatches(inputBatches);
|
|
1371
1229
|
}
|
|
1372
1230
|
};
|
|
@@ -1379,7 +1237,6 @@ var init_default_codecs = __esm({
|
|
|
1379
1237
|
"../compression/src/default-codecs.ts"() {
|
|
1380
1238
|
"use strict";
|
|
1381
1239
|
init_lazy_compression();
|
|
1382
|
-
init_src();
|
|
1383
1240
|
GZIP = { name: "gzip", extensions: ["gz"], contentEncodings: ["gzip"] };
|
|
1384
1241
|
ZSTD = { name: "zstd", extensions: ["zst"], contentEncodings: ["zstd"] };
|
|
1385
1242
|
GZipDecompressor2 = class extends LazyDecompressor {
|
|
@@ -1398,11 +1255,7 @@ var init_default_codecs = __esm({
|
|
|
1398
1255
|
ZSTD,
|
|
1399
1256
|
async () => (await Promise.resolve().then(() => (init_zstd_decompressor(), zstd_decompressor_exports))).ZstdDecompressor,
|
|
1400
1257
|
options,
|
|
1401
|
-
"zstd"
|
|
1402
|
-
(preloadOptions) => {
|
|
1403
|
-
var _a;
|
|
1404
|
-
return !((_a = preloadOptions.modules) == null ? void 0 : _a["zstd-codec"]) && !getJSModuleOrNull("zstd-codec");
|
|
1405
|
-
}
|
|
1258
|
+
"zstd"
|
|
1406
1259
|
);
|
|
1407
1260
|
}
|
|
1408
1261
|
};
|
|
@@ -1410,7 +1263,7 @@ var init_default_codecs = __esm({
|
|
|
1410
1263
|
});
|
|
1411
1264
|
|
|
1412
1265
|
// ../compression/src/index.ts
|
|
1413
|
-
var
|
|
1266
|
+
var init_src = __esm({
|
|
1414
1267
|
"../compression/src/index.ts"() {
|
|
1415
1268
|
"use strict";
|
|
1416
1269
|
init_default_codecs();
|
|
@@ -1502,6 +1355,13 @@ function makeGaussianSplatsArrowTable(splats) {
|
|
|
1502
1355
|
["topology", "point-list"],
|
|
1503
1356
|
["mode", "0"]
|
|
1504
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
|
+
}
|
|
1505
1365
|
const arrowSchema = new arrow.Schema(fields, metadata);
|
|
1506
1366
|
const schema = {
|
|
1507
1367
|
fields: schemaFields,
|
|
@@ -1578,6 +1438,7 @@ var init_splats_arrow_table = __esm({
|
|
|
1578
1438
|
"dist/lib/splats-arrow-table.js"() {
|
|
1579
1439
|
"use strict";
|
|
1580
1440
|
arrow = __toESM(require("apache-arrow"), 1);
|
|
1441
|
+
init_loader_utils();
|
|
1581
1442
|
init_splat_utils();
|
|
1582
1443
|
}
|
|
1583
1444
|
});
|
|
@@ -1948,7 +1809,7 @@ var SPZ_HEADER_BYTE_LENGTH, SPZ_MAGIC, SPZ_VERSION, SPZ_EXTENSION_FLAG, SPZ_COLO
|
|
|
1948
1809
|
var init_parse_spz = __esm({
|
|
1949
1810
|
"dist/lib/parse-spz.js"() {
|
|
1950
1811
|
"use strict";
|
|
1951
|
-
|
|
1812
|
+
init_src();
|
|
1952
1813
|
init_splats_arrow_table();
|
|
1953
1814
|
init_splat_utils();
|
|
1954
1815
|
SPZ_HEADER_BYTE_LENGTH = 32;
|
|
@@ -2035,8 +1896,8 @@ var init_splat_loader = __esm({
|
|
|
2035
1896
|
({ preload: _SPLATLoaderPreload, ...SPLATLoaderMetadataWithoutPreload } = SPLATLoader);
|
|
2036
1897
|
SPLATLoaderWithParser = {
|
|
2037
1898
|
...SPLATLoaderMetadataWithoutPreload,
|
|
2038
|
-
parse: async (arrayBuffer) => parseSPLAT(arrayBuffer),
|
|
2039
|
-
parseSync: (arrayBuffer) => parseSPLAT(arrayBuffer)
|
|
1899
|
+
parse: async (arrayBuffer) => parseSPLAT(arrayBuffer).data,
|
|
1900
|
+
parseSync: (arrayBuffer) => parseSPLAT(arrayBuffer).data
|
|
2040
1901
|
};
|
|
2041
1902
|
}
|
|
2042
1903
|
});
|
|
@@ -2051,15 +1912,17 @@ var init_splat_loader_types = __esm({
|
|
|
2051
1912
|
"dist/splat-loader-types.js"() {
|
|
2052
1913
|
"use strict";
|
|
2053
1914
|
init_splats_format();
|
|
2054
|
-
VERSION2 = true ? "5.0.0-
|
|
1915
|
+
VERSION2 = true ? "5.0.0-beta.10" : "latest";
|
|
2055
1916
|
SPLATLoader = {
|
|
1917
|
+
defaultShape: "arrow",
|
|
1918
|
+
supportsNativeArrow: true,
|
|
2056
1919
|
dataType: null,
|
|
2057
1920
|
batchType: null,
|
|
2058
1921
|
...SPLATFormat,
|
|
2059
1922
|
version: VERSION2,
|
|
2060
1923
|
options: {
|
|
2061
1924
|
splats: {
|
|
2062
|
-
shape: "arrow
|
|
1925
|
+
shape: "arrow"
|
|
2063
1926
|
}
|
|
2064
1927
|
},
|
|
2065
1928
|
preload
|
|
@@ -2360,8 +2223,8 @@ var init_ksplat_loader = __esm({
|
|
|
2360
2223
|
({ preload: _KSPLATLoaderPreload, ...KSPLATLoaderMetadataWithoutPreload } = KSPLATLoader);
|
|
2361
2224
|
KSPLATLoaderWithParser = {
|
|
2362
2225
|
...KSPLATLoaderMetadataWithoutPreload,
|
|
2363
|
-
parse: async (arrayBuffer) => parseKSPLAT(arrayBuffer),
|
|
2364
|
-
parseSync: (arrayBuffer) => parseKSPLAT(arrayBuffer)
|
|
2226
|
+
parse: async (arrayBuffer) => parseKSPLAT(arrayBuffer).data,
|
|
2227
|
+
parseSync: (arrayBuffer) => parseKSPLAT(arrayBuffer).data
|
|
2365
2228
|
};
|
|
2366
2229
|
}
|
|
2367
2230
|
});
|
|
@@ -2376,15 +2239,17 @@ var init_ksplat_loader_types = __esm({
|
|
|
2376
2239
|
"dist/ksplat-loader-types.js"() {
|
|
2377
2240
|
"use strict";
|
|
2378
2241
|
init_splats_format();
|
|
2379
|
-
VERSION3 = true ? "5.0.0-
|
|
2242
|
+
VERSION3 = true ? "5.0.0-beta.10" : "latest";
|
|
2380
2243
|
KSPLATLoader = {
|
|
2244
|
+
defaultShape: "arrow",
|
|
2245
|
+
supportsNativeArrow: true,
|
|
2381
2246
|
dataType: null,
|
|
2382
2247
|
batchType: null,
|
|
2383
2248
|
...KSPLATFormat,
|
|
2384
2249
|
version: VERSION3,
|
|
2385
2250
|
options: {
|
|
2386
2251
|
splats: {
|
|
2387
|
-
shape: "arrow
|
|
2252
|
+
shape: "arrow"
|
|
2388
2253
|
}
|
|
2389
2254
|
},
|
|
2390
2255
|
preload: preload2
|
|
@@ -2406,7 +2271,7 @@ var init_spz_loader = __esm({
|
|
|
2406
2271
|
({ preload: _SPZLoaderPreload, ...SPZLoaderMetadataWithoutPreload } = SPZLoader);
|
|
2407
2272
|
SPZLoaderWithParser = {
|
|
2408
2273
|
...SPZLoaderMetadataWithoutPreload,
|
|
2409
|
-
parse: async (arrayBuffer, options) => parseSPZ(arrayBuffer, options)
|
|
2274
|
+
parse: async (arrayBuffer, options) => (await parseSPZ(arrayBuffer, options)).data
|
|
2410
2275
|
};
|
|
2411
2276
|
}
|
|
2412
2277
|
});
|
|
@@ -2421,15 +2286,17 @@ var init_spz_loader_types = __esm({
|
|
|
2421
2286
|
"dist/spz-loader-types.js"() {
|
|
2422
2287
|
"use strict";
|
|
2423
2288
|
init_splats_format();
|
|
2424
|
-
VERSION4 = true ? "5.0.0-
|
|
2289
|
+
VERSION4 = true ? "5.0.0-beta.10" : "latest";
|
|
2425
2290
|
SPZLoader = {
|
|
2291
|
+
defaultShape: "arrow",
|
|
2292
|
+
supportsNativeArrow: true,
|
|
2426
2293
|
dataType: null,
|
|
2427
2294
|
batchType: null,
|
|
2428
2295
|
...SPZFormat,
|
|
2429
2296
|
version: VERSION4,
|
|
2430
2297
|
options: {
|
|
2431
2298
|
splats: {
|
|
2432
|
-
shape: "arrow
|
|
2299
|
+
shape: "arrow"
|
|
2433
2300
|
}
|
|
2434
2301
|
},
|
|
2435
2302
|
preload: preload3
|
|
@@ -2595,34 +2462,19 @@ var init_parse_rad = __esm({
|
|
|
2595
2462
|
}
|
|
2596
2463
|
});
|
|
2597
2464
|
|
|
2598
|
-
// ../compression/src/deflate-decompressor-
|
|
2599
|
-
var
|
|
2600
|
-
var
|
|
2601
|
-
"../compression/src/deflate-decompressor-
|
|
2465
|
+
// ../compression/src/deflate-decompressor-compress-utils.ts
|
|
2466
|
+
var DeflateCompressUtilsDecompressor;
|
|
2467
|
+
var init_deflate_decompressor_compress_utils = __esm({
|
|
2468
|
+
"../compression/src/deflate-decompressor-compress-utils.ts"() {
|
|
2602
2469
|
"use strict";
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
init_fflate_stream();
|
|
2606
|
-
DeflateFflateDecompressor = class extends Decompressor {
|
|
2607
|
-
name = "deflate";
|
|
2608
|
-
extensions = [];
|
|
2609
|
-
contentEncodings = ["deflate"];
|
|
2610
|
-
isSupported = true;
|
|
2611
|
-
options;
|
|
2470
|
+
init_compress_utils_compression();
|
|
2471
|
+
DeflateCompressUtilsDecompressor = class extends CompressUtilsDecompressor {
|
|
2612
2472
|
constructor(options = {}) {
|
|
2613
|
-
super(
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
const bytes = new Uint8Array(input);
|
|
2619
|
-
const output = this.options.raw ? (0, import_fflate2.inflateSync)(bytes) : (0, import_fflate2.unzlibSync)(bytes);
|
|
2620
|
-
return output.slice().buffer;
|
|
2621
|
-
}
|
|
2622
|
-
/** Decompresses DEFLATE batches incrementally. */
|
|
2623
|
-
async *decompressBatches(inputBatches) {
|
|
2624
|
-
const processor = this.options.raw ? new import_fflate2.Inflate() : new import_fflate2.Unzlib();
|
|
2625
|
-
yield* transformFflateBatches(processor, inputBatches);
|
|
2473
|
+
super(
|
|
2474
|
+
{ name: "deflate", contentEncodings: ["deflate"] },
|
|
2475
|
+
() => options.raw ? import("compress-utils/deflate/decompress") : import("compress-utils/zlib/decompress"),
|
|
2476
|
+
options
|
|
2477
|
+
);
|
|
2626
2478
|
}
|
|
2627
2479
|
};
|
|
2628
2480
|
}
|
|
@@ -2633,26 +2485,27 @@ var DeflateDecompressor2;
|
|
|
2633
2485
|
var init_deflate_decompressor = __esm({
|
|
2634
2486
|
"../compression/src/deflate-decompressor.ts"() {
|
|
2635
2487
|
"use strict";
|
|
2636
|
-
|
|
2488
|
+
init_deflate_decompressor_compress_utils();
|
|
2637
2489
|
init_decompression_stream();
|
|
2638
|
-
DeflateDecompressor2 = class extends
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
}
|
|
2642
|
-
/** Decompresses with the built-in stream when available, then falls back to fflate. */
|
|
2643
|
-
async decompress(input) {
|
|
2490
|
+
DeflateDecompressor2 = class extends DeflateCompressUtilsDecompressor {
|
|
2491
|
+
/** Decompresses with native streams when available, otherwise lazily initializes WASM. */
|
|
2492
|
+
async decompress(input, size) {
|
|
2644
2493
|
if (this.options.useNative !== false) {
|
|
2645
|
-
const
|
|
2646
|
-
|
|
2494
|
+
const output = await decompressWithNativeDecompressionStream(
|
|
2495
|
+
input,
|
|
2496
|
+
this.options.raw ? "deflate-raw" : "deflate"
|
|
2497
|
+
);
|
|
2647
2498
|
if (output) return output;
|
|
2648
2499
|
}
|
|
2649
|
-
return
|
|
2500
|
+
return super.decompress(input, size);
|
|
2650
2501
|
}
|
|
2651
|
-
/**
|
|
2502
|
+
/** Streams native batches when available, otherwise uses the WASM stream. */
|
|
2652
2503
|
async *decompressBatches(inputBatches) {
|
|
2653
2504
|
if (this.options.useNative !== false) {
|
|
2654
|
-
const
|
|
2655
|
-
|
|
2505
|
+
const output = decompressBatchesWithNativeDecompressionStream(
|
|
2506
|
+
inputBatches,
|
|
2507
|
+
this.options.raw ? "deflate-raw" : "deflate"
|
|
2508
|
+
);
|
|
2656
2509
|
if (output) {
|
|
2657
2510
|
yield* output;
|
|
2658
2511
|
return;
|
|
@@ -2665,6 +2518,9 @@ var init_deflate_decompressor = __esm({
|
|
|
2665
2518
|
});
|
|
2666
2519
|
|
|
2667
2520
|
// dist/lib/parse-rad-chunk.js
|
|
2521
|
+
async function preloadRADCompression() {
|
|
2522
|
+
await Promise.all([RAD_PROPERTY_DEFLATE.preload(), RAD_PROPERTY_RAW_DEFLATE.preload()]);
|
|
2523
|
+
}
|
|
2668
2524
|
function parseRADChunk(data, options) {
|
|
2669
2525
|
return makeGaussianSplatsArrowTable(parseRADChunkToGaussianSplats(data, options));
|
|
2670
2526
|
}
|
|
@@ -2872,7 +2728,7 @@ function getRADPropertyBytes(bytes, metadata, property) {
|
|
|
2872
2728
|
return decompressRADProperty(propertyBytes, property.property);
|
|
2873
2729
|
}
|
|
2874
2730
|
function decompressRADProperty(bytes, propertyName) {
|
|
2875
|
-
const arrayBuffer =
|
|
2731
|
+
const arrayBuffer = copyToArrayBuffer2(bytes);
|
|
2876
2732
|
try {
|
|
2877
2733
|
return new Uint8Array(RAD_PROPERTY_DEFLATE.decompressSync(arrayBuffer));
|
|
2878
2734
|
} catch {
|
|
@@ -3114,7 +2970,7 @@ function getSplatEncodingMaximum(splatEncoding, propertyName) {
|
|
|
3114
2970
|
function normalizeColorByte2(value) {
|
|
3115
2971
|
return Math.round(Math.min(Math.max(value, 0), 1) * 255);
|
|
3116
2972
|
}
|
|
3117
|
-
function
|
|
2973
|
+
function copyToArrayBuffer2(bytes) {
|
|
3118
2974
|
const copy = new Uint8Array(bytes.byteLength);
|
|
3119
2975
|
copy.set(bytes);
|
|
3120
2976
|
return copy.buffer;
|
|
@@ -3135,315 +2991,10 @@ var init_parse_rad_chunk = __esm({
|
|
|
3135
2991
|
}
|
|
3136
2992
|
});
|
|
3137
2993
|
|
|
3138
|
-
// dist/rad-loader.js
|
|
3139
|
-
var rad_loader_exports = {};
|
|
3140
|
-
__export(rad_loader_exports, {
|
|
3141
|
-
RADLoaderWithParser: () => RADLoaderWithParser,
|
|
3142
|
-
parseRADChunk: () => parseRADChunk,
|
|
3143
|
-
parseRADChunkHeader: () => parseRADChunkHeader,
|
|
3144
|
-
parseRADChunkToGaussianSplats: () => parseRADChunkToGaussianSplats,
|
|
3145
|
-
parseRADHeader: () => parseRADHeader,
|
|
3146
|
-
tryParseRADHeader: () => tryParseRADHeader
|
|
3147
|
-
});
|
|
3148
|
-
var _RADLoaderPreload, RADLoaderMetadataWithoutPreload, RADLoaderWithParser;
|
|
3149
|
-
var init_rad_loader = __esm({
|
|
3150
|
-
"dist/rad-loader.js"() {
|
|
3151
|
-
"use strict";
|
|
3152
|
-
init_parse_rad();
|
|
3153
|
-
init_rad_loader_types();
|
|
3154
|
-
init_parse_rad();
|
|
3155
|
-
init_parse_rad_chunk();
|
|
3156
|
-
({ preload: _RADLoaderPreload, ...RADLoaderMetadataWithoutPreload } = RADLoader);
|
|
3157
|
-
RADLoaderWithParser = {
|
|
3158
|
-
...RADLoaderMetadataWithoutPreload,
|
|
3159
|
-
parse: async (arrayBuffer) => parseRADHeader(arrayBuffer),
|
|
3160
|
-
parseSync: (arrayBuffer) => parseRADHeader(arrayBuffer)
|
|
3161
|
-
};
|
|
3162
|
-
}
|
|
3163
|
-
});
|
|
3164
|
-
|
|
3165
|
-
// dist/rad-loader-types.js
|
|
3166
|
-
async function preload4() {
|
|
3167
|
-
const { RADLoaderWithParser: RADLoaderWithParser2 } = await Promise.resolve().then(() => (init_rad_loader(), rad_loader_exports));
|
|
3168
|
-
return RADLoaderWithParser2;
|
|
3169
|
-
}
|
|
3170
|
-
var VERSION5, RADLoader;
|
|
3171
|
-
var init_rad_loader_types = __esm({
|
|
3172
|
-
"dist/rad-loader-types.js"() {
|
|
3173
|
-
"use strict";
|
|
3174
|
-
init_splats_format();
|
|
3175
|
-
VERSION5 = true ? "5.0.0-alpha.9" : "latest";
|
|
3176
|
-
RADLoader = {
|
|
3177
|
-
dataType: null,
|
|
3178
|
-
batchType: null,
|
|
3179
|
-
...RADFormat,
|
|
3180
|
-
version: VERSION5,
|
|
3181
|
-
options: {},
|
|
3182
|
-
preload: preload4
|
|
3183
|
-
};
|
|
3184
|
-
}
|
|
3185
|
-
});
|
|
3186
|
-
|
|
3187
|
-
// dist/index.js
|
|
3188
|
-
var index_exports = {};
|
|
3189
|
-
__export(index_exports, {
|
|
3190
|
-
KSPLATFormat: () => KSPLATFormat,
|
|
3191
|
-
KSPLATLoader: () => KSPLATLoader,
|
|
3192
|
-
RADFormat: () => RADFormat,
|
|
3193
|
-
RADLoader: () => RADLoader,
|
|
3194
|
-
RADSource: () => RADSource,
|
|
3195
|
-
RADSourceLoader: () => RADSourceLoader,
|
|
3196
|
-
SPLATFormat: () => SPLATFormat,
|
|
3197
|
-
SPLATLoader: () => SPLATLoader,
|
|
3198
|
-
SPZFormat: () => SPZFormat,
|
|
3199
|
-
SPZLoader: () => SPZLoader,
|
|
3200
|
-
parseSPZ: () => parseSPZ,
|
|
3201
|
-
parseSPZToGaussianSplats: () => parseSPZToGaussianSplats,
|
|
3202
|
-
resolveRADChunkUrl: () => resolveRADChunkUrl
|
|
3203
|
-
});
|
|
3204
|
-
module.exports = __toCommonJS(index_exports);
|
|
3205
|
-
init_splats_format();
|
|
3206
|
-
init_parse_spz();
|
|
3207
|
-
init_splat_loader_types();
|
|
3208
|
-
init_ksplat_loader_types();
|
|
3209
|
-
init_spz_loader_types();
|
|
3210
|
-
init_rad_loader_types();
|
|
3211
|
-
|
|
3212
2994
|
// dist/rad-source-loader.js
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
init_parse_rad_chunk();
|
|
3217
|
-
init_splats_arrow_table();
|
|
3218
|
-
var DEFAULT_RAD_HEADER_BYTE_LENGTHS = [64 * 1024, 256 * 1024, 1024 * 1024];
|
|
3219
|
-
var DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS = 4;
|
|
3220
|
-
var VERSION6 = true ? "5.0.0-alpha.9" : "latest";
|
|
3221
|
-
var RADSourceLoader = {
|
|
3222
|
-
dataType: null,
|
|
3223
|
-
batchType: null,
|
|
3224
|
-
...RADFormat,
|
|
3225
|
-
name: "RADSourceLoader",
|
|
3226
|
-
version: VERSION6,
|
|
3227
|
-
type: "rad",
|
|
3228
|
-
fromUrl: true,
|
|
3229
|
-
fromBlob: true,
|
|
3230
|
-
options: {
|
|
3231
|
-
rad: {
|
|
3232
|
-
headers: void 0,
|
|
3233
|
-
withCredentials: false,
|
|
3234
|
-
headerByteLengths: void 0
|
|
3235
|
-
}
|
|
3236
|
-
},
|
|
3237
|
-
defaultOptions: {
|
|
3238
|
-
rad: {
|
|
3239
|
-
headers: void 0,
|
|
3240
|
-
withCredentials: false,
|
|
3241
|
-
headerByteLengths: void 0
|
|
3242
|
-
}
|
|
3243
|
-
},
|
|
3244
|
-
testURL: (url) => /\.rad(?:$|[?#])/i.test(url),
|
|
3245
|
-
createDataSource: (data, options, coreApi) => new RADSource(data, options, coreApi)
|
|
3246
|
-
};
|
|
3247
|
-
var RADSource = class extends DataSource {
|
|
3248
|
-
/** Shared metadata promise exposed for source-style integrations. */
|
|
3249
|
-
metadata;
|
|
3250
|
-
/** Lazily initialized RAD header promise. */
|
|
3251
|
-
_metadataPromise = null;
|
|
3252
|
-
/** Lazily initialized per-chunk metadata promises. */
|
|
3253
|
-
_chunkMetadataPromises = /* @__PURE__ */ new Map();
|
|
3254
|
-
constructor(data, options, coreApi) {
|
|
3255
|
-
super(data, options, RADSourceLoader.defaultOptions, coreApi);
|
|
3256
|
-
this.metadata = this.getMetadata();
|
|
3257
|
-
}
|
|
3258
|
-
/** Ensures the RAD header metadata has been loaded. */
|
|
3259
|
-
async initialize() {
|
|
3260
|
-
await this.getMetadata();
|
|
3261
|
-
}
|
|
3262
|
-
/** Returns parsed Spark RAD top-level metadata. */
|
|
3263
|
-
async getMetadata() {
|
|
3264
|
-
if (!this._metadataPromise) {
|
|
3265
|
-
this._metadataPromise = this._loadMetadata();
|
|
3266
|
-
}
|
|
3267
|
-
return await this._metadataPromise;
|
|
3268
|
-
}
|
|
3269
|
-
/** Returns the number of chunks declared by the RAD metadata. */
|
|
3270
|
-
async getChunkCount() {
|
|
3271
|
-
const metadata = await this.getMetadata();
|
|
3272
|
-
return metadata.chunks.length;
|
|
3273
|
-
}
|
|
3274
|
-
/** Returns the URL used for a chunk, or `null` for Blob-backed inline chunks. */
|
|
3275
|
-
async getChunkUrl(chunkIndex) {
|
|
3276
|
-
const metadata = await this.getMetadata();
|
|
3277
|
-
const chunk = this._getChunkRange(metadata, chunkIndex);
|
|
3278
|
-
if (chunk.filename) {
|
|
3279
|
-
return resolveRADChunkUrl(this.url, chunk.filename);
|
|
3280
|
-
}
|
|
3281
|
-
return typeof this.data === "string" ? this.url : null;
|
|
3282
|
-
}
|
|
3283
|
-
/** Fetches one raw RADC chunk by index. */
|
|
3284
|
-
async getChunk(chunkIndex, options = {}) {
|
|
3285
|
-
const metadata = await this.getMetadata();
|
|
3286
|
-
const chunk = this._getChunkRange(metadata, chunkIndex);
|
|
3287
|
-
if (chunk.filename) {
|
|
3288
|
-
if (typeof this.data !== "string") {
|
|
3289
|
-
throw new Error("RADSource: sidecar RADC chunks require a URL-backed RAD source.");
|
|
3290
|
-
}
|
|
3291
|
-
return await this._fetchArrayBuffer(resolveRADChunkUrl(this.url, chunk.filename), void 0, {
|
|
3292
|
-
signal: options.signal
|
|
3293
|
-
});
|
|
3294
|
-
}
|
|
3295
|
-
if (chunk.bytes === 0) {
|
|
3296
|
-
return new ArrayBuffer(0);
|
|
3297
|
-
}
|
|
3298
|
-
const byteOffset = metadata.chunksByteOffset + chunk.offset;
|
|
3299
|
-
if (typeof this.data !== "string") {
|
|
3300
|
-
return await this.data.slice(byteOffset, byteOffset + chunk.bytes).arrayBuffer();
|
|
3301
|
-
}
|
|
3302
|
-
return await this._fetchArrayBuffer(this.url, { offset: byteOffset, bytes: chunk.bytes }, { signal: options.signal });
|
|
3303
|
-
}
|
|
3304
|
-
/** Fetches and parses metadata for one RADC chunk. */
|
|
3305
|
-
async getChunkMetadata(chunkIndex, options = {}) {
|
|
3306
|
-
let chunkMetadataPromise = this._chunkMetadataPromises.get(chunkIndex);
|
|
3307
|
-
if (!chunkMetadataPromise) {
|
|
3308
|
-
chunkMetadataPromise = this.getChunk(chunkIndex, options).then((chunk) => parseRADChunkHeader(chunk));
|
|
3309
|
-
this._chunkMetadataPromises.set(chunkIndex, chunkMetadataPromise);
|
|
3310
|
-
}
|
|
3311
|
-
return await chunkMetadataPromise;
|
|
3312
|
-
}
|
|
3313
|
-
/** Fetches and decodes one RADC chunk into raw Gaussian splat arrays. */
|
|
3314
|
-
async getChunkSplats(chunkIndex, options = {}) {
|
|
3315
|
-
const metadata = await this.getMetadata();
|
|
3316
|
-
return parseRADChunkToGaussianSplats(await this.getChunk(chunkIndex, options), this._getChunkDecodeOptions(metadata, options));
|
|
3317
|
-
}
|
|
3318
|
-
/** Fetches and decodes one RADC chunk into a Mesh Arrow table. */
|
|
3319
|
-
async getChunkTable(chunkIndex, options = {}) {
|
|
3320
|
-
const metadata = await this.getMetadata();
|
|
3321
|
-
return parseRADChunk(await this.getChunk(chunkIndex, options), this._getChunkDecodeOptions(metadata, options));
|
|
3322
|
-
}
|
|
3323
|
-
/** Iterates decoded RADC chunks as Mesh Arrow tables. */
|
|
3324
|
-
async *getChunkTables(options = {}) {
|
|
3325
|
-
const metadata = await this.getMetadata();
|
|
3326
|
-
const startChunkIndex = options.startChunkIndex ?? 0;
|
|
3327
|
-
const maxChunks = options.maxChunks ?? Number.POSITIVE_INFINITY;
|
|
3328
|
-
const maxSplats = options.maxSplats ?? Number.POSITIVE_INFINITY;
|
|
3329
|
-
let chunkCount = 0;
|
|
3330
|
-
let splatCount = 0;
|
|
3331
|
-
if (options.pruneLoadedLoDParents) {
|
|
3332
|
-
const chunkIndices = getRADChunkTableIteratorIndices(metadata, startChunkIndex, maxChunks, maxSplats);
|
|
3333
|
-
const splatChunks = await this._getChunkSplatsConcurrently(chunkIndices, options);
|
|
3334
|
-
let loadedGlobalSplatEnd = 0;
|
|
3335
|
-
for (const splats of splatChunks) {
|
|
3336
|
-
chunkCount++;
|
|
3337
|
-
splatCount += splats.splatCount;
|
|
3338
|
-
const base = getRADChunkSplatBase(splats);
|
|
3339
|
-
loadedGlobalSplatEnd = Math.max(loadedGlobalSplatEnd, base + splats.splatCount);
|
|
3340
|
-
}
|
|
3341
|
-
for (const splats of splatChunks) {
|
|
3342
|
-
yield makeGaussianSplatsArrowTable(pruneLoadedLoDParents(splats, loadedGlobalSplatEnd));
|
|
3343
|
-
}
|
|
3344
|
-
return;
|
|
3345
|
-
}
|
|
3346
|
-
for (let chunkIndex = startChunkIndex; chunkIndex < metadata.chunks.length && chunkCount < maxChunks && splatCount < maxSplats; chunkIndex++) {
|
|
3347
|
-
const table = await this.getChunkTable(chunkIndex, options);
|
|
3348
|
-
chunkCount++;
|
|
3349
|
-
splatCount += table.data.numRows;
|
|
3350
|
-
yield table;
|
|
3351
|
-
}
|
|
3352
|
-
}
|
|
3353
|
-
/** Fetches and decodes RAD chunks with bounded concurrency while preserving chunk order. */
|
|
3354
|
-
async _getChunkSplatsConcurrently(chunkIndices, options) {
|
|
3355
|
-
const splatChunks = new Array(chunkIndices.length);
|
|
3356
|
-
const maxConcurrentChunkRequests = getRADMaxConcurrentChunkRequests(options.maxConcurrentChunkRequests);
|
|
3357
|
-
let nextResultIndex = 0;
|
|
3358
|
-
async function loadNextChunk(source) {
|
|
3359
|
-
while (nextResultIndex < chunkIndices.length) {
|
|
3360
|
-
const resultIndex = nextResultIndex++;
|
|
3361
|
-
const chunkIndex = chunkIndices[resultIndex];
|
|
3362
|
-
splatChunks[resultIndex] = await source.getChunkSplats(chunkIndex, options);
|
|
3363
|
-
}
|
|
3364
|
-
}
|
|
3365
|
-
const workerCount = Math.min(maxConcurrentChunkRequests, chunkIndices.length);
|
|
3366
|
-
await Promise.all(Array.from({ length: workerCount }, () => loadNextChunk(this)));
|
|
3367
|
-
return splatChunks;
|
|
3368
|
-
}
|
|
3369
|
-
/** Adds source-level RAD decode metadata to chunk decode options. */
|
|
3370
|
-
_getChunkDecodeOptions(metadata, options) {
|
|
3371
|
-
return {
|
|
3372
|
-
...options,
|
|
3373
|
-
radChunk: {
|
|
3374
|
-
splatEncoding: metadata.splatEncoding,
|
|
3375
|
-
...options.radChunk
|
|
3376
|
-
}
|
|
3377
|
-
};
|
|
3378
|
-
}
|
|
3379
|
-
/** Loads and parses the top-level RAD metadata. */
|
|
3380
|
-
async _loadMetadata() {
|
|
3381
|
-
var _a, _b;
|
|
3382
|
-
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;
|
|
3383
|
-
if (typeof this.data !== "string") {
|
|
3384
|
-
const byteLength = Math.min(this.data.size, Math.max(...headerByteLengths));
|
|
3385
|
-
const metadata = tryParseRADHeader(await this.data.slice(0, byteLength).arrayBuffer());
|
|
3386
|
-
if (metadata) {
|
|
3387
|
-
return metadata;
|
|
3388
|
-
}
|
|
3389
|
-
throw new Error("RADSource: Blob does not contain a complete RAD metadata header.");
|
|
3390
|
-
}
|
|
3391
|
-
for (const byteLength of headerByteLengths) {
|
|
3392
|
-
const metadata = tryParseRADHeader(await this._fetchArrayBuffer(this.url, { offset: 0, bytes: byteLength }));
|
|
3393
|
-
if (metadata) {
|
|
3394
|
-
return metadata;
|
|
3395
|
-
}
|
|
3396
|
-
}
|
|
3397
|
-
throw new Error("RADSource: failed to load a complete RAD metadata header.");
|
|
3398
|
-
}
|
|
3399
|
-
/** Returns a validated chunk table entry. */
|
|
3400
|
-
_getChunkRange(metadata, chunkIndex) {
|
|
3401
|
-
if (!Number.isInteger(chunkIndex) || chunkIndex < 0 || chunkIndex >= metadata.chunks.length) {
|
|
3402
|
-
throw new Error(`RADSource: chunk index ${chunkIndex} is outside 0-${metadata.chunks.length - 1}.`);
|
|
3403
|
-
}
|
|
3404
|
-
return metadata.chunks[chunkIndex];
|
|
3405
|
-
}
|
|
3406
|
-
/** Fetches a full or ranged ArrayBuffer while tolerating non-206 range fallbacks. */
|
|
3407
|
-
async _fetchArrayBuffer(url, range, options = {}) {
|
|
3408
|
-
const response = await this._fetchResponse(url, this._getRequestInit(range, options));
|
|
3409
|
-
if (!response.ok) {
|
|
3410
|
-
throw new Error(`RADSource: failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
|
3411
|
-
}
|
|
3412
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
3413
|
-
if (range && response.status !== 206 && arrayBuffer.byteLength >= range.offset + range.bytes) {
|
|
3414
|
-
return arrayBuffer.slice(range.offset, range.offset + range.bytes);
|
|
3415
|
-
}
|
|
3416
|
-
if (range && arrayBuffer.byteLength > range.bytes) {
|
|
3417
|
-
return arrayBuffer.slice(0, range.bytes);
|
|
3418
|
-
}
|
|
3419
|
-
return arrayBuffer;
|
|
3420
|
-
}
|
|
3421
|
-
/** Fetches through custom source fetch hooks or the injected core fetchFile helper. */
|
|
3422
|
-
async _fetchResponse(url, requestInit) {
|
|
3423
|
-
if (this._hasCustomFetch()) {
|
|
3424
|
-
return await this.fetch(url, requestInit);
|
|
3425
|
-
}
|
|
3426
|
-
return this.hasCoreApi ? await this.coreApi.fetchFile(url, requestInit) : await this.fetch(url, requestInit);
|
|
3427
|
-
}
|
|
3428
|
-
/** Returns true when source options supplied an explicit fetch override. */
|
|
3429
|
-
_hasCustomFetch() {
|
|
3430
|
-
var _a, _b, _c;
|
|
3431
|
-
return Boolean(((_b = (_a = this.loadOptions) == null ? void 0 : _a.core) == null ? void 0 : _b.fetch) || ((_c = this.loadOptions) == null ? void 0 : _c.fetch));
|
|
3432
|
-
}
|
|
3433
|
-
/** Builds request options for RAD fetches. */
|
|
3434
|
-
_getRequestInit(range, options = {}) {
|
|
3435
|
-
var _a, _b;
|
|
3436
|
-
const headers = new Headers((_a = this.options.rad) == null ? void 0 : _a.headers);
|
|
3437
|
-
if (range && range.bytes > 0) {
|
|
3438
|
-
headers.set("Range", `bytes=${range.offset}-${range.offset + range.bytes - 1}`);
|
|
3439
|
-
}
|
|
3440
|
-
return {
|
|
3441
|
-
headers,
|
|
3442
|
-
credentials: ((_b = this.options.rad) == null ? void 0 : _b.withCredentials) ? "include" : "same-origin",
|
|
3443
|
-
signal: options.signal
|
|
3444
|
-
};
|
|
3445
|
-
}
|
|
3446
|
-
};
|
|
2995
|
+
function createRADSource(data, options, coreApi) {
|
|
2996
|
+
return new RADSource(data, options, coreApi);
|
|
2997
|
+
}
|
|
3447
2998
|
function getRADChunkTableIteratorIndices(metadata, startChunkIndex, maxChunks, maxSplats) {
|
|
3448
2999
|
const chunkIndices = [];
|
|
3449
3000
|
let estimatedSplatCount = 0;
|
|
@@ -3526,4 +3077,300 @@ function resolveRADChunkUrl(rootUrl, chunkFilename) {
|
|
|
3526
3077
|
return `${rootDirectory}${chunkFilename}${suffix}`;
|
|
3527
3078
|
}
|
|
3528
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();
|
|
3529
3376
|
//# sourceMappingURL=index.cjs.map
|