Multiple aframe animations

百般思念 提交于 2021-02-08 08:55:28

问题


I have built a scripted animation from point A to B to C and so on.

Animations are triggered via JS (e.g document.getElementById('camera').emit('animazione_zero_avanti')).

I am creating animations like this:

i would like to add a Z-Axis rotation as well to the first animation. Can an animation have multiple attributes?

Thanks in advance.


回答1:


You can add multiple elements. Though note that rotating the camera or taking control of it is heavily not recommended for VR due to sickness. And you might have troubles since the controls continuously update the camera. You might be able to animate a wrapper entity, but then the rotations will compose weirdly.

<a-camera>
  <a-animation attribute="position" ...></a-animation>
  <a-animation attribute="rotation" ...></a-animation>
</a-camera>

Or

<a-entity>
  <a-animation attribute="rotation" ...></a-animation>
  <a-camera>
    <a-animation attribute="position" ...></a-animation>
  </a-camera> 
</a-entity>



回答2:


Starting from aframe version 0.9.0 <a-animation> is no longer supported.

But you can still use and combine animations using the property animation.

For example:

<a-sphere color="blue" radius="0.5" position="0 0.5 0" segments-height="53"
    animation='   property: position; dur: 5000; from: -2 0.5 0; to: 2 0.5 0; dir: alternate; easing: linear; loop: true;'
    animation__2='property: rotation; dur: 1000; from: 0 0 0;    to: 0 360 0; dir: normal;    easing: linear; loop: true;'
    animation__3='property:    scale; dur: 1000; from: 1 1 1;    to: 2 2 2;   dir: alternate; easing: linear; loop: true;'>
</a-sphere>

A live example can be found at this CodePen.

More detail at the a-frame API.



来源:https://stackoverflow.com/questions/38515770/multiple-aframe-animations

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!