【问题标题】:AR.JS - rotating globeAR.JS - 旋转地球
【发布时间】:2018-04-18 00:12:23
【问题描述】:

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

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

    <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>
    

    【讨论】:

      猜你喜欢
      • 2021-05-16
      • 2014-02-02
      • 2015-03-03
      • 1970-01-01
      • 1970-01-01
      • 2014-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多