@pirireis/webglobeplugins 0.9.9 → 0.9.10

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.
Files changed (211) hide show
  1. package/Math/angle-calculation.js +15 -0
  2. package/Math/arc.js +65 -0
  3. package/Math/bounds/line-bbox.js +188 -0
  4. package/Math/constants.js +9 -0
  5. package/Math/frustum/camera.js +24 -0
  6. package/Math/frustum/from-globeinfo.js +48 -0
  7. package/Math/frustum/types.js +2 -0
  8. package/Math/globe-util/horizon-plane.js +112 -0
  9. package/Math/index.js +1 -0
  10. package/Math/juction/arc-plane.js +83 -0
  11. package/Math/juction/line-sphere.js +25 -0
  12. package/Math/juction/plane-plane.js +58 -0
  13. package/Math/line.js +56 -0
  14. package/Math/matrix4.js +1 -0
  15. package/Math/methods.js +201 -0
  16. package/Math/plane.js +60 -0
  17. package/Math/quaternion.js +104 -0
  18. package/Math/types.js +2 -0
  19. package/Math/utils.js +4 -0
  20. package/Math/vec3.js +126 -0
  21. package/algorithms/search-binary.js +19 -0
  22. package/altitude-locator/adaptors.js +1 -0
  23. package/altitude-locator/draw-subset-obj.js +18 -0
  24. package/altitude-locator/keymethod.js +1 -0
  25. package/altitude-locator/plugin.js +341 -0
  26. package/altitude-locator/types.js +23 -0
  27. package/arrowfield/adaptor.js +14 -0
  28. package/arrowfield/index.js +10 -0
  29. package/arrowfield/plugin.js +86 -0
  30. package/bearing-line/index.js +8 -0
  31. package/bearing-line/plugin.js +449 -0
  32. package/circle-line-chain/chain-list-map.js +205 -0
  33. package/circle-line-chain/init.js +1 -0
  34. package/circle-line-chain/plugin.js +424 -0
  35. package/circle-line-chain/util.js +5 -0
  36. package/compass-rose/compass-rose-padding-flat.js +225 -0
  37. package/compass-rose/compass-text-writer.js +153 -0
  38. package/compass-rose/index.js +7 -0
  39. package/compassrose/compassrose.js +296 -0
  40. package/compassrose/index.js +8 -0
  41. package/globe-types.js +1 -0
  42. package/heatwave/index.js +10 -0
  43. package/heatwave/isobar/objectarraylabels.js +202 -0
  44. package/heatwave/isobar/plugin.js +343 -0
  45. package/heatwave/isobar/quadtreecontours.js +300 -0
  46. package/heatwave/plugins/heatwaveglobeshell.js +206 -0
  47. package/jest.config.js +7 -0
  48. package/package.json +4 -4
  49. package/partialrings/buffer-manager.js +81 -0
  50. package/partialrings/index.js +41 -0
  51. package/partialrings/plugin.js +135 -0
  52. package/partialrings/program.js +286 -0
  53. package/pin/pin-object-array.js +305 -0
  54. package/pin/pin-point-totem.js +60 -0
  55. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
  56. package/point-heat-map/index.js +1 -0
  57. package/point-heat-map/plugin-webworker.js +126 -0
  58. package/point-heat-map/point-to-heat-map-flow.js +127 -0
  59. package/point-tracks/key-methods.js +5 -0
  60. package/point-tracks/plugin.js +338 -0
  61. package/programs/arrowfield/index.js +7 -0
  62. package/programs/arrowfield/logic.js +257 -0
  63. package/programs/arrowfield/object.js +66 -0
  64. package/programs/data2legend/density-to-legend.js +101 -0
  65. package/programs/data2legend/point-to-density-texture.js +100 -0
  66. package/programs/float2legendwithratio/index.js +8 -0
  67. package/programs/float2legendwithratio/logic.js +171 -0
  68. package/programs/float2legendwithratio/object.js +110 -0
  69. package/programs/globe-util/is-globe-moved.js +21 -0
  70. package/programs/globeshell/index.js +8 -0
  71. package/programs/globeshell/noise/noises.js +1 -0
  72. package/programs/globeshell/wiggle/index.js +8 -0
  73. package/programs/globeshell/wiggle/logic.js +345 -0
  74. package/programs/globeshell/wiggle/object.js +72 -0
  75. package/programs/helpers/blender/index.js +1 -0
  76. package/programs/helpers/blender/program.js +79 -0
  77. package/programs/helpers/fadeaway/index.js +7 -0
  78. package/programs/helpers/fadeaway/logic.js +72 -0
  79. package/programs/helpers/fadeaway/object.js +20 -0
  80. package/programs/helpers/index.js +8 -0
  81. package/programs/index.js +58 -0
  82. package/programs/interface.js +1 -0
  83. package/programs/line-on-globe/angled-line.js +176 -0
  84. package/programs/line-on-globe/circle-accurate-3d.js +141 -0
  85. package/programs/line-on-globe/circle-accurate-flat.js +216 -0
  86. package/programs/line-on-globe/circle-accurate.js +178 -0
  87. package/programs/line-on-globe/circle.js +167 -0
  88. package/programs/line-on-globe/degree-padding-around-circle-3d.js +159 -0
  89. package/programs/line-on-globe/index.js +1 -0
  90. package/programs/line-on-globe/lines-color-instanced-flat.js +136 -0
  91. package/programs/line-on-globe/linestrip.js +171 -0
  92. package/programs/line-on-globe/naive-accurate-flexible.js +195 -0
  93. package/programs/line-on-globe/to-the-surface.js +111 -0
  94. package/programs/line-on-globe/util.js +8 -0
  95. package/programs/picking/pickable-renderer.js +188 -0
  96. package/programs/point-on-globe/element-globe-surface-glow.js +142 -0
  97. package/programs/point-on-globe/element-point-glow.js +153 -0
  98. package/programs/point-on-globe/square-pixel-point.js +174 -0
  99. package/programs/programcache.js +131 -0
  100. package/programs/rings/distancering/circleflatprogram.js +156 -0
  101. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +369 -0
  102. package/programs/rings/distancering/circlepaddysharedbuffer.js +357 -0
  103. package/programs/rings/distancering/index.js +14 -0
  104. package/programs/rings/distancering/paddyflatprogram.js +172 -0
  105. package/programs/rings/distancering/paddyflatprogram2d.js +174 -0
  106. package/programs/rings/distancering/paddyflatprogram3d.js +172 -0
  107. package/programs/rings/distancering/shader.js +1 -0
  108. package/programs/rings/index.js +17 -0
  109. package/programs/rings/partial-ring/piece-of-pie.js +275 -0
  110. package/programs/totems/camerauniformblock.js +160 -0
  111. package/programs/totems/canvas-webglobe-info.js +110 -0
  112. package/programs/totems/gpu-selection-uniform-block.js +108 -0
  113. package/programs/totems/index.js +40 -0
  114. package/programs/two-d/pixel-circle.js +1 -0
  115. package/programs/two-d/pixel-padding-for-compass.js +162 -0
  116. package/programs/util.js +17 -0
  117. package/programs/vectorfields/index.js +23 -0
  118. package/programs/vectorfields/logics/drawrectangleparticles.js +107 -0
  119. package/programs/vectorfields/logics/index.js +12 -0
  120. package/programs/vectorfields/logics/pixelbased.js +142 -0
  121. package/programs/vectorfields/logics/ubo.js +63 -0
  122. package/programs/vectorfields/pingpongbuffermanager.js +76 -0
  123. package/rangerings/enum.js +5 -0
  124. package/rangerings/index.js +15 -0
  125. package/rangerings/plugin.js +560 -0
  126. package/rangerings/rangeringangletext.js +329 -0
  127. package/rangerings/ring-account.js +117 -0
  128. package/shaders/fragment-toy/firework.js +58 -0
  129. package/shaders/fragment-toy/singularity.js +59 -0
  130. package/shape-on-terrain/arc/naive/plugin.js +252 -0
  131. package/timetracks/adaptors-line-strip.js +71 -0
  132. package/timetracks/adaptors.js +122 -0
  133. package/timetracks/index.js +19 -0
  134. package/timetracks/plugin-line-strip.js +250 -0
  135. package/timetracks/plugin.js +258 -0
  136. package/timetracks/program-line-strip.js +611 -0
  137. package/timetracks/program.js +772 -0
  138. package/timetracks/programpoint-line-strip.js +154 -0
  139. package/timetracks/programpoint.js +147 -0
  140. package/types.js +15 -0
  141. package/util/account/bufferoffsetmanager.js +179 -0
  142. package/util/account/index.js +23 -0
  143. package/util/account/single-attribute-buffer-management/buffer-manager.js +108 -0
  144. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +150 -0
  145. package/util/account/single-attribute-buffer-management/index.js +9 -0
  146. package/util/account/single-attribute-buffer-management/object-store.js +51 -0
  147. package/util/account/single-attribute-buffer-management/types.js +2 -0
  148. package/util/account/util.js +22 -0
  149. package/util/algorithms/index.js +1 -0
  150. package/util/algorithms/search-binary.js +28 -0
  151. package/util/check/get.js +18 -0
  152. package/util/check/index.js +1 -0
  153. package/util/check/typecheck.js +49 -0
  154. package/util/geometry/index.js +51 -0
  155. package/util/gl-util/buffer/attribute-loader.js +69 -0
  156. package/util/gl-util/buffer/index.js +6 -0
  157. package/util/gl-util/buffer/types.js +1 -0
  158. package/util/gl-util/draw-options/methods.js +38 -0
  159. package/util/gl-util/draw-options/types.js +15 -0
  160. package/util/gl-util/uniform-block/manager.js +156 -0
  161. package/util/gl-util/uniform-block/shader.js +1 -0
  162. package/util/gl-util/uniform-block/types.js +8 -0
  163. package/util/heatwavedatamanager/datamanager.js +152 -0
  164. package/util/heatwavedatamanager/index.js +10 -0
  165. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +122 -0
  166. package/util/heatwavedatamanager/pointcoordsmeta.js +20 -0
  167. package/util/index.js +57 -0
  168. package/util/interpolation/index.js +1 -0
  169. package/util/interpolation/timetrack/index.js +5 -0
  170. package/util/interpolation/timetrack/timetrack-interpolator.js +79 -0
  171. package/util/interpolation/timetrack/web-worker-str.js +183 -0
  172. package/util/interpolation/timetrack/web-worker.js +48 -0
  173. package/util/jshelpers/data-filler.js +20 -0
  174. package/util/jshelpers/equality.js +20 -0
  175. package/util/jshelpers/index.js +37 -0
  176. package/util/jshelpers/timefilters.js +32 -0
  177. package/util/picking/fence.js +46 -0
  178. package/util/picking/picker-displayer.js +139 -0
  179. package/util/programs/draw-texture-on-canvas.js +89 -0
  180. package/util/programs/index.js +17 -0
  181. package/util/programs/shapesonglobe.js +214 -0
  182. package/util/programs/supersampletotextures.js +113 -0
  183. package/util/programs/texturetoglobe.js +182 -0
  184. package/util/shaderfunctions/geometrytransformations.js +340 -0
  185. package/util/shaderfunctions/index.js +18 -0
  186. package/util/shaderfunctions/nodata.js +11 -0
  187. package/util/shaderfunctions/noisefunctions.js +43 -0
  188. package/util/surface-line-data/arc-bboxes.js +25 -0
  189. package/util/surface-line-data/arcs-to-cuts.js +50 -0
  190. package/util/surface-line-data/cut-arc.js +1 -0
  191. package/util/surface-line-data/flow.js +28 -0
  192. package/util/surface-line-data/rbush-manager.js +1 -0
  193. package/util/surface-line-data/types.js +1 -0
  194. package/util/surface-line-data/web-worker.js +1 -0
  195. package/util/webglobe/gldefaultstates.js +7 -0
  196. package/util/webglobe/index.js +18 -0
  197. package/util/webglobe/rasteroverlay.js +78 -0
  198. package/util/webglobjectbuilders.js +388 -0
  199. package/util/webglobjectbuilders1.js +237 -0
  200. package/waveparticles/adaptor.js +17 -0
  201. package/waveparticles/index.js +10 -0
  202. package/waveparticles/plugin.js +266 -0
  203. package/wind/imagetovectorfieldandmagnitude.js +35 -0
  204. package/wind/index.js +14 -0
  205. package/wind/plugin.js +926 -0
  206. package/wind/vectorfieldimage.js +25 -0
  207. package/write-text/attached-text-writer.js +91 -0
  208. package/write-text/context-text.js +98 -0
  209. package/write-text/context-text3.js +155 -0
  210. package/write-text/index.js +5 -0
  211. package/write-text/writer-plugin.js +8 -0
