@pirireis/webglobeplugins 0.6.24-a → 0.6.25-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.
@@ -1,4 +1,4 @@
1
- // import { CSZMode } from "@pirireis/webglobe";
1
+ import { CSZMode, CSMeasureTextPositionTypes } from "@pirireis/webglobe";
2
2
 
3
3
  // const defaultStyle = {
4
4
  // textFont: {
@@ -49,16 +49,25 @@ export class PixelPaddingCompassTextWriter {
49
49
  this.northFont = northFont;
50
50
  this.doDraw = doDraw;
51
51
  this.angle = angle;
52
-
52
+ console.log("CSMeasureTextPositionTypes", CSMeasureTextPositionTypes);
53
53
  this.angles = []
54
54
  this.texts = []
55
+ this.positions = []
55
56
  let currentAngle = 0;
56
57
  while (currentAngle < 360) {
58
+ if (currentAngle > 180) {
59
+ this.positions.push(CSMeasureTextPositionTypes.CENTER);
60
+ } else {
61
+ this.positions.push(null);
62
+ }
57
63
  this.angles.push(currentAngle);
58
64
  if (currentAngle == 0) {
59
65
  this.texts.push("K");
60
66
  } else {
61
- this.texts.push(currentAngle.toString());
67
+ // to string 3 chars fill left with 0
68
+
69
+
70
+ this.texts.push(currentAngle.toString().padStart(3, '0'));
62
71
  }
63
72
  currentAngle += this.angle;
64
73
  }
@@ -92,7 +101,6 @@ export class PixelPaddingCompassTextWriter {
92
101
  _checkSetOffsets() {
93
102
  const { globe } = this;
94
103
  const newAngle = globe.api_GetCurrentLookInfo()["NorthAng"] * (Math.PI / 180);;
95
- console.log("n angle", newAngle);
96
104
  if (newAngle !== this._lastNorthAngle) {
97
105
  this._lastNorthAngle = newAngle;
98
106
  this.offsets = this.__offset();
@@ -102,7 +110,7 @@ export class PixelPaddingCompassTextWriter {
102
110
 
103
111
  draw() {
104
112
  if (!this.doDraw) return;
105
- const { globe, font, opacity: opacity_, northFont, itemMap, texts, angles } = this;
113
+ const { globe, font, opacity: opacity_, northFont, itemMap, texts, angles, positions } = this;
106
114
  this._checkSetOffsets();// zMode: CSZMode.Z_GROUND_PERVERTEX,
107
115
  const offsets = this.offsets;
108
116
  for (const [key, { center, radius, opacity = null }] of itemMap) {
@@ -111,6 +119,7 @@ export class PixelPaddingCompassTextWriter {
111
119
  offsets.forEach(({ offsetX, offsetY }, i) => {
112
120
  const text = texts[i];
113
121
  const angle = angles[i];
122
+ font.position = positions[i];
114
123
  if (angle === 0) {
115
124
  globe.api_DrawContextTextMultiLine(text, northFont, o, { x: center.x + offsetX * radius + xGapFit, y: center.y + offsetY * radius + yGapFit });
116
125
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.6.24-a",
3
+ "version": "0.6.25-a",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -1,5 +1,5 @@
1
1
  import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
2
- import { mercatorXYToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
2
+ import { mercatorXYToGLPosition, POLE } from "../../util/shaderfunctions/geometrytransformations";
3
3
  import { noRegisterGlobeProgramCache } from "../programcache";
4
4
  import { createProgram } from "../../util";
5
5
  import { vaoAttributeLoader } from "../../util/account/util";
@@ -25,26 +25,29 @@ in vec2 posA;
25
25
  in vec2 posB;
26
26
  in vec4 color;
27
27
 
28
+ out vec2 v_frame;
28
29
  out vec4 v_color;
29
-
30
30
  void main() {
31
+
31
32
  if ( is3D ) {
32
33
  return;
33
34
  }
35
+ float gap = distance(posA, posB);
34
36
  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_on == 1 || gap > 40000000.0){
38
+ z_alpha = z_level * z_level / ( gap / 100.0 );
37
39
  if( z_alpha < 0.1 ) {return;}
38
40
  if( z_alpha > 1.0 ) {z_alpha = 1.0;}
39
41
  } else {
40
42
  z_alpha = 1.0;
41
43
  }
42
44
  vec2 pos;
43
- if ( gl_VertexID == 0 ) {
44
- pos = posA;
45
- } else {
46
- pos = posB;
47
- }
45
+ if ( gl_VertexID == 0 ) {
46
+ pos = posA;
47
+ } else {
48
+ pos = posB;
49
+ }
50
+ v_frame = pos;
48
51
  gl_Position = mercatorXYToGLPosition( pos );
49
52
  v_color = color;
50
53
  v_color.a *= z_alpha * opacity;
@@ -53,10 +56,14 @@ void main() {
53
56
 
54
57
 
55
58
  const fragmentShaderSource = `#version 300 es
59
+ ${POLE}
56
60
  precision highp float;
57
61
  in vec4 v_color;
62
+ in vec2 v_frame;
58
63
  out vec4 outColor;
59
64
  void main() {
65
+ if ( v_frame.x < -POLE || v_frame.x > POLE || v_frame.y < -POLE || v_frame.y > POLE ){ discard; }
66
+
60
67
  outColor = v_color;
61
68
  }`;
62
69
 
@@ -41,6 +41,7 @@ void main() {
41
41
  gl_Position = cartesian3DToGLPosition(cartesian);
42
42
  v_limp = vec2(0.0, 0.0);
43
43
  } else {
44
+ if ( distance( start_position, end_position) > 30000000.0) { return; }
44
45
  interpolation = float(gl_VertexID);
45
46
  if (gl_VertexID % 2 == 0) {
46
47
  longLat = start_position;
@@ -17,15 +17,15 @@ vec3 coord_opacity(){
17
17
  float angle;
18
18
  float gap = (pixel_radius_big - pixel_radius_small);
19
19
  if( gl_VertexID % 2 == 0){
20
- if( gl_VertexID % 180 == 0){
21
- radius = pixel_radius_small ;
22
- }
23
- else if ( gl_VertexID % 60 == 0){
24
- radius = pixel_radius_small + gap * 0.5;
20
+ // if( gl_VertexID % 180 == 0){
21
+ // radius = pixel_radius_small ;
22
+ // } else
23
+ if ( gl_VertexID % 60 == 0){
24
+ radius = pixel_radius_small;
25
25
  } else if( gl_VertexID % 10 == 0) {
26
- radius = pixel_radius_small + gap * 0.75;
26
+ radius = pixel_radius_small + gap * 0.5;
27
27
  } else {
28
- radius = pixel_radius_small + gap* 0.90;
28
+ radius = pixel_radius_small + gap* 0.75;
29
29
  }
30
30
  angle = (float(gl_VertexID) / (${vertexCount}.0));
31
31
  } else {
@@ -1,29 +0,0 @@
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
- `;