@pirireis/webglobeplugins 0.6.10 → 0.6.12

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.6.10",
3
+ "version": "0.6.12",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -55,8 +55,8 @@ void main() {
55
55
  v_limp = vec2(0.0, 0.0);
56
56
  } else {
57
57
  vec2 position;
58
- if (radius < 250.0) {
59
- position = circleLimpFromLongLatRadCenterMercatorCompass( center_position, radius, angle);
58
+ if (radius < 1400.0) {
59
+ position = circleLimpFromLongLatRadCenterMercatorCompass( center_position, radius/ cos(center_position.y), angle);
60
60
  } else {
61
61
  position = circleLimpFromLongLatRadCenterMercatorRealDistance( center_position, radius, angle);
62
62
  }
@@ -17,7 +17,8 @@ export const R = `
17
17
 
18
18
  export const PI = `
19
19
  #ifndef PI
20
- #define PI 3.1415926535897932384626433832795
20
+ #define PI 3.141592653589793
21
+
21
22
  #endif
22
23
  `;
23
24
 
@@ -77,6 +78,7 @@ export const longLatRadToMercator = R + PI + `
77
78
  vec2 longLatRadToMercator( vec2 longLatRad) {
78
79
  float x = R * longLatRad.x;
79
80
  float y = R * log( tan( PI / 4.0 + longLatRad.y / 2.0 ) );
81
+ y -= mix(-60.0, 60.0, abs(longLatRad.y + PI / 8.0) / (PI / 4.0));
80
82
  return vec2(x, y);
81
83
  }
82
84
  `;
@@ -110,13 +112,33 @@ vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float
110
112
 
111
113
  // TODO: Make it precise. Y axis is not correct.
112
114
 
115
+ export const circleLimpFromLongLatRadCenterMercatorRealDistanceNew = PI + `
116
+ vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle) {
117
+ float ang = angle + PI / 2.0; // Shift angle to align with +x axis
118
+ float r = radius / R;
119
+ float cos_r = cos(r);
120
+ float sin_r = sin(r);
121
+
122
+ float sin_lat = sin(center.y) * cos_r + cos(center.y) * sin_r * cos(ang);
123
+ float lat = asin(sin_lat);
124
+
125
+ float delta_long = atan(sin(ang) * sin_r * cos(center.y), cos_r - sin(center.y) * sin_lat);
126
+ float longi = center.x + delta_long;
127
+
128
+ return vec2(
129
+ R * longi,
130
+ R * log(tan(PI / 4.0 + lat / 2.0))
131
+ );
132
+ }`;
133
+
134
+
113
135
  export const circleLimpFromLongLatRadCenterMercatorRealDistance = PI + `
114
136
  vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle){
115
137
  float ang = angle + PI / 2.0; // this is there because the other methods are implemented in, angle 0 is +x axis orientatation
116
- float r = radius / R;
117
- float sin_lat = sin( center.y) * cos(r) + cos(center.y)*sin(r)* cos(ang);
138
+ float r = radius / R;
139
+ float sin_lat = sin(center.y) * cos(r) + cos(center.y) * sin(r) * cos(ang);
118
140
  float lat = asin(sin_lat);
119
- float longi = center.x + atan( sin(ang) * sin(r) * cos(center.y), cos(r) - sin(center.y) * sin_lat);
141
+ float longi = center.x + atan(sin(ang) * sin(r) * cos(center.y), cos(r) - sin(center.y) * sin_lat);
120
142
  return longLatRadToMercator(vec2(longi, lat));
121
143
  }
122
144
  `;
@@ -124,23 +146,23 @@ vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radiu
124
146
  // TODO: reconstruct this function
125
147
  export const circleLimpFromLongLatRadCenterMercatorRealDistancePadding = `
126
148
  vec2 circleLimpFromLongLatRadCenterMercatorRealDistancePadding(vec2 center, float radius, float angle){
127
- float radius_radian = radius / R;
149
+ float radius_radian = radius / R;
128
150
  float new_angle;
129
- if ( angle != - 1.5707963267948966192313216916398){
130
- float section = floor(angle / ( PI / 2.0)) + 1.0;
151
+ if (angle != - 1.5707963267948966192313216916398) {
152
+ float section = floor(angle / (PI / 2.0)) + 1.0;
131
153
  float lat = center.y - radius_radian * sin(angle);
132
- float scale = 1.0/abs( cos( lat ) );
133
- new_angle = atan( tan(angle) * scale );
134
- if ( section == 2.0 ){
135
- new_angle = mod( new_angle, PI );
136
- } else if ( section == 3.0 ){
137
- new_angle = new_angle + PI;
154
+ float scale = 1.0 / abs(cos(lat));
155
+ new_angle = atan(tan(angle) * scale);
156
+ if (section == 2.0) {
157
+ new_angle = mod(new_angle, PI);
158
+ } else if (section == 3.0) {
159
+ new_angle = new_angle + PI;
138
160
  }
139
161
  } else {
140
- new_angle = angle;
162
+ new_angle = angle;
141
163
  }
142
164
  float new_lat = center.y - radius_radian * sin(new_angle);
143
- float new_scale = 1.0/abs( cos( new_lat ) );
165
+ float new_scale = 1.0 / abs(cos(new_lat));
144
166
 
145
167
  vec2 center_ = longLatRadToMercator(center);
146
168
  float x = center_.x + new_scale * radius * cos(new_angle);
@@ -156,7 +178,7 @@ vec2 circleLimpFromLongLatRadCenterMercatorCompass(vec2 center, float radius, fl
156
178
  float y = -sin(angle) * radius + center_.y;
157
179
  float x = cos(angle) * radius + center_.x;
158
180
  return vec2(x, y);
159
- }`;
181
+ } `;
160
182
 
161
183
 
162
184
  // Function to interpolate between two Cartesian points using spherical interpolation (slerp)
@@ -186,7 +208,7 @@ vec2 cartesianToSpherical(vec3 point) {
186
208
  float lon = degrees(atan(point.y, point.x)); // Longitude
187
209
 
188
210
  return vec2(lat, lon);
189
- }`;
211
+ } `;
190
212
 
191
213
  // Main function to calculate an intermediate point
192
214
 
@@ -204,10 +226,10 @@ vec3 interpolateGeographicPoint(vec2 start, vec2 end, float t) {
204
226
 
205
227
  export const angleBetweenTwoPointsRadian = `
206
228
  float angleBetweenTwoPointsRadian(vec2 start_, vec2 end_) {
207
- float start_lat = log( tan( ( 1.0 - start_.y ) * PI / 2.0 ) );
208
- float end_lat = log( tan( ( 1.0 - end_.y ) * PI / 2.0 ) );
209
- float angle = atan( (end_lat - start_lat ) / (end_.x - start_.x));
210
- return angle;
229
+ float start_lat = log(tan((1.0 - start_.y) * PI / 2.0));
230
+ float end_lat = log(tan((1.0 - end_.y) * PI / 2.0));
231
+ float angle = atan((end_lat - start_lat) / (end_.x - start_.x));
232
+ return angle;
211
233
  }
212
234
  `
213
235