@@ -0,0 +1,340 @@
1
+ "use strict";
2
+ // Z in kolometers
3
+ //
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.circleOnSphere = exports.circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate = exports.circleLimpFromLongLatRadCenterMercatorCompass_accurate = exports.circleLimpFromLongLatRadCenterCartesian3D_accurate = exports.slerp = exports.realDistanceOnSphereR1 = exports.circleCircumferenceInterPolationOf2PointsRadian = exports.angleBetweenTwoPointsRadian = exports.cartesianToSpherical = exports.circleLimpFromLongLatRadCenterMercatorCompass = exports.circleLimpFromLongLatRadCenterMercatorRealDistancePadding = exports.circleLimpFromLongLatRadCenterMercatorRealDistance = exports.circleLimpFromLongLatRadCenterMercatorRealDistanceNew = exports.circleLimpFromLongLatRadCenterCartesian3D = exports.longLatRadToCartesian3DWithR = exports.longLatRadToCartesian3D = exports.longLatRadToMercator = exports.cartesian3DToGLPosition = exports.mercatorXYToGLPosition = exports.pixelXYToCartesian2DPoint = exports.pixelXYToCartesian3DPoint = exports.R_3D = exports.POLE_BY_PI = exports.PI = exports.R = exports.POLE = void 0;
6
+ exports.POLE = `
7
+ #ifndef POLE
8
+ #define POLE 20037508.34
9
+ #endif
10
+ `;
11
+ exports.R = `
12
+ #ifndef R
13
+ #define R 6378137.0
14
+ #endif
15
+ `;
16
+ exports.PI = `
17
+ #ifndef PI
18
+ #define PI 3.141592653589793
19
+
20
+ #endif
21
+ `;
22
+ exports.POLE_BY_PI = `
23
+ #ifndef POLE_BY_PI
24
+ #define POLE_BY_PI 6378137.0
25
+ #endif
26
+ `;
27
+ exports.R_3D = `
28
+ #ifndef R_3D
29
+ #define R_3D 6378.137
30
+ #endif
31
+ `;
32
+ exports.pixelXYToCartesian3DPoint = exports.R_3D + exports.PI + `
33
+ vec3 pixelXYToCartesian3DPoint( vec3 position) {
34
+ float longRad = PI * (2.0 * position.x - 1.0);
35
+ float latRad = PI * position.y;
36
+ float radius = R_3D + position.z;
37
+ float x = radius * sin(latRad) * cos(longRad);
38
+ float y = radius * sin(latRad) * sin(longRad);
39
+ float z = radius * cos(latRad);
40
+ return vec3(x, y, z);
41
+ }
42
+ `;
43
+ exports.pixelXYToCartesian2DPoint = exports.PI + exports.POLE + exports.POLE_BY_PI + `
44
+ vec2 pixelXYToCartesian2DPoint( vec2 position, vec2 translate, vec2 mapWH, vec2 screenWH) {
45
+ float x = (2.0 * position.x - 1.0) * POLE;
46
+ x = ((x - translate.x) / mapWH.x) * screenWH.x;
47
+ float y = log( tan( ( 1.0 - position.y ) * PI / 2.0 ) ) * POLE_BY_PI;
48
+ y = (1.0 - (y - translate.y) / mapWH.y) * screenWH.y;
49
+ return vec2(x, y);
50
+ }
51
+ `;
52
+ // TODO: rename it to mercatorXYToGLPosition
53
+ exports.mercatorXYToGLPosition = `
54
+ vec4 mercatorXYToGLPosition( vec2 position) { // projection, translate, mapWH, screenWH comes from camera uniform block
55
+ float x = (( position.x - translate.x ) / mapWH.x) * screenWH.x;
56
+ float y = (1.0 - (position.y - translate.y) / mapWH.y) * screenWH.y;
57
+ return projection * vec4(x, y, 0.0, 1.0);
58
+ }
59
+ `;
60
+ exports.cartesian3DToGLPosition = `
61
+ vec4 cartesian3DToGLPosition( vec3 position) {
62
+ return projection * view * vec4(position - translate, 1.0);
63
+ }
64
+ `;
65
+ // pi / pole = 2 / R
66
+ exports.longLatRadToMercator = exports.R + exports.PI + `
67
+ vec2 longLatRadToMercator( vec2 longLatRad) {
68
+ float x = R * longLatRad.x;
69
+ float y = R * log( tan( PI / 4.0 + longLatRad.y / 2.0 ) );
70
+ y -= mix(-60.0, 60.0, abs(longLatRad.y + PI / 8.0) / (PI / 4.0));
71
+ return vec2(x, y);
72
+ }
73
+ `;
74
+ exports.longLatRadToCartesian3D = exports.R_3D + `
75
+ vec3 longLatRadToCartesian3D( vec2 longLat) {
76
+ float x = R_3D * cos(longLat.y) * cos(longLat.x);
77
+ float y = R_3D * cos(longLat.y) * sin(longLat.x);
78
+ float z = R_3D * sin(longLat.y);
79
+ return vec3(x, y, z);
80
+ }
81
+ `;
82
+ exports.longLatRadToCartesian3DWithR = `
83
+ vec3 longLatRadToCartesian3DWithR( vec2 longLat, float radius) {
84
+ float x = radius * cos(longLat.y) * cos(longLat.x);
85
+ float y = radius * cos(longLat.y) * sin(longLat.x);
86
+ float z = radius * sin(longLat.y);
87
+ return vec3(x, y, z);
88
+ }
89
+ `;
90
+ // TODO: Make it precise. It doesnt use haversine formula. If this changes, change the formmula which calculates text position.
91
+ exports.circleLimpFromLongLatRadCenterCartesian3D = exports.R + `
92
+ vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float angle) {
93
+ vec3 geoW = longLatRadToCartesian3D(center);
94
+ vec3 normal = normalize(geoW);
95
+ vec3 tangent1 = cross(normal, vec3(0.0, 0.0, -1.0));
96
+ if ( length(tangent1) < 0.1 ){ tangent1 = cross(normal, vec3(0.0, -1.0, 0.0)); }
97
+ tangent1 = normalize(tangent1);
98
+ // rotate tangent with given angle
99
+ tangent1 = cos(angle) * tangent1 - sin(angle) * cross(normal, tangent1);
100
+ float radius_in_angle = radius/R;
101
+ float projected_radius = sin(radius_in_angle) * R / 1000.0;
102
+ return (geoW * cos(radius_in_angle))+ tangent1 * projected_radius;
103
+ }
104
+ `;
105
+ // TODO: Make it precise. Y axis is not correct.
106
+ exports.circleLimpFromLongLatRadCenterMercatorRealDistanceNew = exports.PI + `
107
+ vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle) {
108
+ float ang = angle + PI / 2.0; // Shift angle to align with +x axis
109
+ float r = radius / R;
110
+ float cos_r = cos(r);
111
+ float sin_r = sin(r);
112
+
113
+ float sin_lat = sin(center.y) * cos_r + cos(center.y) * sin_r * cos(ang);
114
+ float lat = asin(sin_lat);
115
+
116
+ float delta_long = atan(sin(ang) * sin_r * cos(center.y), cos_r - sin(center.y) * sin_lat);
117
+ float longi = center.x + delta_long;
118
+
119
+
120
+ return vec2(
121
+ R * longi,
122
+ R * log(tan(PI / 4.0 + lat / 2.0))
123
+ );
124
+ }`;
125
+ exports.circleLimpFromLongLatRadCenterMercatorRealDistance = exports.PI + `
126
+ vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle){
127
+ float ang = angle + PI / 2.0; // this is there because the other methods are implemented in, angle 0 is +x axis orientatation
128
+ float r = radius / R;
129
+ float sin_lat = sin(center.y) * cos(r) + cos(center.y) * sin(r) * cos(ang);
130
+ float lat = asin(sin_lat);
131
+ float longi = center.x + atan(sin(ang) * sin(r) * cos(center.y), cos(r) - sin(center.y) * sin_lat);
132
+ return longLatRadToMercator(vec2(longi, lat));
133
+ }
134
+ `;
135
+ // TODO: reconstruct this function
136
+ exports.circleLimpFromLongLatRadCenterMercatorRealDistancePadding = `
137
+ vec2 circleLimpFromLongLatRadCenterMercatorRealDistancePadding(vec2 center, float radius, float angle){
138
+ float radius_radian = radius / R;
139
+ float new_angle;
140
+ if (angle != - 1.5707963267948966192313216916398) {
141
+ float section = floor(angle / (PI / 2.0)) + 1.0;
142
+ float lat = center.y - radius_radian * sin(angle);
143
+ float scale = 1.0 / abs(cos(lat));
144
+ new_angle = atan(tan(angle) * scale);
145
+ if (section == 2.0) {
146
+ new_angle = mod(new_angle, PI);
147
+ } else if (section == 3.0) {
148
+ new_angle = new_angle + PI;
149
+ }
150
+ } else {
151
+ new_angle = angle;
152
+ }
153
+ float new_lat = center.y - radius_radian * sin(new_angle);
154
+ float new_scale = 1.0 / abs(cos(new_lat));
155
+
156
+ vec2 center_ = longLatRadToMercator(center);
157
+ float x = center_.x + new_scale * radius * cos(new_angle);
158
+ float y = center_.y - new_scale * radius * sin(new_angle);
159
+ return vec2(x, y);
160
+ }
161
+ `;
162
+ exports.circleLimpFromLongLatRadCenterMercatorCompass = `
163
+ vec2 circleLimpFromLongLatRadCenterMercatorCompass(vec2 center, float radius, float angle){
164
+ vec2 center_ = longLatRadToMercator(center);
165
+ float y = -sin(angle) * radius + center_.y;
166
+ float x = cos(angle) * radius + center_.x;
167
+ return vec2(x, y);
168
+ } `;
169
+ // Function to convert Cartesian coordinates back to spherical (latitude, longitude)
170
+ exports.cartesianToSpherical = `
171
+ vec2 cartesianToSpherical(vec3 point) {
172
+ float lat = degrees(asin(point.z)); // Latitude
173
+ float lon = degrees(atan(point.y, point.x)); // Longitude
174
+
175
+ return vec2(lat, lon);
176
+ } `;
177
+ // Main function to calculate an intermediate point
178
+ exports.angleBetweenTwoPointsRadian = `
179
+ float angleBetweenTwoPointsRadian(vec2 start_, vec2 end_) {
180
+ float start_lat = log(tan((1.0 - start_.y) * PI / 2.0));
181
+ float end_lat = log(tan((1.0 - end_.y) * PI / 2.0));
182
+ float angle = atan((end_lat - start_lat) / (end_.x - start_.x));
183
+ return angle;
184
+ }
185
+ `;
186
+ exports.circleCircumferenceInterPolationOf2PointsRadian = `
187
+ float circleCircumferenceInterPolationOf2PointsRadian(vec2 center, vec2 target, float bearing_angle, float ratio) {
188
+ vec2 t = target - center;
189
+ float mainAngle = atan(t.x, t.y);
190
+ float angle = mainAngle - * ratio;
191
+ return angle;
192
+ }
193
+ `;
194
+ exports.realDistanceOnSphereR1 = `
195
+ float realDistanceOnSphereR1(vec2 longLat1, vec2 longLat2) {
196
+ float dLat = longLat2.y - longLat1.y;
197
+ float dLong = longLat2.x - longLat1.x;
198
+ float a = sin(dLat / 2.0) * sin(dLat / 2.0) + cos(longLat1.y) * cos(longLat2.y) * sin(dLong / 2.0) * sin(dLong / 2.0);
199
+ float c = 2.0 * atan(sqrt(a), sqrt(1.0 - a));
200
+ return c;
201
+ }
202
+ `;
203
+ const pointsOnSphereBetween = `
204
+ vec3 pointsOnSphereBetween(vec3 a, vec3 b, float ratio) {
205
+ // Normalize the input points to ensure they are on the unit sphere
206
+ a = normalize(a);
207
+ b = normalize(b);
208
+
209
+ // Compute the dot product and clamp it to avoid numerical issues
210
+ // float dotProduct = clamp(dot(a, b), -1.0, 1.0);
211
+
212
+ // Compute the angle between the points
213
+ float theta = acos(dot(a, b));
214
+
215
+ // Handle the edge case where the points are nearly identical
216
+ if (theta < 0.0001) {
217
+ return normalize(mix(a, b, ratio)); // Linear interpolation as fallback
218
+ }
219
+
220
+ // Compute the interpolated point using spherical linear interpolation (slerp)
221
+ float sinTheta = sin(theta);
222
+ float factorA = sin((1.0 - ratio) * theta) / sinTheta;
223
+ float factorB = sin(ratio * theta) / sinTheta;
224
+
225
+ vec3 result = factorA * a + factorB * b;
226
+
227
+ // Return the normalized result to ensure it lies on the sphere
228
+ return normalize(result);
229
+ }`;
230
+ const slerp = `
231
+ ${pointsOnSphereBetween}
232
+ vec3 slerp(vec3 A, vec3 B, float t) {
233
+ return pointsOnSphereBetween(A, B, t) * mix(length(A), length(B), t);
234
+ }
235
+ `;
236
+ exports.slerp = slerp;
237
+ const circleLimpFromLongLatRadCenterCartesian3D_accurate = exports.R + `
238
+ vec3 circleLimpFromLongLatRadCenterCartesian3D_accurate( vec3 geoW, float radius, float angle) {
239
+ vec3 normal = normalize(geoW);
240
+ vec3 tangent1 = cross(normal, vec3(0.0, 0.0, -1.0));
241
+ if ( length(tangent1) < 0.1 ){ tangent1 = cross(normal, vec3(0.0, -1.0, 0.0)); }
242
+ tangent1 = normalize(tangent1);
243
+ // rotate tangent with given angle
244
+ tangent1 = cos(angle) * tangent1 - sin(angle) * cross(normal, tangent1);
245
+ float radius_in_angle = radius/R;
246
+ float projected_radius = sin(radius_in_angle) * R / 1000.0;
247
+ return (geoW * cos(radius_in_angle)) + tangent1 * projected_radius;
248
+ }`;
249
+ exports.circleLimpFromLongLatRadCenterCartesian3D_accurate = circleLimpFromLongLatRadCenterCartesian3D_accurate;
250
+ const circleOnSphere = `
251
+ vec3 rotateVectorAroundAxis(vec3 v, vec3 axis, float angle) {
252
+ float c = cos(angle);
253
+ float s = sin(angle);
254
+ float t = 1.0 - c;
255
+ vec3 normalizedAxis = normalize(axis); // Ensure axis is unit length
256
+
257
+ return vec3(
258
+ (t * normalizedAxis.x * normalizedAxis.x + c) * v.x +
259
+ (t * normalizedAxis.x * normalizedAxis.y - s * normalizedAxis.z) * v.y +
260
+ (t * normalizedAxis.x * normalizedAxis.z + s * normalizedAxis.y) * v.z,
261
+
262
+ (t * normalizedAxis.x * normalizedAxis.y + s * normalizedAxis.z) * v.x +
263
+ (t * normalizedAxis.y * normalizedAxis.y + c) * v.y +
264
+ (t * normalizedAxis.y * normalizedAxis.z - s * normalizedAxis.x) * v.z,
265
+
266
+ (t * normalizedAxis.x * normalizedAxis.z - s * normalizedAxis.y) * v.x +
267
+ (t * normalizedAxis.y * normalizedAxis.z + s * normalizedAxis.x) * v.y +
268
+ (t * normalizedAxis.z * normalizedAxis.z + c) * v.z
269
+ );
270
+
271
+ // Alternative, more compact way using cross and dot products:
272
+ // vec3 crossProd = cross(normalizedAxis, v);
273
+ // float dotProd = dot(normalizedAxis, v);
274
+ // return v * c + crossProd * s + normalizedAxis * dotProd * t;
275
+ }
276
+
277
+ /**
278
+ * @brief Calculates a point on a circle drawn on the surface of a sphere.
279
+ * The sphere is assumed to be centered at the origin (0,0,0).
280
+ * The circle's center on the sphere surface is M, and H is a starting point on the circle.
281
+ * The function returns the point obtained by rotating H around the axis defined by M by angle A.
282
+ *
283
+ * @param M The center point of the circle on the sphere's surface. The vector from the origin to M defines the rotation axis.
284
+ * @param H A starting point on the circle (also on the sphere's surface).
285
+ * @param A The angle of rotation in radians. Use radians(degrees) if your input is in degrees.
286
+ * @return A vec3 representing the calculated point on the sphere's surface.
287
+ */
288
+ vec3 circleOnSphere(vec3 M, vec3 H, float A) {
289
+ // The rotation axis is the vector from the origin to the circle's center point M on the sphere.
290
+ // This axis vector needs to be normalized for the rotation formula.
291
+ vec3 rotationAxis = normalize(M);
292
+
293
+ // Rotate the starting point H around the rotation axis by angle A.
294
+ vec3 rotatedPoint = rotateVectorAroundAxis(H, rotationAxis, A);
295
+
296
+ // Optional but recommended: Re-normalize the result to ensure it stays exactly on the sphere's surface,
297
+ // counteracting potential floating-point inaccuracies, especially if the original sphere radius was 1.
298
+ // If the sphere has a different radius R, you might want to normalize and multiply by R:
299
+ // float radius = length(M); // Assuming M is exactly on the surface
300
+ // return normalize(rotatedPoint) * radius;
301
+ // If it's a unit sphere:
302
+ // return normalize(rotatedPoint);
303
+
304
+ // For simplicity, returning the direct result of rotation. Assume M and H were perfectly on the sphere.
305
+ return rotatedPoint;
306
+ }`;
307
+ exports.circleOnSphere = circleOnSphere;
308
+ const circleLimpFromLongLatRadCenterMercatorCompass_accurate = `
309
+ vec2 circleLimpFromLongLatRadCenterMercatorCompass_accurate(vec2 center, float radius, float angle){
310
+ float y = -sin(angle) * radius + center.y;
311
+ float x = cos(angle) * radius + center.x;
312
+ return vec2(x, y);
313
+ } `;
314
+ exports.circleLimpFromLongLatRadCenterMercatorCompass_accurate = circleLimpFromLongLatRadCenterMercatorCompass_accurate;
315
+ //TODO make it work...
316
+ const circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate = exports.PI + `
317
+ vec2 circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate(vec2 mercator_center, float radius, float angle) {
318
+ vec2 center = vec2(mercator_center.x /6378137.0 , asin(tanh(mercator_center.y / 6378137.0 )));
319
+ float ang = angle + PI / 2.0; // Shift angle to align with +x axis
320
+ float r = radius / R;
321
+ float cos_r = cos(r);
322
+ float sin_r = sin(r);
323
+
324
+ float sin_lat = sin(center.y) * cos_r + cos(center.y) * sin_r * cos(ang);
325
+ float lat = asin(sin_lat);
326
+
327
+ float delta_long = atan(sin(ang) * sin_r * cos(center.y), cos_r - sin(center.y) * sin_lat);
328
+ float longi = center.x + delta_long;
329
+ // float y = mix(-80.5, 80.5, abs(center.y + PI / 2.0));
330
+ vec2 limp = vec2(
331
+ R * longi,
332
+ R * log(tan(PI / 4.0 + lat / 2.0))
333
+ );
334
+ vec2 center_mercator = vec2(
335
+ R * center.x,
336
+ R * log(tan(PI/4.0+ center.y / 2.0))
337
+ );
338
+ return mercator_center - center_mercator + limp;
339
+ }`;
340
+ exports.circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate = circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./geometrytransformations"), exports);
18
+ __exportStar(require("./nodata"), exports);
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vertexIDtoTextureCoordinate = void 0;
4
+ const vertexIDtoTextureCoordinate = `
5
+ vec2 vertexIDtoTextureCoordinate(float id, vec2 textureDimentions) {
6
+ float x = mod(id, textureDimentions.x);
7
+ float y = floor(id / textureDimentions.x);
8
+ return vec2( x / textureDimentions.x, y / textureDimentions.y);
9
+ }
10
+ `;
11
+ exports.vertexIDtoTextureCoordinate = vertexIDtoTextureCoordinate;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const permute34 = `` `vec3 permute34(vec3 x) {
4
+ x = ((x * 34.0) + 1.0) * x;
5
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
6
+ }` ``;
7
+ const waveNoice = `` `float waveNoice(vec2 v)
8
+ {
9
+ const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439);
10
+
11
+ vec2 i = floor(v + dot(v, C.yy));
12
+ vec2 x0 = v - i + dot(i, C.xx);
13
+
14
+ vec2 i1;
15
+ i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
16
+
17
+ vec4 x12 = x0.xyxy + C.xxzz;
18
+ x12.xy -= i1;
19
+
20
+ i = i - floor(i * (1.0 / 289.0)) * 289.0;
21
+
22
+ vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0))
23
+ + i.x + vec3(0.0, i1.x, 1.0));
24
+
25
+ vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);
26
+ m = m * m;
27
+ m = m * m;
28
+
29
+ vec3 x = 2.0 * fract(p * C.www) - 1.0;
30
+ vec3 h = abs(x) - 0.5;
31
+ vec3 ox = floor(x + 0.5);
32
+ vec3 a0 = x - ox;
33
+
34
+ m *= inversesqrt(a0 * a0 + h * h);
35
+
36
+ vec3 g;
37
+ g.x = a0.x * x0.x + h.x * x0.y;
38
+ g.yz = a0.yz * x12.xz + h.yz * x12.yw;
39
+ return 130.0 * dot(m, g);
40
+ }` ``;
41
+ exports.default = {
42
+ permute34, waveNoice
43
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ // function naiveBBox(a: number[], b: number[]): BBox {
3
+ // return {
4
+ // minX: Math.min(a[0], b[0]),
5
+ // minY: Math.min(a[1], b[1]),
6
+ // maxX: Math.max(a[0], b[0]),
7
+ // maxY: Math.max(a[1], b[1])
8
+ // };
9
+ // }
10
+ // function slerp(a: Vector, b: Vector, t: number, theta: number, sinTheta: number): Vector {
11
+ // }
12
+ // function getArcBBoxes(arc: Arc, dotStep: number = 0.025): BBox[] {
13
+ // const start = arc.start;
14
+ // const end = arc.end;
15
+ // const a = [start[0], start[1], start[2]];
16
+ // const b = [end[0], end[1], end[2]];
17
+ // const theta = Math.acos(a[0] * b[0] + a[1] * b[1] + a[2] * b[2]);
18
+ // const step = dotStep / theta;
19
+ // if (step >= 1) {
20
+ // return [naiveBBox(start, end)];
21
+ // }
22
+ // let points = [start] as Vector[];
23
+ // let currentStep =
24
+ // return bbox;
25
+ // }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ class ArcsToCutsManager {
3
+ constructor(rbush, { dotDistanceOfArcCuts = 0.01 }) {
4
+ this._map = new Map();
5
+ this._dotDistanceOfArcCuts = dotDistanceOfArcCuts;
6
+ this._rbush = rbush;
7
+ }
8
+ insertArcs(arc) {
9
+ if (this._map.has(arc.id)) {
10
+ this._deleteCuts(arc.id);
11
+ }
12
+ }
13
+ _deleteCuts(id) {
14
+ const cuts = this._map.get(id);
15
+ if (cuts) {
16
+ cuts.forEach(cut => cut.remove());
17
+ }
18
+ }
19
+ _cutArcAndAddToRBush(arc) {
20
+ const cuts = this._cutArcToBBoxs(arc);
21
+ cuts.forEach(cut => {
22
+ this._rbush.insert(cut);
23
+ });
24
+ this._map.set(arc.id, cuts);
25
+ }
26
+ _cutArcToBBoxs(arc) {
27
+ const cuts = [];
28
+ // Calculate the bounding box of the arc
29
+ // Create a cut object and add it to the cuts array
30
+ const cut = {
31
+ minX: bbox.minX,
32
+ minY: bbox.minY,
33
+ maxX: bbox.maxX,
34
+ maxY: bbox.maxY,
35
+ arcId: arc.id,
36
+ };
37
+ cuts.push(cut);
38
+ return cuts;
39
+ }
40
+ }
41
+ function sphericalLinearInterpolation(phi1, lambda1, phi2, lambda2, t) {
42
+ // Spherical linear interpolation between two points on a sphere
43
+ // Args: phi1, lambda1: starting point (in radians)
44
+ // phi2, lambda2: ending point (in radians)
45
+ // t: interpolation parameter (0 <= t <= 1)
46
+ // Returns: [phi, lambda] in radians
47
+ const phi = phi1 + t * (phi2 - phi1);
48
+ const lambda = lambda1 + t * (lambda2 - lambda1);
49
+ return [phi, lambda];
50
+ }
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ // class FlowManager {
3
+ // _populateCount: number;
4
+ // _rbush: RBush<any>;
5
+ // _arcToCutsManager: ArcToCutsManager;
6
+ // consturctor({ populateCount = 36, dotDistanceOfArcCuts = 1 / Math.pow(2, 10 - 1) }) {
7
+ // this._populateCount = populateCount;
8
+ // // does the cutting and id mapping(one to many)
9
+ // // cuts have their bbox ready for rbush
10
+ // this._rbush = new RBush(1000);
11
+ // this._arcToCutsManager = new ArcToCutsManager({ dotDistanceOfArcCuts, rbush: this._rbush }); // 10km
12
+ // }
13
+ // /**
14
+ // * adds or updates an arc in the rbush and the cuts manager
15
+ // */
16
+ // insertArc(arc: Arc) {
17
+ // this._arcToCutsManager.insertArc(arc);
18
+ // }
19
+ // deleteArc(id: Arc['id']) {
20
+ // this._arcToCutsManager.deleteArc(id);
21
+ // }
22
+ // queryBBox(bbox: BBox) {
23
+ // const arcIDSet = new Set(this._rbush.query(bbox).map(x => x.id)); // sets Of ids of arcs
24
+ // // arcs U bbox => arcs
25
+ // // populate points
26
+ // // return typed array of points belonging to all the arcs of cuts
27
+ // }
28
+ // }
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultblendfunction = defaultblendfunction;
4
+ function defaultblendfunction(gl) {
5
+ gl.blendEquation(gl.FUNC_ADD); // TODO: TESTING THIS
6
+ gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
7
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./rasteroverlay"), exports);
18
+ __exportStar(require("./gldefaultstates"), exports);
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /**
3
+ * Iceride bir canvas uretir ve degisiklikler bu kanvasta yapilir
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RasterOverlayLoader = void 0;
7
+ // this class loads texture to raster overlay
8
+ class RasterOverlayLoader {
9
+ constructor(id, globe, { opacity = 1.0, minLon = -180, minLat = -90, maxLon = 180, maxLat = 90, beforeObject = null, canvas = null, callBack = null } = {}) {
10
+ this.canvas = canvas || document.createElement('canvas');
11
+ this.gl = this.canvas.getContext('webgl2');
12
+ this.globe = globe;
13
+ this.id = id;
14
+ this._opacity = opacity;
15
+ this.bbox = { ll: { x: minLon, y: minLat }, ur: { x: maxLon, y: maxLat } };
16
+ this._beforeObject = beforeObject;
17
+ this._isProcessing = false;
18
+ this._callBack = callBack;
19
+ }
20
+ getGL() {
21
+ return this.gl;
22
+ }
23
+ getCanvasURL() {
24
+ return this.canvas.toDataURL();
25
+ }
26
+ setBBox(minLon, minLat, maxLon, maxLat) {
27
+ this.bbox = { ll: { x: minLon, y: minLat }, ur: { x: maxLon, y: maxLat } };
28
+ this.draw();
29
+ }
30
+ setCanvasWidthHeight(width, height) {
31
+ this.canvas.width = width;
32
+ this.canvas.height = height;
33
+ this.gl.viewport(0, 0, width, height);
34
+ }
35
+ draw() {
36
+ if (!this._isProcessing) {
37
+ requestAnimationFrame(this._draw.bind(this));
38
+ this._isProcessing = true;
39
+ }
40
+ }
41
+ _draw() {
42
+ this.globe.api_DeleteImageOverlay(this.id);
43
+ const id = this.id;
44
+ const imgUrl = this.getCanvasURL();
45
+ const bbox = this.bbox;
46
+ const opacity = this._opacity;
47
+ const rotDeg = 0;
48
+ const color = null;
49
+ const beforeObject = this._beforeObject;
50
+ const callback = this._callBack || function () { };
51
+ this.globe.api_AddImageOverlay(id, imgUrl, bbox, color, opacity, rotDeg, beforeObject, callback);
52
+ this._isProcessing = false;
53
+ }
54
+ setBeforeObject(beforeObject) {
55
+ this._beforeObject = beforeObject;
56
+ this.draw();
57
+ }
58
+ setCallback(callback) {
59
+ this._callBack = callback;
60
+ }
61
+ setOpacity(opacity) {
62
+ if (opacity < 0 || opacity > 1) {
63
+ return;
64
+ }
65
+ this._opacity = opacity;
66
+ this.globe.api_SetImageOverlayColor(this.id, null, opacity);
67
+ }
68
+ free() {
69
+ this.globe.api_DeleteImageOverlay(this.id);
70
+ }
71
+ on() {
72
+ this.draw();
73
+ }
74
+ off() {
75
+ this.globe.api_DeleteImageOverlay(this.id);
76
+ }
77
+ }
78
+ exports.RasterOverlayLoader = RasterOverlayLoader;