exokitxr / exokit

Native VR/AR/XR engine for JavaScript 🦖
MIT License
997 stars 117 forks source link

Launch into VR from a web site opened in an Exokit iFrame #1050

Open weddingdj opened 5 years ago

weddingdj commented 5 years ago

I open a website in an iFrame which embeds a 'magic window' showing an Enter VR button (eg. A-Frame Enter VR button).

I click on the Enter VR button and I would like to exchange the current 3D environment with the 3D scene embedded in the iFrame. Basically this should happen by listening to the enter-vr event in A-Frame.

If I want to leave the current 3D scene (eg. listening for the exit-vr event in A-Frame), I want to switch back to the original 3D environment.

This feature would enable to enter VR environments which eg. I find by surfing the web in an Exokit iFrame.

Or in in my case: I have a CMS with a painter field type which allows users to add paintings to their scene by entering VR, paint, then exit VR, and save the painting.

Screen Shot 2019-05-10 at 12 40 50 Screen Shot 2019-05-10 at 12 41 07

weddingdj commented 5 years ago

After thinking about it a bit, I realized that it could be solved in another way, specific to Exokit, by sending a message with the URL out of the iframe. So by clicking the button in the iframe UI, I open the VR environment outside the iframe, in the environment where I already am.

In general I see two areas which require specific Exokit implementations, which would not run in a WebVR browser:

a) HTML textures must be defined in iframes b) when using Exokit iframes for UI, I have to use the Exokit messaging system to communicate between the iframe and environment, OR, I communicate via the backend, saving iframe UI states in the backend triggers changes in the VR enironment.

avaer commented 5 years ago

I think a) is in the process of being specced-- when it is, Exokit will follow the same API as the spec.

Regarding b) I think that's generally how it works with any iframe in any browser -- you just have to follow cross-origin rules.

This isn't directly related, but the proposal above sounds a lot like the concept of <portal>.

weddingdj commented 5 years ago

So HTML textures will be specified by the WebXR spec?

True for b) but if I want my app to run in Exokit, I would need specific code to take advantage of the iframe concept. If I use the same app in Oculus browser, it is different and I can just launch into my WebVR experience whereas with Exokit I am already in my WebVR experience from the start. I don't have experience with eg. Apache Cordova but I guess if I want to run my app in it, I would also do some tweaks to the code.

avaer commented 5 years ago

So HTML textures will be specified by the WebXR spec?

You probably won't get actual textures, and my read is this is still measured in years before it happens in mainstream browsers. But here is the issue:

https://github.com/immersive-web/proposals/issues/50