I am trying to load a gltf2.0
model using ar.js
. I have tried it several time but I think I am wrong at something. Here's the code:
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.0/aframe/examples/vendor/aframe/build/aframe.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.0/aframe/build/aframe-ar.js"></script>
<script src="https://rawgit.com/donmccurdy/aframe-extras/master/dist/aframe-extras.loaders.min.js"></script>
<body style='margin : 0px; overflow: hidden;'>
<a-scene embedded arjs='trackingMethod: best;'>
<a-anchor hit-testing-enabled='true'>
<a-gltf-model-next src="damagedHelmet/damagedHelmet.gltf" scale="0.5 0.5 0.5"></a-gltf-model>
</a-anchor>
<a-camera-static/>
</a-scene>
</body>
The folder of gltf model is in the same folder in which the html code is. Can anyone please help me with this?
答案 0 :(得分:1)
这是旧aframe
版本的已知问题,但您的代码存在其他问题。提高您的aframe
版本和aframe-ar
版本。删除aframe-extras
脚本,在新版本中没有必要。摆脱a-anchor
,最后添加一个带有a-marker-camera
的标记:
<script src="https://aframe.io/releases/0.8.0/aframe.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.5/aframe/build/aframe-ar.js"></script>
<body style='margin : 0px; overflow: hidden;'>
<a-scene embedded arjs='trackingMethod: best;'>
<a-gltf-model src="https://rawgit.com/KhronosGroup/glTF-Sample-Models/master/2.0/DamagedHelmet/glTF/DamagedHelmet.gltf"></a-gltf-model>
<a-marker-camera preset='hiro'></a-marker-camera>
<a-camera-static/>
</a-scene>
</body>
或者,如果您想保留旧的aframe
库,可以使用a-assets
加载模型,如下所示:
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.0/aframe/examples/vendor/aframe/build/aframe.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.0/aframe/build/aframe-ar.js"></script>
<body style='margin : 0px; overflow: hidden;'>
<a-scene embedded arjs='trackingMethod: best;'>
<a-assets>
<a-asset-item id="model" src="https://rawgit.com/KhronosGroup/glTF-Sample-Models/master/1.0/CesiumMan/glTF/CesiumMan.gltf" crossOrigin="anonymous"></a-asset-item>
</a-assets>
<a-gltf-model src="#model"></a-gltf-model>
<a-marker-camera preset='hiro'></a-marker-camera>
<a-camera-static/>
</a-scene>
</body>
但请注意,您只能加载gltf 1.0
个型号(头盔为gltf 2.0
)