Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(A-Frame) local gltf wont load; Cannot read property 'slice' of undefined

I took the code from the A-Frame School in which a gltf model is loaded. Then I loaded the Sample Models from Khronos, this box and tried to load it, but I get this error (several times)

GLTFLoader.js:979 Uncaught (in promise) TypeError: Cannot read property 'slice' of undefined
at GLTFLoader.js:979
at i (GLTFLoader.js:570)
at GLTFLoader.js:975
at <anonymous>

I can load .obj models and tried the several versions of the model, but get always the error.
The sample code does work locally, meaning it loads the model correctly, getting it from the aframe cdn.

Heres the code for completion

<!DOCTYPE html>
<html>
  <head>
    <title>glTF Model</title>
    <meta name="description" content="glTF Model">
    <script src="https://rawgit.com/aframevr/aframe/b395ea0/dist/aframe-master.min.js"></script>
  </head>
  <body>
    <a-scene>
      <a-assets>
        <a-asset-item id="boxModel" src="Box.gltf"></a-asset-item>
      </a-assets>          
      <a-gltf-model src="#boxModel"></a-gltf-model>
    </a-scene>
  </body>
</html>  
like image 620
Onion Avatar asked Jun 22 '17 11:06

Onion


2 Answers

Those models are in the 2.0 folder which means you need glTF v2.0 loader. A-Frame 0.5.0/0.6.0 supports glTF v1. But glTF v2 will be supported in A-Frame 0.7.0, but you can use gltf-model-next from Don McCurdy:

https://github.com/donmccurdy/aframe-extras/blob/master/src/loaders/gltf-model-next.js

Or you can grab different models instead from the 1.0 folder: https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/1.0

like image 76
ngokevin Avatar answered Nov 01 '22 09:11

ngokevin


Replace Aframe version to this:

<script src="https://aframe.io/releases/0.7.1/aframe.min.js"></script>

like image 2
Dinesh t Avatar answered Nov 01 '22 07:11

Dinesh t