【问题标题】:Correct way to call animation through and IF statement (A-Frame animation mixer)?通过和 IF 语句(A-Frame 动画混合器)调用动画的正确方法?
【发布时间】:2020-11-11 14:22:26
【问题描述】:

我目前正在使用 A-Frame 中的动画混合器,并试图在播放特定动画时产生一个条件(例如 A、B、C 中的动画“B”)。

我对 Javascript 不熟悉,但我已经做了几次尝试:

 if(character.getAttribute == character.getAttribute("animation-mixer", {clip: "B"}){
 //  Insert action here 
 }

 if(character == character.setAttribute("animation-mixer", {clip: "B"})){
 //  Insert action here
 };

 if(character.getAttribute("animation-mixer") == {clip: "B"}){
 //  Insert action here
 };

【问题讨论】:

    标签: javascript animation three.js aframe


    【解决方案1】:

    要检索组件数据你应该只使用getAttribute(componentName):

    // grabbing the component data object
    character.getAttribute("animation-mixer")
    
    // same + accessing the clip property
    character.getAttribute("animation-mixer").clip
    
    // checking if the property equals "B"
    if (character.getAttribute("animation-mixer").clip === "B") {
       console.log("Its B!")
    }
    

    setAttribute() 会改变动画:

    setAttribute("animation-mixer", "clip", "A")
    // or character.setAttribute("animation-mixer", {clip: "B"})
    character.getAttribute("animation-mixer").clip // A
    

    【讨论】:

      猜你喜欢
      • 2020-11-16
      • 2021-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多