@pirireis/webglobeplugins 0.6.30-c → 0.6.32-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/bearing-line/plugin.js +190 -241
- package/circle-line-chain/plugin.js +148 -155
- package/package.json +1 -1
- package/programs/totems/camerauniformblock.js +2 -1
- package/timetracks/program.js +250 -250
- package/write-text/context-text3.js +1 -7
- package/bearing-line/plugin copy.js +0 -542
package/bearing-line/plugin.js
CHANGED
|
@@ -18,36 +18,16 @@ const constraintFloat = (x, lowerBound, upperBound) => {
|
|
|
18
18
|
if (lowerBound > x || x > upperBound) throw new Error(`input must be between ${lowerBound} - ${upperBound}`)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* partial ring angle should be different on globe and mercator.
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @typedef {Object}textContextInjection
|
|
29
|
-
* @property {string} id
|
|
30
|
-
* @property {function} coordsAdaptor
|
|
31
|
-
* @property {function} textAdaptor
|
|
32
|
-
* @property {ContextTextWriter3} writer
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
// TODO UPDATE TO ContextTextWriter3
|
|
37
|
-
|
|
38
21
|
|
|
39
22
|
export default class Plugin {
|
|
40
23
|
/**
|
|
41
|
-
*
|
|
42
24
|
* @param {*} id
|
|
43
|
-
* @param {Map<[key, ContextTextWriter3]>}
|
|
44
|
-
*
|
|
25
|
+
* @param {Map<[key, ContextTextWriter3]>} textWritersMap
|
|
45
26
|
*/
|
|
46
|
-
|
|
47
27
|
constructor(id,
|
|
48
28
|
{
|
|
49
29
|
opacity = 1,
|
|
50
|
-
|
|
30
|
+
textWritersMap = new Map(),
|
|
51
31
|
textDataPreAdaptor = null,
|
|
52
32
|
drawVRM = true,
|
|
53
33
|
drawBearingLine = true,
|
|
@@ -58,33 +38,33 @@ export default class Plugin {
|
|
|
58
38
|
this.id = id;
|
|
59
39
|
this._opacity = opacity;
|
|
60
40
|
this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
|
|
61
|
-
this._checkTextContextWriterInjectionMap(
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
41
|
+
this._checkTextContextWriterInjectionMap(textWritersMap);
|
|
42
|
+
this._textWritersMap = textWritersMap;
|
|
43
|
+
this._textWritersMap.forEach((writer) => writer.keyAdaptor = (item) => item.key);
|
|
64
44
|
this.drawVRM = drawVRM;
|
|
65
45
|
this.drawBearingLine = drawBearingLine;
|
|
66
46
|
this.drawAngleRing = drawAngleRing;
|
|
67
|
-
|
|
68
47
|
this._textDataPreAdaptor = textDataPreAdaptor;
|
|
69
|
-
this._memoryForText = new Map();
|
|
70
|
-
|
|
71
48
|
this.drawText = drawText;
|
|
72
|
-
|
|
73
|
-
this.circleFlatEdgeCount = circleFlatEdgeCount + 2;
|
|
49
|
+
this._memoryForText = new Map();
|
|
50
|
+
this.circleFlatEdgeCount = circleFlatEdgeCount + 2;
|
|
74
51
|
}
|
|
75
52
|
|
|
53
|
+
|
|
76
54
|
setDoDrawVRM(bool) {
|
|
77
55
|
if (bool === this.drawVRM) return;
|
|
78
56
|
this.drawVRM = bool;
|
|
79
57
|
this.globe.DrawRender();
|
|
80
58
|
}
|
|
81
59
|
|
|
60
|
+
|
|
82
61
|
setDoDrawText(bool) {
|
|
83
62
|
if (bool === this.drawText) return;
|
|
84
63
|
this.drawText = bool;
|
|
85
64
|
this.globe.DrawRender();
|
|
86
65
|
}
|
|
87
66
|
|
|
67
|
+
|
|
88
68
|
setDoDrawText(bool) {
|
|
89
69
|
if (bool === this.drawText) return;
|
|
90
70
|
this.drawText = bool;
|
|
@@ -92,8 +72,6 @@ export default class Plugin {
|
|
|
92
72
|
}
|
|
93
73
|
|
|
94
74
|
|
|
95
|
-
|
|
96
|
-
|
|
97
75
|
setDoDrawAngleRing(bool) {
|
|
98
76
|
if (bool === this.drawAngleRing) return;
|
|
99
77
|
this.drawAngleRing = bool;
|
|
@@ -101,202 +79,14 @@ export default class Plugin {
|
|
|
101
79
|
}
|
|
102
80
|
|
|
103
81
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
82
|
setOpacity(opacity) {
|
|
108
83
|
constraintFloat(opacity, 0, 1);
|
|
109
84
|
this._opacity = opacity;
|
|
110
|
-
this.
|
|
85
|
+
this._textWritersMap.forEach((writer) => writer.setOpacity(opacity));
|
|
111
86
|
this.globe.DrawRender();
|
|
112
87
|
}
|
|
113
88
|
|
|
114
89
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
init(globe, gl) {
|
|
118
|
-
this.gl = gl;
|
|
119
|
-
this.globe = globe;
|
|
120
|
-
this.lineProgram = LineOnGlobeCache.get(globe);
|
|
121
|
-
this.ringProgram = pieceOfPieProgramCache.get(globe);
|
|
122
|
-
this.circleProgram = CircleCache.get(globe);
|
|
123
|
-
this.circle3DProgram = Circle3DCache.get(globe);
|
|
124
|
-
const circleFlatEdgeCount = this.circleFlatEdgeCount
|
|
125
|
-
{
|
|
126
|
-
// createBuffers
|
|
127
|
-
const bufferType = "DYNAMIC_DRAW";
|
|
128
|
-
const initialCapacity = this.bufferOrchestrator.capacity;
|
|
129
|
-
this.bufferManagersCompMap = new Map(
|
|
130
|
-
[
|
|
131
|
-
|
|
132
|
-
["centerCoords2d", {
|
|
133
|
-
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
134
|
-
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.long, item.lat)),
|
|
135
|
-
}],
|
|
136
|
-
["centerCoords2dflat", {
|
|
137
|
-
'bufferManager': new BufferManager(gl, circleFlatEdgeCount * 2, { bufferType, initialCapacity }),
|
|
138
|
-
'adaptor': (item) => item.centerCoords2dflat,
|
|
139
|
-
}],
|
|
140
|
-
["centerCoords3d", {
|
|
141
|
-
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
142
|
-
'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.long, item.lat, 0, 0)),
|
|
143
|
-
}],
|
|
144
|
-
["targetCoords2d", {
|
|
145
|
-
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
146
|
-
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.endLong, item.endLat))
|
|
147
|
-
}],
|
|
148
|
-
["targetCoords3d", {
|
|
149
|
-
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
150
|
-
'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.endLong, item.endLat, 0, 0))
|
|
151
|
-
}],
|
|
152
|
-
["bearingTargetCoords2d", {
|
|
153
|
-
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
154
|
-
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.bearingLong, item.bearingLat))
|
|
155
|
-
}],
|
|
156
|
-
["bearingTargetCoords3d", {
|
|
157
|
-
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
158
|
-
'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.bearingLong, item.bearingLat, 0, 0))
|
|
159
|
-
}],
|
|
160
|
-
["startAngle", {
|
|
161
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
162
|
-
'adaptor': (item) => new Float32Array([item.startAngle])
|
|
163
|
-
}],
|
|
164
|
-
["tailAngle", {
|
|
165
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
166
|
-
'adaptor': (item) => new Float32Array([item.tailAngle])
|
|
167
|
-
}],
|
|
168
|
-
["startAngle2d", {
|
|
169
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
170
|
-
'adaptor': (item) => new Float32Array([item.startAngle2d])
|
|
171
|
-
}],
|
|
172
|
-
["tailAngle2d", {
|
|
173
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
174
|
-
'adaptor': (item) => new Float32Array([item.tailAngle2d])
|
|
175
|
-
}],
|
|
176
|
-
["startAngle3d", {
|
|
177
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
178
|
-
'adaptor': (item) => new Float32Array([item.startAngle3d])
|
|
179
|
-
}],
|
|
180
|
-
["tailAngle3d", {
|
|
181
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
182
|
-
'adaptor': (item) => new Float32Array([item.tailAngle3d])
|
|
183
|
-
}],
|
|
184
|
-
["bearingDashRatio", {
|
|
185
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
186
|
-
'adaptor': (item) => new Float32Array([0])
|
|
187
|
-
}],
|
|
188
|
-
["rgba", {
|
|
189
|
-
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
190
|
-
'adaptor': (item) => new Float32Array(item.rgba)
|
|
191
|
-
}],
|
|
192
|
-
["radius", {
|
|
193
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
194
|
-
'adaptor': (item) => new Float32Array([item.radius])
|
|
195
|
-
}],
|
|
196
|
-
["rgbaMode", {
|
|
197
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
198
|
-
'adaptor': (item) => new Float32Array([item.rgbaMode])
|
|
199
|
-
}],
|
|
200
|
-
["dashRatio", {
|
|
201
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
202
|
-
'adaptor': (item) => new Float32Array([item.dashRatio])
|
|
203
|
-
}],
|
|
204
|
-
["bearingAngle", {
|
|
205
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
206
|
-
'adaptor': (item) => new Float32Array([item.bearingAngle])
|
|
207
|
-
}],
|
|
208
|
-
["bigRadius", {
|
|
209
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
210
|
-
'adaptor': (item) => new Float32Array([item.bigRadius])
|
|
211
|
-
}],
|
|
212
|
-
["dashOpacity", {
|
|
213
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
214
|
-
'adaptor': (item) => new Float32Array([item.dashOpacity]),
|
|
215
|
-
}],
|
|
216
|
-
|
|
217
|
-
// normal circle
|
|
218
|
-
["circleDashAngle", {
|
|
219
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
220
|
-
'adaptor': (item) => new Float32Array([item.circleDashAngle / 360]),
|
|
221
|
-
}],
|
|
222
|
-
// CIRCLE Mercator
|
|
223
|
-
["rgbaMercator", {
|
|
224
|
-
'bufferManager': new BufferManager(gl, 4 * circleFlatEdgeCount, { bufferType, initialCapacity }),
|
|
225
|
-
'adaptor': (item) => populateFloat32Array.fillWithListData(circleFlatEdgeCount, item.rgba),
|
|
226
|
-
}],
|
|
227
|
-
["circleDashAngleMercator", {
|
|
228
|
-
'bufferManager': new BufferManager(gl, circleFlatEdgeCount, { bufferType, initialCapacity }),
|
|
229
|
-
'adaptor': (item) => populateFloat32Array.fillFloat32Array(circleFlatEdgeCount, item.circleDashAngle / 360),
|
|
230
|
-
}],
|
|
231
|
-
["dashOpacityMercator", {
|
|
232
|
-
'bufferManager': new BufferManager(gl, circleFlatEdgeCount, { bufferType, initialCapacity }),
|
|
233
|
-
'adaptor': (item) => populateFloat32Array.fillFloat32Array(circleFlatEdgeCount, item.dashOpacity),
|
|
234
|
-
}],
|
|
235
|
-
|
|
236
|
-
]
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const obj = function (bufferManagerComp, divisor = 1) {
|
|
242
|
-
return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0, divisor }
|
|
243
|
-
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
this.lineVao = this.lineProgram.createVAO(
|
|
247
|
-
...['centerCoords2d', 'centerCoords3d', 'targetCoords2d', 'targetCoords3d', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
248
|
-
this.ringVao = this.ringProgram.createVAO(
|
|
249
|
-
...['centerCoords2d', 'centerCoords3d',
|
|
250
|
-
'startAngle2d',
|
|
251
|
-
'tailAngle2d',
|
|
252
|
-
'startAngle3d',
|
|
253
|
-
'tailAngle3d',
|
|
254
|
-
'rgba',
|
|
255
|
-
'radius',
|
|
256
|
-
'rgbaMode'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
257
|
-
{
|
|
258
|
-
this.bearingLineVAO = this.lineProgram.createVAO(
|
|
259
|
-
...['centerCoords2d', 'centerCoords3d', 'bearingTargetCoords2d', 'bearingTargetCoords3d', 'bearingDashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
260
|
-
}
|
|
261
|
-
// centerObj, startAngleObj, radiusObj, colorObj, dashRatioObj, dashOpacityObj
|
|
262
|
-
this.circleVao = this.circleProgram.createVAO(
|
|
263
|
-
...["centerCoords2dflat", "rgbaMercator", "circleDashAngleMercator", "dashOpacityMercator"].map(key => obj(this.bufferManagersCompMap.get(key)))
|
|
264
|
-
);
|
|
265
|
-
this.circle3DVao = this.circle3DProgram.createVAO(
|
|
266
|
-
...["centerCoords3d", "bigRadius", "rgba", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key)))
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
draw3D() {
|
|
275
|
-
const { gl } = this;
|
|
276
|
-
gl.disable(gl.DEPTH_TEST);
|
|
277
|
-
const is3D = this.globe.api_GetCurrentGeometry() === 0;
|
|
278
|
-
this.lineProgram.draw(this.lineVao, this.bufferOrchestrator.length, this._opacity);
|
|
279
|
-
if (this.drawAngleRing) {
|
|
280
|
-
this.ringProgram.draw(this.bufferOrchestrator.length, this.ringVao, 360, this._opacity * 0.8, RINGPARTIAL_DRAW_MODE.TRIANGLE_FAN);
|
|
281
|
-
this.ringProgram.draw(this.bufferOrchestrator.length, this.ringVao, 360, this._opacity, RINGPARTIAL_DRAW_MODE.LINE_STRIP);
|
|
282
|
-
}
|
|
283
|
-
if (this.drawBearingLine) {
|
|
284
|
-
this.lineProgram.draw(this.bearingLineVAO, this.bufferOrchestrator.length, this._opacity * 0.8);
|
|
285
|
-
}
|
|
286
|
-
if (this.drawVRM) {
|
|
287
|
-
if (is3D) {
|
|
288
|
-
this.circle3DProgram.draw(this.circle3DVao, this.bufferOrchestrator.length, this._opacity);
|
|
289
|
-
} else {
|
|
290
|
-
this.circleProgram.draw(this.circleVao, this.bufferOrchestrator.length, this.circleFlatEdgeCount, this._opacity);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
if (this.drawText) {
|
|
294
|
-
this._textContextInjectionMap.forEach((writer) => writer.draw());
|
|
295
|
-
}
|
|
296
|
-
gl.enable(gl.DEPTH_TEST);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
90
|
/**
|
|
301
91
|
* @typedef {{key, long, lat, endLong, endLat, bearingAngle, radius, rgba:[4numbers], rgbaMode, bigRadius, dashRatio, dashOpacity, circleDashAngle}} item
|
|
302
92
|
* @property {string} key
|
|
@@ -313,9 +103,9 @@ export default class Plugin {
|
|
|
313
103
|
* @property {number} dashOpacity 0-1
|
|
314
104
|
* @property {number} circleDashAngle 0-360
|
|
315
105
|
* @param {Array<item>} items
|
|
316
|
-
* @param {Array<string>} textWriterIDs |
|
|
106
|
+
* @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
|
|
317
107
|
*/
|
|
318
|
-
insertBulk(items, textWriterIDs = []) {
|
|
108
|
+
insertBulk(items, { textWriterIDs = [] } = {}) {
|
|
319
109
|
const { globe, bufferOrchestrator, bufferManagersCompMap } = this;// angleTextContext, distanceTextContext,
|
|
320
110
|
const data = []
|
|
321
111
|
for (let item of items) {
|
|
@@ -329,13 +119,14 @@ export default class Plugin {
|
|
|
329
119
|
|
|
330
120
|
|
|
331
121
|
updateText(textWriterIDs) {
|
|
332
|
-
const
|
|
122
|
+
const textWritersMap = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
|
|
333
123
|
this._memoryForText.forEach((item) => {
|
|
334
|
-
|
|
124
|
+
textWritersMap.forEach((writer) => writer.insertText(item));
|
|
335
125
|
});
|
|
336
126
|
this.globe.DrawRender();
|
|
337
127
|
}
|
|
338
128
|
|
|
129
|
+
|
|
339
130
|
deleteBulk(keys) {
|
|
340
131
|
this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersCompMap);
|
|
341
132
|
for (const key of keys) {
|
|
@@ -346,25 +137,25 @@ export default class Plugin {
|
|
|
346
137
|
}
|
|
347
138
|
|
|
348
139
|
|
|
349
|
-
defrag() {
|
|
140
|
+
defrag() {// use with caution
|
|
350
141
|
this.bufferOrchestrator.defrag(this.bufferManagersCompMap);
|
|
351
142
|
}
|
|
352
143
|
|
|
353
144
|
|
|
354
145
|
/**
|
|
355
146
|
* @param {Array<{key, long, lat, endLong, endLat, bearingAngle}>} items
|
|
356
|
-
* @param {Array<string>} textWriterIDs |
|
|
147
|
+
* @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
|
|
357
148
|
*/
|
|
358
|
-
updateCoordinatesBulk(items, textWriterIDs = []) {
|
|
149
|
+
updateCoordinatesBulk(items, { textWriterIDs = [] } = {}) {
|
|
359
150
|
const { globe, bufferOrchestrator, bufferManagersCompMap, } = this;
|
|
360
151
|
const data = []
|
|
361
152
|
for (let item of items) {
|
|
362
153
|
data.push(this.__updateCoordsAdaptor(item));
|
|
363
154
|
}
|
|
364
155
|
this.__insertTexts(items, textWriterIDs);
|
|
365
|
-
bufferOrchestrator.updateBulk(data, bufferManagersCompMap, ["centerCoords2d", "centerCoords3d", "targetCoords2d", "targetCoords3d",
|
|
156
|
+
bufferOrchestrator.updateBulk(data, bufferManagersCompMap, ["centerCoords2d", "centerCoords3d", "targetCoords2d", "targetCoords3d",
|
|
366
157
|
"startAngle2d", "tailAngle2d", "startAngle3d", "tailAngle3d", "bearingTargetCoords2d", "bearingTargetCoords3d", "centerCoords2dflat",
|
|
367
|
-
"
|
|
158
|
+
"bigRadius", "radius"]);
|
|
368
159
|
globe.DrawRender();
|
|
369
160
|
}
|
|
370
161
|
|
|
@@ -375,9 +166,9 @@ export default class Plugin {
|
|
|
375
166
|
* @param {string} propertyIDs
|
|
376
167
|
* @param {string} textWriterIDs
|
|
377
168
|
* Do NOT send empty data if property ID of this data is entered or NaN is loaded to the buffer, resulting in an unwanted behaviour.
|
|
378
|
-
* textWriterIDs = []
|
|
169
|
+
*{ textWriterIDs = []}
|
|
379
170
|
*/
|
|
380
|
-
updatePartial(items, propertyIDs = [], textWriterIDs = []) {
|
|
171
|
+
updatePartial(items, propertyIDs = [], { textWriterIDs = [] } = {}) {
|
|
381
172
|
if (propertyIDs.length === 0) console.warn("updatePartial is called with no target propertyIDs");
|
|
382
173
|
const fixedPropertyIDs = this.__fixPartialProperties(propertyIDs)
|
|
383
174
|
const { bufferOrchestrator, bufferManagersCompMap } = this;
|
|
@@ -387,6 +178,7 @@ export default class Plugin {
|
|
|
387
178
|
this.globe.DrawRender();
|
|
388
179
|
}
|
|
389
180
|
|
|
181
|
+
// Private methods
|
|
390
182
|
|
|
391
183
|
_checkTextContextWriterInjectionMap(textContextWriterInjectionMap) {
|
|
392
184
|
if (!(textContextWriterInjectionMap instanceof Map)) throw new Error("textContextWriterInjectionMap is not an instance of Map");
|
|
@@ -397,16 +189,17 @@ export default class Plugin {
|
|
|
397
189
|
|
|
398
190
|
|
|
399
191
|
__insertTexts(items, textWriterIDs) {
|
|
400
|
-
const
|
|
192
|
+
const textWritersMap = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
|
|
401
193
|
for (const item of items) {
|
|
402
194
|
const oldItem = this._memoryForText.get(item.key);
|
|
403
195
|
let _item = oldItem !== undefined ? { ...oldItem, ...item } : item;
|
|
404
196
|
if (this._textDataPreAdaptor !== null) _item = this._textDataPreAdaptor(_item);
|
|
405
197
|
this._memoryForText.set(item.key, _item);
|
|
406
|
-
|
|
198
|
+
textWritersMap.forEach((writer) => writer.insertText(_item));
|
|
407
199
|
}
|
|
408
200
|
}
|
|
409
201
|
|
|
202
|
+
|
|
410
203
|
__insertAdaptor(item) {
|
|
411
204
|
const rgba = item.rgba !== undefined ? item.rgba : [0, 0, 0, 0];
|
|
412
205
|
const rgbaMode = item.rgbaMode !== undefined ? item.rgbaMode : 0;
|
|
@@ -482,7 +275,168 @@ export default class Plugin {
|
|
|
482
275
|
return result;
|
|
483
276
|
}
|
|
484
277
|
|
|
485
|
-
//
|
|
278
|
+
// Globe API
|
|
279
|
+
|
|
280
|
+
init(globe, gl) {
|
|
281
|
+
this.gl = gl;
|
|
282
|
+
this.globe = globe;
|
|
283
|
+
this.lineProgram = LineOnGlobeCache.get(globe);
|
|
284
|
+
this.ringProgram = pieceOfPieProgramCache.get(globe);
|
|
285
|
+
this.circleProgram = CircleCache.get(globe);
|
|
286
|
+
this.circle3DProgram = Circle3DCache.get(globe);
|
|
287
|
+
const circleFlatEdgeCount = this.circleFlatEdgeCount
|
|
288
|
+
{
|
|
289
|
+
// createBuffers
|
|
290
|
+
const bufferType = "DYNAMIC_DRAW";
|
|
291
|
+
const initialCapacity = this.bufferOrchestrator.capacity;
|
|
292
|
+
this.bufferManagersCompMap = new Map(
|
|
293
|
+
[
|
|
294
|
+
["centerCoords2d", {
|
|
295
|
+
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
296
|
+
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.long, item.lat)),
|
|
297
|
+
}],
|
|
298
|
+
["centerCoords2dflat", {
|
|
299
|
+
'bufferManager': new BufferManager(gl, circleFlatEdgeCount * 2, { bufferType, initialCapacity }),
|
|
300
|
+
'adaptor': (item) => item.centerCoords2dflat,
|
|
301
|
+
}],
|
|
302
|
+
["centerCoords3d", {
|
|
303
|
+
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
304
|
+
'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.long, item.lat, 0, 0)),
|
|
305
|
+
}],
|
|
306
|
+
["targetCoords2d", {
|
|
307
|
+
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
308
|
+
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.endLong, item.endLat))
|
|
309
|
+
}],
|
|
310
|
+
["targetCoords3d", {
|
|
311
|
+
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
312
|
+
'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.endLong, item.endLat, 0, 0))
|
|
313
|
+
}],
|
|
314
|
+
["bearingTargetCoords2d", {
|
|
315
|
+
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
316
|
+
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.bearingLong, item.bearingLat))
|
|
317
|
+
}],
|
|
318
|
+
["bearingTargetCoords3d", {
|
|
319
|
+
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
320
|
+
'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.bearingLong, item.bearingLat, 0, 0))
|
|
321
|
+
}],
|
|
322
|
+
["startAngle2d", {
|
|
323
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
324
|
+
'adaptor': (item) => new Float32Array([item.startAngle2d])
|
|
325
|
+
}],
|
|
326
|
+
["tailAngle2d", {
|
|
327
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
328
|
+
'adaptor': (item) => new Float32Array([item.tailAngle2d])
|
|
329
|
+
}],
|
|
330
|
+
["startAngle3d", {
|
|
331
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
332
|
+
'adaptor': (item) => new Float32Array([item.startAngle3d])
|
|
333
|
+
}],
|
|
334
|
+
["tailAngle3d", {
|
|
335
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
336
|
+
'adaptor': (item) => new Float32Array([item.tailAngle3d])
|
|
337
|
+
}],
|
|
338
|
+
["bearingDashRatio", {
|
|
339
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
340
|
+
'adaptor': (item) => new Float32Array([0])
|
|
341
|
+
}],
|
|
342
|
+
["rgba", {
|
|
343
|
+
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
344
|
+
'adaptor': (item) => new Float32Array(item.rgba)
|
|
345
|
+
}],
|
|
346
|
+
["radius", {
|
|
347
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
348
|
+
'adaptor': (item) => new Float32Array([item.radius])
|
|
349
|
+
}],
|
|
350
|
+
["rgbaMode", {
|
|
351
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
352
|
+
'adaptor': (item) => new Float32Array([item.rgbaMode])
|
|
353
|
+
}],
|
|
354
|
+
["dashRatio", {
|
|
355
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
356
|
+
'adaptor': (item) => new Float32Array([item.dashRatio])
|
|
357
|
+
}],
|
|
358
|
+
|
|
359
|
+
["bigRadius", {
|
|
360
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
361
|
+
'adaptor': (item) => new Float32Array([item.bigRadius])
|
|
362
|
+
}],
|
|
363
|
+
["dashOpacity", {
|
|
364
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
365
|
+
'adaptor': (item) => new Float32Array([item.dashOpacity]),
|
|
366
|
+
}],
|
|
367
|
+
["circleDashAngle", {
|
|
368
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
369
|
+
'adaptor': (item) => new Float32Array([item.circleDashAngle / 360]),
|
|
370
|
+
}],
|
|
371
|
+
// Mercator circle properties are duplicated for the sake of performance.
|
|
372
|
+
["rgbaMercator", {
|
|
373
|
+
'bufferManager': new BufferManager(gl, 4 * circleFlatEdgeCount, { bufferType, initialCapacity }),
|
|
374
|
+
'adaptor': (item) => populateFloat32Array.fillWithListData(circleFlatEdgeCount, item.rgba),
|
|
375
|
+
}],
|
|
376
|
+
["circleDashAngleMercator", {
|
|
377
|
+
'bufferManager': new BufferManager(gl, circleFlatEdgeCount, { bufferType, initialCapacity }),
|
|
378
|
+
'adaptor': (item) => populateFloat32Array.fillFloat32Array(circleFlatEdgeCount, item.circleDashAngle / 360),
|
|
379
|
+
}],
|
|
380
|
+
["dashOpacityMercator", {
|
|
381
|
+
'bufferManager': new BufferManager(gl, circleFlatEdgeCount, { bufferType, initialCapacity }),
|
|
382
|
+
'adaptor': (item) => populateFloat32Array.fillFloat32Array(circleFlatEdgeCount, item.dashOpacity),
|
|
383
|
+
}],
|
|
384
|
+
]
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
const obj = function (bufferManagerComp, divisor = 1) {
|
|
388
|
+
return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0, divisor }
|
|
389
|
+
};
|
|
390
|
+
this.lineVao = this.lineProgram.createVAO(
|
|
391
|
+
...['centerCoords2d', 'centerCoords3d', 'targetCoords2d', 'targetCoords3d', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
392
|
+
this.ringVao = this.ringProgram.createVAO(
|
|
393
|
+
...['centerCoords2d', 'centerCoords3d',
|
|
394
|
+
'startAngle2d',
|
|
395
|
+
'tailAngle2d',
|
|
396
|
+
'startAngle3d',
|
|
397
|
+
'tailAngle3d',
|
|
398
|
+
'rgba',
|
|
399
|
+
'radius',
|
|
400
|
+
'rgbaMode'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
401
|
+
{
|
|
402
|
+
this.bearingLineVAO = this.lineProgram.createVAO(
|
|
403
|
+
...['centerCoords2d', 'centerCoords3d', 'bearingTargetCoords2d', 'bearingTargetCoords3d', 'bearingDashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
404
|
+
}
|
|
405
|
+
this.circleVao = this.circleProgram.createVAO(
|
|
406
|
+
...["centerCoords2dflat", "rgbaMercator", "circleDashAngleMercator", "dashOpacityMercator"].map(key => obj(this.bufferManagersCompMap.get(key)))
|
|
407
|
+
);
|
|
408
|
+
this.circle3DVao = this.circle3DProgram.createVAO(
|
|
409
|
+
...["centerCoords3d", "bigRadius", "rgba", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key)))
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
draw3D() {
|
|
415
|
+
const { gl } = this;
|
|
416
|
+
gl.disable(gl.DEPTH_TEST);
|
|
417
|
+
const is3D = this.globe.api_GetCurrentGeometry() === 0;
|
|
418
|
+
this.lineProgram.draw(this.lineVao, this.bufferOrchestrator.length, this._opacity);
|
|
419
|
+
if (this.drawAngleRing) {
|
|
420
|
+
this.ringProgram.draw(this.bufferOrchestrator.length, this.ringVao, 360, this._opacity * 0.8, RINGPARTIAL_DRAW_MODE.TRIANGLE_FAN);
|
|
421
|
+
this.ringProgram.draw(this.bufferOrchestrator.length, this.ringVao, 360, this._opacity, RINGPARTIAL_DRAW_MODE.LINE_STRIP);
|
|
422
|
+
}
|
|
423
|
+
if (this.drawBearingLine) {
|
|
424
|
+
this.lineProgram.draw(this.bearingLineVAO, this.bufferOrchestrator.length, this._opacity * 0.8);
|
|
425
|
+
}
|
|
426
|
+
if (this.drawVRM) {
|
|
427
|
+
if (is3D) {
|
|
428
|
+
this.circle3DProgram.draw(this.circle3DVao, this.bufferOrchestrator.length, this._opacity);
|
|
429
|
+
} else {
|
|
430
|
+
this.circleProgram.draw(this.circleVao, this.bufferOrchestrator.length, this.circleFlatEdgeCount, this._opacity);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (this.drawText) {
|
|
434
|
+
this._textWritersMap.forEach((writer) => writer.draw());
|
|
435
|
+
}
|
|
436
|
+
gl.enable(gl.DEPTH_TEST);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
|
|
486
440
|
free() {
|
|
487
441
|
if (this.isFreed) return;
|
|
488
442
|
this.bufferManagersCompMap.forEach(({ bufferManager, adaptor }) => {
|
|
@@ -502,16 +456,11 @@ export default class Plugin {
|
|
|
502
456
|
}
|
|
503
457
|
|
|
504
458
|
|
|
505
|
-
|
|
506
|
-
|
|
507
459
|
_deleteTexts(keys) {
|
|
508
|
-
this.
|
|
460
|
+
this._textWritersMap.forEach((writer) => {
|
|
509
461
|
writer.deleteTextBulk(keys);
|
|
510
462
|
});
|
|
511
463
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
464
|
}
|
|
516
465
|
|
|
517
466
|
|