@pirireis/webglobeplugins 0.6.2-a → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -261,7 +261,7 @@ export default class RangeRingAngleText {
|
|
|
261
261
|
const hideText = centerMap.get("textHide");
|
|
262
262
|
const isHidden = hide === ENUM_HIDE.HIDE || hideText === ENUM_TEXT_HIDE.HIDE;
|
|
263
263
|
if (!isHidden) this._fillDeleteBucket(centerID, deleteBucket);
|
|
264
|
-
centerMap.set("
|
|
264
|
+
centerMap.set("hide", ENUM_HIDE.HIDE);
|
|
265
265
|
}
|
|
266
266
|
this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
|
|
267
267
|
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { CSZMode } from "@pirireis/webglobe";
|
|
2
2
|
|
|
3
|
+
const defaultStyle = {
|
|
4
|
+
textFont: {
|
|
5
|
+
name: 'Arial',
|
|
6
|
+
textColor: '#FFFFFF', // beyaz
|
|
7
|
+
hollowColor: '#000000', // siyah
|
|
8
|
+
size: 12, // piksel
|
|
9
|
+
hollow: true,
|
|
10
|
+
bold: true,
|
|
11
|
+
italic: false,
|
|
12
|
+
},
|
|
13
|
+
opacity: 1.0,
|
|
14
|
+
zMode: CSZMode.Z_GROUND_PERVERTEX,
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
/**
|
|
4
18
|
* TODOs:
|
|
5
19
|
* 1) update all if initials change (propably need a context and a callback to iterate over data)
|
|
@@ -7,33 +21,10 @@ import { CSZMode } from "@pirireis/webglobe";
|
|
|
7
21
|
* 3) extend the mechanic on 2 to other events
|
|
8
22
|
*/
|
|
9
23
|
export class ContextTextWriter2 {
|
|
10
|
-
constructor(globe, {
|
|
11
|
-
style = {
|
|
12
|
-
textFont: {
|
|
13
|
-
name: 'Arial',
|
|
14
|
-
textColor: '#FFFFFF', // beyaz
|
|
15
|
-
hollowColor: '#000000', // siyah
|
|
16
|
-
size: 12, // piksel
|
|
17
|
-
hollow: true,
|
|
18
|
-
bold: true,
|
|
19
|
-
italic: false,
|
|
20
|
-
},
|
|
21
|
-
opacity: 1.0,
|
|
22
|
-
zMode: CSZMode.Z_GROUND_PERVERTEX,
|
|
23
|
-
},
|
|
24
|
-
doDraw = true,
|
|
25
|
-
textAdaptor = null,
|
|
26
|
-
coordinatesAdaptor = null,
|
|
27
|
-
keyAdaptor = null,
|
|
28
|
-
opacityAdaptor = null,
|
|
29
|
-
angleAdaptor = null,
|
|
30
|
-
angleOnSphere = false,
|
|
31
|
-
zoomLevelOpacityAdaptor = null,
|
|
32
|
-
zoomLevelSizeAdaptor = null,
|
|
33
|
-
} = {}) {
|
|
24
|
+
constructor(globe, { style = null, doDraw = true, textAdaptor = null, coordinatesAdaptor = null, keyAdaptor = null, opacityAdaptor = null, angleAdaptor = null, angleOnSphere = false } = {}) {
|
|
34
25
|
this.globe = globe;
|
|
35
26
|
this.itemMap = new Map();
|
|
36
|
-
this.style = style;
|
|
27
|
+
this.style = style || defaultStyle;
|
|
37
28
|
this.doDraw = doDraw;
|
|
38
29
|
|
|
39
30
|
|
|
@@ -41,9 +32,6 @@ export class ContextTextWriter2 {
|
|
|
41
32
|
this.coordinatesAdaptor = coordinatesAdaptor;
|
|
42
33
|
this.keyAdaptor = keyAdaptor;
|
|
43
34
|
|
|
44
|
-
this.zoomLevelOpacityAdaptor = zoomLevelOpacityAdaptor;
|
|
45
|
-
this.zoomLevelSizeAdaptor = zoomLevelSizeAdaptor;
|
|
46
|
-
|
|
47
35
|
this.opacityAdaptor = opacityAdaptor ? opacityAdaptor : () => 1;
|
|
48
36
|
this.angleOnSphere = angleOnSphere;
|
|
49
37
|
if (angleAdaptor) {
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { CSZMode } from "@pirireis/webglobe";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* TODOs:
|
|
5
|
-
* 1) update all if initials change (propably need a context and a callback to iterate over data)
|
|
6
|
-
* 2) expose a mechanic to update text on zoom change
|
|
7
|
-
* 3) extend the mechanic on 2 to other events
|
|
8
|
-
*/
|
|
9
|
-
export class ContextTextWriter2 {
|
|
10
|
-
constructor(globe, {
|
|
11
|
-
style = {
|
|
12
|
-
textFont: {
|
|
13
|
-
name: 'Arial',
|
|
14
|
-
textColor: '#FFFFFF', // beyaz
|
|
15
|
-
hollowColor: '#000000', // siyah
|
|
16
|
-
size: 12, // piksel
|
|
17
|
-
hollow: true,
|
|
18
|
-
bold: true,
|
|
19
|
-
italic: false,
|
|
20
|
-
},
|
|
21
|
-
opacity: 1.0,
|
|
22
|
-
zMode: CSZMode.Z_GROUND_PERVERTEX,
|
|
23
|
-
},
|
|
24
|
-
doDraw = true,
|
|
25
|
-
textAdaptor = null,
|
|
26
|
-
coordinatesAdaptor = null,
|
|
27
|
-
keyAdaptor = null,
|
|
28
|
-
opacityAdaptor = null,
|
|
29
|
-
angleAdaptor = null,
|
|
30
|
-
angleOnSphere = false,
|
|
31
|
-
zoomLevelOpacityAdaptor = (zoomLevel, item) => 1,
|
|
32
|
-
zoomLevelSizeAdaptor = (zoomLevel, item) => 1,
|
|
33
|
-
} = {}) {
|
|
34
|
-
this.globe = globe;
|
|
35
|
-
this.itemMap = new Map();
|
|
36
|
-
this.style = style;
|
|
37
|
-
this.doDraw = doDraw;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.textAdaptor = textAdaptor;
|
|
41
|
-
this.coordinatesAdaptor = coordinatesAdaptor;
|
|
42
|
-
this.keyAdaptor = keyAdaptor;
|
|
43
|
-
|
|
44
|
-
this.zoomLevelOpacityAdaptor = zoomLevelOpacityAdaptor;
|
|
45
|
-
this.zoomLevelSizeAdaptor = zoomLevelSizeAdaptor;
|
|
46
|
-
|
|
47
|
-
this.opacityAdaptor = opacityAdaptor ? opacityAdaptor : () => 1;
|
|
48
|
-
this.angleOnSphere = angleOnSphere;
|
|
49
|
-
if (angleAdaptor) {
|
|
50
|
-
this.angleAdaptor = angleAdaptor
|
|
51
|
-
this.angleAdaptorIsOn = true;
|
|
52
|
-
} else {
|
|
53
|
-
this.angleAdaptor = () => null
|
|
54
|
-
this.angleAdaptorIsOn = false
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
setKeyAdaptor(adaptor) {
|
|
59
|
-
this.keyAdaptor = adaptor;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
setDoDraw(bool) {
|
|
63
|
-
this.doDraw = bool;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
setStyle(style) {
|
|
67
|
-
this.style = style;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
setOpacity(opacity) {
|
|
71
|
-
this.style.opacity = opacity;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
draw() {
|
|
77
|
-
if (!this.doDraw) return;
|
|
78
|
-
const { globe, style, itemMap } = this;
|
|
79
|
-
const { textFont, opacity: opacity_ } = style;
|
|
80
|
-
const textSize = textFont.size;
|
|
81
|
-
const is3D = globe.api_GetCurrentGeometry() === 0;
|
|
82
|
-
const angleIsOn = is3D ? (this.angleAdaptorIsOn && this.angleOnSphere) : (this.angleAdaptorIsOn)
|
|
83
|
-
const zoomLevel = globe.api_GetCurrentLODWithDecimal()
|
|
84
|
-
for (const [key, item] of itemMap) {
|
|
85
|
-
const { lat, long, text, opacity = null, angle = null } = item;
|
|
86
|
-
const { x, y } = globe.api_GetScreenPointFromGeo(
|
|
87
|
-
{
|
|
88
|
-
long: long,
|
|
89
|
-
lat: lat,
|
|
90
|
-
z: 0,
|
|
91
|
-
},
|
|
92
|
-
style.zMode === CSZMode.Z_MSL,
|
|
93
|
-
);
|
|
94
|
-
const o = (opacity === null ? opacity_ : opacity * opacity_) * this.zoomLevelOpacityAdaptor(zoomLevel, item);
|
|
95
|
-
textFont.size = this.zoomLevelSizeAdaptor(zoomLevel) * textSize;
|
|
96
|
-
|
|
97
|
-
if (x !== null && y !== null) globe.api_DrawContextTextMultiLine(text, textFont, o, { x, y }, angleIsOn, angle);
|
|
98
|
-
}
|
|
99
|
-
textFont.size = textSize;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
updateOpacityOfItem(item, i, container, properties) {
|
|
104
|
-
const opacity = this.opacityAdaptor(item, i, container, properties);
|
|
105
|
-
if (opacity == null) return;
|
|
106
|
-
const key = this.keyAdaptor(item, i, container, properties);
|
|
107
|
-
const data = this.itemMap.get(key)
|
|
108
|
-
data.opacity = opacity;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
updateOpacityContainer(container, properties) {
|
|
112
|
-
container.forEach((v, i, c) => {
|
|
113
|
-
this.updateOpacityOfItem(v, i, c, properties);
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
insertTextBulk(container, properties) {
|
|
119
|
-
container.forEach((v, i, c) => {
|
|
120
|
-
this.insertText(v, i, c, properties);
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
updateTextCoords(item, i, container, properties) {
|
|
125
|
-
const coords = this.coordinatesAdaptor(item, i, container, properties);
|
|
126
|
-
if (coords == null) return;
|
|
127
|
-
const key = this.keyAdaptor(item, i, container, properties);
|
|
128
|
-
const data = this.itemMap.get(key)
|
|
129
|
-
data.angle = this.angleAdaptor(item, i, container, properties);
|
|
130
|
-
data.long = coords.long;
|
|
131
|
-
data.lat = coords.lat;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
updateTextCoordsBulk(container, properties) {
|
|
135
|
-
container.forEach((v, i, c) => {
|
|
136
|
-
this.updateTextCoords(v, i, c, properties)
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
deleteTextBulk(keys) {
|
|
141
|
-
for (const key of keys) {
|
|
142
|
-
this.itemMap.delete(key);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
insertText(item, id, container, properties) {
|
|
148
|
-
const key = this.keyAdaptor(item, id, container, properties)
|
|
149
|
-
const coords = this.coordinatesAdaptor(item, id, container, properties)
|
|
150
|
-
if (coords == null) {
|
|
151
|
-
this.itemMap.delete(key);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const text = this.textAdaptor(item, id, container, properties)
|
|
155
|
-
if (text == null) {
|
|
156
|
-
this.itemMap.delete(key);
|
|
157
|
-
return
|
|
158
|
-
};
|
|
159
|
-
const opacity = this.opacityAdaptor(item, id, container, properties);
|
|
160
|
-
const angle = this.angleAdaptor(item, id, container, properties);
|
|
161
|
-
this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle });
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
clear() {
|
|
165
|
-
this.itemMap.clear();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|