Cesium实现实体与实体之间按时间段进行连线
import * as Cesium from 'cesium'
export default function addline(options) {
const {
viewer,
startTime,
stopTime,
satellite,
station,
satelliteTimelineList,
} = options;
const _passIntervalArray = [];
satelliteTimelineList.forEach( v => {
_passIntervalArray.push(new Cesium.TimeInterval({
start: v[0],
stop: v[1]
}));
})
const _passIntervalObj = new Cesium.TimeIntervalCollection(_passIntervalArray);
return viewer.entities.add({
availablity: new Cesium.TimeIntervalCollection([
new Cesium.TimeInterval({
start: startTime,
stop: stopTime
})
]),
polyline: {
show: new Cesium.CallbackProperty( time => _passIntervalObj.contains(time), false),
width: 10,
material: Cesium.Color.RED,
positions: new Cesium.CallbackProperty( time => [satellite.position.getValue(time), station.position.getValue(time)], false)
}
})
}