mkkellogg / GaussianSplats3D

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

Loading Issues with Cached Splats? #237

Closed timothyallan closed 4 months ago

timothyallan commented 4 months ago

Sorry in advance, but this is one of those "can't replicate" issues :)

I'm loading the .splat files like this:

     const viewer = new DropInViewer({
          gpuAcceleratedSort: true,
          sharedMemoryForWorkers: false,
          sphericalHarmonicsDegree: 0,
          splatAlphaRemovalThreshold: 5,
        });

       scene.add(viewer);

...

   viewer.addSplatScene(path, {
            splatAlphaRemovalThreshold: 5,
            format,
            showLoadingUI: false,
            showLoadingSpinner: false,
            streamView: true,
          })

Myself and a couple other testers have been running into this issue where the Splat isn't loaded correctly if we've already loaded it multiple times. The only way I've been able to fix it, is to open up dev tools, disable the cache and reload. This is on our staging site where the code hasn't changed in days, so it's not something related to building/compiling other javascript.

Seems to only happen in Chrome, although again that might be because it's the one I primarily use for dev/testing and the issue requires multiple re-loads of the same splat.

Currently using Release v0.4.1, although it was happening with previous versions as well.

Screenshot 2024-05-21 at 5 31 58 PM

Here's a couple before/afters in case it visually shows you anything:

Screenshot 2024-05-21 at 5 46 46 PM Screenshot 2024-05-21 at 5 46 40 PM Screenshot 2024-05-21 at 5 46 12 PM Screenshot 2024-05-21 at 5 37 01 PM

Edit: It seems to be a race condition somewhere, which probably explains why it happens only on the compiled staging site, and not on the slower dev stuff.

If I throttle the network, it still loads from the cache, and the splat appears fine all the time. Changing the network throttle back to none and reloading the page give me the messed up view consistently.

Screenshot 2024-05-22 at 1 30 43 PM

timothyallan commented 4 months ago

The issue is that I attach an object to the Drop in Viewer after onProgress hits 1, but it seems like there's something else that needs to run internally after that, and my object botches it up.

If I ignore the onProgress and just us a then() after viewer.addSplatScene, my object attaches fine, and the splat renders correctly all the time.

mkkellogg commented 4 months ago

Ah, so onProgress() will show progress for both downloading the splat scene and then for processing the scene after download. It has 3 parameters: percentComplete (ranges from 0 to 1), percentCompleteLabel (text version of percentComplete) and a parameter that describes the current task. For each of those tasks the percentComplete value ranges from 0 to 1, so you're probably trying to do something after the scene is downloaded, but before it is processed.

timothyallan commented 4 months ago

That'd do it! think there's multiple issues actually:

Adding my object after the train .splat was done processing fixed that issue, but the tractor .ply file was only loading portions correctly.

It would have visible seams either right down the middle, or in 4 squares, where 3 squares were not loaded properly... on a guess, I set streamView: false on the viewer, and magically it now loads fine every time. Will have to do some more investigation it looks like. Thanks for the help.