BabylonJS / Babylon.js

Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework.
http://www.babylonjs.com
Apache License 2.0
23.26k stars 3.43k forks source link

WebXR #3899

Closed deltakosh closed 5 years ago

deltakosh commented 6 years ago
veikkoeeva commented 6 years ago

Further resources, discussion groups etc. from Mozilla blog: https://blog.mozilla.org/blog/2017/10/20/bringing-mixed-reality-web/. Further refined goals at a later post https://blog.mozvr.com/enabling-the-social-3d-web/ .

It appears to me this is about unifying the augmented reality experience. Concretely in near term, codewise, to me this looks like a proposal to add avatars and coordinate their actions via WebRTC (notably, by the way, MS also opened one peer server codebase).

veikkoeeva commented 6 years ago

To continue a bit, this also looks alluring for an outsider: https://blog.mozvr.com/experimenting-with-ar-and-the-web-on-ios/.

It might be useful to see how could WASM be utilized for more compute intensive tasks now that it's coming hard to the fore, so to speak. For instance, there's Blazor template already at https://dotnet.myget.org/feed/blazor-dev/package/nuget/Microsoft.AspNetCore.Blazor.Templates (dotnet new -i Microsoft.AspNetCore.Blazor.Templates::0.1.0-preview1-10071 --nuget-source https://dotnet.myget.org/F/blazor-dev/api/v3/index.json) for those in .NET Standard 2.0, adding SignalR, VSIX etc. in the next few weeks apparently. This is obviously .NET centric view, though likely other ecosystems have something similar.

veikkoeeva commented 6 years ago

Adding https://blog.mozvr.com/responsive-webxr-a-painter-xr/ too. Sorry (a little) for spamming (but goes with the first mentioned and seems to offer some more information). :) Also: https://blog.mozvr.com/building-mixed-reality-spaces-for-the-web/ (build virtual spaces and interact with other people in them).

veikkoeeva commented 6 years ago

Since the (Mozilla) WebXR seems to rely on WebRTC quite a lot, I'll add a few articles pertaining to the woes: https://bloggeek.me/webrtc-adapter-js/, and more tangentially https://webrtchacks.com/webrtc-sdp-inaki-baz-castillo/.

tl;dr; Using WebRTC without adapter.js seem to be maddness.

deltakosh commented 6 years ago

Thanks a lot for all these references. @trevordev is currently looking at the current state of the art to see how we can support it:)

TrevorDev commented 6 years ago

I now have a decently working prototype. https://github.com/TrevorDev/Babylon.js/tree/webXR Would love to get feedback. @phu-ms @brianzinn

Proposed approach

Note: I'm recommending vr experience helper and webVR camera be marked as deprecated due to the inconsistent position behavior defined by the webVR camera where is position is always zero as well as the current complexity of the matricies in it making the moving car scenario difficult.

Core scenarios

Setup

Current setups I have tested to work: Desktop setup:

Current mobile setup:

Not supported

Debugging:

Note: https://github.com/immersive-web/webxr-polyfill can be used in the future to polyfill browsers that dont support webXR

deltakosh commented 6 years ago

Some comments about naming:

brianzinn commented 6 years ago

Great work!!

Thanks. Looking forward to seeing what's next! :)

TrevorDev commented 6 years ago

Thanks,

Yea, some pieces are still not prototyped, feature detection will definitely be part of the xrSessionManager, for no customization's what I mean is xrHelper should ship with very little options and be stricter on adding additional options, I would like to avoid the complexity which led to some issues/confusion in the vrHelper, eg the way multiple cameras were handles. VR/webVR will continue to exist and not be deleted for back compat but it would be recommended to switch to XR to gain additional features. Ideally the VR helper could be extend to become the XR helper but due to camera inconsistencies with the webVR cameras (eg. position of webVR camera isn't the actual position) a completely new class was recommended.

I'm sure this design will change as more issues will expose themselves after pieces are checked in and people start trying it out and especially since the w3c spec is still in flux

soniapello commented 6 years ago

@deltakosh It will be added to babylon 4 which is planned for April 30, 2019. Is there any chance that a major browser like microsoft edge support webxr at that date ?

