Cesium实时目标跟踪最新特效教程系列1—实时发亮直线跟踪移动目标

主要利用CallbackProperty来实时更新直线末端位置。效果如下图

Cesium实时目标跟踪最新特效教程系列1—实时发亮直线跟踪移动目标_第1张图片

function traceTarget(sourEntity,tarEntity){
	viewer.entities.add({
	   polyline : {
               positions : new Cesium.CallbackProperty(function(time, result) {
                var sourpos = sourEntity.position.getValue(time);
             var cartographic1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(sourpos);
            var lon1 = Cesium.Math.toDegrees(cartographic1.longitude);
            var lat1 = Cesium.Math.toDegrees(cartographic1.latitude);
            var height1 = cartographic1.height;

            var tarpos = tarEntity.position.getValue(time);
            var cartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(tarpos);
            var lon2 = Cesium.Math.toDegrees(cartographic.longitude);
            var lat2 = Cesium.Math.toDegrees(cartographic.latitude);
            var height2 = cartographic.height;
            return  Cesium.Cartesian3. fromDegreesArrayHeights([lon1, lat1, height1, lon2, lat2, height2],Cesium.Ellipsoid.WGS84, result); 
             }),
            width : 5,
            material : new Cesium.PolylineGlowMaterialProperty({
	        glowPower:0.3,
	        color:Cesium.Color.BLUE.withAlpha(0.9)
      })
  }
})
}

 

你可能感兴趣的:(Cesium系列,cesium特效,目标跟踪,发亮直线)