如何更改动画A帧对象的旋转轴? [英] How to change the rotation axis for an animated A-Frame object?
问题描述
与此问题有关,我似乎找不到一种框架内的方式来改变旋转方式A-Frame对象的轴(例如,像地球的倾斜轴)。
Somewhat related to this question, I can't seem to find an 'in-framework' way to change the rotational axis for an A-Frame object (like Earth's tilted axis, for example).
链接的问题是通过将对象包装在父实体中来更改旋转枢轴点
The linked question refers to changing the rotation pivot point by wrapping the object in a parent entity which will offset the child entity (see below):
<a-entity rotation="0 45 0"> <!-- Parent entity -->
<a-box position="0 1 0"></a-box> <!-- Child entity -->
</a-entity>
我采用了类似的方法,但是我没有改变枢轴点,而是尝试改变旋转轴。向父级添加动画时,旋转始终沿全局Y轴,而不是局部(父级)旋转的Y轴:
I've adopted a similar method but rather than offset the pivot point, I've tried to change the rotation axis. When adding an animation to the parent, the rotation is always along the global Y-axis, rather than the local (parent's) rotated Y-axis:
<a-entity rotation="0 0 25"> <!-- Parent entity -->
<a-animation
attribute="rotation"
easing="linear"
dur="60000"
to="0 360 0"
repeat="indefinite">
</a-animation> <!-- Animates parent -->
<a-box position="0 0 0></a-box> <!-- Child entity -->
<a-entity rotation="0 0 25">
有人知道如何最好地将轴从全局空间更改为局部空间,或者是否有没有一种方法可以围绕倾斜轴进行动画处理?
Does anyone know how best to change the axis from global- to local-space, or if there's a way to animate around a tilted axis?
推荐答案
我认为您可以围绕所有内容添加一个附加父实体并对其进行旋转。
I think you can add an additional parent entity around everything and rotate that.
<a-entity> <!-- Grandparent entity -->
<a-animation
attribute="rotation"
easing="linear"
dur="60000"
to="0 360 0"
repeat="indefinite">
</a-animation>
<a-entity rotation="0 0 25"> <!-- Parent entity -->
<a-box position="0 0 0></a-box> <!-- Child entity -->
</a-entity>
</a-entity>
打开A框检查器(ctrl + alt + i)并旋转以查看哪个您想旋转的方式。
Open the A-Frame Inspector (ctrl + alt + i) and play with the rotation to see which way you want to rotate.
这篇关于如何更改动画A帧对象的旋转轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!