@pirireis/webglobeplugins 0.3.4 → 0.3.6
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
|
@@ -146,9 +146,9 @@ export default class Plugin {
|
|
|
146
146
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
147
147
|
'adaptor': (item) => new Float32Array([item.dashOpacity])
|
|
148
148
|
}],
|
|
149
|
-
["
|
|
149
|
+
["circleDashAngle", {
|
|
150
150
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
151
|
-
'adaptor': (item) => new Float32Array([item.
|
|
151
|
+
'adaptor': (item) => new Float32Array([item.circleDashAngle / 360])
|
|
152
152
|
}]
|
|
153
153
|
]
|
|
154
154
|
);
|
|
@@ -174,7 +174,7 @@ export default class Plugin {
|
|
|
174
174
|
}
|
|
175
175
|
// centerObj, startAngleObj, radiusObj, colorObj, dashRatioObj, dashOpacityObj
|
|
176
176
|
this.circleVao = this.circleProgram.createVAO(
|
|
177
|
-
...["centerCoords", "startAngle", "bigRadius", "rgba", "
|
|
177
|
+
...["centerCoords", "startAngle", "bigRadius", "rgba", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
|
|
@@ -215,11 +215,9 @@ export default class Plugin {
|
|
|
215
215
|
* @property {number} dashRatio 0-1
|
|
216
216
|
* @property {number} dashOpacity 0-1
|
|
217
217
|
* @property {number} circleDashAngle 0-360
|
|
218
|
-
*
|
|
219
218
|
* @param {Array<item>} items
|
|
220
219
|
* @param {Array<string>} injectionsSubSetIDs | textContextInjectionMap keys to be used for writing text.
|
|
221
220
|
*/
|
|
222
|
-
|
|
223
221
|
insertBulk(items, injectionsSubSetIDs = []) {
|
|
224
222
|
const { globe, bufferOrchestrator, bufferManagersCompMap } = this;// angleTextContext, distanceTextContext,
|
|
225
223
|
const injectionsSubSet = injectionsSubSetIDs.map((id) => this._textContextInjectionMap.get(id));
|
|
@@ -237,7 +235,6 @@ export default class Plugin {
|
|
|
237
235
|
|
|
238
236
|
deleteBulk(keys) {
|
|
239
237
|
this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersCompMap, ["radius", "centerCoords", "targetCoords", "rgba"]);
|
|
240
|
-
|
|
241
238
|
this._deleteTexts(keys);
|
|
242
239
|
this.globe.DrawRender();
|
|
243
240
|
}
|
|
@@ -245,16 +242,15 @@ export default class Plugin {
|
|
|
245
242
|
|
|
246
243
|
defrag() {
|
|
247
244
|
this.bufferOrchestrator.defrag(this.bufferManagersCompMap);
|
|
248
|
-
// this.globe.DrawRender();
|
|
249
245
|
}
|
|
250
246
|
|
|
251
247
|
/**
|
|
252
248
|
*
|
|
253
249
|
* @param {Array<{key, long, lat, endLong, endLat, bearingAngle}>} items
|
|
254
|
-
* @param {Array<string>}
|
|
250
|
+
* @param {Array<string>} textWriterInjectionSubSetIDs | textContextInjectionMap keys to be used for writing text.
|
|
255
251
|
*/
|
|
256
|
-
updateCoordinatesBulk(items,
|
|
257
|
-
const injectionsSubSet =
|
|
252
|
+
updateCoordinatesBulk(items, textWriterInjectionSubSetIDs = []) { //TODO
|
|
253
|
+
const injectionsSubSet = textWriterInjectionSubSetIDs.map((id) => this._textContextInjectionMap.get(id));
|
|
258
254
|
const { globe, bufferOrchestrator, bufferManagersCompMap, angleTextContext, distanceTextContext } = this;
|
|
259
255
|
const data = []
|
|
260
256
|
for (let item of items) {
|
|
@@ -267,6 +263,22 @@ export default class Plugin {
|
|
|
267
263
|
}
|
|
268
264
|
|
|
269
265
|
|
|
266
|
+
/**
|
|
267
|
+
*
|
|
268
|
+
* @param {*} items some colums EXCEPT positional ones
|
|
269
|
+
* @param {*} propertyIDs
|
|
270
|
+
* @param {*} textWriterInjectionSubSetIDs
|
|
271
|
+
* 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.
|
|
272
|
+
*/
|
|
273
|
+
updatePartial(items, propertyIDs = [], textWriterInjectionSubSetIDs = []) {
|
|
274
|
+
if (propertyIDs.length === 0) console.warn("updatePartial is called with no target propertyIDs");
|
|
275
|
+
const { _textContextInjectionMap, bufferOrchestrator, bufferManagersCompMap } = this;
|
|
276
|
+
const writers = textWriterInjectionSubSetIDs.map((x) => _textContextInjectionMap.get(x));
|
|
277
|
+
for (let item of items) { this._insertTexts(item, writers) }
|
|
278
|
+
bufferOrchestrator.updateBulk(items, bufferManagersCompMap, propertyIDs);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
270
282
|
__insertAdaptor(item) {
|
|
271
283
|
const lat = radian(item.lat)
|
|
272
284
|
const long = radian(item.long)
|
|
@@ -276,7 +288,7 @@ export default class Plugin {
|
|
|
276
288
|
const rgbaMode = item.rgbaMode !== undefined ? item.rgbaMode : 0;
|
|
277
289
|
const dashRatio = item.dashRatio !== undefined ? item.dashRatio : 1.0;
|
|
278
290
|
const dashOpacity = item.dashOpacity !== undefined ? item.dashOpacity : 0.9;
|
|
279
|
-
const
|
|
291
|
+
const circleDashAngle = item.circleDashAngle !== undefined ? item.circleDashAngle : 360;
|
|
280
292
|
const bigRadius = item.bigRadius !== undefined ? item.bigRadius : this.globe.Math.GetDist3D(item.long, item.lat, item.endLong, item.endLat);
|
|
281
293
|
const radius = item.radius !== undefined ? item.radius : bigRadius * 0.2;
|
|
282
294
|
const startAngle = calculateStartAngle(long, lat, endLong, endLat);
|
|
@@ -299,7 +311,7 @@ export default class Plugin {
|
|
|
299
311
|
rgba,
|
|
300
312
|
dashRatio,
|
|
301
313
|
dashOpacity,
|
|
302
|
-
|
|
314
|
+
circleDashAngle,
|
|
303
315
|
rgbaMode
|
|
304
316
|
};
|
|
305
317
|
}
|
|
@@ -309,7 +321,6 @@ export default class Plugin {
|
|
|
309
321
|
const long = radian(item.long)
|
|
310
322
|
const endLat = radian(item.endLat)
|
|
311
323
|
const endLong = radian(item.endLong)
|
|
312
|
-
|
|
313
324
|
const bigRadius = item.bigRadius !== undefined ? item.bigRadius : this.globe.Math.GetDist3D(item.long, item.lat, item.endLong, item.endLat);
|
|
314
325
|
const radius = item.radius !== undefined ? item.radius : bigRadius * 0.2;
|
|
315
326
|
const startAngle = calculateStartAngle(long, lat, endLong, endLat);
|
|
@@ -348,8 +359,9 @@ export default class Plugin {
|
|
|
348
359
|
|
|
349
360
|
|
|
350
361
|
|
|
351
|
-
_insertTexts(item,
|
|
352
|
-
|
|
362
|
+
_insertTexts(item, textWriterInjectionSubSet) {
|
|
363
|
+
//TODO This method can be more performant if it works horizontally, tabular
|
|
364
|
+
textWriterInjectionSubSet.forEach((v) => {
|
|
353
365
|
const { coordsAdaptor, textAdaptor, writer } = v
|
|
354
366
|
const { lat, long } = coordsAdaptor(item);
|
|
355
367
|
const text = textAdaptor(item);
|
package/package.json
CHANGED
|
@@ -102,22 +102,22 @@ vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float
|
|
|
102
102
|
tangent1 = normalize(tangent1);
|
|
103
103
|
// rotate tangent with given angle
|
|
104
104
|
tangent1 = cos(angle) * tangent1 - sin(angle) * cross(normal, tangent1);
|
|
105
|
-
|
|
105
|
+
float radius_in_angle = radius/R;
|
|
106
|
+
float projected_radius = sin(radius_in_angle) * R / 1000.0;
|
|
107
|
+
return (geoW * cos(radius_in_angle))+ tangent1 * projected_radius;
|
|
106
108
|
}
|
|
107
109
|
`;
|
|
108
110
|
|
|
109
111
|
// TODO: Make it precise. Y axis is not correct.
|
|
110
112
|
|
|
111
|
-
|
|
112
|
-
export const circleLimpFromLongLatRadCenterMercatorRealDistance = `
|
|
113
|
+
export const circleLimpFromLongLatRadCenterMercatorRealDistance = PI + `
|
|
113
114
|
vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle){
|
|
114
|
-
float
|
|
115
|
-
float
|
|
116
|
-
float
|
|
117
|
-
float
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return vec2(x, y);
|
|
115
|
+
float ang = angle + PI / 2.0; // this is there because rest of the program is in angle 0 is +x axis orientatation
|
|
116
|
+
float r = radius / R;
|
|
117
|
+
float sin_lat = sin( center.y) * cos(r) + cos(center.y)*sin(r)* cos(ang);
|
|
118
|
+
float lat = asin(sin_lat);
|
|
119
|
+
float longi = center.x + atan( sin(ang) * sin(r) * cos(center.y), cos(r) - sin(center.y) * sin_lat);
|
|
120
|
+
return longLatRadToMercator(vec2(longi, lat));
|
|
121
121
|
}
|
|
122
122
|
`;
|
|
123
123
|
|
|
@@ -206,7 +206,7 @@ export const angleBetweenTwoPointsRadian = `
|
|
|
206
206
|
float angleBetweenTwoPointsRadian(vec2 start_, vec2 end_) {
|
|
207
207
|
float start_lat = log( tan( ( 1.0 - start_.y ) * PI / 2.0 ) );
|
|
208
208
|
float end_lat = log( tan( ( 1.0 - end_.y ) * PI / 2.0 ) );
|
|
209
|
-
float angle = atan( (end_lat - start_lat )/ (end_.x - start_.x));
|
|
209
|
+
float angle = atan( (end_lat - start_lat ) / (end_.x - start_.x));
|
|
210
210
|
return angle;
|
|
211
211
|
}
|
|
212
212
|
`
|