【问题标题】:A-Frame local image is not loadingA-Frame 本地图像未加载
【发布时间】:2017-02-25 06:20:14
【问题描述】:
<!doctype html>
<html>
  <head>
    <script src="https://rawgit.com/aframevr/aframe/b813db0614ac2b518e547105e810b5b6eccfe1c8/dist/aframe.min.js"></script>
  </head>
  <body>
    <script>
      AFRAME.registerComponent('set-sky', {
        schema: {default: ''},
        init() {
          const sky = document.querySelector('a-sky');
          this.el.addEventListener('click', () => {
            sky.setAttribute('src', this.data);
          });
        }
      });
    </script>

    <a-scene>
      <a-camera position="0 2 4">
        <a-cursor color="#4CC3D9" fuse="true" timeout="10"></a-cursor>
      </a-camera>

      <a-sphere color="#F44336" radius="1" position="-4 2 0" set-sky="https://c3.staticflickr.com/2/1475/26239222850_cabde81c39_k.jpg"></a-sphere>

      <a-sphere color="#FFEB3B" radius="1" position="4 2 0" set-sky="32252838043_e8f2be6783_k.jpeg"></a-sphere>

      <a-sky></a-sky>
    </a-scene>
  </body>
</html>

我是 a-frame 的新手,也没有在 java 脚本中工作太多。上面的代码适用于引用的图像,但不适用于本地图像。实际上我做错了什么?我找到了这个例子here。

【问题讨论】:

    标签: aframe


    【解决方案1】:

    确保您使用的是本地服务器(例如,Mongoose、python -m SimpleHTTPServer 或 npm install live-server),并且该图像与您的 index.html 位于相同的路径上,因为您引用它的位置。

    【讨论】:

    • 任何像 'Apache' 这样的服务器都可以工作,或者特别是它必须是 Mongoose ?
    • 例如,如“例如”,因此任何服务器都可以工作。我的意思是本地开发服务器。阿帕奇是矫枉过正。请参阅 A-Frame 入门指南。
    【解决方案2】:

    使用https://www.cesanta.com/products/binary,很容易使用。无需以任何方式配置服务器结构。

    【讨论】:

      猜你喜欢
      • 2021-06-01
      • 1970-01-01
      • 2017-11-28
      • 2019-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多