@pirireis/webglobeplugins 0.6.26-a → 0.6.28-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 +2 -7
- package/circle-line-chain/plugin.js +2 -4
- package/package.json +1 -1
- package/programs/line-on-globe/circle-accurate-flat.js +19 -2
- package/programs/line-on-globe/lines-color-instanced-flat.js +1 -1
- package/rangerings/index.js +1 -1
- package/{rangerings-2 → rangerings}/plugin.js +27 -24
- package/rangerings/rangeringangletext.js +31 -45
- package/{rangerings-2 → rangerings}/ring-account.js +7 -7
- package/timetracks/program.js +1 -1
- package/write-text/context-text.js +1 -1
- package/write-text/context-text3.js +8 -6
- package/bearing-line/plugin-flat-old.js +0 -500
- package/bearing-line/pluginOLD.js +0 -430
- package/circle-line-chain/plugin_newer_old.js +0 -406
- package/circle-line-chain/plugin_old.js +0 -398
- package/rangerings/rangerings copy.js +0 -219
- package/rangerings/rangerings.js +0 -222
- package/rangerings-2/enum.js +0 -7
- package/rangerings-2/index.js +0 -4
- package/rangerings-2/rangeringangletext.js +0 -486
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
import { LineOnGlobeCache } from '../programs/line-on-globe/naive';
|
|
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
|
-
["centerCoords", {
|
|
88
|
-
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
89
|
-
'adaptor': (item) => new Float32Array([radian * item.long, radian * item.lat]),
|
|
90
|
-
}],
|
|
91
|
-
["targetCoords", {
|
|
92
|
-
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
93
|
-
'adaptor': (item) => new Float32Array([radian * item.targetLong, radian * item.targetLat])
|
|
94
|
-
}],
|
|
95
|
-
["rgba", {
|
|
96
|
-
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
97
|
-
'adaptor': (item) => {
|
|
98
|
-
if (item.lineProperties?.rgba) return new Float32Array(item.lineProperties.rgba);
|
|
99
|
-
return new Float32Array(item.chainProperties.rgba);
|
|
100
|
-
}
|
|
101
|
-
}],
|
|
102
|
-
["bigRadius", {
|
|
103
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
104
|
-
'adaptor': (item) => new Float32Array([item.bigRadius])
|
|
105
|
-
}],
|
|
106
|
-
["dashRatio", {
|
|
107
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
108
|
-
'adaptor': (item) => new Float32Array([item.chainProperties.dashRatio])
|
|
109
|
-
}],
|
|
110
|
-
|
|
111
|
-
["dashOpacity", {
|
|
112
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
113
|
-
'adaptor': (item) => new Float32Array([item.chainProperties.dashOpacity])
|
|
114
|
-
}],
|
|
115
|
-
["circleDashAngle", {
|
|
116
|
-
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
117
|
-
'adaptor': (item) => {
|
|
118
|
-
if (item.circleProperties?.circleDashAngle) return new Float32Array([item.circleProperties.circleDashAngle / 360]);
|
|
119
|
-
return new Float32Array([item.chainProperties.circleDashAngle / 360]);
|
|
120
|
-
}
|
|
121
|
-
}],
|
|
122
|
-
["rgbaCircle", {
|
|
123
|
-
"bufferManager": new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
124
|
-
"adaptor": (item) => {
|
|
125
|
-
if (item.circleProperties?.rgba) return new Float32Array(item.circleProperties.rgba);
|
|
126
|
-
return new Float32Array(item.chainProperties.rgba);
|
|
127
|
-
}
|
|
128
|
-
}]
|
|
129
|
-
]
|
|
130
|
-
);
|
|
131
|
-
// (startPotisionBufferObj, endPositionBufferObj, dashRatioBufferObj, colorBufferObj)
|
|
132
|
-
const obj = function (bufferManagerComp) {
|
|
133
|
-
return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 }
|
|
134
|
-
};
|
|
135
|
-
this.lineVao = this.lineProgram.createVAO(
|
|
136
|
-
...['centerCoords', 'targetCoords', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
137
|
-
this.circleVao = this.circleProgram.createVAO(
|
|
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))));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
// API
|
|
147
|
-
setDrawCircleOn(bool) {
|
|
148
|
-
if (typeof bool !== 'boolean') throw new Error("setDrawCircleOn parameter must be a boolean");
|
|
149
|
-
this._drawCircleOn = bool;
|
|
150
|
-
this.globe.DrawRender();
|
|
151
|
-
}
|
|
152
|
-
// -- update bulk family
|
|
153
|
-
/**
|
|
154
|
-
*
|
|
155
|
-
* @param {Array<chain>} data
|
|
156
|
-
* @typedef chain
|
|
157
|
-
* @property {string} chainKey
|
|
158
|
-
* @property {Array<node>} nodes
|
|
159
|
-
* @typedef {Object} node
|
|
160
|
-
* @property {string} key
|
|
161
|
-
* @property {number} long
|
|
162
|
-
* @property {number} lat
|
|
163
|
-
*/
|
|
164
|
-
updateCoordinatesBulk(data, { textWriterIDs = [] } = {}) {
|
|
165
|
-
// update implicit data structure
|
|
166
|
-
// find keys to update.. (inserted data and the radius of "from")
|
|
167
|
-
// updateBuffers
|
|
168
|
-
// update text
|
|
169
|
-
const chainKeys = [];
|
|
170
|
-
for (const chain of data) {
|
|
171
|
-
chainKeys.push(chain.chainKey);
|
|
172
|
-
chain.nodes.forEach((node) => {
|
|
173
|
-
this._chainListMap.updateCoordsinatesOfNode(node, chain.chainKey);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
this._reconstructChains(chainKeys);
|
|
177
|
-
this._updateTexts(chainKeys, textWriterIDs);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
*
|
|
183
|
-
* @param {*} chainKey
|
|
184
|
-
* @param {Array<{nodeKey, circleProperties:Map[propertyName ,value], lineProperties:Map[propertyName ,value] }} propertyMap
|
|
185
|
-
*/
|
|
186
|
-
updateNodesProperties(chainKey, nodesAndPropertyMap, { textWriterIDs = [] } = {}) {
|
|
187
|
-
this._chainListMap.updateNodesProperties(chainKey, nodesAndPropertyMap)
|
|
188
|
-
this._reconstructChains([chainKey]);
|
|
189
|
-
this._updateTexts([chainKey], textWriterIDs);
|
|
190
|
-
this.globe.DrawRender();
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
*
|
|
195
|
-
* @param {*} chainKey
|
|
196
|
-
* @param {Map<propertyName ,value} propertyMap
|
|
197
|
-
*/
|
|
198
|
-
updateChainProperties(chainKey, propertyMap, { textWriterIDs = [] } = {}) {
|
|
199
|
-
this._chainListMap.updateChainProperties(chainKey, propertyMap);
|
|
200
|
-
this._reconstructChains([chainKey]);
|
|
201
|
-
if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// ---- insertBulk family
|
|
205
|
-
/**
|
|
206
|
-
*
|
|
207
|
-
* @param {Array<chain>} data
|
|
208
|
-
* @typedef chain
|
|
209
|
-
* @property {string} chainKey
|
|
210
|
-
* @property {StyleProperties} chainProperties
|
|
211
|
-
|
|
212
|
-
* } chainProperties
|
|
213
|
-
*
|
|
214
|
-
* @typedef {Object} node
|
|
215
|
-
* @property {string} key
|
|
216
|
-
* @property {number} long
|
|
217
|
-
* @property {number} lat
|
|
218
|
-
* @property {StyleProperties} circleProperties
|
|
219
|
-
*/
|
|
220
|
-
insertBulk(data, { textWriterIDs = [] } = []) {
|
|
221
|
-
// first insert everything to implicit structure,
|
|
222
|
-
// then iterate over data again to update text
|
|
223
|
-
// let _reconstractChainBufferData method interact with data and bufferOrchestrator.
|
|
224
|
-
const chainKeysToConstruct = [];
|
|
225
|
-
|
|
226
|
-
for (const { chainKey, chainProperties, nodes } of data) {
|
|
227
|
-
this._chainListMap.setChain(chainKey, nodes);
|
|
228
|
-
this._chainListMap.setChainProperties(chainKey, chainProperties);
|
|
229
|
-
chainKeysToConstruct.push(chainKey);
|
|
230
|
-
}
|
|
231
|
-
this._reconstructChains(chainKeysToConstruct);
|
|
232
|
-
if (textWriterIDs) this._updateTexts(chainKeysToConstruct, textWriterIDs);
|
|
233
|
-
this.globe.DrawRender();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
*
|
|
238
|
-
* @param {{key, long, lat}} node
|
|
239
|
-
* @param {*} chainKey
|
|
240
|
-
* @param {*} theNodeKeyFront | node key of the next node, null places to the last
|
|
241
|
-
*/
|
|
242
|
-
addNode(node, chainKey, { theNodeKeyFront = null, textWriterIDs = [] } = {}) {
|
|
243
|
-
// TODO: if before object is null update the last two elements of the chain only.
|
|
244
|
-
this._chainListMap.addNode(node, chainKey, theNodeKeyFront);
|
|
245
|
-
if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
|
|
246
|
-
this._reconstructChains([chainKey]);
|
|
247
|
-
this.globe.DrawRender();
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
updateNodeCoordinates(node, chainKey, { textWriterIDs = [] } = {}) {
|
|
254
|
-
this._chainListMap.updateCoordsinatesOfNode(node, chainKey);
|
|
255
|
-
if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
|
|
256
|
-
this._reconstructChains([chainKey]);
|
|
257
|
-
this.globe.DrawRender();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
setOpacity(opacity) {
|
|
263
|
-
if (typeof opacity !== 'number') throw new Error("opacity must be a number");
|
|
264
|
-
if (opacity < 0 || 1 < opacity) throw new Error("opacity must be between 0-1");
|
|
265
|
-
this._textContextWriterInjectionMap.forEach((writer) => writer.setOpacity(opacity));
|
|
266
|
-
this._opacity = opacity;
|
|
267
|
-
this.globe.DrawRender();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
getChain(chainKey) {
|
|
273
|
-
this._chainListMap.getChain(chainKey);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
*
|
|
278
|
-
* @param {*} chainKeys
|
|
279
|
-
*/
|
|
280
|
-
deleteChains(chainKeys) {
|
|
281
|
-
const bufferKeys = [];
|
|
282
|
-
for (const chainKey of chainKeys) {
|
|
283
|
-
bufferKeys.push(...this._chainListMap.deleteChainAndReturnChainKeys(chainKey));
|
|
284
|
-
}
|
|
285
|
-
this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
|
|
286
|
-
this._updateTexts(chainKeys, this._textContextWriterInjectionMap.keys());
|
|
287
|
-
this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
|
|
288
|
-
this.globe.DrawRender();
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
*
|
|
294
|
-
* @param {Array<{chainKey, nodeKeys:[]} keysAndNodes
|
|
295
|
-
*/
|
|
296
|
-
deleteNodes(keysAndNodes, { textWriterIDs = [] } = {}) {
|
|
297
|
-
const bufferKeys = [];
|
|
298
|
-
const chainKeysToReconstuct = [];
|
|
299
|
-
keysAndNodes.forEach(({ chainKey, nodeKeys }) => {
|
|
300
|
-
bufferKeys.push(...this._chainListMap.deleteNodesBelongToAChain(chainKey, nodeKeys));
|
|
301
|
-
chainKeysToReconstuct.push(chainKey);
|
|
302
|
-
});
|
|
303
|
-
this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
|
|
304
|
-
this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
|
|
305
|
-
this._reconstructChains(chainKeysToReconstuct);
|
|
306
|
-
this._updateTexts(chainKeysToReconstuct, textWriterIDs);
|
|
307
|
-
this.globe.DrawRender();
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
updateText(textWriterIDs) {
|
|
313
|
-
const chainKeyIterator = this._chainListMap.getAllChainKeysIterator();
|
|
314
|
-
this._updateTexts(chainKeyIterator, textWriterIDs);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
// implicit
|
|
319
|
-
|
|
320
|
-
_updateTexts(chainKeys, textWriterIDs) {
|
|
321
|
-
if (textWriterIDs.length === 0) return;
|
|
322
|
-
const textWriters = textWriterGetOrThrow(this._textContextWriterInjectionMap, textWriterIDs)
|
|
323
|
-
chainKeys.forEach((chainKey) => {
|
|
324
|
-
this._chainListMap.textUpdate(chainKey, textWriters, this._textDataPreAdaptor);
|
|
325
|
-
})
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
_reconstructChains(chainKeys) {
|
|
330
|
-
const { globe } = this;
|
|
331
|
-
// this.lineVao = this.lineProgram.createVAO(
|
|
332
|
-
// ...['centerCoords', 'targetCoords', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
333
|
-
// this.circleVao = this.circleProgram.createVAO(
|
|
334
|
-
// ...["centerCoords", "bigRadius", "rgba", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
335
|
-
// }
|
|
336
|
-
|
|
337
|
-
const radiusM = radiusMethod(globe);
|
|
338
|
-
const callback = (v, i, array, chainProperties) => {
|
|
339
|
-
if (i == array.length - 1) return null;
|
|
340
|
-
return {
|
|
341
|
-
chainProperties: chainProperties,
|
|
342
|
-
bigRadius: radiusM(v, i, array),
|
|
343
|
-
targetLong: array[i + 1].long,
|
|
344
|
-
targetLat: array[i + 1].lat,
|
|
345
|
-
long: v.long,
|
|
346
|
-
lat: v.lat,
|
|
347
|
-
lineProperties: v.lineProperties,
|
|
348
|
-
circleProperties: v.circleProperties,
|
|
349
|
-
key: v.__identity__
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
const bulkData = [];
|
|
353
|
-
chainKeys.forEach((k) => {
|
|
354
|
-
this._chainListMap.calculateBufferPropertiesChain(k, callback, bulkData);
|
|
355
|
-
})
|
|
356
|
-
|
|
357
|
-
this._insertBulk(bulkData);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
_insertBulk(bulkData) {
|
|
362
|
-
this.bufferOrchestrator.insertBulk(bulkData, this.bufferManagersCompMap);
|
|
363
|
-
this.globe.DrawRender();
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
// GLOBE API
|
|
368
|
-
//TODO:
|
|
369
|
-
free() {
|
|
370
|
-
if (this.isFreed) return;
|
|
371
|
-
this.bufferManagersCompMap.forEach(({ bufferManager }) => {
|
|
372
|
-
bufferManager.free();
|
|
373
|
-
})
|
|
374
|
-
LineOnGlobeCache.release(this.globe);
|
|
375
|
-
CircleCache.release(this.globe);
|
|
376
|
-
this.lineProgram = null;
|
|
377
|
-
this.circleProgram = null;
|
|
378
|
-
this.isFreed = true;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
draw3D() {
|
|
382
|
-
const { gl, globe } = this;
|
|
383
|
-
gl.disable(gl.DEPTH_TEST);
|
|
384
|
-
this.lineProgram.draw(this.lineVao, this.bufferOrchestrator.length, this._opacity);
|
|
385
|
-
if (this._drawCircleOn) this.circleProgram.draw(this.circleVao, this.bufferOrchestrator.length, this._opacity);
|
|
386
|
-
this._textContextWriterInjectionMap.forEach((writer) => writer.draw());
|
|
387
|
-
gl.enable(gl.DEPTH_TEST);
|
|
388
|
-
this.lineToTheOriginProgram.draw(this.toOriginVao, this.bufferOrchestrator.length, this._opacity);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const radiusMethod = (globe) => (v, i, array) => {
|
|
395
|
-
return globe.Math.GetDist3D(v.long, v.lat, array[i + 1].long, array[i + 1].lat)
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
const textWriterGetOrThrow = mapGetOrThrow("textWriterIds is invalid")
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { rings } from "../programs";
|
|
2
|
-
import { COMPASS_MODES } from "./enum";
|
|
3
|
-
import { PaddingFreeAngleCache } from "../programs/rings/distancering";
|
|
4
|
-
|
|
5
|
-
import RangeRingAngleText from "./rangeringangletext";
|
|
6
|
-
const { circleProgramCache, PaddingProgramCache, CirclePaddySharedBuffer } = rings;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @typedef RangeRingData
|
|
10
|
-
* @property {number} centerX
|
|
11
|
-
* @property {number} centerY
|
|
12
|
-
* @property {Array<Ring>} rings
|
|
13
|
-
*
|
|
14
|
-
* @typedef Ring
|
|
15
|
-
* @property {number} radius
|
|
16
|
-
* @property {number} padding
|
|
17
|
-
* @property {[number, number, number]} color
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export default class {
|
|
24
|
-
|
|
25
|
-
constructor(id, { oneDegreePadding = true, compass = COMPASS_MODES.REAL, showNumbers = true, numbersStyle = null, opacity = 1 } = {}) {
|
|
26
|
-
this.id = id;
|
|
27
|
-
this.compass = compass;
|
|
28
|
-
this._showNumbers = showNumbers;
|
|
29
|
-
this._numbersStyle = numbersStyle;
|
|
30
|
-
this._opacity = opacity;
|
|
31
|
-
this.circleEdgeCount = 360;
|
|
32
|
-
this._onedegreepaddingOn = oneDegreePadding;
|
|
33
|
-
this.bufferManager = null;
|
|
34
|
-
|
|
35
|
-
this._deleteCounter = 0;
|
|
36
|
-
this._deleteThreshold = 10;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
setOneDegreePaddingOn(oneDegreePadding) {
|
|
41
|
-
this._onedegreepaddingOn = oneDegreePadding;
|
|
42
|
-
this.globe.DrawRender();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
init(globe, gl) {
|
|
46
|
-
this.gl = gl;
|
|
47
|
-
this.globe = globe;
|
|
48
|
-
this.circleFlatProgram = circleProgramCache.getProgram(globe);
|
|
49
|
-
this.paddyFlatProgram = PaddingProgramCache.getProgram(globe);
|
|
50
|
-
this.paddingFreeAngleProgram = PaddingFreeAngleCache.getProgram(globe);
|
|
51
|
-
if (this._showNumbers) {
|
|
52
|
-
this.textPlugin = new RangeRingAngleText(globe, this.id + "text", { flatCompassMode: this.compass, style: this._numbersStyle, opacity: this._opacity });
|
|
53
|
-
delete this._numbersStyle;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// TODO: Add text free
|
|
58
|
-
free() {
|
|
59
|
-
|
|
60
|
-
this.circleProgramCache?.releaseProgram(this.globe);
|
|
61
|
-
this.PaddingProgramCache?.releaseProgram(this.globe);
|
|
62
|
-
this.PaddingFreeAngleCache?.releaseProgram(this.globe);
|
|
63
|
-
this.gl.deleteVertexArray(this.bufferManager?.vao);
|
|
64
|
-
this.gl.deleteVertexArray(this.paddingBufferManager?.vao);
|
|
65
|
-
this.paddingBufferManager?.free();
|
|
66
|
-
this.bufferManager?.free();
|
|
67
|
-
this.textPlugin?.free();
|
|
68
|
-
this.circleFlatProgram = null;
|
|
69
|
-
this.paddyFlatProgram = null;
|
|
70
|
-
this.bufferManager = null;
|
|
71
|
-
this.paddingBufferManager = null;
|
|
72
|
-
this.textPlugin = null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
setOpacity(opacity) {
|
|
77
|
-
this._opacity = opacity;
|
|
78
|
-
this.textPlugin?.setOpacity(opacity); // TODO impolement this
|
|
79
|
-
this.globe.DrawRender();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
setGeometry() {
|
|
83
|
-
this.textPlugin?.setGeometry();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
draw3D() {
|
|
88
|
-
const { circleFlatProgram, paddyFlatProgram, paddingFreeAngleProgram, bufferManager, compass, gl, circleEdgeCount, paddingBufferManager, _opacity } = this;
|
|
89
|
-
if (this.bufferManager !== null && bufferManager.length > 0) {
|
|
90
|
-
gl.disable(gl.DEPTH_TEST);
|
|
91
|
-
circleFlatProgram.draw(bufferManager, compass, circleEdgeCount, _opacity);
|
|
92
|
-
if (this._onedegreepaddingOn) paddyFlatProgram.draw(bufferManager, 360, compass, _opacity);
|
|
93
|
-
paddingFreeAngleProgram.draw(paddingBufferManager, compass, _opacity);
|
|
94
|
-
gl.enable(gl.DEPTH_TEST);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @param {RangeRingData} rangeRingData
|
|
102
|
-
* 0 compass limps
|
|
103
|
-
* other real distance limp
|
|
104
|
-
*/
|
|
105
|
-
setCampass(compass) {
|
|
106
|
-
this.compass = compass;
|
|
107
|
-
this.textPlugin?.setCompass(compass);
|
|
108
|
-
this.globe.DrawRender();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
initilizeBufferManager(initialRingCapacity, bufferDrawType) {
|
|
112
|
-
const { gl, globe } = this
|
|
113
|
-
this.bufferDrawType = bufferDrawType;
|
|
114
|
-
this.bufferManager = new CirclePaddySharedBuffer(gl, globe, { bufferType: bufferDrawType, initialRingCapacity: initialRingCapacity });
|
|
115
|
-
this.paddingBufferManager = this.paddingFreeAngleProgram.createBuffer({ bufferType: bufferDrawType, initialRingCapacity });
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @typedef {Array<{ringID, radius, paddingRange}>} rings
|
|
121
|
-
* @param {Array<centerID:string, x:number, y:number, stepAngle:number, rgba:[4 numbers], rings:rings} items
|
|
122
|
-
*/
|
|
123
|
-
insertBulk(items) {
|
|
124
|
-
const insertData = ringItemsToCircleBufferInsertDataAdaptor(items);
|
|
125
|
-
|
|
126
|
-
this.bufferManager.insertBulk(insertData);
|
|
127
|
-
for (const item of items) {
|
|
128
|
-
item.paddingAngles = angleToPaddingAngles(item.stepAngle, 0);
|
|
129
|
-
}
|
|
130
|
-
this.paddingBufferManager.insertBulk(items);
|
|
131
|
-
this.textPlugin?.insertBulk(items);
|
|
132
|
-
this.globe.DrawRender();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
*
|
|
138
|
-
* @param {Array<{centerID, x, y}>} items
|
|
139
|
-
*/
|
|
140
|
-
updateCentersXY(items) {
|
|
141
|
-
this.bufferManager.updateCentersXY(items);
|
|
142
|
-
this.paddingBufferManager.updateCentersXY(items);
|
|
143
|
-
this.textPlugin?.updateCentersXY(items);
|
|
144
|
-
this.globe.DrawRender();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @param {Array<{centerID, rgba:[4 numbers]}>} centerColors
|
|
150
|
-
*/
|
|
151
|
-
updateCentersColor(centerColors) {
|
|
152
|
-
this.bufferManager.updateCentersColor(centerColors);
|
|
153
|
-
this.paddingBufferManager.updateCentersColor(centerColors);
|
|
154
|
-
this.globe.DrawRender();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @param {Array<{centerID}>} centerIds
|
|
160
|
-
*/
|
|
161
|
-
removeCenters(centerIds) {
|
|
162
|
-
this.bufferManager.removeCenters(centerIds);
|
|
163
|
-
this.paddingBufferManager.removeCenters(centerIds);
|
|
164
|
-
this.textPlugin?.removeCenters(centerIds);
|
|
165
|
-
this._deleteCounter += centerIds.length;
|
|
166
|
-
if (this._deleteCounter > this._deleteThreshold) {
|
|
167
|
-
// this is naive since we are not checking the actual deletion
|
|
168
|
-
// but it works
|
|
169
|
-
this._deleteCounter = 0;
|
|
170
|
-
this.bufferManager.defrag();
|
|
171
|
-
this.paddingBufferManager.defrag();
|
|
172
|
-
}
|
|
173
|
-
this.globe.DrawRender();
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
*
|
|
179
|
-
* @param {Array<{centerID, hide, textHide}>} centerHides
|
|
180
|
-
*/
|
|
181
|
-
updateCentersHide(centerHides) {
|
|
182
|
-
this.bufferManager.updateCentersHide(centerHides);
|
|
183
|
-
this.paddingBufferManager.updateCentersHide(centerHides);
|
|
184
|
-
this.textPlugin?.updateCentersHide(centerHides);
|
|
185
|
-
this.globe.DrawRender();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const ringItemsToCircleBufferInsertDataAdaptor = (ringItems) => {
|
|
193
|
-
|
|
194
|
-
const result = [];
|
|
195
|
-
for (const { centerID, x, y, rgba, rings, hide = 0, textHide = 0 } of ringItems) {
|
|
196
|
-
const resultRings = [];
|
|
197
|
-
for (const { ringID, radius, padding } of rings) {
|
|
198
|
-
resultRings.push({
|
|
199
|
-
ringID,
|
|
200
|
-
radius,
|
|
201
|
-
padding: padding / 5,
|
|
202
|
-
rgba,
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
result.push({
|
|
207
|
-
centerID,
|
|
208
|
-
x,
|
|
209
|
-
y,
|
|
210
|
-
rings: resultRings,
|
|
211
|
-
hide,
|
|
212
|
-
textHide
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
return result;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const angleToPaddingAngles = (gapDegree, offsetDegree = 0) => Array.from({ length: Math.ceil(360 / gapDegree) }, (_, i) => (i * gapDegree + offsetDegree) * Math.PI / 180);
|
|
219
|
-
|