cesium icon indicating copy to clipboard operation
cesium copied to clipboard

WebXR

Open bagnell opened this issue 9 years ago • 18 comments

  • [ ] DeviceOrientationCamera, #4608
  • [ ] Future WEBGL_multiview extension?
  • [ ] The VRButton should search for VR devices. If none, are available default to Cardboard.
  • [ ] The HMDVRDevice should be passed to Fullscreen.requestFullscreen and has viewing parameters that should be used for the left and right eye cameras.
  • [ ] The PositionSensorVRDevice should be passed to DeviceOrientationCameraController to set the camera orientation. If the parameter is undefined, default to using the deviceorientation event.
  • [ ] Public API for multiple viewports, each potentially with its own camera

bagnell avatar Jan 13 '16 20:01 bagnell

Searching for VR devices:

function enumerateVRDevices(devices) {
    var i;
    for (i = 0; i < devices.length; ++i) {
        if (devices[i] instanceof HMDVRDevice) {
                // ...
        }
    }

    for (i = 0; i < devices.length; ++i) {
        if (devices[i] instanceof PositionSensorVRDevice) {
            // Ensure devices[i].hardwareUnitId is the same as the HMDVRDevice
            // ..
        }
    }
}

if (navigator.getVRDevices) {
    navigator.getVRDevices().then(enumerateVRDevices);
} else if (navigator.mozGetVRDevices) {
    navigator.mozGetVRDevices(enumerateVRDevices);
}

bagnell avatar Jan 13 '16 21:01 bagnell

the code just works for Oculus Rift, while not for htc vive ??

taozhi8833998 avatar Oct 26 '16 09:10 taozhi8833998

Good article. Multiview is also coming to three.js, https://github.com/fernandojsg/three.js/tree/multiview_support

pjcozzi avatar Nov 08 '17 22:11 pjcozzi

  • WEBGL_multiview was promoted to draft and will support WebGL 1.0

pjcozzi avatar Jan 05 '18 00:01 pjcozzi

Resources via @TrevorDev

  • Babylon WIP: https://github.com/TrevorDev/Babylon.js/commit/10e379c26a4588df1e5c821ab2259e5968e1c9f5
  • Guide: https://codelabs.developers.google.com/codelabs/ar-with-webxr/#0

pjcozzi avatar Aug 08 '18 13:08 pjcozzi

Latest from Mozilla:

We have begun work to add WebXR support to Firefox. An early implementation will be available in Firefox Nightly in the coming months, so developers and early adopters can turn it on and give it a test-drive.

pjcozzi avatar Sep 14 '18 18:09 pjcozzi

From WebVR/XR — The future is here:

WebXR was created to target a wider range of immersive devices beyond just VR. These include augmented reality devices (Digital content on top of the real world) such as phones, Microsoft HoloLens and Magic Leap One. WebVR had a few issues making it hard to extend to all immersive devices, so it was decided to be deprecated in favor of the WebXR API. Existing WebVR apps won’t be out of luck thanks to the WebVR polyfill which provides WebVR as long as WebXR exists.

The WebXR spec is still under development but has early experimental implementations in some browsers (e.g. Chrome Canary). The current milestone dates are here. Unfortunately, it isn’t recommended to code against yet as it is still evolving.

pjcozzi avatar Jan 24 '19 19:01 pjcozzi

FYI: Mozilla releases WebXR emulator extensions for Chrome and Firefox so anyone can develop without needing extra hardware. Blog: https://blog.mozvr.com/webxr-emulator-extension/

Firefox: https://addons.mozilla.org/en-US/firefox/addon/webxr-api-emulator/ Chrome: https://chrome.google.com/webstore/detail/webxr-api-emulator/mjddjgeghkdijejnciaefnkjmkafnnje

mramato avatar Sep 12 '19 14:09 mramato

Is there a simple way to convert XRView's transform and projectionMatrix to a Camera object? I was thinking I could try to extract camera params (pos + rot + frustum) from the matrices and create a camera, but it seems hacky

python273 avatar Mar 14 '21 11:03 python273

The VRButton should search for VR devices. If none, are available default to Cardboard. The HMDVRDevice should be passed to Fullscreen.requestFullscreen and has viewing parameters that should be used for the left and right eye cameras. The PositionSensorVRDevice should be passed to DeviceOrientationCameraController to set the camera orientation. If the parameter is undefined, default to using the deviceorientation event.

Hi bagnell, I would like to ask how to do these three things in webxr, because these mentioned APIs are in the outdated WebVR. image image I want my vr mode to be immersive rather than a cardboard. If you can help me, I will be very grateful. Thank U~

nangongwentian-fe avatar Dec 19 '22 10:12 nangongwentian-fe

any update for web-xr? Is there a simple way to convert XRView's transform and projectionMatrix to a Camera object?

abigstupidbear avatar Mar 11 '23 14:03 abigstupidbear

HI @abigstupidbear, there hasn't been any activity on this item recently.

If you'd like to add more information about your use case, that may help us prioritize. Or, if you are interesting in contributing, please let us know and we'd be happy to discuss implementation or review a PR.

I don't believe there is a way to set the Camera projection through the existing API. There would need to be change to the class itself, or camera properties would need to be set individually as we do for the existing WebVR implementation.

Thanks!

ggetz avatar Mar 13 '23 13:03 ggetz

Hi. I just ran into this discussion. I have been working on a flow that truly works with WebXR. I am ready to send a PR, but only as a proof of concept. I got it working for v1.74, so I'll update my code to the latest version and then send you the proposal. Maybe a PR is not the best option for you to check it out, so please tell me if there is a better way.

pupitetris avatar Jun 23 '23 23:06 pupitetris

Hi. I have opened a PR as I start to work on WebXR support. This PR concretely adds displaying the VR session on the HMD using WebXR. #11372

pupitetris avatar Jun 27 '23 03:06 pupitetris

Is there a simple way to convert XRView's transform and projectionMatrix to a Camera object? I was thinking I could try to extract camera params (pos + rot + frustum) from the matrices and create a camera, but it seems hacky

Hey @python273 @abigstupidbear did you find any answers to this problem? I could use some help with that and get cameras working correctly for the WebXR fork of CesiumJS that I am working on. Right now we are doing this, which is not utilizing WebXR's parameters: Scene.js:prepareWebVRPose

pupitetris avatar Jun 29 '23 14:06 pupitetris

Hi @pupitetris, has there been any activity on this lately or what happened to your PR?

geotom avatar Oct 12 '24 18:10 geotom

Hi. I stalled. Also, I did a mess with git and my fork is in shambles. I don't think it is a priority for Cesium to do VR through web technologies. Maybe they are focusing on Unity for VR, as there is less overhead and Cesium will run smoother on standalone headsets, I don't know.

pupitetris avatar Oct 12 '24 20:10 pupitetris

Hi. I stalled. Also, I did a mess with git and my fork is in shambles. I don't think it is a priority for Cesium to do VR through web technologies. Maybe they are focusing on Unity for VR, as there is less overhead and Cesium will run smoother on standalone headsets, I don't know.

Thanks for the update @pupitetris. I am currently reviewing solutions to get a georeferenced MR environment on my Meta quest, to display objects with spatial coordinates. I know there is the Cesium integration with Unity/Unreal, but when I discovered WebXR, it sounded like a much more simple way to achieve this and stay in Javascript world.

A pity, that the cesium so far does not natively support WebXR. How much work do you think it takes to get your PR in a workable state, with the current Cesium? Which commit of your fork was most stable / or from where was it starting to fall apart? I'll think I give it a try, so any help appreciated!

geotom avatar Oct 14 '24 08:10 geotom