如何实现Spherical Joint锚点跟随glTF模型的位置与旋转
问题:让Spherical Joint锚点跟随glTF模型的位置与旋转
我需要让Spherical Joint锚点遵循rapier文档示例中的锚点逻辑,跟随加载的glTF模型边缘的位置与旋转变化。目前已通过每帧调用以下代码实现位置跟随:
const move = (leftAnchor, rightAnchor) => { /** * model: 包含glTF模型的组的引用 * leftAnchorPos: leftAnchor的初始位置 * rightAnchorPos: rightAnchor的初始位置 */ const modelPos = model.current.position const leftPos = new Vector3( leftAnchorPos.x + modelPos.x, leftAnchorPos.y + modelPos.y, leftAnchorPos.z + modelPos.z) const rightPos = new Vector3( rightAnchorPos.x + modelPos.x, rightAnchorPos.y + modelPos.y, rightAnchorPos.z + modelPos.z) leftAnchor.setNextKinematicTranslation(leftPos) rightAnchor.setNextKinematicTranslation(rightPos) }
但我无法让锚点正确跟随模型的旋转,想了解是否有更简便的实现方式。
内容的提问来源于stack exchange,提问作者A7med
相关产品推荐
相关产品推荐

