Here is my Code:
const Q1 = this.orientationBuffer.get(‘ORIENTATION_Q_C1’).getValue(this.ovtCesiumViewer.getCurrentTime()) ?? 0;
const Q2 = this.orientationBuffer.get('ORIENTATION_Q_C2').getValue(this.ovtCesiumViewer.getCurrentTime()) ?? 0;
const Q3 = this.orientationBuffer.get('ORIENTATION_Q_C3').getValue(this.ovtCesiumViewer.getCurrentTime()) ?? 0;
const Q4 = this.orientationBuffer.get('ORIENTATION_Q_C4').getValue(this.ovtCesiumViewer.getCurrentTime()) ?? 1;
this.showViewInfoText.quaternion = (Q1.toFixed(5) + ', ' + Q2.toFixed(5) + ', ' + Q3.toFixed(5) + ', ' + Q4.toFixed(5));
for (const entity of this.czmlDataSource.entities.values) {
if (entity.position) {
const pos = entity.position.getValue(this.ovtCesiumViewer.getCurrentTime());
if (pos) {
const quarternionInput = new Cesium.Quaternion(Q1, Q2, Q3, Q4);
const hpr = Cesium.HeadingPitchRoll.fromQuaternion(quarternionInput);
const orientation = Cesium.Transforms.headingPitchRollQuaternion(pos, hpr);
entity.orientation = orientation;
}
}
}
What I need:
this calculation gets the models orientation based on the position of the model from the earth. I need to calculate the orientation based off of the sun. I have a callback to get the sun’s cartesian 3 position, but I don’t know how (in Cesium) to calculate the orientation/based off of the sun’s position. Help math people out there!