@pirireis/webglobeplugins 0.1.6 → 0.1.8

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.6",
3
+ "version": "0.1.8",
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,46 @@ 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);
102
108
  this._compassmode = compass;
103
109
  }
104
- if (circle_edge_count !== this._circleEdgeCountLocation) {
105
- gl.uniform1f(this._circleEdgeCountLocation, circle_edge_count);
106
- this._circle_edge_count = circle_edge_count;
110
+
111
+ if (opacity !== this._opacity) {
112
+ gl.uniform1f(this._opacityLocation, opacity);
113
+ this._opacity = opacity;
114
+ }
115
+
116
+ if (circleEdgeCount !== this._circleEdgeCount) {
117
+ gl.uniform1f(this._circleEdgeCountLocation, circleEdgeCount);
118
+ this._circleEdgeCount = circleEdgeCount;
107
119
  }
108
- gl.drawArraysInstanced(gl.LINE_LOOP, 0, circle_edge_count, attrBufferManager.length);
120
+ gl.drawArraysInstanced(gl.LINE_LOOP, 0, circleEdgeCount, attrBufferManager.length);
109
121
  gl.bindVertexArray(null);
110
122
  cameraBlockTotem.unbind(cameraBlockBindingPoint);
111
123
  }
@@ -118,18 +130,7 @@ class Logic {
118
130
  }
119
131
 
120
132
 
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
- }
133
+ export const programCache = Object.freeze({
134
+ getProgram: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
135
+ releaseProgram: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
136
+ });
@@ -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';
2
- import PaddyFlatProgram from './paddyflatprogram';
1
+ import { programCache as circleProgramCache } from './circleflatprogram';
2
+ import { PaddingProgramCache } from './paddyflatprogram';
3
3
  import CirclePaddySharedBuffer from './circlepaddysharedbuffer';
4
4
  import { PaddingFreeAngleCache } from './circlepaddingfreeangleprogram';
5
- export { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer, PaddingFreeAngleCache };
5
+ export { circleProgramCache, PaddingProgramCache, 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,44 @@ 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);
101
+ this.gl.uniform1f(this._opacityLocation, 1.0);
102
+ this.gl.uniform1f(this._padCountLocation, 360)
96
103
  this.gl.useProgram(currentProgram);
97
104
  }
98
105
 
99
106
  }
100
107
 
101
108
 
