handleGLTFLoaded({ detail }) {
const el = detail.value.target;
const gltf = el.getComponent("gltf");
const ballonGLTF = gltf.getInternalNodeByName("支架");
ballonGLTF.addComponent(xrFrameSystem.CubeShape,{size: [0.2,3.5,0.2],center:[0,0.3,0]});
ballonGLTF.addComponent(xrFrameSystem.ShapeInteract, { collide: true, bounciness: 0 });
const cube = gltf.getInternalNodeByName("ground");
cube.addComponent(xrFrameSystem.CubeShape,{autoFit:true});
cube.addComponent(xrFrameSystem.ShapeInteract,{ collide: true, bounciness: 0 });
const left = gltf.getInternalNodeByName("left");
left.addComponent(xrFrameSystem.MeshShape,{size: [2,0.02,2]});
left.addComponent(xrFrameSystem.ShapeInteract, { collide: true, bounciness: 0 });
}
上面的代码展示了就是在GLTF加载成功之后,我需要对内部节点进行碰撞或者重叠检测,但是发现只能按照 “支架”那段代码为例子进行添加shape,然后才能进行碰撞检测。
增加CubeShape组建,设置autoFit:true,我log输出检查时设置成功的,但是不进行碰撞检测。
增加meshShape组建,也是设置成功了但是无法进行碰撞检测。
请教下,autoFit参数或者MeshShape,只能作用于这个gltf整体,而不能作用于内部组件。是因为缺少包围盒盒包围球吗?那么我blender导出模型的时候应该怎么做?