Skip to content

feat(WebXR): Add support for head-mounted augmented reality displays #2824

New issue

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

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

Already on GitHub? # to your account

Merged
merged 5 commits into from
May 11, 2023

Conversation

tbirdso
Copy link
Contributor

@tbirdso tbirdso commented May 10, 2023

Context

Adds support for rendering to WebXR head-mounted augmented reality sessions.

Results

Previous behavior: vtk.js supported HMD VR (two cameras) or mobile AR (one camera) sessions, but not AR HMDs (two cameras). Side effect was that rendering in an AR headset (Meta Quest 2) would produce undefined behavior with only one eye able to see the scene at a time.

Updated behavior: Proper stereoscopic rendering for AR HMDs, combines existing support for VR HMD rendering with AR transparency.

Note that HoloLens 2 AR HMDs appear to be treated as VR headsets by WebXR and support immersive-vr but not immersive-ar sessions. Scale factors for VR scenes are updated to be more comfortable for HoloLens users.

Screenshot captured on HoloLens 2:

hololens-cropped

Changes

  • Documentation and TypeScript definitions were updated to match those changes
  • Adds HmdAR enum value to request head-mounted augmented reality XR session
  • Adds handling for HmdAR session in OpenGL/RenderWindow
  • Moves scene background handling for AR sessions from application level into OpenGL/RenderWindow to reduce redundancy
  • Adds scripts to securely serve WebXR and WebGPU examples locally via HTTPS with self-signed SSL certificate

PR and Code Checklist

  • semantic-release commit messages
  • Run npm run reformat to have correctly formatted code

Testing

  • Tested environment:
    • vtk.js: master
    • OS: Windows 10
    • Browser: Microsoft Edge

Tested on the following devices:

  • Meta Quest 2 (w/ AR passthrough)
  • Microsoft HoloLens 2
  • Samsung Galaxy (mobile AR)

@tbirdso tbirdso requested review from floryst and aylward May 10, 2023 20:15
@tbirdso tbirdso force-pushed the webxr-ar-hmd branch 3 times, most recently from e06b46f to 5454722 Compare May 11, 2023 13:59
tbirdso added 3 commits May 11, 2023 10:00
Adds support for serving examples locally over HTTPS
via self-signed SSL certificate automatically generated by webpack.

Run the following command to serve an example over HTTPS:
```
> npm run example-https -- <example-name>
```

These changes are motivated by the WebXR specification requiring that
documents be served in a secure context.

https://immersive-web.github.io/webxr/privacy-security-explainer.html

Also updates WebGPU example command to always run over HTTPS. WebGPU is
only available in secure contexts.

https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API
Consolidates WebXR background caching and updates so that
"OpenGL/RenderWindow" is responsible for managing background
transparency for augmented reality sessions. Previous behavior required
the application to set background transparency.
Adds support for head-mounted augmented reality displays (AR HMDs),
building on existing support for WebXR head-mounted VR displays and
mobile augmented reality displays.
@tbirdso
Copy link
Contributor Author

tbirdso commented May 11, 2023

cc @LucasGandel

tbirdso added 2 commits May 11, 2023 11:07
…lays (AR HMDs)

Updates WebXR documentation with descriptions and example scenes
for augmented reality head-mounted display support.

Includes parameter parsing for AR cone example to switch between mobile
and HMD AR.
Updates default WebXR scene factors to standardize across
VR and AR experiences. Factors are selected to scale and
translate the default scene so that VR and AR example datasets
can be viewed comfortably. Previous behavior resulted in
VR models appearing very large and very close to the user's
face, which was particularly uncomfortable in testing on the
HoloLens 2 headset. In updated behavior the examples in
`GeometryViewer` and `WebXRVolume` appear smaller and at a
comfortable distance from the user.
@djelouze
Copy link

Thank you so much!!

@floryst
Copy link
Collaborator

floryst commented May 11, 2023

LGTM!

@floryst floryst added this pull request to the merge queue May 11, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 11, 2023
@floryst floryst added this pull request to the merge queue May 11, 2023
Merged via the queue into Kitware:master with commit e1c7ca6 May 11, 2023
@github-actions
Copy link

🎉 This PR is included in version 27.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Automated label label May 11, 2023
@tbirdso tbirdso mentioned this pull request May 11, 2023
46 tasks
@djelouze
Copy link

Thank you so much!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
released Automated label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants