我刚刚开始学习如何使用AR.js创建AR场景,但是在加载自定义3D模型时遇到了一些麻烦。我已经尝试了许多示例,并且所有示例都能完美运行,但是一旦插入自己的模型,它就不会显示出来。对于给定的示例和3D模型,我使用了几乎相同的代码:
<!DOCTYPE html>
<html>
<script src="https://aframe.io/releases/1.0.0/aframe.min.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
<body style="margin : 0px; overflow: hidden;">
<a-scene embedded arjs>
<a-marker preset="hiro">
<a-entity
position="0 0 0"
<!-- example given in AR.js docs -->
<!-- scale="0.05 0.05 0.05"
gltf-model="https://arjs-cors-proxy.herokuapp.com/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/scene.gltf"
-->
<!-- my 3D model -->
scale="0.05 0.05 0.5"
gltf-model="model/scene.gltf"
></a-entity>
</a-marker>
<a-entity camera></a-entity>
</a-scene>
</body>
</html>
我的页面结构:
.
|_ index.html
|_ model
|_ scene.gltf
|_ scene.bin
我的模特:
https://sketchfab.com/3d-models/coronavirus-covid-19-virus-991102145c294fe4b633faecc23f3799
我尝试了许多其他模型,其他格式(.dae,.obj,.fbx),更改了模型的比例,但似乎没有任何效果。可能是什么问题?
答案 0 :(得分:2)
由于两个因素,该模型不会显示:
如果您的模型出现在Dons gltf-viewer中,请始终在香草a-frame
中试用您的模型-至少在fiddle中进行尝试。它易于检查,调试,并且可以确定a-frame
是否引起了麻烦。
scene.gltf
在其当前目录中搜索scene.bin
(编辑并搜索gltf
文件-它易于阅读),但是它不存在。 用故障URL替换路径是一个不好的主意(通常,除了.bin
以外,还有更多路径)。您应该将模型推送到github存储库中,该目录在其中按预期工作。
正在使用arjs glitch here。