如何使应用程序准备好"ovrweb"协议(将在Gear VR中查看)? [英] How to make an app ready for 'ovrweb' protocol (to be viewed in Gear VR)?

查看:121
本文介绍了如何使应用程序准备好"ovrweb"协议(将在Gear VR中查看)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用ThreeJS的网络应用程序.我目前正在尝试将WebVR包含在Gear VR中.

I have a web app that uses ThreeJS. I am currently trying to include WebVR to be used with Gear VR.

我知道我需要使用 ovrweb 协议链接到该Web应用程序才能在Gear VR中打开它.我的问题是事实并非如此.

I am aware that I need to link to that web app using the ovrweb protocol in order to open it in Gear VR. My problem is that it does not.

每当我使用window.location.href = "ovrweb:http://my-app-url"时,都会要求我将设备连接到Gear VR.但是,一旦这样做,屏幕就会保持黑色.我注意到,每当我使用一些非VR网页作为URL(例如ovrweb:https://www.google.com)时,都会发生同样的事情. 但是,ovrweb协议在某些URL(例如ovrweb:https://playcanv.as/p/VNTAx5Eu/)上可以正常工作.

Whenever I use window.location.href = "ovrweb:http://my-app-url", I am asked to attach the device to Gear VR. But once I do so, the screen remains black. I noticed that the same thing happens whenever I use some non-VR webpage as the URL (like ovrweb:https://www.google.com). However the ovrweb protocol works fine as expected with certain URLs - such as ovrweb:https://playcanv.as/p/VNTAx5Eu/.

我不确定我缺少什么.我的应用程序有一个VR按钮,点击该按钮会触发display.requestPresent API调用&屏幕分为两部分(可在Chrome Canary中使用).通过ovrweb协议可以识别我的应用程序需要满足的所有需求列表吗?如果是这样,那是什么?

I am not sure what I am missing. My app has a VR button, on clicking which the display.requestPresent API call gets fired & the screen splits into two (works in Chrome Canary). Is that any list of requirements that my app needs to satisfy to be recognized via ovrweb protocol? If so, what are those?

我浏览了Oculus文档,但没有找到任何可以帮助我的东西.如何使我的应用通过ovrweb协议运行?

I went through the Oculus docs, but did not find anything that could help me. How do I make my app run via ovrweb protocol?

更新:我发现ThreeJS示例链接(例如 https://threejs.org/examples/webvr_rollercoaster.html )也无法通过ovrweb协议工作.

Update: I found that ThreeJS example links (such as https://threejs.org/examples/webvr_rollercoaster.html) are not working over ovrweb protocol either.

推荐答案

好的,我自己找到了解决方案.

Okay, found the solution myself.

每当我们尝试使用ovrweb协议时,设备都会尝试打开其Carmel Developer Preview浏览器(不同于在使用Oculus Home体验时可以使用的互联网浏览器")中提供的URL. 现在,Carmel Developer Preview仅支持"3D"网站. Carmel Developer Preview当前不支持导航到2D网站. ( https://developer.oculus.com/documentation/vrweb/latest/concepts/carmel-launching-content/).这就是为什么我自己的Web应用程序以及诸如google.com之类的链接显示为黑色的原因.

Whenever we try to use ovrweb protocol, the device will try to open the URL provided in its Carmel Developer Preview browser (different from the "internet browser" one can use when inside Oculus Home experience). Now the Carmel Developer Preview supports only "3D" websites. Navigating to 2D websites is not currently supported in Carmel Developer Preview. (https://developer.oculus.com/documentation/vrweb/latest/concepts/carmel-launching-content/). That's why my own web app, as well as links such as google.com, appeared black.

因此,我要做的只是从一开始就触发display.requestPresent,从而将其与2D网站区分开来.

So all that I had to do was simply trigger display.requestPresent at the very start - thereby differentiating it from a 2D website.

现在,如果没有某种用户交互(例如单击按钮),display.requestPresent将不起作用.出于安全考虑,其他JS API(例如全屏)也是如此.

Now display.requestPresent does not work without some kind of user interaction (such as click of a button). Same is the case with other JS APIs (such as fullscreen), for security concerns.

但是,通过ovrweb协议导航到链接并在Carmel Developer Preview中查看它似乎也满足了用户交互条件.因此,现在我的VR场景在Gear VR中完全可见.

However it seems like navigating to a link over ovrweb protocol and thereby viewing it in Carmel Developer Preview also satisfies the user interaction condition. Hence now my VR scene is perfectly visible in Gear VR.

此解决方案也应在ThreeJS webvr示例(包括OP中链接的过山车示例)中使用.

This solution should also work in the ThreeJS webvr examples (including the rollercoaster example linked in OP).

所有要做的就是在网页加载时触发此代码段.

All one needs to do is trigger this snippet on page load.

display.requestPresent( [ { source: canvas } ] )
.then(function() {
    // Presenting to WebVR display
}, function(e) {
    // On error
});

这篇关于如何使应用程序准备好"ovrweb"协议(将在Gear VR中查看)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