实体上的 A 帧静态体

A-Frame static-body on a-entity

我正在尝试框架物理

我可以在形状对象上应用静态属性:

<a-sphere color="red" width="2" height="2" depth="2" position="2 1 -5" rotation="45 0 0" static-body></a-sphere>

但不是在实体对象上,我仍然能够穿过对象:

<a-entity static-body obj-model="obj:models/lamp_mesh.obj;mtl:images/lamp_mesh.mtl" rotation="0 90 0" position="5.46 0 0" animation></a-entity>

是否只能在形状对象上应用 static/dynamic 属性?

或者我哪里做错了

我看过很多关于形状对象的物理学教程,但 none 关于实体对象的教程。

请指教。 提前致谢。

static-body 与任何 <a-entity> 元素一起使用应该没有问题。 Here 你有一个 link,我将它与 <a-entity> 和 gltf 模型一起使用。


physics 组件有一个有用的标志 debug: true

<a-scene physics="debug: true">

如果您没有在对象周围看到线框,则可能没有附加物理体。


确保你的模型加载正确,检查它周围的线框,如果有none,你可以:

1) 将您的 .obj 模型转换为网络标准 .gltf(官方转换器 here
2) 手动创建 physics 个实体。来自 docs:

<a-entity gltf-model="src: mug.glb"
      body="type: dynamic; mass: 5; shape: none;"
      shape__main="shape: cylinder;
                   height: 0.36;
                   radiusTop: 0.24;
                   radiusBottom: 0.24;"
      shape__handle="shape: box;
                     halfExtents: 0.15 0.18 0.04;
                     offset: 0.4 0 0;">
</a-entity>