I’ve spent the past few days trying all I can think of to get the Cesium Airplane to rotate correctly around the x, y and z access. I’ve seen a lot of discussions about using Quaternions but haven’t been able to determine the exact steps to use for it. The closest I’ve been able to come is changing the roll and seeing the place rotate accordingly. If I add any other values to pitch or heading, the rotations get funny. Here is the code I am currently using. I determined the 50 and 339 were needed to get the plane level before I start doing any rotations to it.
var qx = Cesium.Quaternion.fromAxisAngle(Cesium.Cartesian3.UNIT_X, degreesToRadians(50));
var qy = Cesium.Quaternion.fromAxisAngle(Cesium.Cartesian3.UNIT_Y, degreesToRadians(339 + roll));
var qz = Cesium.Quaternion.fromAxisAngle(Cesium.Cartesian3.UNIT_Z, degreesToRadians(0));
var conx = Cesium.Quaternion.conjugate(qx);
var qt = Cesium.Quaternion.multiple(qz, qy);
var cont = Cesium.Quaternion.conjugate(qt);
var n = Cesium.Quaternion.multiple(conx, cont);
var czmlData = { “id”:“Plane”,
“availability”:“2012-08-04T16:00:00Z/2012-08-04T17:04:54.9962195740191Z”,
“position”:{
“cartographicDegrees”:[lon, lat, alt]
},
“model” : {
“gltf” : ‘…/lib/models/Cesium_Air.json’, “scale” : 750.0
},
“scale”:1.0,
“show”:[{“boolean”:true}],
“orientation” : {
“epoch” : “2012-08-04T16:00:00Z”,
“interpolationAlgorithm” : “LINEAR”,
“interpolationDegree” : 1,
“unitQuaternion” : [0, n[‘x’], n[‘y’], n[‘z’], n[‘w’], 3600, n[‘x’], n[‘y’], n[‘z’], n[‘w’]]
}
};
Based on other questions and replies, I’ve tried numerous different variations of conjugating the quaternions and this is the only one that has been somewhat successful. Does anyone have any idea what I am doing wrong? Or suggestions on something new to try? Thanks.