toEulerAngles_(quat) {
    const angles = {
      pitch: 0,
      yaw: 0,
      roll: 0,
    };
    const x = quat[0];
    const y = quat[1];
    const z = quat[2];
    const w = quat[3];
    const x2 = x * x;
    const y2 = y * y;
    const z2 = z * z;
    const w2 = w * w;
    const unit = x2 + y2 + z2 + w2;
    const test = x * w - y * z;
    if (test > 0.499995 * unit) {
      // singularity at the north pole
      angles.pitch = Math.PI / 2;
      angles.yaw = 2 * Math.atan2(y, x);
      angles.roll = 0;
    } else if (test < -0.499995 * unit) {
      // singularity at the south pole
      angles.pitch = -Math.PI / 2;
      angles.yaw = 2 * Math.atan2(y, x);
      angles.roll = 0;
    } else {
      angles.pitch = Math.asin(2 * (x * z - w * y));
      angles.yaw = Math.atan2(2 * (x * w + y * z), 1 - 2 * (z2 + w2));
      angles.roll = Math.atan2(2 * (x * y + z * w), 1 - 2 * (y2 + z2));
    }
    return angles;
  }
@param {!Float32Array} quat
@return {{pitch: number, yaw: number, roll: number}} as radians
@private