70 lines
2.5 KiB
JavaScript
70 lines
2.5 KiB
JavaScript
|
|
export default class DynamicRange{
|
||
|
|
constructor(val){
|
||
|
|
this.source = val.source;
|
||
|
|
}
|
||
|
|
dynamicRange(val){
|
||
|
|
let minR=val.minR;//最小半径
|
||
|
|
let maxR = val.maxR;// 最大半径
|
||
|
|
let deviationR = val.deviationR; // 每次增加的大小
|
||
|
|
var r1 = minR
|
||
|
|
function changeR1() {
|
||
|
|
r1=r1+deviationR;//deviationR为每次圆增加的大小
|
||
|
|
if(r1>=maxR){
|
||
|
|
r1=minR;
|
||
|
|
}
|
||
|
|
return r1;
|
||
|
|
}
|
||
|
|
function color() {
|
||
|
|
let x=1-r1/maxR;
|
||
|
|
return Cesium.Color.WHITE.withAlpha(x);
|
||
|
|
}
|
||
|
|
let entitys = this.source.entities.add({
|
||
|
|
position: Cesium.Cartesian3.fromDegrees(122.0, 23.0),
|
||
|
|
name: 'ellipse on surface with outline',
|
||
|
|
ellipse: {
|
||
|
|
semiMinorAxis: new Cesium.CallbackProperty(changeR1,false),
|
||
|
|
semiMajorAxis: new Cesium.CallbackProperty(changeR1,false),
|
||
|
|
material: new Cesium.ImageMaterialProperty({
|
||
|
|
image:require("../assets/ring.png"),
|
||
|
|
repeat:new Cesium.Cartesian2(1.0, 1.0),
|
||
|
|
transparent:true,
|
||
|
|
color:new Cesium.CallbackProperty(color,false)
|
||
|
|
}),
|
||
|
|
outlineColor: Cesium.Color.RED
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return entitys
|
||
|
|
}
|
||
|
|
dynamicRange2(options){
|
||
|
|
let minR=options.minR;//最小半径
|
||
|
|
let maxR = options.maxR;// 最大半径
|
||
|
|
let deviationR = options.deviationR; // 每次增加的大小
|
||
|
|
let coords = options.coords;
|
||
|
|
let height = options.height||0;
|
||
|
|
var r1 = minR
|
||
|
|
function getChangeR1() {
|
||
|
|
r1=r1+deviationR;//deviationR为每次圆增加的大小
|
||
|
|
if(r1>=maxR){
|
||
|
|
r1=minR;
|
||
|
|
}
|
||
|
|
return r1;
|
||
|
|
}
|
||
|
|
function getColor() {
|
||
|
|
let x=1-r1/maxR;
|
||
|
|
return Cesium.Color.RED.withAlpha(x);
|
||
|
|
}
|
||
|
|
let radius = new Cesium.CallbackProperty(getChangeR1,false);
|
||
|
|
let entitys = this.source.entities.add({
|
||
|
|
position: Cesium.Cartesian3.fromDegrees(coords[0],coords[1]),
|
||
|
|
// name: 'ellipse on surface with outline',
|
||
|
|
ellipse: {
|
||
|
|
semiMajorAxis: radius,
|
||
|
|
semiMinorAxis: radius,
|
||
|
|
material: new Cesium.ColorMaterialProperty(new Cesium.CallbackProperty(getColor,false)),
|
||
|
|
outlineColor: Cesium.Color.RED,
|
||
|
|
height:height
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return entitys
|
||
|
|
}
|
||
|
|
}
|