@d5techs/3dgs-lib 1.4.24 → 1.4.25
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/dist/3dgs-lib.cjs +11 -0
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +11 -0
- package/dist/3dgs-lib.js.map +1 -1
- package/package.json +1 -1
package/dist/3dgs-lib.js
CHANGED
|
@@ -6624,12 +6624,14 @@ async function encodeWebP(width, height, pixelData) {
|
|
|
6624
6624
|
}
|
|
6625
6625
|
return new Uint8Array(await blob.arrayBuffer());
|
|
6626
6626
|
}
|
|
6627
|
+
const yieldToUI = () => new Promise((r) => setTimeout(r, 0));
|
|
6627
6628
|
async function serializeSOG(data, coordinateSystem = "blender", options = {}, onProgress) {
|
|
6628
6629
|
const { maxSHBands = 3, iterations = 10, paletteSize = 1024 } = options;
|
|
6629
6630
|
const { count, colors, opacities } = data;
|
|
6630
6631
|
let { positions, scales, rotations } = data;
|
|
6631
6632
|
let shCoeffs = data.shCoeffs ? new Float32Array(data.shCoeffs) : void 0;
|
|
6632
6633
|
onProgress == null ? void 0 : onProgress("coord_transform", 0);
|
|
6634
|
+
await yieldToUI();
|
|
6633
6635
|
if (coordinateSystem === "blender") {
|
|
6634
6636
|
positions = new Float32Array(positions);
|
|
6635
6637
|
scales = new Float32Array(scales);
|
|
@@ -6653,6 +6655,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
|
|
|
6653
6655
|
}
|
|
6654
6656
|
}
|
|
6655
6657
|
onProgress == null ? void 0 : onProgress("morton_sort", 0.05);
|
|
6658
|
+
await yieldToUI();
|
|
6656
6659
|
const sortOrder = mortonSort(positions, count);
|
|
6657
6660
|
const sPos = new Float32Array(count * 3);
|
|
6658
6661
|
const sSca = new Float32Array(count * 3);
|
|
@@ -6686,6 +6689,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
|
|
|
6686
6689
|
const { width, height } = calcImageDimensions(count);
|
|
6687
6690
|
const totalPixels = width * height;
|
|
6688
6691
|
onProgress == null ? void 0 : onProgress("encode_position", 0.1);
|
|
6692
|
+
await yieldToUI();
|
|
6689
6693
|
const logPos = new Float32Array(count * 3);
|
|
6690
6694
|
for (let i = 0; i < count * 3; i++) logPos[i] = symLog(sPos[i]);
|
|
6691
6695
|
const mins = [Infinity, Infinity, Infinity];
|
|
@@ -6714,6 +6718,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
|
|
|
6714
6718
|
meansUData[off + 3] = 255;
|
|
6715
6719
|
}
|
|
6716
6720
|
onProgress == null ? void 0 : onProgress("encode_scale", 0.2);
|
|
6721
|
+
await yieldToUI();
|
|
6717
6722
|
const logScales = new Float32Array(count * 3);
|
|
6718
6723
|
for (let i = 0; i < count * 3; i++) logScales[i] = Math.log(Math.max(1e-8, sSca[i]));
|
|
6719
6724
|
const scaleCodebook = buildCodebook(logScales, 256);
|
|
@@ -6727,6 +6732,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
|
|
|
6727
6732
|
scalesData[off + 3] = 255;
|
|
6728
6733
|
}
|
|
6729
6734
|
onProgress == null ? void 0 : onProgress("encode_quaternion", 0.3);
|
|
6735
|
+
await yieldToUI();
|
|
6730
6736
|
const quatsData = new Uint8ClampedArray(totalPixels * 4);
|
|
6731
6737
|
quatsData.fill(255);
|
|
6732
6738
|
const SQRT2 = Math.SQRT2;
|
|
@@ -6780,6 +6786,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
|
|
|
6780
6786
|
quatsData[off + 3] = largest + 252;
|
|
6781
6787
|
}
|
|
6782
6788
|
onProgress == null ? void 0 : onProgress("encode_color", 0.4);
|
|
6789
|
+
await yieldToUI();
|
|
6783
6790
|
const dcValues = new Float32Array(count * 3);
|
|
6784
6791
|
for (let i = 0; i < count; i++) {
|
|
6785
6792
|
dcValues[i * 3] = (sCol[i * 3] - 0.5) / SH_C0;
|
|
@@ -6809,6 +6816,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
|
|
|
6809
6816
|
];
|
|
6810
6817
|
if (actualBands > 0 && sSH) {
|
|
6811
6818
|
onProgress == null ? void 0 : onProgress("sh_compress", 0.5);
|
|
6819
|
+
await yieldToUI();
|
|
6812
6820
|
const pointsFlat = new Float32Array(count * shDim);
|
|
6813
6821
|
for (let i = 0; i < count; i++) {
|
|
6814
6822
|
const b = i * 45;
|
|
@@ -6827,6 +6835,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
|
|
|
6827
6835
|
}
|
|
6828
6836
|
);
|
|
6829
6837
|
onProgress == null ? void 0 : onProgress("sh_quantize", 0.88);
|
|
6838
|
+
await yieldToUI();
|
|
6830
6839
|
const allCoeffValues = new Float32Array(effectivePaletteSize * shDim);
|
|
6831
6840
|
for (let c = 0; c < effectivePaletteSize; c++) {
|
|
6832
6841
|
for (let d = 0; d < shDim; d++) allCoeffValues[c * shDim + d] = centroids[c * shDim + d];
|
|
@@ -6869,6 +6878,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
|
|
|
6869
6878
|
};
|
|
6870
6879
|
}
|
|
6871
6880
|
onProgress == null ? void 0 : onProgress("encode_webp", 0.92);
|
|
6881
|
+
await yieldToUI();
|
|
6872
6882
|
const webps = await Promise.all(webpPromises);
|
|
6873
6883
|
const [meansLWebP, meansUWebP, scalesWebP, quatsWebP, sh0WebP] = webps;
|
|
6874
6884
|
const meta = {
|
|
@@ -6895,6 +6905,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
|
|
|
6895
6905
|
zipEntries["sh_labels.webp"] = webps[6];
|
|
6896
6906
|
}
|
|
6897
6907
|
onProgress == null ? void 0 : onProgress("pack_zip", 0.98);
|
|
6908
|
+
await yieldToUI();
|
|
6898
6909
|
const zipData = zipSync(zipEntries, { level: 0 });
|
|
6899
6910
|
onProgress == null ? void 0 : onProgress("done", 1);
|
|
6900
6911
|
return zipData.buffer;
|