【发布时间】:2012-07-23 10:47:26
【问题描述】:
我想围绕世界 x 和 y 轴旋转一个球体。我用这段代码成功地做到了:
// Update ball rotation.
var tempMat = new THREE.Matrix4();
tempMat.makeRotationAxis(new THREE.Vector3(0,1,0), stepX/ballRadius);
tempMat.multiplySelf(ballMesh.matrix);
ballMesh.matrix = tempMat;
tempMat = new THREE.Matrix4();
tempMat.makeRotationAxis(new THREE.Vector3(1,0,0), -stepY/ballRadius);
tempMat.multiplySelf(ballMesh.matrix);
ballMesh.matrix = tempMat;
ballMesh.rotation.getRotationFromMatrix(ballMesh.matrix);
但是,当我以任何方式远离 (1,1,1) 缩放 ballMesh 时,旋转会以一种难以描述的方式出错。我在这里提出了一个 jsfiddle 示例:
http://jsfiddle.net/pxTTv/26/(使用方向键旋转)
如果将比例(在 jsfiddle 代码中表示)改回 (1,1,1),它会按我的预期工作。
这是什么原因造成的,我该如何解决?
【问题讨论】:
标签: javascript matrix webgl three.js rotational-matrices