src/orbit-orientation-controls.js
function Quat2Angle(x, y, z, w) {
  const test = x * y + z * w;

  // singularity at north pole
  if (test > 0.499) {
    const yaw = 2 * Math.atan2(x, w);
    const pitch = Math.PI / 2;
    const roll = 0;

    return new THREE.Vector3(pitch, roll, yaw);
  }

  // singularity at south pole
  if (test < -0.499) {
    const yaw = -2 * Math.atan2(x, w);
    const pitch = -Math.PI / 2;
    const roll = 0;

    return new THREE.Vector3(pitch, roll, yaw);
  }

  const sqx = x * x;
  const sqy = y * y;
  const sqz = z * z;
  const yaw = Math.atan2(2 * y * w - 2 * x * z, 1 - 2 * sqy - 2 * sqz);
  const pitch = Math.asin(2 * test);
  const roll = Math.atan2(2 * x * w - 2 * y * z, 1 - 2 * sqx - 2 * sqz);

  return new THREE.Vector3(pitch, roll, yaw);
}
function Quat2Angle(x, y, z, w) {
  const test = x * y + z * w;

  // singularity at north pole
  if (test > 0.499) {
    const yaw = 2 * Math.atan2(x, w);
    const pitch = Math.PI / 2;
    const roll = 0;

    return new THREE.Vector3(pitch, roll, yaw);
  }

  // singularity at south pole
  if (test < -0.499) {
    const yaw = -2 * Math.atan2(x, w);
    const pitch = -Math.PI / 2;
    const roll = 0;

    return new THREE.Vector3(pitch, roll, yaw);
  }

  const sqx = x * x;
  const sqy = y * y;
  const sqz = z * z;
  const yaw = Math.atan2(2 * y * w - 2 * x * z, 1 - 2 * sqy - 2 * sqz);
  const pitch = Math.asin(2 * test);
  const roll = Math.atan2(2 * x * w - 2 * y * z, 1 - 2 * sqx - 2 * sqz);

  return new THREE.Vector3(pitch, roll, yaw);
}
function Quat2Angle ( x , y , z , w ) { const test = x * y + z * w ; // singularity at north pole if ( test > 0.499 ) { const yaw = 2 * Math . atan2 ( x , w ) ; const pitch = Math . PI / 2 ; const roll = 0 ; return new THREE . Vector3 ( pitch , roll , yaw ) ; } // singularity at south pole if ( test < - 0.499 ) { const yaw = - 2 * Math . atan2 ( x , w ) ; const pitch = - Math . PI / 2 ; const roll = 0 ; return new THREE . Vector3 ( pitch , roll , yaw ) ; } const sqx = x * x ; const sqy = y * y ; const sqz = z * z ; const yaw = Math . atan2 ( 2 * y * w - 2 * x * z , 1 - 2 * sqy - 2 * sqz ) ; const pitch = Math . asin ( 2 * test ) ; const roll = Math . atan2 ( 2 * x * w - 2 * y * z , 1 - 2 * sqx - 2 * sqz ) ; return new THREE . Vector3 ( pitch , roll , yaw ) ; }
Convert a quaternion to an angle

Taken from https://stackoverflow.com/a/35448946
Thanks P. Ellul
Convert a quaternion to an angle