I have been attempting to showcase an entity moving within Cesium through the use of live/dynamic data. After trying various techniques and consulting past forums, particularly those from 2015-2016, I am still struggling to make it work.
Despite my efforts, nothing seems to be loading properly on the screen whenever I implement the methods suggested on stackoverflow and Cesium forums. It consistently displays a blank screen each time.
Cesium.Ion.defaultAccessToken = 'xxxx';
const viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: Cesium.createWorldTerrain()
});
const osmBuildings = viewer.scene.primitives.add(Cesium.createOsmBuildings());
const data = JSON.parse('C:/Users/moose/Documents/Cesium/telemetryGet.json');
var telemetry = Cesium.Cartesian3.fromDegrees(data.longitude, data.latitude, data.altitude);
var dronePositions = new Cesium.SampledPositionProperty();
dronePositions.addSample( Cesium.JulianDate.fromDate(new Date()), telemetry);
// Load the glTF model from Cesium ion.
const airplaneUri = await Cesium.IonResource.fromAssetId(1634734);
const DroneEntity = viewer.entities.add({
position: dronePositions,
// Attach the 3D model instead of the green point.
model: { uri: airplaneUri },
// Automatically compute the orientation from the position.
orientation: new Cesium.VelocityOrientationProperty(telemetry),
});
viewer.selectedEntity = DroneEntity;
// setTimeout(loadModel, 1000);
viewer.zoomTo(viewer.entities);
var clock = viewer.clock;
var lastUpdated = clock.currentTime;
clock.onTick.addEventListener(function() {
var dt = Cesium.JulianDate.secondsDifference(clock.currentTime, lastUpdated);
if (dt >= 1.0) {
// Add a new sample position
lastUpdated = clock.currentTime;
}
});