Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load another Splat resource #37

Closed
yufeng1103 opened this issue Nov 2, 2023 · 6 comments
Closed

Load another Splat resource #37

yufeng1103 opened this issue Nov 2, 2023 · 6 comments

Comments

@yufeng1103
Copy link

I am loading another Splat in the garden scene, which may cause occlusion issues. When I move the camera's perspective, the table will disappear, and I cannot find the reason for it

微信图片_20231102165400
微信图片_20231102165407

@mkkellogg
Copy link
Owner

I have never tried to load more than one .splat scene at a time, and my immediate guess is that it won't work correctly simply because it is not currently designed to work that way. Ultimately I plan on adding support for loading &viewing multiple .splat files simultaneously. Can you share your code and maybe I can see if there's a quick work-around in the mean-time?

@yufeng1103
Copy link
Author

Yeah,Due to the urgent need to implement the rendering effects of two splats, I have only made simple modifications to your code as follows

const group = new THREE.Group();
const viewer = new GaussianSplats3D.Viewer({
  'cameraUp': [0, -1, -0.54],
  'initialCameraPosition': [-3.15634, -0.16946, -0.51552],
  'initialCameraLookAt': [1.52976, 2.27776, 1.65898],
  'group': group
});

viewer.init();

let path = 'assets/data/garden/garden';
path += isMobile() ? '.splat' : '_high.splat';

viewer.loadFile(path, {
    'halfPrecisionCovariancesOnGPU': true
})
.then(() => {
  path = 'assets/data/garden/pingzi_high.splat';
  viewer.loadFile(path, {
      'halfPrecisionCovariancesOnGPU': false
  }).then(() => {
    group.children[1].position.set(0,1.3,-0.5);
    group.children[1].scale.set(0.3,0.3,0.3);
    viewer.start();
  });
});

;

    this.splatMesh = SplatMesh.buildMesh(splatBuffer, splatAlphaRemovalThreshold, halfPrecisionCovariancesOnGPU);

    this.splatMesh.position.copy(position);

    this.splatMesh.quaternion.copy(quaternion);

    this.splatMesh.frustumCulled = false;

    this.splatMesh.renderOrder = 10;

    this.group.add(this.splatMesh);
    
    this.updateSplatMeshUniforms();

this.renderer.render(this.group, this.camera);

It seems that I just loaded it in and didn't do any other work,

@mkkellogg
Copy link
Owner

Right now when you load a splat mesh into the viewer via loadFile(), it stores that mesh internally using a single member variable (above it is this.splatMesh). So when you load a second splat file, the first one gets overwritten. That's why in the above screen shots you're only seeing the second splat mesh render correctly. There really isn't a great way to force the viewer to support multiple simultaneous splat meshes right now. You might try creating two instances of Viewer and passing in your own three.js renderer with autoClear set to false because Viewer.render() clears the screen before rendering. It still won't look quite right because the splats for each scene would be sorted separately.

@yufeng1103
Copy link
Author

Thank you for your suggestion. I will continue to try

@mkkellogg
Copy link
Owner

@yufeng1103 I'm not sure if you're still interested, but I just released a version that supports loading multiple splats simultaneously via the Viewer.loadFiles() function: v0.1.3

@yufeng1103
Copy link
Author

@yufeng1103 I'm not sure if you're still interested, but I just released a version that supports loading multiple splats simultaneously via the Viewer.loadFiles() function: v0.1.3

Great job, I just saw your reply, it's a big improvement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants