我第一次使用 AR.JS 并用一个简单的小动画解决了一些问题我试图获得一个在 HIRO 标记上方旋转的地球图像。以下代码有效:
<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>
<img id='earth' src='https://raw.githubusercontent.com/aframevr/sample-assets/master/assets/images/space/earth_atmos_4096.jpg'/>
<img id='earth2' src='http://www.keepthestreak.net/Earth_NZ.jpg'/>
</a-assets>
<a-anchor hit-testing-enabled='true'>
<a-sphere material='src: #earth;'
position="0 0.5 0" radius="1" segments-height="53">
<a-animation attribute="rotation"
dur="7000"
to="0 360 0"
easing= "linear"
repeat="indefinite">
</a-animation>
</a-sphere>
</a-anchor>
<a-camera-static/>
</a-scene>
</body>
地球仪也从上方显示,因此主要显示北极。我希望最高点是赤道,这样你就可以看到几乎所有有人居住的世界。我查看了 a-frame 的客户端文档并试图找到一个更好的例子,但我真的很难弄清楚如何旋转它来查看世界上人口稠密的部分而不是冰盖。
关于最终预期结果的一点背景。
我最终想要实现的是一个旋转地球的 AR 叠加,突出显示了用户的祖国。为此,我需要定义多个源图像并使用(可能)一些 javascript 内联更改它们。
谢谢你的帮助。