@loaders.gl/splats 5.0.0-alpha.1 → 5.0.0-alpha.3
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 +14 -3
- package/dist/dist.dev.js +18326 -5805
- package/dist/dist.min.js +46 -7
- package/dist/index.cjs +1294 -180
- package/dist/index.cjs.map +3 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ksplat-loader-types.js +1 -1
- package/dist/lib/parse-rad-chunk.js +3 -3
- package/dist/lib/parse-rad-chunk.js.map +1 -1
- package/dist/lib/parse-rad.d.ts +23 -7
- package/dist/lib/parse-rad.d.ts.map +1 -1
- package/dist/lib/parse-rad.js +10 -135
- package/dist/lib/parse-rad.js.map +1 -1
- package/dist/lib/parse-spz.js +3 -3
- package/dist/lib/parse-spz.js.map +1 -1
- package/dist/rad-loader-types.js +1 -1
- package/dist/rad-metadata.schema.json +133 -0
- package/dist/rad-source-loader.js +1 -1
- package/dist/rad-zod-schema.cjs +81 -0
- package/dist/rad-zod-schema.cjs.map +6 -0
- package/dist/rad-zod-schema.d.ts +88 -0
- package/dist/rad-zod-schema.d.ts.map +1 -0
- package/dist/rad-zod-schema.js +70 -0
- package/dist/rad-zod-schema.js.map +1 -0
- package/dist/radc-metadata.schema.json +112 -0
- package/dist/splat-loader-types.js +1 -1
- package/dist/spz-loader-types.js +1 -1
- package/package.json +17 -8
- package/src/index.ts +2 -0
- package/src/lib/parse-rad-chunk.ts +3 -3
- package/src/lib/parse-rad.ts +46 -167
- package/src/lib/parse-spz.ts +3 -3
- package/src/rad-zod-schema.ts +83 -0
package/dist/index.cjs
CHANGED
|
@@ -5,8 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
|
|
8
|
+
var __esm = (fn, res, err) => function __init() {
|
|
9
|
+
if (err) throw err[0];
|
|
10
|
+
try {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw err = [e], e;
|
|
14
|
+
}
|
|
10
15
|
};
|
|
11
16
|
var __export = (target, all) => {
|
|
12
17
|
for (var name in all)
|
|
@@ -83,12 +88,12 @@ function convertColorByteToSphericalHarmonicDc(colorByte) {
|
|
|
83
88
|
function convertAlphaByteToLinearOpacity(alphaByte) {
|
|
84
89
|
return Math.min(Math.max(alphaByte / 255, 0), 1);
|
|
85
90
|
}
|
|
86
|
-
function normalizeQuaternion(w, x, y,
|
|
87
|
-
const length = Math.hypot(w, x, y,
|
|
91
|
+
function normalizeQuaternion(w, x, y, z2) {
|
|
92
|
+
const length = Math.hypot(w, x, y, z2);
|
|
88
93
|
if (!Number.isFinite(length) || length <= Number.EPSILON) {
|
|
89
94
|
return [1, 0, 0, 0];
|
|
90
95
|
}
|
|
91
|
-
return [w / length, x / length, y / length,
|
|
96
|
+
return [w / length, x / length, y / length, z2 / length];
|
|
92
97
|
}
|
|
93
98
|
function decodeQuaternionByte(byte) {
|
|
94
99
|
return (byte - 128) / 128;
|
|
@@ -270,11 +275,11 @@ function parseSPLATToGaussianSplats(data) {
|
|
|
270
275
|
colors[positionOffset + 1] = dataView.getUint8(byteOffset + 25);
|
|
271
276
|
colors[positionOffset + 2] = dataView.getUint8(byteOffset + 26);
|
|
272
277
|
opacities[splatIndex] = convertAlphaByteToLinearOpacity(dataView.getUint8(byteOffset + 27));
|
|
273
|
-
const [w, x, y,
|
|
278
|
+
const [w, x, y, z2] = normalizeQuaternion(decodeQuaternionByte(dataView.getUint8(byteOffset + 28)), decodeQuaternionByte(dataView.getUint8(byteOffset + 29)), decodeQuaternionByte(dataView.getUint8(byteOffset + 30)), decodeQuaternionByte(dataView.getUint8(byteOffset + 31)));
|
|
274
279
|
rotations[rotationOffset + 0] = w;
|
|
275
280
|
rotations[rotationOffset + 1] = x;
|
|
276
281
|
rotations[rotationOffset + 2] = y;
|
|
277
|
-
rotations[rotationOffset + 3] =
|
|
282
|
+
rotations[rotationOffset + 3] = z2;
|
|
278
283
|
}
|
|
279
284
|
return {
|
|
280
285
|
format: "splat",
|
|
@@ -331,7 +336,7 @@ var init_splat_loader_types = __esm({
|
|
|
331
336
|
"dist/splat-loader-types.js"() {
|
|
332
337
|
"use strict";
|
|
333
338
|
init_splats_format();
|
|
334
|
-
VERSION = true ? "5.0.0-alpha.
|
|
339
|
+
VERSION = true ? "5.0.0-alpha.3" : "latest";
|
|
335
340
|
SPLATLoader = {
|
|
336
341
|
dataType: null,
|
|
337
342
|
batchType: null,
|
|
@@ -407,11 +412,11 @@ function decodeKSPLATSplat(data, header, section, localSplatIndex, outputSplatIn
|
|
|
407
412
|
scales[positionOffset + 0] = readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 0, header.compressionLevel);
|
|
408
413
|
scales[positionOffset + 1] = readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 1, header.compressionLevel);
|
|
409
414
|
scales[positionOffset + 2] = readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 2, header.compressionLevel);
|
|
410
|
-
const [w, x, y,
|
|
415
|
+
const [w, x, y, z2] = normalizeQuaternion(readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 3, header.compressionLevel), readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 4, header.compressionLevel), readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 5, header.compressionLevel), readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 6, header.compressionLevel));
|
|
411
416
|
rotations[rotationOffset + 0] = w;
|
|
412
417
|
rotations[rotationOffset + 1] = x;
|
|
413
418
|
rotations[rotationOffset + 2] = y;
|
|
414
|
-
rotations[rotationOffset + 3] =
|
|
419
|
+
rotations[rotationOffset + 3] = z2;
|
|
415
420
|
const colorBase = splatBase + layout.colorOffsetBytes;
|
|
416
421
|
const colorView = new Uint8Array(data, colorBase, 4);
|
|
417
422
|
colors[positionOffset + 0] = colorView[0];
|
|
@@ -656,7 +661,7 @@ var init_ksplat_loader_types = __esm({
|
|
|
656
661
|
"dist/ksplat-loader-types.js"() {
|
|
657
662
|
"use strict";
|
|
658
663
|
init_splats_format();
|
|
659
|
-
VERSION2 = true ? "5.0.0-alpha.
|
|
664
|
+
VERSION2 = true ? "5.0.0-alpha.3" : "latest";
|
|
660
665
|
KSPLATLoader = {
|
|
661
666
|
dataType: null,
|
|
662
667
|
batchType: null,
|
|
@@ -672,6 +677,1093 @@ var init_ksplat_loader_types = __esm({
|
|
|
672
677
|
}
|
|
673
678
|
});
|
|
674
679
|
|
|
680
|
+
// ../loader-utils/src/lib/log-utils/log.ts
|
|
681
|
+
function createLog() {
|
|
682
|
+
const log2 = new import_log.Log({ id: "loaders.gl" });
|
|
683
|
+
globalThis.loaders ||= {};
|
|
684
|
+
globalThis.loaders.log = log2;
|
|
685
|
+
globalThis.loaders.version = version;
|
|
686
|
+
globalThis.probe ||= {};
|
|
687
|
+
globalThis.probe.loaders = log2;
|
|
688
|
+
return log2;
|
|
689
|
+
}
|
|
690
|
+
var import_log, VERSION3, version, log;
|
|
691
|
+
var init_log = __esm({
|
|
692
|
+
"../loader-utils/src/lib/log-utils/log.ts"() {
|
|
693
|
+
"use strict";
|
|
694
|
+
import_log = require("@probe.gl/log");
|
|
695
|
+
VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
696
|
+
version = VERSION3[0] >= "0" && VERSION3[0] <= "9" ? `v${VERSION3}` : "";
|
|
697
|
+
log = createLog();
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
// ../loader-utils/src/lib/javascript-utils/is-type.ts
|
|
702
|
+
var isObject, isPureObject, isSharedArrayBuffer;
|
|
703
|
+
var init_is_type = __esm({
|
|
704
|
+
"../loader-utils/src/lib/javascript-utils/is-type.ts"() {
|
|
705
|
+
"use strict";
|
|
706
|
+
isObject = (value) => value !== null && typeof value === "object";
|
|
707
|
+
isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
|
|
708
|
+
isSharedArrayBuffer = (value) => typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
// ../loader-utils/src/lib/option-utils/merge-options.ts
|
|
713
|
+
function mergeOptions(baseOptions, newOptions) {
|
|
714
|
+
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
715
|
+
}
|
|
716
|
+
function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
|
|
717
|
+
if (level > 3) {
|
|
718
|
+
return newOptions;
|
|
719
|
+
}
|
|
720
|
+
const options = { ...baseOptions };
|
|
721
|
+
for (const [key, newValue] of Object.entries(newOptions)) {
|
|
722
|
+
if (isPureObject(newValue)) {
|
|
723
|
+
options[key] = mergeOptionsRecursively(
|
|
724
|
+
options[key] || {},
|
|
725
|
+
newOptions[key],
|
|
726
|
+
level + 1
|
|
727
|
+
);
|
|
728
|
+
} else {
|
|
729
|
+
options[key] = newOptions[key];
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
return options;
|
|
733
|
+
}
|
|
734
|
+
var init_merge_options = __esm({
|
|
735
|
+
"../loader-utils/src/lib/option-utils/merge-options.ts"() {
|
|
736
|
+
"use strict";
|
|
737
|
+
init_is_type();
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
742
|
+
function registerJSModules(modules) {
|
|
743
|
+
globalThis.loaders ||= {};
|
|
744
|
+
globalThis.loaders.modules ||= {};
|
|
745
|
+
Object.assign(globalThis.loaders.modules, modules);
|
|
746
|
+
}
|
|
747
|
+
function getJSModule(name, caller) {
|
|
748
|
+
var _a, _b;
|
|
749
|
+
const module2 = (_b = (_a = globalThis.loaders) == null ? void 0 : _a.modules) == null ? void 0 : _b[name];
|
|
750
|
+
if (!module2) {
|
|
751
|
+
throw new Error(`${caller}: ${name} library not installed`);
|
|
752
|
+
}
|
|
753
|
+
return module2;
|
|
754
|
+
}
|
|
755
|
+
function getJSModuleOrNull(name) {
|
|
756
|
+
var _a, _b;
|
|
757
|
+
const module2 = (_b = (_a = globalThis.loaders) == null ? void 0 : _a.modules) == null ? void 0 : _b[name];
|
|
758
|
+
return module2 || null;
|
|
759
|
+
}
|
|
760
|
+
var init_js_module_utils = __esm({
|
|
761
|
+
"../loader-utils/src/lib/module-utils/js-module-utils.ts"() {
|
|
762
|
+
"use strict";
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
|
|
767
|
+
function concatenateArrayBuffers(...sources) {
|
|
768
|
+
return concatenateArrayBuffersFromArray(sources);
|
|
769
|
+
}
|
|
770
|
+
function concatenateArrayBuffersFromArray(sources) {
|
|
771
|
+
const sourceArrays = sources.map(
|
|
772
|
+
(source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2
|
|
773
|
+
);
|
|
774
|
+
const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);
|
|
775
|
+
const result = new Uint8Array(byteLength);
|
|
776
|
+
let offset = 0;
|
|
777
|
+
for (const sourceArray of sourceArrays) {
|
|
778
|
+
result.set(sourceArray, offset);
|
|
779
|
+
offset += sourceArray.byteLength;
|
|
780
|
+
}
|
|
781
|
+
return result.buffer;
|
|
782
|
+
}
|
|
783
|
+
var init_array_buffer_utils = __esm({
|
|
784
|
+
"../loader-utils/src/lib/binary-utils/array-buffer-utils.ts"() {
|
|
785
|
+
"use strict";
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
// ../loader-utils/src/lib/iterators/async-iteration.ts
|
|
790
|
+
async function concatenateArrayBuffersAsync(asyncIterator) {
|
|
791
|
+
const arrayBuffers = [];
|
|
792
|
+
for await (const chunk of asyncIterator) {
|
|
793
|
+
arrayBuffers.push(copyToArrayBuffer(chunk));
|
|
794
|
+
}
|
|
795
|
+
return concatenateArrayBuffers(...arrayBuffers);
|
|
796
|
+
}
|
|
797
|
+
function copyToArrayBuffer(chunk) {
|
|
798
|
+
if (chunk instanceof ArrayBuffer) {
|
|
799
|
+
return chunk;
|
|
800
|
+
}
|
|
801
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
802
|
+
const { buffer, byteOffset, byteLength } = chunk;
|
|
803
|
+
return copyFromBuffer(buffer, byteOffset, byteLength);
|
|
804
|
+
}
|
|
805
|
+
return copyFromBuffer(chunk);
|
|
806
|
+
}
|
|
807
|
+
function copyFromBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
808
|
+
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
809
|
+
const copy = new Uint8Array(view.length);
|
|
810
|
+
copy.set(view);
|
|
811
|
+
return copy.buffer;
|
|
812
|
+
}
|
|
813
|
+
var init_async_iteration = __esm({
|
|
814
|
+
"../loader-utils/src/lib/iterators/async-iteration.ts"() {
|
|
815
|
+
"use strict";
|
|
816
|
+
init_array_buffer_utils();
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
// ../loader-utils/src/lib/request-utils/request-credentials.ts
|
|
821
|
+
function createAuthenticatedFetch(options) {
|
|
822
|
+
const baseFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
|
|
823
|
+
if (!options.credentials.length) return baseFetch;
|
|
824
|
+
const existingMetadata = baseFetch[AUTHENTICATED_FETCH];
|
|
825
|
+
if (existingMetadata === options.credentials) return baseFetch;
|
|
826
|
+
const authenticatedFetch = async (url, requestOptions = {}) => {
|
|
827
|
+
var _a, _b, _c;
|
|
828
|
+
const resolvedURL = parseHTTPURL(url);
|
|
829
|
+
if (!resolvedURL) return baseFetch(url, requestOptions);
|
|
830
|
+
const authorization = await authorizeRequest(resolvedURL, requestOptions, options.credentials);
|
|
831
|
+
const response = await baseFetch(authorization.url, authorization.options);
|
|
832
|
+
const refreshableCredentials = authorization.credentials.filter(
|
|
833
|
+
({ credential }) => typeof credential.token === "function" && credential.refreshStatusCodes.includes(response.status)
|
|
834
|
+
);
|
|
835
|
+
if (!refreshableCredentials.length || !isReplayableRequest(requestOptions)) return response;
|
|
836
|
+
if ((_a = requestOptions.signal) == null ? void 0 : _a.aborted) throw createAbortError();
|
|
837
|
+
const refreshedTokens = /* @__PURE__ */ new Map();
|
|
838
|
+
await Promise.all(
|
|
839
|
+
refreshableCredentials.map(async ({ credential }) => {
|
|
840
|
+
const token = await refreshCredential(credential, url, response);
|
|
841
|
+
if (token) refreshedTokens.set(credential, token);
|
|
842
|
+
})
|
|
843
|
+
);
|
|
844
|
+
if (!refreshedTokens.size) return response;
|
|
845
|
+
await ((_b = response.body) == null ? void 0 : _b.cancel().catch(() => {
|
|
846
|
+
}));
|
|
847
|
+
if ((_c = requestOptions.signal) == null ? void 0 : _c.aborted) throw createAbortError();
|
|
848
|
+
const replayAuthorization = await authorizeRequest(
|
|
849
|
+
resolvedURL,
|
|
850
|
+
requestOptions,
|
|
851
|
+
options.credentials,
|
|
852
|
+
refreshedTokens,
|
|
853
|
+
authorization.credentials
|
|
854
|
+
);
|
|
855
|
+
return baseFetch(replayAuthorization.url, replayAuthorization.options);
|
|
856
|
+
};
|
|
857
|
+
Object.defineProperty(authenticatedFetch, AUTHENTICATED_FETCH, {
|
|
858
|
+
value: options.credentials
|
|
859
|
+
});
|
|
860
|
+
return authenticatedFetch;
|
|
861
|
+
}
|
|
862
|
+
async function authorizeRequest(sourceURL, requestOptions, credentials, tokenOverrides = /* @__PURE__ */ new Map(), previousCredentials = []) {
|
|
863
|
+
const url = new URL(sourceURL);
|
|
864
|
+
const headers = new Headers(requestOptions.headers);
|
|
865
|
+
const resolvedCredentials = [];
|
|
866
|
+
const previousTokens = new Map(
|
|
867
|
+
previousCredentials.map(({ credential, token }) => [credential, token])
|
|
868
|
+
);
|
|
869
|
+
for (const credential of credentials) {
|
|
870
|
+
if (!credential.origins.includes(url.origin)) continue;
|
|
871
|
+
const overrideToken = tokenOverrides.get(credential);
|
|
872
|
+
const previousToken = previousTokens.get(credential);
|
|
873
|
+
const ownsQueryParameter = credential.type === "query-parameter" && previousToken !== void 0;
|
|
874
|
+
const ownsHeader = credential.type === "header" && previousToken !== void 0;
|
|
875
|
+
if (credential.type === "query-parameter" && url.searchParams.has(credential.name) && !ownsQueryParameter || credential.type === "header" && headers.has(credential.name) && !ownsHeader) {
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
const token = overrideToken ?? previousToken ?? await resolveToken(credential.token, { url: sourceURL.toString(), reason: "request" });
|
|
879
|
+
if (!token) continue;
|
|
880
|
+
if (credential.type === "query-parameter") {
|
|
881
|
+
url.searchParams.set(credential.name, token);
|
|
882
|
+
} else {
|
|
883
|
+
headers.set(credential.name, `${credential.prefix || ""}${token}`);
|
|
884
|
+
}
|
|
885
|
+
resolvedCredentials.push({ credential, token });
|
|
886
|
+
}
|
|
887
|
+
return {
|
|
888
|
+
url: url.toString(),
|
|
889
|
+
options: { ...requestOptions, headers },
|
|
890
|
+
credentials: resolvedCredentials
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
async function refreshCredential(credential, url, response) {
|
|
894
|
+
const existingPromise = refreshPromises.get(credential);
|
|
895
|
+
if (existingPromise) return existingPromise;
|
|
896
|
+
const tokenProvider = credential.token;
|
|
897
|
+
const promise = Promise.resolve(
|
|
898
|
+
tokenProvider({
|
|
899
|
+
url,
|
|
900
|
+
reason: "refresh",
|
|
901
|
+
response: { status: response.status, headers: response.headers }
|
|
902
|
+
})
|
|
903
|
+
).finally(() => refreshPromises.delete(credential));
|
|
904
|
+
refreshPromises.set(credential, promise);
|
|
905
|
+
return promise;
|
|
906
|
+
}
|
|
907
|
+
async function resolveToken(token, context) {
|
|
908
|
+
return typeof token === "function" ? token(context) : token;
|
|
909
|
+
}
|
|
910
|
+
function parseHTTPURL(url) {
|
|
911
|
+
try {
|
|
912
|
+
const parsedURL = new URL(url);
|
|
913
|
+
return ["http:", "https:"].includes(parsedURL.protocol) ? parsedURL : null;
|
|
914
|
+
} catch {
|
|
915
|
+
return null;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
function isReplayableRequest(options) {
|
|
919
|
+
const method = (options.method || "GET").toUpperCase();
|
|
920
|
+
if (!["GET", "HEAD", "OPTIONS", "PUT", "DELETE"].includes(method)) return false;
|
|
921
|
+
return !(options.body && typeof ReadableStream !== "undefined" && options.body instanceof ReadableStream);
|
|
922
|
+
}
|
|
923
|
+
function createAbortError() {
|
|
924
|
+
return new DOMException("The operation was aborted.", "AbortError");
|
|
925
|
+
}
|
|
926
|
+
var AUTHENTICATED_FETCH, refreshPromises;
|
|
927
|
+
var init_request_credentials = __esm({
|
|
928
|
+
"../loader-utils/src/lib/request-utils/request-credentials.ts"() {
|
|
929
|
+
"use strict";
|
|
930
|
+
AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
|
|
931
|
+
refreshPromises = /* @__PURE__ */ new WeakMap();
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
// ../loader-utils/src/lib/path-utils/file-aliases.ts
|
|
936
|
+
function resolvePath(filename) {
|
|
937
|
+
for (const alias in fileAliases) {
|
|
938
|
+
if (filename.startsWith(alias)) {
|
|
939
|
+
const replacement = fileAliases[alias];
|
|
940
|
+
filename = filename.replace(alias, replacement);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
if (!filename.startsWith("http://") && !filename.startsWith("https://")) {
|
|
944
|
+
filename = `${pathPrefix}${filename}`;
|
|
945
|
+
}
|
|
946
|
+
return filename;
|
|
947
|
+
}
|
|
948
|
+
var pathPrefix, fileAliases;
|
|
949
|
+
var init_file_aliases = __esm({
|
|
950
|
+
"../loader-utils/src/lib/path-utils/file-aliases.ts"() {
|
|
951
|
+
"use strict";
|
|
952
|
+
pathPrefix = "";
|
|
953
|
+
fileAliases = {};
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
// ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
|
|
958
|
+
function ensureArrayBuffer(bufferSource) {
|
|
959
|
+
if (bufferSource instanceof ArrayBuffer) {
|
|
960
|
+
return bufferSource;
|
|
961
|
+
}
|
|
962
|
+
if (isSharedArrayBuffer(bufferSource)) {
|
|
963
|
+
return copyToArrayBuffer2(bufferSource);
|
|
964
|
+
}
|
|
965
|
+
const { buffer, byteOffset, byteLength } = bufferSource;
|
|
966
|
+
if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
|
|
967
|
+
return buffer;
|
|
968
|
+
}
|
|
969
|
+
return copyToArrayBuffer2(buffer, byteOffset, byteLength);
|
|
970
|
+
}
|
|
971
|
+
function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
972
|
+
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
973
|
+
const copy = new Uint8Array(view.length);
|
|
974
|
+
copy.set(view);
|
|
975
|
+
return copy.buffer;
|
|
976
|
+
}
|
|
977
|
+
var init_memory_conversion_utils = __esm({
|
|
978
|
+
"../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts"() {
|
|
979
|
+
"use strict";
|
|
980
|
+
init_is_type();
|
|
981
|
+
}
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
// ../loader-utils/src/lib/sources/data-source.ts
|
|
985
|
+
function getFetchFunction(options) {
|
|
986
|
+
var _a, _b;
|
|
987
|
+
const fetchOption = (options == null ? void 0 : options.fetch) ?? ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.fetch);
|
|
988
|
+
let fetchFunction;
|
|
989
|
+
if (typeof fetchOption === "function") {
|
|
990
|
+
fetchFunction = (url, fetchOptions) => fetchOption(url, fetchOptions);
|
|
991
|
+
} else if (fetchOption) {
|
|
992
|
+
fetchFunction = (url, requestOptions) => fetch(url, mergeFetchOptions(fetchOption, requestOptions));
|
|
993
|
+
} else {
|
|
994
|
+
fetchFunction = (url, requestOptions) => fetch(url, requestOptions);
|
|
995
|
+
}
|
|
996
|
+
return createAuthenticatedFetch({
|
|
997
|
+
fetch: fetchFunction,
|
|
998
|
+
credentials: ((_b = options == null ? void 0 : options.core) == null ? void 0 : _b.credentials) || []
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
function mergeFetchOptions(fetchOptions, requestOptions) {
|
|
1002
|
+
const mergedOptions = { ...fetchOptions, ...requestOptions };
|
|
1003
|
+
if (fetchOptions.headers || (requestOptions == null ? void 0 : requestOptions.headers)) {
|
|
1004
|
+
mergedOptions.headers = mergeHeaders(fetchOptions.headers, requestOptions == null ? void 0 : requestOptions.headers);
|
|
1005
|
+
}
|
|
1006
|
+
return mergedOptions;
|
|
1007
|
+
}
|
|
1008
|
+
function mergeHeaders(defaultHeaders, requestHeaders) {
|
|
1009
|
+
const headers = new Headers(defaultHeaders);
|
|
1010
|
+
if (requestHeaders) {
|
|
1011
|
+
new Headers(requestHeaders).forEach((value, key) => headers.set(key, value));
|
|
1012
|
+
}
|
|
1013
|
+
return headers;
|
|
1014
|
+
}
|
|
1015
|
+
function normalizeDirectLoaderOptions(options) {
|
|
1016
|
+
const loadOptions = { ...options };
|
|
1017
|
+
if (options == null ? void 0 : options.core) {
|
|
1018
|
+
loadOptions.core = { ...options.core };
|
|
1019
|
+
}
|
|
1020
|
+
const topLevelBaseUri = typeof loadOptions.baseUri === "string" ? loadOptions.baseUri : void 0;
|
|
1021
|
+
const topLevelBaseUrl = typeof loadOptions.baseUrl === "string" ? loadOptions.baseUrl : void 0;
|
|
1022
|
+
if (topLevelBaseUri !== void 0 || topLevelBaseUrl !== void 0) {
|
|
1023
|
+
loadOptions.core ||= {};
|
|
1024
|
+
if (loadOptions.core.baseUrl === void 0) {
|
|
1025
|
+
loadOptions.core.baseUrl = topLevelBaseUrl ?? topLevelBaseUri;
|
|
1026
|
+
}
|
|
1027
|
+
delete loadOptions.baseUri;
|
|
1028
|
+
delete loadOptions.baseUrl;
|
|
1029
|
+
}
|
|
1030
|
+
return loadOptions;
|
|
1031
|
+
}
|
|
1032
|
+
function normalizeError(error, message) {
|
|
1033
|
+
if (error instanceof Error) {
|
|
1034
|
+
return error;
|
|
1035
|
+
}
|
|
1036
|
+
if (typeof error === "string") {
|
|
1037
|
+
return new Error(error);
|
|
1038
|
+
}
|
|
1039
|
+
return new Error(message);
|
|
1040
|
+
}
|
|
1041
|
+
function unavailableCoreApiMethod(methodName) {
|
|
1042
|
+
return () => {
|
|
1043
|
+
throw new Error(
|
|
1044
|
+
`CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.createDataSource().`
|
|
1045
|
+
);
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
var UNAVAILABLE_CORE_API, DataSource;
|
|
1049
|
+
var init_data_source = __esm({
|
|
1050
|
+
"../loader-utils/src/lib/sources/data-source.ts"() {
|
|
1051
|
+
"use strict";
|
|
1052
|
+
init_merge_options();
|
|
1053
|
+
init_file_aliases();
|
|
1054
|
+
init_log();
|
|
1055
|
+
init_request_credentials();
|
|
1056
|
+
UNAVAILABLE_CORE_API = {
|
|
1057
|
+
fetchFile: unavailableCoreApiMethod("fetchFile"),
|
|
1058
|
+
parse: unavailableCoreApiMethod("parse"),
|
|
1059
|
+
parseFile: unavailableCoreApiMethod("parseFile"),
|
|
1060
|
+
parseSync: unavailableCoreApiMethod("parseSync"),
|
|
1061
|
+
parseInBatches: unavailableCoreApiMethod("parseInBatches"),
|
|
1062
|
+
load: unavailableCoreApiMethod("load"),
|
|
1063
|
+
loadInBatches: unavailableCoreApiMethod("loadInBatches")
|
|
1064
|
+
};
|
|
1065
|
+
DataSource = class _DataSource {
|
|
1066
|
+
static defaultOptions = {
|
|
1067
|
+
core: {
|
|
1068
|
+
type: "auto",
|
|
1069
|
+
attributions: [],
|
|
1070
|
+
loadOptions: {},
|
|
1071
|
+
loaders: [],
|
|
1072
|
+
onError: void 0
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
optionsType;
|
|
1076
|
+
options;
|
|
1077
|
+
data;
|
|
1078
|
+
url;
|
|
1079
|
+
/** The actual load options, if calling a loaders.gl loader */
|
|
1080
|
+
loadOptions;
|
|
1081
|
+
/** A resolved fetch function extracted from loadOptions prop */
|
|
1082
|
+
fetch;
|
|
1083
|
+
/** Shared source-level runtime hooks, when supplied by the source factory. */
|
|
1084
|
+
coreApi;
|
|
1085
|
+
/** Whether a real CoreAPI instance was injected by the integration layer. */
|
|
1086
|
+
hasCoreApi;
|
|
1087
|
+
_needsRefresh = true;
|
|
1088
|
+
constructor(data, options, defaultOptions, coreApi) {
|
|
1089
|
+
var _a;
|
|
1090
|
+
if (defaultOptions) {
|
|
1091
|
+
this.options = mergeOptions({ ...defaultOptions, core: _DataSource.defaultOptions }, options);
|
|
1092
|
+
} else {
|
|
1093
|
+
this.options = { ...options };
|
|
1094
|
+
}
|
|
1095
|
+
this.data = data;
|
|
1096
|
+
this.url = typeof data === "string" ? resolvePath(data) : "";
|
|
1097
|
+
const loadOptions = normalizeDirectLoaderOptions((_a = this.options.core) == null ? void 0 : _a.loadOptions);
|
|
1098
|
+
this.loadOptions = loadOptions;
|
|
1099
|
+
const fetch2 = getFetchFunction(loadOptions);
|
|
1100
|
+
this.coreApi = coreApi || UNAVAILABLE_CORE_API;
|
|
1101
|
+
this.hasCoreApi = Boolean(coreApi);
|
|
1102
|
+
this.fetch = fetch2;
|
|
1103
|
+
}
|
|
1104
|
+
setProps(options) {
|
|
1105
|
+
this.options = Object.assign(this.options, options);
|
|
1106
|
+
this.setNeedsRefresh();
|
|
1107
|
+
}
|
|
1108
|
+
/** Mark this data source as needing a refresh (redraw) */
|
|
1109
|
+
setNeedsRefresh() {
|
|
1110
|
+
this._needsRefresh = true;
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Does this data source need refreshing?
|
|
1114
|
+
* @note The specifics of the refresh mechanism depends on type of data source
|
|
1115
|
+
*/
|
|
1116
|
+
getNeedsRefresh(clear = true) {
|
|
1117
|
+
const needsRefresh = this._needsRefresh;
|
|
1118
|
+
if (clear) {
|
|
1119
|
+
this._needsRefresh = false;
|
|
1120
|
+
}
|
|
1121
|
+
return needsRefresh;
|
|
1122
|
+
}
|
|
1123
|
+
/** Reports a source-level failure through the configured callback or the shared logger. */
|
|
1124
|
+
reportError(error, message) {
|
|
1125
|
+
var _a;
|
|
1126
|
+
const normalizedError = normalizeError(error, message);
|
|
1127
|
+
const callback = (_a = this.options.core) == null ? void 0 : _a.onError;
|
|
1128
|
+
if (callback) {
|
|
1129
|
+
callback(normalizedError, this);
|
|
1130
|
+
} else {
|
|
1131
|
+
log.warn(`${this.constructor.name}: ${normalizedError.message}`)();
|
|
1132
|
+
}
|
|
1133
|
+
return normalizedError;
|
|
1134
|
+
}
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
// ../loader-utils/src/index.ts
|
|
1140
|
+
var init_src = __esm({
|
|
1141
|
+
"../loader-utils/src/index.ts"() {
|
|
1142
|
+
"use strict";
|
|
1143
|
+
init_js_module_utils();
|
|
1144
|
+
init_js_module_utils();
|
|
1145
|
+
init_async_iteration();
|
|
1146
|
+
init_memory_conversion_utils();
|
|
1147
|
+
init_data_source();
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
// ../compression/src/lib/compression.ts
|
|
1152
|
+
var CompressionTransform, Compressor, Decompressor, Compression;
|
|
1153
|
+
var init_compression = __esm({
|
|
1154
|
+
"../compression/src/lib/compression.ts"() {
|
|
1155
|
+
"use strict";
|
|
1156
|
+
init_src();
|
|
1157
|
+
CompressionTransform = class {
|
|
1158
|
+
/** Preloads any dynamic libraries. May enable sync functions */
|
|
1159
|
+
async preload(modules = {}) {
|
|
1160
|
+
registerJSModules(modules);
|
|
1161
|
+
return void 0;
|
|
1162
|
+
}
|
|
1163
|
+
// HELPERS
|
|
1164
|
+
concatenate(asyncIterator) {
|
|
1165
|
+
return concatenateArrayBuffersAsync(asyncIterator);
|
|
1166
|
+
}
|
|
1167
|
+
improveError(error) {
|
|
1168
|
+
if (!error.message.includes(this.name)) {
|
|
1169
|
+
error.message = `${this.name} ${error.message}`;
|
|
1170
|
+
}
|
|
1171
|
+
return error;
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
Compressor = class extends CompressionTransform {
|
|
1175
|
+
constructor(options) {
|
|
1176
|
+
super();
|
|
1177
|
+
this.compressBatches = this.compressBatches.bind(this);
|
|
1178
|
+
}
|
|
1179
|
+
/** Asynchronously compresses data. */
|
|
1180
|
+
async compress(input) {
|
|
1181
|
+
await this.preload();
|
|
1182
|
+
return this.compressSync(input);
|
|
1183
|
+
}
|
|
1184
|
+
/** Synchronously compresses data. */
|
|
1185
|
+
compressSync(input) {
|
|
1186
|
+
throw new Error(`${this.name}: sync compression not supported`);
|
|
1187
|
+
}
|
|
1188
|
+
/** Compresses batches. */
|
|
1189
|
+
async *compressBatches(asyncIterator) {
|
|
1190
|
+
const input = await this.concatenate(asyncIterator);
|
|
1191
|
+
yield this.compress(input);
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
Decompressor = class extends CompressionTransform {
|
|
1195
|
+
constructor(options) {
|
|
1196
|
+
super();
|
|
1197
|
+
this.decompressBatches = this.decompressBatches.bind(this);
|
|
1198
|
+
}
|
|
1199
|
+
/** Asynchronously decompresses data. */
|
|
1200
|
+
async decompress(input, size) {
|
|
1201
|
+
await this.preload();
|
|
1202
|
+
return this.decompressSync(input, size);
|
|
1203
|
+
}
|
|
1204
|
+
/** Synchronously decompresses data. */
|
|
1205
|
+
decompressSync(input, size) {
|
|
1206
|
+
throw new Error(`${this.name}: sync decompression not supported`);
|
|
1207
|
+
}
|
|
1208
|
+
/** Decompresses batches. */
|
|
1209
|
+
async *decompressBatches(asyncIterator) {
|
|
1210
|
+
const input = await this.concatenate(asyncIterator);
|
|
1211
|
+
yield this.decompress(input);
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
Compression = class extends Compressor {
|
|
1215
|
+
constructor(options) {
|
|
1216
|
+
super(options);
|
|
1217
|
+
this.decompressBatches = this.decompressBatches.bind(this);
|
|
1218
|
+
}
|
|
1219
|
+
/** Asynchronously decompresses data. */
|
|
1220
|
+
async decompress(input, size) {
|
|
1221
|
+
await this.preload();
|
|
1222
|
+
return this.decompressSync(input, size);
|
|
1223
|
+
}
|
|
1224
|
+
/** Synchronously decompresses data. */
|
|
1225
|
+
decompressSync(input, size) {
|
|
1226
|
+
throw new Error(`${this.name}: sync decompression not supported`);
|
|
1227
|
+
}
|
|
1228
|
+
/** Decompresses batches. */
|
|
1229
|
+
async *decompressBatches(asyncIterator) {
|
|
1230
|
+
const input = await this.concatenate(asyncIterator);
|
|
1231
|
+
yield this.decompress(input);
|
|
1232
|
+
}
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
// ../compression/src/lib/compression-stream.ts
|
|
1238
|
+
async function compressWithNativeCompressionStream(input, format) {
|
|
1239
|
+
const outputBatches = compressBatchesWithNativeCompressionStream([input], format);
|
|
1240
|
+
return outputBatches ? await concatenateBatches(outputBatches) : null;
|
|
1241
|
+
}
|
|
1242
|
+
function compressBatchesWithNativeCompressionStream(inputBatches, format) {
|
|
1243
|
+
const compressionStream = createNativeCompressionStream(format);
|
|
1244
|
+
return compressionStream ? transformBatches(inputBatches, compressionStream) : null;
|
|
1245
|
+
}
|
|
1246
|
+
function createNativeCompressionStream(format) {
|
|
1247
|
+
if (typeof globalThis.CompressionStream === "undefined") {
|
|
1248
|
+
return null;
|
|
1249
|
+
}
|
|
1250
|
+
try {
|
|
1251
|
+
const CompressionStreamConstructor = globalThis.CompressionStream;
|
|
1252
|
+
return new CompressionStreamConstructor(format);
|
|
1253
|
+
} catch (error) {
|
|
1254
|
+
if (error instanceof TypeError || (error == null ? void 0 : error.name) === "TypeError") {
|
|
1255
|
+
return null;
|
|
1256
|
+
}
|
|
1257
|
+
throw error;
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
async function* transformBatches(inputBatches, compressionStream) {
|
|
1261
|
+
const writer = compressionStream.writable.getWriter();
|
|
1262
|
+
const reader = compressionStream.readable.getReader();
|
|
1263
|
+
const writePromise = writeBatches(inputBatches, writer);
|
|
1264
|
+
writePromise.catch(() => {
|
|
1265
|
+
});
|
|
1266
|
+
let outputCompleted = false;
|
|
1267
|
+
try {
|
|
1268
|
+
while (true) {
|
|
1269
|
+
const { done, value } = await reader.read();
|
|
1270
|
+
if (done) {
|
|
1271
|
+
outputCompleted = true;
|
|
1272
|
+
break;
|
|
1273
|
+
}
|
|
1274
|
+
yield new Uint8Array(value).buffer;
|
|
1275
|
+
}
|
|
1276
|
+
await writePromise;
|
|
1277
|
+
} finally {
|
|
1278
|
+
if (!outputCompleted) {
|
|
1279
|
+
await reader.cancel().catch(() => {
|
|
1280
|
+
});
|
|
1281
|
+
await writer.abort().catch(() => {
|
|
1282
|
+
});
|
|
1283
|
+
await writePromise.catch(() => {
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
reader.releaseLock();
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
async function writeBatches(inputBatches, writer) {
|
|
1290
|
+
try {
|
|
1291
|
+
for await (const inputBatch of inputBatches) {
|
|
1292
|
+
await writer.write(new Uint8Array(inputBatch));
|
|
1293
|
+
}
|
|
1294
|
+
await writer.close();
|
|
1295
|
+
} catch (error) {
|
|
1296
|
+
await writer.abort(error).catch(() => {
|
|
1297
|
+
});
|
|
1298
|
+
throw error;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
async function concatenateBatches(batches) {
|
|
1302
|
+
const output = [];
|
|
1303
|
+
let byteLength = 0;
|
|
1304
|
+
for await (const batch of batches) {
|
|
1305
|
+
const bytes = new Uint8Array(batch);
|
|
1306
|
+
output.push(bytes);
|
|
1307
|
+
byteLength += bytes.byteLength;
|
|
1308
|
+
}
|
|
1309
|
+
const result = new Uint8Array(byteLength);
|
|
1310
|
+
let offset = 0;
|
|
1311
|
+
for (const batch of output) {
|
|
1312
|
+
result.set(batch, offset);
|
|
1313
|
+
offset += batch.byteLength;
|
|
1314
|
+
}
|
|
1315
|
+
return result.buffer;
|
|
1316
|
+
}
|
|
1317
|
+
var init_compression_stream = __esm({
|
|
1318
|
+
"../compression/src/lib/compression-stream.ts"() {
|
|
1319
|
+
"use strict";
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
// ../compression/src/lib/decompression-stream.ts
|
|
1324
|
+
async function decompressWithNativeDecompressionStream(input, format) {
|
|
1325
|
+
const outputBatches = decompressBatchesWithNativeDecompressionStream([input], format);
|
|
1326
|
+
return outputBatches ? await concatenateNativeDecompressionBatches(outputBatches) : null;
|
|
1327
|
+
}
|
|
1328
|
+
function decompressBatchesWithNativeDecompressionStream(inputBatches, format) {
|
|
1329
|
+
const decompressionStream = createNativeDecompressionStream(format);
|
|
1330
|
+
return decompressionStream ? transformBatchesWithNativeDecompressionStream(inputBatches, decompressionStream) : null;
|
|
1331
|
+
}
|
|
1332
|
+
function isNativeDecompressionSupported(format) {
|
|
1333
|
+
return Boolean(createNativeDecompressionStream(format));
|
|
1334
|
+
}
|
|
1335
|
+
function createNativeDecompressionStream(format) {
|
|
1336
|
+
var _a, _b;
|
|
1337
|
+
if (typeof globalThis.DecompressionStream === "undefined") {
|
|
1338
|
+
return null;
|
|
1339
|
+
}
|
|
1340
|
+
if (((_b = (_a = globalThis.process) == null ? void 0 : _a.release) == null ? void 0 : _b.name) === "node" && typeof globalThis.Buffer === "undefined") {
|
|
1341
|
+
return null;
|
|
1342
|
+
}
|
|
1343
|
+
try {
|
|
1344
|
+
const DecompressionStreamConstructor = globalThis.DecompressionStream;
|
|
1345
|
+
return new DecompressionStreamConstructor(format);
|
|
1346
|
+
} catch (error) {
|
|
1347
|
+
if (error instanceof TypeError || (error == null ? void 0 : error.name) === "TypeError") {
|
|
1348
|
+
return null;
|
|
1349
|
+
}
|
|
1350
|
+
throw error;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
async function* transformBatchesWithNativeDecompressionStream(inputBatches, decompressionStream) {
|
|
1354
|
+
const writer = decompressionStream.writable.getWriter();
|
|
1355
|
+
const reader = decompressionStream.readable.getReader();
|
|
1356
|
+
const writePromise = writeBatchesToNativeDecompressionStream(inputBatches, writer);
|
|
1357
|
+
writePromise.catch(() => {
|
|
1358
|
+
});
|
|
1359
|
+
let outputCompleted = false;
|
|
1360
|
+
try {
|
|
1361
|
+
while (true) {
|
|
1362
|
+
const { done, value } = await reader.read();
|
|
1363
|
+
if (done) {
|
|
1364
|
+
outputCompleted = true;
|
|
1365
|
+
break;
|
|
1366
|
+
}
|
|
1367
|
+
yield copyExactArrayBuffer(value);
|
|
1368
|
+
}
|
|
1369
|
+
await writePromise;
|
|
1370
|
+
} finally {
|
|
1371
|
+
if (!outputCompleted) {
|
|
1372
|
+
await reader.cancel().catch(() => {
|
|
1373
|
+
});
|
|
1374
|
+
await writer.abort().catch(() => {
|
|
1375
|
+
});
|
|
1376
|
+
await writePromise.catch(() => {
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
reader.releaseLock();
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
async function concatenateNativeDecompressionBatches(outputBatches) {
|
|
1383
|
+
const batches = [];
|
|
1384
|
+
let byteLength = 0;
|
|
1385
|
+
for await (const outputBatch of outputBatches) {
|
|
1386
|
+
const bytes = new Uint8Array(outputBatch);
|
|
1387
|
+
batches.push(bytes);
|
|
1388
|
+
byteLength += bytes.byteLength;
|
|
1389
|
+
}
|
|
1390
|
+
const output = new Uint8Array(byteLength);
|
|
1391
|
+
let byteOffset = 0;
|
|
1392
|
+
for (const batch of batches) {
|
|
1393
|
+
output.set(batch, byteOffset);
|
|
1394
|
+
byteOffset += batch.byteLength;
|
|
1395
|
+
}
|
|
1396
|
+
return output.buffer;
|
|
1397
|
+
}
|
|
1398
|
+
function copyExactArrayBuffer(value) {
|
|
1399
|
+
return new Uint8Array(value).buffer;
|
|
1400
|
+
}
|
|
1401
|
+
async function writeBatchesToNativeDecompressionStream(inputBatches, writer) {
|
|
1402
|
+
try {
|
|
1403
|
+
for await (const inputBatch of inputBatches) {
|
|
1404
|
+
await writer.write(new Uint8Array(inputBatch));
|
|
1405
|
+
}
|
|
1406
|
+
await writer.close();
|
|
1407
|
+
} catch (error) {
|
|
1408
|
+
await writer.abort(error).catch(() => {
|
|
1409
|
+
});
|
|
1410
|
+
throw error;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
var init_decompression_stream = __esm({
|
|
1414
|
+
"../compression/src/lib/decompression-stream.ts"() {
|
|
1415
|
+
"use strict";
|
|
1416
|
+
}
|
|
1417
|
+
});
|
|
1418
|
+
|
|
1419
|
+
// ../compression/src/lib/native-decompressor.ts
|
|
1420
|
+
var native_decompressor_exports = {};
|
|
1421
|
+
__export(native_decompressor_exports, {
|
|
1422
|
+
NativeDecompressor: () => NativeDecompressor
|
|
1423
|
+
});
|
|
1424
|
+
var NativeDecompressor;
|
|
1425
|
+
var init_native_decompressor = __esm({
|
|
1426
|
+
"../compression/src/lib/native-decompressor.ts"() {
|
|
1427
|
+
"use strict";
|
|
1428
|
+
init_compression();
|
|
1429
|
+
init_decompression_stream();
|
|
1430
|
+
NativeDecompressor = class extends Decompressor {
|
|
1431
|
+
name;
|
|
1432
|
+
extensions;
|
|
1433
|
+
contentEncodings;
|
|
1434
|
+
isSupported = true;
|
|
1435
|
+
/** Runtime stream format used for every operation. */
|
|
1436
|
+
format;
|
|
1437
|
+
constructor(metadata, format, options = {}) {
|
|
1438
|
+
super(options);
|
|
1439
|
+
this.name = metadata.name;
|
|
1440
|
+
this.extensions = [...metadata.extensions];
|
|
1441
|
+
this.contentEncodings = [...metadata.contentEncodings];
|
|
1442
|
+
this.format = format;
|
|
1443
|
+
}
|
|
1444
|
+
/** Decompresses one buffer with the runtime-provided stream. */
|
|
1445
|
+
async decompress(input) {
|
|
1446
|
+
const output = await decompressWithNativeDecompressionStream(input, this.format);
|
|
1447
|
+
if (!output) throw new Error(`${this.name}: built-in decompression is no longer available`);
|
|
1448
|
+
return output;
|
|
1449
|
+
}
|
|
1450
|
+
/** Decompresses batches incrementally with the runtime-provided stream. */
|
|
1451
|
+
async *decompressBatches(inputBatches) {
|
|
1452
|
+
const output = decompressBatchesWithNativeDecompressionStream(inputBatches, this.format);
|
|
1453
|
+
if (!output) throw new Error(`${this.name}: built-in decompression is no longer available`);
|
|
1454
|
+
yield* output;
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
});
|
|
1459
|
+
|
|
1460
|
+
// ../compression/src/lib/lazy-compression.ts
|
|
1461
|
+
function mergeModules(options, modules) {
|
|
1462
|
+
return { ...options, modules: { ...options.modules, ...modules } };
|
|
1463
|
+
}
|
|
1464
|
+
var LazyDecompressor;
|
|
1465
|
+
var init_lazy_compression = __esm({
|
|
1466
|
+
"../compression/src/lib/lazy-compression.ts"() {
|
|
1467
|
+
"use strict";
|
|
1468
|
+
init_compression();
|
|
1469
|
+
init_decompression_stream();
|
|
1470
|
+
LazyDecompressor = class extends Decompressor {
|
|
1471
|
+
name;
|
|
1472
|
+
extensions;
|
|
1473
|
+
contentEncodings;
|
|
1474
|
+
isSupported = true;
|
|
1475
|
+
/** Constructor options retained until a concrete implementation is selected. */
|
|
1476
|
+
options;
|
|
1477
|
+
/** Built-in stream format to probe, or null when the format has no built-in path. */
|
|
1478
|
+
nativeFormat;
|
|
1479
|
+
/** Returns whether built-in selection remains eligible for the merged preload options. */
|
|
1480
|
+
shouldUseNative;
|
|
1481
|
+
/** Dynamically imports the balanced fallback constructor. */
|
|
1482
|
+
loadFallback;
|
|
1483
|
+
/** Selected concrete implementation after preload completes. */
|
|
1484
|
+
implementation = null;
|
|
1485
|
+
/** Shared in-flight selection used by concurrent asynchronous calls. */
|
|
1486
|
+
implementationPromise = null;
|
|
1487
|
+
constructor(metadata, loadFallback, options = {}, nativeFormat = null, shouldUseNative = () => true) {
|
|
1488
|
+
super(options);
|
|
1489
|
+
this.name = metadata.name;
|
|
1490
|
+
this.extensions = [...metadata.extensions];
|
|
1491
|
+
this.contentEncodings = [...metadata.contentEncodings];
|
|
1492
|
+
this.options = options;
|
|
1493
|
+
this.nativeFormat = nativeFormat;
|
|
1494
|
+
this.shouldUseNative = shouldUseNative;
|
|
1495
|
+
this.loadFallback = loadFallback;
|
|
1496
|
+
}
|
|
1497
|
+
/** Selects and returns the built-in or dynamically imported fallback decompressor. */
|
|
1498
|
+
async preload(modules = {}) {
|
|
1499
|
+
if (this.implementation) return this.implementation;
|
|
1500
|
+
const options = mergeModules(this.options, modules);
|
|
1501
|
+
this.implementationPromise ||= this.loadImplementation(options);
|
|
1502
|
+
try {
|
|
1503
|
+
this.implementation = await this.implementationPromise;
|
|
1504
|
+
return this.implementation;
|
|
1505
|
+
} catch (error) {
|
|
1506
|
+
this.implementationPromise = null;
|
|
1507
|
+
throw error;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
/** Loads the selected concrete decompressor. */
|
|
1511
|
+
async loadImplementation(options) {
|
|
1512
|
+
if (options.useNative !== false && this.nativeFormat && this.shouldUseNative(options) && isNativeDecompressionSupported(this.nativeFormat)) {
|
|
1513
|
+
const { NativeDecompressor: NativeDecompressor2 } = await Promise.resolve().then(() => (init_native_decompressor(), native_decompressor_exports));
|
|
1514
|
+
return new NativeDecompressor2(this, this.nativeFormat, options);
|
|
1515
|
+
}
|
|
1516
|
+
const Decompressor2 = await this.loadFallback();
|
|
1517
|
+
const implementation = new Decompressor2({ ...options, useNative: false });
|
|
1518
|
+
await implementation.preload(options.modules);
|
|
1519
|
+
return implementation;
|
|
1520
|
+
}
|
|
1521
|
+
/** Decompresses after lazily selecting the default implementation. */
|
|
1522
|
+
async decompress(input, size) {
|
|
1523
|
+
return (await this.preload()).decompress(input, size);
|
|
1524
|
+
}
|
|
1525
|
+
/** Decompresses synchronously after an implementation has been preloaded. */
|
|
1526
|
+
decompressSync(input, size) {
|
|
1527
|
+
if (!this.implementation) {
|
|
1528
|
+
throw new Error(`${this.name}: call preload() before decompressSync()`);
|
|
1529
|
+
}
|
|
1530
|
+
return this.implementation.decompressSync(input, size);
|
|
1531
|
+
}
|
|
1532
|
+
/** Decompresses batches after lazily selecting the default implementation. */
|
|
1533
|
+
async *decompressBatches(inputBatches) {
|
|
1534
|
+
yield* (await this.preload()).decompressBatches(inputBatches);
|
|
1535
|
+
}
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1539
|
+
|
|
1540
|
+
// ../compression/src/zstd-decompressor-fzstd.ts
|
|
1541
|
+
var import_fzstd, ZstdFzstdDecompressor;
|
|
1542
|
+
var init_zstd_decompressor_fzstd = __esm({
|
|
1543
|
+
"../compression/src/zstd-decompressor-fzstd.ts"() {
|
|
1544
|
+
"use strict";
|
|
1545
|
+
init_compression();
|
|
1546
|
+
import_fzstd = require("fzstd");
|
|
1547
|
+
ZstdFzstdDecompressor = class extends Decompressor {
|
|
1548
|
+
name = "zstd";
|
|
1549
|
+
extensions = ["zst"];
|
|
1550
|
+
contentEncodings = ["zstd"];
|
|
1551
|
+
isSupported = true;
|
|
1552
|
+
constructor(options = {}) {
|
|
1553
|
+
super(options);
|
|
1554
|
+
}
|
|
1555
|
+
/** Decompresses one Zstandard frame synchronously. */
|
|
1556
|
+
decompressSync(input) {
|
|
1557
|
+
return (0, import_fzstd.decompress)(new Uint8Array(input)).slice().buffer;
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
});
|
|
1562
|
+
|
|
1563
|
+
// ../compression/src/zstd-fallback.ts
|
|
1564
|
+
var zstd_fallback_exports = {};
|
|
1565
|
+
__export(zstd_fallback_exports, {
|
|
1566
|
+
decompressZstd: () => decompressZstd
|
|
1567
|
+
});
|
|
1568
|
+
function decompressZstd(input) {
|
|
1569
|
+
return (0, import_fzstd2.decompress)(input);
|
|
1570
|
+
}
|
|
1571
|
+
var import_fzstd2;
|
|
1572
|
+
var init_zstd_fallback = __esm({
|
|
1573
|
+
"../compression/src/zstd-fallback.ts"() {
|
|
1574
|
+
"use strict";
|
|
1575
|
+
import_fzstd2 = require("fzstd");
|
|
1576
|
+
}
|
|
1577
|
+
});
|
|
1578
|
+
|
|
1579
|
+
// ../compression/src/lib/zstd-compression.ts
|
|
1580
|
+
var zstd_compression_exports = {};
|
|
1581
|
+
__export(zstd_compression_exports, {
|
|
1582
|
+
ZstdCompression: () => ZstdCompression
|
|
1583
|
+
});
|
|
1584
|
+
var CHUNK_SIZE, zstdPromise, zstd, ZstdCompression;
|
|
1585
|
+
var init_zstd_compression = __esm({
|
|
1586
|
+
"../compression/src/lib/zstd-compression.ts"() {
|
|
1587
|
+
"use strict";
|
|
1588
|
+
init_compression();
|
|
1589
|
+
init_src();
|
|
1590
|
+
init_compression_stream();
|
|
1591
|
+
init_decompression_stream();
|
|
1592
|
+
CHUNK_SIZE = 1e6;
|
|
1593
|
+
ZstdCompression = class extends Compression {
|
|
1594
|
+
name = "zstd";
|
|
1595
|
+
extensions = [];
|
|
1596
|
+
contentEncodings = [];
|
|
1597
|
+
isSupported = true;
|
|
1598
|
+
options;
|
|
1599
|
+
/**
|
|
1600
|
+
* zstd-codec is an injectable dependency due to big size
|
|
1601
|
+
* @param options
|
|
1602
|
+
*/
|
|
1603
|
+
constructor(options = {}) {
|
|
1604
|
+
super(options);
|
|
1605
|
+
this.options = options;
|
|
1606
|
+
registerJSModules(options == null ? void 0 : options.modules);
|
|
1607
|
+
}
|
|
1608
|
+
async preload(modules = {}) {
|
|
1609
|
+
registerJSModules(modules);
|
|
1610
|
+
const ZstdCodec = getJSModuleOrNull("zstd-codec");
|
|
1611
|
+
if (!zstdPromise && ZstdCodec) {
|
|
1612
|
+
zstdPromise = new Promise((resolve) => ZstdCodec.run((zstd2) => resolve(zstd2)));
|
|
1613
|
+
}
|
|
1614
|
+
if (zstdPromise) {
|
|
1615
|
+
zstd = await zstdPromise;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
compressSync(input) {
|
|
1619
|
+
getJSModule("zstd-codec", this.name);
|
|
1620
|
+
const simpleZstd = new zstd.Simple();
|
|
1621
|
+
const inputArray = new Uint8Array(input);
|
|
1622
|
+
return simpleZstd.compress(inputArray).buffer;
|
|
1623
|
+
}
|
|
1624
|
+
async compress(input) {
|
|
1625
|
+
var _a;
|
|
1626
|
+
if (this.options.useNative !== false && ((_a = this.options.zstd) == null ? void 0 : _a.useNative) !== false) {
|
|
1627
|
+
const nativeOutput = await compressWithNativeCompressionStream(input, "zstd");
|
|
1628
|
+
if (nativeOutput) return nativeOutput;
|
|
1629
|
+
}
|
|
1630
|
+
await this.preload();
|
|
1631
|
+
return this.compressSync(input);
|
|
1632
|
+
}
|
|
1633
|
+
decompressSync(input) {
|
|
1634
|
+
getJSModule("zstd-codec", this.name);
|
|
1635
|
+
const simpleZstd = new zstd.Simple();
|
|
1636
|
+
const inputArray = new Uint8Array(input);
|
|
1637
|
+
return simpleZstd.decompress(inputArray).buffer;
|
|
1638
|
+
}
|
|
1639
|
+
async decompress(input, size) {
|
|
1640
|
+
var _a;
|
|
1641
|
+
if (!getJSModuleOrNull("zstd-codec") && this.options.useNative !== false && ((_a = this.options.zstd) == null ? void 0 : _a.useNative) !== false) {
|
|
1642
|
+
const nativeOutput = await decompressWithNativeDecompressionStream(input, "zstd");
|
|
1643
|
+
if (nativeOutput) return nativeOutput;
|
|
1644
|
+
}
|
|
1645
|
+
await this.preload();
|
|
1646
|
+
const inputArray = new Uint8Array(input);
|
|
1647
|
+
if (!zstd) {
|
|
1648
|
+
const { decompressZstd: decompressZstd2 } = await Promise.resolve().then(() => (init_zstd_fallback(), zstd_fallback_exports));
|
|
1649
|
+
return ensureArrayBuffer(decompressZstd2(inputArray));
|
|
1650
|
+
}
|
|
1651
|
+
const simpleZstd = new zstd.Streaming();
|
|
1652
|
+
const chunks = [];
|
|
1653
|
+
for (let i = 0; i <= inputArray.length; i += CHUNK_SIZE) {
|
|
1654
|
+
const chunkView = inputArray.subarray(i, i + CHUNK_SIZE);
|
|
1655
|
+
const chunkArrayBuffer = ensureArrayBuffer(chunkView);
|
|
1656
|
+
chunks.push(new Uint8Array(chunkArrayBuffer));
|
|
1657
|
+
}
|
|
1658
|
+
const decompressResult = await simpleZstd.decompressChunks(chunks);
|
|
1659
|
+
return decompressResult.buffer;
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
|
|
1665
|
+
// ../compression/src/zstd-decompressor.ts
|
|
1666
|
+
var zstd_decompressor_exports = {};
|
|
1667
|
+
__export(zstd_decompressor_exports, {
|
|
1668
|
+
ZstdDecompressor: () => ZstdDecompressor
|
|
1669
|
+
});
|
|
1670
|
+
var ZstdDecompressor;
|
|
1671
|
+
var init_zstd_decompressor = __esm({
|
|
1672
|
+
"../compression/src/zstd-decompressor.ts"() {
|
|
1673
|
+
"use strict";
|
|
1674
|
+
init_zstd_decompressor_fzstd();
|
|
1675
|
+
init_decompression_stream();
|
|
1676
|
+
init_src();
|
|
1677
|
+
ZstdDecompressor = class extends ZstdFzstdDecompressor {
|
|
1678
|
+
options;
|
|
1679
|
+
compatibility = null;
|
|
1680
|
+
constructor(options = {}) {
|
|
1681
|
+
super(options);
|
|
1682
|
+
this.options = options;
|
|
1683
|
+
registerJSModules(options.modules);
|
|
1684
|
+
}
|
|
1685
|
+
/** Preloads an injected zstd-codec implementation when supplied. */
|
|
1686
|
+
async preload(modules = {}) {
|
|
1687
|
+
registerJSModules(modules);
|
|
1688
|
+
if (getJSModuleOrNull("zstd-codec")) {
|
|
1689
|
+
const { ZstdCompression: ZstdCompression2 } = await Promise.resolve().then(() => (init_zstd_compression(), zstd_compression_exports));
|
|
1690
|
+
this.compatibility ||= new ZstdCompression2(this.options);
|
|
1691
|
+
await this.compatibility.preload(modules);
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
/** Decompresses with the built-in stream when available, then falls back to fzstd. */
|
|
1695
|
+
async decompress(input) {
|
|
1696
|
+
if (this.options.useNative !== false) {
|
|
1697
|
+
const output = await decompressWithNativeDecompressionStream(input, "zstd");
|
|
1698
|
+
if (output) return output;
|
|
1699
|
+
}
|
|
1700
|
+
if (getJSModuleOrNull("zstd-codec")) {
|
|
1701
|
+
await this.preload(this.options.modules);
|
|
1702
|
+
}
|
|
1703
|
+
return this.decompressSync(input);
|
|
1704
|
+
}
|
|
1705
|
+
/** Decompresses with a preloaded zstd-codec implementation or compact fzstd. */
|
|
1706
|
+
decompressSync(input) {
|
|
1707
|
+
if (this.compatibility) {
|
|
1708
|
+
return this.compatibility.decompressSync(input);
|
|
1709
|
+
}
|
|
1710
|
+
if (getJSModuleOrNull("zstd-codec")) {
|
|
1711
|
+
throw new Error("zstd: call preload() before synchronous decompression with zstd-codec");
|
|
1712
|
+
}
|
|
1713
|
+
return super.decompressSync(input);
|
|
1714
|
+
}
|
|
1715
|
+
/** Decompresses batches with a built-in stream or compact fzstd fallback. */
|
|
1716
|
+
async *decompressBatches(inputBatches) {
|
|
1717
|
+
if (this.options.useNative !== false) {
|
|
1718
|
+
const output = decompressBatchesWithNativeDecompressionStream(inputBatches, "zstd");
|
|
1719
|
+
if (output) {
|
|
1720
|
+
yield* output;
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
if (getJSModuleOrNull("zstd-codec")) {
|
|
1725
|
+
yield this.decompress(await this.concatenate(inputBatches));
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1728
|
+
yield* super.decompressBatches(inputBatches);
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
});
|
|
1733
|
+
|
|
1734
|
+
// ../compression/src/default-codecs.ts
|
|
1735
|
+
var ZSTD, ZstdDecompressor2;
|
|
1736
|
+
var init_default_codecs = __esm({
|
|
1737
|
+
"../compression/src/default-codecs.ts"() {
|
|
1738
|
+
"use strict";
|
|
1739
|
+
init_lazy_compression();
|
|
1740
|
+
init_src();
|
|
1741
|
+
ZSTD = { name: "zstd", extensions: ["zst"], contentEncodings: ["zstd"] };
|
|
1742
|
+
ZstdDecompressor2 = class extends LazyDecompressor {
|
|
1743
|
+
constructor(options = {}) {
|
|
1744
|
+
super(
|
|
1745
|
+
ZSTD,
|
|
1746
|
+
async () => (await Promise.resolve().then(() => (init_zstd_decompressor(), zstd_decompressor_exports))).ZstdDecompressor,
|
|
1747
|
+
options,
|
|
1748
|
+
"zstd",
|
|
1749
|
+
(preloadOptions) => {
|
|
1750
|
+
var _a;
|
|
1751
|
+
return !((_a = preloadOptions.modules) == null ? void 0 : _a["zstd-codec"]) && !getJSModuleOrNull("zstd-codec");
|
|
1752
|
+
}
|
|
1753
|
+
);
|
|
1754
|
+
}
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
|
|
1759
|
+
// ../compression/src/index.ts
|
|
1760
|
+
var init_src2 = __esm({
|
|
1761
|
+
"../compression/src/index.ts"() {
|
|
1762
|
+
"use strict";
|
|
1763
|
+
init_default_codecs();
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
|
|
675
1767
|
// dist/lib/parse-spz.js
|
|
676
1768
|
async function parseSPZ(data, options) {
|
|
677
1769
|
return makeGaussianSplatsArrowTable(await parseSPZToGaussianSplats(data, options));
|
|
@@ -680,8 +1772,8 @@ async function parseSPZToGaussianSplats(data, options) {
|
|
|
680
1772
|
const header = parseSPZHeader(data);
|
|
681
1773
|
const streamInfos = parseSPZStreamInfos(data, header, getSPZStreamByteLengths(header));
|
|
682
1774
|
const compressedStreams = streamInfos.map((streamInfo) => data.slice(streamInfo.compressedOffset, streamInfo.compressedOffset + streamInfo.compressedSize));
|
|
683
|
-
const
|
|
684
|
-
const streams = await Promise.all(compressedStreams.map((compressedStream, streamIndex) =>
|
|
1775
|
+
const decompressor = new ZstdDecompressor2({ modules: options == null ? void 0 : options.modules });
|
|
1776
|
+
const streams = await Promise.all(compressedStreams.map((compressedStream, streamIndex) => decompressor.decompress(compressedStream, streamInfos[streamIndex].uncompressedSize)));
|
|
685
1777
|
validateSPZStreamLengths(streams, streamInfos);
|
|
686
1778
|
return decodeSPZStreams(header, streams, data);
|
|
687
1779
|
}
|
|
@@ -827,12 +1919,12 @@ function decodeSPZRotations(rotationStream, rotations) {
|
|
|
827
1919
|
const byteOffset = splatIndex * 4;
|
|
828
1920
|
const component = rotationStream[byteOffset] | rotationStream[byteOffset + 1] << 8 | rotationStream[byteOffset + 2] << 16 | rotationStream[byteOffset + 3] << 24;
|
|
829
1921
|
const xyzw = decodeSPZQuaternion(component >>> 0);
|
|
830
|
-
const [w, x, y,
|
|
1922
|
+
const [w, x, y, z2] = normalizeQuaternion(xyzw[3], xyzw[0], xyzw[1], xyzw[2]);
|
|
831
1923
|
const rotationOffset = splatIndex * 4;
|
|
832
1924
|
rotations[rotationOffset + 0] = w;
|
|
833
1925
|
rotations[rotationOffset + 1] = x;
|
|
834
1926
|
rotations[rotationOffset + 2] = y;
|
|
835
|
-
rotations[rotationOffset + 3] =
|
|
1927
|
+
rotations[rotationOffset + 3] = z2;
|
|
836
1928
|
}
|
|
837
1929
|
}
|
|
838
1930
|
function decodeSPZQuaternion(component) {
|
|
@@ -898,11 +1990,11 @@ function getSPZExtensionBytes(data, header) {
|
|
|
898
1990
|
const extensionByteLength = getSPZExtensionByteLength(header);
|
|
899
1991
|
return extensionByteLength ? new Uint8Array(data.slice(SPZ_HEADER_BYTE_LENGTH, header.tocByteOffset)) : void 0;
|
|
900
1992
|
}
|
|
901
|
-
var
|
|
1993
|
+
var SPZ_HEADER_BYTE_LENGTH, SPZ_MAGIC, SPZ_VERSION, SPZ_EXTENSION_FLAG, SPZ_COLOR_SCALE, SPZ_ROTATION_COMPONENT_SCALE, SPZ_ROTATION_COMPONENT_MASK;
|
|
902
1994
|
var init_parse_spz = __esm({
|
|
903
1995
|
"dist/lib/parse-spz.js"() {
|
|
904
1996
|
"use strict";
|
|
905
|
-
|
|
1997
|
+
init_src2();
|
|
906
1998
|
init_splats_arrow_table();
|
|
907
1999
|
init_splat_utils();
|
|
908
2000
|
SPZ_HEADER_BYTE_LENGTH = 32;
|
|
@@ -939,17 +2031,17 @@ async function preload3() {
|
|
|
939
2031
|
const { SPZLoaderWithParser: SPZLoaderWithParser2 } = await Promise.resolve().then(() => (init_spz_loader(), spz_loader_exports));
|
|
940
2032
|
return SPZLoaderWithParser2;
|
|
941
2033
|
}
|
|
942
|
-
var
|
|
2034
|
+
var VERSION4, SPZLoader;
|
|
943
2035
|
var init_spz_loader_types = __esm({
|
|
944
2036
|
"dist/spz-loader-types.js"() {
|
|
945
2037
|
"use strict";
|
|
946
2038
|
init_splats_format();
|
|
947
|
-
|
|
2039
|
+
VERSION4 = true ? "5.0.0-alpha.3" : "latest";
|
|
948
2040
|
SPZLoader = {
|
|
949
2041
|
dataType: null,
|
|
950
2042
|
batchType: null,
|
|
951
2043
|
...SPZFormat,
|
|
952
|
-
version:
|
|
2044
|
+
version: VERSION4,
|
|
953
2045
|
options: {
|
|
954
2046
|
splats: {
|
|
955
2047
|
shape: "arrow-table"
|
|
@@ -960,6 +2052,65 @@ var init_spz_loader_types = __esm({
|
|
|
960
2052
|
}
|
|
961
2053
|
});
|
|
962
2054
|
|
|
2055
|
+
// dist/rad-zod-schema.js
|
|
2056
|
+
var import_zod, nonNegativeSafeIntegerSchema, RADSplatEncodingSchema, RADChunkRangeSchema, RADMetadataJSONSchema, RADChunkPropertySchema, RADChunkMetadataJSONSchema;
|
|
2057
|
+
var init_rad_zod_schema = __esm({
|
|
2058
|
+
"dist/rad-zod-schema.js"() {
|
|
2059
|
+
"use strict";
|
|
2060
|
+
import_zod = require("zod");
|
|
2061
|
+
nonNegativeSafeIntegerSchema = import_zod.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
2062
|
+
RADSplatEncodingSchema = import_zod.z.object({
|
|
2063
|
+
rgbMin: import_zod.z.number().finite().optional(),
|
|
2064
|
+
rgbMax: import_zod.z.number().finite().optional(),
|
|
2065
|
+
lnScaleMin: import_zod.z.number().finite().optional(),
|
|
2066
|
+
lnScaleMax: import_zod.z.number().finite().optional(),
|
|
2067
|
+
sh1Max: import_zod.z.number().finite().optional(),
|
|
2068
|
+
sh2Max: import_zod.z.number().finite().optional(),
|
|
2069
|
+
sh3Max: import_zod.z.number().finite().optional(),
|
|
2070
|
+
lodOpacity: import_zod.z.boolean().optional()
|
|
2071
|
+
}).passthrough();
|
|
2072
|
+
RADChunkRangeSchema = import_zod.z.object({
|
|
2073
|
+
offset: nonNegativeSafeIntegerSchema,
|
|
2074
|
+
bytes: nonNegativeSafeIntegerSchema,
|
|
2075
|
+
base: nonNegativeSafeIntegerSchema.optional(),
|
|
2076
|
+
count: nonNegativeSafeIntegerSchema.optional(),
|
|
2077
|
+
filename: import_zod.z.string().optional()
|
|
2078
|
+
}).passthrough();
|
|
2079
|
+
RADMetadataJSONSchema = import_zod.z.object({
|
|
2080
|
+
version: import_zod.z.literal(1),
|
|
2081
|
+
type: import_zod.z.literal("gsplat"),
|
|
2082
|
+
count: nonNegativeSafeIntegerSchema,
|
|
2083
|
+
maxSh: nonNegativeSafeIntegerSchema.optional(),
|
|
2084
|
+
lodTree: import_zod.z.boolean().optional(),
|
|
2085
|
+
chunkSize: nonNegativeSafeIntegerSchema.optional(),
|
|
2086
|
+
allChunkBytes: nonNegativeSafeIntegerSchema.optional(),
|
|
2087
|
+
chunks: import_zod.z.array(RADChunkRangeSchema),
|
|
2088
|
+
splatEncoding: RADSplatEncodingSchema.optional(),
|
|
2089
|
+
shCodeCount: nonNegativeSafeIntegerSchema.optional(),
|
|
2090
|
+
comment: import_zod.z.string().optional()
|
|
2091
|
+
}).passthrough();
|
|
2092
|
+
RADChunkPropertySchema = import_zod.z.object({
|
|
2093
|
+
offset: nonNegativeSafeIntegerSchema,
|
|
2094
|
+
bytes: nonNegativeSafeIntegerSchema,
|
|
2095
|
+
property: import_zod.z.string(),
|
|
2096
|
+
encoding: import_zod.z.string(),
|
|
2097
|
+
compression: import_zod.z.string().optional(),
|
|
2098
|
+
min: import_zod.z.number().finite().optional(),
|
|
2099
|
+
max: import_zod.z.number().finite().optional()
|
|
2100
|
+
}).passthrough();
|
|
2101
|
+
RADChunkMetadataJSONSchema = import_zod.z.object({
|
|
2102
|
+
version: import_zod.z.literal(1),
|
|
2103
|
+
base: nonNegativeSafeIntegerSchema,
|
|
2104
|
+
count: nonNegativeSafeIntegerSchema,
|
|
2105
|
+
payloadBytes: nonNegativeSafeIntegerSchema,
|
|
2106
|
+
maxSh: nonNegativeSafeIntegerSchema.optional(),
|
|
2107
|
+
lodTree: import_zod.z.boolean().optional(),
|
|
2108
|
+
splatEncoding: RADSplatEncodingSchema.optional(),
|
|
2109
|
+
properties: import_zod.z.array(RADChunkPropertySchema)
|
|
2110
|
+
}).passthrough();
|
|
2111
|
+
}
|
|
2112
|
+
});
|
|
2113
|
+
|
|
963
2114
|
// dist/lib/parse-rad.js
|
|
964
2115
|
function parseRADHeader(data) {
|
|
965
2116
|
const metadata = tryParseRADHeader(data);
|
|
@@ -983,7 +2134,7 @@ function tryParseRADHeader(data) {
|
|
|
983
2134
|
if (bytes.byteLength < headerJsonEnd) {
|
|
984
2135
|
return null;
|
|
985
2136
|
}
|
|
986
|
-
const rawMetadata =
|
|
2137
|
+
const rawMetadata = RADMetadataJSONSchema.parse(parseJSON(bytes.subarray(RAD_HEADER_BYTE_LENGTH, headerJsonEnd), "RADLoader: failed to parse RAD metadata JSON."));
|
|
987
2138
|
return normalizeRADMetadata(rawMetadata, headerJsonByteLength);
|
|
988
2139
|
}
|
|
989
2140
|
function parseRADChunkHeader(data) {
|
|
@@ -1003,7 +2154,7 @@ function parseRADChunkHeader(data) {
|
|
|
1003
2154
|
if (bytes.byteLength < payloadByteOffset) {
|
|
1004
2155
|
throw new Error("RADLoader: RADC chunk must contain a complete metadata header.");
|
|
1005
2156
|
}
|
|
1006
|
-
const rawMetadata =
|
|
2157
|
+
const rawMetadata = RADChunkMetadataJSONSchema.parse(parseJSON(bytes.subarray(RAD_HEADER_BYTE_LENGTH, headerJsonEnd), "RADLoader: failed to parse RADC metadata JSON."));
|
|
1007
2158
|
const payloadBytes = readSafeUint642(dataView, payloadByteLengthOffset, "RADC payload byte length");
|
|
1008
2159
|
return normalizeRADChunkMetadata(rawMetadata, headerJsonByteLength, payloadByteOffset, payloadBytes);
|
|
1009
2160
|
}
|
|
@@ -1011,157 +2162,31 @@ function roundUpToEight(byteLength) {
|
|
|
1011
2162
|
return byteLength + 7 & ~7;
|
|
1012
2163
|
}
|
|
1013
2164
|
function normalizeRADMetadata(rawMetadata, headerJsonByteLength) {
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
throw new Error(`RADLoader: version ${version} is not supported.`);
|
|
1017
|
-
}
|
|
1018
|
-
const type = requireString(rawMetadata.type, "RAD type");
|
|
1019
|
-
if (type !== "gsplat") {
|
|
1020
|
-
throw new Error(`RADLoader: RAD type ${type} is not supported.`);
|
|
1021
|
-
}
|
|
1022
|
-
const chunks = requireArray(rawMetadata.chunks, "RAD chunks").map((chunk, chunkIndex) => normalizeRADChunkRange(chunk, chunkIndex));
|
|
1023
|
-
const metadata = {
|
|
1024
|
-
version,
|
|
1025
|
-
type,
|
|
1026
|
-
count: requireSafeInteger(rawMetadata.count, "RAD count"),
|
|
1027
|
-
maxSh: optionalSafeInteger(rawMetadata.maxSh, "RAD maxSh"),
|
|
1028
|
-
lodTree: optionalBoolean(rawMetadata.lodTree, "RAD lodTree"),
|
|
1029
|
-
chunkSize: optionalSafeInteger(rawMetadata.chunkSize, "RAD chunkSize"),
|
|
1030
|
-
allChunkBytes: optionalSafeInteger(rawMetadata.allChunkBytes, "RAD allChunkBytes"),
|
|
1031
|
-
chunks,
|
|
1032
|
-
splatEncoding: optionalSplatEncoding(rawMetadata.splatEncoding, "RAD splatEncoding"),
|
|
1033
|
-
shCodeCount: optionalSafeInteger(rawMetadata.shCodeCount, "RAD shCodeCount"),
|
|
1034
|
-
comment: optionalString(rawMetadata.comment, "RAD comment"),
|
|
2165
|
+
return {
|
|
2166
|
+
...rawMetadata,
|
|
1035
2167
|
headerJsonByteLength,
|
|
1036
2168
|
chunksByteOffset: RAD_HEADER_BYTE_LENGTH + roundUpToEight(headerJsonByteLength)
|
|
1037
2169
|
};
|
|
1038
|
-
return metadata;
|
|
1039
|
-
}
|
|
1040
|
-
function normalizeRADChunkRange(rawChunk, chunkIndex) {
|
|
1041
|
-
const chunk = requireRecord(rawChunk, `RAD chunk ${chunkIndex}`);
|
|
1042
|
-
return {
|
|
1043
|
-
offset: requireSafeInteger(chunk.offset, `RAD chunk ${chunkIndex} offset`),
|
|
1044
|
-
bytes: requireSafeInteger(chunk.bytes, `RAD chunk ${chunkIndex} bytes`),
|
|
1045
|
-
base: optionalSafeInteger(chunk.base, `RAD chunk ${chunkIndex} base`),
|
|
1046
|
-
count: optionalSafeInteger(chunk.count, `RAD chunk ${chunkIndex} count`),
|
|
1047
|
-
filename: optionalString(chunk.filename, `RAD chunk ${chunkIndex} filename`)
|
|
1048
|
-
};
|
|
1049
2170
|
}
|
|
1050
2171
|
function normalizeRADChunkMetadata(rawMetadata, headerJsonByteLength, payloadByteOffset, payloadBytes) {
|
|
1051
|
-
|
|
1052
|
-
if (version !== 1) {
|
|
1053
|
-
throw new Error(`RADLoader: RADC version ${version} is not supported.`);
|
|
1054
|
-
}
|
|
1055
|
-
const metadataPayloadBytes = requireSafeInteger(rawMetadata.payloadBytes, "RADC payloadBytes");
|
|
1056
|
-
if (metadataPayloadBytes !== payloadBytes) {
|
|
2172
|
+
if (rawMetadata.payloadBytes !== payloadBytes) {
|
|
1057
2173
|
throw new Error("RADLoader: RADC metadata payload byte length does not match binary header.");
|
|
1058
2174
|
}
|
|
1059
2175
|
return {
|
|
1060
|
-
|
|
1061
|
-
base: requireSafeInteger(rawMetadata.base, "RADC base"),
|
|
1062
|
-
count: requireSafeInteger(rawMetadata.count, "RADC count"),
|
|
2176
|
+
...rawMetadata,
|
|
1063
2177
|
payloadBytes,
|
|
1064
|
-
maxSh: optionalSafeInteger(rawMetadata.maxSh, "RADC maxSh"),
|
|
1065
|
-
lodTree: optionalBoolean(rawMetadata.lodTree, "RADC lodTree"),
|
|
1066
|
-
splatEncoding: optionalSplatEncoding(rawMetadata.splatEncoding, "RADC splatEncoding"),
|
|
1067
|
-
properties: requireArray(rawMetadata.properties, "RADC properties").map((property, index) => normalizeRADChunkProperty(property, index)),
|
|
1068
2178
|
headerJsonByteLength,
|
|
1069
2179
|
payloadByteOffset,
|
|
1070
2180
|
chunkByteLength: payloadByteOffset + payloadBytes
|
|
1071
2181
|
};
|
|
1072
2182
|
}
|
|
1073
|
-
function
|
|
1074
|
-
const property = requireRecord(rawProperty, `RADC property ${propertyIndex}`);
|
|
1075
|
-
return {
|
|
1076
|
-
offset: requireSafeInteger(property.offset, `RADC property ${propertyIndex} offset`),
|
|
1077
|
-
bytes: requireSafeInteger(property.bytes, `RADC property ${propertyIndex} bytes`),
|
|
1078
|
-
property: requireString(property.property, `RADC property ${propertyIndex} name`),
|
|
1079
|
-
encoding: requireString(property.encoding, `RADC property ${propertyIndex} encoding`),
|
|
1080
|
-
compression: optionalString(property.compression, `RADC property ${propertyIndex} compression`),
|
|
1081
|
-
min: optionalFiniteNumber(property.min, `RADC property ${propertyIndex} min`),
|
|
1082
|
-
max: optionalFiniteNumber(property.max, `RADC property ${propertyIndex} max`)
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
function optionalSplatEncoding(value, fieldName) {
|
|
1086
|
-
if (value === void 0) {
|
|
1087
|
-
return void 0;
|
|
1088
|
-
}
|
|
1089
|
-
const encoding = requireRecord(value, fieldName);
|
|
1090
|
-
return {
|
|
1091
|
-
rgbMin: optionalFiniteNumber(encoding.rgbMin, `${fieldName}.rgbMin`),
|
|
1092
|
-
rgbMax: optionalFiniteNumber(encoding.rgbMax, `${fieldName}.rgbMax`),
|
|
1093
|
-
lnScaleMin: optionalFiniteNumber(encoding.lnScaleMin, `${fieldName}.lnScaleMin`),
|
|
1094
|
-
lnScaleMax: optionalFiniteNumber(encoding.lnScaleMax, `${fieldName}.lnScaleMax`),
|
|
1095
|
-
sh1Max: optionalFiniteNumber(encoding.sh1Max, `${fieldName}.sh1Max`),
|
|
1096
|
-
sh2Max: optionalFiniteNumber(encoding.sh2Max, `${fieldName}.sh2Max`),
|
|
1097
|
-
sh3Max: optionalFiniteNumber(encoding.sh3Max, `${fieldName}.sh3Max`),
|
|
1098
|
-
lodOpacity: optionalBoolean(encoding.lodOpacity, `${fieldName}.lodOpacity`)
|
|
1099
|
-
};
|
|
1100
|
-
}
|
|
1101
|
-
function parseJSONRecord(bytes, message) {
|
|
2183
|
+
function parseJSON(bytes, message) {
|
|
1102
2184
|
try {
|
|
1103
|
-
return
|
|
1104
|
-
} catch
|
|
1105
|
-
if (error instanceof Error && error.message.startsWith("RADLoader:")) {
|
|
1106
|
-
throw error;
|
|
1107
|
-
}
|
|
2185
|
+
return JSON.parse(TEXT_DECODER.decode(bytes));
|
|
2186
|
+
} catch {
|
|
1108
2187
|
throw new Error(message);
|
|
1109
2188
|
}
|
|
1110
2189
|
}
|
|
1111
|
-
function requireRecord(value, fieldName) {
|
|
1112
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1113
|
-
throw new Error(`RADLoader: ${fieldName} must be an object.`);
|
|
1114
|
-
}
|
|
1115
|
-
return value;
|
|
1116
|
-
}
|
|
1117
|
-
function requireArray(value, fieldName) {
|
|
1118
|
-
if (!Array.isArray(value)) {
|
|
1119
|
-
throw new Error(`RADLoader: ${fieldName} must be an array.`);
|
|
1120
|
-
}
|
|
1121
|
-
return value;
|
|
1122
|
-
}
|
|
1123
|
-
function requireString(value, fieldName) {
|
|
1124
|
-
if (typeof value !== "string") {
|
|
1125
|
-
throw new Error(`RADLoader: ${fieldName} must be a string.`);
|
|
1126
|
-
}
|
|
1127
|
-
return value;
|
|
1128
|
-
}
|
|
1129
|
-
function optionalString(value, fieldName) {
|
|
1130
|
-
if (value === void 0) {
|
|
1131
|
-
return void 0;
|
|
1132
|
-
}
|
|
1133
|
-
return requireString(value, fieldName);
|
|
1134
|
-
}
|
|
1135
|
-
function optionalBoolean(value, fieldName) {
|
|
1136
|
-
if (value === void 0) {
|
|
1137
|
-
return void 0;
|
|
1138
|
-
}
|
|
1139
|
-
if (typeof value !== "boolean") {
|
|
1140
|
-
throw new Error(`RADLoader: ${fieldName} must be a boolean.`);
|
|
1141
|
-
}
|
|
1142
|
-
return value;
|
|
1143
|
-
}
|
|
1144
|
-
function requireSafeInteger(value, fieldName) {
|
|
1145
|
-
if (!Number.isSafeInteger(value) || Number(value) < 0) {
|
|
1146
|
-
throw new Error(`RADLoader: ${fieldName} must be a non-negative safe integer.`);
|
|
1147
|
-
}
|
|
1148
|
-
return Number(value);
|
|
1149
|
-
}
|
|
1150
|
-
function optionalSafeInteger(value, fieldName) {
|
|
1151
|
-
if (value === void 0) {
|
|
1152
|
-
return void 0;
|
|
1153
|
-
}
|
|
1154
|
-
return requireSafeInteger(value, fieldName);
|
|
1155
|
-
}
|
|
1156
|
-
function optionalFiniteNumber(value, fieldName) {
|
|
1157
|
-
if (value === void 0) {
|
|
1158
|
-
return void 0;
|
|
1159
|
-
}
|
|
1160
|
-
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1161
|
-
throw new Error(`RADLoader: ${fieldName} must be a finite number.`);
|
|
1162
|
-
}
|
|
1163
|
-
return value;
|
|
1164
|
-
}
|
|
1165
2190
|
function readSafeUint642(dataView, byteOffset, fieldName) {
|
|
1166
2191
|
const value = dataView.getBigUint64(byteOffset, true);
|
|
1167
2192
|
if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
@@ -1176,6 +2201,7 @@ var RAD_MAGIC, RAD_CHUNK_MAGIC, RAD_HEADER_BYTE_LENGTH, RAD_CHUNK_PAYLOAD_LENGTH
|
|
|
1176
2201
|
var init_parse_rad = __esm({
|
|
1177
2202
|
"dist/lib/parse-rad.js"() {
|
|
1178
2203
|
"use strict";
|
|
2204
|
+
init_rad_zod_schema();
|
|
1179
2205
|
RAD_MAGIC = 809779538;
|
|
1180
2206
|
RAD_CHUNK_MAGIC = 1128546642;
|
|
1181
2207
|
RAD_HEADER_BYTE_LENGTH = 8;
|
|
@@ -1184,6 +2210,94 @@ var init_parse_rad = __esm({
|
|
|
1184
2210
|
}
|
|
1185
2211
|
});
|
|
1186
2212
|
|
|
2213
|
+
// ../compression/src/lib/fflate-stream.ts
|
|
2214
|
+
async function* transformFflateBatches(processor, inputBatches) {
|
|
2215
|
+
const chunks = [];
|
|
2216
|
+
processor.ondata = (data) => {
|
|
2217
|
+
chunks.push(data.slice().buffer);
|
|
2218
|
+
};
|
|
2219
|
+
for await (const batch of inputBatches) {
|
|
2220
|
+
processor.push(new Uint8Array(batch), false);
|
|
2221
|
+
yield* chunks.splice(0);
|
|
2222
|
+
}
|
|
2223
|
+
processor.push(new Uint8Array(0), true);
|
|
2224
|
+
yield* chunks;
|
|
2225
|
+
}
|
|
2226
|
+
var init_fflate_stream = __esm({
|
|
2227
|
+
"../compression/src/lib/fflate-stream.ts"() {
|
|
2228
|
+
"use strict";
|
|
2229
|
+
}
|
|
2230
|
+
});
|
|
2231
|
+
|
|
2232
|
+
// ../compression/src/deflate-decompressor-fflate.ts
|
|
2233
|
+
var import_fflate, DeflateFflateDecompressor;
|
|
2234
|
+
var init_deflate_decompressor_fflate = __esm({
|
|
2235
|
+
"../compression/src/deflate-decompressor-fflate.ts"() {
|
|
2236
|
+
"use strict";
|
|
2237
|
+
import_fflate = require("fflate");
|
|
2238
|
+
init_compression();
|
|
2239
|
+
init_fflate_stream();
|
|
2240
|
+
DeflateFflateDecompressor = class extends Decompressor {
|
|
2241
|
+
name = "deflate";
|
|
2242
|
+
extensions = [];
|
|
2243
|
+
contentEncodings = ["deflate"];
|
|
2244
|
+
isSupported = true;
|
|
2245
|
+
options;
|
|
2246
|
+
constructor(options = {}) {
|
|
2247
|
+
super(options);
|
|
2248
|
+
this.options = options;
|
|
2249
|
+
}
|
|
2250
|
+
/** Decompresses one zlib-wrapped DEFLATE payload synchronously. */
|
|
2251
|
+
decompressSync(input) {
|
|
2252
|
+
const bytes = new Uint8Array(input);
|
|
2253
|
+
const output = this.options.raw ? (0, import_fflate.inflateSync)(bytes) : (0, import_fflate.unzlibSync)(bytes);
|
|
2254
|
+
return output.slice().buffer;
|
|
2255
|
+
}
|
|
2256
|
+
/** Decompresses DEFLATE batches incrementally. */
|
|
2257
|
+
async *decompressBatches(inputBatches) {
|
|
2258
|
+
const processor = this.options.raw ? new import_fflate.Inflate() : new import_fflate.Unzlib();
|
|
2259
|
+
yield* transformFflateBatches(processor, inputBatches);
|
|
2260
|
+
}
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
});
|
|
2264
|
+
|
|
2265
|
+
// ../compression/src/deflate-decompressor.ts
|
|
2266
|
+
var DeflateDecompressor2;
|
|
2267
|
+
var init_deflate_decompressor = __esm({
|
|
2268
|
+
"../compression/src/deflate-decompressor.ts"() {
|
|
2269
|
+
"use strict";
|
|
2270
|
+
init_deflate_decompressor_fflate();
|
|
2271
|
+
init_decompression_stream();
|
|
2272
|
+
DeflateDecompressor2 = class extends DeflateFflateDecompressor {
|
|
2273
|
+
constructor(options = {}) {
|
|
2274
|
+
super(options);
|
|
2275
|
+
}
|
|
2276
|
+
/** Decompresses with the built-in stream when available, then falls back to fflate. */
|
|
2277
|
+
async decompress(input) {
|
|
2278
|
+
if (this.options.useNative !== false) {
|
|
2279
|
+
const format = this.options.raw ? "deflate-raw" : "deflate";
|
|
2280
|
+
const output = await decompressWithNativeDecompressionStream(input, format);
|
|
2281
|
+
if (output) return output;
|
|
2282
|
+
}
|
|
2283
|
+
return this.decompressSync(input);
|
|
2284
|
+
}
|
|
2285
|
+
/** Decompresses batches with a built-in or fflate stream. */
|
|
2286
|
+
async *decompressBatches(inputBatches) {
|
|
2287
|
+
if (this.options.useNative !== false) {
|
|
2288
|
+
const format = this.options.raw ? "deflate-raw" : "deflate";
|
|
2289
|
+
const output = decompressBatchesWithNativeDecompressionStream(inputBatches, format);
|
|
2290
|
+
if (output) {
|
|
2291
|
+
yield* output;
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
yield* super.decompressBatches(inputBatches);
|
|
2296
|
+
}
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
});
|
|
2300
|
+
|
|
1187
2301
|
// dist/lib/parse-rad-chunk.js
|
|
1188
2302
|
function parseRADChunk(data, options) {
|
|
1189
2303
|
return makeGaussianSplatsArrowTable(parseRADChunkToGaussianSplats(data, options));
|
|
@@ -1281,9 +2395,9 @@ function decodeRADRotations(bytes, metadata, splatCount) {
|
|
|
1281
2395
|
const rotationOffset = splatIndex * 4;
|
|
1282
2396
|
const x = xyz[xyzOffset + 0];
|
|
1283
2397
|
const y = xyz[xyzOffset + 1];
|
|
1284
|
-
const
|
|
1285
|
-
const w = Math.sqrt(Math.max(0, 1 - x * x - y * y -
|
|
1286
|
-
const normalized = normalizeQuaternion(w, x, y,
|
|
2398
|
+
const z2 = xyz[xyzOffset + 2];
|
|
2399
|
+
const w = Math.sqrt(Math.max(0, 1 - x * x - y * y - z2 * z2));
|
|
2400
|
+
const normalized = normalizeQuaternion(w, x, y, z2);
|
|
1287
2401
|
rotations.set(normalized, rotationOffset);
|
|
1288
2402
|
}
|
|
1289
2403
|
return rotations;
|
|
@@ -1392,7 +2506,7 @@ function getRADPropertyBytes(bytes, metadata, property) {
|
|
|
1392
2506
|
return decompressRADProperty(propertyBytes, property.property);
|
|
1393
2507
|
}
|
|
1394
2508
|
function decompressRADProperty(bytes, propertyName) {
|
|
1395
|
-
const arrayBuffer =
|
|
2509
|
+
const arrayBuffer = copyToArrayBuffer3(bytes);
|
|
1396
2510
|
try {
|
|
1397
2511
|
return new Uint8Array(RAD_PROPERTY_DEFLATE.decompressSync(arrayBuffer));
|
|
1398
2512
|
} catch {
|
|
@@ -1517,8 +2631,8 @@ function decodeRADOct88R8Rotations(bytes, count) {
|
|
|
1517
2631
|
const rotations = new Float32Array(count * 4);
|
|
1518
2632
|
for (let splatIndex = 0; splatIndex < count; splatIndex++) {
|
|
1519
2633
|
const byteOffset = splatIndex * 3;
|
|
1520
|
-
const [x, y,
|
|
1521
|
-
rotations.set(normalizeQuaternion(w, x, y,
|
|
2634
|
+
const [x, y, z2, w] = decodeQuatOct888(bytes[byteOffset], bytes[byteOffset + 1], bytes[byteOffset + 2]);
|
|
2635
|
+
rotations.set(normalizeQuaternion(w, x, y, z2), splatIndex * 4);
|
|
1522
2636
|
}
|
|
1523
2637
|
return rotations;
|
|
1524
2638
|
}
|
|
@@ -1549,14 +2663,14 @@ function decodeScale8(scale, min, max) {
|
|
|
1549
2663
|
function decodeQuatOct888(u, v, r) {
|
|
1550
2664
|
let x = u / 255 * 2 - 1;
|
|
1551
2665
|
let y = v / 255 * 2 - 1;
|
|
1552
|
-
const
|
|
1553
|
-
const t = Math.max(-
|
|
2666
|
+
const z2 = 1 - Math.abs(x) - Math.abs(y);
|
|
2667
|
+
const t = Math.max(-z2, 0);
|
|
1554
2668
|
x = x >= 0 ? x - t : x + t;
|
|
1555
2669
|
y = y >= 0 ? y - t : y + t;
|
|
1556
|
-
const length = Math.hypot(x, y,
|
|
2670
|
+
const length = Math.hypot(x, y, z2);
|
|
1557
2671
|
const axisX = length > Number.EPSILON ? x / length : 1;
|
|
1558
2672
|
const axisY = length > Number.EPSILON ? y / length : 0;
|
|
1559
|
-
const axisZ = length > Number.EPSILON ?
|
|
2673
|
+
const axisZ = length > Number.EPSILON ? z2 / length : 0;
|
|
1560
2674
|
const halfTheta = r / 255 * 0.5 * Math.PI;
|
|
1561
2675
|
const sinHalfTheta = Math.sin(halfTheta);
|
|
1562
2676
|
return [axisX * sinHalfTheta, axisY * sinHalfTheta, axisZ * sinHalfTheta, Math.cos(halfTheta)];
|
|
@@ -1634,7 +2748,7 @@ function getSplatEncodingMaximum(splatEncoding, propertyName) {
|
|
|
1634
2748
|
function normalizeColorByte2(value) {
|
|
1635
2749
|
return Math.round(Math.min(Math.max(value, 0), 1) * 255);
|
|
1636
2750
|
}
|
|
1637
|
-
function
|
|
2751
|
+
function copyToArrayBuffer3(bytes) {
|
|
1638
2752
|
const copy = new Uint8Array(bytes.byteLength);
|
|
1639
2753
|
copy.set(bytes);
|
|
1640
2754
|
return copy.buffer;
|
|
@@ -1642,16 +2756,16 @@ function copyToArrayBuffer(bytes) {
|
|
|
1642
2756
|
function getUint8Array2(data) {
|
|
1643
2757
|
return data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
1644
2758
|
}
|
|
1645
|
-
var
|
|
2759
|
+
var RAD_PROPERTY_DEFLATE, RAD_PROPERTY_RAW_DEFLATE;
|
|
1646
2760
|
var init_parse_rad_chunk = __esm({
|
|
1647
2761
|
"dist/lib/parse-rad-chunk.js"() {
|
|
1648
2762
|
"use strict";
|
|
1649
|
-
|
|
2763
|
+
init_deflate_decompressor();
|
|
1650
2764
|
init_parse_rad();
|
|
1651
2765
|
init_splats_arrow_table();
|
|
1652
2766
|
init_splat_utils();
|
|
1653
|
-
RAD_PROPERTY_DEFLATE = new
|
|
1654
|
-
RAD_PROPERTY_RAW_DEFLATE = new
|
|
2767
|
+
RAD_PROPERTY_DEFLATE = new DeflateDecompressor2({ useNative: false });
|
|
2768
|
+
RAD_PROPERTY_RAW_DEFLATE = new DeflateDecompressor2({ raw: true, useNative: false });
|
|
1655
2769
|
}
|
|
1656
2770
|
});
|
|
1657
2771
|
|
|
@@ -1687,17 +2801,17 @@ async function preload4() {
|
|
|
1687
2801
|
const { RADLoaderWithParser: RADLoaderWithParser2 } = await Promise.resolve().then(() => (init_rad_loader(), rad_loader_exports));
|
|
1688
2802
|
return RADLoaderWithParser2;
|
|
1689
2803
|
}
|
|
1690
|
-
var
|
|
2804
|
+
var VERSION5, RADLoader;
|
|
1691
2805
|
var init_rad_loader_types = __esm({
|
|
1692
2806
|
"dist/rad-loader-types.js"() {
|
|
1693
2807
|
"use strict";
|
|
1694
2808
|
init_splats_format();
|
|
1695
|
-
|
|
2809
|
+
VERSION5 = true ? "5.0.0-alpha.3" : "latest";
|
|
1696
2810
|
RADLoader = {
|
|
1697
2811
|
dataType: null,
|
|
1698
2812
|
batchType: null,
|
|
1699
2813
|
...RADFormat,
|
|
1700
|
-
version:
|
|
2814
|
+
version: VERSION5,
|
|
1701
2815
|
options: {},
|
|
1702
2816
|
preload: preload4
|
|
1703
2817
|
};
|
|
@@ -1705,8 +2819,8 @@ var init_rad_loader_types = __esm({
|
|
|
1705
2819
|
});
|
|
1706
2820
|
|
|
1707
2821
|
// dist/index.js
|
|
1708
|
-
var
|
|
1709
|
-
__export(
|
|
2822
|
+
var index_exports = {};
|
|
2823
|
+
__export(index_exports, {
|
|
1710
2824
|
KSPLATFormat: () => KSPLATFormat,
|
|
1711
2825
|
KSPLATLoader: () => KSPLATLoader,
|
|
1712
2826
|
RADFormat: () => RADFormat,
|
|
@@ -1719,7 +2833,7 @@ __export(dist_exports, {
|
|
|
1719
2833
|
SPZLoader: () => SPZLoader,
|
|
1720
2834
|
resolveRADChunkUrl: () => resolveRADChunkUrl
|
|
1721
2835
|
});
|
|
1722
|
-
module.exports = __toCommonJS(
|
|
2836
|
+
module.exports = __toCommonJS(index_exports);
|
|
1723
2837
|
init_splats_format();
|
|
1724
2838
|
init_splat_loader_types();
|
|
1725
2839
|
init_ksplat_loader_types();
|
|
@@ -1727,20 +2841,20 @@ init_spz_loader_types();
|
|
|
1727
2841
|
init_rad_loader_types();
|
|
1728
2842
|
|
|
1729
2843
|
// dist/rad-source-loader.js
|
|
1730
|
-
|
|
2844
|
+
init_src();
|
|
1731
2845
|
init_splats_format();
|
|
1732
2846
|
init_parse_rad();
|
|
1733
2847
|
init_parse_rad_chunk();
|
|
1734
2848
|
init_splats_arrow_table();
|
|
1735
2849
|
var DEFAULT_RAD_HEADER_BYTE_LENGTHS = [64 * 1024, 256 * 1024, 1024 * 1024];
|
|
1736
2850
|
var DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS = 4;
|
|
1737
|
-
var
|
|
2851
|
+
var VERSION6 = true ? "5.0.0-alpha.3" : "latest";
|
|
1738
2852
|
var RADSourceLoader = {
|
|
1739
2853
|
dataType: null,
|
|
1740
2854
|
batchType: null,
|
|
1741
2855
|
...RADFormat,
|
|
1742
2856
|
name: "RADSourceLoader",
|
|
1743
|
-
version:
|
|
2857
|
+
version: VERSION6,
|
|
1744
2858
|
type: "rad",
|
|
1745
2859
|
fromUrl: true,
|
|
1746
2860
|
fromBlob: true,
|
|
@@ -1761,7 +2875,7 @@ var RADSourceLoader = {
|
|
|
1761
2875
|
testURL: (url) => /\.rad(?:$|[?#])/i.test(url),
|
|
1762
2876
|
createDataSource: (data, options, coreApi) => new RADSource(data, options, coreApi)
|
|
1763
2877
|
};
|
|
1764
|
-
var RADSource = class extends
|
|
2878
|
+
var RADSource = class extends DataSource {
|
|
1765
2879
|
/** Shared metadata promise exposed for source-style integrations. */
|
|
1766
2880
|
metadata;
|
|
1767
2881
|
/** Lazily initialized RAD header promise. */
|