是否可以让单个实体执行多个动画



我想知道我是否可以让一个对象,比如盒子或球体,做两个动画,比如旋转和颜色。我知道你可以在动画属性的属性部分设置这些属性,但如果我试图在一个对象上放置多个动画属性,或者如果我尝试在一个动画属性中放置两个属性,它要么不设置动画,要么只设置其中一个动画。这是我正在使用的代码,如果可能的话,如果你们中的任何人都能编辑它使其工作,我将不胜感激:

<!DOCTYPE html>
<html>
<head>
<script src="https://aframe.io/releases/1.0.0/aframe.min.js"></script>
</head>
<body>
<a-scene>
<a-sky color="lightblue"></a-sky>
<a-box position="0 0 -5" width="2" depth="2" height="2" color= rgb(0,0,0)
animation="
property: rotation;
from: 0 0 0;
to: -360 -360 -360;
loop: true;
dur: 3000;
dir: alternate;
property: color;
from: rgb(0,0,0);
to: rgb(255,255,255);
loop: true;
dur: 3000;
dir: alternate;"></a-box>
</a-scene>
</body>
</html>

您需要将动画指令拆分为单独的animation组件,它们应该如下所示:

animation__<id>="stuff"
// like this:
animation__first="single animation related stuff"
animation__second="another single animation related stuff"

您的代码应该更像这样:

<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<a-scene>
<a-sky color="lightblue"></a-sky>
<a-box position="0 0 -5" width="2" depth="2" height="2" color=rgb(0,0,0) 

animation__rotation="
property: rotation;
from: 0 0 0;
to: -360 -360 -360;
loop: true;
dur: 3000;
dir: alternate;"

animation__color="
property: color;
from: rgb(0,0,0);
to: rgb(255,255,255);
loop: true;
dur: 3000;
dir: alternate;"></a-box>
</a-scene>

最新更新