THREEJS использует кватернионы вместо вращения вокруг X, Y, Z в некотором порядке. Вы можете извлечь кватернион оси:
export function deconstructQuaternion(q: THREE.Quaternion) {
if (q.w > 1) {
q.normalize(); // if w > 1 acos and sqrt will produce errors, this cant happen if quaternion is normalised
}
const angle = 2 * Math.acos(q.w);
const s = Math.sqrt(1 - q.w * q.w); // assuming quaternion normalized then w is less than 1, so term always positive.
const axis = new THREE.Vector3();
if (s < 0.001) { // test to avoid divide by zero, s is always positive due to sqrt
// if s close to zero then direction of axis not important
axis.set(q.x, q.y, q.z); // if it is important that axis is normalized then replace with x=1; y=z=0;
} else {
// normalize axis
axis.set(q.x / s, q.y / s, q.z / s)
}
return {
axis,
angle
};
}