Reputation: 11
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?
Upvotes: 1
Views: 2927
Reputation: 10402
This is known issue with old aframe
builds, however your code has extra issues. Bump up your aframe
version and aframe-ar
version. Remove the aframe-extras
script, it's not necessary in the new builds. Get rid of the a-anchor
and finally add a marker with 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>
Alternatively, if you want to keep the old aframe
library you can load the model using a-assets
like this:
<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>
but note that you'll only be able to load gltf 1.0
models (the helmet is gltf 2.0
)
Upvotes: 1