Kitware / vtk-js

Visualization Toolkit for the Web
https://kitware.github.io/vtk-js/
BSD 3-Clause "New" or "Revised" License
1.24k stars 380 forks source link

WebXR Implementation #1320

Closed aneeshikmat closed 2 years ago

aneeshikmat commented 4 years ago

Hi, Since WebVR 1.1 will be removed from Chrome.in v80, and from v79 webxr is supported and we can use it, also since all browser and website now work on WebXr nested of WebVr, I Think we need to update our WebGlRenderWindow.js and use webXr....

I take a look in webvr-migration, and do what I see in article, and run it...but I have an issue, the webxr is work, but volume not seen (I can see something like volume light in long way), so that I think the issue for me how I can implements transform for volume to be seen in xrDevice...


`    if (pose) {
      let glLayer = session.renderState.baseLayer;
      // If we do have a valid pose, bind the WebGL layer's framebuffer,
      // which is where any content to be displayed on the XRDevice must be
      // rendered.
      gl.bindFramebuffer(gl.FRAMEBUFFER, glLayer.framebuffer);

      // Clear the framebuffer
      gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

      // Loop through each of the views reported by the frame and draw them
      // into the corresponding viewport.
      for (let view of pose.views) {
        let viewport = glLayer.getViewport(view);
        gl.viewport(viewport.x, viewport.y,
                    viewport.width, viewport.height);
        let matView = mat4.clone(view.transform.matrix);
        ren
          .getActiveCamera()
          .applyTransform(
            matView
          );
        ren
          .getActiveCamera()
          .setProjectionMatrix(view.projectionMatrix);

          publicAPI.traverseAllPasses();
      }
    }`

also I try this:
`let matView = mat4.clone(view.transform.inverse.matrix);
        ren
          .getActiveCamera()
          .computeViewParametersFromPhysicalMatrix(
            matView
          );`

and more solution like this, but I fail....

If you can tell me how I can replace these line will be good to publish it...
`ren
      .getActiveCamera()
      .computeViewParametersFromPhysicalMatrix(
        model.vrFrameData.leftViewMatrix
      );
    ren
      .getActiveCamera()
      .setProjectionMatrix(model.vrFrameData.leftProjectionMatrix);`

thanks
aneeshikmat commented 4 years ago

I build nice app which its support VR by vtk, so that I think if I updated core and let it support webxr will be nice for me and all vtk user for future release :D at current step, usually I end and deploy all parts ...maybe still need to work in screen display when vr start, and clean code..and all will be nice... If this part is hard to deploy, I think will stop and keep it for professional developer :D

daker commented 2 years ago

@tbirdso can this be close?

tbirdso commented 2 years ago

@daker Yes, thanks. WebXR is now supported in the vtkOpenGLRenderWindow.