@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 CHANGED
@@ -6626,12 +6626,14 @@ async function encodeWebP(width, height, pixelData) {
6626
6626
  }
6627
6627
  return new Uint8Array(await blob.arrayBuffer());
6628
6628
  }
6629
+ const yieldToUI = () => new Promise((r) => setTimeout(r, 0));
6629
6630
  async function serializeSOG(data, coordinateSystem = "blender", options = {}, onProgress) {
6630
6631
  const { maxSHBands = 3, iterations = 10, paletteSize = 1024 } = options;
6631
6632
  const { count, colors, opacities } = data;
6632
6633
  let { positions, scales, rotations } = data;
6633
6634
  let shCoeffs = data.shCoeffs ? new Float32Array(data.shCoeffs) : void 0;
6634
6635
  onProgress == null ? void 0 : onProgress("coord_transform", 0);
6636
+ await yieldToUI();
6635
6637
  if (coordinateSystem === "blender") {
6636
6638
  positions = new Float32Array(positions);
6637
6639
  scales = new Float32Array(scales);
@@ -6655,6 +6657,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
6655
6657
  }
6656
6658
  }
6657
6659
  onProgress == null ? void 0 : onProgress("morton_sort", 0.05);
6660
+ await yieldToUI();
6658
6661
  const sortOrder = mortonSort(positions, count);
6659
6662
  const sPos = new Float32Array(count * 3);
6660
6663
  const sSca = new Float32Array(count * 3);
@@ -6688,6 +6691,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
6688
6691
  const { width, height } = calcImageDimensions(count);
6689
6692
  const totalPixels = width * height;
6690
6693
  onProgress == null ? void 0 : onProgress("encode_position", 0.1);
6694
+ await yieldToUI();
6691
6695
  const logPos = new Float32Array(count * 3);
6692
6696
  for (let i = 0; i < count * 3; i++) logPos[i] = symLog(sPos[i]);
6693
6697
  const mins = [Infinity, Infinity, Infinity];
@@ -6716,6 +6720,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
6716
6720
  meansUData[off + 3] = 255;
6717
6721
  }
6718
6722
  onProgress == null ? void 0 : onProgress("encode_scale", 0.2);
6723
+ await yieldToUI();
6719
6724
  const logScales = new Float32Array(count * 3);
6720
6725
  for (let i = 0; i < count * 3; i++) logScales[i] = Math.log(Math.max(1e-8, sSca[i]));
6721
6726
  const scaleCodebook = buildCodebook(logScales, 256);
@@ -6729,6 +6734,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
6729
6734
  scalesData[off + 3] = 255;
6730
6735
  }
6731
6736
  onProgress == null ? void 0 : onProgress("encode_quaternion", 0.3);
6737
+ await yieldToUI();
6732
6738
  const quatsData = new Uint8ClampedArray(totalPixels * 4);
6733
6739
  quatsData.fill(255);
6734
6740
  const SQRT2 = Math.SQRT2;
@@ -6782,6 +6788,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
6782
6788
  quatsData[off + 3] = largest + 252;
6783
6789
  }
6784
6790
  onProgress == null ? void 0 : onProgress("encode_color", 0.4);
6791
+ await yieldToUI();
6785
6792
  const dcValues = new Float32Array(count * 3);
6786
6793
  for (let i = 0; i < count; i++) {
6787
6794
  dcValues[i * 3] = (sCol[i * 3] - 0.5) / SH_C0;
@@ -6811,6 +6818,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
6811
6818
  ];
6812
6819
  if (actualBands > 0 && sSH) {
6813
6820
  onProgress == null ? void 0 : onProgress("sh_compress", 0.5);
6821
+ await yieldToUI();
6814
6822
  const pointsFlat = new Float32Array(count * shDim);
6815
6823
  for (let i = 0; i < count; i++) {
6816
6824
  const b = i * 45;
@@ -6829,6 +6837,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
6829
6837
  }
6830
6838
  );
6831
6839
  onProgress == null ? void 0 : onProgress("sh_quantize", 0.88);
6840
+ await yieldToUI();
6832
6841
  const allCoeffValues = new Float32Array(effectivePaletteSize * shDim);
6833
6842
  for (let c = 0; c < effectivePaletteSize; c++) {
6834
6843
  for (let d = 0; d < shDim; d++) allCoeffValues[c * shDim + d] = centroids[c * shDim + d];
@@ -6871,6 +6880,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
6871
6880
  };
6872
6881
  }
6873
6882
  onProgress == null ? void 0 : onProgress("encode_webp", 0.92);
6883
+ await yieldToUI();
6874
6884
  const webps = await Promise.all(webpPromises);
6875
6885
  const [meansLWebP, meansUWebP, scalesWebP, quatsWebP, sh0WebP] = webps;
6876
6886
  const meta = {
@@ -6897,6 +6907,7 @@ async function serializeSOG(data, coordinateSystem = "blender", options = {}, on
6897
6907
  zipEntries["sh_labels.webp"] = webps[6];
6898
6908
  }
6899
6909
  onProgress == null ? void 0 : onProgress("pack_zip", 0.98);
6910
+ await yieldToUI();
6900
6911
  const zipData = zipSync(zipEntries, { level: 0 });
6901
6912
  onProgress == null ? void 0 : onProgress("done", 1);
6902
6913
  return zipData.buffer;