@pirireis/webglobeplugins 0.6.2-b → 0.6.3

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.
@@ -27,7 +27,12 @@ const constraintFloat = (x, lowerBound, upperBound) => {
27
27
  */
28
28
 
29
29
  export default class Plugin {
30
-
30
+ /**
31
+ *
32
+ * @param {*} id
33
+ * @param {Map<[K ,ContextTextWriter]} textContextInjectionMap import { ContextTextWriter } from '@pirireis/webglobeplugins/write-text/context-text';
34
+ *
35
+ */
31
36
 
32
37
  constructor(id, { opacity = 1, textContextInjectionMap = new Map(), drawVRM = true, drawBearingLine = true, drawAngleRing = true, drawText = true } = {}) {
33
38
  this.id = id;
@@ -9,6 +9,7 @@ export class ChainListMap {
9
9
  this._chainSideProperties = new Map();
10
10
  this._indexMap = new Map(); // hold list index of lastly updated nodes. on add delete goes empty
11
11
  this.keyMethod = keyMethod;
12
+
12
13
  }
13
14
 
14
15
  getChain(chainKey) {
@@ -171,12 +172,13 @@ export class ChainListMap {
171
172
  * @param {*} textWriterObjs
172
173
  * @param {*} nodeKeys use nodeKeys on updateCoordinatesOnly
173
174
  */
174
- textUpdate(chainKey, textWriterObjs) {
175
+ textUpdate(chainKey, textWriterObjs, dataPreAdaptor) {
175
176
  const chain = this._chainMap.get(chainKey);
177
+ const data = (dataPreAdaptor) ? chain.map(dataPreAdaptor) : chain;
176
178
  if (!chain) return;
177
179
  const properties = this._chainSideProperties.get(chainKey);
178
180
  textWriterObjs.forEach((writer) => {
179
- writer.insertTextBulk(chain, properties);
181
+ writer.insertTextBulk(data, properties);
180
182
  });
181
183
 
182
184
  }
@@ -34,15 +34,24 @@ import { keyMethod } from "./util";
34
34
  const radian = Math.PI / 180;
35
35
 
36
36
  export class CircleLineChainPlugin {
37
-
38
- constructor(id, { drawCircleOn = true, textContextWriterInjectionMap = new Map() } = {}) {
37
+ /**
38
+ *
39
+ * @param {*} id
40
+ * @param {Map<[key, ContextTextWriter3]} textContextWriterInjectionMap //import { ContextTextWriter3 } from "@pirireis/webglobeplugins/write-text/context-text3";
41
+ */
42
+ constructor(id, {
43
+ drawCircleOn = true,
44
+ textContextWriterInjectionMap = new Map(),
45
+ textDataPreAdaptor = null
46
+ } = {}) {
39
47
  this.id = id;
40
48
  this._textContextWriterInjectionMap = textContextWriterInjectionMap;
41
49
  this._textContextWriterInjectionMap.forEach((writer) => writer.setKeyAdaptor((v, i, c, properties) => v.__identity__));
42
50
  this._opacity = 1;
43
51
  this._chainListMap = new ChainListMap(keyMethod);
44
52
  this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
45
- this._drawCircleOn = drawCircleOn
53
+ this._drawCircleOn = drawCircleOn;
54
+ this._textDataPreAdaptor = textDataPreAdaptor;
46
55
  }
47
56
 
48
57
  // init
@@ -262,8 +271,8 @@ export class CircleLineChainPlugin {
262
271
  for (const chainKey of chainKeys) {
263
272
  bufferKeys.push(...this._chainListMap.deleteChainAndReturnChainKeys(chainKey));
264
273
  }
265
- this._updateTexts(chainKeys, this._textContextWriterInjectionMap.keys());
266
274
  this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
275
+ this._updateTexts(chainKeys, this._textContextWriterInjectionMap.keys());
267
276
  this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
268
277
  this.globe.DrawRender();
269
278
  }
@@ -301,7 +310,7 @@ export class CircleLineChainPlugin {
301
310
  _updateTexts(chainKeys, textWriterIDs) {
302
311
  const textWriters = textWriterIDs.map((v) => this._textContextWriterInjectionMap.get(v));
303
312
  chainKeys.forEach((chainKey) => {
304
- this._chainListMap.textUpdate(chainKey, textWriters);
313
+ this._chainListMap.textUpdate(chainKey, textWriters, this._textDataPreAdaptor);
305
314
  })
306
315
  }
307
316
 
@@ -14,7 +14,7 @@ export class PixelPaddingCompassPlugin {
14
14
  defaultProperties = {
15
15
  rgba: [1, 1, 1, 1],
16
16
  pixelRadiusBig: 250,
17
- pixelRadiusSmall: 220
17
+ pixelRadiusSmall: 200
18
18
  },
19
19
  font = {
20
20
  name: 'Arial',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.6.2-b",
3
+ "version": "0.6.3",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -18,10 +18,14 @@ vec3 coord_opacity(){
18
18
  float radius;
19
19
  float angle;
20
20
  if( gl_VertexID % 2 == 0){
21
- if ( gl_VertexID % 60 == 0){
22
- radius = pixel_radius_small;
21
+ if( gl_VertexID % 180 == 0){
22
+ radius = pixel_radius_small ;
23
+ }
24
+ else if ( gl_VertexID % 60 == 0){
25
+ float gap = (pixel_radius_big - pixel_radius_small) / 5.0;
26
+ radius = pixel_radius_small + gap;
23
27
  } else if( gl_VertexID % 10 == 0) {
24
- float gap = (pixel_radius_big - pixel_radius_small) / 4.0;
28
+ float gap = (pixel_radius_big - pixel_radius_small) / 2.0;
25
29
  radius = pixel_radius_small + gap;
26
30
  } else {
27
31
  float gap = (pixel_radius_big - pixel_radius_small) * 0.75;
@@ -29,7 +33,7 @@ vec3 coord_opacity(){
29
33
  }
30
34
  angle = (float(gl_VertexID) / (${vertexCount}.0));
31
35
  } else {
32
- if ( gl_VertexID % 60 == 1){
36
+ if ( gl_VertexID % 180 == 1){
33
37
  radius = pixel_radius_big + 10.0;
34
38
 
35
39
  } else {
@@ -1,10 +1,6 @@
1
1
 
2
2
  import {
3
- CSGlobe,
4
- CSObjectTypes,
5
- CSIconTypes,
6
3
  CSObjectArrayUpdateTypes,
7
- GlobeManager
8
4
  } from "@pirireis/webglobe";
9
5
  import { ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES } from "./enum";
10
6
 
@@ -64,16 +60,7 @@ export default class RangeRingAngleText {
64
60
  label.hAlignment = 2;
65
61
  label.size = 17;
66
62
  label.text = "`${aci}`"
67
- // this.style.filter = [
68
- // {
69
- // rule: ["any", ["===", "aci", "K"]],
70
- // name: "startLODRule",
71
- // style: {
72
- // ...
73
- // }
74
-
75
- // }
76
- // ];
63
+
77
64
  return style;
78
65
  }
79
66
 
@@ -259,9 +246,10 @@ export default class RangeRingAngleText {
259
246
  for (const [centerID, centerMap] of this._centerCollection) {
260
247
  const hide = centerMap.get("hide");
261
248
  const hideText = centerMap.get("textHide");
262
- const isHidden = hide === ENUM_HIDE.HIDE || hideText === ENUM_TEXT_HIDE.HIDE;
249
+ centerMap.set("textHide", ENUM_TEXT_HIDE.HIDE);
250
+ if (hide === ENUM_HIDE.HIDE) continue;
251
+ const isHidden = hideText === ENUM_TEXT_HIDE.HIDE;
263
252
  if (!isHidden) this._fillDeleteBucket(centerID, deleteBucket);
264
- centerMap.set("textHide", ENUM_HIDE.HIDE);
265
253
  }
266
254
  this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
267
255
  }
@@ -275,8 +263,9 @@ export default class RangeRingAngleText {
275
263
  }
276
264
  for (const [centerID, centerMap] of this._centerCollection) {
277
265
  const hide = centerMap.get("hide");
266
+ if (hide === ENUM_HIDE.HIDE) continue;
278
267
  const hideText = centerMap.get("textHide");
279
- const isHidden = hide === ENUM_HIDE.HIDE || hideText === ENUM_TEXT_HIDE.HIDE;
268
+ const isHidden = hideText === ENUM_TEXT_HIDE.HIDE;
280
269
  if (isHidden) {
281
270
  const x = centerMap.get("x");
282
271
  const y = centerMap.get("y");
@@ -292,29 +281,6 @@ export default class RangeRingAngleText {
292
281
 
293
282
 
294
283
 
295
- showAllVisibleCircleText() {
296
- this._hideAll = false;
297
- const addBucket = {
298
- coords: [],
299
- coordsZ: [],
300
- attribs: []
301
- }
302
- for (const [centerID, centerMap] of this._centerCollection) {
303
- const hide = centerMap.get("hide");
304
- const hideText = centerMap.get("textHide");
305
- if (hide === ENUM_HIDE.HIDE) continue
306
- const isHidden = hideText === ENUM_TEXT_HIDE.HIDE;
307
- if (isHidden) {
308
- const x = centerMap.get("x");
309
- const y = centerMap.get("y");
310
- const maxRadius = centerMap.get("maxRadius");
311
- const stepAngle = centerMap.get("stepAngle");
312
- this._appendCircle(x, y, maxRadius, stepAngle, centerID, addBucket);
313
- centerMap.set("textHide", ENUM_TEXT_HIDE.SHOW);
314
- }
315
- }
316
- if (addBucket.coords.length) this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD);
317
- }
318
284
 
319
285
  flush() {
320
286
  const data = {
@@ -153,7 +153,7 @@ export class ContextTextWriter2 {
153
153
  };
154
154
  const opacity = this.opacityAdaptor(item, id, container, properties);
155
155
  const angle = this.angleAdaptor(item, id, container, properties);
156
- this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle });
156
+ this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle, data: item });
157
157
  }
158
158
 
159
159
  clear() {
@@ -6,7 +6,7 @@ import { CSZMode } from "@pirireis/webglobe";
6
6
  * 2) expose a mechanic to update text on zoom change
7
7
  * 3) extend the mechanic on 2 to other events
8
8
  */
9
- export class ContextTextWriter2 {
9
+ export class ContextTextWriter3 {
10
10
  constructor(globe, {
11
11
  style = {
12
12
  textFont: {
@@ -28,8 +28,12 @@ export class ContextTextWriter2 {
28
28
  opacityAdaptor = null,
29
29
  angleAdaptor = null,
30
30
  angleOnSphere = false,
31
- zoomLevelOpacityAdaptor = (zoomLevel, item) => 1,
32
- zoomLevelSizeAdaptor = (zoomLevel, item) => 1,
31
+ zoomLevelAdaptor = (zoomLevel) => (item) => {
32
+ return {
33
+ opacityMultiplier: 1,
34
+ sizeMultiplier: 1
35
+ }
36
+ }
33
37
  } = {}) {
34
38
  this.globe = globe;
35
39
  this.itemMap = new Map();
@@ -41,8 +45,7 @@ export class ContextTextWriter2 {
41
45
  this.coordinatesAdaptor = coordinatesAdaptor;
42
46
  this.keyAdaptor = keyAdaptor;
43
47
 
44
- this.zoomLevelOpacityAdaptor = zoomLevelOpacityAdaptor;
45
- this.zoomLevelSizeAdaptor = zoomLevelSizeAdaptor;
48
+ this.zoomLevelAdaptor = zoomLevelAdaptor;
46
49
 
47
50
  this.opacityAdaptor = opacityAdaptor ? opacityAdaptor : () => 1;
48
51
  this.angleOnSphere = angleOnSphere;
@@ -80,9 +83,10 @@ export class ContextTextWriter2 {
80
83
  const textSize = textFont.size;
81
84
  const is3D = globe.api_GetCurrentGeometry() === 0;
82
85
  const angleIsOn = is3D ? (this.angleAdaptorIsOn && this.angleOnSphere) : (this.angleAdaptorIsOn)
83
- const zoomLevel = globe.api_GetCurrentLODWithDecimal()
86
+ const zoomLevel = globe.api_GetCurrentLODWithDecimal();
87
+ const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
84
88
  for (const [key, item] of itemMap) {
85
- const { lat, long, text, opacity = null, angle = null } = item;
89
+ const { lat, long, text, opacity = null, angle = null, data } = item;
86
90
  const { x, y } = globe.api_GetScreenPointFromGeo(
87
91
  {
88
92
  long: long,
@@ -91,8 +95,9 @@ export class ContextTextWriter2 {
91
95
  },
92
96
  style.zMode === CSZMode.Z_MSL,
93
97
  );
94
- const o = (opacity === null ? opacity_ : opacity * opacity_) * this.zoomLevelOpacityAdaptor(zoomLevel, item);
95
- textFont.size = this.zoomLevelSizeAdaptor(zoomLevel) * textSize;
98
+ const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(data);
99
+ const o = (opacity === null ? opacity_ : opacity * opacity_) * opacityMultiplier;
100
+ textFont.size = sizeMultiplier * textSize;
96
101
 
97
102
  if (x !== null && y !== null) globe.api_DrawContextTextMultiLine(text, textFont, o, { x, y }, angleIsOn, angle);
98
103
  }
@@ -158,7 +163,7 @@ export class ContextTextWriter2 {
158
163
  };
159
164
  const opacity = this.opacityAdaptor(item, id, container, properties);
160
165
  const angle = this.angleAdaptor(item, id, container, properties);
161
- this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle });
166
+ this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle, data: item });
162
167
  }
163
168
 
164
169
  clear() {