html - 实体上的 A-Frame 静态主体
问题描述
我正在尝试框架物理
我可以在形状对象上应用静态体属性:
<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-body
与任何<a-entity>
元素
一起使用应该没有问题。在这里你有一个链接,我将它与<a-entity>
gltf 模型一起使用。
debug: true
该组件有一个有用的标志physics
:
<a-scene physics="debug: true">
如果您在对象周围没有看到线框,则可能没有物理实体连接到它。
确保你的模型加载正确,检查它周围的线框,如果没有,你可以:
1)将您的.obj
模型转换为网络标准(此处.gltf
为官方转换器)
2)手动创建主体。从文档:physics
<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>
推荐阅读
- javascript - Gulp browserSync 不会自动重新加载
- php - 来自 Ajax jQuery 数组的 POST 的取消定义索引
- java - 编译错误:对 TreeMap 的引用不明确
- c++ - 如何从 range-v3 的 istream_range 检索文件大小?
- c# - 按下按钮后动态加载的用户控件消失 c# win forms
- machine-learning - catboost算法中对称树背后的直觉是什么?
- r - Unnest 函数只保留列表中的第一个值
- c++ - 在底部设置运行进程
- java - 从第三个应用程序读取清单
- jupyter-notebook - 如何在 jupyter notebook 中打开整个文件