CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.98k stars 3.5k forks source link

WebXR #3422

Open bagnell opened 8 years ago

bagnell commented 8 years ago
bagnell commented 8 years ago

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);
}
taozhi8833998 commented 8 years ago

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

pjcozzi commented 7 years ago

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

pjcozzi commented 6 years ago
pjcozzi commented 6 years ago

Resources via @TrevorDev

pjcozzi commented 6 years ago

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 commented 5 years ago

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.

mramato commented 5 years ago

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

python273 commented 3 years ago

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

EvenJie-XR commented 1 year ago

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~

abigstupidbear commented 1 year ago

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

ggetz commented 1 year ago

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!

pupitetris commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

geotom commented 1 month ago

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

pupitetris commented 1 month ago

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.

geotom commented 1 month ago

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!