@pirireis/webglobeplugins 0.6.21 → 0.6.23-a

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.
@@ -66,7 +66,7 @@ export default class Plugin {
66
66
 
67
67
  this.drawText = drawText;
68
68
 
69
- this.circleFlatEdgeCount = circleFlatEdgeCount + 2;//circleFlatEdgeCount;
69
+ this.circleFlatEdgeCount = circleFlatEdgeCount + 2; //circleFlatEdgeCount;
70
70
  }
71
71
 
72
72
  setDoDrawVRM(bool) {
@@ -230,8 +230,8 @@ export default class Plugin {
230
230
 
231
231
  // normal circle
232
232
  ["circleDashAngle", {
233
- 'bufferManager': new BufferManager(gl, circleFlatEdgeCount, { bufferType, initialCapacity }),
234
- 'adaptor': (item) => new Float32Array(item.rgba),
233
+ 'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
234
+ 'adaptor': (item) => new Float32Array([item.circleDashAngle / 360]),
235
235
  }],
236
236
  // CIRCLE Mercator
237
237
  ["rgbaMercator", {
@@ -476,9 +476,7 @@ export default class Plugin {
476
476
  const result = []
477
477
  for (const item of propertyIDs) {
478
478
  result.push(item);
479
- console.log(item + " is processing")
480
479
  if (s.has(item)) {
481
- console.log(item + "Mercator is added")
482
480
  result.push(item + "Mercator");
483
481
  }
484
482
  }
@@ -83,7 +83,7 @@ export class CircleLineChainPlugin {
83
83
  this.circleProgram2d = CircleCache.get(globe);
84
84
  this.circle3DProgram = Circle3DCache.get(globe);
85
85
 
86
- this.lineToTheOriginProgram = LineToTheOriginCache.get(globe);
86
+ // this.lineToTheOriginProgram = LineToTheOriginCache.get(globe);
87
87
  const _circleFlatEdgeCount = this._circleFlatEdgeCount;
88
88
  {
89
89
  // createBuffers
@@ -174,8 +174,8 @@ export class CircleLineChainPlugin {
174
174
  ...['centerCoords2d', 'centerCoords3d', 'targetCoords2d', 'targetCoords3d', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
175
175
  this.circleVao2d = this.circleProgram2d.createVAO(
176
176
  ...["centerCoords2dMercator", "rgbaCircleMercator", "circleDashAngleMercator", "dashOpacityMercator"].map(key => obj(this.bufferManagersCompMap.get(key))));
177
- this.toOriginVao = this.lineToTheOriginProgram.createVAO(
178
- ...["targetCoords3d", "rgba"].map(key => obj(this.bufferManagersCompMap.get(key))));
177
+ // this.toOriginVao = this.lineToTheOriginProgram.createVAO(
178
+ // ...["targetCoords3d", "rgba"].map(key => obj(this.bufferManagersCompMap.get(key))));
179
179
  this.circle3DVao = this.circle3DProgram.createVAO(
180
180
  ...["centerCoords3d", "bigRadius", "rgbaCircle", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key)))
181
181
  );
@@ -426,7 +426,7 @@ export class CircleLineChainPlugin {
426
426
  const { gl } = this;
427
427
  gl.deleteVertexArray(this.lineVao);
428
428
  gl.deleteVertexArray(this.circleVao2d);
429
- gl.deleteVertexArray(this.toOriginVao);
429
+ // gl.deleteVertexArray(this.toOriginVao);
430
430
  this.lineProgram = null;
431
431
  this.circleProgram2d = null;
432
432
  this.isFreed = true;
@@ -437,7 +437,7 @@ export class CircleLineChainPlugin {
437
437
  gl.disable(gl.DEPTH_TEST);
438
438
  this.lineProgram.draw(this.lineVao, this.bufferOrchestrator.length, this._opacity);
439
439
  this._textContextWriterInjectionMap.forEach((writer) => writer.draw());
440
- this.lineToTheOriginProgram.draw(this.toOriginVao, this.bufferOrchestrator.length, this._opacity);
440
+ // this.lineToTheOriginProgram.draw(this.toOriginVao, this.bufferOrchestrator.length, this._opacity);
441
441
  const is3D = globe.api_GetCurrentGeometry() === 0;
442
442
  if (this._drawCircleOn) {
443
443
  if (is3D) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.6.21",
3
+ "version": "0.6.23-a",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -45,14 +45,12 @@ out float interpolation;
45
45
  out vec4 v_color;
46
46
  out float v_dash_ratio;
47
47
  out float v_dash_opacity;
48
- out vec2 v_limp;
49
48
  void main() {
50
49
  interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE}.0;
51
50
  if ( is3D ) {
52
51
  float angle = PI * 2.0 * interpolation;
53
52
  vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, radius, angle);
54
53
  gl_Position = cartesian3DToGLPosition(position);
55
- v_limp = vec2(0.0, 0.0);
56
54
  } else {
57
55
  return;
58
56
  }
@@ -73,7 +71,6 @@ in float interpolation;
73
71
  in vec2 v_limp;
74
72
  out vec4 color;
75
73
  void main() {
76
- if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ color = vec4(0.0,0.0,0.0,0.0); return; }
77
74
  color = v_color;
78
75
  color.a *= opacity;
79
76
  if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
@@ -110,8 +107,8 @@ class Logic {
110
107
  gl.bindAttribLocation(program, 0, "center_position3d");
111
108
  gl.bindAttribLocation(program, 1, "radius");
112
109
  gl.bindAttribLocation(program, 2, "color");
113
- gl.bindAttribLocation(program, 2, "dash_ratio");
114
- gl.bindAttribLocation(program, 3, "dash_opacity");
110
+ gl.bindAttribLocation(program, 3, "dash_ratio");
111
+ gl.bindAttribLocation(program, 4, "dash_opacity");
115
112
  }
116
113
 
117
114
  this.cameraBindingPoint = 0;
@@ -69,8 +69,7 @@ void main() {
69
69
  if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
70
70
  color.a *= v_dash_opacity;
71
71
  }
72
- }
73
- `;
72
+ }`;
74
73
 
75
74
 
76
75
 
@@ -180,9 +179,9 @@ const CircleCache = Object.freeze({
180
179
  });
181
180
 
182
181
 
183
- function centerCoords2dflatDataCreator(globe, centerLong, centerLat, targetLong, targetLat, { startAngleOfCircle = null, edgeCount = EDGE_COUNT } = {}) {
182
+ function centerCoords2dflatDataCreator(globe, centerLong, centerLat, targetLong, targetLat, { startAngleOfCircle = null, edgeCount = EDGE_COUNT, radiusOffset = 0 } = {}) {
184
183
  const centerCoords2dflat = new Float32Array(edgeCount * 2);
185
- const radius2d = globe.Math.GetDist2D(centerLong, centerLat, targetLong, targetLat);
184
+ const radius2d = globe.Math.GetDist2D(centerLong, centerLat, targetLong, targetLat) + radiusOffset;
186
185
  let angle;
187
186
  if (startAngleOfCircle === null) {
188
187
  angle = globe.Math.GetAzimuthAngle(centerLong, centerLat, targetLong, targetLat);
@@ -205,6 +204,26 @@ function centerCoords2dflatDataCreator(globe, centerLong, centerLat, targetLong,
205
204
  return centerCoords2dflat;
206
205
  }
207
206
 
207
+
208
+ function centerCoords2dflatDataCreatorWithRadius(globe, centerLong, centerLat, radius2d, { startAngleOfCircle = null, edgeCount = EDGE_COUNT } = {}) {
209
+ const centerCoords2dflat = new Float32Array(edgeCount * 2);
210
+ const pointsLongLat = globe.Math.GetEllipseGeo(
211
+ centerLong,
212
+ centerLat,
213
+ radius2d,
214
+ radius2d,
215
+ 0,
216
+ 360 / (edgeCount - 2), // 1 for return to start point, 1 for cutting circles
217
+ );
218
+
219
+ for (let i = 1; i < edgeCount; i++) {
220
+ const { long: lg, lat: lt } = pointsLongLat[i - 1];
221
+ centerCoords2dflat.set(globe.api_GetMercator2DPoint(lg, lt), i * 2);
222
+ }
223
+ return centerCoords2dflat;
224
+ }
225
+
226
+
208
227
  export {
209
- CircleCache, EDGE_COUNT, centerCoords2dflatDataCreator
228
+ CircleCache, EDGE_COUNT, centerCoords2dflatDataCreator, centerCoords2dflatDataCreatorWithRadius
210
229
  }
@@ -0,0 +1,145 @@
1
+ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
2
+ import { mercatorXYToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
3
+ import { noRegisterGlobeProgramCache } from "../programcache";
4
+ import { createProgram } from "../../util";
5
+ import { vaoAttributeLoader } from "../../util/account/util";
6
+
7
+ /**
8
+ * This program draws line between points provided from the first and second buffer.
9
+ * draw method gl.drawInstanced( gl.POINTS, 0,2, lineCount);
10
+ * */
11
+
12
+ const Z_ALPHA_MODE = Object.freeze({
13
+ ON: 1,
14
+ OFF: 0
15
+ });
16
+
17
+ const vertexShaderSource = `#version 300 es
18
+ precision highp float;
19
+ ${CameraUniformBlockString}
20
+ ${mercatorXYToGLPosition}
21
+ uniform float opacity;
22
+ uniform int z_alpha_on;
23
+
24
+ in vec2 posA;
25
+ in vec2 posB;
26
+ in vec4 color;
27
+
28
+ out vec4 v_color;
29
+
30
+ void main() {
31
+ if ( is3D ) {
32
+ return;
33
+ }
34
+ float z_alpha;
35
+ if ( z_alpha_on == 1){
36
+ z_alpha = z_level * z_level / (distance(posA, posB) / 100.0 );
37
+ if( z_alpha < 0.1 ) {return;}
38
+ if( z_alpha > 1.0 ) {z_alpha = 1.0;}
39
+ } else {
40
+ z_alpha = 1.0;
41
+ }
42
+ vec2 pos;
43
+ if ( gl_VertexID == 0 ) {
44
+ pos = posA;
45
+ } else {
46
+ pos = posB;
47
+ }
48
+ gl_Position = mercatorXYToGLPosition( pos );
49
+ v_color = color;
50
+ v_color.a *= z_alpha * opacity;
51
+ gl_PointSize = 15.0;
52
+ }`;
53
+
54
+
55
+ const fragmentShaderSource = `#version 300 es
56
+ precision highp float;
57
+ in vec4 v_color;
58
+ out vec4 outColor;
59
+ void main() {
60
+ outColor = v_color;
61
+ }`;
62
+
63
+
64
+ class Logic {
65
+ constructor(globe) {
66
+ this.globe = globe;
67
+ this.gl = globe.gl;
68
+ this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
69
+ this._lastOpicity = 1.0;
70
+ this._lastZAlphaOn = Z_ALPHA_MODE.OFF;
71
+
72
+ const { gl, program } = this;
73
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
74
+ gl.useProgram(program);
75
+ { // assign attribute locations
76
+ gl.bindAttribLocation(program, 0, 'posA');
77
+ gl.bindAttribLocation(program, 1, 'posB');
78
+ gl.bindAttribLocation(program, 2, 'color');
79
+ }
80
+
81
+ { // uniform locations
82
+ this._opacityLocation = gl.getUniformLocation(program, 'opacity');
83
+ this._zAlphaOnLocation = gl.getUniformLocation(program, 'z_alpha_on');
84
+ gl.uniform1i(this._zAlphaOnLocation, this._lastZAlphaOn);
85
+ gl.uniform1f(this._opacityLocation, this._lastOpicity);
86
+ }
87
+ { // uniform block
88
+ this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
89
+ this._cameraBindingPoint = 0;
90
+ const cameraBlockBindingIndex = gl.getUniformBlockIndex(program, 'CameraUniformBlock');
91
+ gl.uniformBlockBinding(program, cameraBlockBindingIndex, this._cameraBindingPoint);
92
+ }
93
+ gl.useProgram(currentProgram);
94
+ }
95
+ createVAO(posAObj, posBObj, colorObj) {
96
+
97
+ const { gl } = this;
98
+ const vao = gl.createVertexArray();
99
+ const type = gl.Float;
100
+ const divisor = 1;
101
+ gl.bindVertexArray(vao);
102
+ [posAObj, posBObj, colorObj].forEach((obj, index) => {
103
+ const { buffer, size, stride, offset } = obj;
104
+ vaoAttributeLoader(gl, index, buffer, size, stride, offset, divisor, type);
105
+ });
106
+ gl.bindVertexArray(null);
107
+ return vao;
108
+ }
109
+
110
+
111
+ draw(vao, lineCount, opacity = 1.0, zAlphaOn = Z_ALPHA_MODE.OFF) {
112
+ const { gl, program, _cameraBindingPoint, _cameraUniformBlock } = this;
113
+ gl.useProgram(program);
114
+ _cameraUniformBlock.bind(_cameraBindingPoint);
115
+ gl.bindVertexArray(vao);
116
+ if (this._lastOpicity !== opacity) {
117
+ this._lastOpicity = opacity;
118
+ gl.uniform1f(this._opacityLocation, opacity);
119
+ }
120
+ if (this._lastZAlphaOn !== zAlphaOn) {
121
+ this._lastZAlphaOn = zAlphaOn;
122
+ gl.uniform1i(this._zAlphaOnLocation, zAlphaOn);
123
+ }
124
+ gl.drawInstanced(gl.POINTS, 0, 2, lineCount);
125
+ _cameraUniformBlock.unbind(_cameraBindingPoint);
126
+ gl.bindVertexArray(null);
127
+ }
128
+
129
+
130
+ free() {
131
+ if (this.isFreed) return;
132
+ const { gl, program, globe } = this;
133
+ CameraUniformBlockTotemCache.release(globe);
134
+ gl.deleteProgram(program);
135
+ this.isFreed = true;
136
+ }
137
+ }
138
+
139
+
140
+ const LinesColorInstancedFlatCache = Object.freeze({
141
+ get: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
142
+ release: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
143
+ });
144
+
145
+ export { LinesColorInstancedFlatCache, Z_ALPHA_MODE };
@@ -1,8 +1,4 @@
1
1
  import { createProgram, shaderfunctions } from "../../../util";
2
- import {
3
- circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
4
- circleLimpFromLongLatRadCenterCartesian3D_accurate_accurate
5
- } from "../../../util/shaderfunctions/geometrytransformations";
6
2
  import CameraUniformBlockTotem, { CameraUniformBlockString } from "../../totems/camerauniformblock";
7
3
  import { globeProgramCache, noRegisterGlobeProgramCache } from "../../programcache";
8
4
 
@@ -14,12 +10,11 @@ const vertexShader = `#version 300 es ` +
14
10
  shaderfunctions.mercatorXYToGLPosition +
15
11
  shaderfunctions.longLatRadToMercator +
16
12
  shaderfunctions.longLatRadToCartesian3D +
13
+ shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
17
14
  shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
18
15
  shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistancePadding +
19
16
  shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
20
17
 
21
- ${circleLimpFromLongLatRadCenterCartesian3D_accurate_accurate}
22
-
23
18
  in vec2 center;
24
19
  in float radius;
25
20
  in float pad_range;
@@ -51,7 +46,7 @@ void main() {
51
46
 
52
47
  if ( is3D){
53
48
  gl_Position = projection * view * vec4(
54
- circleLimpFromLongLatRadCenterCartesian3D_accurate( center, radius_, angle) - translate, 1.0);
49
+ circleLimpFromLongLatRadCenterCartesian3D( center, radius_, angle) - translate, 1.0);
55
50
  v_limp = vec2(0.0, 0.0);
56
51
  return;
57
52
  }
@@ -111,6 +106,10 @@ class Logic {
111
106
  }
112
107
 
113
108
 
109
+ draw(vao, length, opaity) {
110
+
111
+ }
112
+
114
113
  draw(attrBufferManager, padCount, compass, opacity) {
115
114
  const { gl, program, _padCountLocation, cameraBlockBindingPoint, cameraBlockTotem, _compassLocation } = this;
116
115
  gl.useProgram(program);
@@ -1,8 +1,4 @@
1
1
  import { createProgram, shaderfunctions } from "../../../util";
2
- import {
3
- circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
4
- circleLimpFromLongLatRadCenterCartesian3D_accurate_accurate
5
- } from "../../../util/shaderfunctions/geometrytransformations";
6
2
  import CameraUniformBlockTotem, { CameraUniformBlockString } from "../../totems/camerauniformblock";
7
3
  import { globeProgramCache, noRegisterGlobeProgramCache } from "../../programcache";
8
4
 
@@ -14,12 +10,11 @@ const vertexShader = `#version 300 es ` +
14
10
  shaderfunctions.mercatorXYToGLPosition +
15
11
  shaderfunctions.longLatRadToMercator +
16
12
  shaderfunctions.longLatRadToCartesian3D +
13
+ shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
17
14
  shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
18
15
  shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistancePadding +
19
16
  shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
20
17
 
21
- ${circleLimpFromLongLatRadCenterCartesian3D_accurate_accurate}
22
-
23
18
  in vec2 center;
24
19
  in float radius;
25
20
  in float pad_range;
@@ -51,7 +46,7 @@ void main() {
51
46
 
52
47
  if ( is3D){
53
48
  gl_Position = projection * view * vec4(
54
- circleLimpFromLongLatRadCenterCartesian3D_accurate( center, radius_, angle) - translate, 1.0);
49
+ circleLimpFromLongLatRadCenterCartesian3D( center, radius_, angle) - translate, 1.0);
55
50
  v_limp = vec2(0.0, 0.0);
56
51
  return;
57
52
  }
@@ -19,7 +19,6 @@ const { circleProgramCache, PaddingProgramCache, CirclePaddySharedBuffer } = rin
19
19
  */
20
20
 
21
21
 
22
-
23
22
  export default class {
24
23
 
25
24
  constructor(id, { oneDegreePadding = true, compass = COMPASS_MODES.REAL, showNumbers = true, numbersStyle = null, opacity = 1 } = {}) {
@@ -73,11 +72,7 @@ export default class {
73
72
  }
74
73
 
75
74
 
76
- setOpacity(opacity) {
77
- this._opacity = opacity;
78
- this.textPlugin?.setOpacity(opacity); // TODO impolement this
79
- this.globe.DrawRender();
80
- }
75
+
81
76
 
82
77
  setGeometry() {
83
78
  this.textPlugin?.setGeometry();
@@ -97,6 +92,14 @@ export default class {
97
92
 
98
93
 
99
94
 
95
+
96
+ setOpacity(opacity) {
97
+ this._opacity = opacity;
98
+ this.textPlugin?.setOpacity(opacity); // TODO impolement this
99
+ this.globe.DrawRender();
100
+ }
101
+
102
+
100
103
  /**
101
104
  * @param {RangeRingData} rangeRingData
102
105
  * 0 compass limps
@@ -0,0 +1,7 @@
1
+
2
+ export const ENUM_HIDE = Object.freeze({ SHOW: 0, HIDE: 1, HIDE_1_DEGREE_PADDINGS: 2 });
3
+ export const ENUM_TEXT_HIDE = Object.freeze({ SHOW: 0, HIDE: 1 });
4
+ export const COMPASS_MODES = Object.freeze({
5
+ COMPASS: 1,
6
+ REAL: 0,
7
+ });
@@ -0,0 +1,4 @@
1
+ import { RangeRings } from "./plugin";
2
+ import RangeRingAngleText from './rangeringangletext';
3
+ import { ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES } from './enum';
4
+ export { RangeRings, ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES, RangeRingAngleText };