@pirireis/webglobeplugins 0.1.5 → 0.1.7

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.
@@ -0,0 +1,29 @@
1
+ // TODO: Implement compass rose in 2D
2
+ // TODO: enrich cameraBlockTotem with globe tile and more...
3
+
4
+ const vertexShader = `#version 300 es
5
+
6
+
7
+ in vec2 center;
8
+ in float pixel_radius;
9
+ in vec4 color;
10
+ out vec4 v_color;
11
+ void main() {
12
+ const float PI = 3.14159265359;
13
+ float angle = float(gl_VertexID) / 180.0 * PI;
14
+ vec2 limp = vec2(
15
+
16
+ )
17
+ vec2 position =
18
+ v_color = color;
19
+ }
20
+ `;
21
+
22
+ const fragmentShader = `#version 300 es
23
+ precision mediump float;
24
+ in vec4 v_color;
25
+ out vec4 outColor;
26
+ void main() {
27
+ outColor = v_color;
28
+ }
29
+ `;
@@ -132,8 +132,8 @@ const object = {
132
132
  "x": 16,
133
133
  "y": -16
134
134
  },
135
- "vAlignment": 0,
136
- "hAlignment": 0,
135
+ "vAlignment": 2,
136
+ "hAlignment": 2,
137
137
  "size": 20,
138
138
  "hollowColor": "#000",
139
139
  "textColor": "#FFF",
