6

I wrote a demo scene on glitch to test my exported gltf model in a-frame, but I am getting an error in the console:

My code

<!DOCTYPE html>
<html>
  <head>
    <title>Basic Scene - A-Frame</title>
    <meta name="description" content="Basic Scene - A-Frame">
    <script src="https://aframe.io/releases/0.6.0/aframe.min.js"></script>
  </head>
  <body>
    <a-scene>
      <a-assets>
        <a-asset-item id="gltfDemo" src="https://cdn.glitch.com/a3c2afff-dcc6-4918-bb73-5716b35f39b0%2Fexport.gltf?1499844855169"></a-asset-item>
        <a-asset-item id="buffer_0.bin" src="https://cdn.glitch.com/a3c2afff-dcc6-4918-bb73-5716b35f39b0%2Fbuffer_0.bin?1499844851189"></a-asset-item>
        <a-asset-item id="buffer_1.bin" src="https://cdn.glitch.com/a3c2afff-dcc6-4918-bb73-5716b35f39b0%2Fbuffer_1.bin?1499844853034"></a-asset-item>
      </a-assets>
      
      <a-entity gltf-model="#gltfDemo"></a-entity>
      
      <a-sky color="#000"></a-sky>
      <a-light type="ambient" color="#445451"></a-light>
      <a-plane color="#050" rotation="-90 0 0" height="100" width="100"></a-plane>  
      <a-camera>
        <a-cursor color="#FAFAFA"></a-cursor>
      </a-camera>
    </a-scene>
  </body>
</html>

The error:

VM1762:1 Uncaught SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at e.parse (GLTFLoader.js:68)
at GLTFLoader.js:32
at three.js:29160

Source files: Glitch Fiddle with source files

I have a feeling that I am importing the gltf wrongly into glitch or using it the wrong way. Can anybody help me?

Don McCurdy
  • 10,975
  • 2
  • 37
  • 75

1 Answers1

5

from what I understand Your .gltf holds references to the .bins and .jpg textures.
Glitch is not that straightforward, and these files are not in one "directory", as You can see, when You get the links.

The error You get is caused by aframe trying to parse a null/nonexistent source file ( bins and jpgs).


I think it may be better if You put these files on Your server, or put it on github if You want (for the directories are straightforward).

You can also change the file paths in the .gltf file like suggested here.

Piotr Adam Milewski
  • 14,150
  • 3
  • 21
  • 42
  • Thank you so much! so the problem is just hosting the files on glitch? that is good to know and really a shame (because glitch is super awesome for quick demos and sharing code) – Madlaina Kalunder Jul 12 '17 at 09:37
  • 2
    @MadlainaKalunder, i tried changing the sources in the gltf file to the glitch links, but still got the same error, I'm not sure what exactly aframe is unable to parse ( as I initially thought are null sources, now i think that maybe https links are invalid as well ). Nonetheless i suggest You make Your examples on glitch, but host the model+assets elsewhere. Glad I could help :) – Piotr Adam Milewski Jul 12 '17 at 10:53