I managed to achieve my goal of rotating a sphere around the x and y axes using the following code:
// 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);
However, when I adjust the scale of the ballMesh
to anything other than (1,1,1), the rotations become erratic in a way that is challenging to explain. You can see an example of this behavior in this jsfiddle:
http://jsfiddle.net/pxTTv/26/ (use the arrow keys to rotate)
Returning the scale (as shown in the jsfiddle code) to (1,1,1) resolves the issue and it rotates as expected.
I am curious to know what is causing this and how I can address it?