簡體   English   中英

如何從 A-Frame 上的 GLB 3D 對象獲取動畫剪輯的名稱?

[英]How to get the names of animation clips from a GLB 3D object on A-Frame?

我在 A-FRAME 上創建了一個簡單的場景,並導入了一個包含 3 個動畫的 3D GLB 對象。

現在我想使用純 Javascript 獲取這些動畫的名稱,以便稍后使用它,但我不知道如何獲取它們。

使用瀏覽器控制台我能夠找到動畫的名稱,但無法使用 JS 收集它們。

GLB 3D 對象組件

任何幫助表示贊賞

動畫引用保存在gltf-model組件屬性中: model.animations ( source )。 就像 KostasX 在他的評論中寫的那樣,你可以簡單地獲取屬性:

// better to check the glft-model, as it is responsible for loading the model
document.getElementById("GLB3D614").components['gltf-model'].model.animations 

為確保屬性不是undefined ,您應該等到model-loaded事件發出:

// custom component of the entity with the gltf-model
this.el.addEventListener('model-loaded', e => {
    console.log(this.el.components['gltf-model'].model.animations
})

暫無
暫無

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

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