【问题标题】:A-frame animation to value and backA 帧动画到值并返回
【发布时间】:2017-10-30 23:56:03
【问题描述】:

我目前是第一次使用 a-frame,但不知道如何重新设置动画回到起点。目前我有一个旋转 90 度的手臂,当它完成后,它会弹回原来的位置。我怎样才能使动画从 0 度变为 90 度并返回。

<a-obj-model src="#robot" mtl="#material" position="0 0 -150">
</a-obj-model>
<a-obj-model src="#robotshoulder" mtl="#material" position="0 0 -150">
    <a-animation attribute="rotation"
        dur="3000"
        fill="both"
        from="0 0 0"
        to="90 0 0"
        repeat="indefinite"></a-animation>
    <a-obj-model src="#robotarmr" mtl="#material">
    </a-obj-model>
</a-obj-model>

已经感谢您的帮助!

【问题讨论】:

    标签: html animation aframe


    【解决方案1】:

    尝试在动画属性中使用 direction="alternate"。

    来自 A-Frame 文档:

    direction 属性定义了在起始值和最终值之间动画的方式。 当我们定义一个交替方向时,动画会像溜溜球一样在 from 和 to 值之间来回切换。只有当我们重复动画时,交替方向才会生效。

    【讨论】:

    • 感谢您的回复,我试了一下,但由于某种原因并没有改变任何东西。
    • 哦,然后尝试删除填充属性,看看是否有效。我现在无法测试,抱歉。我认为它会干扰您想要的行为。 From A-Frame: backwards 在动画开始之前,将起始值设置为 from 值。 both 结合后向填充和前向填充的效果。 forwards 动画结束后,最终值将保持在 to 值。默认填充。
    • 确实是这个问题!非常感谢。
    猜你喜欢
    • 2016-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-03
    • 2021-10-06
    • 2021-07-20
    • 2021-07-22
    • 1970-01-01
    相关资源
    最近更新 更多