2017-09-09 51 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>