2 回答

TA贡献2011条经验 获得超2个赞
经过一番摆弄,我找到了解决方案:
let root = new Bone();
let parent = root;
let pos = new Vector3();
for (let joint of robot.arm.movable) {
let link = robot.getLinkForJoint(joint);
link.getWorldPosition(pos);
let bone = new Bone();
parent.add(bone);
parent.lookAt(pos);
parent.updateMatrixWorld(); // crucial for worldToLocal!
bone.position.copy(bone.worldToLocal(pos));
parent = bone;
}
重要的部分是在lookAt()之后调用updateMatrixWOrld(),以便bone.worldToLocal()正常工作。还lookAt()省去了很多矩阵麻烦:)

TA贡献1856条经验 获得超5个赞
child.getWorldPosition(p);
恐怕将世界空间中的位置应用于代表本地Bone.position
空间中的位置是不正确的。
骨骼父 = 骨骼;
这条线看起来也有问题。一根骨头可以有多个子元素。在我看来,您的代码没有考虑这个用例。
添加回答
举报