three.js WebVR示例代码适用于threejs.org,但不适用于本地服务器 [英] three.js WebVR example code works on threejs.org but not on my local server

查看:833
本文介绍了three.js WebVR示例代码适用于threejs.org,但不适用于本地服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试这个例子时: https://threejs.org/examples/webvr_cubes.html 在我的Android 7.0三星Galaxy 7手机上使用Chrome浏览器和Utopia360耳机,一切正常,我可以进入VR模式。当我使用完全相同的代码尝试完全相同的事情时,只能在本地服务器上获得您的浏览器不支持WebVR,请参阅webvr.info以获取帮助。

代码完全相同,three.js和WebVR.js文件除了three.js和WebVR.js文件位于目录结构(即< script src =js / threejs / three.jstype =text / javascript>< / script> 而不是< script src =../ build / three.js>< / script>

解决方案

根据 Google WebVR状态文档

Threejs.org是一个使用HTTPS的站点,但您的localhost几乎肯定不会通过安全连接传送内容。这就是为什么你会看到误导性的警告你的浏览器不支持WebVR,事实上它就是这样。



不幸的是,通过Apache提供HTTPS的可用方法使它听起来像三个选项来获得本地主机的SSL证书不适用于Chrome浏览器(或价格昂贵),因此使用 WebVR填充是目前最好的解决方案。


When I try out the example: https://threejs.org/examples/webvr_cubes.html on my Android 7.0 Samsung Galaxy 7 phone using the Chrome browser and the Utopia360 headset, everything works and I can enter VR mode. When I try the exact same thing with exactly the same code, only on my local server, I get "Your browser does not support WebVR. See webvr.info for assistance."

The code is exactly the same and the three.js and WebVR.js files are exactly the same except for where the three.js and WebVR.js files are located in the directory structure (i.e. <script src="js/threejs/three.js" type="text/javascript"></script> instead of <script src="../build/three.js"></script>)

解决方案

The issue is that you must "serve your WebVR content via HTTPS", according to the Google WebVR status documentation.

Threejs.org is a site that uses HTTPS, but your localhost is almost certainly not delivering the content via a secure connection. That's why you're seeing that misleading warning that "Your browser does not support WebVR", when in fact, it does.

Unfortunately, the available methods to deliver HTTPS via Apache make it sound like the three options to get an SSL certificate for localhosts won't work on Chrome for Android (or are pricey), so using the WebVR polyfill is the best solution for the time being.

这篇关于three.js WebVR示例代码适用于threejs.org,但不适用于本地服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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