Javascript 如何从a帧上的GLB 3D对象获取动画片段的名称?
我在a帧上创建了一个简单的场景,并导入了一个包含3个动画的3D GLB对象 现在,我想使用纯Javascript获取这些动画的名称,以便稍后使用,但我不知道如何获取它们 使用浏览器控制台,我能够找到动画的名称,但无法使用JS收集它们Javascript 如何从a帧上的GLB 3D对象获取动画片段的名称?,javascript,aframe,Javascript,Aframe,我在a帧上创建了一个简单的场景,并导入了一个包含3个动画的3D GLB对象 现在,我想使用纯Javascript获取这些动画的名称,以便稍后使用,但我不知道如何获取它们 使用浏览器控制台,我能够找到动画的名称,但无法使用JS收集它们 感谢您的帮助动画参考保存在gltf模型组件属性:model.animations()。正如Kostax在其评论中所写,您可以简单地抓住该房产: // better to check the glft-model, as it is responsible for
感谢您的帮助动画参考保存在
gltf模型
组件属性:model.animations
()。正如Kostax在其评论中所写,您可以简单地抓住该房产:
// better to check the glft-model, as it is responsible for loading the model
document.getElementById("GLB3D614").components['gltf-model'].model.animations
为了确保属性不是未定义的,您应该等待,直到发出模型加载
事件:
// custom component of the entity with the gltf-model
this.el.addEventListener('model-loaded', e => {
console.log(this.el.components['gltf-model'].model.animations
})
为什么不深入研究组件对象呢?document.getElementById(“GLB3D614”).components['animation-mixer'].model.animationsThank@KostasX!我以前在Chrome上使用过该代码,但没有结果。不,我在Firefox上试过,效果很好…不知道为什么不起作用