@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,216 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EDGE_COUNT = exports.CircleCache = void 0;
4
+ exports.centerCoords2dflatDataCreator = centerCoords2dflatDataCreator;
5
+ exports.centerCoords2dflatDataCreatorWithRadius = centerCoords2dflatDataCreatorWithRadius;
6
+ const webglobjectbuilders_1 = require("../../util/webglobjectbuilders");
7
+ const camerauniformblock_1 = require("../totems/camerauniformblock");
8
+ const programcache_1 = require("../programcache");
9
+ const util_1 = require("../../util/account/util");
10
+ const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
11
+ const Pole = 20037508.34;
12
+ /**
13
+ * Warning:
14
+ * Insert the points from the second index and skip 1 point as you placed 361 points
15
+ */
16
+ /**
17
+ * Plus 1 for returning to the start point. 1 for cutting the circle into pieces.
18
+ */
19
+ const EDGE_COUNT = 62;
20
+ exports.EDGE_COUNT = EDGE_COUNT;
21
+ const ESCAPE_VALUE = 200000000;
22
+ const vertexShaderSource = `#version 300 es
23
+ precision highp float;
24
+
25
+ # define escape_value ${ESCAPE_VALUE}.0
26
+
27
+ ${camerauniformblock_1.CameraUniformBlockString}
28
+ ${geometrytransformations_1.mercatorXYToGLPosition}
29
+
30
+ uniform int edge_count;
31
+
32
+
33
+ in vec2 position2d;
34
+ in vec4 color;
35
+ in float dash_ratio;
36
+ in float dash_opacity;
37
+
38
+ out float interpolation;
39
+ out vec4 v_color;
40
+ out float v_dash_ratio;
41
+ out float v_dash_opacity;
42
+ out vec2 v_limp;
43
+
44
+
45
+ void main() {
46
+ if ( position2d.x == escape_value && position2d.y == escape_value){ return; }
47
+ interpolation = float( gl_VertexID % edge_count ) / float(edge_count);
48
+ if ( gl_VertexID % edge_count == 0 ) { return; } // cut on the first point.
49
+ if ( is3D ) {
50
+ return;
51
+ v_limp = vec2(0.0, 0.0);
52
+ } else {
53
+ v_limp = position2d;
54
+ gl_Position = mercatorXYToGLPosition( position2d);
55
+ }
56
+ v_dash_ratio = dash_ratio;
57
+ v_dash_opacity = dash_opacity;
58
+ v_color = color;
59
+ gl_PointSize = 15.0;
60
+
61
+ }`;
62
+ const fragmentShaderSource = `#version 300 es
63
+ ${geometrytransformations_1.POLE}
64
+ precision highp float;
65
+ uniform float opacity;
66
+ in vec4 v_color;
67
+ in float v_dash_ratio;
68
+ in float v_dash_opacity;
69
+ in float interpolation;
70
+ in vec2 v_limp;
71
+ out vec4 color;
72
+ void main() {
73
+ if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){
74
+ discard;
75
+ // color = vec4(0.0,0.0,0.0,0.0);
76
+ // return;
77
+ }
78
+ color = v_color;
79
+ color.a *= opacity;
80
+ if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
81
+ if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
82
+ color.a *= v_dash_opacity;
83
+ }
84
+ }`;
85
+ class Logic {
86
+ constructor(globe) {
87
+ this.globe = globe;
88
+ this.gl = globe.gl;
89
+ this._lastOpacity = 1.0;
90
+ this._lastMercatorMode = 0;
91
+ this._lastEdgeCount = EDGE_COUNT;
92
+ this.program = (0, webglobjectbuilders_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
93
+ const { gl, program } = this;
94
+ this.program.uniforms = {
95
+ opacity: gl.getUniformLocation(program, "opacity"),
96
+ edgeCount: gl.getUniformLocation(program, "edge_count"),
97
+ mercator_calculation_mode: gl.getUniformLocation(program, "mercator_calculation_mode")
98
+ };
99
+ // initial uniform values
100
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
101
+ gl.useProgram(program);
102
+ gl.uniform1f(program.uniforms.opacity, 1.0);
103
+ gl.uniform1i(program.uniforms.edgeCount, EDGE_COUNT);
104
+ gl.uniform1i(program.uniforms.mercator_calculation_mode, 0);
105
+ gl.useProgram(currentProgram);
106
+ // assign attribute locations
107
+ gl.bindAttribLocation(program, 0, "position2d");
108
+ gl.bindAttribLocation(program, 1, "color");
109
+ gl.bindAttribLocation(program, 2, "dash_ratio");
110
+ gl.bindAttribLocation(program, 3, "dash_opacity");
111
+ this.cameraBindingPoint = 0;
112
+ this.cameraBlockTotem = camerauniformblock_1.CameraUniformBlockTotemCache.get(globe);
113
+ const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
114
+ gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
115
+ }
116
+ createVAO(centerObj, colorObj, dashRatioObj, dashOpacityObj) {
117
+ const { gl } = this;
118
+ const vao = gl.createVertexArray();
119
+ gl.bindVertexArray(vao);
120
+ { // make this a function end import from account module.
121
+ const { buffer, stride = 0, offset = 0 } = centerObj;
122
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 0, 2, stride, offset, null);
123
+ }
124
+ {
125
+ const { buffer, stride = 0, offset = 0 } = colorObj;
126
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 1, 4, stride, offset, null);
127
+ }
128
+ {
129
+ const { buffer, stride = 0, offset = 0 } = dashRatioObj;
130
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 2, 1, stride, offset, null);
131
+ }
132
+ {
133
+ const { buffer, stride = 0, offset = 0 } = dashOpacityObj;
134
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 3, 1, stride, offset, null);
135
+ }
136
+ gl.bindVertexArray(null);
137
+ gl.bindVertexArray(null);
138
+ return vao;
139
+ }
140
+ draw(vao, length, edgeCount, opacity) {
141
+ const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
142
+ gl.useProgram(program);
143
+ if (this._lastOpacity !== opacity) {
144
+ gl.uniform1f(program.uniforms.opacity, opacity);
145
+ this._lastOpacity = opacity;
146
+ }
147
+ if (this._lastEdgeCount !== edgeCount) {
148
+ gl.uniform1i(program.uniforms.edgeCount, edgeCount);
149
+ this._lastEdgeCount = edgeCount;
150
+ }
151
+ gl.bindVertexArray(vao);
152
+ cameraBlockTotem.bind(cameraBindingPoint);
153
+ gl.drawArrays(gl.LINE_STRIP, 0, length * edgeCount);
154
+ // gl.drawArrays(gl.POINTS, 0, length * EDGE_COUNT)
155
+ cameraBlockTotem.unbind(cameraBindingPoint);
156
+ gl.bindVertexArray(null);
157
+ }
158
+ free() {
159
+ if (this.isFreed)
160
+ return;
161
+ camerauniformblock_1.CameraUniformBlockTotemCache.release(this.globe);
162
+ this.gl.deleteProgram(this.program);
163
+ this.isFreed = true;
164
+ }
165
+ }
166
+ const CircleCache = Object.freeze({
167
+ get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
168
+ release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
169
+ });
170
+ exports.CircleCache = CircleCache;
171
+ function centerCoords2dflatDataCreator(globe, centerLong, centerLat, targetLong, targetLat, { startAngleOfCircle = null, edgeCount = EDGE_COUNT, radiusOffset = 0 } = {}) {
172
+ const centerCoords2dflat = new Float32Array(edgeCount * 2);
173
+ const radius2d = globe.Math.GetDist2D(centerLong, centerLat, targetLong, targetLat) + radiusOffset;
174
+ let angle;
175
+ if (startAngleOfCircle === null) {
176
+ angle = globe.Math.GetAzimuthAngle(centerLong, centerLat, targetLong, targetLat);
177
+ }
178
+ else {
179
+ angle = startAngleOfCircle;
180
+ }
181
+ const pointsLongLat = globe.Math.GetEllipseGeo(centerLong, centerLat, radius2d, radius2d, angle, 360 / (edgeCount - 2));
182
+ let lastlg = pointsLongLat[0].long;
183
+ let lastlt = pointsLongLat[0].lat;
184
+ for (let i = 1; i < edgeCount; i++) {
185
+ const { long: lg, lat: lt } = pointsLongLat[i - 1];
186
+ if (manhattanDistance(lastlg, lastlt, lg, lt) < 170) {
187
+ centerCoords2dflat.set(globe.api_GetMercator2DPoint(lg, lt), i * 2);
188
+ }
189
+ else {
190
+ centerCoords2dflat.set([NaN, NaN], i * 2);
191
+ }
192
+ lastlg = lg;
193
+ lastlt = lt;
194
+ }
195
+ return centerCoords2dflat;
196
+ }
197
+ function centerCoords2dflatDataCreatorWithRadius(globe, centerLong, centerLat, radius2d, { startAngleOfCircle = null, edgeCount = EDGE_COUNT } = {}) {
198
+ const centerCoords2dflat = new Float32Array(edgeCount * 2);
199
+ const pointsLongLat = globe.Math.GetEllipseGeo(centerLong, centerLat, radius2d, radius2d, 0, 360 / (edgeCount - 2));
200
+ let { long: lastlg, lat: lastlt } = pointsLongLat[0];
201
+ for (let i = 1; i < edgeCount; i++) {
202
+ const { long: lg, lat: lt } = pointsLongLat[i - 1];
203
+ if (manhattanDistance(lastlg, lastlt, lg, lt) < 170) {
204
+ centerCoords2dflat.set(globe.api_GetMercator2DPoint(lg, lt), i * 2);
205
+ }
206
+ else {
207
+ centerCoords2dflat.set([NaN, NaN], i * 2);
208
+ }
209
+ lastlg = lg;
210
+ lastlt = lt;
211
+ }
212
+ return centerCoords2dflat;
213
+ }
214
+ function manhattanDistance(x1, y1, x2, y2) {
215
+ return Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2));
216
+ }
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CircleCache = void 0;
4
+ const webglobjectbuilders_1 = require("../../util/webglobjectbuilders");
5
+ const camerauniformblock_1 = require("../totems/camerauniformblock");
6
+ const programcache_1 = require("../programcache");
7
+ const util_1 = require("../../util/account/util");
8
+ const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
9
+ /**
10
+ * TODO:
11
+ * 1. integrate geometry functions for radius angle and center
12
+ * 2. integrate attributes
13
+ *
14
+ * TODO:
15
+ * center_position is too small or doenst loaded as expected.
16
+ */
17
+ const EDGE_COUNT_ON_SPHERE = 360;
18
+ const vertexShaderSource = `#version 300 es
19
+ precision highp float;
20
+ ${camerauniformblock_1.CameraUniformBlockString}
21
+ ${geometrytransformations_1.longLatRadToMercator}
22
+ ${geometrytransformations_1.longLatRadToCartesian3D}
23
+ ${geometrytransformations_1.cartesian3DToGLPosition}
24
+ ${geometrytransformations_1.mercatorXYToGLPosition}
25
+ ${geometrytransformations_1.realDistanceOnSphereR1}
26
+ ${geometrytransformations_1.circleLimpFromLongLatRadCenterCartesian3D_accurate}
27
+ ${geometrytransformations_1.circleLimpFromLongLatRadCenterMercatorCompass_accurate}
28
+ ${geometrytransformations_1.circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate}
29
+
30
+ uniform float edge_count;
31
+
32
+ in vec2 center_position;
33
+ in vec3 center_position3d;
34
+ in float radius;
35
+ in vec4 color;
36
+ in float dash_ratio;
37
+ in float dash_opacity;
38
+
39
+ out float interpolation;
40
+ out vec4 v_color;
41
+ out float v_dash_ratio;
42
+ out float v_dash_opacity;
43
+ out vec2 v_limp;
44
+ void main() {
45
+ interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE}.0;
46
+ float angle = PI * 2.0 * interpolation;
47
+ if ( is3D ) {
48
+
49
+ vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, radius, angle);
50
+
51
+ gl_Position = cartesian3DToGLPosition(position);
52
+ v_limp = vec2(0.0, 0.0);
53
+ } else {
54
+ vec2 position;
55
+ if ( radius < 0.0) {
56
+ float cosine1 = cos(asin(tanh(center_position.y / 6378137.0)));
57
+ position = circleLimpFromLongLatRadCenterMercatorCompass_accurate(center_position, radius / cosine1 , angle);
58
+ } else {
59
+ position = circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate( center_position, radius, angle);
60
+ }
61
+ v_limp = position;
62
+ gl_Position = mercatorXYToGLPosition( position);
63
+
64
+ }
65
+ v_dash_ratio = dash_ratio;
66
+ v_dash_opacity = dash_opacity;
67
+ v_color = color;
68
+ gl_PointSize = 3.0;
69
+
70
+ }`;
71
+ const fragmentShaderSource = `#version 300 es
72
+ ${geometrytransformations_1.POLE}
73
+ precision highp float;
74
+ uniform float opacity;
75
+ in vec4 v_color;
76
+ in float v_dash_ratio;
77
+ in float v_dash_opacity;
78
+ in float interpolation;
79
+ in vec2 v_limp;
80
+ out vec4 color;
81
+ void main() {
82
+ 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; }
83
+ color = v_color;
84
+ color.a *= opacity;
85
+ if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
86
+ if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
87
+ color.a *= v_dash_opacity;
88
+ }
89
+ }
90
+ `;
91
+ class Logic {
92
+ constructor(globe) {
93
+ this.globe = globe;
94
+ this.gl = globe.gl;
95
+ this._lastOpacity = 1.0;
96
+ this.program = (0, webglobjectbuilders_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
97
+ const { gl, program } = this;
98
+ this.program.uniforms = {
99
+ opacity: gl.getUniformLocation(program, "opacity")
100
+ };
101
+ { // initial uniform values
102
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
103
+ gl.useProgram(program);
104
+ gl.uniform1f(program.uniforms.opacity, 1.0);
105
+ gl.useProgram(currentProgram);
106
+ }
107
+ { // assign attribute locations
108
+ gl.bindAttribLocation(program, 0, "center_position");
109
+ gl.bindAttribLocation(program, 1, "center_position3d");
110
+ gl.bindAttribLocation(program, 2, "radius");
111
+ gl.bindAttribLocation(program, 3, "color");
112
+ gl.bindAttribLocation(program, 4, "dash_ratio");
113
+ gl.bindAttribLocation(program, 5, "dash_opacity");
114
+ }
115
+ this.cameraBindingPoint = 0;
116
+ this.cameraBlockTotem = camerauniformblock_1.CameraUniformBlockTotemCache.get(globe);
117
+ const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
118
+ gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
119
+ }
120
+ createVAO(centerObj, center3dObj, radiusObj, colorObj, dashRatioObj, dashOpacityObj) {
121
+ const { gl } = this;
122
+ const vao = gl.createVertexArray();
123
+ const divisor = 1;
124
+ gl.bindVertexArray(vao);
125
+ { // make this a function end import from account module.
126
+ const { buffer, stride = 0, offset = 0 } = centerObj;
127
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 0, 2, stride, offset, divisor);
128
+ }
129
+ { // make this a function end import from account module.
130
+ const { buffer, stride = 0, offset = 0 } = center3dObj;
131
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 1, 3, stride, offset, divisor);
132
+ }
133
+ {
134
+ const { buffer, stride = 0, offset = 0 } = radiusObj;
135
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 2, 1, stride, offset, divisor);
136
+ }
137
+ {
138
+ const { buffer, stride = 0, offset = 0 } = colorObj;
139
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 3, 4, stride, offset, divisor);
140
+ }
141
+ {
142
+ const { buffer, stride = 0, offset = 0 } = dashRatioObj;
143
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 4, 1, stride, offset, divisor);
144
+ }
145
+ {
146
+ const { buffer, stride = 0, offset = 0 } = dashOpacityObj;
147
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 5, 1, stride, offset, divisor);
148
+ }
149
+ gl.bindVertexArray(null);
150
+ gl.bindVertexArray(null);
151
+ return vao;
152
+ }
153
+ draw(vao, length, opacity) {
154
+ const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
155
+ gl.useProgram(program);
156
+ if (this._lastOpacity !== opacity) {
157
+ gl.uniform1f(program.uniforms.opacity, opacity);
158
+ this._lastOpacity = opacity;
159
+ }
160
+ gl.bindVertexArray(vao);
161
+ cameraBlockTotem.bind(cameraBindingPoint);
162
+ gl.drawArraysInstanced(gl.LINE_STRIP, 0, EDGE_COUNT_ON_SPHERE + 1, length);
163
+ gl.drawArraysInstanced(gl.POINTS, 0, EDGE_COUNT_ON_SPHERE + 1, length);
164
+ cameraBlockTotem.unbind(cameraBindingPoint);
165
+ gl.bindVertexArray(null);
166
+ }
167
+ free() {
168
+ if (this.isFreed)
169
+ return;
170
+ camerauniformblock_1.CameraUniformBlockTotemCache.release(this.globe);
171
+ this.gl.deleteProgram(this.program);
172
+ this.isFreed = true;
173
+ }
174
+ }
175
+ exports.CircleCache = Object.freeze({
176
+ get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
177
+ release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
178
+ });
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CircleCache = void 0;
4
+ const webglobjectbuilders_1 = require("../../util/webglobjectbuilders");
5
+ const camerauniformblock_1 = require("../totems/camerauniformblock");
6
+ const programcache_1 = require("../programcache");
7
+ const util_1 = require("../../util/account/util");
8
+ const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
9
+ /**
10
+ * TODO:
11
+ * 1. integrate geometry functions for radius angle and center
12
+ * 2. integrate attributes
13
+ *
14
+ * TODO:
15
+ * center_position is too small or doenst loaded as expected.
16
+ */
17
+ const EDGE_COUNT_ON_SPHERE = 360;
18
+ const vertexShaderSource = `#version 300 es
19
+ precision highp float;
20
+ ${camerauniformblock_1.CameraUniformBlockString}
21
+ ${geometrytransformations_1.longLatRadToMercator}
22
+ ${geometrytransformations_1.longLatRadToCartesian3D}
23
+ ${geometrytransformations_1.cartesian3DToGLPosition}
24
+ ${geometrytransformations_1.mercatorXYToGLPosition}
25
+ ${geometrytransformations_1.realDistanceOnSphereR1}
26
+ ${geometrytransformations_1.circleLimpFromLongLatRadCenterCartesian3D}
27
+ ${geometrytransformations_1.circleLimpFromLongLatRadCenterMercatorCompass}
28
+ ${geometrytransformations_1.circleLimpFromLongLatRadCenterMercatorRealDistance}
29
+
30
+ uniform float edge_count;
31
+
32
+ in vec2 center_position;
33
+ in float radius;
34
+ in vec4 color;
35
+ in float dash_ratio;
36
+ in float dash_opacity;
37
+
38
+ out float interpolation;
39
+ out vec4 v_color;
40
+ out float v_dash_ratio;
41
+ out float v_dash_opacity;
42
+ out vec2 v_limp;
43
+ void main() {
44
+ interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE}.0;
45
+ float angle = PI * 2.0 * interpolation;
46
+ if ( is3D ) {
47
+ vec3 position = circleLimpFromLongLatRadCenterCartesian3D( center_position, radius, angle);
48
+ gl_Position = cartesian3DToGLPosition(position);
49
+ v_limp = vec2(0.0, 0.0);
50
+ } else {
51
+ vec2 position;
52
+ if (radius < 1400.0) {
53
+ position = circleLimpFromLongLatRadCenterMercatorCompass( center_position, radius/ cos(center_position.y), angle);
54
+ } else {
55
+ position = circleLimpFromLongLatRadCenterMercatorRealDistance( center_position, radius, angle);
56
+ }
57
+ v_limp = position;
58
+ gl_Position = mercatorXYToGLPosition( position);
59
+
60
+ }
61
+ v_dash_ratio = dash_ratio;
62
+ v_dash_opacity = dash_opacity;
63
+ v_color = color;
64
+
65
+ }`;
66
+ const fragmentShaderSource = `#version 300 es
67
+ ${geometrytransformations_1.POLE}
68
+ precision highp float;
69
+ uniform float opacity;
70
+ in vec4 v_color;
71
+ in float v_dash_ratio;
72
+ in float v_dash_opacity;
73
+ in float interpolation;
74
+ in vec2 v_limp;
75
+ out vec4 color;
76
+ void main() {
77
+ 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; }
78
+ color = v_color;
79
+ color.a *= opacity;
80
+ if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
81
+ if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
82
+ color.a *= v_dash_opacity;
83
+ }
84
+ }
85
+ `;
86
+ class Logic {
87
+ constructor(globe) {
88
+ this.globe = globe;
89
+ this.gl = globe.gl;
90
+ this._lastOpacity = 1.0;
91
+ this.program = (0, webglobjectbuilders_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
92
+ const { gl, program } = this;
93
+ this.program.uniforms = {
94
+ opacity: gl.getUniformLocation(program, "opacity")
95
+ };
96
+ { // initial uniform values
97
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
98
+ gl.useProgram(program);
99
+ gl.uniform1f(program.uniforms.opacity, 1.0);
100
+ gl.useProgram(currentProgram);
101
+ }
102
+ { // assign attribute locations
103
+ gl.bindAttribLocation(program, 0, "center_position");
104
+ gl.bindAttribLocation(program, 1, "radius");
105
+ gl.bindAttribLocation(program, 2, "color");
106
+ gl.bindAttribLocation(program, 3, "dash_ratio");
107
+ gl.bindAttribLocation(program, 4, "dash_opacity");
108
+ }
109
+ this.cameraBindingPoint = 0;
110
+ this.cameraBlockTotem = camerauniformblock_1.CameraUniformBlockTotemCache.get(globe);
111
+ const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
112
+ gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
113
+ }
114
+ createVAO(centerObj, radiusObj, colorObj, dashRatioObj, dashOpacityObj) {
115
+ const { gl } = this;
116
+ const vao = gl.createVertexArray();
117
+ const divisor = 1;
118
+ gl.bindVertexArray(vao);
119
+ { // make this a function end import from account module.
120
+ const { buffer, stride = 0, offset = 0 } = centerObj;
121
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 0, 2, stride, offset, divisor);
122
+ }
123
+ {
124
+ const { buffer, stride = 0, offset = 0 } = radiusObj;
125
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 1, 1, stride, offset, divisor);
126
+ }
127
+ {
128
+ const { buffer, stride = 0, offset = 0 } = colorObj;
129
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 2, 4, stride, offset, divisor);
130
+ }
131
+ {
132
+ const { buffer, stride = 0, offset = 0 } = dashRatioObj;
133
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 3, 1, stride, offset, divisor);
134
+ }
135
+ {
136
+ const { buffer, stride = 0, offset = 0 } = dashOpacityObj;
137
+ (0, util_1.vaoAttributeLoader)(gl, buffer, 4, 1, stride, offset, divisor);
138
+ }
139
+ gl.bindVertexArray(null);
140
+ gl.bindVertexArray(null);
141
+ return vao;
142
+ }
143
+ draw(vao, length, opacity) {
144
+ const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
145
+ gl.useProgram(program);
146
+ if (this._lastOpacity !== opacity) {
147
+ gl.uniform1f(program.uniforms.opacity, opacity);
148
+ this._lastOpacity = opacity;
149
+ }
150
+ gl.bindVertexArray(vao);
151
+ cameraBlockTotem.bind(cameraBindingPoint);
152
+ gl.drawArraysInstanced(gl.LINE_STRIP, 0, EDGE_COUNT_ON_SPHERE + 1, length);
153
+ cameraBlockTotem.unbind(cameraBindingPoint);
154
+ gl.bindVertexArray(null);
155
+ }
156
+ free() {
157
+ if (this.isFreed)
158
+ return;
159
+ camerauniformblock_1.CameraUniformBlockTotemCache.release(this.globe);
160
+ this.gl.deleteProgram(this.program);
161
+ this.isFreed = true;
162
+ }
163
+ }
164
+ exports.CircleCache = Object.freeze({
165
+ get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
166
+ release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
167
+ });