Google VR 视图 - 托管代码不起作用

geo*_*off 3 html javascript google-vr

也许这是一个比我意识到的更简单的问题,但我对 HTML/JS 有点陌生,在我看来,这是此代码的一个特定问题。我正在使用 Google VR 查看器在我的网页中嵌入 360 度元素。

他们的文档非常简单,如果我也使用 Google 域上托管的媒体,那么按照他们网站上的设置进行设置就可以正常工作。这是我正在使用的代码,效果很好:

<script src="https://storage.googleapis.com/vrview/2.0/build/vrview.min.js"></script>
<script>
  window.addEventListener('load', onVrViewLoad);
  function onVrViewLoad() {
    vrView = new VRView.Player('#vrview', {
    width: '100%',
    height: 480,
    image: 'https://storage.googleapis.com/vrview/examples/coral.jpg',
    is_stereo: true,
    is_autopan_off: true
    });
  }
</script>
Run Code Online (Sandbox Code Playgroud)

但是,我需要将 .js 文件托管在我自己的服务器上,而不是仅仅链接到 Google。所以我尝试下载脚本并使用以下代码,但无法让它工作。任何人都可以发现出了什么问题吗?

<script src="build/vrview.min.js"></script>
<script>
  window.addEventListener('load', onVrViewLoad);
  function onVrViewLoad() {
    vrView = new VRView.Player('#vrview', {
    width: '100%',
    height: 480,
    image: '360/coral.jpg',
    is_stereo: true,
    is_autopan_off: true
    });
  }
</script>
Run Code Online (Sandbox Code Playgroud)

作为参考,我得到的错误是

Cannot GET /index.html?image=http://127.0.0.1:61060/360/coral.jpg&amp;is_stereo=true&amp;is_autopan_off=true&amp;
Run Code Online (Sandbox Code Playgroud)

谢谢!希望这不是一个太愚蠢的问题。

zil*_*ilp 6

这确实是缺乏(已存档)Google VRView 的文档。

您需要从VRView 存储库的该分支下载所有文件。您可以安全地删除示例文件夹,但保留其他所有内容。将所有这些文件和文件夹放在站点的子文件夹中。

例如,文件夹结构可以是:

yoursite/index.html <-- Your website
yoursite/ <-- Anything else you want, img/, css/, other root .html files
yoursite/googlevr/ <-- all the files from VRView repo
Run Code Online (Sandbox Code Playgroud)

这应该使您拥有 yoursite/googlevr/build、yoursite/googlevr/images 等,以及 googlevr/ 根目录中的 index.html 和 style.css 文件

之后,您可以使用您自己的index.html(或该文件夹中的任何其他.html)中的.js,通过

<script src="/googlevr/build/vrview.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

请注意,Google VRView 现已存档在 Github 中,他们似乎已停止对此的任何支持。另请注意,默认情况下,VR 视图无法在 iOS 12.1 设备和新设备上运行,因为默认情况下禁用设备方向的隐私设置。您的用户需要在其设备设置中手动打开方向传感器。