我正在尝试使用ar.js加载gltf2.0模型。我已经试过好几次了,但我觉得我做错了什么。代码如下:
<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>gltf model的文件夹与html代码所在的文件夹相同。有谁能帮我一下吗?
发布于 2018-04-19 17:30:12
这是旧的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)
https://stackoverflow.com/questions/48596340
复制相似问题