mkkellogg / GaussianSplats3D

Three.js-based implementation of 3D Gaussian splatting
MIT License
1.5k stars 196 forks source link

Decompressing Texture in Viewer #367

Closed GuoFengYung closed 2 hours ago

GuoFengYung commented 5 days ago

Hi! If I compress the file into a texture format according to the method in this paper to reduce model size, should I start from the loader to decompress it in the viewer?

GuoFengYung commented 23 hours ago

Hi, I have already written a decompression parser that returns a blob format of the 3DGS PLY file. I want to directly use your parser to convert and render the results, but currently, I've only converted it into a splat array. Could you please guide me on how to render the result? My code:

  try {
    const splats = await decompressor.decompress(compressDir);
    console.log('decompress:', splats);
    const plySaver = new PlySaver(splats, 3);
    plySaver.extractData();
    plySaver.prepareVertices();
    const plyBuffer = plySaver.save();  // Get the blob
    const reader = new FileReader();

    reader.onload = function(event) {
        const arrayBuffer = event.target.result;
        const splatArray = GaussianSplats3D.PlyParser.parseToUncompressedSplatArray(arrayBuffer,0);
        console.log(splatArray);
    };

    reader.readAsArrayBuffer(plyBuffer);

  } catch (err) {
    console.error('decompress fail:', err);
  }
})();

splatArray: image

mkkellogg commented 10 hours ago

You would probably need to update the PLY loader code to decompress the data. Specifically at this line: https://github.com/mkkellogg/GaussianSplats3D/blob/f6f4adea2e0a5745f942767214c7d3b335a10751/src/loaders/ply/PlyLoader.js#L284 The file data would be in plyFileData and it would need to be decompressed before being passed to PlyParser.parseToUncompressedSplatArray()