I have created an entity using a gltf file. The entity needs to be rotating and moving at the same time. I'm not facing any issues with changing the position of the entity (movement). However, there seem to be some issues with the rotation. When I remove the codes regarding the positioning of the entity, the rotation remains constant at the specified angle. Without removing the code for the movement, the entity rotates as it moves and its clearly not rotating at the value I specified.
var clock = viewer.clock;
var lastUpdated = clock.currentTime;
var count = 1;
var position = Cesium.Cartesian3.fromDegrees(103.7764, 1.2966, 50000.0);
var heading = Cesium.Math.toRadians(90);
var pitch = 0;
var roll = 0;
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
viewer.entities.removeAll();
satelliteModel = viewer.entities.add({
name : satelliteModel,
position : position,
orientation : orientation,
});
clock.onTick.addEventListener(function() {
var dt = Cesium.JulianDate.secondsDifference(clock.currentTime, lastUpdated);
if (dt >= 1.0) {
var date = new Date(clock.currentTime);
const latLonObj = tlejs.getLatLon(tleStr, date.toUTCString());
count += 10;
if (count >= 180) count = 10;
heading = Cesium.Math.toRadians(count);
pitch = 0;
roll = 0;
hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
if(satelliteModel != null) {
satelliteModel.position = Cesium.Cartesian3.fromDegrees(latLonObj.lng, latLonObj.lat, 50000.0);
satelliteModel.orientaion = Cesium.Transforms.headingPitchRollQuaternion(satelliteModel.position, hpr);
}
lastUpdated = clock.currentTime;
}
});
The position changes according to the coordinates of the satellite (no issues). The rotation is meant for sun tracking. I haven't work on the angle required for sun tracking yet. Just wanted to know how to rotate the entity continuously wrt to time. Thank you.