基于cesium自定义材质线插件
// 自定义纹理材质
let MaterialLineImage = [
'./src/line.png',
'./src/line2.png',
'./src/line3.png',
]
// color
let colors = [
new Cesium.Color(77 / 255, 201 / 255, 255 / 255, 1),
new Cesium.Color(255 / 255, 201 / 255, 38 / 255, 1),
new Cesium.Color(221 / 255, 221 / 255, 221 / 255, 1)
];
// 创建材质线
let getCustomMaterialLine = (image, color) => {
return new Cesium.CustomMaterialLine({
image: image,
color: color,
duration: 2000
})
}
// 添加实体线
let startPoint = Cesium.Cartesian3.fromDegrees(104.081701757991, 30.627042558105988)
let glowingLine = null
for (let i = 0, len = 8; i < len; i++) {
let endPoint = Cesium.Cartesian3.fromDegrees((Math.random() / 100) +
104.081701757991, (Math.random() / 100) + 30.627042558105988);
glowingLine = viewer.entities.add({
polyline: {
positions: [startPoint, endPoint],
width: 5,
material: getCustomMaterialLine(MaterialLineImage[i % 3], colors[i % 3]),
}
});
}