【问题标题】:How to change the rotation axis for an animated A-Frame object?如何更改动画 A-Frame 对象的旋转轴?
【发布时间】:2017-08-07 21:19:23
【问题描述】:

this question 有点相关,我似乎找不到一种“框架内”方法来更改 A 框架对象的旋转轴(例如地球的倾斜轴)。

链接的问题是指通过将对象包装在将偏移子实体的父实体中来更改旋转轴心点(见下文):

<a-entity rotation="0 45 0">        <!-- Parent entity -->
  <a-box position="0 1 0"></a-box>  <!-- Child entity -->
</a-entity>

我采用了类似的方法,但不是偏移枢轴点,而是尝试更改旋转轴。向父级添加动画时,旋转始终沿全局 Y 轴,而不是局部(父级)旋转的 Y 轴:

<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">

有谁知道如何最好地将轴从全局空间更改为局部空间,或者是否有办法围绕倾斜的轴设置动画?

【问题讨论】:

  • 我认为您可以在所有内容周围添加一个额外的父实体并旋转它。打开 A-Frame Inspector (ctrl + alt + i) 并使用旋转来查看您想要旋转的方式。
  • @ngokevin 太简单了!有效。您可以重新发布您的评论作为我接受的答案吗?
  • 甜蜜,添加了一个答案。

标签: html rotation aframe webvr


【解决方案1】:

我认为您可以在所有内容周围添加一个额外的父实体并旋转它。

<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-Frame Inspector (ctrl + alt + i) 并使用旋转来查看您想要旋转的方式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-24
    • 1970-01-01
    • 2021-08-13
    • 2020-09-29
    • 1970-01-01
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多