I have the need to precisely adjust the rotation of an object along the world axis by a specific angle. At the moment, I am utilizing the rotateAroundWorldAxis function (which I came across in another discussion) in my attempts to accomplish this.
function render() {
// update mesh position
rotateAroundWorldAxis(mesh, new THREE.Vector3(1, 0, 0), angle);
renderer.render(scene, camera);
}
function rotateAroundWorldAxis(object, axis, radians) {
rotWorldMatrix = new THREE.Matrix4();
rotWorldMatrix.makeRotationAxis(axis.normalize(), radians);
rotWorldMatrix.multiply(object.matrix);
object.matrix = rotWorldMatrix;
object.rotation.setFromRotationMatrix(object.matrix);
}
The issue lies in my requirement to solely set the angle (such as rotation.x = angle), rather than incrementing it (like rotation.x += angle). Can anyone suggest how I can modify the rotateAroundWorldAxis function above to allow me to set the angle without incrementing it?