102
- draw(attrBufferManager, padCount, compass) {
109
+ draw(attrBufferManager, padCount, compass, opacity) {
103
110
  const { gl, program, _padCountLocation, cameraBlockBindingPoint, cameraBlockTotem, _compassLocation } = this;
104
111
  gl.useProgram(program);
105
112
  attrBufferManager.bindPaddingVAO();
106
113
  cameraBlockTotem.bind(cameraBlockBindingPoint);
107
114
  // draw instanced
108
- gl.uniform1f(_padCountLocation, padCount);
109
- gl.uniform1i(_compassLocation, compass);
115
+ if (padCount !== this._padCount) {
116
+ this._padCount = padCount;
117
+ console.log("padCount", padCount);
118
+ gl.uniform1f(_padCountLocation, padCount);
119
+ }
120
+ if (compass !== this._compassMode) {
121
+ console.log("compass", compass);
122
+ gl.uniform1i(_compassLocation, compass);
123
+ this._compassMode = compass;
124
+ }
125
+ if (opacity !== this._opacity) {
126
+ console.log("opacity", opacity);
127
+ this._opacity = opacity;
128
+ gl.uniform1f(this._opacityLocation, opacity);
129
+ }
110
130
  gl.drawArraysInstanced(gl.LINES, 0, padCount * 2, attrBufferManager.length);
111
131
  gl.bindVertexArray(null);
112
132
  cameraBlockTotem.unbind(cameraBlockBindingPoint);
@@ -120,17 +140,7 @@ class Logic {
120
140
 
121
141
 
122
142
 
123
- export default class {
124
- constructor(globe, gl) {
125
- this.gl = gl;
126
- this.logic = noRegisterGlobeProgramCache.getProgram(globe, Logic);
127
- }
128
-
129
- draw(attrBufferManager, padCount, compass) {
130
- this.logic.draw(attrBufferManager, padCount, compass);
131
- }
132
-
133
- free() {
134
- noRegisterGlobeProgramCache.releaseProgram(this.gl, Logic);
135
- }
136
- }
143
+ export const PaddingProgramCache = Object.freeze({
144
+ getProgram: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
145
+ releaseProgram: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
146
+ })
@@ -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 };
@@ -32,7 +32,7 @@ const object = {
32
32
 
33
33
 
34
34
  export default class RangeRingAngleText {
35
- constructor(globe, id, { style = null, flatCompassMode = COMPASS_MODES.REAL, hideAll = false } = {}) {
35
+ constructor(globe, id, { style = null, flatCompassMode = COMPASS_MODES.REAL, hideAll = false, opacity = 1 } = {}) {
36
36
  this.globe = globe;
37
37
  this.ObjectArray = globe.ObjectArray;
38
38
  this.id = id;
@@ -40,7 +40,7 @@ export default class RangeRingAngleText {
40
40
  this._lastImplicitCompassMode = this.__implicitCompassMode();
41
41
 
42
42
  this._hideAll = hideAll;
43
-
43
+ this._opacity = opacity;
44
44
  const style_ = style !== null ? style : this.getDefaultStyle();
45
45
  this.object = Object.assign({}, object, { style: style_, id: this.id });
46
46
 
@@ -66,10 +66,10 @@ export default class RangeRingAngleText {
66
66
  label.text = "`${aci}`"
67
67
  // this.style.filter = [
68
68
  // {
69
- // rule: ["any", ["<", "startLod", "LOD"]],
69
+ // rule: ["any", ["===", "aci", "K"]],
70
70
  // name: "startLODRule",
71
71
  // style: {
72
- // opacity: 0
72
+ // ...
73
73
  // }
74
74
 
75
75
  // }
@@ -80,11 +80,19 @@ export default class RangeRingAngleText {
80
80
 
81
81
  setStyle(style) {
82
82
  if (style === null) return;
83
+ style.opacity = this._opacity;
83
84
  this.object.style = style;
84
85
  this.ObjectArray.StyleChanged(this.object);
85
86
  }
86
87
 
87
88
 
89
+ setOpacity(opacity) {
90
+ this._opacity = opacity;
91
+ const { style } = this.object;
92
+ style.opacity = opacity;
93
+ this.ObjectArray.StyleChanged(this.object);
94
+ }
95
+
88
96
  setCompass(mode) {
89
97
  if (mode === this._flatCompassMode) return;
90
98
  this._flatCompassMode = mode;
@@ -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, PaddingProgramCache, CirclePaddySharedBuffer } = rings;
7
7
 
8
8
  /**
9
9
  * @typedef RangeRingData
@@ -22,11 +22,12 @@ const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
22
22
 
23
23
  export default class {
24
24
 
25
- constructor(id, { oneDegreePadding = true, compass = COMPASS_MODES.REAL, showNumbers = true, numbersStyle = null } = {}) {
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
29
  this._numbersStyle = numbersStyle;
30
+ this._opacity = opacity;
30
31
  this.circleEdgeCount = 360;
31
32
  this._onedegreepaddingOn = oneDegreePadding;
32
33
  this.bufferManager = null;
@@ -40,25 +41,35 @@ export default class {
40
41
  init(globe, gl) {
41
42
  this.gl = gl;
42
43
  this.globe = globe;
43
- this.circleFlatProgram = new CircleFlatProgram(globe, gl);
44
- this.paddyFlatProgram = new PaddyFlatProgram(globe, gl);
44
+ this.circleFlatProgram = circleProgramCache.getProgram(globe);
45
+ this.paddyFlatProgram = PaddingProgramCache.getProgram(globe);
45
46
  this.paddingFreeAngleProgram = PaddingFreeAngleCache.getProgram(globe);
46
47
  if (this._showNumbers) {
47
- this.textPlugin = new RangeRingAngleText(globe, this.id + "text", { flatCompassMode: this.compass, style: this._numbersStyle });
48
+ this.textPlugin = new RangeRingAngleText(globe, this.id + "text", { flatCompassMode: this.compass, style: this._numbersStyle, opacity: this._opacity });
48
49
  delete this._numbersStyle;
49
50
  }
50
51
  }
51
52
 
52
53
  // TODO: Add text free
53
54
  free() {
54
- this.circleFlatProgram.free();
55
- this.paddyFlatProgram.free();
55
+ this.circleFlatProgram?.free();
56
+ this.paddyFlatProgram?.free();
56
57
  this.bufferManager?.free();
58
+ this.paddingBufferManager?.free();
57
59
  this.textPlugin?.free();
60
+ this.circleFlatProgram = null;
61
+ this.paddyFlatProgram = null;
62
+ this.bufferManager = null;
63
+ this.paddingBufferManager = null;
64
+ this.textPlugin = null;
58
65
  }
59
66
 
60
67
 
61
-
68
+ setOpacity(opacity) {
69
+ this._opacity = opacity;
70
+ this.textPlugin?.setOpacity(opacity); // TODO impolement this
71
+ this.globe.DrawRender();
72
+ }
62
73
 
63
74
  setGeometry() {
64
75
  this.textPlugin?.setGeometry();
@@ -66,16 +77,15 @@ export default class {
66
77
 
67
78
 
68
79
  draw3D() {
69
- const { circleFlatProgram, paddyFlatProgram, paddingFreeAngleProgram, bufferManager, compass, gl, circleEdgeCount, paddingBufferManager } = this;
70
- // if (globe.api_GetCurrentGeometry() === 0) return; // do not draw in 3D mode
80
+ const { circleFlatProgram, paddyFlatProgram, paddingFreeAngleProgram, bufferManager, compass, gl, circleEdgeCount, paddingBufferManager, _opacity } = this;
71
81
  if (this.bufferManager !== null && bufferManager.length > 0) {
72
82
  gl.disable(gl.DEPTH_TEST);
73
83
  // gl.enable(gl.BLEND);
74
84
  // gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
75
- circleFlatProgram.draw(bufferManager, compass, circleEdgeCount);
76
- if (this._onedegreepaddingOn) paddyFlatProgram.draw(bufferManager, 360, compass);
77
- paddingFreeAngleProgram.draw(paddingBufferManager, compass);
78
-
85
+ console.log("the opacity", _opacity);
86
+ circleFlatProgram.draw(bufferManager, compass, circleEdgeCount, _opacity);
87
+ if (this._onedegreepaddingOn) paddyFlatProgram.draw(bufferManager, 360, compass, _opacity);
88
+ paddingFreeAngleProgram.draw(paddingBufferManager, compass, _opacity);
79
89
  gl.enable(gl.DEPTH_TEST);
80
90
  }
81
91
  }
@@ -96,7 +106,7 @@ export default class {
96
106
  const { gl, globe } = this
97
107
  this.bufferDrawType = bufferDrawType;
98
108
  this.bufferManager = new CirclePaddySharedBuffer(gl, globe, { bufferType: bufferDrawType, initialRingCapacity: initialRingCapacity });
99
- this.paddingBufferManager = this.paddingFreeAngleProgram.initilizeBufferManager({ bufferType: bufferDrawType, initialRingCapacity });
109
+ this.paddingBufferManager = this.paddingFreeAngleProgram.createBuffer({ bufferType: bufferDrawType, initialRingCapacity });
100
110
  }
101
111
 
102
112
 
@@ -117,6 +127,10 @@ export default class {
117
127
  }
118
128
 
119
129
 
130
+ /**
131
+ *
132
+ * @param {Array<{centerID, x, y}>} items
133
+ */
120
134
  updateCentersXY(items) {
121
135
  this.bufferManager.updateCentersXY(items);
122
136
  this.paddingBufferManager.updateCentersXY(items);
@@ -125,6 +139,9 @@ export default class {
125
139
  }
126
140
 
127
141
 
142
+ /**
143
+ * @param {Array<{centerID, rgba:[4 numbers]}>} centerColors
144
+ */
128
145
  updateCentersColor(centerColors) {
129
146
  this.bufferManager.updateCentersColor(centerColors);
130
147
  this.paddingBufferManager.updateCentersColor(centerColors);
@@ -132,7 +149,9 @@ export default class {
132
149
  }
133
150
 
134
151
 
135
- // TODO: test
152
+ /**
153
+ * @param {Array<{centerID}>} centerIds
154
+ */
136
155
  removeCenters(centerIds) {
137
156
  this.bufferManager.removeCenters(centerIds);
138
157
  this.paddingBufferManager.removeCenters(centerIds);
@@ -143,7 +162,10 @@ export default class {
143
162
 
144
163
  }
145
164
 
146
- //TODO: test
165
+ /**
166
+ *
167
+ * @param {Array<{centerID, hide, textHide}>} centerHides
168
+ */
147
169
  updateCentersHide(centerHides) {
148
170
  this.bufferManager.updateCentersHide(centerHides);
149
171
  this.paddingBufferManager.updateCentersHide(centerHides);
@@ -153,6 +175,8 @@ export default class {
153
175
  }
154
176
 
155
177
 
178
+
179
+
156
180
  const ringItemsToCircleBufferInsertDataAdaptor = (ringItems) => {
157
181
 
158
182
  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 };