mkkellogg / GaussianSplats3D

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

.KSPLAT is not visible in scene #187

Closed MarcelloPajntar97 closed 2 months ago

MarcelloPajntar97 commented 2 months ago

Hi @mkkellogg, i paste here the code that i use to load a simple .splat

const viewer = new GaussianSplats3D.Viewer({
  'selfDrivenMode': false,
  'renderer': renderer,
  'camera': camera,
  'useBuiltInControls': false,
  'ignoreDevicePixelRatio': false,
  'gpuAcceleratedSort': check ? false : true,
  'halfPrecisionCovariancesOnGPU':  check ? false : true,
  'sharedMemoryForWorkers': false,
  'integerBasedSort': true,
  'dynamicScene': false,
  'webXRMode': GaussianSplats3D.WebXRMode.None,

});
properToggle(true);
viewer.addSplatScene('../assets/splats/112.splat', {
  'splatAlphaRemovalThreshold': 11,
  'showLoadingSpinner': false,
  'position': [0, 2, 0],
  'rotation': [0, 0, 0, 1],
  'scale': [1, 1, 1]
})
  .then(() => {
    requestAnimationFrame(update);
    if (document.querySelector(".loader-container")){
      document.querySelector(".loader-container").classList.add("loaded")
      setTimeout(() => {
        document.querySelector(".loader-container").style.display = "none";
      }, 400);
    }

    // setTimeout(() => {
      animateStuff();
    // }, 5000);

  });

The code Works well but when i put a .ksplat compression i cant view gaussian in scene

mkkellogg commented 2 months ago

Is there an error is the browser debug console? Often if there is a problem loading a file a helpful message will be there. If you want to share the .ksplat I can try to load it on my end to debug. Also, have you tried loading it on the demo page: https://projects.markkellogg.org/threejs/demo_gaussian_splats_3d.php

MarcelloPajntar97 commented 2 months ago

Hi, i've already tried to load in your demo and always works well. I've no error in console but i notice that the voice Avg splat count per node in console return Nan i believe that could be a potential problem.

Screenshot 2024-04-02 alle 18 20 47
mkkellogg commented 2 months ago

Well I'm not sure what the error could be based on the above console output, but clearly something is going wrong during loading of the scene. I don't think I can do much else to troubleshoot from here, would you be willing to share your model and I can try to debug on my end?

MarcelloPajntar97 commented 2 months ago

https://we.tl/t-0MD8Ga1W9d here you can download .ksplat file, converted using your tool. Let me know. Thx :)

mkkellogg commented 2 months ago

I can definitely load that .ksplat just fine on my end, could you also post the code for your update() and animateStuff() functions? Also what version of my library are you using?

MarcelloPajntar97 commented 2 months ago
function update() {
    if (document.getElementById("cnvs").style.display === "block") {
      angle += 0.001; 
      camera.position.x = Math.sin(angle) * orbitRadius;
      camera.position.z = Math.cos(angle) * orbitRadius;
      const lookX = Math.sin(lookAngleX);
      const lookZ = Math.cos(lookAngleX);
      const lookY = Math.sin(lookAngleY);

      if (orbitRadius < mouseLookThreshold) {
        camera.position.y = posY;
        camera.lookAt(camera.position.x + lookX,camera.position.y + lookY,camera.position.z + lookZ);
      } else {
        camera.lookAt(0, 0, 0);
      }

      viewer.update();
      viewer.render();
    }
    requestAnimationFrame(update);
  }

  function animateStuff() {
    let tl = gsap.timeline({
      repeat: -1,
      delay: 5,
      yoyo: true,
      defaults: { ease: "sine.inOut" },
      onUpdate: function () {
        orbitRadius = orbit.radius;
      },
    });

  tl.// Move closer quickly
    to(orbit, { radius: 2, duration: 1.5 }) 
    .to(orbit, { radius: 2, duration: pauseAtStartDuration, immediateRender: false })
    .to(orbit, { radius: 30, duration: 1.5 })
    .to(orbit, { radius: 30, duration: pauseAtCloseDuration, immediateRender: false });
  }

I'm using 0.2.3 version

MarcelloPajntar97 commented 2 months ago

im really sorry but i've just updated version to latest (0.3.6) and always works good now! sorry for wating your time

mkkellogg commented 2 months ago

No problem, glad you figured it out!