@@ -219,7 +219,8 @@ export default class CompassRose {
219
219
 
220
220
  this.primaryKey = primaryKey;
221
221
 
222
- this.object = Object.assign({}, object);
222
+ this.object = structuredClone(object);
223
+ this.object.id = id;
223
224
 
224
225
  setIconSize(this.object, size);
225
226
  if (imageURL) {
@@ -320,6 +321,10 @@ export default class CompassRose {
320
321
  }
321
322
  }
322
323
 
324
+ removeFromMap() {
325
+ this.globe.ObjectArray.Delete(this.id);
326
+ }
327
+
323
328
 
324
329
  // private
325
330
  _setData(data) {
@@ -337,6 +342,7 @@ export default class CompassRose {
337
342
  globe.ObjectArray.UpdateData(object, operation, [data], canChange);
338
343
  }
339
344
 
345
+
340
346
  }
341
347
 
342
348
  const getID = (data, primaryKey) => data.attribs[primaryKey];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
package/programs/index.js CHANGED
@@ -5,7 +5,7 @@ import ArrowField from "./arrowfield";
5
5
  import { glProgramCache, globeProgramCache, noRegisterGlobeProgramCache } from "./programcache";
6
6
  import * as vectorfield from "./vectorfields";
7
7
  import { FadeAway } from "./helpers";
8
- import rings from "./rings";
8
+ import * as rings from "./rings";
9
9
  export {
10
10
  Float2LegendWithRatio,
11
11
  GlobeShellWiggle,
File without changes
@@ -0,0 +1,115 @@
1
+ import { CameraUniformBlockString, CameraUniformBlockTotem } from "../totems";
2
+ import { longLatRadToMercator, longLatRadToCartesian3D, cartesian3DToGLPosition, mercatorXYTo2DPoint } from "../shaderfunctions/geometrytransformations";
3
+ import { createProgram } from "../webgl/program";
4
+ import { noRegisterGlobeProgramCache, globeProgramCache } from "../programcache";
5
+ import { BufferOffsetManger } from "../../util/account";
6
+
7
+ const GLOBE_MIDPOINT_COUNT = 100;
8
+ const ITEM_SIZE = 8;
9
+
10
+ const vertexShader = `#version 300 es
11
+ precision highp float;
12
+ ${CameraUniformBlockString}
13
+ ${longLatRadToMercator}
14
+ ${longLatRadToCartesian3D}
15
+ ${cartesian3DToGLPosition}
16
+ ${mercatorXYTo2DPoint}
17
+
18
+ in vec2 start_position;
19
+ in vec2 end_position;
20
+ in vec4 color;
21
+ out vec4 v_color;
22
+
23
+ void main() {
24
+
25
+ vec2 longLat;
26
+ if (is3D) {
27
+ float interpolation = float(gl_VertexID) / ${GLOBE_MIDPOINT_COUNT}.0;
28
+ longLat = mix(start_position, end_position, interpolation)
29
+ vec3 cartesian = longLatRadToMercator(longLat);
30
+ gl_Position = cartesian3DToGLPosition(cartesian);
31
+ } else {
32
+ if ( gl_VertexID == 0 ) {
33
+ longLat = start_position;
34
+ } else {
35
+ longLat = end_position;
36
+ }
37
+ vec2 mercator = longLatRadToMercator(longLat);
38
+ gl_Position = mercatorXYTo2DPoint(mercator);
39
+ }
40
+ v_color = color;
41
+ }
42
+ `
43
+
44
+ const fragmentShader = `#version 300 es
45
+ precision highp float;
46
+ in vec4 v_color;
47
+ out vec4 color;
48
+ void main() {
49
+ color = v_color;
50
+ }
51
+ `
52
+
53
+
54
+ class Logic {
55
+
56
+ constructor(globe) {
57
+ this.globe = globe;
58
+ this.gl = gl;
59
+ this.program = createProgram(gl, vertexShader, fragmentShader);
60
+ const { gl, program } = this;
61
+ {
62
+ // assign attribute locations
63
+ gl.bindAttribLocation(program, 0, "start_position");
64
+ gl.bindAttribLocation(program, 1, "end_position");
65
+ gl.bindAttribLocation(program, 2, "color");
66
+
67
+ }
68
+
69
+
70
+ this.cameraBlockBindingPoint = 0;
71
+ const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
72
+ this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
73
+
74
+ }
75
+
76
+
77
+ draw(bufferManager) {
78
+
79
+ }
80
+
81
+
82
+
83
+ }
84
+
85
+
86
+ class BufferManager extends BufferOffsetManger {
87
+
88
+ constructor(gl, { capacity = 10, bufferType = "DYNAMIC_DRAW" } = {}) {
89
+ super(ITEM_SIZE, { capacity, bufferType });
90
+ this.gl = gl;
91
+ this.buffer = gl.createBuffer();
92
+
93
+ const { gl, buffer } = this;
94
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
95
+ gl.bufferData(gl.ARRAY_BUFFER, _capacity * ITEM_SIZE * 4, gl[bufferType]);
96
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
97
+
98
+ this.vao = gl.createVertexArray();
99
+ {
100
+
101
+ }
102
+ }
103
+
104
+ insertBulk(items) {
105
+
106
+ }
107
+ }
108
+
109
+
110
+
111
+ export const programCache = Object.freeze({
112
+ get: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
113
+ release: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
114
+ });
115
+
@@ -2,7 +2,7 @@ import { createProgram, shaderfunctions } from "../../../util";
2
2
  import CameraUniformBlockTotem, { CameraUniformBlockString } from "../../totems/camerauniformblock";
3
3
  import { noRegisterGlobeProgramCache, globeProgramCache } from "../../programcache";
4
4
 
5
- const CIRCLE_EDGE_COUNT = 72;
5
+ const CIRCLE_EDGE_COUNT = 360;
6
6
 
7
7
  const vertexShader = `#version 300 es ` +
8
8
  shaderfunctions.PI +
@@ -19,6 +19,8 @@ const vertexShader = `#version 300 es ` +
19
19
  uniform int compass;
20
20
  uniform float circle_edge_count;
21
21
 
22
+ uniform float opacity;
23
+
22
24
  in vec2 center;
23
25
  in float radius;
24
26
  in vec4 color;
@@ -28,7 +30,7 @@ out vec2 v_limp;
28
30
 
29
31
  void main() {
30
32
  if( flag == 1.0 || radius == 0.0) return; // flag 1.0 is hide
31
- v_color = color;
33
+ v_color = vec4(color.rgb, color.a * opacity);
32
34
  if ( gl_VertexID == 270 ) v_color.rgb += 0.2;
33
35
  float angle = 3.1415926535897932384626433832795 * 2.0 * (float(gl_VertexID) / circle_edge_count);
34
36
  if ( is3D ){
@@ -76,36 +78,49 @@ class Logic {
76
78
  const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
77
79
  this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
78
80
 
81
+ this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
79
82
  this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
80
83
  this._circleEdgeCountLocation = this.gl.getUniformLocation(this.program, "circle_edge_count");
81
- this._circle_edge_count = CIRCLE_EDGE_COUNT;
84
+ this._circleEdgeCount = CIRCLE_EDGE_COUNT;
82
85
  this._compassmode = 1;
86
+ this._opacity = 1.0;
83
87
  {
84
88
  const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
85
89
  this.gl.useProgram(this.program);
86
90
  this.gl.uniform1i(this._compassLocation, 1);
87
91
  this.gl.uniform1f(this._circleEdgeCountLocation, CIRCLE_EDGE_COUNT);
92
+ this.gl.uniform1f(this._opacityLocation, 1.0);
93
+
88
94
  this.gl.useProgram(currentProgram);
89
95
  }
90
96
 
91
97
  }
92
98
 
93
99
 
94
- draw(attrBufferManager, compass, circle_edge_count) {
100
+ draw(attrBufferManager, compass, circleEdgeCount, opacity) {
95
101
  const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
96
102
  gl.useProgram(program);
97
103
  cameraBlockTotem.bind(cameraBlockBindingPoint);
98
104
  attrBufferManager.bindCircleVAO();
99
105
 
100
- if (compass !== this._compassLocation) {
106
+ if (compass !== this._compassmode) {
101
107
  gl.uniform1i(this._compassLocation, compass);
108
+ console.log("compass", compass);
102
109
  this._compassmode = compass;
103
110
  }
104
- if (circle_edge_count !== this._circleEdgeCountLocation) {
105
- gl.uniform1f(this._circleEdgeCountLocation, circle_edge_count);
106
- this._circle_edge_count = circle_edge_count;
111
+
112
+ if (opacity !== this._opacity) {
113
+ gl.uniform1f(this._opacityLocation, opacity);
114
+ console.log("opacity", opacity);
115
+ this._opacity = opacity;
116
+ }
117
+
118
+ if (circleEdgeCount !== this._circleEdgeCount) {
119
+ gl.uniform1f(this._circleEdgeCountLocation, circleEdgeCount);
120
+ console.log("circleEdgeCount", circleEdgeCount);
121
+ this._circleEdgeCount = circleEdgeCount;
107
122
  }
108
- gl.drawArraysInstanced(gl.LINE_LOOP, 0, circle_edge_count, attrBufferManager.length);
123
+ gl.drawArraysInstanced(gl.LINE_LOOP, 0, circleEdgeCount, attrBufferManager.length);
109
124
  gl.bindVertexArray(null);
110
125
  cameraBlockTotem.unbind(cameraBlockBindingPoint);
111
126
  }
@@ -118,18 +133,7 @@ class Logic {
118
133
  }
119
134
 
120
135
 
121
- export default class {
122
- constructor(globe, gl) {
123
- this.gl = gl;
124
- this.globe = globe;
125
- this.logic = noRegisterGlobeProgramCache.getProgram(globe, Logic);
126
- }
127
-
128
- draw(attrBufferManager, compass, circle_edge_count) {
129
- this.logic.draw(attrBufferManager, compass, circle_edge_count);
130
- }
131
-
132
- free() {
133
- noRegisterGlobeProgramCache.releaseProgram(this.gl, Logic);
134
- }
135
- }
136
+ export const programCache = Object.freeze({
137
+ getProgram: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
138
+ releaseProgram: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
139
+ });
@@ -25,13 +25,16 @@ in float pad_angle;
25
25
 
26
26
  uniform int compass;
27
27
 
28
+ uniform float opacity;
29
+
28
30
  out vec2 v_limp;
29
31
  out vec4 v_color;
30
32
 
31
33
 
32
34
  void main() {
33
35
  if( flag == 1.0 || radius == 0.0 ) return; // 1.0 is hide
34
- v_color = color;
36
+ v_color = vec4(color.rgb, color.a * opacity);
37
+
35
38
  if ( pad_angle == 0.0 ) v_color.rgb -= 0.2;
36
39
  gl_PointSize = 2.0;
37
40
 
@@ -80,12 +83,13 @@ class Logic {
80
83
 
81
84
  {
82
85
  const gl = this.gl;
83
- this.center = gl.getAttribLocation(this.program, "center");
84
- this.radius = gl.getAttribLocation(this.program, "radius");
85
- this.pad_range = gl.getAttribLocation(this.program, "pad_range");
86
- this.color = gl.getAttribLocation(this.program, "color");
87
- this.flag = gl.getAttribLocation(this.program, "flag");
88
- this.pad_angle = gl.getAttribLocation(this.program, "pad_angle");
86
+ // assign attribute locations
87
+ gl.bindAttribLocation(this.program, 0, "center");
88
+ gl.bindAttribLocation(this.program, 1, "radius");
89
+ gl.bindAttribLocation(this.program, 2, "pad_range");
90
+ gl.bindAttribLocation(this.program, 3, "color");
91
+ gl.bindAttribLocation(this.program, 4, "flag");
92
+ gl.bindAttribLocation(this.program, 5, "pad_angle");
89
93
 
90
94
  }
91
95
 
@@ -94,19 +98,20 @@ class Logic {
94
98
  this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
95
99
  this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
96
100
  this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
97
-
98
-
101
+ this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
102
+ this._opacity = 1.0;
99
103
  {
100
104
  const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
101
105
  this.gl.useProgram(this.program);
102
106
  this.gl.uniform1i(this._compassLocation, 1);
107
+ this.gl.uniform1f(this._opacityLocation, 1.0);
103
108
  this._lastCompass = 1;
104
109
  this.gl.useProgram(currentProgram);
105
110
  }
106
111
  }
107
112
 
108
113
 
109
- draw(attrBufferManager, compass) {
114
+ draw(attrBufferManager, compass, opacity) {
110
115
 
111
116
  const { gl, program, cameraBlockBindingPoint, cameraBlockTotem, _compassLocation } = this;
112
117
 
@@ -117,6 +122,10 @@ class Logic {
117
122
  gl.uniform1i(_compassLocation, compass);
118
123
  this._lastCompass = compass;
119
124
  }
125
+ if (opacity !== this._opacity) {
126
+ gl.uniform1f(this._opacityLocation, opacity);
127
+ this._opacity = opacity;
128
+ }
120
129
  gl.disable(gl.DEPTH_TEST);
121
130
  gl.drawArraysInstanced(gl.LINES, 0, 2, attrBufferManager.length);
122
131
  gl.enable(gl.DEPTH_TEST);
@@ -124,7 +133,7 @@ class Logic {
124
133
  gl.bindVertexArray(null);
125
134
 
126
135
  }
127
- initilizeBufferManager({ bufferType = "DYNAMIC_DRAW", initialRingCapacity = 10 } = {}) {
136
+ createBuffer({ bufferType = "DYNAMIC_DRAW", initialRingCapacity = 10 } = {}) {
128
137
  return new BufferManager(this.gl, bufferType, initialRingCapacity);
129
138
 
130
139
  }
@@ -214,7 +223,7 @@ export class BufferManager extends BufferOffsetManager {
214
223
  console.log("space left:", spaceLeft, "required space:", requiredSpace);
215
224
  if (requiredSpace > spaceLeft) {
216
225
  console.log("new capacity:", this.capacity + requiredSpace - spaceLeft)
217
- this.extendBuffer(gl, buffer, this.bufferType, this.capacity + requiredSpace - spaceLeft);
226
+ this.extendBuffer(this.capacity + requiredSpace - spaceLeft);
218
227
  }
219
228
 
220
229
  const items = [];
@@ -1,5 +1,5 @@
1
- import CircleFlatProgram from './circleflatprogram';
1
+ import { programCache as circleProgramCache } from './circleflatprogram';
2
2
  import PaddyFlatProgram from './paddyflatprogram';
3
3
  import CirclePaddySharedBuffer from './circlepaddysharedbuffer';
4
4
  import { PaddingFreeAngleCache } from './circlepaddingfreeangleprogram';
5
- export { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer, PaddingFreeAngleCache };
5
+ export { circleProgramCache, PaddyFlatProgram, CirclePaddySharedBuffer, PaddingFreeAngleCache };
@@ -24,6 +24,9 @@ in float flag;
24
24
  uniform int compass;
25
25
  uniform float pad_count;
26
26
 
27
+ uniform float opacity;
28
+
29
+
27
30
  out vec2 v_limp;
28
31
  out vec4 v_color;
29
32
 
@@ -32,7 +35,7 @@ void main() {
32
35
 
33
36
  float alpha_padding = z_level * z_level / (pad_range/ 100.0 );
34
37
  if( flag == 2.0 || flag == 1.0 || radius == 0.0 || alpha_padding < 0.1 || z_level < 3.0 ) return; // 1.0 is hide
35
- v_color = vec4(color.rgb, alpha_padding);
38
+ v_color = vec4(color.rgb, color.a * alpha_padding * opacity);
36
39
 
37
40
  gl_PointSize = 2.0;
38
41
 
@@ -86,27 +89,40 @@ class Logic {
86
89
  this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
87
90
  this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
88
91
  this._padCountLocation = this.gl.getUniformLocation(this.program, "pad_count");
89
-
92
+ this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
90
93
  this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
91
-
94
+ this._compassMode = 1;
95
+ this._opacity = 1.0;
96
+ this._padCount = 360;
92
97
  {
93
98
  const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
94
99
  this.gl.useProgram(this.program);
95
100
  this.gl.uniform1i(this._compassLocation, 1);
96
101
  this.gl.useProgram(currentProgram);
102
+ this.gl.uniform1f(this._padCountLocation, 360)
97
103
  }
98
104
 
99
105
  }
100
106
 
101
107
 
102
- draw(attrBufferManager, padCount, compass) {
108
+ draw(attrBufferManager, padCount, compass, opacity) {
103
109
  const { gl, program, _padCountLocation, cameraBlockBindingPoint, cameraBlockTotem, _compassLocation } = this;
104
110
  gl.useProgram(program);
105
111
  attrBufferManager.bindPaddingVAO();
106
112
  cameraBlockTotem.bind(cameraBlockBindingPoint);
107
113
  // draw instanced
108
- gl.uniform1f(_padCountLocation, padCount);
109
- gl.uniform1i(_compassLocation, compass);
114
+ if (padCount !== this._padCount) {
115
+ this._padCount = padCount;
116
+ gl.uniform1f(_padCountLocation, padCount);
117
+ }
118
+ if (compass !== this._compassMode) {
119
+ gl.uniform1i(_compassLocation, compass);
120
+ this._compassMode = compass;
121
+ }
122
+ if (opacity !== this._opacity) {
123
+ this._opacity = opacity;
124
+ gl.uniform1f(this._opacityLocation, opacity);
125
+ }
110
126
  gl.drawArraysInstanced(gl.LINES, 0, padCount * 2, attrBufferManager.length);
111
127
  gl.bindVertexArray(null);
112
128
  cameraBlockTotem.unbind(cameraBlockBindingPoint);
@@ -1,9 +1 @@
1
- import CirclePaddySharedBuffer from './distancering/circlepaddysharedbuffer';
2
- import CircleFlatProgram from './distancering/circleflatprogram';
3
- import PaddyFlatProgram from './distancering/paddyflatprogram';
4
-
5
- export default {
6
- CirclePaddySharedBuffer,
7
- CircleFlatProgram,
8
- PaddyFlatProgram,
9
- };
1
+ export * from "./distancering";
@@ -1,3 +1,4 @@
1
1
  import RangeRings from './rangerings';
2
+ import RangeRingAngleText from './rangeringangletext';
2
3
  import { ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES } from './enum';
3
- export { RangeRings, ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES };
4
+ export { RangeRings, ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES, RangeRingAngleText };
@@ -17,9 +17,8 @@ const fidKey = "__fid__";
17
17
 
18
18
 
19
19
  const object = {
20
- "displayName": "CompassRose",
20
+ "displayName": "RangeRingAngleText",
21
21
  "layerType": 3,
22
-
23
22
  "wkbGeom": null,
24
23
  "wfsLayerName": null,
25
24
  "objectType": "point",
@@ -33,38 +32,17 @@ const object = {
33
32
 
34
33
 
35
34
  export default class RangeRingAngleText {
36
- constructor(globe, id, { style = null, flatCompassMode = COMPASS_MODES.REAL } = {}) {
35
+ constructor(globe, id, { style = null, flatCompassMode = COMPASS_MODES.REAL, hideAll = false } = {}) {
37
36
  this.globe = globe;
38
37
  this.ObjectArray = globe.ObjectArray;
39
38
  this.id = id;
40
39
  this._flatCompassMode = flatCompassMode;
41
40
  this._lastImplicitCompassMode = this.__implicitCompassMode();
42
- if (style) {
43
- this.style = style;
44
- } else {
45
- this.style = this.ObjectArray.GetDefaultStyle();
46
- const { labels } = this.style;
47
- const label = labels[0];
48
- label.offset = { x: 0, y: 0 };
49
- label.fontFamily.hollowWidth = 1;
50
- label.vAlignment = 2;
51
- label.hAlignment = 2;
52
- label.size = 17;
53
- // this.style.filter = [
54
- // {
55
- // rule: ["any", ["<", "startLod", "LOD"]],
56
- // name: "startLODRule",
57
- // style: {
58
- // opacity: 0
59
- // }
60
-
61
- // }
62
- // ];
63
- }
64
41
 
65
- this.style.labels[0].text = "`${aci}`"
66
- this.style.fidKey = fidKey;
67
- this.object = Object.assign({}, object, { style: this.style, id: this.id });
42
+ this._hideAll = hideAll;
43
+
44
+ const style_ = style !== null ? style : this.getDefaultStyle();
45
+ this.object = Object.assign({}, object, { style: style_, id: this.id });
68
46
 
69
47
  this._centerCollection = new Map();
70
48
  // new inner MAP params
@@ -75,6 +53,37 @@ export default class RangeRingAngleText {
75
53
 
76
54
  }
77
55
 
56
+ getDefaultStyle() {
57
+ const style = this.ObjectArray.GetDefaultStyle();
58
+ style.fidKey = fidKey;
59
+ const { labels } = style;
60
+ const label = labels[0];
61
+ label.offset = { x: 0, y: 0 };
62
+ label.fontFamily.hollowWidth = 1;
63
+ label.vAlignment = 2;
64
+ label.hAlignment = 2;
65
+ label.size = 17;
66
+ label.text = "`${aci}`"
67
+ // this.style.filter = [
68
+ // {
69
+ // rule: ["any", ["===", "aci", "K"]],
70
+ // name: "startLODRule",
71
+ // style: {
72
+ // ...
73
+ // }
74
+
75
+ // }
76
+ // ];
77
+ return style;
78
+ }
79
+
80
+
81
+ setStyle(style) {
82
+ if (style === null) return;
83
+ this.object.style = style;
84
+ this.ObjectArray.StyleChanged(this.object);
85
+ }
86
+
78
87
 
79
88
  setCompass(mode) {
80
89
  if (mode === this._flatCompassMode) return;
@@ -100,7 +109,7 @@ export default class RangeRingAngleText {
100
109
  *
101
110
  * */
102
111
  insertBulk(ringDatas) {
103
-
112
+ const { _hideAll } = this;
104
113
  const addBucket = {
105
114
  coords: [],
106
115
  coordsZ: [],
@@ -118,7 +127,8 @@ export default class RangeRingAngleText {
118
127
  this._fillDeleteBucket(centerID, deleteBucket);
119
128
  }
120
129
  const maxRadius = rings.reduce((acc, { radius }) => Math.max(acc, radius), 0);
121
- const show = hide !== ENUM_HIDE.HIDE && textHide === ENUM_TEXT_HIDE.SHOW;
130
+ const textHide_ = _hideAll ? ENUM_TEXT_HIDE.HIDE : textHide;
131
+ const show = hide !== ENUM_HIDE.HIDE && textHide_ === ENUM_TEXT_HIDE.SHOW;
122
132
  if (show) this._appendCircle(x, y, maxRadius, stepAngle, centerID, addBucket);
123
133
  this._centerCollection.set(centerID,
124
134
  new Map([
@@ -127,10 +137,10 @@ export default class RangeRingAngleText {
127
137
  ["x", x],
128
138
  ["y", y],
129
139
  ["hide", hide],
130
- ["textHide", textHide]
140
+ ["textHide", textHide_]
131
141
  ]));
132
142
  }
133
-
143
+ if (this._hideAll) return;
134
144
  if (deleteBucket.coords.length > 0) this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
135
145
  if (addBucket.coords.length > 0) this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD);
136
146
 
@@ -149,18 +159,22 @@ export default class RangeRingAngleText {
149
159
  for (const { centerID, x, y } of centerDatas) {
150
160
  if (this._centerCollection.has(centerID)) {
151
161
  const centerMap = this._centerCollection.get(centerID);
162
+ centerMap.set("x", x);
163
+ centerMap.set("y", y);
164
+ const hide = centerMap.get("hide");
165
+ const textHide = centerMap.get("textHide");
166
+ const isHidden = hide === ENUM_HIDE.HIDE || textHide === ENUM_TEXT_HIDE.HIDE;
167
+ if (isHidden) continue;
152
168
  const maxRadius = centerMap.get("maxRadius");
153
169
  const stepAngle = centerMap.get("stepAngle");
154
170
  // long, lat, radius, step, centerID, outBucket
155
171
  this._appendCircle(x, y, maxRadius, stepAngle, centerID, updateBucket);
156
- centerMap.set("x", x);
157
- centerMap.set("y", y);
158
172
 
159
173
  }
160
174
  }
161
- for (const attribs of updateBucket.attribs) {
162
- delete attribs["aci"];
163
- }
175
+ // for (const attribs of updateBucket.attribs) {
176
+ // delete attribs["aci"];
177
+ // }
164
178
  if (updateBucket.coords.length > 0) {
165
179
  this._updateData(updateBucket, CSObjectArrayUpdateTypes.UPDATE);
166
180
  }
@@ -173,6 +187,10 @@ export default class RangeRingAngleText {
173
187
  * @param {Array<{centerID:string, hide: bool}} centerHides
174
188
  */
175
189
  updateCentersHide(centerHides) {
190
+ if (this._hideAll) {
191
+ console.warn("Tum mesafe halkasi yazilari gizli durum. Islem yapilamaz");
192
+ return;
193
+ };
176
194
  const addBucket = {
177
195
  coords: [],
178
196
  coordsZ: [],
@@ -223,6 +241,46 @@ export default class RangeRingAngleText {
223
241
  }
224
242
 
225
243
 
244
+ hideAll() {
245
+ this._hideAll = true;
246
+ const deleteBucket = {
247
+ coords: [],
248
+ coordsZ: [],
249
+ attribs: []
250
+ }
251
+ for (const [centerID, centerMap] of this._centerCollection) {
252
+ const hide = centerMap.get("hide");
253
+ const hideText = centerMap.get("textHide");
254
+ const isHidden = hide === ENUM_HIDE.HIDE || hideText === ENUM_TEXT_HIDE.HIDE;
255
+ if (!isHidden) this._fillDeleteBucket(centerID, deleteBucket);
256
+ centerMap.set("hide", ENUM_HIDE.HIDE);
257
+ }
258
+ this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
259
+ }
260
+
261
+ showAll() {
262
+ this._hideAll = false;
263
+ const addBucket = {
264
+ coords: [],
265
+ coordsZ: [],
266
+ attribs: []
267
+ }
268
+ for (const [centerID, centerMap] of this._centerCollection) {
269
+ const hide = centerMap.get("hide");
270
+ const hideText = centerMap.get("textHide");
271
+ const isHidden = hide === ENUM_HIDE.HIDE || hideText === ENUM_TEXT_HIDE.HIDE;
272
+ if (isHidden) {
273
+ const x = centerMap.get("x");
274
+ const y = centerMap.get("y");
275
+ const maxRadius = centerMap.get("maxRadius");
276
+ const stepAngle = centerMap.get("stepAngle");
277
+ this._appendCircle(x, y, maxRadius, stepAngle, centerID, addBucket);
278
+ centerMap.set("hide", ENUM_HIDE.SHOW);
279
+ centerMap.set("textHide", ENUM_TEXT_HIDE.SHOW);
280
+ }
281
+ }
282
+ if (addBucket.coords.length) this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD);
283
+ }
226
284
 
227
285
 
228
286
 
@@ -3,7 +3,7 @@ import { COMPASS_MODES } from "./enum";
3
3
  import { PaddingFreeAngleCache } from "../programs/rings/distancering";
4
4
 
5
5
  import RangeRingAngleText from "./rangeringangletext";
6
- const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
6
+ const { circleProgramCache, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
7
7
 
8
8
  /**
9
9
  * @typedef RangeRingData
@@ -22,10 +22,12 @@ const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
22
22
 
23
23
  export default class {
24
24
 
25
- constructor(id, { oneDegreePadding = true, compass = COMPASS_MODES.COMPASS, showNumbers = true } = {}) {
25
+ constructor(id, { oneDegreePadding = true, compass = COMPASS_MODES.REAL, showNumbers = true, numbersStyle = null, opacity = 1 } = {}) {
26
26
  this.id = id;
27
27
  this.compass = compass;
28
28
  this._showNumbers = showNumbers;
29
+ this._numbersStyle = numbersStyle;
30
+ this._opacity = opacity;
29
31
  this.circleEdgeCount = 360;
30
32
  this._onedegreepaddingOn = oneDegreePadding;
31
33
  this.bufferManager = null;
@@ -39,11 +41,12 @@ export default class {
39
41
  init(globe, gl) {
40
42
  this.gl = gl;
41
43
  this.globe = globe;
42
- this.circleFlatProgram = new CircleFlatProgram(globe, gl);
44
+ this.circleFlatProgram = circleProgramCache.getProgram(globe);
43
45
  this.paddyFlatProgram = new PaddyFlatProgram(globe, gl);
44
46
  this.paddingFreeAngleProgram = PaddingFreeAngleCache.getProgram(globe);
45
47
  if (this._showNumbers) {
46
- this._textPlugin = new RangeRingAngleText(globe, this.id + "text", { flatCompassMode: this.compass });
48
+ this.textPlugin = new RangeRingAngleText(globe, this.id + "text", { flatCompassMode: this.compass, style: this._numbersStyle });
49
+ delete this._numbersStyle;
47
50
  }
48
51
  }
49
52
 
@@ -52,28 +55,29 @@ export default class {
52
55
  this.circleFlatProgram.free();
53
56
  this.paddyFlatProgram.free();
54
57
  this.bufferManager?.free();
55
- this._textPlugin?.free();
58
+ this.textPlugin?.free();
56
59
  }
57
60
 
58
61
 
59
-
62
+ setOpacity(opacity) {
63
+ this._opacity = opacity;
64
+ this.globe.DrawRender();
65
+ }
60
66
 
61
67
  setGeometry() {
62
- this._textPlugin?.setGeometry();
68
+ this.textPlugin?.setGeometry();
63
69
  }
64
70
 
65
71
 
66
72
  draw3D() {
67
- const { circleFlatProgram, paddyFlatProgram, paddingFreeAngleProgram, bufferManager, compass, gl, circleEdgeCount, paddingBufferManager } = this;
68
- // if (globe.api_GetCurrentGeometry() === 0) return; // do not draw in 3D mode
73
+ const { circleFlatProgram, paddyFlatProgram, paddingFreeAngleProgram, bufferManager, compass, gl, circleEdgeCount, paddingBufferManager, _opacity } = this;
69
74
  if (this.bufferManager !== null && bufferManager.length > 0) {
70
75
  gl.disable(gl.DEPTH_TEST);
71
76
  // gl.enable(gl.BLEND);
72
77
  // gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
73
- circleFlatProgram.draw(bufferManager, compass, circleEdgeCount);
74
- if (this._onedegreepaddingOn) paddyFlatProgram.draw(bufferManager, 360, compass);
75
- paddingFreeAngleProgram.draw(paddingBufferManager, compass);
76
-
78
+ circleFlatProgram.draw(bufferManager, compass, circleEdgeCount, _opacity);
79
+ if (this._onedegreepaddingOn) paddyFlatProgram.draw(bufferManager, 360, compass, _opacity);
80
+ paddingFreeAngleProgram.draw(paddingBufferManager, compass, _opacity);
77
81
  gl.enable(gl.DEPTH_TEST);
78
82
  }
79
83
  }
@@ -87,14 +91,14 @@ export default class {
87
91
  */
88
92
  setCampass(compass) {
89
93
  this.compass = compass;
90
- this._textPlugin?.setCompass(compass);
94
+ this.textPlugin?.setCompass(compass);
91
95
  }
92
96
 
93
97
  initilizeBufferManager(initialRingCapacity, bufferDrawType) {
94
98
  const { gl, globe } = this
95
99
  this.bufferDrawType = bufferDrawType;
96
100
  this.bufferManager = new CirclePaddySharedBuffer(gl, globe, { bufferType: bufferDrawType, initialRingCapacity: initialRingCapacity });
97
- this.paddingBufferManager = this.paddingFreeAngleProgram.initilizeBufferManager({ bufferType: bufferDrawType, initialRingCapacity });
101
+ this.paddingBufferManager = this.paddingFreeAngleProgram.createBuffer({ bufferType: bufferDrawType, initialRingCapacity });
98
102
  }
99
103
 
100
104
 
@@ -110,19 +114,26 @@ export default class {
110
114
  item.paddingAngles = angleToPaddingAngles(item.stepAngle, 0);
111
115
  }
112
116
  this.paddingBufferManager.insertBulk(items);
113
- this._textPlugin?.insertBulk(items);
117
+ this.textPlugin?.insertBulk(items);
114
118
  this.globe.DrawRender();
115
119
  }
116
120
 
117
121
 
122
+ /**
123
+ *
124
+ * @param {Array<{centerID, x, y}>} items
125
+ */
118
126
  updateCentersXY(items) {
119
127
  this.bufferManager.updateCentersXY(items);
120
128
  this.paddingBufferManager.updateCentersXY(items);
121
- this._textPlugin?.updateCentersXY(items);
129
+ this.textPlugin?.updateCentersXY(items);
122
130
  this.globe.DrawRender();
123
131
  }
124
132
 
125
133
 
134
+ /**
135
+ * @param {Array<{centerID, rgba:[4 numbers]}>} centerColors
136
+ */
126
137
  updateCentersColor(centerColors) {
127
138
  this.bufferManager.updateCentersColor(centerColors);
128
139
  this.paddingBufferManager.updateCentersColor(centerColors);
@@ -130,27 +141,34 @@ export default class {
130
141
  }
131
142
 
132
143
 
133
- // TODO: test
144
+ /**
145
+ * @param {Array<{centerID}>} centerIds
146
+ */
134
147
  removeCenters(centerIds) {
135
148
  this.bufferManager.removeCenters(centerIds);
136
149
  this.paddingBufferManager.removeCenters(centerIds);
137
- this._textPlugin?.removeCenters(centerIds);
150
+ this.textPlugin?.removeCenters(centerIds);
138
151
  // this.bufferManager.defrag();
139
152
  // this.paddingBufferManager.defrag();
140
153
  this.globe.DrawRender();
141
154
 
142
155
  }
143
156
 
144
- //TODO: test
157
+ /**
158
+ *
159
+ * @param {Array<{centerID, hide, textHide}>} centerHides
160
+ */
145
161
  updateCentersHide(centerHides) {
146
162
  this.bufferManager.updateCentersHide(centerHides);
147
163
  this.paddingBufferManager.updateCentersHide(centerHides);
148
- this._textPlugin?.updateCentersHide(centerHides);
164
+ this.textPlugin?.updateCentersHide(centerHides);
149
165
  this.globe.DrawRender();
150
166
  }
151
167
  }
152
168
 
153
169
 
170
+
171
+
154
172
  const ringItemsToCircleBufferInsertDataAdaptor = (ringItems) => {
155
173
 
156
174
  const result = [];
@@ -116,7 +116,8 @@ export default class {
116
116
  }
117
117
 
118
118
 
119
- extendBuffer(gl, buffer, bufferType, newCapacity) {
119
+ extendBuffer(newCapacity) {
120
+ const { gl, buffer, bufferType } = this;
120
121
  const itemSize = this.itemSize;
121
122
  const bufferData = this._getBufferData();
122
123
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
@@ -136,7 +137,8 @@ export default class {
136
137
  * @param {number} partOffset
137
138
  * @returns
138
139
  */
139
- _updatePartial(items, partOffset, gl, buffer) {
140
+ _updatePartial(items, partOffset) {
141
+ const { gl, buffer } = this;
140
142
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
141
143
  const partStart = partOffset * 4;
142
144
  for (let { key, payload } of items) {
@@ -1,3 +1,3 @@
1
1
  import VectorFieldWaveParticle from "./plugin";
2
2
  import { centigradePlus90ToVectorArray } from "./adaptor";
3
- export { centigradePlus90ToVectorArray, VectorFieldWaveParticle };
3
+ export { centigradePlus90ToVectorArray, VectorFieldWaveParticle };