【发布时间】:2021-01-19 02:44:06
【问题描述】:
如何在 a-frame 动画混合器中从动画中间(从第 n 次/帧开始)开始动画
【问题讨论】:
如何在 a-frame 动画混合器中从动画中间(从第 n 次/帧开始)开始动画
【问题讨论】:
Soon 动画混合器将有一个startFrame 属性,它将确定以毫秒为单位的开始时间。
不过,有一种简单的方法可以实现它。该组件基于THREE.AnimationMixer,可作为animation-mixer 属性使用:
// element refers to an entity with the animation mixer; make sure it's loaded
let mixerComponent = element.components["animation-mixer"]
let mixer = mixerComponent.mixer;
混音器有一个setTime(time) 函数,它将设置动画在给定时间(以秒为单位)开始:
// will set the start time at 1s
mixer.setTime(1);
如果动画是循环播放的,请确保在每个循环中都这样做:
this.el.addEventListener("animation-loop", e => mixer.setTime(1));
【讨论】: