如何让 a-frame 实体知道其动画属性已更改?
How do I make an a-frame entity aware that its animation attribute has changed?
我在 aframe 中有一个 <a-box>
和 <a-animation>
:
<a-box scale='3 3 3' position='0 3 -8' color=red>
<a-animation begin=move attribute=position dur=2000 to='10 3 -12'></a-animation>
</a-box>
如果我将 to
属性设置为新值,然后 运行 动画,它会使用之前的 from
和 to
值执行动画。
但是,如果我从 dom 中删除 <a-animation>
然后再次添加它(设置新的 to
值) , 它现在将使用新值进行动画处理。
有没有办法设置新的 to
值,然后让 <a-box>
/ <a-animation>
知道它的 to
值已经更新,以便下次我发出 begin
move
时,它将使用新的 to
属性?
此动画组件应在每次 属性 更改时重新创建动画配置:https://github.com/ngokevin/kframe/tree/master/components/animation。我将更多地维护此动画实现,而不是 <a-animation>
可能会被弃用的实现。
<a-box scale='3 3 3' position='0 3 -8' color='red'
animation__move="startEvents: move; property: position; dur: 2000; to: 10 3 -12"></a-box>
document.querySelector('a-box').setAttribute('animation__move', 'to', '20 20 20');
我在 aframe 中有一个 <a-box>
和 <a-animation>
:
<a-box scale='3 3 3' position='0 3 -8' color=red>
<a-animation begin=move attribute=position dur=2000 to='10 3 -12'></a-animation>
</a-box>
如果我将 to
属性设置为新值,然后 运行 动画,它会使用之前的 from
和 to
值执行动画。
但是,如果我从 dom 中删除 <a-animation>
然后再次添加它(设置新的 to
值) , 它现在将使用新值进行动画处理。
有没有办法设置新的 to
值,然后让 <a-box>
/ <a-animation>
知道它的 to
值已经更新,以便下次我发出 begin
move
时,它将使用新的 to
属性?
此动画组件应在每次 属性 更改时重新创建动画配置:https://github.com/ngokevin/kframe/tree/master/components/animation。我将更多地维护此动画实现,而不是 <a-animation>
可能会被弃用的实现。
<a-box scale='3 3 3' position='0 3 -8' color='red'
animation__move="startEvents: move; property: position; dur: 2000; to: 10 3 -12"></a-box>
document.querySelector('a-box').setAttribute('animation__move', 'to', '20 20 20');