A-Frame 具有方向向量的物理系统复合对撞机

A-Frame Physics System Compound Colliders with Orientation Vectors

使用 here 提供的 A-Frame 物理系统组件,我一直在尝试创建类似于文档中示例的复合碰撞器。但是,每当我向任何碰撞体添加方向矢量时,body 形状似乎会破裂并掉入地面静电 body。

关于如何使用这些组件将旋转形状实施到复合碰撞器中,有什么建议吗?使用记录的方法很难排除故障;我还考虑过创建单独的实体并通过锁定约束将它们连接起来,但是当单独的实体之间存在过多重叠时,这样做会引发问题。

根据组件的文档,这是我为一个模型尝试的初始实现:

<a-entity gltf-model="#rams-horn" body="type: dynamic; shape: none; mass: 1;" id="ramsHorn" class="seed" position="0 5 0" scale="1 1 1" rotation="180 45 45"
                 shape__main="shape: sphere;
                              radius: 0.085;
                              offset: -0.145 0.136 0.165;"
                 shape__body1="shape: sphere;
                               radius: 0.06;
                               offset: -0.083 0.243 0.198;"
                 shape__body2="shape: sphere;
                               radius: 0.06;
                               offset: -0.173 0.029 0.118;"
                 shape__bodyTop="shape: box;
                                 halfExtents: 0.084 0.103 0.105;
                                 offset: -0.157 0.098 0.038;
                                 orientation: 48.823 151.396 128.878 1;"

                 shape__leftArm="shape: box;
                                 halfExtents: 0.137 0.0445 0.0325;
                                 offset: 0.005 -0.244 0.06;
                                 orientation: 14.802 -1.075 -11.758 1;"
                 shape__leftArm1="shape: box;
                                  halfExtents: 0.13 0.041 0.0305;
                                  offset: 0.249 -0.271 0.017;
                                  orientation: 4.774 21.49 5.687 1;"
                 shape__leftArm2="shape: box;
                                  halfExtents: 0.09 0.0365 0.02;
                                  offset: 0.412 -0.203 -0.073;
                                  orientation: -5.452 37.235 41.454 1;"
                 shape__leftArm3="shape: box;
                                  halfExtents: 0.0485 0.0305 0.02;
                                  offset: 0.482 -0.107 -0.142;
                                  orientation: -8.285 39.333 53.542 1;"
                 shape__leftArm4="shape: box;
                                  halfExtents: 0.091 0.0285 0.013;
                                  offset: 0.487 0.007 -0.18;
                                  orientation: -16.037 12.177 114.669 1;"

                 shape__rightArm="shape: box;
                                  halfExtents: 0.026 0.044 0.1045;
                                  offset: -0.171 -0.098 -0.15;
                                  orientation: 8.467 -17.253 -43.762 1;"
                 shape__rightArm1="shape: box;
                                   halfExtents: 0.12 0.0245 0.0355;
                                   offset: -0.073 -0.048 -0.325;
                                   orientation: -19.243 36.415 23.184 1;"
                 shape__rightArm2="shape: box;
                                   halfExtents: 0.1065 0.032 0.0205;
                                   offset: 0.092 0.02 -0.43;
                                   orientation: 72.192 124.564 108.909 1;"
                 shape__rightArm3="shape: box;
                                   halfExtents: 0.0865 0.025 0.0145;
                                   offset: 0.263 0.07 -0.436;
                                   orientation: 75.904 92.023 107.88 1;"
                 shape__rightArm4="shape: box;
                                   halfExtents: 0.0455 0.0165 0.0145;
                                   offset: 0.371 0.101 -0.386;
                                   orientation: 70.206 100.066 148.711 1;"
                 shape__rightArm5="shape: box;
                                   halfExtents: 0.0515 0.022 0.01;
                                   offset: 0.407 0.11 -0.31;
                                   orientation: 70.356 103.559 -174.73 1;" shadow>

愚蠢的错误,使用度数而不是弧度来表示方向:(任何其他有类似问题的人都应该参考 Three.js

中的四元数文档

愚蠢的错误愚蠢的第一个答案。 Three.js和CANNON.js中四元数的单位是弧度,但欧拉坐标和四元数之间的转换也是必须的。您可以编写一个转换工具或使用CANNON.js中四元数class支持的方法;我使用了 online calculator 因为我的对撞机仅由几个基元组成。