cesium创建闪烁点
创建闪烁点用到的方法
创建闪烁点主要是通过回调函数CallbackProperty,控制样式改变或是否显示识。通过CallbackProperty改变点的大小或者颜色,可以实现点的闪烁。
改变点的大小实现闪烁
CallbackProperty函数改变点的大小实现闪烁
function addPoint() {
let y = 5;//点初始大小
viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(116.435314, 39.960521, 0),
point: {
show: true, // default
color:Cesium.Color.RED.withAlpha(0.7),
pixelSize: new Cesium.CallbackProperty(function () {
y = y + 0.5;//点每次增加大小
if (y >= 40) {
y = 5;
}
return y;
}, false),
outlineWidth: 0
}
});
}
改变点的颜色实现闪烁
CallbackProperty函数改变点的颜色实现闪烁
function addPoint() {
let x = 1;
let flog = true;
viewer.entities.add({
name: "圆点point闪烁",
position: Cesium.Cartesian3.fromDegrees(116.435314, 39.960521, 0),
point: {
show: true, // default
color: new Cesium.CallbackProperty(function () {
if (flog) {
x = x - 0.05;
if (x <= 0) {
flog = false;
}
} else {
x = x + 0.05;
if (x >= 1) {
flog = true;
}
}
return Cesium.Color.RED.withAlpha(x);
}, false),
pixelSize: 10, // default: 1
outlineWidth: 0
}
});
}