3not3
3not3

Reputation: 536

A-Frame local image is not loading

<!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>

I'm new to a-frame, have not worked much in java script either. The code above works fine for the referenced image, but does not work for the local image. What is actually i'm doing wrong ? I found this example here.

Upvotes: 1

Views: 1771

Answers (2)

M.R.
M.R.

Reputation: 28

Use https://www.cesanta.com/products/binary, it's easy to use. No configuring of server structure in any way needed.

Upvotes: 0

ngokevin
ngokevin

Reputation: 13233

Ensure you are using a local server (e.g., Mongoose, python -m SimpleHTTPServer, or npm install live-server) and that the image is on the same path as your index.html given where you're referencing it form.

Upvotes: 1

Related Questions