@pirireis/webglobeplugins 0.6.42-a → 0.6.44-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 +20 -6
- package/circle-line-chain/plugin.js +11 -4
- package/package.json +1 -1
- package/rangerings/plugin.js +19 -17
- package/rangerings/ring-account.js +10 -4
package/bearing-line/plugin.js
CHANGED
|
@@ -28,7 +28,7 @@ export default class BearingLinePlugin {
|
|
|
28
28
|
{
|
|
29
29
|
opacity = 1,
|
|
30
30
|
textWritersMap = new Map(),
|
|
31
|
-
textDataPreAdaptor =
|
|
31
|
+
textDataPreAdaptor = (x) => x,
|
|
32
32
|
drawVRM = true,
|
|
33
33
|
drawBearingLine = true,
|
|
34
34
|
drawAngleRing = true,
|
|
@@ -118,11 +118,25 @@ export default class BearingLinePlugin {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
/**
|
|
122
|
+
* @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
|
|
123
|
+
* @param {Array<string>} itemKeys | if empty, all texts will be updated.
|
|
124
|
+
*/
|
|
125
|
+
updateText(textWriterIDs = [], itemKeys = null) {
|
|
122
126
|
const textWritersMap = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
if (itemKeys === null) {
|
|
128
|
+
this._memoryForText.forEach((item) => {
|
|
129
|
+
let _item = this._textDataPreAdaptor(item);
|
|
130
|
+
textWritersMap.forEach((writer) => writer.insertText(_item));
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
itemKeys.forEach((key) => {
|
|
134
|
+
let item = this._memoryForText.get(key);
|
|
135
|
+
if (item === undefined) return;
|
|
136
|
+
let _item = this._textDataPreAdaptor(item);
|
|
137
|
+
textWritersMap.forEach((writer) => writer.insertText(_item));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
126
140
|
this.globe.DrawRender();
|
|
127
141
|
}
|
|
128
142
|
|
|
@@ -193,8 +207,8 @@ export default class BearingLinePlugin {
|
|
|
193
207
|
for (const item of items) {
|
|
194
208
|
const oldItem = this._memoryForText.get(item.key);
|
|
195
209
|
let _item = oldItem !== undefined ? { ...oldItem, ...item } : item;
|
|
196
|
-
if (this._textDataPreAdaptor !== null) _item = this._textDataPreAdaptor(_item);
|
|
197
210
|
this._memoryForText.set(item.key, _item);
|
|
211
|
+
if (this._textDataPreAdaptor !== null) _item = this._textDataPreAdaptor(_item);
|
|
198
212
|
textWritersMap.forEach((writer) => writer.insertText(_item));
|
|
199
213
|
}
|
|
200
214
|
}
|
|
@@ -126,9 +126,16 @@ export class CircleLineChainPlugin {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
|
|
134
|
+
* @param {Array<string>} chainKeys | if empty, all texts will be updated
|
|
135
|
+
*/
|
|
136
|
+
updateText(textWriterIDs = [], chainKeys = null) {
|
|
137
|
+
if (chainKeys === null) chainKeys = this._chainListMap.getAllChainKeysIterator();
|
|
138
|
+
this._updateTexts(chainKeys, textWriterIDs);
|
|
132
139
|
this.globe.DrawRender();
|
|
133
140
|
}
|
|
134
141
|
|
|
@@ -354,7 +361,7 @@ export class CircleLineChainPlugin {
|
|
|
354
361
|
const textWriters = textWriterGetOrThrow(this._textWritersMap, textWriterIDs)
|
|
355
362
|
chainKeys.forEach((chainKey) => {
|
|
356
363
|
this._chainListMap.textUpdate(chainKey, textWriters, this._textDataPreAdaptor);
|
|
357
|
-
})
|
|
364
|
+
});
|
|
358
365
|
}
|
|
359
366
|
|
|
360
367
|
|
package/package.json
CHANGED
package/rangerings/plugin.js
CHANGED
|
@@ -51,7 +51,7 @@ import { LinesColorInstancedFlatCache } from "../programs/line-on-globe/lines-co
|
|
|
51
51
|
import { BufferOrchestrator, BufferManager } from "../util/account";
|
|
52
52
|
import { mapGetOrThrow } from "../util/check/get";
|
|
53
53
|
import { populateFloat32Array } from "../util/jshelpers/data-filler";
|
|
54
|
-
import { RingAccount, ringBigPaddingKeyMethod } from "./ring-account";
|
|
54
|
+
import { RingAccount, ringBigPaddingKeyMethod, ringKeyMethod } from "./ring-account";
|
|
55
55
|
import { CirclePadding3DCache } from "../programs/line-on-globe/degree-padding-around-circle-3d";
|
|
56
56
|
import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate';
|
|
57
57
|
import RangeRingAngleText from "./rangeringangletext";
|
|
@@ -217,16 +217,26 @@ class RangeRings {
|
|
|
217
217
|
* 2. delete from buffer orchestators
|
|
218
218
|
* 3. mark centers as hidden
|
|
219
219
|
*/
|
|
220
|
-
|
|
221
220
|
}
|
|
222
221
|
|
|
223
222
|
|
|
224
223
|
/**
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
|
|
224
|
+
* @param {Array<string>} textWriterIDs textWritersMap keys to be used for writing text.
|
|
225
|
+
* @param {Array<string>} itemKeys if empty, all texts will be updated. Use {@link ringKeyMethod} method to get keys
|
|
226
|
+
*/
|
|
227
|
+
updateText(textWriterIDs = [], itemKeys = null) {
|
|
228
228
|
const textWritersMap = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
|
|
229
|
-
|
|
229
|
+
if (itemKeys === null) {
|
|
230
|
+
this._ringAccount.updateAllText(textWritersMap, this._textDataPreAdaptor);
|
|
231
|
+
this.globe.DrawRender();
|
|
232
|
+
} else {
|
|
233
|
+
itemKeys.forEach((key) => {
|
|
234
|
+
const item = this._ringAccount.getCenter(key);
|
|
235
|
+
if (item === undefined) throw new Error("Center not found");
|
|
236
|
+
const textData = this._textDataPreAdaptor(item);
|
|
237
|
+
textWritersMap.forEach((textWriter) => textWriter.insertText(textData));
|
|
238
|
+
});
|
|
239
|
+
}
|
|
230
240
|
this.globe.DrawRender();
|
|
231
241
|
}
|
|
232
242
|
|
|
@@ -237,12 +247,6 @@ class RangeRings {
|
|
|
237
247
|
* @method removeCenters @param { Array < { centerID } >} centerIDs
|
|
238
248
|
*/
|
|
239
249
|
removeCenters(centerIDs) {
|
|
240
|
-
// Algorithm
|
|
241
|
-
/**
|
|
242
|
-
* 1. ask centerRingAccount for existing rings
|
|
243
|
-
* 2. delete from buffer orchestators
|
|
244
|
-
* 3. delete from centerRingAccount
|
|
245
|
-
*/
|
|
246
250
|
const { globe,
|
|
247
251
|
bufferOrchestrator, bufferManagersCompMap,
|
|
248
252
|
paddingBufferOrchestrator, bufferManagersCompMapPadding,
|
|
@@ -252,9 +256,9 @@ class RangeRings {
|
|
|
252
256
|
if (existingKeys.length) {
|
|
253
257
|
bufferOrchestrator.deleteBulk(existingKeys, bufferManagersCompMap);
|
|
254
258
|
this._textWritersMap.forEach((textWriter) => textWriter.deleteTextBulk(existingKeys));
|
|
259
|
+
|
|
255
260
|
}
|
|
256
261
|
}
|
|
257
|
-
|
|
258
262
|
for (const centerID of centerIDs) {
|
|
259
263
|
const paddingKeys = _ringAccount.ringBigPaddingKeys(centerID);
|
|
260
264
|
if (paddingKeys.length) {
|
|
@@ -262,9 +266,7 @@ class RangeRings {
|
|
|
262
266
|
}
|
|
263
267
|
}
|
|
264
268
|
this.textPlugin?.removeCenters(centerIDs);
|
|
265
|
-
|
|
266
|
-
// this.__contextTextWriterUpdate(centerIDs, null);
|
|
267
|
-
|
|
269
|
+
this._ringAccount.removeCenters(centerIDs);
|
|
268
270
|
globe.DrawRender();
|
|
269
271
|
}
|
|
270
272
|
|
|
@@ -272,7 +274,7 @@ class RangeRings {
|
|
|
272
274
|
* @method setOpacity @param { number } opacity
|
|
273
275
|
*/
|
|
274
276
|
setOpacity(opacity) {
|
|
275
|
-
if (typeof opacity !== "number" || opacity < 0 || opacity > 1) throw new Error("Invalid opacity
|
|
277
|
+
if (typeof opacity !== "number" || opacity < 0 || opacity > 1) throw new Error("Invalid value for opacity");
|
|
276
278
|
this._opacity = opacity;
|
|
277
279
|
this.textPlugin?.setOpacity(opacity);
|
|
278
280
|
this._textWritersMap.forEach((writer) => writer.setOpacity(opacity));
|
|
@@ -13,7 +13,7 @@ const ringBigPaddingKeyMethod = (centerID, ringID, angle) => `${centerID}_${ring
|
|
|
13
13
|
*/
|
|
14
14
|
class RingAccount {
|
|
15
15
|
constructor() {
|
|
16
|
-
this.
|
|
16
|
+
this._centralMap = new Map(); // key, new MAP(x,y, rings:[])
|
|
17
17
|
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -25,7 +25,7 @@ class RingAccount {
|
|
|
25
25
|
centralItem.rings.forEach((ring) => {
|
|
26
26
|
ring.__identity__ = ringKeyMethod(centralItem.centerID, ring.ringID);
|
|
27
27
|
});
|
|
28
|
-
this.
|
|
28
|
+
this._centralMap.set(centralItem.centerID, {
|
|
29
29
|
...centralItem,
|
|
30
30
|
rgba: new Float32Array(centralItem.rgba),
|
|
31
31
|
|
|
@@ -34,7 +34,7 @@ class RingAccount {
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
getCenter(centerID) {
|
|
37
|
-
return this.
|
|
37
|
+
return this._centralMap.get(centerID);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
updateCentersCoordinate(items) {
|
|
@@ -101,6 +101,12 @@ class RingAccount {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
|
|
104
|
+
removeCenters(centerIDs) {
|
|
105
|
+
const centralMap = this._centralMap;
|
|
106
|
+
centerIDs.forEach((centerID) => {
|
|
107
|
+
centralMap.delete(centerID);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
104
110
|
|
|
105
111
|
textUpdate(centerID, textWriterObjs, dataPreAdaptor = null) {
|
|
106
112
|
const center = this.getCenter(centerID);
|
|
@@ -113,7 +119,7 @@ class RingAccount {
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
updateAllText(textWriterObjs, dataPreAdaptor = null) {
|
|
116
|
-
this.
|
|
122
|
+
this._centralMap.forEach((center) => {
|
|
117
123
|
this.textUpdate(center.centerID, textWriterObjs, dataPreAdaptor);
|
|
118
124
|
});
|
|
119
125
|
}
|