@pirireis/webglobeplugins 0.6.3 → 0.6.4
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PixelPaddingForFlatCompassCache } from "../programs/two-d/pixel-padding-for-compass";
|
|
2
2
|
import { BufferManager, BufferOrchestrator } from "../util/account";
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import { PixelPaddingCompassTextWriter } from "./compass-text-writer"
|
|
5
5
|
|
|
6
6
|
const PaddingAngle = 30;
|
package/package.json
CHANGED
|
@@ -9,32 +9,28 @@ in vec2 screen_coordinate;
|
|
|
9
9
|
in float pixel_radius_small;
|
|
10
10
|
in float pixel_radius_big;
|
|
11
11
|
in vec4 rgba;
|
|
12
|
-
|
|
13
12
|
out vec4 v_rgba;
|
|
14
|
-
|
|
15
13
|
uniform float plugin_opacity;
|
|
16
14
|
|
|
17
15
|
vec3 coord_opacity(){
|
|
18
16
|
float radius;
|
|
19
17
|
float angle;
|
|
18
|
+
float gap = (pixel_radius_big - pixel_radius_small);
|
|
20
19
|
if( gl_VertexID % 2 == 0){
|
|
21
20
|
if( gl_VertexID % 180 == 0){
|
|
22
21
|
radius = pixel_radius_small ;
|
|
23
22
|
}
|
|
24
23
|
else if ( gl_VertexID % 60 == 0){
|
|
25
|
-
|
|
26
|
-
radius = pixel_radius_small + gap;
|
|
24
|
+
radius = pixel_radius_small + gap * 0.5;
|
|
27
25
|
} else if( gl_VertexID % 10 == 0) {
|
|
28
|
-
|
|
29
|
-
radius = pixel_radius_small + gap;
|
|
26
|
+
radius = pixel_radius_small + gap * 0.75;
|
|
30
27
|
} else {
|
|
31
|
-
|
|
32
|
-
radius = pixel_radius_small + gap;
|
|
28
|
+
radius = pixel_radius_small + gap* 0.90;
|
|
33
29
|
}
|
|
34
30
|
angle = (float(gl_VertexID) / (${vertexCount}.0));
|
|
35
31
|
} else {
|
|
36
32
|
if ( gl_VertexID % 180 == 1){
|
|
37
|
-
radius = pixel_radius_big +
|
|
33
|
+
radius = pixel_radius_big + gap * 0.1;
|
|
38
34
|
|
|
39
35
|
} else {
|
|
40
36
|
radius = pixel_radius_big;
|
|
@@ -2,7 +2,7 @@ import { CSZMode } from "@pirireis/webglobe";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* TODOs:
|
|
5
|
-
* 1) update all if initials change (propably need a context and a callback to iterate over
|
|
5
|
+
* 1) update all if initials change (propably need a context and a callback to iterate over payload)
|
|
6
6
|
* 2) expose a mechanic to update text on zoom change
|
|
7
7
|
* 3) extend the mechanic on 2 to other events
|
|
8
8
|
*/
|
|
@@ -28,6 +28,8 @@ export class ContextTextWriter3 {
|
|
|
28
28
|
opacityAdaptor = null,
|
|
29
29
|
angleAdaptor = null,
|
|
30
30
|
angleOnSphere = false,
|
|
31
|
+
xOffset = 0,
|
|
32
|
+
yOffset = 0,
|
|
31
33
|
zoomLevelAdaptor = (zoomLevel) => (item) => {
|
|
32
34
|
return {
|
|
33
35
|
opacityMultiplier: 1,
|
|
@@ -56,6 +58,9 @@ export class ContextTextWriter3 {
|
|
|
56
58
|
this.angleAdaptor = () => null
|
|
57
59
|
this.angleAdaptorIsOn = false
|
|
58
60
|
}
|
|
61
|
+
|
|
62
|
+
this.xOffset = xOffset;
|
|
63
|
+
this.yOffset = yOffset;
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
setKeyAdaptor(adaptor) {
|
|
@@ -78,7 +83,7 @@ export class ContextTextWriter3 {
|
|
|
78
83
|
|
|
79
84
|
draw() {
|
|
80
85
|
if (!this.doDraw) return;
|
|
81
|
-
const { globe, style, itemMap } = this;
|
|
86
|
+
const { globe, style, itemMap, xOffset, yOffset } = this;
|
|
82
87
|
const { textFont, opacity: opacity_ } = style;
|
|
83
88
|
const textSize = textFont.size;
|
|
84
89
|
const is3D = globe.api_GetCurrentGeometry() === 0;
|
|
@@ -86,7 +91,7 @@ export class ContextTextWriter3 {
|
|
|
86
91
|
const zoomLevel = globe.api_GetCurrentLODWithDecimal();
|
|
87
92
|
const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
|
|
88
93
|
for (const [key, item] of itemMap) {
|
|
89
|
-
const { lat, long, text, opacity = null, angle = null,
|
|
94
|
+
const { lat, long, text, opacity = null, angle = null, payload } = item;
|
|
90
95
|
const { x, y } = globe.api_GetScreenPointFromGeo(
|
|
91
96
|
{
|
|
92
97
|
long: long,
|
|
@@ -95,29 +100,16 @@ export class ContextTextWriter3 {
|
|
|
95
100
|
},
|
|
96
101
|
style.zMode === CSZMode.Z_MSL,
|
|
97
102
|
);
|
|
98
|
-
const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(
|
|
103
|
+
const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(payload);
|
|
99
104
|
const o = (opacity === null ? opacity_ : opacity * opacity_) * opacityMultiplier;
|
|
100
105
|
textFont.size = sizeMultiplier * textSize;
|
|
101
106
|
|
|
102
|
-
if (x !== null && y !== null) globe.api_DrawContextTextMultiLine(text, textFont, o, { x, y }, angleIsOn, angle);
|
|
107
|
+
if (x !== null && y !== null) globe.api_DrawContextTextMultiLine(text, textFont, o, { x: x + xOffset, y: y - yOffset }, angleIsOn, angle);
|
|
103
108
|
}
|
|
104
109
|
textFont.size = textSize;
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
|
|
108
|
-
updateOpacityOfItem(item, i, container, properties) {
|
|
109
|
-
const opacity = this.opacityAdaptor(item, i, container, properties);
|
|
110
|
-
if (opacity == null) return;
|
|
111
|
-
const key = this.keyAdaptor(item, i, container, properties);
|
|
112
|
-
const data = this.itemMap.get(key)
|
|
113
|
-
data.opacity = opacity;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
updateOpacityContainer(container, properties) {
|
|
117
|
-
container.forEach((v, i, c) => {
|
|
118
|
-
this.updateOpacityOfItem(v, i, c, properties);
|
|
119
|
-
})
|
|
120
|
-
}
|
|
121
113
|
|
|
122
114
|
|
|
123
115
|
insertTextBulk(container, properties) {
|
|
@@ -126,21 +118,7 @@ export class ContextTextWriter3 {
|
|
|
126
118
|
})
|
|
127
119
|
}
|
|
128
120
|
|
|
129
|
-
updateTextCoords(item, i, container, properties) {
|
|
130
|
-
const coords = this.coordinatesAdaptor(item, i, container, properties);
|
|
131
|
-
if (coords == null) return;
|
|
132
|
-
const key = this.keyAdaptor(item, i, container, properties);
|
|
133
|
-
const data = this.itemMap.get(key)
|
|
134
|
-
data.angle = this.angleAdaptor(item, i, container, properties);
|
|
135
|
-
data.long = coords.long;
|
|
136
|
-
data.lat = coords.lat;
|
|
137
|
-
}
|
|
138
121
|
|
|
139
|
-
updateTextCoordsBulk(container, properties) {
|
|
140
|
-
container.forEach((v, i, c) => {
|
|
141
|
-
this.updateTextCoords(v, i, c, properties)
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
122
|
|
|
145
123
|
deleteTextBulk(keys) {
|
|
146
124
|
for (const key of keys) {
|
|
@@ -163,7 +141,7 @@ export class ContextTextWriter3 {
|
|
|
163
141
|
};
|
|
164
142
|
const opacity = this.opacityAdaptor(item, id, container, properties);
|
|
165
143
|
const angle = this.angleAdaptor(item, id, container, properties);
|
|
166
|
-
this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle,
|
|
144
|
+
this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle, payload: item });
|
|
167
145
|
}
|
|
168
146
|
|
|
169
147
|
clear() {
|
|
@@ -1,164 +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 = null,
|
|
32
|
-
zoomLevelSizeAdaptor = null,
|
|
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 is3D = globe.api_GetCurrentGeometry() === 0;
|
|
81
|
-
const angleIsOn = is3D ? (this.angleAdaptorIsOn && this.angleOnSphere) : (this.angleAdaptorIsOn)
|
|
82
|
-
for (const [key, { lat, long, text, opacity = null, angle = null }] of itemMap) {
|
|
83
|
-
const { x, y } = globe.api_GetScreenPointFromGeo(
|
|
84
|
-
{
|
|
85
|
-
long: long,
|
|
86
|
-
lat: lat,
|
|
87
|
-
z: 0,
|
|
88
|
-
},
|
|
89
|
-
style.zMode === CSZMode.Z_MSL,
|
|
90
|
-
);
|
|
91
|
-
const o = opacity === null ? opacity_ : opacity * opacity_;
|
|
92
|
-
|
|
93
|
-
if (x !== null && y !== null) globe.api_DrawContextTextMultiLine(text, textFont, o, { x, y }, angleIsOn, angle);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
updateOpacityOfItem(item, i, container, properties) {
|
|
99
|
-
const opacity = this.opacityAdaptor(item, i, container, properties);
|
|
100
|
-
if (opacity == null) return;
|
|
101
|
-
const key = this.keyAdaptor(item, i, container, properties);
|
|
102
|
-
const data = this.itemMap.get(key)
|
|
103
|
-
data.opacity = opacity;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
updateOpacityContainer(container, properties) {
|
|
107
|
-
container.forEach((v, i, c) => {
|
|
108
|
-
this.updateOpacityOfItem(v, i, c, properties);
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
insertTextBulk(container, properties) {
|
|
114
|
-
container.forEach((v, i, c) => {
|
|
115
|
-
this.insertText(v, i, c, properties);
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
updateTextCoords(item, i, container, properties) {
|
|
120
|
-
const coords = this.coordinatesAdaptor(item, i, container, properties);
|
|
121
|
-
if (coords == null) return;
|
|
122
|
-
const key = this.keyAdaptor(item, i, container, properties);
|
|
123
|
-
const data = this.itemMap.get(key)
|
|
124
|
-
data.angle = this.angleAdaptor(item, i, container, properties);
|
|
125
|
-
data.long = coords.long;
|
|
126
|
-
data.lat = coords.lat;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
updateTextCoordsBulk(container, properties) {
|
|
130
|
-
container.forEach((v, i, c) => {
|
|
131
|
-
this.updateTextCoords(v, i, c, properties)
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
deleteTextBulk(keys) {
|
|
136
|
-
for (const key of keys) {
|
|
137
|
-
this.itemMap.delete(key);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
insertText(item, id, container, properties) {
|
|
143
|
-
const key = this.keyAdaptor(item, id, container, properties)
|
|
144
|
-
const coords = this.coordinatesAdaptor(item, id, container, properties)
|
|
145
|
-
if (coords == null) {
|
|
146
|
-
this.itemMap.delete(key);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const text = this.textAdaptor(item, id, container, properties)
|
|
150
|
-
if (text == null) {
|
|
151
|
-
this.itemMap.delete(key);
|
|
152
|
-
return
|
|
153
|
-
};
|
|
154
|
-
const opacity = this.opacityAdaptor(item, id, container, properties);
|
|
155
|
-
const angle = this.angleAdaptor(item, id, container, properties);
|
|
156
|
-
this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle, data: item });
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
clear() {
|
|
160
|
-
this.itemMap.clear();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|