我从A型框架学校 https://aframe.io/aframe-school/#/11其中加载了 gltf 模型。然后我从 Khronos 加载了示例模型,this box https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Box并尝试加载它,但我收到此错误(多次)
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 获取模型。
这是完成的代码
<!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。但是glTF v2将在A-Frame 0.7.0中支持,但是你可以使用gltf-model-next
来自唐·麦柯迪:
https://github.com/donmccurdy/aframe-extras/blob/master/src/loaders/gltf-model-next.js https://github.com/donmccurdy/aframe-extras/blob/master/src/loaders/gltf-model-next.js
或者您可以从 1.0 文件夹中获取不同的模型:https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/1.0 https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/1.0
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)