@pirireis/webglobeplugins 0.6.12 → 0.6.15
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/chain-list-map.js +1 -1
- package/circle-line-chain/plugin-accurate.js +406 -0
- package/circle-line-chain/plugin.js +6 -3
- package/compass-rose/compass-rose-padding-flat.js +25 -2
- package/heatwave/plugins/heatwaveglobeshell.js +0 -2
- package/package.json +1 -1
- package/{heatwavemaps/isobar/objectarraylabels.js → pin/pin-object-array.js} +135 -1
- package/programs/line-on-globe/naive-accurate.js +219 -0
- package/programs/line-on-globe/naive.js +1 -1
- package/programs/line-on-globe/to-the-origin.js +165 -0
- package/programs/two-d/pixel-padding-for-compass.js +0 -3
- package/util/shaderfunctions/geometrytransformations.js +29 -1
- package/heatwavemaps/index.js +0 -4
- package/heatwavemaps/isobar/plugin.js +0 -337
- package/heatwavemaps/isobar/quadtreecontours.js +0 -338
- package/heatwavemaps/plugins/heatwaveglobeshell.js +0 -257
|
@@ -174,8 +174,8 @@ export class ChainListMap {
|
|
|
174
174
|
*/
|
|
175
175
|
textUpdate(chainKey, textWriterObjs, dataPreAdaptor) {
|
|
176
176
|
const chain = this._chainMap.get(chainKey);
|
|
177
|
-
const data = (dataPreAdaptor) ? chain.map(dataPreAdaptor) : chain;
|
|
178
177
|
if (!chain) return;
|
|
178
|
+
const data = (dataPreAdaptor) ? chain.map(dataPreAdaptor) : chain;
|
|
179
179
|
const properties = this._chainSideProperties.get(chainKey);
|
|
180
180
|
textWriterObjs.forEach((writer) => {
|
|
181
181
|
writer.insertTextBulk(data, properties);
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate';
|
|
2
|
+
import { CircleCache } from '../programs/line-on-globe/circle';
|
|
3
|
+
import { LineToTheOriginCache } from "../programs/line-on-globe/to-the-origin"
|
|
4
|
+
import { BufferOrchestrator, BufferManager } from "../util/account";
|
|
5
|
+
import { ChainListMap } from "./chain-list-map";
|
|
6
|
+
import { mapGetOrThrow } from "../util/check/get";
|
|
7
|
+
import { keyMethod } from "./util";
|
|
8
|
+
import { ContextTextWriter3 } from '../write-text/context-text3';
|
|
9
|
+
// TODO: Add update buffer and update text mehods on add, delete, update methods
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Insert info to chain list map (nodes and properties)
|
|
14
|
+
*
|
|
15
|
+
* ask chain list map for text data
|
|
16
|
+
* ask chain list map for buffer data
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
* addNode
|
|
20
|
+
* insertBulk
|
|
21
|
+
* deleteChain
|
|
22
|
+
* deleteNodes
|
|
23
|
+
* updateCoordinates()
|
|
24
|
+
* updateChainProperties
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef StyleProperties
|
|
30
|
+
* @property {[0-1,0-1,0-1,0-1]} rgba
|
|
31
|
+
* @property { 0-1 } dashOpacity
|
|
32
|
+
* @property { 0-1 } dashRatio
|
|
33
|
+
* @property {0-360} circleDashAngle
|
|
34
|
+
* @property {Array<node>} nodes
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const radian = Math.PI / 180;
|
|
38
|
+
|
|
39
|
+
export class CircleLineChainPlugin {
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param {*} id
|
|
43
|
+
* @param {Map<[key, ContextTextWriter3]} textContextWriterInjectionMap //import { ContextTextWriter3 } from "@pirireis/webglobeplugins/write-text/context-text3";
|
|
44
|
+
*/
|
|
45
|
+
constructor(id, {
|
|
46
|
+
drawCircleOn = true,
|
|
47
|
+
textContextWriterInjectionMap = new Map(),
|
|
48
|
+
textDataPreAdaptor = null
|
|
49
|
+
} = {}) {
|
|
50
|
+
this.id = id;
|
|
51
|
+
this._checkTextContextWriterInjectionMap(textContextWriterInjectionMap);
|
|
52
|
+
this._textContextWriterInjectionMap = textContextWriterInjectionMap;
|
|
53
|
+
this._textContextWriterInjectionMap.forEach((writer) => writer.setKeyAdaptor((v, i, c, properties) => v.__identity__));
|
|
54
|
+
this._opacity = 1;
|
|
55
|
+
this._chainListMap = new ChainListMap(keyMethod);
|
|
56
|
+
this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
|
|
57
|
+
this._drawCircleOn = drawCircleOn;
|
|
58
|
+
this._textDataPreAdaptor = textDataPreAdaptor;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// init
|
|
62
|
+
|
|
63
|
+
init(globe, gl) {
|
|
64
|
+
this.gl = gl;
|
|
65
|
+
this.globe = globe
|
|
66
|
+
this._initOrchestrations()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_checkTextContextWriterInjectionMap(textContextWriterInjectionMap) {
|
|
70
|
+
if (!(textContextWriterInjectionMap instanceof Map)) throw new Error("textContextWriterInjectionMap is not an instance of Map");
|
|
71
|
+
textContextWriterInjectionMap.forEach((v) => {
|
|
72
|
+
if (!(v instanceof ContextTextWriter3)) throw new Error("textContextWriterInjectionMap element is not an instance of ContextTextWriter3");
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_initOrchestrations() {
|
|
77
|
+
const { gl, globe } = this;
|
|
78
|
+
this.lineProgram = LineOnGlobeCache.get(globe);
|
|
79
|
+
this.circleProgram = CircleCache.get(globe);
|
|
80
|
+
this.lineToTheOriginProgram = LineToTheOriginCache.get(globe);
|
|
81
|
+
{
|
|
82
|
+
// createBuffers
|
|
83
|
+
const bufferType = "DYNAMIC_DRAW";
|
|
84
|
+
const initialCapacity = this.bufferOrchestrator.capacity;
|
|
85
|
+
this.bufferManagersCompMap = new Map(
|
|
86
|
+
[
|
|
87
|
+
["centerCoords2d", {
|
|
88
|
+
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
89
|
+
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.long, item.lat)),
|
|
90
|
+
}],
|
|
91
|
+
["centerCoords3d", {
|
|
92
|
+
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
93
|
+
'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.long, item.lat, 0, 0)),
|
|
94
|
+
}],
|
|
95
|
+
["targetCoords2d", {
|
|
96
|
+
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
97
|
+
'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.targetLong, item.targetLat)),
|
|
98
|
+
}],
|
|
99
|
+
["targetCoords3d", {
|
|
100
|
+
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
101
|
+
'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.targetLong, item.targetLat, 0, 0)),
|
|
102
|
+
}],
|
|
103
|
+
["rgba", {
|
|
104
|
+
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
105
|
+
'adaptor': (item) => {
|
|
106
|
+
if (item.lineProperties?.rgba) return new Float32Array(item.lineProperties.rgba);
|
|
107
|
+
return new Float32Array(item.chainProperties.rgba);
|
|
108
|
+
}
|
|
109
|
+
}],
|
|
110
|
+
["bigRadius", {
|
|
111
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
112
|
+
'adaptor': (item) => new Float32Array([item.bigRadius])
|
|
113
|
+
}],
|
|
114
|
+
["dashRatio", {
|
|
115
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
116
|
+
'adaptor': (item) => new Float32Array([item.chainProperties.dashRatio])
|
|
117
|
+
}],
|
|
118
|
+
|
|
119
|
+
["dashOpacity", {
|
|
120
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
121
|
+
'adaptor': (item) => new Float32Array([item.chainProperties.dashOpacity])
|
|
122
|
+
}],
|
|
123
|
+
["circleDashAngle", {
|
|
124
|
+
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
125
|
+
'adaptor': (item) => {
|
|
126
|
+
if (item.circleProperties?.circleDashAngle) return new Float32Array([item.circleProperties.circleDashAngle / 360]);
|
|
127
|
+
return new Float32Array([item.chainProperties.circleDashAngle / 360]);
|
|
128
|
+
}
|
|
129
|
+
}],
|
|
130
|
+
["rgbaCircle", {
|
|
131
|
+
"bufferManager": new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
132
|
+
"adaptor": (item) => {
|
|
133
|
+
if (item.circleProperties?.rgba) return new Float32Array(item.circleProperties.rgba);
|
|
134
|
+
return new Float32Array(item.chainProperties.rgba);
|
|
135
|
+
}
|
|
136
|
+
}]
|
|
137
|
+
]
|
|
138
|
+
);
|
|
139
|
+
// (startPotisionBufferObj, endPositionBufferObj, dashRatioBufferObj, colorBufferObj)
|
|
140
|
+
const obj = function (bufferManagerComp) {
|
|
141
|
+
return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 }
|
|
142
|
+
};
|
|
143
|
+
this.lineVao = this.lineProgram.createVAO(
|
|
144
|
+
...['centerCoords2d', 'centerCoords3d', 'targetCoords2d', 'targetCoords3d', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
145
|
+
// this.circleVao = this.circleProgram.createVAO(
|
|
146
|
+
// ...["centerCoords", "bigRadius", "rgbaCircle", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
147
|
+
// this.toOriginVao = this.lineToTheOriginProgram.createVAO(
|
|
148
|
+
// ...["targetCoords", "rgba"].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
// API
|
|
155
|
+
setDrawCircleOn(bool) {
|
|
156
|
+
if (typeof bool !== 'boolean') throw new Error("setDrawCircleOn parameter must be a boolean");
|
|
157
|
+
this._drawCircleOn = bool;
|
|
158
|
+
this.globe.DrawRender();
|
|
159
|
+
}
|
|
160
|
+
// -- update bulk family
|
|
161
|
+
/**
|
|
162
|
+
*
|
|
163
|
+
* @param {Array<chain>} data
|
|
164
|
+
* @typedef chain
|
|
165
|
+
* @property {string} chainKey
|
|
166
|
+
* @property {Array<node>} nodes
|
|
167
|
+
* @typedef {Object} node
|
|
168
|
+
* @property {string} key
|
|
169
|
+
* @property {number} long
|
|
170
|
+
* @property {number} lat
|
|
171
|
+
*/
|
|
172
|
+
updateCoordinatesBulk(data, { textWriterIDs = [] } = {}) {
|
|
173
|
+
// update implicit data structure
|
|
174
|
+
// find keys to update.. (inserted data and the radius of "from")
|
|
175
|
+
// updateBuffers
|
|
176
|
+
// update text
|
|
177
|
+
const chainKeys = [];
|
|
178
|
+
for (const chain of data) {
|
|
179
|
+
chainKeys.push(chain.chainKey);
|
|
180
|
+
chain.nodes.forEach((node) => {
|
|
181
|
+
this._chainListMap.updateCoordsinatesOfNode(node, chain.chainKey);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
this._reconstructChains(chainKeys);
|
|
185
|
+
this._updateTexts(chainKeys, textWriterIDs);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
*
|
|
191
|
+
* @param {*} chainKey
|
|
192
|
+
* @param {Array<{nodeKey, circleProperties:Map[propertyName ,value], lineProperties:Map[propertyName ,value] }} propertyMap
|
|
193
|
+
*/
|
|
194
|
+
updateNodesProperties(chainKey, nodesAndPropertyMap, { textWriterIDs = [] } = {}) {
|
|
195
|
+
this._chainListMap.updateNodesProperties(chainKey, nodesAndPropertyMap)
|
|
196
|
+
this._reconstructChains([chainKey]);
|
|
197
|
+
this._updateTexts([chainKey], textWriterIDs);
|
|
198
|
+
this.globe.DrawRender();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
*
|
|
203
|
+
* @param {*} chainKey
|
|
204
|
+
* @param {Map<propertyName ,value} propertyMap
|
|
205
|
+
*/
|
|
206
|
+
updateChainProperties(chainKey, propertyMap, { textWriterIDs = [] } = {}) {
|
|
207
|
+
this._chainListMap.updateChainProperties(chainKey, propertyMap);
|
|
208
|
+
this._reconstructChains([chainKey]);
|
|
209
|
+
if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ---- insertBulk family
|
|
213
|
+
/**
|
|
214
|
+
*
|
|
215
|
+
* @param {Array<chain>} data
|
|
216
|
+
* @typedef chain
|
|
217
|
+
* @property {string} chainKey
|
|
218
|
+
* @property {StyleProperties} chainProperties
|
|
219
|
+
|
|
220
|
+
* } chainProperties
|
|
221
|
+
*
|
|
222
|
+
* @typedef {Object} node
|
|
223
|
+
* @property {string} key
|
|
224
|
+
* @property {number} long
|
|
225
|
+
* @property {number} lat
|
|
226
|
+
* @property {StyleProperties} circleProperties
|
|
227
|
+
*/
|
|
228
|
+
insertBulk(data, { textWriterIDs = [] } = []) {
|
|
229
|
+
// first insert everything to implicit structure,
|
|
230
|
+
// then iterate over data again to update text
|
|
231
|
+
// let _reconstractChainBufferData method interact with data and bufferOrchestrator.
|
|
232
|
+
const chainKeysToConstruct = [];
|
|
233
|
+
|
|
234
|
+
for (const { chainKey, chainProperties, nodes } of data) {
|
|
235
|
+
this._chainListMap.setChain(chainKey, nodes);
|
|
236
|
+
this._chainListMap.setChainProperties(chainKey, chainProperties);
|
|
237
|
+
chainKeysToConstruct.push(chainKey);
|
|
238
|
+
}
|
|
239
|
+
this._reconstructChains(chainKeysToConstruct);
|
|
240
|
+
if (textWriterIDs) this._updateTexts(chainKeysToConstruct, textWriterIDs);
|
|
241
|
+
this.globe.DrawRender();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
*
|
|
246
|
+
* @param {{key, long, lat}} node
|
|
247
|
+
* @param {*} chainKey
|
|
248
|
+
* @param {*} theNodeKeyFront | node key of the next node, null places to the last
|
|
249
|
+
*/
|
|
250
|
+
addNode(node, chainKey, { theNodeKeyFront = null, textWriterIDs = [] } = {}) {
|
|
251
|
+
// TODO: if before object is null update the last two elements of the chain only.
|
|
252
|
+
this._chainListMap.addNode(node, chainKey, theNodeKeyFront);
|
|
253
|
+
if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
|
|
254
|
+
this._reconstructChains([chainKey]);
|
|
255
|
+
this.globe.DrawRender();
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
updateNodeCoordinates(node, chainKey, { textWriterIDs = [] } = {}) {
|
|
262
|
+
this._chainListMap.updateCoordsinatesOfNode(node, chainKey);
|
|
263
|
+
if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
|
|
264
|
+
this._reconstructChains([chainKey]);
|
|
265
|
+
this.globe.DrawRender();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
setOpacity(opacity) {
|
|
271
|
+
if (typeof opacity !== 'number') throw new Error("opacity must be a number");
|
|
272
|
+
if (opacity < 0 || 1 < opacity) throw new Error("opacity must be between 0-1");
|
|
273
|
+
this._textContextWriterInjectionMap.forEach((writer) => writer.setOpacity(opacity));
|
|
274
|
+
this._opacity = opacity;
|
|
275
|
+
this.globe.DrawRender();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
getChain(chainKey) {
|
|
281
|
+
this._chainListMap.getChain(chainKey);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
*
|
|
286
|
+
* @param {*} chainKeys
|
|
287
|
+
*/
|
|
288
|
+
deleteChains(chainKeys) {
|
|
289
|
+
const bufferKeys = [];
|
|
290
|
+
for (const chainKey of chainKeys) {
|
|
291
|
+
bufferKeys.push(...this._chainListMap.deleteChainAndReturnChainKeys(chainKey));
|
|
292
|
+
}
|
|
293
|
+
this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
|
|
294
|
+
this._updateTexts(chainKeys, this._textContextWriterInjectionMap.keys());
|
|
295
|
+
this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
|
|
296
|
+
this.globe.DrawRender();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
*
|
|
302
|
+
* @param {Array<{chainKey, nodeKeys:[]} keysAndNodes
|
|
303
|
+
*/
|
|
304
|
+
deleteNodes(keysAndNodes, { textWriterIDs = [] } = {}) {
|
|
305
|
+
const bufferKeys = [];
|
|
306
|
+
const chainKeysToReconstuct = [];
|
|
307
|
+
keysAndNodes.forEach(({ chainKey, nodeKeys }) => {
|
|
308
|
+
bufferKeys.push(...this._chainListMap.deleteNodesBelongToAChain(chainKey, nodeKeys));
|
|
309
|
+
chainKeysToReconstuct.push(chainKey);
|
|
310
|
+
});
|
|
311
|
+
this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
|
|
312
|
+
this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
|
|
313
|
+
this._reconstructChains(chainKeysToReconstuct);
|
|
314
|
+
this._updateTexts(chainKeysToReconstuct, textWriterIDs);
|
|
315
|
+
this.globe.DrawRender();
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
updateText(textWriterIDs) {
|
|
321
|
+
const chainKeyIterator = this._chainListMap.getAllChainKeysIterator();
|
|
322
|
+
this._updateTexts(chainKeyIterator, textWriterIDs);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
// implicit
|
|
327
|
+
|
|
328
|
+
_updateTexts(chainKeys, textWriterIDs) {
|
|
329
|
+
if (textWriterIDs.length === 0) return;
|
|
330
|
+
const textWriters = textWriterGetOrThrow(this._textContextWriterInjectionMap, textWriterIDs)
|
|
331
|
+
chainKeys.forEach((chainKey) => {
|
|
332
|
+
this._chainListMap.textUpdate(chainKey, textWriters, this._textDataPreAdaptor);
|
|
333
|
+
})
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
_reconstructChains(chainKeys) {
|
|
338
|
+
const { globe } = this;
|
|
339
|
+
// this.lineVao = this.lineProgram.createVAO(
|
|
340
|
+
// ...['centerCoords', 'targetCoords', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
341
|
+
// this.circleVao = this.circleProgram.createVAO(
|
|
342
|
+
// ...["centerCoords", "bigRadius", "rgba", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
343
|
+
// }
|
|
344
|
+
|
|
345
|
+
const radiusM = radiusMethod(globe);
|
|
346
|
+
const callback = (v, i, array, chainProperties) => {
|
|
347
|
+
if (i == array.length - 1) return null;
|
|
348
|
+
return {
|
|
349
|
+
chainProperties: chainProperties,
|
|
350
|
+
bigRadius: radiusM(v, i, array),
|
|
351
|
+
targetLong: array[i + 1].long,
|
|
352
|
+
targetLat: array[i + 1].lat,
|
|
353
|
+
long: v.long,
|
|
354
|
+
lat: v.lat,
|
|
355
|
+
lineProperties: v.lineProperties,
|
|
356
|
+
circleProperties: v.circleProperties,
|
|
357
|
+
key: v.__identity__
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const bulkData = [];
|
|
361
|
+
chainKeys.forEach((k) => {
|
|
362
|
+
this._chainListMap.calculateBufferPropertiesChain(k, callback, bulkData);
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
this._insertBulk(bulkData);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
_insertBulk(bulkData) {
|
|
370
|
+
this.bufferOrchestrator.insertBulk(bulkData, this.bufferManagersCompMap);
|
|
371
|
+
this.globe.DrawRender();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
// GLOBE API
|
|
376
|
+
//TODO:
|
|
377
|
+
free() {
|
|
378
|
+
if (this.isFreed) return;
|
|
379
|
+
this.bufferManagersCompMap.forEach(({ bufferManager }) => {
|
|
380
|
+
bufferManager.free();
|
|
381
|
+
})
|
|
382
|
+
LineOnGlobeCache.release(this.globe);
|
|
383
|
+
CircleCache.release(this.globe);
|
|
384
|
+
this.lineProgram = null;
|
|
385
|
+
this.circleProgram = null;
|
|
386
|
+
this.isFreed = true;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
draw3D() {
|
|
390
|
+
const { gl, globe } = this;
|
|
391
|
+
gl.disable(gl.DEPTH_TEST);
|
|
392
|
+
this.lineProgram.draw(this.lineVao, this.bufferOrchestrator.length, this._opacity);
|
|
393
|
+
if (this._drawCircleOn) this.circleProgram.draw(this.circleVao, this.bufferOrchestrator.length, this._opacity);
|
|
394
|
+
this._textContextWriterInjectionMap.forEach((writer) => writer.draw());
|
|
395
|
+
gl.enable(gl.DEPTH_TEST);
|
|
396
|
+
this.lineToTheOriginProgram.draw(this.toOriginVao, this.bufferOrchestrator.length, this._opacity);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
const radiusMethod = (globe) => (v, i, array) => {
|
|
403
|
+
return globe.Math.GetDist3D(v.long, v.lat, array[i + 1].long, array[i + 1].lat)
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const textWriterGetOrThrow = mapGetOrThrow("textWriterIds is invalid")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LineOnGlobeCache } from '../programs/line-on-globe/naive';
|
|
2
2
|
import { CircleCache } from '../programs/line-on-globe/circle';
|
|
3
|
+
import { LineToTheOriginCache } from "../programs/line-on-globe/to-the-origin"
|
|
3
4
|
import { BufferOrchestrator, BufferManager } from "../util/account";
|
|
4
5
|
import { ChainListMap } from "./chain-list-map";
|
|
5
6
|
import { mapGetOrThrow } from "../util/check/get";
|
|
@@ -76,6 +77,7 @@ export class CircleLineChainPlugin {
|
|
|
76
77
|
const { gl, globe } = this;
|
|
77
78
|
this.lineProgram = LineOnGlobeCache.get(globe);
|
|
78
79
|
this.circleProgram = CircleCache.get(globe);
|
|
80
|
+
this.lineToTheOriginProgram = LineToTheOriginCache.get(globe);
|
|
79
81
|
{
|
|
80
82
|
// createBuffers
|
|
81
83
|
const bufferType = "DYNAMIC_DRAW";
|
|
@@ -134,14 +136,14 @@ export class CircleLineChainPlugin {
|
|
|
134
136
|
...['centerCoords', 'targetCoords', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
135
137
|
this.circleVao = this.circleProgram.createVAO(
|
|
136
138
|
...["centerCoords", "bigRadius", "rgbaCircle", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
139
|
+
this.toOriginVao = this.lineToTheOriginProgram.createVAO(
|
|
140
|
+
...["targetCoords", "rgba"].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
|
|
142
146
|
// API
|
|
143
|
-
|
|
144
|
-
|
|
145
147
|
setDrawCircleOn(bool) {
|
|
146
148
|
if (typeof bool !== 'boolean') throw new Error("setDrawCircleOn parameter must be a boolean");
|
|
147
149
|
this._drawCircleOn = bool;
|
|
@@ -377,12 +379,13 @@ export class CircleLineChainPlugin {
|
|
|
377
379
|
}
|
|
378
380
|
|
|
379
381
|
draw3D() {
|
|
380
|
-
const { gl } = this;
|
|
382
|
+
const { gl, globe } = this;
|
|
381
383
|
gl.disable(gl.DEPTH_TEST);
|
|
382
384
|
this.lineProgram.draw(this.lineVao, this.bufferOrchestrator.length, this._opacity);
|
|
383
385
|
if (this._drawCircleOn) this.circleProgram.draw(this.circleVao, this.bufferOrchestrator.length, this._opacity);
|
|
384
386
|
this._textContextWriterInjectionMap.forEach((writer) => writer.draw());
|
|
385
387
|
gl.enable(gl.DEPTH_TEST);
|
|
388
|
+
this.lineToTheOriginProgram.draw(this.toOriginVao, this.bufferOrchestrator.length, this._opacity);
|
|
386
389
|
}
|
|
387
390
|
}
|
|
388
391
|
|
|
@@ -57,14 +57,27 @@ export class PixelPaddingCompassPlugin {
|
|
|
57
57
|
this._initOrchestrations()
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} key
|
|
63
|
+
* @param {number} long
|
|
64
|
+
* @param {number} lat
|
|
65
|
+
* @typedef properties
|
|
66
|
+
* @property {number} pixelRadiusBig
|
|
67
|
+
* @property {number} pixelRadiusSmall
|
|
68
|
+
* @property {[4 numbers between 0-1]} rgba
|
|
69
|
+
*/
|
|
60
70
|
insert(key, long, lat, properties = null) {
|
|
61
71
|
this.__insertText(key, null, null, { properties, update: true });
|
|
62
72
|
this.compassMap.insert(key, long, lat, properties);
|
|
63
73
|
this.globe.DrawRender();
|
|
64
|
-
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param {string} key
|
|
80
|
+
*/
|
|
68
81
|
delete(key) {
|
|
69
82
|
this.compassMap.delete(key);
|
|
70
83
|
this.globe.DrawRender();
|
|
@@ -166,7 +179,10 @@ export class PixelPaddingCompassPlugin {
|
|
|
166
179
|
}
|
|
167
180
|
|
|
168
181
|
free() {
|
|
169
|
-
|
|
182
|
+
this.compassMap.free();
|
|
183
|
+
this.bufferManagersCompMap.forEach(v => {
|
|
184
|
+
v.bufferManager.free();
|
|
185
|
+
})
|
|
170
186
|
|
|
171
187
|
}
|
|
172
188
|
}
|
|
@@ -190,6 +206,13 @@ class CompassMap {
|
|
|
190
206
|
this.propertyMemory.delete(key);
|
|
191
207
|
}
|
|
192
208
|
|
|
209
|
+
free() {
|
|
210
|
+
this.coordsMemory.clear();
|
|
211
|
+
this.propertyMemory.clear();
|
|
212
|
+
this.coordsMemory = null;
|
|
213
|
+
this.propertyMemory = null;
|
|
214
|
+
}
|
|
215
|
+
|
|
193
216
|
query(globe, writer) {
|
|
194
217
|
const { coordsMemory, propertyMemory } = this;
|
|
195
218
|
const defaultProperties = this.parent.defaultProperties;
|
package/package.json
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* IconData;
|
|
4
|
+
* iconMap, iconCoords for objectArray
|
|
5
|
+
*
|
|
6
|
+
* Pin data:
|
|
7
|
+
* long, lat, payload
|
|
8
|
+
*
|
|
9
|
+
* methods insertPin pin and its data
|
|
10
|
+
* methods deletePin
|
|
11
|
+
*
|
|
12
|
+
* Behaviur injection:
|
|
13
|
+
* hover
|
|
14
|
+
* move
|
|
15
|
+
* pick drop
|
|
16
|
+
* mouseclicks
|
|
17
|
+
* keyboard clicks
|
|
18
|
+
* mouse curser changes ( this can be implemented inside above methods)
|
|
19
|
+
*/
|
|
20
|
+
|
|
1
21
|
import {
|
|
2
22
|
CSGlobe,
|
|
3
23
|
CSIconTypes,
|
|
4
24
|
CSObjectTypes,
|
|
5
25
|
CSObjectArrayUpdateTypes,
|
|
6
26
|
} from "@pirireis/webglobe";
|
|
27
|
+
import AlarmTimeLineFadeInFadeOut from "../../plugins/alarms/alarmFadeInFadeOutPlugin/AlarmTimeLineFadeInFadeOutPlugin";
|
|
7
28
|
|
|
8
29
|
/**
|
|
9
30
|
* @typedef {Object} IconPayload
|
|
@@ -30,6 +51,118 @@ import {
|
|
|
30
51
|
* @property {PointPayload[]} attribs
|
|
31
52
|
*/
|
|
32
53
|
|
|
54
|
+
function addIconMap(globe, mapName = "IconMapName", ICON_MAP_URL, ICON_MAP_JSON_URL) {
|
|
55
|
+
globe.api_AddIconMap('IconMapName', ICON_MAP_URL, ICON_MAP_JSON_URL);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
class ObjectArray {
|
|
59
|
+
constructor(symbolSet, style) {
|
|
60
|
+
this.symbolSet = symbolSet;
|
|
61
|
+
this.style = style;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setSymbolSet(symbolSet) {
|
|
65
|
+
this.symbolSet = symbolSet;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class PinPointObjectArray {
|
|
73
|
+
constructor(id,
|
|
74
|
+
globe,
|
|
75
|
+
symbolSet, // iconMapName
|
|
76
|
+
style,
|
|
77
|
+
callBacks = {
|
|
78
|
+
mouseDown: (pinItem, event) => { },
|
|
79
|
+
mouseMove: (pinItem, event) => { },
|
|
80
|
+
mouseUp: (pinItem, event) => { },
|
|
81
|
+
mouseClick: (pinItem, event) => { },
|
|
82
|
+
mouseDblClick: (pinItem, event) => { },
|
|
83
|
+
|
|
84
|
+
} = {}) {
|
|
85
|
+
this.id = id
|
|
86
|
+
this.globe = globe;
|
|
87
|
+
this.symbolSet = symbolSet;
|
|
88
|
+
this.style = style;
|
|
89
|
+
this.iconMapName = iconMapName;
|
|
90
|
+
this.callBacks = callBacks;
|
|
91
|
+
|
|
92
|
+
// this item will be used
|
|
93
|
+
|
|
94
|
+
this.currentItem = null
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
insertPins(pins) {
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
deletePins(pinsIDs) {
|
|
103
|
+
const deleteBucket = {
|
|
104
|
+
coords: [],
|
|
105
|
+
coordsZ: [],
|
|
106
|
+
attribs: []
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
_queryByScreenFindFirst() {
|
|
112
|
+
const { clientX, clientY } = this.globe.api_GetMousePos();
|
|
113
|
+
const allObjects = this.globe.queryByScreen(clientX, clientY);
|
|
114
|
+
for (let i = 0; i < allObjects.length; i++) {
|
|
115
|
+
const { obj, owner } = allObjects[i];
|
|
116
|
+
if (owner === this.objectArray) {
|
|
117
|
+
return obj;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// mouseDown(x, y, event) {
|
|
123
|
+
// return false
|
|
124
|
+
// }
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
// // mouse'a basılıp hareket ettirildiğinde, mouseDown'dan true dönmüşse çağrılır
|
|
128
|
+
// mouseMove(x, y, event) {
|
|
129
|
+
|
|
130
|
+
// }
|
|
131
|
+
|
|
132
|
+
// // mouse bırakıldığında çağrılır
|
|
133
|
+
// mouseUp(x, y, event) {
|
|
134
|
+
|
|
135
|
+
// }
|
|
136
|
+
|
|
137
|
+
// // harita üzerinde tıklandığında çağrılır
|
|
138
|
+
// mouseClick() {
|
|
139
|
+
// return false
|
|
140
|
+
// }
|
|
141
|
+
|
|
142
|
+
// // harita üzerinde çift tıklandığında çağrılır
|
|
143
|
+
// mouseDblClick() {
|
|
144
|
+
// return false
|
|
145
|
+
// }
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
free() {
|
|
149
|
+
this.globe.api_ClearMouseEvents() // TODO
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
_setMouseEvent() {
|
|
153
|
+
const { globe } = this;
|
|
154
|
+
globe.api_SetMouseEvents()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
_getIdForGlobe() {
|
|
158
|
+
const { globe, objectArray } = this;
|
|
159
|
+
const callback = () => {
|
|
160
|
+
const allObjects = globe.api_queryByScreen()
|
|
161
|
+
}
|
|
162
|
+
return `${this.id}_pinObjectArrayMouseEvent`;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
33
166
|
class ObjectArrayLabels {
|
|
34
167
|
/**
|
|
35
168
|
* @param {number | string} id
|
|
@@ -244,4 +377,5 @@ class ObjectArrayLabels {
|
|
|
244
377
|
}
|
|
245
378
|
}
|
|
246
379
|
|
|
247
|
-
export default ObjectArrayLabels;
|
|
380
|
+
export default ObjectArrayLabels;
|
|
381
|
+
|