英文:
How to access a GLB's Skeleton when using Aframe's entity gltf-model to load it?
问题
我正在遵循此规范来加载GLB文件,https://aframe.io/docs/1.4.0/components/gltf-model.html,
我已经使用以下格式加载了一个GLB文件。
<a-scene>
<a-entity gltf-model="./assets/models/Streetbud_1.7.glb"
move position=".5 1.5 -15" scale="5 5 5"></a-entity>
</a-scene>
如果我然后访问该模型,在控制台中会看到以下内容。
如果我使用three.js的gltfloader加载相同的模型,如下所示。
gltfLoader.load('./assets/models/Streetbud_1.7.glb', (gltf) => {
....
}
我会得到以下结果。
请注意,在gltfLoader的情况下,模型中有骨骼。在使用
我希望将一些BVH动画重新定位到我的骨骼上。有没有办法让骨架在使用
英文:
I'm following this spec for loading GLB's, https://aframe.io/docs/1.4.0/components/gltf-model.html,
i've loaded a GLB file using
this format.
<a-scene>
<a-entity gltf-model="./assets/models/Streetbud_1.7.glb"
move position=".5 1.5 -15" scale="5 5 5"></a-entity>
</a-scene>
If i then access the model, i see the following in the console.
If i load the same model using the gltfloader from three.js with..
gltfLoader.load('./assets/models/Streetbud_1.7.glb', (gltf) => {
....
}
i get the following.
Notice, in the case of the gltfLoader, the Skeleton is available in the model. I don't have this option when using the Aframe entity.
I'm looking to retarget some BVH animations to my skeleton. Any ideas on how i can get the skelton populated using <a-entity>? I prefer to use the newer approach for compatibility reasons with some other libraries..
答案1
得分: 0
应该像这样工作:
- 等待模型加载完成
- 使用
getObject3D('mesh')
查找根网格对象 - 遍历查找带有
isSkinnedMesh
标志的节点 - 访问
skeleton
属性。
<hr>
AFRAME.registerComponent("skinnedMesh-logger", {
init: function() {
this.el.addEventListener("model-loaded", e => {
const mesh = this.el.getObject3D("mesh");
mesh.traverse(node => {
if (!node.isSkinnedMesh) return;
console.log(node); // 或者 node.skeleton
})
})
}
})
英文:
Should work like this:
- wait until the model is loaded
- find the root mesh object with
getObject3D('mesh')
- traverse it looking for the
isSkinnedMesh
flag. - access the
skeleteon
property.
<hr>
AFRAME.registerComponent("skinnedMesh-logger", {
init: function() {
this.el.addEventListener("model-loaded", e => {
const mesh = this.el.getObject3D("mesh");
mesh.traverse(node => {
if (!node.isSkinnedMesh) return;
console.log(node); // or node.skeleton
})
})
}
})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论