I added to code below, I would like to move objEntity which respect to entity. Thank you.
var viewer = new Cesium.Viewer(‘cesiumContainer’, {
infoBox: false, //Disable InfoBox widget
selectionIndicator: false, //Disable selection indicator
shouldAnimate: true, // Enable animations
//terrainProvider: Cesium.createWorldTerrain()
});
//Enable lighting based on sun/moon positions
viewer.scene.globe.enableLighting = true;
//Enable depth testing so things behind the terrain disappear.
viewer.scene.globe.depthTestAgainstTerrain = true;
//Set bounds of our simulation time
var start = Cesium.JulianDate.fromDate(new Date(2015, 2, 25, 16));
var stop = Cesium.JulianDate.addSeconds(start, 74, new Cesium.JulianDate());
var current = Cesium.JulianDate.now();
//heading of the model object
var heading = Cesium.Math.toRadians(90.0);
var pitch = Cesium.Math.toRadians(0);
var roll = Cesium.Math.toRadians(0);
var hpRoll = new Cesium.HeadingPitchRoll(heading,pitch,roll);
var fixedFrameTransform = Cesium.Transforms.localFrameToFixedFrameGenerator(‘south’, ‘west’);
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.multiplier = 0.2;
viewer.timeline.zoomTo(start, stop);
var lon_lat = [29.207734,41.0220831,
29.2102525,41.0200434,
29.206165,41.0178572,];
function computeCirclularFlight(height) {
var property = new Cesium.SampledPositionProperty();
var time_array = ;
for (var i = 0; i <= 5; i += 2) {
var time = Cesium.JulianDate.addSeconds(start, i, new Cesium.JulianDate());
var position = Cesium.Cartesian3.fromDegrees(lon_lat[i], lon_lat[i+1], height);
property.addSample(time, position);
time_array.push(time);
//Also create a point for each sample we generate.
viewer.entities.add({
position : position,
point : {
pixelSize : 6,
color : Cesium.Color.TRANSPARENT,
outlineColor : Cesium.Color.GREEN,
outlineWidth : 1
}
});
}
return [property,time_array];
}
var [position,timing] = computeCirclularFlight(0.5);
console.log(timing);
var positionOfLabel = computeCirclularFlight(5);
var positionOfLabel = positionOfLabel[0];
var entity = viewer.entities.add({
//Set the entity availability to the same interval as the simulation time.
availability : new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
start : start,
stop : stop
})]),
//Use our computed positions
position : position,
//Automatically compute orientation based on position movement.
orientation : new Cesium.VelocityOrientationProperty(position),
//Load the Cesium plane model to represent the entity
model : {
uri : ‘…/…/…/…/Apps/SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb’,
minimumPixelSize : 8,
scale: 1,
maximumScale: 2
},
//Show the path as a pink line sampled in 1 second increments.
path : {
resolution : 1,
material : new Cesium.PolylineGlowMaterialProperty({
glowPower : 0.1,
color : Cesium.Color.YELLOW
}),
width : 10
}
});
//tracked object is vehicle
var labelEntity = viewer.entities.add({
position: positionOfLabel,
label : {
id : ‘speed’,
text: ‘phil’,
verticalOrigin: Cesium.VerticalOrigin.TOP
},
path : {
resolution : 1,
material : new Cesium.PolylineGlowMaterialProperty({
glowPower : 0.1,
color : Cesium.Color.YELLOW
}),
width : 10
}
});
var timeofObj = Cesium.JulianDate.addSeconds(start, 5, new Cesium.JulianDate());
var objPosition = Cesium.Cartesian3.fromDegrees( 8.29458,49.0682,0.5);
var objEntity = viewer.entities.add({
position : entity.position.getValue(current),
orientation : new Cesium.VelocityOrientationProperty(position),
model : {
uri : ‘…/…/…/…/Apps/SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb’,
minimumPixelSize : 8,
scale: 1,
maximumScale: 2
}
});
viewer.trackedEntity = entity;
//interpolation part, there should be one interpolation for each line that the code draw
entity.position.setInterpolationOptions({
interpolationDegree : 2,
interpolationAlgorithm : Cesium.LagrangePolynomialApproximation
});
labelEntity.position.setInterpolationOptions({
interpolationDegree : 2,
interpolationAlgorithm : Cesium.LagrangePolynomialApproximation
});