Oni*_*ion 8 javascript three.js aframe gltf
我从A-Frame学校获取了加载gltf模型的代码.然后我从Khronos加载了Sample Models,这个盒子并尝试加载它,但是我得到了这个错误(好几次)
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>
Run Code Online (Sandbox Code Playgroud)
我可以加载.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>
Run Code Online (Sandbox Code Playgroud)
ngo*_*vin 11
那些模型在2.0文件夹中,这意味着你需要glTF v2.0加载器.A-Frame 0.5.0/0.6.0支持glTF v1.但是在A-Frame 0.7.0中支持glTF v2,但你可以使用gltf-model-next
Don McCurdy:
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