aframe 获取 object3d 子项 [英] aframe get object3d children
问题描述
我正在为游戏使用 gltf 模型.它被引用为 -
<a-asset-item id="orca1" src="../images/models/orca/scene.gltf"></a-asset-item>
然后访问为
<a-entity id="orca" position="-1 0.4 -40" gltf-model="#orca1"></a-entity>
和
但 e.detail.model 在控制台日志中提供以下内容 -
因此,当我尝试从 data.target.object3d.children[0] 访问OSG_Scene"时,我在 console.log 中得到undefined".
另外,为什么我无法通过这两种方法中的任何一种获得OSG_Scene" -
- data.target.getObject3D('Scene') OR
- data.target.getobjectbyname("OSG_Scene")
非常感谢您的帮助.
解决方案应该是data.target.getObject3D('mesh')
I am working with a gltf model for a game. It is referenced as -
<a-asset-item id="orca1" src="../images/models/orca/scene.gltf"></a-asset-item>
and then accessed as
<a-entity id="orca" position="-1 0.4 -40" gltf-model="#orca1"></a-entity>
and
<a-entity model-subset="target: #orca"></a-entity>
So, in the model-subset component, I am trying to get a hold on the object3d scene so that I can clone it. Here is how I access the object3d there
AFRAME.registerComponent('model-subset', {
schema: {
target: { default: '', type: 'selector' }
},
init: function() {
var data = this.data;
var el = this.el;
console.log(data.target.object3D.children);
data.target.addEventListener('model-loaded', function(e) {
this.model = e.detail.model;
console.log(this.model)
})
}
})
What I am trying to understand is - when I do the data.target.object3D.children, I get the following in my console log -
but the e.detail.model gives the following in the console log -
So, when I try to access the "OSG_Scene" from data.target.object3d.children[0], I get "undefined" in the console.log.
Also, why am I not able to get "OSG_Scene" via either of these methods -
- data.target.getObject3D('Scene') OR
- data.target.getobjectbyname("OSG_Scene")
Thank you so much for your help.
解决方案 It should be data.target.getObject3D('mesh')
这篇关于aframe 获取 object3d 子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!