I would like to move a model continously with real time tracking between two points.
/Set bounds of our simulation time
var start = Cesium.JulianDate.fromDate(new Date(2015, 2, 25, 16));
var stop = Cesium.JulianDate.addSeconds(start, 120, new Cesium.JulianDate());
//Make sure viewer is at the desired time.
viewer.clock.startTime = start.clone();
viewer.clock.stopTime = stop.clone();
viewer.clock.currentTime = start.clone();
viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP; //Loop at the end
viewer.clock.clockRange = Cesium.ClockRange.CLAMPED;
viewer.clock.multiplier = 1;
viewer.clock.shouldAnimate = true;
var constant;
var position3;
function p1() {
var position1 = Cesium.Cartesian3.fromDegrees(lon1, lat1, alt1);
var position2 = Cesium.Cartesian3.fromDegrees(lon2, lat2, alt2);
position3 = new Cesium.SampledPositionProperty();
position3.addSample(start, position1);
position3.addSample(stop, position2);
var heading1 = Cesium.Math.toRadians(cou1);
var pitch1 = 0;
var roll1 = 0;
var hpr1 = new Cesium.HeadingPitchRoll(heading1, pitch1, roll1);
var orientation1 = Cesium.Transforms.headingPitchRollQuaternion(position3, hpr1);
}
var entity1;
function k1() {
viewer.entities.remove(entity1);
constant = true;
var promise = Cesium.IonResource.fromAssetId($f1).then(function (resource) {
entity1 = viewer.entities.add({
availability : new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
start : start,
stop : stop
})]),
name : $name1,
position: new Cesium.CallbackProperty(getPos, constant),
orientation : new Cesium.VelocityOrientationProperty(position3),
model: {
uri: resource,
heightReference : Cesium.HeightReference.CLAMP_TO_GROUND,
minimumPixelSize : 128,
maximumScale : 2
}
});
viewer.trackedEntity = entity1;
})
}
function getPos() {
//return new Cesium.Cartesian3.fromDegrees(lon1, lat1); ???
}
function setPosCallback() {
constant = !constant;
entity1.position.setCallback(getPos.bind(entity1), true);
}
setInterval(setPosCallback, 1000);