在Three.js中,如何在改变父母的轮换时保持一个子对象静止?我有一个关节机器人模型,其根节点是躯干(Body_Torso),但我试图保持脚(Body_RAR)“接地”。显而易见的方法(计算脚的矩阵变换,并将其应用于躯干)具有非常奇怪的结果,似乎与时间有关。这是我的代码:
// Hold the foot in place!
footMatrix = new THREE.Matrix4();
footMatrix.copy(hubo.links.Body_RAR.matrixWorld);
function fixFoot() {
// Rotate the whole shebang so that the foot is the "grounded" object.
a = new THREE.Matrix4();
a.getInverse(hubo.links.Body_RAR.matrixWorld);
b = new THREE.Matrix4();
b.multiplyMatrices(a,footMatrix);
hubo.links.Body_Torso.applyMatrix(b);
hubo.canvas.render();
}
或那种程度的东西。 Object3D.applyMatrix()是否异步?我只是得到了非常奇怪的结果。如果我只计算一次,它似乎做正确的事情,但如果我尝试将其连接到滑块,脚部位置会出现很多“抖动”。有时机器人就会从页面上消失。有没有更好的方法来实现我的目标?
修改 这是一个实例:http://wmhilton.github.io/hubo-js/examples/sliders/sliders.html
重现的步骤:
答案 0 :(得分:1)
我可以更轻松地使用Object3D层次结构,并更改子.rotation
属性,而不是应用矩阵,例如此机器人手臂模拟http://dimitriipokrovskii.appspot.com/robot_arm_joints.html