I am attempting to create a rotation of the Earth around its tilted axis using Three.js. I came across this helpful solution and tried implementing it in my code, but unfortunately, it doesn't seem to be working as expected.
After running the code, I noticed that the planet remains stationary and doesn't exhibit any signs of rotation. Since I lack a solid understanding of quaternions and how they operate, I'm struggling to pinpoint where things might have gone wrong.
function rotateAroundAxis(object, axis, radians) {
var vector = axis.normalize();
var quaternion = new THREE.Quaternion().setFromAxisAngle(vector, radians);
object.rotation = new THREE.Euler().setFromQuaternion( quaternion );
}
earthAxis = new THREE.Vector3(Math.cos(23.4*Math.PI/180), Math.sin(23.4*Math.PI/180), 0);
function render() {
stats.update();
step += 0.02;
rotateAroundAxis(earth, earthAxis, step);
}