1

My code worked in the morning. I made a few changes and it stopped working. I ran the code reverted to the earlier version and it also stopped working with the following warning in the debug console of visual studio code:

A-Frame:error This HTML file is currently being served via the file:// protocol. Assets, textures, and models WILL NOT WORK due to cross-origin policy! Please use a local or hosted server: https://aframe.io/docs/0.5.0/introduction/getting-started.html#using-a-local-server. 
aframe.io/releases/1.2.0/aframe.min.js:23
A-Frame Version: 1.2.0 (Date 2021-02-05, Commit #b220fa00)
aframe.io/releases/1.2.0/aframe.min.js:2682
THREE Version (https://github.com/supermedium/three.js): ^0.125.1
aframe.io/releases/1.2.0/aframe.min.js:2682
WebVR Polyfill Version: ^0.10.12
aframe.io/releases/1.2.0/aframe.min.js:2682
Uncaught Event
core:a-assets:warn Asset loading timed out in   3000 ms
releases/1.2.0/node_modules/debug/browser.js:111

This is the error in the browser console: enter image description here

I can't figure out why it is not working. I have also used crossorigion=null Here's the complete code:

<html>
    <head>
        <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
        <script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.1/dist/aframe-extras.min.js"></script>
        
    </head>
    <body>
        <a-scene>
            <!-- Asset Management System -->
            <a-assets>
                <img id="space" src="space.jpg" crossorigin=null>
                <a-asset-item id="spaceship" response-type="arraybuffer" src="spaceship.glb" ></a-asset-item>
            </a-assets>

            <!-- Sky -->
            <a-sky src="#space"></a-sky>

            <!-- Spaceship -->
            <a-entity gltf-model="#spaceship" scale="0.1 0.1 0.1" animation-mixer="clip: CubeAction; loop: infinite" visible="" position="0 1.096 0" rotation="65.1693655337701 179.9998479605043 0"></a-entity>

            <!-- Camera -->
            <a-camera  position="0 3.0 0" ></a-camera>
        </a-scene>
    </body>
</html>
sanepete
  • 979
  • 9
  • 28
Psychonaut007
  • 167
  • 3
  • 13

2 Answers2

1

My problem was that I wasn't using CORS in write manner. My files in the project are exposed at with extentions "C:/" whereasa cross orgion response request supports only https and remaining other mentioned in screenshot. It can be big problem to security therefore in order to avoid it make a server.

https://stackoverflow.com/a/33801287/16972919

Psychonaut007
  • 167
  • 3
  • 13
0

In my case, Coding in VSCode

  • Install extension "Live Server"
  • move your file to the current directory that you coded
  • access or call your file like => ./yourFileName.glb
  • Open live server at the right bottom of VS Code, That's it

Holp this helps :)

Pipo
  • 1