@pirireis/webglobeplugins 0.3.3 → 0.3.5
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
CHANGED
|
@@ -9,6 +9,13 @@ export const RINGPARTIAL_DRAW_MODE = Object.freeze({
|
|
|
9
9
|
TRIANGLE_FAN: "TRIANGLE_FAN",
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
const constraintFloat = (x, lowerBound, upperBound) => {
|
|
13
|
+
if (typeof x !== "number") throw new Error("type must be numberic")
|
|
14
|
+
if (lowerBound > x || x > upperBound) throw new Error(`input must be between ${lowerBound} - ${upperBound}`)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
21
|
* @typedef {Object}textContextInjection
|
|
@@ -71,6 +78,7 @@ export default class Plugin {
|
|
|
71
78
|
|
|
72
79
|
|
|
73
80
|
setOpacity(opacity) {
|
|
81
|
+
constraintFloat(opacity, 0, 1);
|
|
74
82
|
this._opacity = opacity;
|
|
75
83
|
this._textContextInjectionMap.forEach(({ writer }) => writer.setOpacity(opacity));
|
|
76
84
|
this.globe.DrawRender();
|
|
@@ -138,9 +146,10 @@ export default class Plugin {
|
|
|
138
146
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
139
147
|
'adaptor': (item) => new Float32Array([item.dashOpacity])
|
|
140
148
|
}],
|
|
141
|
-
["
|
|
149
|
+
["circleDashAngle", {
|
|
150
|
+
|
|
142
151
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
143
|
-
'adaptor': (item) => new Float32Array([item.
|
|
152
|
+
'adaptor': (item) => new Float32Array([item.circleDashAngle / 360])
|
|
144
153
|
}]
|
|
145
154
|
]
|
|
146
155
|
);
|
|
@@ -166,7 +175,7 @@ export default class Plugin {
|
|
|
166
175
|
}
|
|
167
176
|
// centerObj, startAngleObj, radiusObj, colorObj, dashRatioObj, dashOpacityObj
|
|
168
177
|
this.circleVao = this.circleProgram.createVAO(
|
|
169
|
-
...["centerCoords", "startAngle", "bigRadius", "rgba", "
|
|
178
|
+
...["centerCoords", "startAngle", "bigRadius", "rgba", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
170
179
|
}
|
|
171
180
|
|
|
172
181
|
|
|
@@ -207,11 +216,9 @@ export default class Plugin {
|
|
|
207
216
|
* @property {number} dashRatio 0-1
|
|
208
217
|
* @property {number} dashOpacity 0-1
|
|
209
218
|
* @property {number} circleDashAngle 0-360
|
|
210
|
-
*
|
|
211
219
|
* @param {Array<item>} items
|
|
212
220
|
* @param {Array<string>} injectionsSubSetIDs | textContextInjectionMap keys to be used for writing text.
|
|
213
221
|
*/
|
|
214
|
-
|
|
215
222
|
insertBulk(items, injectionsSubSetIDs = []) {
|
|
216
223
|
const { globe, bufferOrchestrator, bufferManagersCompMap } = this;// angleTextContext, distanceTextContext,
|
|
217
224
|
const injectionsSubSet = injectionsSubSetIDs.map((id) => this._textContextInjectionMap.get(id));
|
|
@@ -229,7 +236,6 @@ export default class Plugin {
|
|
|
229
236
|
|
|
230
237
|
deleteBulk(keys) {
|
|
231
238
|
this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersCompMap, ["radius", "centerCoords", "targetCoords", "rgba"]);
|
|
232
|
-
|
|
233
239
|
this._deleteTexts(keys);
|
|
234
240
|
this.globe.DrawRender();
|
|
235
241
|
}
|
|
@@ -237,16 +243,15 @@ export default class Plugin {
|
|
|
237
243
|
|
|
238
244
|
defrag() {
|
|
239
245
|
this.bufferOrchestrator.defrag(this.bufferManagersCompMap);
|
|
240
|
-
// this.globe.DrawRender();
|
|
241
246
|
}
|
|
242
247
|
|
|
243
248
|
/**
|
|
244
249
|
*
|
|
245
250
|
* @param {Array<{key, long, lat, endLong, endLat, bearingAngle}>} items
|
|
246
|
-
* @param {Array<string>}
|
|
251
|
+
* @param {Array<string>} textWriterInjectionSubSetIDs | textContextInjectionMap keys to be used for writing text.
|
|
247
252
|
*/
|
|
248
|
-
updateCoordinatesBulk(items,
|
|
249
|
-
const injectionsSubSet =
|
|
253
|
+
updateCoordinatesBulk(items, textWriterInjectionSubSetIDs = []) { //TODO
|
|
254
|
+
const injectionsSubSet = textWriterInjectionSubSetIDs.map((id) => this._textContextInjectionMap.get(id));
|
|
250
255
|
const { globe, bufferOrchestrator, bufferManagersCompMap, angleTextContext, distanceTextContext } = this;
|
|
251
256
|
const data = []
|
|
252
257
|
for (let item of items) {
|
|
@@ -259,6 +264,22 @@ export default class Plugin {
|
|
|
259
264
|
}
|
|
260
265
|
|
|
261
266
|
|
|
267
|
+
/**
|
|
268
|
+
*
|
|
269
|
+
* @param {*} items some colums EXCEPT positional ones
|
|
270
|
+
* @param {*} propertyIDs
|
|
271
|
+
* @param {*} textWriterInjectionSubSetIDs
|
|
272
|
+
* 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.
|
|
273
|
+
*/
|
|
274
|
+
updatePartial(items, propertyIDs = [], textWriterInjectionSubSetIDs = []) {
|
|
275
|
+
if (propertyIDs.length === 0) console.warn("updatePartial is called with no target propertyIDs");
|
|
276
|
+
const { _textContextInjectionMap, bufferOrchestrator, bufferManagersCompMap } = this;
|
|
277
|
+
const writers = textWriterInjectionSubSetIDs.map((x) => _textContextInjectionMap.get(x));
|
|
278
|
+
for (let item of items) { this._insertTexts(item, writers) }
|
|
279
|
+
bufferOrchestrator.updateBulk(items, bufferManagersCompMap, propertyIDs);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
|
|
262
283
|
__insertAdaptor(item) {
|
|
263
284
|
const lat = radian(item.lat)
|
|
264
285
|
const long = radian(item.long)
|
|
@@ -268,7 +289,7 @@ export default class Plugin {
|
|
|
268
289
|
const rgbaMode = item.rgbaMode !== undefined ? item.rgbaMode : 0;
|
|
269
290
|
const dashRatio = item.dashRatio !== undefined ? item.dashRatio : 1.0;
|
|
270
291
|
const dashOpacity = item.dashOpacity !== undefined ? item.dashOpacity : 0.9;
|
|
271
|
-
const
|
|
292
|
+
const circleDashAngle = item.circleDashAngle !== undefined ? item.circleDashAngle : 360;
|
|
272
293
|
const bigRadius = item.bigRadius !== undefined ? item.bigRadius : this.globe.Math.GetDist3D(item.long, item.lat, item.endLong, item.endLat);
|
|
273
294
|
const radius = item.radius !== undefined ? item.radius : bigRadius * 0.2;
|
|
274
295
|
const startAngle = calculateStartAngle(long, lat, endLong, endLat);
|
|
@@ -291,7 +312,7 @@ export default class Plugin {
|
|
|
291
312
|
rgba,
|
|
292
313
|
dashRatio,
|
|
293
314
|
dashOpacity,
|
|
294
|
-
|
|
315
|
+
circleDashAngle,
|
|
295
316
|
rgbaMode
|
|
296
317
|
};
|
|
297
318
|
}
|
|
@@ -301,7 +322,6 @@ export default class Plugin {
|
|
|
301
322
|
const long = radian(item.long)
|
|
302
323
|
const endLat = radian(item.endLat)
|
|
303
324
|
const endLong = radian(item.endLong)
|
|
304
|
-
|
|
305
325
|
const bigRadius = item.bigRadius !== undefined ? item.bigRadius : this.globe.Math.GetDist3D(item.long, item.lat, item.endLong, item.endLat);
|
|
306
326
|
const radius = item.radius !== undefined ? item.radius : bigRadius * 0.2;
|
|
307
327
|
const startAngle = calculateStartAngle(long, lat, endLong, endLat);
|
|
@@ -340,8 +360,9 @@ export default class Plugin {
|
|
|
340
360
|
|
|
341
361
|
|
|
342
362
|
|
|
343
|
-
_insertTexts(item,
|
|
344
|
-
|
|
363
|
+
_insertTexts(item, textWriterInjectionSubSet) {
|
|
364
|
+
//TODO This method can be more performant if it works horizontally, tabular
|
|
365
|
+
textWriterInjectionSubSet.forEach((v) => {
|
|
345
366
|
const { coordsAdaptor, textAdaptor, writer } = v
|
|
346
367
|
const { lat, long } = coordsAdaptor(item);
|
|
347
368
|
const text = textAdaptor(item);
|
package/package.json
CHANGED
|
@@ -66,6 +66,7 @@ void main() {
|
|
|
66
66
|
if (v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE) { discard; }
|
|
67
67
|
color = v_color;
|
|
68
68
|
color.a *= opacity;
|
|
69
|
+
if ( v_dash_ratio >= 1.0 ) { return; }
|
|
69
70
|
if (interpolation > 0.95) { return; }
|
|
70
71
|
if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5) { color.a /= 4.0; }
|
|
71
72
|
|