@pirireis/webglobeplugins 0.6.15 → 0.6.17

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,5 +1,5 @@
1
- import { LineOnGlobeCache } from '../programs/line-on-globe/naive';
2
- import { CircleCache } from '../programs/line-on-globe/circle';
1
+ import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate';
2
+ import { CircleCache } from '../programs/line-on-globe/circle-accurate';
3
3
  import { LineToTheOriginCache } from "../programs/line-on-globe/to-the-origin"
4
4
  import { BufferOrchestrator, BufferManager } from "../util/account";
5
5
  import { ChainListMap } from "./chain-list-map";
@@ -84,13 +84,21 @@ export class CircleLineChainPlugin {
84
84
  const initialCapacity = this.bufferOrchestrator.capacity;
85
85
  this.bufferManagersCompMap = new Map(
86
86
  [
87
- ["centerCoords", {
87
+ ["centerCoords2d", {
88
88
  'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
89
- 'adaptor': (item) => new Float32Array([radian * item.long, radian * item.lat]),
89
+ 'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.long, item.lat)),
90
90
  }],
91
- ["targetCoords", {
91
+ ["centerCoords3d", {
92
+ 'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
93
+ 'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.long, item.lat, 0, 0)),
94
+ }],
95
+ ["targetCoords2d", {
92
96
  'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
93
- 'adaptor': (item) => new Float32Array([radian * item.targetLong, radian * item.targetLat])
97
+ 'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.targetLong, item.targetLat)),
98
+ }],
99
+ ["targetCoords3d", {
100
+ 'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
101
+ 'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.targetLong, item.targetLat, 0, 0)),
94
102
  }],
95
103
  ["rgba", {
96
104
  'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
@@ -133,11 +141,11 @@ export class CircleLineChainPlugin {
133
141
  return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 }
134
142
  };
135
143
  this.lineVao = this.lineProgram.createVAO(
136
- ...['centerCoords', 'targetCoords', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
144
+ ...['centerCoords2d', 'centerCoords3d', 'targetCoords2d', 'targetCoords3d', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
137
145
  this.circleVao = this.circleProgram.createVAO(
138
- ...["centerCoords", "bigRadius", "rgbaCircle", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
146
+ ...["centerCoords2d", "centerCoords3d", "bigRadius", "rgbaCircle", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
139
147
  this.toOriginVao = this.lineToTheOriginProgram.createVAO(
140
- ...["targetCoords", "rgba"].map(key => obj(this.bufferManagersCompMap.get(key))));
148
+ ...["targetCoords3d", "rgba"].map(key => obj(this.bufferManagersCompMap.get(key))));
141
149
  }
142
150
 
143
151
  }
@@ -384,8 +392,8 @@ export class CircleLineChainPlugin {
384
392
  this.lineProgram.draw(this.lineVao, this.bufferOrchestrator.length, this._opacity);
385
393
  if (this._drawCircleOn) this.circleProgram.draw(this.circleVao, this.bufferOrchestrator.length, this._opacity);
386
394
  this._textContextWriterInjectionMap.forEach((writer) => writer.draw());
387
- gl.enable(gl.DEPTH_TEST);
388
395
  this.lineToTheOriginProgram.draw(this.toOriginVao, this.bufferOrchestrator.length, this._opacity);
396
+ gl.enable(gl.DEPTH_TEST);
389
397
  }
390
398
  }
391
399
 
@@ -1,4 +1,4 @@
1
- import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate';
1
+ import { LineOnGlobeCache } from '../programs/line-on-globe/naive';
2
2
  import { CircleCache } from '../programs/line-on-globe/circle';
3
3
  import { LineToTheOriginCache } from "../programs/line-on-globe/to-the-origin"
4
4
  import { BufferOrchestrator, BufferManager } from "../util/account";
@@ -84,21 +84,13 @@ export class CircleLineChainPlugin {
84
84
  const initialCapacity = this.bufferOrchestrator.capacity;
85
85
  this.bufferManagersCompMap = new Map(
86
86
  [
87
- ["centerCoords2d", {
87
+ ["centerCoords", {
88
88
  'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
89
- 'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.long, item.lat)),
89
+ 'adaptor': (item) => new Float32Array([radian * item.long, radian * item.lat]),
90
90
  }],
91
- ["centerCoords3d", {
92
- 'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
93
- 'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.long, item.lat, 0, 0)),
94
- }],
95
- ["targetCoords2d", {
91
+ ["targetCoords", {
96
92
  'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
97
- 'adaptor': (item) => new Float32Array(globe.api_GetMercator2DPoint(item.targetLong, item.targetLat)),
98
- }],
99
- ["targetCoords3d", {
100
- 'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
101
- 'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.targetLong, item.targetLat, 0, 0)),
93
+ 'adaptor': (item) => new Float32Array([radian * item.targetLong, radian * item.targetLat])
102
94
  }],
103
95
  ["rgba", {
104
96
  'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
@@ -141,11 +133,11 @@ export class CircleLineChainPlugin {
141
133
  return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 }
142
134
  };
143
135
  this.lineVao = this.lineProgram.createVAO(
144
- ...['centerCoords2d', 'centerCoords3d', 'targetCoords2d', 'targetCoords3d', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
145
- // this.circleVao = this.circleProgram.createVAO(
146
- // ...["centerCoords", "bigRadius", "rgbaCircle", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
147
- // this.toOriginVao = this.lineToTheOriginProgram.createVAO(
148
- // ...["targetCoords", "rgba"].map(key => obj(this.bufferManagersCompMap.get(key))));
136
+ ...['centerCoords', 'targetCoords', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
137
+ this.circleVao = this.circleProgram.createVAO(
138
+ ...["centerCoords", "bigRadius", "rgbaCircle", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
139
+ this.toOriginVao = this.lineToTheOriginProgram.createVAO(
140
+ ...["targetCoords", "rgba"].map(key => obj(this.bufferManagersCompMap.get(key))));
149
141
  }
150
142
 
151
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.6.15",
3
+ "version": "0.6.17",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -0,0 +1,200 @@
1
+ import { createProgram } from "../../util/webglobjectbuilders";
2
+ import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
3
+ import { noRegisterGlobeProgramCache } from "../programcache";
4
+ import { vaoAttributeLoader } from "../../util/account/util";
5
+ import {
6
+ longLatRadToMercator, longLatRadToCartesian3D, cartesian3DToGLPosition, mercatorXYToGLPosition, realDistanceOnSphereR1,
7
+ circleLimpFromLongLatRadCenterCartesian3D_accurate,
8
+ circleLimpFromLongLatRadCenterMercatorCompass_accurate,
9
+ circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
10
+ POLE
11
+ } from "../../util/shaderfunctions/geometrytransformations";
12
+
13
+
14
+ /**
15
+ * TODO:
16
+ * 1. integrate geometry functions for radius angle and center
17
+ * 2. integrate attributes
18
+ *
19
+ * TODO:
20
+ * center_position is too small or doenst loaded as expected.
21
+ */
22
+ const EDGE_COUNT_ON_SPHERE = 360;
23
+
24
+ const vertexShaderSource = `#version 300 es
25
+ precision highp float;
26
+ ${CameraUniformBlockString}
27
+ ${longLatRadToMercator}
28
+ ${longLatRadToCartesian3D}
29
+ ${cartesian3DToGLPosition}
30
+ ${mercatorXYToGLPosition}
31
+ ${realDistanceOnSphereR1}
32
+ ${circleLimpFromLongLatRadCenterCartesian3D_accurate}
33
+ ${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
34
+ ${circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate}
35
+
36
+ uniform float edge_count;
37
+
38
+ in vec2 center_position;
39
+ in vec3 center_position3d;
40
+ in float radius;
41
+ in vec4 color;
42
+ in float dash_ratio;
43
+ in float dash_opacity;
44
+
45
+ out float interpolation;
46
+ out vec4 v_color;
47
+ out float v_dash_ratio;
48
+ out float v_dash_opacity;
49
+ out vec2 v_limp;
50
+ void main() {
51
+ interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE}.0;
52
+ float angle = PI * 2.0 * interpolation;
53
+ if ( is3D ) {
54
+
55
+ vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, radius, angle);
56
+
57
+ gl_Position = cartesian3DToGLPosition(position);
58
+ v_limp = vec2(0.0, 0.0);
59
+ } else {
60
+ vec2 position;
61
+ if ( radius < 1000.0) {
62
+ float cosine1 = cos(asin(tanh(center_position.y / 6378137.0)));
63
+ position = circleLimpFromLongLatRadCenterMercatorCompass_accurate(center_position, radius / cosine1 , angle);
64
+ } else {
65
+ position = circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate( center_position, radius, angle);
66
+ }
67
+ v_limp = position;
68
+ gl_Position = mercatorXYToGLPosition( position);
69
+
70
+ }
71
+ v_dash_ratio = dash_ratio;
72
+ v_dash_opacity = dash_opacity;
73
+ v_color = color;
74
+
75
+ }`
76
+
77
+ const fragmentShaderSource = `#version 300 es
78
+ ${POLE}
79
+ precision highp float;
80
+ uniform float opacity;
81
+ in vec4 v_color;
82
+ in float v_dash_ratio;
83
+ in float v_dash_opacity;
84
+ in float interpolation;
85
+ in vec2 v_limp;
86
+ out vec4 color;
87
+ void main() {
88
+ 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; }
89
+ color = v_color;
90
+ color.a *= opacity;
91
+ if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
92
+ if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
93
+ color.a *= v_dash_opacity;
94
+ }
95
+ }
96
+ `;
97
+
98
+
99
+
100
+ class Logic {
101
+
102
+ constructor(globe) {
103
+ this.globe = globe;
104
+ this.gl = globe.gl;
105
+ this._lastOpacity = 1.0;
106
+
107
+ this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
108
+
109
+ const { gl, program } = this;
110
+ this.program.uniforms = {
111
+ opacity: gl.getUniformLocation(program, "opacity")
112
+ };
113
+
114
+ { // initial uniform values
115
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
116
+ gl.useProgram(program);
117
+ gl.uniform1f(program.uniforms.opacity, 1.0);
118
+ gl.useProgram(currentProgram);
119
+ }
120
+
121
+ { // assign attribute locations
122
+ gl.bindAttribLocation(program, 0, "center_position");
123
+ gl.bindAttribLocation(program, 1, "center_position3d");
124
+ gl.bindAttribLocation(program, 2, "radius");
125
+ gl.bindAttribLocation(program, 3, "color");
126
+ gl.bindAttribLocation(program, 4, "dash_ratio");
127
+ gl.bindAttribLocation(program, 5, "dash_opacity");
128
+ }
129
+
130
+ this.cameraBindingPoint = 0;
131
+ this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
132
+ const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
133
+ gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
134
+ }
135
+
136
+ createVAO(centerObj, center3dObj, radiusObj, colorObj, dashRatioObj, dashOpacityObj) {
137
+ const { gl } = this;
138
+ const vao = gl.createVertexArray();
139
+ const divisor = 1;
140
+ gl.bindVertexArray(vao);
141
+ { // make this a function end import from account module.
142
+ const { buffer, stride = 0, offset = 0 } = centerObj;
143
+ vaoAttributeLoader(gl, buffer, 0, 2, stride, offset, divisor);
144
+ }
145
+ { // make this a function end import from account module.
146
+ const { buffer, stride = 0, offset = 0 } = center3dObj;
147
+ vaoAttributeLoader(gl, buffer, 1, 3, stride, offset, divisor);
148
+ }
149
+ {
150
+ const { buffer, stride = 0, offset = 0 } = radiusObj;
151
+ vaoAttributeLoader(gl, buffer, 2, 1, stride, offset, divisor);
152
+ }
153
+ {
154
+ const { buffer, stride = 0, offset = 0 } = colorObj;
155
+ vaoAttributeLoader(gl, buffer, 3, 4, stride, offset, divisor);
156
+ }
157
+ {
158
+ const { buffer, stride = 0, offset = 0 } = dashRatioObj;
159
+ vaoAttributeLoader(gl, buffer, 4, 1, stride, offset, divisor);
160
+ }
161
+ {
162
+ const { buffer, stride = 0, offset = 0 } = dashOpacityObj;
163
+ vaoAttributeLoader(gl, buffer, 5, 1, stride, offset, divisor);
164
+ }
165
+ gl.bindVertexArray(null);
166
+ gl.bindVertexArray(null);
167
+ return vao;
168
+ }
169
+
170
+ draw(vao, length, opacity) {
171
+ const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
172
+ gl.useProgram(program);
173
+
174
+ if (this._lastOpacity !== opacity) {
175
+ gl.uniform1f(program.uniforms.opacity, opacity);
176
+ this._lastOpacity = opacity;
177
+ }
178
+ gl.bindVertexArray(vao);
179
+ cameraBlockTotem.bind(cameraBindingPoint);
180
+ gl.drawArraysInstanced(gl.LINE_STRIP, 0, EDGE_COUNT_ON_SPHERE + 1, length);
181
+ cameraBlockTotem.unbind(cameraBindingPoint);
182
+ gl.bindVertexArray(null);
183
+ }
184
+
185
+
186
+
187
+ free() {
188
+ if (this.isFreed) return;
189
+ CameraUniformBlockTotemCache.release(this.globe);
190
+ this.gl.deleteProgram(this.program);
191
+ this.isFreed = true;
192
+ }
193
+ }
194
+
195
+
196
+
197
+ export const CircleCache = Object.freeze({
198
+ get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
199
+ release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
200
+ });
@@ -19,7 +19,7 @@ ${cartesian3DToGLPosition}
19
19
  in vec2 start_position;
20
20
  in vec3 start_poisition3d;
21
21
  in vec2 end_position;
22
- in vec3 end_position3;
22
+ in vec3 end_position3d;
23
23
  in float dash_ratio;
24
24
  in vec4 color;
25
25
  in float dash_opacity;
@@ -34,7 +34,7 @@ void main() {
34
34
  vec2 longLat;
35
35
  if (is3D) {
36
36
  interpolation = float(gl_VertexID) / ${GLOBE_MIDPOINT_COUNT - 1}.0;
37
- vec3 cartesian = pointsOnSphereBetween(start_poisition3d, end_position3, interpolation) * R_3D;
37
+ vec3 cartesian = pointsOnSphereBetween(start_poisition3d, end_position3d, interpolation) * length(end_position3d);
38
38
  gl_Position = cartesian3DToGLPosition(cartesian);
39
39
  v_limp = vec2(0.0, 0.0);
40
40
  } else {
@@ -18,7 +18,7 @@ ${R_3D}
18
18
  ${longLatRadToCartesian3DWithR}
19
19
  ${cartesian3DToGLPosition}
20
20
 
21
- in vec2 position2d;
21
+ in vec3 position3d;
22
22
  in vec4 rgba;
23
23
  uniform float origin_r;
24
24
  flat out vec4 v_rgba;
@@ -28,10 +28,10 @@ void main() {
28
28
  if (!is3D) {return;}
29
29
  vec3 cartesian;
30
30
  if(gl_VertexID == 0) {
31
- cartesian = longLatRadToCartesian3DWithR(position2d, R_3D);
31
+ cartesian = normalize( position3d) * R_3D;
32
32
  interpolation_value = 1.0;
33
33
  } else {
34
- cartesian = longLatRadToCartesian3DWithR(position2d, origin_r);
34
+ cartesian = position3d;
35
35
  interpolation_value = 0.0;
36
36
  }
37
37
  gl_Position = cartesian3DToGLPosition(cartesian);
@@ -48,11 +48,12 @@ in float interpolation_value;
48
48
  flat in vec4 v_rgba;
49
49
  out vec4 color;
50
50
  void main(){
51
- if ( fract( interpolation_value * 100.0) < 0.5) {discard;}
51
+ if ( fract( interpolation_value * 30.0) < 0.5) {discard;}
52
52
  color = vec4(
53
- v_rgba.rgb,
54
- v_rgba.a * plugin_opacity * interpolation_value * 0.9
53
+ v_rgba.rgb * 1.2,
54
+ v_rgba.a * plugin_opacity
55
55
  );
56
+
56
57
  }`;
57
58
 
58
59
 
@@ -65,7 +66,7 @@ class Logic {
65
66
  this._lastOriginR = 6378.137 - 1;
66
67
  const { gl, program } = this;
67
68
  {
68
- gl.bindAttribLocation(program, 0, "position2d");
69
+ gl.bindAttribLocation(program, 0, "position3d");
69
70
  gl.bindAttribLocation(program, 1, "rgba");
70
71
 
71
72
  }
@@ -105,12 +106,10 @@ class Logic {
105
106
  gl.uniform1f(this._originRLocation, originR);
106
107
  this._lastOriginR = originR;
107
108
  }
108
-
109
- // gl.disable(gl.DEPTH_TEST);
110
109
  gl.drawArraysInstanced(gl.LINE_STRIP, 0, 2, length);
110
+ gl.drawArraysInstanced(gl.POINTS, 0, 2, length);
111
111
  gl.bindVertexArray(null);
112
112
  cameraBlockTotem.unbind(cameraBlockBindingPoint);
113
- // gl.enable(gl.DEPTH_TEST);
114
113
  }
115
114
 
116
115
  _checkOpacity(opacity) {
@@ -122,15 +121,15 @@ class Logic {
122
121
  if (r < 0.0 || r > 6378.137 - 0.3) throw RangeError("r should be between 0 and 6378.137 - 0.3");
123
122
  }
124
123
 
125
- createVAO(potisionBufferObj, colorBufferObj) {
124
+ createVAO(potision3dBufferObj, colorBufferObj) {
126
125
  const { gl } = this;
127
126
  const vao = gl.createVertexArray();
128
127
  gl.bindVertexArray(vao);
129
128
  {
130
- const { buffer, stride = 0, offset = 0 } = potisionBufferObj;
129
+ const { buffer, stride = 0, offset = 0 } = potision3dBufferObj;
131
130
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
132
131
  gl.enableVertexAttribArray(0);
133
- gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
132
+ gl.vertexAttribPointer(0, 3, gl.FLOAT, false, stride, offset);
134
133
  gl.vertexAttribDivisor(0, 1);
135
134
  }
136
135
  {
@@ -118,6 +118,8 @@ vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float
118
118
  }
119
119
  `;
120
120
 
121
+
122
+
121
123
  // TODO: Make it precise. Y axis is not correct.
122
124
 
123
125
  export const circleLimpFromLongLatRadCenterMercatorRealDistanceNew = PI + `
@@ -306,7 +308,52 @@ const pointsOnSphereBetween = `vec3 pointsOnSphereBetween(vec3 a, vec3 b, float
306
308
  return normalize(result);
307
309
  }`
308
310
 
311
+
312
+ const circleLimpFromLongLatRadCenterCartesian3D_accurate = R + `
313
+ vec3 circleLimpFromLongLatRadCenterCartesian3D_accurate( vec3 geoW, float radius, float angle) {
314
+ vec3 normal = normalize(geoW);
315
+ vec3 tangent1 = cross(normal, vec3(0.0, 0.0, -1.0));
316
+ if ( length(tangent1) < 0.1 ){ tangent1 = cross(normal, vec3(0.0, -1.0, 0.0)); }
317
+ tangent1 = normalize(tangent1);
318
+ // rotate tangent with given angle
319
+ tangent1 = cos(angle) * tangent1 - sin(angle) * cross(normal, tangent1);
320
+ float radius_in_angle = radius/R;
321
+ float projected_radius = sin(radius_in_angle) * R / 1000.0;
322
+ return (geoW * cos(radius_in_angle))+ tangent1 * projected_radius;
323
+ }`;
324
+
325
+ const circleLimpFromLongLatRadCenterMercatorCompass_accurate = `
326
+ vec2 circleLimpFromLongLatRadCenterMercatorCompass_accurate(vec2 center, float radius, float angle){
327
+ float y = -sin(angle) * radius + center.y;
328
+ float x = cos(angle) * radius + center.x;
329
+ return vec2(x, y);
330
+ } `;
331
+
332
+ //TODO make it work...
333
+ const circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate = PI + `
334
+ vec2 circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate(vec2 mercator_center, float radius, float angle) {
335
+ vec2 center = vec2(mercator_center.x /6378137.0 , asin(tanh(mercator_center.y / 6378137.0 )));
336
+ float ang = angle + PI / 2.0; // Shift angle to align with +x axis
337
+ float r = radius / R;
338
+ float cos_r = cos(r);
339
+ float sin_r = sin(r);
340
+
341
+ float sin_lat = sin(center.y) * cos_r + cos(center.y) * sin_r * cos(ang);
342
+ float lat = asin(sin_lat);
343
+
344
+ float delta_long = atan(sin(ang) * sin_r * cos(center.y), cos_r - sin(center.y) * sin_lat);
345
+ float longi = center.x + delta_long;
346
+
347
+ return vec2(
348
+ R * longi,
349
+ R * log(tan(PI / 4.0 + lat / 2.0))
350
+ );
351
+ }`;
352
+
309
353
  export {
310
- pointsOnSphereBetween
354
+ pointsOnSphereBetween,
355
+ circleLimpFromLongLatRadCenterCartesian3D_accurate,
356
+ circleLimpFromLongLatRadCenterMercatorCompass_accurate,
357
+ circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate
311
358
 
312
359
  }