@pirireis/webglobeplugins 0.1.7 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -105,19 +105,16 @@ class Logic {
105
105
 
106
106
  if (compass !== this._compassmode) {
107
107
  gl.uniform1i(this._compassLocation, compass);
108
- console.log("compass", compass);
109
108
  this._compassmode = compass;
110
109
  }
111
110
 
112
111
  if (opacity !== this._opacity) {
113
112
  gl.uniform1f(this._opacityLocation, opacity);
114
- console.log("opacity", opacity);
115
113
  this._opacity = opacity;
116
114
  }
117
115
 
118
116
  if (circleEdgeCount !== this._circleEdgeCount) {
119
117
  gl.uniform1f(this._circleEdgeCountLocation, circleEdgeCount);
120
- console.log("circleEdgeCount", circleEdgeCount);
121
118
  this._circleEdgeCount = circleEdgeCount;
122
119
  }
123
120
  gl.drawArraysInstanced(gl.LINE_LOOP, 0, circleEdgeCount, attrBufferManager.length);
@@ -1,5 +1,5 @@
1
1
  import { programCache as circleProgramCache } from './circleflatprogram';
2
- import PaddyFlatProgram from './paddyflatprogram';
2
+ import { PaddingProgramCache } from './paddyflatprogram';
3
3
  import CirclePaddySharedBuffer from './circlepaddysharedbuffer';
4
4
  import { PaddingFreeAngleCache } from './circlepaddingfreeangleprogram';
5
- export { circleProgramCache, PaddyFlatProgram, CirclePaddySharedBuffer, PaddingFreeAngleCache };
5
+ export { circleProgramCache, PaddingProgramCache, CirclePaddySharedBuffer, PaddingFreeAngleCache };
@@ -98,8 +98,9 @@ class Logic {
98
98
  const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
99
99
  this.gl.useProgram(this.program);
100
100
  this.gl.uniform1i(this._compassLocation, 1);
101
- this.gl.useProgram(currentProgram);
101
+ this.gl.uniform1f(this._opacityLocation, 1.0);
102
102
  this.gl.uniform1f(this._padCountLocation, 360)
103
+ this.gl.useProgram(currentProgram);
103
104
  }
104
105
 
105
106
  }
@@ -113,13 +114,16 @@ class Logic {
113
114
  // draw instanced
114
115
  if (padCount !== this._padCount) {
115
116
  this._padCount = padCount;
117
+ console.log("padCount", padCount);
116
118
  gl.uniform1f(_padCountLocation, padCount);
117
119
  }
118
120
  if (compass !== this._compassMode) {
121
+ console.log("compass", compass);
119
122
  gl.uniform1i(_compassLocation, compass);
120
123
  this._compassMode = compass;
121
124
  }
122
125
  if (opacity !== this._opacity) {
126
+ console.log("opacity", opacity);
123
127
  this._opacity = opacity;
124
128
  gl.uniform1f(this._opacityLocation, opacity);
125
129
  }
@@ -136,17 +140,7 @@ class Logic {
136
140
 
137
141
 
138
142
 
139
- export default class {
140
- constructor(globe, gl) {
141
- this.gl = gl;
142
- this.logic = noRegisterGlobeProgramCache.getProgram(globe, Logic);
143
- }
144
-
145
- draw(attrBufferManager, padCount, compass) {
146
- this.logic.draw(attrBufferManager, padCount, compass);
147
- }
148
-
149
- free() {
150
- noRegisterGlobeProgramCache.releaseProgram(this.gl, Logic);
151
- }
152
- }
143
+ export const PaddingProgramCache = Object.freeze({
144
+ getProgram: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
145
+ releaseProgram: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
146
+ })
@@ -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
 
@@ -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 { circleProgramCache, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
6
+ const { circleProgramCache, PaddingProgramCache, CirclePaddySharedBuffer } = rings;
7
7
 
8
8
  /**
9
9
  * @typedef RangeRingData
@@ -42,25 +42,32 @@ export default class {
42
42
  this.gl = gl;
43
43
  this.globe = globe;
44
44
  this.circleFlatProgram = circleProgramCache.getProgram(globe);
45
- this.paddyFlatProgram = new PaddyFlatProgram(globe, gl);
45
+ this.paddyFlatProgram = PaddingProgramCache.getProgram(globe);
46
46
  this.paddingFreeAngleProgram = PaddingFreeAngleCache.getProgram(globe);
47
47
  if (this._showNumbers) {
48
- 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 });
49
49
  delete this._numbersStyle;
50
50
  }
51
51
  }
52
52
 
53
53
  // TODO: Add text free
54
54
  free() {
55
- this.circleFlatProgram.free();
56
- this.paddyFlatProgram.free();
55
+ this.circleFlatProgram?.free();
56
+ this.paddyFlatProgram?.free();
57
57
  this.bufferManager?.free();
58
+ this.paddingBufferManager?.free();
58
59
  this.textPlugin?.free();
60
+ this.circleFlatProgram = null;
61
+ this.paddyFlatProgram = null;
62
+ this.bufferManager = null;
63
+ this.paddingBufferManager = null;
64
+ this.textPlugin = null;
59
65
  }
60
66
 
61
67
 
62
68
  setOpacity(opacity) {
63
69
  this._opacity = opacity;
70
+ this.textPlugin?.setOpacity(opacity); // TODO impolement this
64
71
  this.globe.DrawRender();
65
72
  }
66
73
 
@@ -75,6 +82,7 @@ export default class {
75
82
  gl.disable(gl.DEPTH_TEST);
76
83
  // gl.enable(gl.BLEND);
77
84
  // gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
85
+ console.log("the opacity", _opacity);
78
86
  circleFlatProgram.draw(bufferManager, compass, circleEdgeCount, _opacity);
79
87
  if (this._onedegreepaddingOn) paddyFlatProgram.draw(bufferManager, 360, compass, _opacity);
80
88
  paddingFreeAngleProgram.draw(paddingBufferManager, compass, _opacity);