本文介绍了(A-Frame)本地gltf不会加载;无法读取未定义的属性“切片”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从获取了代码,其中gltf模型是加载。然后我从Khronos加载了Sample Models,并尝试加载它,但我收到此错误(几次)

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>

我可以加载.obj模型并尝试了几个版本的模型,但总是得到错误。

示例代码在本地工作,这意味着它正确加载模型,从aframe cdn获取它。

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.

下面是完成代码

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


推荐答案

这些型号在2.0文件夹中,这意味着你需要glTF v2.0加载器。 A-Frame 0.5.0 / 0.6.0支持glTF v1。但是在A-Frame 0.7.0中支持glTF v2,但你可以使用Don McCurdy的 gltf-model-next

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:

或者你可以抓住不同的型号而不是1.0文件夹:

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

这篇关于(A-Frame)本地gltf不会加载;无法读取未定义的属性“切片”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 07:56