@pirireis/webglobeplugins 0.6.0 → 0.6.1
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.
|
@@ -23,6 +23,7 @@ export class PixelPaddingCompassPlugin {
|
|
|
23
23
|
|
|
24
24
|
this.compassMap = new CompassMap(this);
|
|
25
25
|
this._opacity = opacity;
|
|
26
|
+
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
init(globe, gl) {
|
|
@@ -35,7 +36,7 @@ export class PixelPaddingCompassPlugin {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
insert(key, long, lat, properties = null) {
|
|
38
|
-
this.__insertText(key, null, null, properties);
|
|
39
|
+
this.__insertText(key, null, null, { properties, update: true });
|
|
39
40
|
this.compassMap.insert(key, long, lat, properties);
|
|
40
41
|
this.globe.DrawRender();
|
|
41
42
|
|
|
@@ -99,15 +100,19 @@ export class PixelPaddingCompassPlugin {
|
|
|
99
100
|
this.writer = new ContextTextWriter2Offsets(this.globe, { angle: PaddingAngle });
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
__insertText(key, x, y, properties) {
|
|
103
|
+
__insertText(key, x, y, { properties, update = false } = {}) {
|
|
103
104
|
if (!this.writer) return;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
if (update) {
|
|
106
|
+
let radius;
|
|
107
|
+
if (properties != null && properties.pixelRadiusBig) {
|
|
108
|
+
radius = properties.pixelRadiusBig
|
|
109
|
+
} else {
|
|
110
|
+
radius = this.defaultProperties.pixelRadiusBig;
|
|
111
|
+
}
|
|
112
|
+
this.writer.insertTextItem(key, x, y, radius);
|
|
107
113
|
} else {
|
|
108
|
-
|
|
114
|
+
this.writer.insertTextItem(key, x, y)
|
|
109
115
|
}
|
|
110
|
-
this.writer.insertTextItem(key, x, y, radius);
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
// Globe API interface methods
|
|
@@ -21,13 +21,41 @@ const defaultStyle = {
|
|
|
21
21
|
* 3) extend the mechanic on 2 to other events
|
|
22
22
|
*/
|
|
23
23
|
export class ContextTextWriter2Offsets {
|
|
24
|
-
constructor(globe, { style = null,
|
|
24
|
+
constructor(globe, { style = null, northStyle = {
|
|
25
|
+
textFont: {
|
|
26
|
+
name: 'Arial',
|
|
27
|
+
textColor: '#BB0000', // beyaz
|
|
28
|
+
hollowColor: '#000000', // siyah
|
|
29
|
+
size: 14, // piksel
|
|
30
|
+
hollow: true,
|
|
31
|
+
bold: true,
|
|
32
|
+
italic: false,
|
|
33
|
+
},
|
|
34
|
+
opacity: 1.0,
|
|
35
|
+
zMode: CSZMode.Z_GROUND_PERVERTEX,
|
|
36
|
+
}, doDraw = true, angle = 30, } = {}) {
|
|
25
37
|
this.globe = globe;
|
|
26
38
|
this.itemMap = new Map();
|
|
27
39
|
this.style = style || defaultStyle;
|
|
40
|
+
this.northStyle = northStyle || defaultStyle;
|
|
28
41
|
this.doDraw = doDraw;
|
|
29
42
|
this.angle = angle;
|
|
30
43
|
|
|
44
|
+
this.angles = []
|
|
45
|
+
this.texts = []
|
|
46
|
+
let currentAngle = 0;
|
|
47
|
+
while (currentAngle < 360) {
|
|
48
|
+
this.angles.push(currentAngle);
|
|
49
|
+
if (currentAngle == 0) {
|
|
50
|
+
this.texts.push("K");
|
|
51
|
+
} else {
|
|
52
|
+
this.texts.push(currentAngle.toString());
|
|
53
|
+
}
|
|
54
|
+
currentAngle += this.angle;
|
|
55
|
+
}
|
|
56
|
+
this._lastNorthAngle = globe.api_GetCurrentLookInfo()["NorthAng"] * (Math.PI / 180);
|
|
57
|
+
this.offsets = this.__offset(this._lastNorthAngle);
|
|
58
|
+
|
|
31
59
|
|
|
32
60
|
}
|
|
33
61
|
|
|
@@ -48,22 +76,37 @@ export class ContextTextWriter2Offsets {
|
|
|
48
76
|
}
|
|
49
77
|
|
|
50
78
|
|
|
79
|
+
_checkSetOffsets() {
|
|
80
|
+
const { globe } = this;
|
|
81
|
+
const newAngle = globe.api_GetCurrentLookInfo()["NorthAng"] * (Math.PI / 180);;
|
|
82
|
+
console.log("n angle", newAngle);
|
|
83
|
+
if (newAngle !== this._lastNorthAngle) {
|
|
84
|
+
this._lastNorthAngle = newAngle;
|
|
85
|
+
this.offsets = this.__offset();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
51
89
|
|
|
52
90
|
draw() {
|
|
53
91
|
if (!this.doDraw) return;
|
|
54
|
-
const { globe, style, itemMap } = this;
|
|
92
|
+
const { globe, style, itemMap, texts, angles } = this;
|
|
55
93
|
const { textFont, opacity: opacity_ } = style;
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
for (const [key, { center,
|
|
94
|
+
const { textFont: nFont } = this.northStyle;
|
|
95
|
+
this._checkSetOffsets();
|
|
96
|
+
const offsets = this.offsets;
|
|
97
|
+
for (const [key, { center, radius, opacity = null }] of itemMap) {
|
|
60
98
|
const o = opacity === null ? opacity_ : opacity * opacity_;
|
|
61
99
|
if (center.x !== null && center.y !== null) {
|
|
62
100
|
offsets.forEach(({ offsetX, offsetY }, i) => {
|
|
63
101
|
const text = texts[i];
|
|
64
102
|
const angle = angles[i];
|
|
65
|
-
|
|
66
|
-
|
|
103
|
+
if (angle === 0) {
|
|
104
|
+
globe.api_DrawContextTextMultiLine(text, nFont, o, { x: center.x + offsetX * radius, y: center.y + offsetY * radius });
|
|
105
|
+
|
|
106
|
+
} else {
|
|
107
|
+
globe.api_DrawContextTextMultiLine(text, textFont, o, { x: center.x + offsetX * radius, y: center.y + offsetY * radius });
|
|
108
|
+
|
|
109
|
+
}
|
|
67
110
|
});
|
|
68
111
|
}
|
|
69
112
|
|
|
@@ -71,15 +114,13 @@ export class ContextTextWriter2Offsets {
|
|
|
71
114
|
}
|
|
72
115
|
|
|
73
116
|
|
|
74
|
-
insertTextItem(key, x, y, radius) {
|
|
117
|
+
insertTextItem(key, x, y, radius = undefined) {
|
|
75
118
|
const item = this.getItem(key);
|
|
76
119
|
item.center = { x, y };
|
|
120
|
+
if (radius === undefined) return;
|
|
77
121
|
if (item.radius != undefined && item.radius === radius) return;
|
|
78
122
|
item.radius = radius;
|
|
79
|
-
|
|
80
|
-
item.offsets = offsets;
|
|
81
|
-
item.angles = angles;
|
|
82
|
-
item.texts = texts;
|
|
123
|
+
|
|
83
124
|
}
|
|
84
125
|
|
|
85
126
|
getItem(key) {
|
|
@@ -87,28 +128,21 @@ export class ContextTextWriter2Offsets {
|
|
|
87
128
|
return this.itemMap.get(key);
|
|
88
129
|
}
|
|
89
130
|
|
|
90
|
-
__calculateOffset(
|
|
131
|
+
__calculateOffset(angle) {
|
|
91
132
|
const rAngle = (angle - 90) * (Math.PI / 180);
|
|
92
|
-
return { offsetX: Math.cos(rAngle
|
|
133
|
+
return { offsetX: Math.cos(rAngle + this._lastNorthAngle), offsetY: Math.sin(rAngle + this._lastNorthAngle) };
|
|
93
134
|
}
|
|
94
135
|
|
|
95
|
-
|
|
136
|
+
__offset() {
|
|
96
137
|
const angle = this.angle;
|
|
97
138
|
const offsets = []
|
|
98
|
-
const angles = []
|
|
99
|
-
const texts = []
|
|
100
139
|
let currentAngle = 0;
|
|
101
140
|
while (currentAngle < 360) {
|
|
102
|
-
offsets.push(this.__calculateOffset(
|
|
103
|
-
|
|
104
|
-
if (currentAngle == 0) {
|
|
105
|
-
texts.push("K");
|
|
106
|
-
} else {
|
|
107
|
-
texts.push(currentAngle.toString());
|
|
108
|
-
}
|
|
141
|
+
offsets.push(this.__calculateOffset(currentAngle));
|
|
142
|
+
|
|
109
143
|
currentAngle += angle;
|
|
110
144
|
}
|
|
111
|
-
return
|
|
145
|
+
return offsets;
|
|
112
146
|
}
|
|
113
147
|
|
|
114
148
|
|