AR.JS - 旋转地球仪

问题描述 投票:1回答:1

我第一次使用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>

地球也从上面显示,所以主要显示北极。我希望最重要的是成为赤道,所以当它旋转时,你可以看到几乎所有有人居住的世界。我已经查看了client documentation的一个框架,并试图找到一个更好的例子,但我真的很难弄清楚如何旋转它来看看世界上填充的位而不是冰盖。

关于最终预期结果的一点背景。

我最终想要实现的是旋转地球仪的AR覆盖,其中突出显示用户本国。要做到这一点,我需要定义多个源图像,并与(可能)一些javascript内联更改它们。

谢谢你的帮助。

javascript augmented-reality aframe ar.js
1个回答
1
投票

您需要添加一个执行旋转的空实体。这在这里工作:

<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' />
    </a-assets>

    <a-anchor hit-testing-enabled='true'>
      <a-entity rotation="90 0 0">
        <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-entity>
    </a-anchor>
    <a-camera-static/>
  </a-scene>
</body>
© www.soinside.com 2019 - 2024. All rights reserved.