@pirireis/webglobeplugins 0.6.25-a → 0.6.26-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.
@@ -13,8 +13,8 @@ export class PixelPaddingCompassPlugin {
13
13
 
14
14
  defaultProperties = {
15
15
  rgba: [1, 1, 1, 1],
16
- pixelRadiusBig: 250,
17
- pixelRadiusSmall: 200
16
+ pixelRadiusRatioBig: 0.8,
17
+ pixelRadiusRatioSmall: 0.6,
18
18
  },
19
19
  font = {
20
20
  name: 'Arial',
@@ -50,6 +50,7 @@ export class PixelPaddingCompassPlugin {
50
50
 
51
51
  init(globe, gl) {
52
52
  this.globe = globe;
53
+ this.resize();
53
54
  this.gl = gl;
54
55
  if (this.textAngleOn) {
55
56
  this._createTextWriter();
@@ -63,8 +64,8 @@ export class PixelPaddingCompassPlugin {
63
64
  * @param {number} long
64
65
  * @param {number} lat
65
66
  * @typedef properties
66
- * @property {number} pixelRadiusBig
67
- * @property {number} pixelRadiusSmall
67
+ * @property {number} pixelRadiusRatioBig
68
+ * @property {number} pixelRadiusRatioSmall
68
69
  * @property {[4 numbers between 0-1]} rgba
69
70
  */
70
71
  insert(key, long, lat, properties = null) {
@@ -115,13 +116,13 @@ export class PixelPaddingCompassPlugin {
115
116
  'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
116
117
  'adaptor': (item) => new Float32Array([item.x, item.y])
117
118
  }],
118
- ["pixelRadiusSmall", {
119
+ ["pixelRadiusRatioSmall", {
119
120
  'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
120
- 'adaptor': (item) => new Float32Array([item.properties.pixelRadiusSmall])
121
+ 'adaptor': (item) => new Float32Array([item.properties.pixelRadiusRatioSmall])
121
122
  }],
122
- ["pixelRadiusBig", {
123
+ ["pixelRadiusRatioBig", {
123
124
  'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
124
- 'adaptor': (item) => new Float32Array([item.properties.pixelRadiusBig])
125
+ 'adaptor': (item) => new Float32Array([item.properties.pixelRadiusRatioBig])
125
126
  }],
126
127
  ["rgba", {
127
128
  'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
@@ -134,7 +135,7 @@ export class PixelPaddingCompassPlugin {
134
135
  return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 }
135
136
  };
136
137
  this.paddingVao = this.paddingProgram.createVAO(
137
- ...['screenCoordinates', 'pixelRadiusSmall', 'pixelRadiusBig', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
138
+ ...['screenCoordinates', 'pixelRadiusRatioSmall', 'pixelRadiusRatioBig', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
138
139
  }
139
140
  }
140
141
 
@@ -143,15 +144,19 @@ export class PixelPaddingCompassPlugin {
143
144
  }
144
145
 
145
146
 
147
+ resize() {
148
+ this.writer?.resize();
149
+ }
150
+
146
151
 
147
152
  __insertText(key, x, y, { properties, update = false } = {}) {
148
153
  if (!this.writer) return;
149
154
  if (update) {
150
155
  let radius;
151
- if (properties != null && properties.pixelRadiusBig) {
152
- radius = properties.pixelRadiusBig
156
+ if (properties != null && properties.pixelRadiusRatioBig) {
157
+ radius = properties.pixelRadiusRatioBig * this.radiusMultiplier;
153
158
  } else {
154
- radius = this.defaultProperties.pixelRadiusBig;
159
+ radius = this.defaultProperties.pixelRadiusRatioBig * this.radiusMultiplier;
155
160
  }
156
161
  this.writer.insertTextItem(key, x, y, radius + textGapFit);
157
162
  } else {
@@ -185,6 +190,23 @@ export class PixelPaddingCompassPlugin {
185
190
  })
186
191
 
187
192
  }
193
+
194
+ resize() {
195
+ this.radiusMultiplier = this._shorterDimension() * 0.5;
196
+ this._reinsertAllText();
197
+ }
198
+
199
+
200
+ _reinsertAllText() {
201
+ this.compassMap.query(this.globe, this.writer).forEach((v) => {
202
+ this.__insertText(v.key, v.x, v.y, { properties: v.properties, update: true });
203
+ });
204
+ }
205
+
206
+ _shorterDimension() {
207
+ const globe = this.globe;
208
+ return Math.min(globe.api_ScrW(), globe.api_ScrH());
209
+ }
188
210
  }
189
211
 
190
212
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.6.25-a",
3
+ "version": "0.6.26-a",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -6,8 +6,8 @@ const vertexShaderSource = `#version 300 es
6
6
  ${CameraUniformBlockString}
7
7
 
8
8
  in vec2 screen_coordinate;
9
- in float pixel_radius_small;
10
- in float pixel_radius_big;
9
+ in float pixel_radius_small_ratio;
10
+ in float pixel_radius_big_ratio;
11
11
  in vec4 rgba;
12
12
  out vec4 v_rgba;
13
13
  uniform float plugin_opacity;
@@ -15,31 +15,31 @@ uniform float plugin_opacity;
15
15
  vec3 coord_opacity(){
16
16
  float radius;
17
17
  float angle;
18
- float gap = (pixel_radius_big - pixel_radius_small);
18
+ float gap = (pixel_radius_big_ratio - pixel_radius_small_ratio);
19
19
  if( gl_VertexID % 2 == 0){
20
20
  // if( gl_VertexID % 180 == 0){
21
- // radius = pixel_radius_small ;
21
+ // radius = pixel_radius_small_ratio ;
22
22
  // } else
23
23
  if ( gl_VertexID % 60 == 0){
24
- radius = pixel_radius_small;
24
+ radius = pixel_radius_small_ratio;
25
25
  } else if( gl_VertexID % 10 == 0) {
26
- radius = pixel_radius_small + gap * 0.5;
26
+ radius = pixel_radius_small_ratio + gap * 0.5;
27
27
  } else {
28
- radius = pixel_radius_small + gap* 0.75;
28
+ radius = pixel_radius_small_ratio + gap* 0.75;
29
29
  }
30
30
  angle = (float(gl_VertexID) / (${vertexCount}.0));
31
31
  } else {
32
32
  if ( gl_VertexID % 180 == 1){
33
- radius = pixel_radius_big + gap * 0.1;
33
+ radius = pixel_radius_big_ratio + gap * 0.1;
34
34
 
35
35
  } else {
36
- radius = pixel_radius_big;
36
+ radius = pixel_radius_big_ratio;
37
37
  }
38
38
  angle = (float(gl_VertexID - 1) / (${vertexCount}.0));
39
39
  }
40
40
  float opacity = fract(angle + 0.2475) / 1.5 + 0.33;
41
41
  angle = angle * ${Math.PI * 2.0} + world_north_angle;
42
-
42
+ radius = radius * min(screenWH.x, screenWH.y) / 2.0;;
43
43
  return vec3( screen_coordinate + vec2( cos(angle), sin(angle)) * radius, opacity);
44
44
  }
45
45
 
@@ -78,13 +78,13 @@ class Logic {
78
78
  const { gl, program } = this;
79
79
  { // assign attribute locations
80
80
  // in vec2 screen_coordinate;
81
- // in float pixel_radius_small;
82
- // in float pixel_radius_big;
81
+ // in float pixel_radius_small_ratio;
82
+ // in float pixel_radius_big_ratio;
83
83
  // in vec4 rgba;
84
84
 
85
85
  gl.bindAttribLocation(program, 0, "screen_coordinate");
86
- gl.bindAttribLocation(program, 1, "pixel_radius_small");
87
- gl.bindAttribLocation(program, 2, "pixel_radius_big");
86
+ gl.bindAttribLocation(program, 1, "pixel_radius_small_ratio");
87
+ gl.bindAttribLocation(program, 2, "pixel_radius_big_ratio");
88
88
  gl.bindAttribLocation(program, 3, "rgba");
89
89
  }
90
90
  {
@@ -118,7 +118,7 @@ class Logic {
118
118
  cameraBlockTotem.unbind(cameraBlockBindingPoint);
119
119
  }
120
120
 
121
- createVAO(screenCoordsBufferObj, pixelRadiusSmallBufferObj, pixelRadiusBigBufferObj, rgbaBufferObj) {
121
+ createVAO(screenCoordsBufferObj, pixelRadiusRatioSmallBufferObj, pixelRadiusRatioBigBufferObj, rgbaBufferObj) {
122
122
  const { gl } = this;
123
123
  const vao = gl.createVertexArray();
124
124
  gl.bindVertexArray(vao);
@@ -130,14 +130,14 @@ class Logic {
130
130
  gl.vertexAttribDivisor(0, 1);
131
131
  }
132
132
  {
133
- const { buffer, stride = 0, offset = 0 } = pixelRadiusSmallBufferObj;
133
+ const { buffer, stride = 0, offset = 0 } = pixelRadiusRatioSmallBufferObj;
134
134
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
135
135
  gl.enableVertexAttribArray(1);
136
136
  gl.vertexAttribPointer(1, 1, gl.FLOAT, false, stride, offset);
137
137
  gl.vertexAttribDivisor(1, 1);
138
138
  }
139
139
  {
140
- const { buffer, stride = 0, offset = 0 } = pixelRadiusBigBufferObj;
140
+ const { buffer, stride = 0, offset = 0 } = pixelRadiusRatioBigBufferObj;
141
141
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
142
142
  gl.enableVertexAttribArray(2);
143
143
  gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
@@ -356,7 +356,7 @@ export default class RangeRingAngleText {
356
356
  // fidkey is the key
357
357
  attribs.push({
358
358
  "__fid__": key,
359
- "aci": (360 - aci).toString()
359
+ "aci": (360 - aci).toString().padStart(3, '0')
360
360
  })
361
361
  aci += stepAngle;
362
362
  }