通过和IF语句调用动画的正确方法(A帧动画混合器)



我目前正在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
};

要检索组件数据,只需使用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

最新更新