Giter Site home page Giter Site logo

drop in viewer about gaussiansplats3d HOT 6 OPEN

lewibs avatar lewibs commented on September 4, 2024
drop in viewer

from gaussiansplats3d.

Comments (6)

mkkellogg avatar mkkellogg commented on September 4, 2024 1

Do you see any errors in the console? My guess is that you're getting an error telling you that you can't add a splat scene while another load is already in progress. The issue is this loop:

 splats.map((url)=>
    this.splatViewer.addSplatScene(url, {
        'splatAlphaRemovalThreshold': 5,
        'position': [0, 0, 0],
        'rotation': [0, 0, 1, 0],
        //'scale': [scale, scale, scale],
        "showLoadingUI": false,
        "onProgress": onProgress,
    })
)

That would fire off multiple simultaneous calls to addSplatScene(), which is not supported. If you want to load multiple scenes simultaneously you can use the addSplatScenes() function, otherwise you need to wait until one call to addSplatScene() has finished before issuing the next call.

from gaussiansplats3d.

lewibs avatar lewibs commented on September 4, 2024

I fixed that. No errors and still nothing. Just a black screen with the objects I put inside it

from gaussiansplats3d.

mkkellogg avatar mkkellogg commented on September 4, 2024

Other than that, I don't see anything wrong, it should work. For what it's worth I was able to take your above code and get it working by putting it inside a class (with minor tweaks):

const renderWidth = 800;
const renderHeight = 600;

class Engine {

  constructor() {

  const that = this;
  function animate() {
      requestAnimationFrame(animate);
      that.renderer.render(that.scene, that.camera);
  }

  this.scene = new THREE.Scene();
  this.camera = new THREE.PerspectiveCamera(75, renderWidth / renderHeight, 0.1, 1000);
  this.camera.position.set(20, 20, 20);
  this.camera.lookAt(0,0,0)

  this.renderer = new THREE.WebGLRenderer();
  this.renderer.setSize(window.innerWidth,window.innerHeight);

  this.controls = new GaussianSplats3D.OrbitControls(this.camera, this.renderer.domElement);
  this.controls.listenToKeyEvents(window);
  this.controls.rotateSpeed = 0.5;
  this.controls.maxPolarAngle = Math.PI * .75;
  this.controls.minPolarAngle = 0.1;
  this.controls.enableDamping = true;
  this.controls.dampingFactor = 0.05;
  this.controls.target.copy(new THREE.Vector3(0,0,0));
  this.controls.update()

  this.splatViewer = new GaussianSplats3D.DropInViewer({
      'gpuAcceleratedSort': true,
      // 'cameraUp': [0, 1, 0],
      // 'initialCameraPosition': [0.1, 0.1, 0.1],
      // 'initialCameraLookAt': [0, 0, 0],
      //"ignoreDevicePixelRatio": true, //speed
      //"dynamicScene": true, //speed
      //'useBuiltInControls': false,
      //'webXRMode': GaussianSplats3D.WebXRMode.None,
      "sharedMemoryForWorkers": false, //TODO get this to work without bugs when set to true
  });
  this.scene.add(this.splatViewer);

  const rootElement = document.createElement('div');
  rootElement.style.width = renderWidth + 'px';
  rootElement.style.height = renderHeight + 'px';
  rootElement.style.position = 'relative';
  rootElement.style.left = '50%';
  rootElement.style.top = '50%';
  rootElement.style.transform = 'translate(-50%, -50%)';
  document.body.appendChild(rootElement);

  this.renderer.domElement.style.position = 'fixed';
  this.renderer.domElement.style.top = '0';
  this.renderer.domElement.style.left = '0';
  this.renderer.domElement.style.width = '100%';
  this.renderer.domElement.style.height = '100%';
  rootElement.appendChild(this.renderer.domElement);

  let ambientLight = new THREE.AmbientLight( 0xffffff, 1 );
  this.scene.add(ambientLight);

  let hemisphereLight = new THREE.HemisphereLight(0xffffff, 3);
  this.scene.add(hemisphereLight);

  animate();
  
  this.splatViewer.addSplatScenes([
    {
      'path': 'assets/data/garden/garden_high.ksplat',
      'splatAlphaRemovalThreshold': 20,
    },
    {
      'path': 'assets/data/bonsai/bonsai_trimmed.ksplat',
      'rotation': [-0.14724434, -0.0761755, 0.1410657, 0.976020],
      'scale': [1.5, 1.5, 1.5],
      'position': [-3, -2, -3.2],
      'splatAlphaRemovalThreshold': 20,
    }
  ], true);
  }

}

new Engine();

from gaussiansplats3d.

lewibs avatar lewibs commented on September 4, 2024

Even with your changes no luck. Not sure whats up with that. Ill keep looking into it I suppose. The only reason I want to do the drop in viewer is cause the splat is not a major part of what im doing. However, When im using the regular viewer, i must add a splat before I can see my scene. Is there a way to show the scene before adding the splat?

from gaussiansplats3d.

mkkellogg avatar mkkellogg commented on September 4, 2024

Unfortunately the way it works right now is that the viewer won't start rendering anything until a splat scene has been loaded (that might change in a future update). Are you only using one single instance of THREE.WebGLRenderer for both the splat viewer and your other three.js objects?

from gaussiansplats3d.

lewibs avatar lewibs commented on September 4, 2024

Yep just the one renderer

from gaussiansplats3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.