Remove obsolete code

This commit is contained in:
Andreas Sundquist
2025-05-30 10:49:49 -07:00
parent 7defe60edb
commit 8b5f854848
25 changed files with 5267 additions and 7213 deletions
-14
View File
@@ -73,7 +73,6 @@ export class SplatLoader extends Loader {
export enum SplatFileType {
PLY = "ply",
WLG0 = "wlg0",
SPZ = "spz",
SPLAT = "splat",
KSPLAT = "ksplat",
@@ -86,9 +85,6 @@ export function getSplatFileType(
if ((view.getUint32(0, true) & 0x00ffffff) === 0x00796c70) {
return SplatFileType.PLY;
}
if (view.getUint32(0, true) === 0x30474c57) {
return SplatFileType.WLG0;
}
if ((view.getUint32(0, true) & 0x00ffffff) === 0x00088b1f) {
// Gzipped file, unpack beginning to check magic number
const header = decompressPartialGzip(fileBytes, 4);
@@ -125,9 +121,6 @@ export function getSplatFileTypeFromPath(
if (extension === "ply") {
return SplatFileType.PLY;
}
if (extension === "wlg") {
return SplatFileType.WLG0;
}
if (extension === "spz") {
return SplatFileType.SPZ;
}
@@ -164,13 +157,6 @@ export async function unpackSplats({
}
switch (splatFileType) {
case SplatFileType.WLG0:
return await withWorker(async (worker) => {
const { packedArray, numSplats } = (await worker.call("decodeWlg", {
fileBytes,
})) as { packedArray: Uint32Array; numSplats: number };
return { packedArray, numSplats };
});
case SplatFileType.PLY: {
const ply = new PlyReader({ fileBytes });
await ply.parseHeader();
-34
View File
@@ -8,9 +8,7 @@ import {
} from "./SplatLoader";
import { GunzipReader, fromHalf, unpackSplat } from "./utils";
import init_wasm, { decode_wlg } from "forge-internal-rs";
import { decodeAntiSplat } from "./antisplat";
import { SPLAT_TEX_HEIGHT, SPLAT_TEX_WIDTH } from "./defines";
import { decodeKsplat } from "./ksplat";
import { PlyReader } from "./ply";
@@ -463,38 +461,6 @@ export async function transcodeSpz(input: TranscodeSpzInput) {
}
}
switch (fileType) {
case SplatFileType.WLG0: {
await init_wasm();
const decoded = decode_wlg(
input.fileBytes,
SPLAT_TEX_WIDTH,
SPLAT_TEX_HEIGHT,
) as { numSplats: number; packedSplats: Uint32Array };
for (let i = 0; i < decoded.numSplats; ++i) {
let { center, scales, quaternion, opacity, color } = unpackSplat(
decoded.packedSplats,
i,
);
center = transformPos(center);
if (withinClip(center) && withinOpacity(opacity)) {
const index = splats.pushSplat();
splats.setCenter(index, center.x, center.y, center.z);
scales = transformScales(scales);
splats.setScale(index, scales.x, scales.y, scales.z);
quaternion = transformQuaternion(quaternion);
splats.setQuaternion(
index,
quaternion.x,
quaternion.y,
quaternion.z,
quaternion.w,
);
splats.setOpacity(index, opacity);
splats.setColor(index, color.r, color.g, color.b);
}
}
break;
}
case SplatFileType.PLY: {
const ply = new PlyReader({ fileBytes: input.fileBytes });
await ply.parseHeader();
+9 -41
View File
@@ -1,8 +1,4 @@
import init_wasm, {
decode_wlg,
old_sort_splats,
sort_splats,
} from "forge-internal-rs";
import init_wasm, { sort_splats } from "forge-internal-rs";
import type { TranscodeSpzInput } from "./SplatLoader";
import { unpackAntiSplat } from "./antisplat";
import {
@@ -57,20 +53,6 @@ async function onMessage(event: MessageEvent) {
};
break;
}
case "decodeWlg": {
const { fileBytes } = args as { fileBytes: Uint8Array };
const decoded = decode_wlg(
fileBytes,
SPLAT_TEX_WIDTH,
SPLAT_TEX_HEIGHT,
) as { numSplats: number; packedSplats: Uint32Array };
result = {
id,
numSplats: decoded.numSplats,
packedArray: decoded.packedSplats,
};
break;
}
case "decodeSpz": {
const { fileBytes } = args as { fileBytes: Uint8Array };
const decoded = unpackSpz(fileBytes);
@@ -113,25 +95,11 @@ async function onMessage(event: MessageEvent) {
ordering: Uint32Array;
};
// Sort totalSplats splats each with 4 bytes of readback, and outputs Uint32Array ordering of splat indices
if (WASM_SPLAT_SORT) {
result = {
id,
readback,
ordering,
activeSplats: old_sort_splats(
maxSplats,
totalSplats,
readback,
ordering,
),
};
} else {
result = {
id,
readback,
...oldSortSplats({ totalSplats, readback, ordering }),
};
}
result = {
id,
readback,
...sortSplats({ totalSplats, readback, ordering }),
};
break;
}
case "sortDoubleSplats": {
@@ -158,7 +126,7 @@ async function onMessage(event: MessageEvent) {
result = {
id,
readback,
...sortSplats({ numSplats, readback, ordering }),
...sortDoubleSplats({ numSplats, readback, ordering }),
};
}
break;
@@ -322,7 +290,7 @@ const DEPTH_INFINITY = 0x7c00;
const DEPTH_SIZE = DEPTH_INFINITY + 1;
let depthArray: Uint32Array | null = null;
function oldSortSplats({
function sortSplats({
totalSplats,
readback,
ordering,
@@ -386,7 +354,7 @@ function oldSortSplats({
// Sort numSplats splats, each with 2 bytes of float16 readback for distance metric,
// using one bucket sort pass, outputting Uint32Array of indices.
function sortSplats({
function sortDoubleSplats({
numSplats,
readback,
ordering,