Hi @mzschwartz5 ,
Thank you for the information!
Suppose the rotation field is the ECEF Euler angles, how to use it to setView?
I attempted to convert it into ENU Euler angles in the following way:
// ENU HeadingPitchRoll in degrees should be approximately (270.12, -44.61, 0).
const destination = Cartesian3.fromDegrees(
121.73286024286688,
31.23933153689792,
20695,
);
const rx = CesiumMath.toRadians(159.34465662912814);
const ry = CesiumMath.toRadians(67.17562316976208);
const rz = CesiumMath.toRadians(45.669011717197826);
const matrix3_rx = Matrix3.fromRotationX(rx);
const matrix3_ry = Matrix3.fromRotationY(ry);
const matrix3_rz = Matrix3.fromRotationZ(rz);
const matrix3_r = new Matrix3();
// x -> y -> z
// Matrix3.multiply(matrix3_ry, matrix3_rz, matrix3_r);
// Matrix3.multiply(matrix3_rx, matrix3_r, matrix3_r);
Matrix3.multiply(matrix3_rx, matrix3_ry, matrix3_r);
Matrix3.multiply(matrix3_r, matrix3_rz, matrix3_r);
// // x -> z -> y
// Matrix3.multiply(matrix3_rz, matrix3_ry, matrix3_r);
// Matrix3.multiply(matrix3_rx, matrix3_r, matrix3_r);
// Matrix3.multiply(matrix3_rx, matrix3_rz, matrix3_r);
// Matrix3.multiply(matrix3_r, matrix3_ry, matrix3_r);
// // y -> x -> z
// Matrix3.multiply(matrix3_rx, matrix3_rz, matrix3_r);
// Matrix3.multiply(matrix3_ry, matrix3_r, matrix3_r);
// Matrix3.multiply(matrix3_ry, matrix3_rx, matrix3_r);
// Matrix3.multiply(matrix3_r, matrix3_rz, matrix3_r);
// // y -> z -> x
// Matrix3.multiply(matrix3_rz, matrix3_rx, matrix3_r);
// Matrix3.multiply(matrix3_ry, matrix3_r, matrix3_r);
// Matrix3.multiply(matrix3_ry, matrix3_rz, matrix3_r);
// Matrix3.multiply(matrix3_r, matrix3_rx, matrix3_r);
// // z -> x -> y
// Matrix3.multiply(matrix3_rx, matrix3_ry, matrix3_r);
// Matrix3.multiply(matrix3_rz, matrix3_r, matrix3_r);
// Matrix3.multiply(matrix3_rz, matrix3_rx, matrix3_r);
// Matrix3.multiply(matrix3_r, matrix3_ry, matrix3_r);
// // z -> y -> x
// Matrix3.multiply(matrix3_ry, matrix3_rx, matrix3_r);
// Matrix3.multiply(matrix3_rz, matrix3_r, matrix3_r);
// Matrix3.multiply(matrix3_rz, matrix3_ry, matrix3_r);
// Matrix3.multiply(matrix3_r, matrix3_rx, matrix3_r);
const enuTransform = Transforms.eastNorthUpToFixedFrame(destination);
const enuTransformInv = Matrix4.inverse(enuTransform, new Matrix4());
const ecefRotationMatrix4 = Matrix4.fromRotationTranslation(matrix3_r);
const enuRotationMatrix4 = Matrix4.multiply(enuTransformInv, ecefRotationMatrix4, new Matrix4());
const enuRotationMatrix = Matrix4.getMatrix3(enuRotationMatrix4, new Matrix3());
const quaternion = Quaternion.fromRotationMatrix(enuRotationMatrix);
const headingPitchRoll = HeadingPitchRoll.fromQuaternion(quaternion);
const { heading, pitch, roll } = headingPitchRoll;
console.log('heading: ', CesiumMath.toDegrees(heading).toFixed(2));
console.log('pitch: ', CesiumMath.toDegrees(pitch).toFixed(2));
console.log('roll: ', CesiumMath.toDegrees(roll).toFixed(2));
viewer.camera.setView({
destination,
orientation: {
heading,
pitch,
roll,
},
});
But the result is incorrect. Where might the problem be?