我刚刚开始学习如何用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),改变了模型的规模,但似乎没有什么效果。有什么问题吗?
发布于 2020-03-24 08:43:55
由于以下两个因素,该模型不会出现:
如果您的模型出现在Dons 格尔特夫中--总是尝试使用香草a-frame --至少在小提琴中是这样的。这很容易检查、调试,并且您可以确定a-frame是否造成了问题。
scene.gltf在其当前目录中搜索scene.bin (编辑和搜索gltf文件--它的人类可读性),但它不在那里。用故障urls替换路径是个坏主意(通常,除了.bin之外,还有更多的路径)。您应该将模型推到github存储库中,在github存储库中目录按预期工作。
正在工作的小故障。
https://stackoverflow.com/questions/60816750
复制相似问题