效果

实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const DEF_OPT = {
color: Cesium.Color.BLUE,
duration: 3000,
count: 2.0,
freely: 'vertical',
direction: '-'
}
CV.PolylineTrailLinkMaterialProperty = class {

constructor(options) {
options = options || DEF_OPT
this._definitionChanged = new Cesium.Event();
this._color = undefined;
this._colorSubscription = undefined;
this.color = options.color;
this.duration = options.duration;
this._time = new Date().getTime();

this.create(options)
}

get isConstant() {
return false
}

get definitionChanged() {
return this._definitionChanged
}

getType(time) {
return "PolylineTrailLink";
}

getValue (time, result) {
if (!Cesium.defined(result)) {
result = {};
}
result.color = Cesium.Property.getValueOrClonedDefault(
this._color,
time,
Cesium.Color.WHITE,
result.color
);
result.image = Cesium.Material.PolylineTrailLinkImage;
result.time =
((new Date().getTime() - this._time) % this.duration) / this.duration;
return result;
};

equals(other) {
return (
this === other ||
(other instanceof CV.PolylineTrailLinkMaterialProperty &&
Cesium.Property.equals(this._color, other._color))
);
}

getMaterail(options) {
let materail = 【定义的shader材质,csdn博客实现】
}

create(options) {
Cesium.Material.PolylineTrailLinkType = "PolylineTrailLink";
Cesium.Material.PolylineTrailLinkImage = options.image || "/examples/images/color1.png"; //图片
Cesium.Material.PolylineTrailLinkSource = this.getMaterail(options)

Cesium.Material._materialCache.addMaterial(
Cesium.Material.PolylineTrailLinkType,
{
fabric: {
type: Cesium.Material.PolylineTrailLinkType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
image: Cesium.Material.PolylineTrailLinkImage,
time: 0
},
source: Cesium.Material.PolylineTrailLinkSource
},
translucent: function (material) {
return true;
}
}
);
}
}

Object.defineProperties(CV.PolylineTrailLinkMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor("color")
});
使用
1
2
3
4
entity方式:设置材质


material: new CV.PolylineTrailLinkMaterialProperty()