vtkXRRenderWindow is web-served “vtk.js” service

Hey all,

First off, for those of you who follow both the ParaView and VTK Discourse, my apologies for the double posting – I realized today that this is the better place for my question. [The original post is at: ParaView Discourse: vtkXRRenderWindow.

And my question/issue is:

I have a sample “vtk.js” application working using “https://unpkg.com/vtk.js” to provide the VTK functionality, however that version of VTK doesn’t seem to have the XR stuff available, as I get the error message:
Uncaught TypeError: vtk.Rendering.Misc.vtkXRRenderWindow is undefined

I tried using “cdn.jsdelivr.net”, which requires using the “npm/@kitware/vtk.js@30.0.0/vtk.js” path, which may or may-not have “vtkXRRenderWindow”, but I can’t find out, because I now get the error:

Uncaught TypeError: The specifier “globalthis” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “…/” or “/”.

I feel like I’m close with the unpkg.com/vtk.js as it seems to have the “vtkXRRenderWindow” class, but doesn’t have the “newInstance()” method.

Does anyone have an example of a vtk.js program with WebXR features, and making use of a remotely served “vtk.js” package?

Thanks, Bill

Hello,

I think that it is because the WebXR folder is not exposed by default in Sources/Rendering/index.js. The default export is the following:

export default {
  Core,
  Misc,
  OpenGL,
  SceneGraph,
  WebGPU,
};

Is there a way to access WebXR anyway @Sebastien_Jourdain ?

Via the ESM bundle or when you compile your app using the source. Either way, you need a bundler at that point (not really for esm).

We should just add it to the Sources/Rendering/index.js

I made a quick PR to solve this issue

@Thibault_Bruyere Great, thanks. I hope it gets approved.

(I guess that means I’ll be building VTK again in the near future?)

Bill

It is merged, and available in version 32.2.0
If you use a CDN without specifying a version like unpkg.com/vtk.js, you will automatically get the latest version that contains the fix
If you use a version in the URL, you will have to bump that version: unpkg.com/vtk.js@32.2.0
I advice specifying a version in the URL to avoid unwanted changes of behavior