【问题标题】:A-Frame Animation-mixer start animation at a perticular time frameA-Frame Animation-mixer 在特定时间帧开始动画
【发布时间】:2021-01-19 02:44:06
【问题描述】:

如何在 a-frame 动画混合器中从动画中间(从第 n 次/帧开始)开始动画

【问题讨论】:

    标签: animation aframe


    【解决方案1】:

    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));
    

    你可以看到它在工作here (source)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-22
      • 2021-09-09
      • 1970-01-01
      • 2021-09-21
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 2016-12-15
      相关资源
      最近更新 更多