簡體   English   中英

通過和 IF 語句(A-Frame animation 混音器)調用 animation 的正確方法?

[英]Correct way to call animation through and IF statement (A-Frame animation mixer)?

我目前正在使用 A-Frame 中的 animation 混音器,並試圖在播放特定 animation 時出現條件(例如,A、B、C 中的 Animation '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()將改變 animation:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM