@pirireis/webglobeplugins 0.6.34 → 0.6.36-a
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/circle-line-chain/plugin.js +0 -2
- package/package.json +1 -1
- package/programs/line-on-globe/lines-color-instanced-flat.js +1 -1
- package/rangerings/plugin.js +59 -23
- package/rangerings/rangeringangletext.js +1 -3
- package/rangerings/ring-account.js +30 -19
- package/timetracks/plugin-line-strip.js +1 -14
- package/timetracks/program-line-strip.js +1 -12
- package/write-text/attached-text-writer.js +105 -0
- package/write-text/context-text3.js +4 -1
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ void main() {
|
|
|
34
34
|
if ( gap > 37000000.0) { return; }
|
|
35
35
|
float z_alpha;
|
|
36
36
|
if ( z_alpha_on == 1 ){
|
|
37
|
-
z_alpha = pow(z_level,3.0) / (
|
|
37
|
+
z_alpha = pow(z_level,3.0) / ( 20000000.0 / gap);
|
|
38
38
|
if( z_alpha < 0.1 ) {return;}
|
|
39
39
|
if( z_alpha > 1.0 ) {z_alpha = 1.0;}
|
|
40
40
|
} else {
|
package/rangerings/plugin.js
CHANGED
|
@@ -49,29 +49,40 @@ import { centerCoords2dflatDataCreatorWithRadius, CircleCache as CircleCache2D }
|
|
|
49
49
|
import { CircleCache as CircleCache3D } from "../programs/line-on-globe/circle-accurate-3d";
|
|
50
50
|
import { LinesColorInstancedFlatCache } from "../programs/line-on-globe/lines-color-instanced-flat";
|
|
51
51
|
import { BufferOrchestrator, BufferManager } from "../util/account";
|
|
52
|
+
import { mapGetOrThrow } from "../util/check/get";
|
|
52
53
|
import { populateFloat32Array } from "../util/jshelpers/data-filler";
|
|
53
|
-
import { RingAccount,
|
|
54
|
+
import { RingAccount, ringBigPaddingKeyMethod } from "./ring-account";
|
|
54
55
|
import { CirclePadding3DCache } from "../programs/line-on-globe/degree-padding-around-circle-3d";
|
|
55
56
|
import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate';
|
|
56
57
|
import RangeRingAngleText from "./rangeringangletext";
|
|
57
58
|
import { Z_ALPHA_MODE } from "../programs/line-on-globe/util";
|
|
59
|
+
import { ENUM_HIDE } from "./enum";
|
|
58
60
|
|
|
59
61
|
const CIRCLE_FLAT_EDGE_COUNT = 362; // 360 + 2 for closing the circle and a cutting point
|
|
60
62
|
|
|
61
63
|
|
|
62
64
|
|
|
63
65
|
|
|
64
|
-
class RangeRings {
|
|
65
|
-
constructor(id, { oneDegreePadding = true, showNumbers = true, numbersStyle = null, opacity = 1, zAlphaOnDegreePadding = Z_ALPHA_MODE.ON } = {}) {
|
|
66
66
|
|
|
67
|
+
class RangeRings {
|
|
68
|
+
constructor(id,
|
|
69
|
+
{
|
|
70
|
+
oneDegreePadding = true, showNumbers = true, numbersStyle = null, opacity = 1, zAlphaOnDegreePadding = Z_ALPHA_MODE.ON
|
|
71
|
+
} = {},
|
|
72
|
+
{
|
|
73
|
+
textDataPreAdaptor = null,
|
|
74
|
+
textWritersMap = new Map()
|
|
75
|
+
} = {}) {
|
|
67
76
|
this.id = id;
|
|
68
|
-
|
|
69
77
|
this._oneDegreePadding = oneDegreePadding;
|
|
70
78
|
this._zAlphaOnDegreePadding = zAlphaOnDegreePadding;
|
|
71
79
|
this._showNumbers = showNumbers;
|
|
72
80
|
this._numbersStyle = numbersStyle;
|
|
73
81
|
this._opacity = opacity;
|
|
74
82
|
this._ringAccount = new RingAccount();
|
|
83
|
+
this._textWritersMap = textWritersMap;
|
|
84
|
+
this._textDataPreAdaptor = textDataPreAdaptor;
|
|
85
|
+
this._textWritersMap.forEach((textWriter) => textWriter.setKeyAdaptor((item) => item.__identity__));
|
|
75
86
|
|
|
76
87
|
}
|
|
77
88
|
|
|
@@ -83,7 +94,7 @@ class RangeRings {
|
|
|
83
94
|
/**
|
|
84
95
|
* @method updateCentersCoordinate @param { Array < { centerID, long,lat } >} items
|
|
85
96
|
*/
|
|
86
|
-
updateCentersCoordinate(items) {
|
|
97
|
+
updateCentersCoordinate(items, { textWriterIDs = [] } = {}) {
|
|
87
98
|
// Algorithm
|
|
88
99
|
/**
|
|
89
100
|
* 1. ask centerRingAccount for existing rings COORDINATE RELATED KEYS
|
|
@@ -98,15 +109,13 @@ class RangeRings {
|
|
|
98
109
|
} = this;
|
|
99
110
|
for (const { centerID } of items) {
|
|
100
111
|
const datas = this.__reconstructCentralRings(centerID);
|
|
101
|
-
// TODO add big paddings when when implemented
|
|
102
112
|
bufferOrchestrator.updateBulk(datas, bufferManagersCompMap, ["centerCoords3d", "centerCoords2dflat", "centerCoords2dflatForPadding"]);
|
|
103
113
|
const paddingDatas = this.__reconstructCentralRingsBigPaddings(centerID);
|
|
104
114
|
paddingBufferOrchestrator.updateBulk(paddingDatas, bufferManagersCompMapPadding, ["circlePoint", "paddingPoint", "circlePoint3d", "paddingPoint3d"]);
|
|
105
115
|
}
|
|
106
116
|
this.textPlugin?.updateCentersXY(items);
|
|
107
117
|
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
this.__contextTextWriterUpdate(items.map(({ centerID }) => centerID), textWriterIDs);
|
|
110
119
|
globe.DrawRender();
|
|
111
120
|
}
|
|
112
121
|
|
|
@@ -115,17 +124,15 @@ class RangeRings {
|
|
|
115
124
|
* @typedef { Array < { ringID, radius, padding } >} rings
|
|
116
125
|
* @param { Array < centerID: string, long: number, lat: number, stepAngle: number, rgba: [4 numbers], rings: rings, hide, textHide } items
|
|
117
126
|
*/
|
|
118
|
-
insertBulk(items) {
|
|
127
|
+
insertBulk(items, { textWriterIDs = [] } = {}) {
|
|
119
128
|
// Algorithm
|
|
120
129
|
/**
|
|
121
130
|
* 1 ask centerRingAccount for existing rings
|
|
122
|
-
* presizely: TODO
|
|
123
131
|
* 2. delete all existing keys with buffer orchestators
|
|
124
132
|
* 3. insert new centerRings to centerRingAccount
|
|
125
133
|
* 4. insert new keys with buffer orchestators
|
|
126
134
|
*/
|
|
127
135
|
const { globe, _ringAccount, bufferOrchestrator, bufferManagersCompMap, paddingBufferOrchestrator, bufferManagersCompMapPadding } = this;
|
|
128
|
-
// TODO add delete existing for padding
|
|
129
136
|
for (const item of items) {
|
|
130
137
|
const existingKeys = _ringAccount.ringKeys(item.centerID);
|
|
131
138
|
if (existingKeys.length) {
|
|
@@ -145,6 +152,7 @@ class RangeRings {
|
|
|
145
152
|
paddingBufferOrchestrator.insertBulk(paddingDatas, bufferManagersCompMapPadding);
|
|
146
153
|
}
|
|
147
154
|
this.textPlugin?.insertBulk(items);
|
|
155
|
+
this.__contextTextWriterUpdate(items.map(({ centerID }) => centerID), textWriterIDs);
|
|
148
156
|
globe.DrawRender();
|
|
149
157
|
}
|
|
150
158
|
|
|
@@ -154,7 +162,7 @@ class RangeRings {
|
|
|
154
162
|
/**
|
|
155
163
|
* @method updateCentersColor @param { Array < { centerID, rgba: [4 numbers] } >} centerColors
|
|
156
164
|
*/
|
|
157
|
-
updateCentersColor(centerColors) {
|
|
165
|
+
updateCentersColor(centerColors, { textWriterIDs = [] } = {}) {
|
|
158
166
|
// Algorithm
|
|
159
167
|
/**
|
|
160
168
|
* 1. ask centerRingAccount for existing rings COLOR KEYS
|
|
@@ -172,6 +180,7 @@ class RangeRings {
|
|
|
172
180
|
const paddingDatas = this.__reconstructCentralPaddingProperties(centerID)
|
|
173
181
|
paddingBufferOrchestrator.updateBulk(paddingDatas, bufferManagersCompMapPadding, ["rgba"]);
|
|
174
182
|
}
|
|
183
|
+
this.__contextTextWriterUpdate(centerColors.map(({ centerID }) => centerID), textWriterIDs);
|
|
175
184
|
globe.DrawRender();
|
|
176
185
|
}
|
|
177
186
|
|
|
@@ -179,7 +188,7 @@ class RangeRings {
|
|
|
179
188
|
*
|
|
180
189
|
* @method updateCentersHide @param { Array < { centerID, hide, textHide } >} centerHides
|
|
181
190
|
*/
|
|
182
|
-
updateCentersHide(centerHides) {
|
|
191
|
+
updateCentersHide(centerHides, { textWriterIDs = [] } = {}) {
|
|
183
192
|
// Algorithm
|
|
184
193
|
/**
|
|
185
194
|
* Simple
|
|
@@ -196,11 +205,14 @@ class RangeRings {
|
|
|
196
205
|
for (const { centerID } of centerHides) {
|
|
197
206
|
const datas = this.__reconstructCentralProperties(centerID);
|
|
198
207
|
bufferOrchestrator.updateBulk(datas, bufferManagersCompMap, ["rgba", "rgbaMercator"]);
|
|
208
|
+
const paddingDatas0 = this.__reconstructCentralRings(centerID);
|
|
209
|
+
bufferOrchestrator.updateBulk(paddingDatas0, bufferManagersCompMap, ["radius3dsmall", "centerCoords2dflatForPadding"]);
|
|
210
|
+
|
|
199
211
|
const paddingDatas = this.__reconstructCentralPaddingProperties(centerID)
|
|
200
212
|
paddingBufferOrchestrator.updateBulk(paddingDatas, bufferManagersCompMapPadding, ["rgba"]);
|
|
201
213
|
}
|
|
202
|
-
|
|
203
214
|
this.textPlugin?.updateCentersHide(centerHides);
|
|
215
|
+
this.__contextTextWriterUpdate(centerHides.map(({ centerID }) => centerID), textWriterIDs);
|
|
204
216
|
globe.DrawRender();
|
|
205
217
|
/**
|
|
206
218
|
* Complicated
|
|
@@ -229,6 +241,7 @@ class RangeRings {
|
|
|
229
241
|
const existingKeys = _ringAccount.ringKeys(centerID);
|
|
230
242
|
if (existingKeys.length) {
|
|
231
243
|
bufferOrchestrator.deleteBulk(existingKeys, bufferManagersCompMap);
|
|
244
|
+
this._textWritersMap.forEach((textWriter) => textWriter.deleteTextBulk(existingKeys));
|
|
232
245
|
}
|
|
233
246
|
}
|
|
234
247
|
|
|
@@ -239,6 +252,9 @@ class RangeRings {
|
|
|
239
252
|
}
|
|
240
253
|
}
|
|
241
254
|
this.textPlugin?.removeCenters(centerIDs);
|
|
255
|
+
|
|
256
|
+
// this.__contextTextWriterUpdate(centerIDs, null);
|
|
257
|
+
|
|
242
258
|
globe.DrawRender();
|
|
243
259
|
}
|
|
244
260
|
|
|
@@ -249,6 +265,7 @@ class RangeRings {
|
|
|
249
265
|
if (typeof opacity !== "number" || opacity < 0 || opacity > 1) throw new Error("Invalid opacity value");
|
|
250
266
|
this._opacity = opacity;
|
|
251
267
|
this.textPlugin?.setOpacity(opacity);
|
|
268
|
+
this._textWritersMap((writer) => writer.setOpacity(opacity));
|
|
252
269
|
this.globe.DrawRender();
|
|
253
270
|
}
|
|
254
271
|
|
|
@@ -302,7 +319,7 @@ class RangeRings {
|
|
|
302
319
|
}],
|
|
303
320
|
["rgba", {
|
|
304
321
|
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
305
|
-
'adaptor': (item) => new Float32Array(item.hide ===
|
|
322
|
+
'adaptor': (item) => new Float32Array(item.hide === ENUM_HIDE.HIDE ? [0, 0, 0, 0] : item.rgba)
|
|
306
323
|
}],
|
|
307
324
|
["radius3d", {
|
|
308
325
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
@@ -310,7 +327,10 @@ class RangeRings {
|
|
|
310
327
|
}],
|
|
311
328
|
["radius3dsmall", {
|
|
312
329
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
313
|
-
'adaptor': (item) =>
|
|
330
|
+
'adaptor': (item) => {
|
|
331
|
+
if (item.hide === ENUM_HIDE.HIDE_1_DEGREE_PADDINGS) return new Float32Array([item.radius]);
|
|
332
|
+
return new Float32Array([item.radius - item.padding / 3])
|
|
333
|
+
}
|
|
314
334
|
}],
|
|
315
335
|
["circleDashAngle", {
|
|
316
336
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
@@ -332,7 +352,7 @@ class RangeRings {
|
|
|
332
352
|
}],
|
|
333
353
|
["rgbaMercator", {
|
|
334
354
|
'bufferManager': new BufferManager(gl, 4 * CIRCLE_FLAT_EDGE_COUNT, { bufferType, initialCapacity }),
|
|
335
|
-
'adaptor': (item) => populateFloat32Array.fillWithListData(CIRCLE_FLAT_EDGE_COUNT, item.hide ===
|
|
355
|
+
'adaptor': (item) => populateFloat32Array.fillWithListData(CIRCLE_FLAT_EDGE_COUNT, item.hide === ENUM_HIDE.HIDE ? [0, 0, 0, 0] : item.rgba),
|
|
336
356
|
}],
|
|
337
357
|
["circleDashAngleMercator", {
|
|
338
358
|
'bufferManager': new BufferManager(gl, CIRCLE_FLAT_EDGE_COUNT, { bufferType, initialCapacity }),
|
|
@@ -451,10 +471,11 @@ class RangeRings {
|
|
|
451
471
|
|
|
452
472
|
const result = [];
|
|
453
473
|
|
|
454
|
-
for (const { ringID, radius, padding } of rings) {
|
|
455
|
-
const key =
|
|
474
|
+
for (const { ringID, radius, padding, __identity__ } of rings) {
|
|
475
|
+
const key = __identity__;
|
|
456
476
|
const centerCoords2dflat = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radius, { edgeCount: CIRCLE_FLAT_EDGE_COUNT });
|
|
457
|
-
const
|
|
477
|
+
const radiusPadding = hide === ENUM_HIDE.HIDE_1_DEGREE_PADDINGS ? radius : radius - padding / 3;
|
|
478
|
+
const centerCoords2dflatForPadding = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radiusPadding, { edgeCount: CIRCLE_FLAT_EDGE_COUNT });
|
|
458
479
|
result.push({
|
|
459
480
|
key,
|
|
460
481
|
centerCoords3d,
|
|
@@ -495,11 +516,11 @@ class RangeRings {
|
|
|
495
516
|
if (centerItem === undefined) throw new Error("Center not found");
|
|
496
517
|
const { rgba, rings, hide = 0, textHide = 0 } = centerItem;
|
|
497
518
|
const result = [];
|
|
498
|
-
for (const { ringID } of rings) {
|
|
499
|
-
const key =
|
|
519
|
+
for (const { ringID, __identity__ } of rings) {
|
|
520
|
+
const key = __identity__;
|
|
500
521
|
result.push({
|
|
501
522
|
key,
|
|
502
|
-
rgba: hide ===
|
|
523
|
+
rgba: hide === ENUM_HIDE.HIDE ? new Float32Array([0, 0, 0, 0]) : rgba,
|
|
503
524
|
textHide
|
|
504
525
|
});
|
|
505
526
|
}
|
|
@@ -543,6 +564,7 @@ class RangeRings {
|
|
|
543
564
|
if (_oneDegreePadding) _padding2dProgram.draw(_oneDegreePaddingVao, bufferOrchestrator.length * CIRCLE_FLAT_EDGE_COUNT, _opacity, _zAlphaOnDegreePadding);
|
|
544
565
|
}
|
|
545
566
|
_bigPadding3dFlatProgram.draw(_bigPadding3dFlatVAO, paddingBufferOrchestrator.length, _opacity);
|
|
567
|
+
this._textWritersMap.forEach((textWriter) => textWriter.draw());
|
|
546
568
|
gl.enable(gl.DEPTH_TEST);
|
|
547
569
|
}
|
|
548
570
|
|
|
@@ -572,7 +594,21 @@ class RangeRings {
|
|
|
572
594
|
this._isFreed = true;
|
|
573
595
|
}
|
|
574
596
|
|
|
597
|
+
|
|
598
|
+
__contextTextWriterUpdate(centerIDs, textWriterIDs = null) {
|
|
599
|
+
let textWriters = null;
|
|
600
|
+
if (textWriterIDs === null) {
|
|
601
|
+
textWriters = Array.from(this._textWritersMap.values());
|
|
602
|
+
} else if (textWriterIDs.length === 0) {
|
|
603
|
+
return
|
|
604
|
+
} else {
|
|
605
|
+
textWriters = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
|
|
606
|
+
}
|
|
607
|
+
centerIDs.forEach((centerID) => { this._ringAccount.textUpdate(centerID, textWriters, this._textDataPreAdaptor); });
|
|
608
|
+
}
|
|
575
609
|
}
|
|
576
610
|
|
|
577
611
|
|
|
612
|
+
const textWriterGetOrThrow = mapGetOrThrow("textWriterIDs is invalid")
|
|
613
|
+
|
|
578
614
|
export { RangeRings, Z_ALPHA_MODE };
|
|
@@ -44,9 +44,7 @@ export default class RangeRingAngleText {
|
|
|
44
44
|
// new inner MAP params
|
|
45
45
|
// hide
|
|
46
46
|
// textHide
|
|
47
|
-
|
|
48
47
|
this.ObjectArray.Add(this.object);
|
|
49
|
-
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
getDefaultStyle() {
|
|
@@ -205,7 +203,7 @@ export default class RangeRingAngleText {
|
|
|
205
203
|
const _hide = hide !== null ? hide : centerMap.get("hide");
|
|
206
204
|
const _textHide = textHide !== null ? textHide : centerMap.get("textHide");
|
|
207
205
|
|
|
208
|
-
const show = _hide !== ENUM_HIDE.HIDE && _textHide === ENUM_TEXT_HIDE.SHOW;
|
|
206
|
+
const show = (_hide !== ENUM_HIDE.HIDE) && (_textHide === ENUM_TEXT_HIDE.SHOW);
|
|
209
207
|
if (!isHidden && !show) {
|
|
210
208
|
this._fillDeleteBucket(centerID, deleteBucket);
|
|
211
209
|
} else if (isHidden && show) {
|
|
@@ -4,11 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { BufferOrchestrator, BufferManager } from "../util/account";
|
|
10
|
-
|
|
11
|
-
|
|
12
7
|
const ringKeyMethod = (centerID, ringID) => `${centerID}_${ringID}`;
|
|
13
8
|
const ringBigPaddingKeyMethod = (centerID, ringID, angle) => `${centerID}_${ringID}_${angle}`;
|
|
14
9
|
|
|
@@ -23,18 +18,22 @@ class RingAccount {
|
|
|
23
18
|
}
|
|
24
19
|
|
|
25
20
|
/**
|
|
26
|
-
* @typedef {centerID, long,lat, rings}
|
|
21
|
+
* @typedef {centerID, long,lat, rings} centralItem
|
|
27
22
|
*
|
|
28
23
|
*/
|
|
29
|
-
insertCenter(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
insertCenter(centralItem) {
|
|
25
|
+
centralItem.rings.forEach((ring) => {
|
|
26
|
+
ring.__identity__ = ringKeyMethod(centralItem.centerID, ring.ringID);
|
|
27
|
+
});
|
|
28
|
+
this._centeralMap.set(centralItem.centerID, {
|
|
29
|
+
centerID: centralItem.centerID,
|
|
30
|
+
long: centralItem.long,
|
|
31
|
+
lat: centralItem.lat,
|
|
32
|
+
rings: centralItem.rings,
|
|
33
|
+
rgba: new Float32Array(centralItem.rgba),
|
|
34
|
+
hide: centralItem.hide,
|
|
35
|
+
textHide: centralItem.textHide,
|
|
36
|
+
stepAngle: centralItem.stepAngle,
|
|
38
37
|
});
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -57,8 +56,8 @@ class RingAccount {
|
|
|
57
56
|
for (const { centerID, hide = null, textHide = null } of items) {
|
|
58
57
|
const center = this.getCenter(centerID);
|
|
59
58
|
if (center) {
|
|
60
|
-
if (hide) center.hide = hide;
|
|
61
|
-
if (textHide) center.textHide = textHide;
|
|
59
|
+
if (hide !== null) center.hide = hide;
|
|
60
|
+
if (textHide !== null) center.textHide = textHide;
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
}
|
|
@@ -83,8 +82,8 @@ class RingAccount {
|
|
|
83
82
|
const center = this.getCenter(centerID);
|
|
84
83
|
if (center) {
|
|
85
84
|
const rings = center.rings;
|
|
86
|
-
for (const {
|
|
87
|
-
result.push(
|
|
85
|
+
for (const { __identity__ } of rings) {
|
|
86
|
+
result.push(__identity__);
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
return result;
|
|
@@ -105,6 +104,18 @@ class RingAccount {
|
|
|
105
104
|
}
|
|
106
105
|
return result;
|
|
107
106
|
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
textUpdate(centerID, textWriterObjs, dataPreAdaptor = null) {
|
|
111
|
+
const center = this.getCenter(centerID);
|
|
112
|
+
if (!center) return;
|
|
113
|
+
const data = (dataPreAdaptor) ? dataPreAdaptor(center) : center;
|
|
114
|
+
textWriterObjs.forEach((writer) => {
|
|
115
|
+
writer.insertTextBulk(data.rings, data);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
}
|
|
108
119
|
}
|
|
109
120
|
|
|
110
121
|
|
|
@@ -89,16 +89,6 @@ export default class TimeTrackMultiColorPlugin {
|
|
|
89
89
|
this.globe.DrawRender();
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
setGlow(isGlow) {
|
|
93
|
-
this.program.setGlow(isGlow);
|
|
94
|
-
this.globe.DrawRender();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
setPremultipliedAlpha(isPremultiplied) {
|
|
98
|
-
this.program.setPremultipliedAlpha(isPremultiplied);
|
|
99
|
-
this.globe.DrawRender();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
92
|
setBlurWeights(weights) {
|
|
103
93
|
this.program.setBlurWeights(weights);
|
|
104
94
|
this.globe.DrawRender();
|
|
@@ -134,10 +124,7 @@ export default class TimeTrackMultiColorPlugin {
|
|
|
134
124
|
this.globe.DrawRender();
|
|
135
125
|
}
|
|
136
126
|
|
|
137
|
-
|
|
138
|
-
this.program.setAlphaThreshold(alphaThreshold);
|
|
139
|
-
this.globe.DrawRender();
|
|
140
|
-
}
|
|
127
|
+
|
|
141
128
|
|
|
142
129
|
// ---------------point program setters-------------------
|
|
143
130
|
|
|
@@ -60,7 +60,7 @@ export default class TrackGlowLineProgram {
|
|
|
60
60
|
gl.uniform1f(_lineProgram.u_route_alpha, options.routeAlpha || 0.025);
|
|
61
61
|
|
|
62
62
|
gl.useProgram(_blurProgram.program);
|
|
63
|
-
gl.uniform1fv(_blurProgram.u_weight, options.weights || [
|
|
63
|
+
gl.uniform1fv(_blurProgram.u_weight, options.weights || [0.55, 0.45045946, 0.3216216, 0.254054, 0.056216]);
|
|
64
64
|
|
|
65
65
|
gl.useProgram(_combineProgram.program);
|
|
66
66
|
gl.uniform1f(_combineProgram.u_exposure, options.exposure || 1.0);
|
|
@@ -71,14 +71,6 @@ export default class TrackGlowLineProgram {
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
setPremultipliedAlpha(boolean) {
|
|
75
|
-
throw new Error("setPremultipliedAlpha method is depricated. Please remove it from your code.");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
setAlphaThreshold(alpha) {
|
|
80
|
-
throw new Error("setAlphaThreshold method is depricated. Please remove it from your code.");
|
|
81
|
-
}
|
|
82
74
|
|
|
83
75
|
|
|
84
76
|
/**
|
|
@@ -163,9 +155,6 @@ export default class TrackGlowLineProgram {
|
|
|
163
155
|
gl.useProgram(currentProgram);
|
|
164
156
|
}
|
|
165
157
|
|
|
166
|
-
setGlow(boolean) {
|
|
167
|
-
throw new Error("setGlow method is depricated. Please remove it from your code.");
|
|
168
|
-
}
|
|
169
158
|
|
|
170
159
|
/**
|
|
171
160
|
* blur uses pingpong effect. This number decides how many times the blur will be applied.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
|
|
2
|
+
import { CSZMode } from "@pirireis/webglobe";
|
|
3
|
+
import { isTextFont, opacityCheck } from "../util/check/typecheck";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Light wight version of context text writer.
|
|
7
|
+
* The parameters by text are calculated on user side and inserted as items. (ContextTextWriter3 constructs text data from items)
|
|
8
|
+
*
|
|
9
|
+
* Good side of ContextTextWriters pattern is that there is only one way to create text.
|
|
10
|
+
* The glue is inside the plugin.
|
|
11
|
+
* This makes the code more readable and maintainable.
|
|
12
|
+
*
|
|
13
|
+
* With AttachedTextWriter the glue is created by user.
|
|
14
|
+
* I observed that the users generally uses a wrapper around the plugin logic anyway. This wrapper can be used as the glue for plugin and attacked writer.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export class AttachedTextWriter {
|
|
18
|
+
constructor(globe, {
|
|
19
|
+
style = {
|
|
20
|
+
textFont: {
|
|
21
|
+
name: 'Arial',
|
|
22
|
+
textColor: '#FFFFFF', // beyaz
|
|
23
|
+
hollowColor: '#000000', // siyah
|
|
24
|
+
size: 12, // piksel
|
|
25
|
+
hollow: true,
|
|
26
|
+
bold: true,
|
|
27
|
+
italic: false,
|
|
28
|
+
},
|
|
29
|
+
opacity: 1.0,
|
|
30
|
+
zMode: CSZMode.Z_GROUND_PERVERTEX,
|
|
31
|
+
},
|
|
32
|
+
doDraw = true,
|
|
33
|
+
angleOnSphere = false,
|
|
34
|
+
zoomLevelAdaptor = (zoomLevel) => (item) => {
|
|
35
|
+
return {
|
|
36
|
+
opacityMultiplier: 1,
|
|
37
|
+
sizeMultiplier: 1
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
} = {}) {
|
|
41
|
+
this.globe = globe;
|
|
42
|
+
this._itemMap = new Map();
|
|
43
|
+
this.doDraw = doDraw;
|
|
44
|
+
this.angleOnSphere = angleOnSphere;
|
|
45
|
+
this.zoomLevelAdaptor = zoomLevelAdaptor;
|
|
46
|
+
this.setStyle(style);
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
setOpacity(opacity) {
|
|
52
|
+
opacityCheck(opacity);
|
|
53
|
+
this._style.opacity = opacity;
|
|
54
|
+
this.globe.DrawRender();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setStyle(style) {
|
|
58
|
+
isTextFont(style.textFont);
|
|
59
|
+
this._style = style;
|
|
60
|
+
this.globe.DrawRender();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param {{text, long, lat, z = 0, xOffset = 0, yOffset = 0, isAngleOn = false, Angle = 0 }} item
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
insertItem(item) {
|
|
70
|
+
const key = this.keyAdaptor ? this.keyAdaptor(item) : item;
|
|
71
|
+
this._itemMap.set(key, item);
|
|
72
|
+
this.globe.DrawRender();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// TODO: use item style
|
|
76
|
+
draw() {
|
|
77
|
+
if (!this.doDraw) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const { globe, _itemMap, _style } = this;
|
|
81
|
+
const { zMode, textFont, opacity } = _style;
|
|
82
|
+
const is3D = globe.api_GetCurrentGeometry() === 0;
|
|
83
|
+
const angleIsOn = is3D ? true : this.angleOnSphere;
|
|
84
|
+
const zoomLevel = globe.api_GetCurrentLODWithDecimal();
|
|
85
|
+
const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
|
|
86
|
+
const theSize = textFont.size;
|
|
87
|
+
_itemMap.forEach((item, key) => {
|
|
88
|
+
const { text, long, lat, z = 0, xOffset = 0, yOffset = 0, isAngleOn = false, angle = 0 } = item;
|
|
89
|
+
const { x, y } = globe.api_GetScreenPointFromGeo(
|
|
90
|
+
{
|
|
91
|
+
long,
|
|
92
|
+
lat,
|
|
93
|
+
z
|
|
94
|
+
},
|
|
95
|
+
zMode
|
|
96
|
+
);
|
|
97
|
+
const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(item);
|
|
98
|
+
textFont.size = sizeMultiplier * theSize;
|
|
99
|
+
if (x !== null && y !== null) {
|
|
100
|
+
globe.api_DrawContextText(text, textFont, opacityMultiplier * opacity, { x: x + xOffset, y: y - yOffset }, (isAngleOn && angleIsOn), angle);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
textFont.size = theSize;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -81,16 +81,19 @@ export class ContextTextWriter3 {
|
|
|
81
81
|
|
|
82
82
|
setDoDraw(bool) {
|
|
83
83
|
this.doDraw = bool;
|
|
84
|
+
this.globe.DrawRender();
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
setStyle(style) {
|
|
87
88
|
isTextFont(style.textFont);
|
|
88
89
|
opacityCheck(style.opacity);
|
|
89
90
|
this.style = style;
|
|
91
|
+
this.globe.DrawRender();
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
setOpacity(opacity) {
|
|
93
95
|
this.style.opacity = opacity;
|
|
96
|
+
this.globe.DrawRender();
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
|
|
@@ -129,7 +132,7 @@ export class ContextTextWriter3 {
|
|
|
129
132
|
insertTextBulk(container, properties) {
|
|
130
133
|
container.forEach((v, i, c) => {
|
|
131
134
|
this.insertText(v, i, c, properties);
|
|
132
|
-
})
|
|
135
|
+
});
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
|