mkkellogg / GaussianSplats3D

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

Accessing Splats Bounds on Load #170

Closed EliCDavis closed 3 months ago

EliCDavis commented 3 months ago

In a previous version, when the splat is loaded, I accessed guassianSplatViewer.splatMesh.splatTree.subTrees[0] and grabbed it's sceneMin and sceneMax to build an AABB.

I've recently updated to the latest, and have noticed on load, guassianSplatViewer.splatMesh.splatTree isn't set immediately.

Is there something I should subscribe to be notified when the splat tree is set? Is there a better way to get the bounds of the splat?

mkkellogg commented 3 months ago

This is an interesting use case that I was unaware of. As part of adding progressive loading functionality, I moved construction of the splat tree to a worker thread so that users could start interacting with the scene before the splat tree is built (because it can sometimes take multiple seconds to construct). Currently there's no built in way to be notified when it is ready, but it sounds like I need to add a mechanism to do that. Are you using the NPM library or building from source? If you're building from source I could show you a temporary work around (or maybe I can just make the change and push to my dev branch).

EliCDavis commented 3 months ago

Building from source atm, also down for just pulling from the dev branch, this is all hobby stuff for polyform.

mkkellogg commented 3 months ago

Ok I just pushed the update to dev, you should now be able to do something like:

viewer.addSplatScene(path)
.then(() => {
    viewer.start();
    viewer.splatMesh.onSplatTreeReady((splatTree) => {
         console.log(splatTree);
    });
});
EliCDavis commented 3 months ago

Ayy that did the trick! thanks!

mkkellogg commented 3 months ago

great! I'll make sure the update gets added to the next release.