-
Notifications
You must be signed in to change notification settings - Fork 31
/
BillboardGroup.js
48 lines (39 loc) · 1.38 KB
/
BillboardGroup.js
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
const {BillboardCollection, Cartesian2, Cartesian3, Color, HorizontalOrigin, VerticalOrigin} = window.Cesium;
export default class BillboardGroup {
constructor(scene, options) {
this._scene = scene;
this._options = options;
// create one common billboard collection for all billboards
const b = new BillboardCollection();
this._scene.primitives.add(b);
this._billboards = b;
// keep an ordered list of billboards
this._orderedBillboards = [];
}
createBillboard(position) {
const billboard = this._billboards.add({
show: true,
position: position,
pixelOffset: new Cartesian2(this._options.shiftX, this._options.shiftY),
eyeOffset: new Cartesian3(0.0, 0.0, -1000.0),
horizontalOrigin: HorizontalOrigin.CENTER,
verticalOrigin: VerticalOrigin.CENTER,
scale: 1.0,
image: this._options.iconUrl,
color: new Color(1.0, 1.0, 1.0, 1.0)
});
return billboard;
}
addBillboard(position) {
const billboard = this.createBillboard(position);
this._orderedBillboards.push(billboard);
return billboard;
}
getBillboard(index) {
return this._orderedBillboards[index];
}
destroy() {
this._billboards.removeAll();
this._billboards.destroy();
};
}