TrevorDev commented 6 years ago

@soniapello You can see the timeline in the current webXR charter here: https://www.w3.org/2018/08/immersive-web-wg-charter.html

The spec and implementation is still under churn and the recent canary update this week broke most of the magic window samples I've been building as well as other samples eg. https://codelabs.developers.google.com/codelabs/ar-with-webxr/#0

Major browsers such as Edge, Chrome and Firefox have all expressed interest in supporting WebXR. Based on this there is definitely a chance it will be supported (at least behind flags like chrome canary) by then but not guaranteed. I would probably give it 50% chance odds but that's just a guess.

soniapello commented 6 years ago

Thanks for your answer Trevor

nikeinikei commented 5 years ago

I couldn't get the example to work on chrome canary (version 74), it seems like they removed the concept of an XRDevice, at least according to https://immersive-web.github.io/webxr/#xr-interface. I also tried adjusting the code to make it work in the newest chrome canary version, but was unable to do so (This is my first attempt at a contribution to BabylonJS, and I'm still unsure how BabylonJS's internals work). Is someone else working on this?

deltakosh commented 5 years ago

@TrevorDev is the owner of that feature

TrevorDev commented 5 years ago

Hey @nikeinikei ,

You can see this thread: https://forum.babylonjs.com/t/web-xr-current-status/1354

yea the implementation is a bit out of date, it targets a version of chrome canary from early January (it should work if you have an apk). It’s hard to figure out what to target at the moment (firefox, polyfill, chrome chanary) and it is unclear to me how to find which spec which implements so I’ve been holding off until I have an implementation/spec that is more final.

The webXR spec was just updated Feb 13th https://immersive-web.github.io/webxr/ but once a browser announces they support the latest spec I will sync the code again. (I'm hoping this is soon)

WebVR works right now (https://www.babylonjs-playground.com/#TAFSN0#2) so you could take a look at that at the moment if you are not dependent on an XR feature while we wait.

nikeinikei commented 5 years ago

WebVR works right

So is the babylon api for webxr unlikely to change?

TrevorDev commented 5 years ago

@nikeinikei The webVR api won't change but webVR is not widely supported in all browers and is being phased out a bit in favor of webXR (w3c spec editors found flaws trying to extend webVR so they decided on making a new api). To better support webXR in babylon we will also have a new api, but it will be very similar to webVR so I would use webVR for now and port to XR if new features are required.

It looks like there is an issue to track what browsers/setup supports what version of the spec https://github.com/immersive-web/webxr/issues/529

leon commented 5 years ago

I've been doing some research into how for web-xr has come since january. It looks like chrome 76 may contain the new web-xr specification. https://github.com/immersive-web/webxr/blob/master/explainer.md

It's available in canary by enabling the xr stuff in chrome://flags

I'm going to try out babylons current implementation on my samsung s4 tablet and samsung s8 to see if it works.

@TrevorDev Maybe it's time to have another look :)

leon commented 5 years ago

@TrevorDev Seems that we need to do some updating. I'm getting: ERROR Error: Uncaught (in promise): TypeError: this._xrNavigator.xr.requestDevice is not a function

TrevorDev commented 5 years ago

@leon , Thanks, I have started trying to resync with the latest spec again and there are a couple interface changes.

I managed to get one spec samples (https://cs.chromium.org/chromium/src/chrome/test/data/xr/e2e_test_files/html/test_webxr_input.html) to work in the latest chromium (only works with windows mixed reality headset, not rift). Ill code against this for now, hopefully Ill have something working again soon.

TrevorDev commented 5 years ago

@leon I have synced Babylon again. The playgrounds linked in the recent PRs I've merged should work. Ill be working on documenting everything/getting feedback on the current API next week. Chrome with xr flags turned on finally seems to work with rift and wmr headsets 🥇 so hopefully the spec doesn't change a lot from now on. Let me know if you have any questions/issues.

Yonet commented 5 years ago

@leon examples do not work on Chrome Canary 79. Can we re-open the issue please. Thanks.

deltakosh commented 5 years ago

Do you mind creating a new one and pinging @RaananW ? Thanks a lot