mkkellogg / GaussianSplats3D

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

Load splats with opacity:0 #258

Closed jvandereijk closed 1 week ago

jvandereijk commented 1 week ago

Hi Mark,

Thanks for adding the opacity property to the splats, it opens a lot of new possibilities. However, I ran in to the issue that all splats are visible at start when loading with addSplatScenes. In some scenarios I would like to start with most splats hidden, and let splats appear on demand afterwards.

I tried adding the opacity property to the splat array properties like this:

viewer.addSplatScenes([{
        'path': '<path to first .ply, .ksplat, or .splat file>',
        'splatAlphaRemovalThreshold': 20
    },
    {
        'path': '<path to second .ply, .ksplat, or .splat file>',
        'rotation': [-0.14724434, -0.0761755, 0.1410657, 0.976020],
        'scale': [1.5, 1.5, 1.5],
        'position': [-3, -2, -3.2]
        'opacity': 0,
    }
])
.then(() => {
    viewer.start();
});

But that seems to be ignored. Do you know of another way to allow with opacity:0 ? or could you perhaps add this property to the addSplatScenes method as in the example above ?

mkkellogg commented 1 week ago

Ah, I didn't even think about setting opacity and/or visibility of splat scenes as part of the addSplatScenes() function, I'll definitely make sure to add that capability in the next release. In the mean time, I think you could just set the opacity to 0 right before calling viewer.start():

.then(() => {
    viewer.getSplatScene(<scene index>).opacity = 0.0;
    viewer.start();
});

You probably already know this, but you will also need to enable changing the opacity by passing a value of true for the enableOptionalEffects parameter for Viewer.

jvandereijk commented 1 week ago

Thanks! setting the opacity in the callback actually seems to work just fine !

And yes, I did find the enableOptionalEffects flag. I could not see any performance degradation visually yet (even on a 4 year old iphone). So far it works great :)

mkkellogg commented 1 week ago

Glad it worked for you!