// Using Entities:
// the original add of the empty swathe
viewer.entities.add({
id: result.objectsWithinCzml.id,
name: result.objectsWithinCzml.name + 'swathe',
polygon: {
hierarchy: new Cesium.CallbackProperty(callbackSwathe, false),
material: Cesium.Color.GREEN.withAlpha(0.5),
height: 0,
outline: true // height is required for outline to display
}
});
// update the callback to allow a non static return
function onSimulationClockChange() {
// run every 60 seconds of simulation
var currentTime = viewer.clock.currentTime;
for (var i = 0; i < vehicles.length; i++) {
if (vehicles[i].swathe !== null) {
if (Cesium.JulianDate.compare(currentTime, Cesium.JulianDate.fromDate(moment(vehicles[i].swathe.item1[vehicles[i].swathe.item1.length - 1]).toDate())) <= 0 && viewer.entities.getById(vehicles[i].id).polygon.hierarchy.isConstant) {
viewer.entities.getById(vehicles[i].id).polygon.hierarchy.setCallback(callbackSwathe, false);
clockChange = currentTime;
}
}
}
}
// callback to update the swathe to the current time and also update the callback to keep the final swathe shown if the current time is after the flight end time
function callbackSwathe() {
//alert('this is it');
// run every 60 seconds of simulation
var currentTime = viewer.clock.currentTime;
var swathe = vehicles.find(x => x.id === this.id).swathe;
var fullSwathe;
var currentSwathe;
var timeDifference = Cesium.JulianDate.secondsDifference(currentTime, clockChange);
if (timeDifference >= parseFloat($('#StepTime').val()) || timeDifference < 0) {
clockChange = currentTime;
if (Cesium.JulianDate.compare(currentTime,...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.