2017-09-09 52 views
0

我一直在試圖在一個完美的圓圈中移動圖像,但無法做到完美。我編寫了一個盒子以方形路徑旋轉。代碼如下。如何動畫圖像在框架中移動一圈?

<a-box id="box" position="-1 0.5 -3" src="images/pic2.jpg" onclick="loaddoc()" visible="true"> 
 
      <a-animation attribute="position" fill="both" from="-1.0 0.5 -3" to="-2 0.5 -3" dur="5000"></a-animation> 
 
      <a-animation attribute="position" fill="both" from="-2 0.5 -3" to="-2 0.5 3" dur="5000" delay="5000"></a-animation> 
 
      <a-animation attribute="position" fill="both" from="-2.0 0.5 3" to="-1 0.5 3" dur="5000" delay="10000"></a-animation> 
 
      <a-animation attribute="position" fill="both" from="-1.0 0.5 3" to="-1 0.5 -3" dur="5000" delay="15000"></a-animation> 
 
     </a-box>

+0

代碼的後JS-小提琴。 –

回答

0

這是所有關於父母 - 子女親戚關係。
您在您的父實體中放置一個位置偏移的子項,並旋轉父項。


<script src="https://aframe.io/releases/0.6.1/aframe.min.js"></script> 
 
<a-scene> 
 
    <a-entity position="0 5 -5"> 
 
    <a-box color="red" position="0 -1 0"></a-box> 
 
    <a-animation attribute="rotation" dur="4000" fill="forwards" to="0 0 360" repeat="indefinite"></a-animation> 
 
    </a-entity> 
 
</a-scene>