@pirireis/webglobeplugins 0.9.5 → 0.9.7

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 (226) hide show
  1. package/package.json +8 -2
  2. package/Math/angle-calculation.js +0 -14
  3. package/Math/arc.ts +0 -76
  4. package/Math/bounds/line-bbox.js +0 -225
  5. package/Math/constants.ts +0 -11
  6. package/Math/frustum/camera.ts +0 -32
  7. package/Math/frustum/from-globeinfo.ts +0 -63
  8. package/Math/frustum/types.ts +0 -11
  9. package/Math/globe-util/horizon-plane.ts +0 -137
  10. package/Math/index.js +0 -0
  11. package/Math/juction/arc-plane.ts +0 -114
  12. package/Math/juction/line-sphere.ts +0 -30
  13. package/Math/juction/plane-plane.ts +0 -66
  14. package/Math/line.ts +0 -70
  15. package/Math/matrix4.ts +0 -0
  16. package/Math/methods.js +0 -237
  17. package/Math/plane.ts +0 -86
  18. package/Math/quaternion.ts +0 -120
  19. package/Math/roadmap.md +0 -10
  20. package/Math/types.ts +0 -45
  21. package/Math/utils.js +0 -3
  22. package/Math/vec3.ts +0 -155
  23. package/algorithms/search-binary.js +0 -14
  24. package/altitude-locator/adaptors.js +0 -0
  25. package/altitude-locator/draw-subset-obj.js +0 -27
  26. package/altitude-locator/keymethod.js +0 -0
  27. package/altitude-locator/plugin.js +0 -439
  28. package/altitude-locator/types.js +0 -26
  29. package/arrowfield/adaptor.js +0 -11
  30. package/arrowfield/index.js +0 -3
  31. package/arrowfield/plugin.js +0 -128
  32. package/bearing-line/index.js +0 -2
  33. package/bearing-line/plugin.js +0 -512
  34. package/circle-line-chain/chain-list-map.js +0 -221
  35. package/circle-line-chain/init.js +0 -0
  36. package/circle-line-chain/plugin.js +0 -469
  37. package/circle-line-chain/readme.md +0 -57
  38. package/circle-line-chain/util.js +0 -1
  39. package/compass-rose/compass-rose-padding-flat.js +0 -266
  40. package/compass-rose/compass-text-writer.js +0 -173
  41. package/compass-rose/index.js +0 -3
  42. package/compassrose/compassrose.js +0 -341
  43. package/compassrose/index.js +0 -2
  44. package/depth-locator/readme.md +0 -26
  45. package/globe-types.ts +0 -13
  46. package/heatwave/index.js +0 -4
  47. package/heatwave/isobar/objectarraylabels.js +0 -247
  48. package/heatwave/isobar/plugin.js +0 -340
  49. package/heatwave/isobar/quadtreecontours.js +0 -336
  50. package/heatwave/plugins/heatwaveglobeshell.js +0 -258
  51. package/jest.config.js +0 -6
  52. package/partialrings/buffer-manager.js +0 -89
  53. package/partialrings/goals.md +0 -17
  54. package/partialrings/index.js +0 -3
  55. package/partialrings/plugin.js +0 -160
  56. package/partialrings/program.js +0 -324
  57. package/pin/pin-object-array.js +0 -381
  58. package/pin/pin-point-totem.js +0 -77
  59. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +0 -78
  60. package/point-heat-map/index.js +0 -0
  61. package/point-heat-map/plugin-webworker.js +0 -151
  62. package/point-heat-map/point-to-heat-map-flow.js +0 -150
  63. package/point-heat-map/readme.md +0 -15
  64. package/point-tracks/key-methods.js +0 -3
  65. package/point-tracks/plugin.js +0 -394
  66. package/programs/arrowfield/index.js +0 -2
  67. package/programs/arrowfield/logic.js +0 -286
  68. package/programs/arrowfield/object.js +0 -89
  69. package/programs/data2legend/density-to-legend.js +0 -115
  70. package/programs/data2legend/point-to-density-texture.js +0 -114
  71. package/programs/float2legendwithratio/index.js +0 -3
  72. package/programs/float2legendwithratio/logic.js +0 -194
  73. package/programs/float2legendwithratio/object.js +0 -141
  74. package/programs/globe-util/is-globe-moved.js +0 -27
  75. package/programs/globeshell/index.js +0 -2
  76. package/programs/globeshell/noise/noises.js +0 -0
  77. package/programs/globeshell/wiggle/index.js +0 -6
  78. package/programs/globeshell/wiggle/logic.js +0 -371
  79. package/programs/globeshell/wiggle/object.js +0 -93
  80. package/programs/helpers/blender/index.js +0 -0
  81. package/programs/helpers/blender/program.js +0 -91
  82. package/programs/helpers/fadeaway/index.js +0 -3
  83. package/programs/helpers/fadeaway/logic.js +0 -76
  84. package/programs/helpers/fadeaway/object.js +0 -20
  85. package/programs/helpers/index.js +0 -2
  86. package/programs/index.js +0 -21
  87. package/programs/interface.ts +0 -7
  88. package/programs/line-on-globe/angled-line.js +0 -206
  89. package/programs/line-on-globe/circle-accurate-3d.js +0 -167
  90. package/programs/line-on-globe/circle-accurate-flat.js +0 -262
  91. package/programs/line-on-globe/circle-accurate.js +0 -202
  92. package/programs/line-on-globe/circle.js +0 -191
  93. package/programs/line-on-globe/degree-padding-around-circle-3d.js +0 -188
  94. package/programs/line-on-globe/index.js +0 -0
  95. package/programs/line-on-globe/lines-color-instanced-flat.js +0 -151
  96. package/programs/line-on-globe/linestrip.ts +0 -228
  97. package/programs/line-on-globe/naive-accurate-flexible.js +0 -239
  98. package/programs/line-on-globe/to-the-surface.js +0 -129
  99. package/programs/line-on-globe/util.js +0 -8
  100. package/programs/picking/pickable-renderer.js +0 -216
  101. package/programs/point-on-globe/element-globe-surface-glow.js +0 -168
  102. package/programs/point-on-globe/element-point-glow.js +0 -184
  103. package/programs/point-on-globe/square-pixel-point.js +0 -189
  104. package/programs/programcache.ts +0 -131
  105. package/programs/rings/distancering/circleflatprogram.js +0 -136
  106. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -378
  107. package/programs/rings/distancering/circlepaddysharedbuffer.js +0 -420
  108. package/programs/rings/distancering/index.js +0 -5
  109. package/programs/rings/distancering/paddyflatprogram.js +0 -146
  110. package/programs/rings/distancering/paddyflatprogram2d.js +0 -150
  111. package/programs/rings/distancering/paddyflatprogram3d.js +0 -146
  112. package/programs/rings/distancering/shader.js +0 -0
  113. package/programs/rings/index.js +0 -1
  114. package/programs/rings/partial-ring/piece-of-pie.js +0 -315
  115. package/programs/totems/camerauniformblock.d.ts +0 -48
  116. package/programs/totems/camerauniformblock.js +0 -197
  117. package/programs/totems/canvas-webglobe-info.js +0 -136
  118. package/programs/totems/gpu-selection-uniform-block.js +0 -132
  119. package/programs/totems/index.ts +0 -2
  120. package/programs/two-d/pixel-circle.js +0 -0
  121. package/programs/two-d/pixel-padding-for-compass.js +0 -174
  122. package/programs/util.js +0 -20
  123. package/programs/vectorfields/index.js +0 -3
  124. package/programs/vectorfields/logics/drawrectangleparticles.js +0 -125
  125. package/programs/vectorfields/logics/index.js +0 -5
  126. package/programs/vectorfields/logics/pixelbased.js +0 -161
  127. package/programs/vectorfields/logics/ubo.js +0 -64
  128. package/programs/vectorfields/pingpongbuffermanager.js +0 -80
  129. package/publish.bat +0 -60
  130. package/rangerings/enum.js +0 -3
  131. package/rangerings/index.js +0 -5
  132. package/rangerings/plugin.js +0 -649
  133. package/rangerings/rangeringangletext.js +0 -368
  134. package/rangerings/ring-account.js +0 -129
  135. package/shaders/fragment-toy/firework.js +0 -55
  136. package/shaders/fragment-toy/singularity.js +0 -59
  137. package/shape-on-terrain/arc/naive/plugin.ts +0 -304
  138. package/shape-on-terrain/goal.md +0 -12
  139. package/tests/Math/junction/arc-plane.test.ts +0 -133
  140. package/tests/Math/junction/plane-plane.test.ts +0 -82
  141. package/tests/Math/plane.test.ts +0 -43
  142. package/tests/Math/vec3.test.ts +0 -14
  143. package/timetracks/adaptors-line-strip.js +0 -80
  144. package/timetracks/adaptors.js +0 -133
  145. package/timetracks/index.js +0 -6
  146. package/timetracks/plugin-line-strip.js +0 -295
  147. package/timetracks/plugin.js +0 -304
  148. package/timetracks/program-line-strip.js +0 -688
  149. package/timetracks/program.js +0 -850
  150. package/timetracks/programpoint-line-strip.js +0 -175
  151. package/timetracks/programpoint.js +0 -168
  152. package/timetracks/readme.md +0 -1
  153. package/tsconfig.json +0 -21
  154. package/types.ts +0 -17
  155. package/util/account/bufferoffsetmanager.js +0 -209
  156. package/util/account/index.js +0 -6
  157. package/util/account/single-attribute-buffer-management/buffer-manager.ts +0 -119
  158. package/util/account/single-attribute-buffer-management/buffer-orchestrator.ts +0 -173
  159. package/util/account/single-attribute-buffer-management/index.ts +0 -13
  160. package/util/account/single-attribute-buffer-management/object-store.ts +0 -65
  161. package/util/account/single-attribute-buffer-management/types.ts +0 -39
  162. package/util/account/util.js +0 -22
  163. package/util/algorithms/index.js +0 -0
  164. package/util/algorithms/search-binary.js +0 -26
  165. package/util/check/get.js +0 -13
  166. package/util/check/index.js +0 -0
  167. package/util/check/typecheck.js +0 -39
  168. package/util/geometry/index.js +0 -53
  169. package/util/gl-util/buffer/attribute-loader.ts +0 -85
  170. package/util/gl-util/buffer/index.ts +0 -6
  171. package/util/gl-util/buffer/types.ts +0 -13
  172. package/util/gl-util/draw-options/methods.ts +0 -66
  173. package/util/gl-util/draw-options/types.ts +0 -28
  174. package/util/gl-util/uniform-block/manager.ts +0 -187
  175. package/util/gl-util/uniform-block/roadmap.md +0 -70
  176. package/util/gl-util/uniform-block/shader.js +0 -0
  177. package/util/gl-util/uniform-block/types.ts +0 -27
  178. package/util/heatwavedatamanager/datamanager.js +0 -168
  179. package/util/heatwavedatamanager/index.js +0 -3
  180. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +0 -133
  181. package/util/heatwavedatamanager/pointcoordsmeta.js +0 -22
  182. package/util/index.js +0 -13
  183. package/util/interpolation/index.js +0 -0
  184. package/util/interpolation/timetrack/index.js +0 -9
  185. package/util/interpolation/timetrack/timetrack-interpolator.js +0 -88
  186. package/util/interpolation/timetrack/web-worker-str.js +0 -180
  187. package/util/interpolation/timetrack/web-worker.js +0 -51
  188. package/util/jshelpers/data-filler.js +0 -19
  189. package/util/jshelpers/equality.js +0 -17
  190. package/util/jshelpers/index.js +0 -1
  191. package/util/jshelpers/timefilters.js +0 -32
  192. package/util/picking/fence.js +0 -46
  193. package/util/picking/picker-displayer.js +0 -177
  194. package/util/programs/draw-texture-on-canvas.js +0 -102
  195. package/util/programs/index.js +0 -1
  196. package/util/programs/shapesonglobe.js +0 -246
  197. package/util/programs/supersampletotextures.js +0 -142
  198. package/util/programs/texturetoglobe.js +0 -203
  199. package/util/shaderfunctions/geometrytransformations.ts +0 -388
  200. package/util/shaderfunctions/index.js +0 -2
  201. package/util/shaderfunctions/nodata.js +0 -10
  202. package/util/shaderfunctions/noisefunctions.js +0 -44
  203. package/util/surface-line-data/arc-bboxes.ts +0 -42
  204. package/util/surface-line-data/arcs-to-cuts.js +0 -74
  205. package/util/surface-line-data/cut-arc.js +0 -0
  206. package/util/surface-line-data/flow.ts +0 -52
  207. package/util/surface-line-data/rbush-manager.js +0 -0
  208. package/util/surface-line-data/types.ts +0 -27
  209. package/util/surface-line-data/web-worker.js +0 -0
  210. package/util/webglobe/gldefaultstates.js +0 -5
  211. package/util/webglobe/index.js +0 -2
  212. package/util/webglobe/rasteroverlay.js +0 -96
  213. package/util/webglobjectbuilders.ts +0 -456
  214. package/util/webglobjectbuilders1.js +0 -271
  215. package/waveparticles/adaptor.js +0 -16
  216. package/waveparticles/index.js +0 -3
  217. package/waveparticles/plugin.js +0 -313
  218. package/wind/imagetovectorfieldandmagnitude.js +0 -39
  219. package/wind/index.js +0 -5
  220. package/wind/plugin.js +0 -1057
  221. package/wind/vectorfieldimage.js +0 -27
  222. package/write-text/attached-text-writer.js +0 -105
  223. package/write-text/context-text.js +0 -125
  224. package/write-text/context-text3.js +0 -178
  225. package/write-text/index.js +0 -1
  226. package/write-text/writer-plugin.js +0 -7
@@ -1,206 +0,0 @@
1
- // angle radius, rgba, dashRatio, rgbaMode
2
-
3
-
4
- import { createProgram } from "../../util";
5
- import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
6
- import {
7
- longLatRadToMercator, longLatRadToCartesian3D, cartesian3DToGLPosition, mercatorXYToGLPosition,
8
- circleLimpFromLongLatRadCenterCartesian3D,
9
- circleLimpFromLongLatRadCenterMercatorCompass,
10
- circleLimpFromLongLatRadCenterMercatorRealDistance,
11
- POLE
12
- } from "../../util/shaderfunctions/geometrytransformations";
13
- import { noRegisterGlobeProgramCache } from "../programcache";
14
-
15
-
16
- const EDGE_COUNT_ON_SPHERE = 50;
17
-
18
- const vertexShaderSource = `#version 300 es
19
- precision highp float;
20
-
21
- ${CameraUniformBlockString}
22
- ${longLatRadToMercator}
23
- ${longLatRadToCartesian3D}
24
- ${cartesian3DToGLPosition}
25
- ${mercatorXYToGLPosition}
26
- ${circleLimpFromLongLatRadCenterCartesian3D}
27
- ${circleLimpFromLongLatRadCenterMercatorCompass}
28
- ${circleLimpFromLongLatRadCenterMercatorRealDistance}
29
-
30
- in vec2 center_point;
31
- in float angle;
32
- in float radius;
33
- in vec4 rgba;
34
- in float dash_ratio;
35
- in float dash_opacity;
36
-
37
- out vec4 v_color;
38
- out float v_dash_ratio;
39
- out float interpolation;
40
- out float v_dash_opacity;
41
- out vec2 v_limp;
42
- // TODO: Draw World Boundaries
43
- void main() {
44
- if ( is3D ) {
45
- interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE - 1}.0;
46
- float radius_ = radius* interpolation;
47
- vec3 position = circleLimpFromLongLatRadCenterCartesian3D( center_point, radius_, angle);
48
- gl_Position = cartesian3DToGLPosition( position);
49
- v_limp = vec2(0.0, 0.0);
50
- } else {
51
- interpolation = float( gl_VertexID );
52
- float radius_ = radius * interpolation;
53
- vec2 position = circleLimpFromLongLatRadCenterMercatorRealDistance( center_point, radius_, angle);
54
- v_limp = position;
55
- gl_Position = mercatorXYToGLPosition( position);
56
- }
57
- v_dash_opacity = dash_opacity;
58
- v_color = rgba;
59
- v_dash_ratio = dash_ratio;
60
- }`;
61
-
62
-
63
-
64
- const fragmentShaderSource = `#version 300 es
65
- ${POLE}
66
- precision highp float;
67
-
68
- uniform float opacity;
69
- in vec4 v_color;
70
- in float v_dash_ratio;
71
- in float v_dash_opacity;
72
- in float interpolation;
73
- in vec2 v_limp;
74
- out vec4 color;
75
-
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 = vec4(v_color.rgb, v_color.a * opacity);
79
- if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
80
- color.a *= v_dash_opacity;
81
- }
82
- }`;
83
-
84
-
85
- class Logic {
86
-
87
- constructor(globe) {
88
-
89
- this.globe = globe;
90
- this.gl = globe.gl;
91
- this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
92
- this._lastOpacity = 1;
93
-
94
- const { gl, program } = this;
95
- { // assign attribute locations
96
- gl.bindAttribLocation(program, 0, "center_point");
97
- gl.bindAttribLocation(program, 1, "angle");
98
- gl.bindAttribLocation(program, 2, "radius");
99
- gl.bindAttribLocation(program, 3, "rgba");
100
- gl.bindAttribLocation(program, 4, "dash_ratio");
101
- gl.bindAttribLocation(program, 5, "dash_opacity");
102
- }
103
-
104
- {
105
- this._opacityLocation = gl.getUniformLocation(program, "opacity");
106
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
107
- gl.useProgram(program);
108
- gl.uniform1f(this._opacityLocation, this._lastOpacity);
109
- gl.useProgram(currentProgram);
110
- }
111
-
112
- this.cameraBlockBindingPoint = 0;
113
- const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
114
- this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
115
- gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
116
-
117
- }
118
-
119
-
120
- draw(vao, length, opacity) {
121
- const { gl, program, globe, cameraBlockTotem, cameraBlockBindingPoint } = this;
122
- gl.useProgram(program);
123
- if (opacity !== this._lastOpacity) {
124
- gl.uniform1f(this._opacityLocation, opacity);
125
- this._lastOpacity = opacity;
126
- }
127
- const drawCount = globe.api_GetCurrentGeometry() === 0 ? EDGE_COUNT_ON_SPHERE : 2;
128
- gl.bindVertexArray(vao);
129
- cameraBlockTotem.bind(cameraBlockBindingPoint)
130
- // gl.disable(gl.DEPTH_TEST);
131
- gl.drawArraysInstanced(gl.LINE_STRIP, 0, drawCount, length);
132
- gl.bindVertexArray(null);
133
- cameraBlockTotem.unbind(cameraBlockBindingPoint);
134
- // gl.enable(gl.DEPTH_TEST);
135
- }
136
-
137
-
138
- createVAO(centerCoords, angle, radius, rgba, dashRatio, dashOpacity) {
139
-
140
- const { gl } = this;
141
- const vao = gl.createVertexArray();
142
- gl.bindVertexArray(vao);
143
- {
144
- const { buffer, stride = 0, offset = 0 } = centerCoords;
145
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
146
- gl.enableVertexAttribArray(0);
147
- gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
148
- gl.vertexAttribDivisor(0, 1);
149
- }
150
- {
151
- const { buffer, stride = 0, offset = 0 } = angle;
152
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
153
- gl.enableVertexAttribArray(1);
154
- gl.vertexAttribPointer(1, 1, gl.FLOAT, false, stride, offset);
155
- gl.vertexAttribDivisor(1, 1);
156
- }
157
- {
158
- const { buffer, stride = 0, offset = 0 } = radius;
159
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
160
- gl.enableVertexAttribArray(2);
161
- gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
162
- gl.vertexAttribDivisor(2, 1);
163
- }
164
-
165
- {
166
- const { buffer, stride = 0, offset = 0 } = rgba;
167
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
168
- gl.enableVertexAttribArray(3);
169
- gl.vertexAttribPointer(3, 4, gl.FLOAT, false, stride, offset);
170
- gl.vertexAttribDivisor(3, 1);
171
- }
172
- {
173
- const { buffer, stride = 0, offset = 0 } = dashRatio;
174
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
175
- gl.enableVertexAttribArray(4);
176
- gl.vertexAttribPointer(4, 1, gl.FLOAT, false, stride, offset);
177
- gl.vertexAttribDivisor(4, 1);
178
- }
179
- {
180
- const { buffer, stride = 0, offset = 0 } = dashOpacity;
181
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
182
- gl.enableVertexAttribArray(5);
183
- gl.vertexAttribPointer(5, 1, gl.FLOAT, false, stride, offset);
184
- gl.vertexAttribDivisor(5, 1);
185
- }
186
- gl.bindVertexArray(null);
187
- return vao;
188
- }
189
-
190
-
191
- free() {
192
- if (this.isFreed) return;
193
- CameraUniformBlockTotemCache.release(this.globe);
194
- this.cameraBlockTotem = null;
195
- this.gl.deleteProgram(this.program);
196
- this.isFreed = true;
197
- }
198
-
199
-
200
- }
201
-
202
-
203
- export const AngledLineProgramCache = Object.freeze({
204
- get: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
205
- release: (globe) => { return noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
206
- });
@@ -1,167 +0,0 @@
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 { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
6
- import {
7
- cartesian3DToGLPosition,
8
- circleLimpFromLongLatRadCenterCartesian3D_accurate,
9
- circleOnSphere,
10
- POLE,
11
- PI
12
- } from "../../util/shaderfunctions/geometrytransformations";
13
-
14
-
15
- /**
16
- * TODO:
17
- * 1. integrate geometry functions for radius angle and center
18
- * 2. integrate attributes
19
- *
20
- * TODO:
21
- * center_position is too small or doenst loaded as expected.
22
- */
23
- const EDGE_COUNT_ON_SPHERE = 360;
24
- //${circleLimpFromLongLatRadCenterCartesian3D_accurate}
25
- const vertexShaderSource = `#version 300 es
26
- precision highp float;
27
- ${PI}
28
- ${CameraUniformBlockString}
29
- ${cartesian3DToGLPosition}
30
- ${circleOnSphere}
31
-
32
- uniform float edge_count;
33
-
34
- in vec3 center_position3d;
35
- in vec3 target_position3d;
36
- // in float radius;
37
- in vec4 color;
38
- in float dash_ratio;
39
- in float dash_opacity;
40
-
41
- out float interpolation;
42
- out vec4 v_color;
43
- out float v_dash_ratio;
44
- out float v_dash_opacity;
45
- void main() {
46
- interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE}.0;
47
- if ( is3D ) {
48
- float angle = PI * 2.0 * interpolation;
49
- vec3 position = circleOnSphere(center_position3d, target_position3d, angle);
50
- gl_Position = cartesian3DToGLPosition(position);
51
- } else {
52
- return;
53
- }
54
- v_dash_ratio = dash_ratio;
55
- v_dash_opacity = dash_opacity;
56
- v_color = color;
57
- gl_PointSize = 3.0;
58
- }`
59
-
60
- const fragmentShaderSource = `#version 300 es
61
- ${POLE}
62
- precision highp float;
63
- uniform float opacity;
64
- in vec4 v_color;
65
- in float v_dash_ratio;
66
- in float v_dash_opacity;
67
- in float interpolation;
68
- in vec2 v_limp;
69
- out vec4 color;
70
- void main() {
71
- color = v_color;
72
- color.a *= opacity;
73
- if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
74
- if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
75
- color.a *= v_dash_opacity;
76
- }
77
- }
78
- `;
79
-
80
-
81
-
82
- class Logic {
83
-
84
- constructor(globe) {
85
- this.globe = globe;
86
- this.gl = globe.gl;
87
- this._lastOpacity = 1.0;
88
-
89
- this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
90
-
91
- const { gl, program } = this;
92
- this.program.uniforms = {
93
- opacity: gl.getUniformLocation(program, "opacity")
94
- };
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
-
103
- { // assign attribute locations
104
- gl.bindAttribLocation(program, 0, "center_position3d");
105
- gl.bindAttribLocation(program, 1, "target_position3d");
106
- gl.bindAttribLocation(program, 2, "color");
107
- gl.bindAttribLocation(program, 3, "dash_ratio");
108
- gl.bindAttribLocation(program, 4, "dash_opacity");
109
- }
110
-
111
- this.cameraBindingPoint = 0;
112
- this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
113
- const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
114
- gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
115
- }
116
-
117
- createVAO(center3dObj, target3dObj, colorObj, dashRatioObj, dashOpacityObj) {
118
- const { gl } = this;
119
- const vao = gl.createVertexArray();
120
- const divisor = 1;
121
-
122
- gl.bindVertexArray(vao);
123
-
124
- attributeLoader(gl, center3dObj, 0, 3, { divisor });
125
- attributeLoader(gl, target3dObj, 1, 3, { divisor });
126
- // attributeLoader(gl, radiusObj, 1, 1, { divisor });
127
- attributeLoader(gl, colorObj, 2, 4, { divisor });
128
- attributeLoader(gl, dashRatioObj, 3, 1, { divisor });
129
- attributeLoader(gl, dashOpacityObj, 4, 1, { divisor });
130
-
131
- gl.bindVertexArray(null);
132
- gl.bindVertexArray(null);
133
- return vao;
134
- }
135
-
136
- draw(vao, length, opacity) {
137
- const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
138
- gl.useProgram(program);
139
-
140
- if (this._lastOpacity !== opacity) {
141
- gl.uniform1f(program.uniforms.opacity, opacity);
142
- this._lastOpacity = opacity;
143
- }
144
- gl.bindVertexArray(vao);
145
- cameraBlockTotem.bind(cameraBindingPoint);
146
- gl.drawArraysInstanced(gl.LINE_STRIP, 0, EDGE_COUNT_ON_SPHERE + 1, length);
147
- // gl.drawArraysInstanced(gl.POINTS, 0, EDGE_COUNT_ON_SPHERE + 1, length);
148
- cameraBlockTotem.unbind(cameraBindingPoint);
149
- gl.bindVertexArray(null);
150
- }
151
-
152
-
153
-
154
- free() {
155
- if (this.isFreed) return;
156
- CameraUniformBlockTotemCache.release(this.globe);
157
- this.gl.deleteProgram(this.program);
158
- this.isFreed = true;
159
- }
160
- }
161
-
162
-
163
-
164
- export const CircleCache = Object.freeze({
165
- get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
166
- release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
167
- });
@@ -1,262 +0,0 @@
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
- mercatorXYToGLPosition, POLE
7
- } from "../../util/shaderfunctions/geometrytransformations";
8
-
9
- const Pole = 20037508.34;
10
- /**
11
- * Warning:
12
- * Insert the points from the second index and skip 1 point as you placed 361 points
13
- */
14
-
15
- /**
16
- * Plus 1 for returning to the start point. 1 for cutting the circle into pieces.
17
- */
18
- const EDGE_COUNT = 62;
19
- const ESCAPE_VALUE = 200000000;
20
-
21
- const vertexShaderSource = `#version 300 es
22
- precision highp float;
23
-
24
- # define escape_value ${ESCAPE_VALUE}.0
25
-
26
- ${CameraUniformBlockString}
27
- ${mercatorXYToGLPosition}
28
-
29
- uniform int edge_count;
30
-
31
-
32
- in vec2 position2d;
33
- in vec4 color;
34
- in float dash_ratio;
35
- in float dash_opacity;
36
-
37
- out float interpolation;
38
- out vec4 v_color;
39
- out float v_dash_ratio;
40
- out float v_dash_opacity;
41
- out vec2 v_limp;
42
-
43
-
44
- void main() {
45
- if ( position2d.x == escape_value && position2d.y == escape_value){ return; }
46
- interpolation = float( gl_VertexID % edge_count ) / float(edge_count);
47
- if ( gl_VertexID % edge_count == 0 ) { return; } // cut on the first point.
48
- if ( is3D ) {
49
- return;
50
- v_limp = vec2(0.0, 0.0);
51
- } else {
52
- v_limp = position2d;
53
- gl_Position = mercatorXYToGLPosition( position2d);
54
- }
55
- v_dash_ratio = dash_ratio;
56
- v_dash_opacity = dash_opacity;
57
- v_color = color;
58
- gl_PointSize = 15.0;
59
-
60
- }`
61
-
62
- const fragmentShaderSource = `#version 300 es
63
- ${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
-
86
-
87
-
88
- class Logic {
89
-
90
-
91
- constructor(globe) {
92
- this.globe = globe;
93
- this.gl = globe.gl;
94
- this._lastOpacity = 1.0;
95
- this._lastMercatorMode = 0;
96
- this._lastEdgeCount = EDGE_COUNT;
97
- this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
98
-
99
- const { gl, program } = this;
100
- this.program.uniforms = {
101
- opacity: gl.getUniformLocation(program, "opacity"),
102
- edgeCount: gl.getUniformLocation(program, "edge_count"),
103
- mercator_calculation_mode: gl.getUniformLocation(program, "mercator_calculation_mode")
104
- };
105
-
106
- // initial uniform values
107
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
108
- gl.useProgram(program);
109
- gl.uniform1f(program.uniforms.opacity, 1.0);
110
- gl.uniform1i(program.uniforms.edgeCount, EDGE_COUNT);
111
- gl.uniform1i(program.uniforms.mercator_calculation_mode, 0);
112
- gl.useProgram(currentProgram);
113
-
114
- // assign attribute locations
115
- gl.bindAttribLocation(program, 0, "position2d");
116
- gl.bindAttribLocation(program, 1, "color");
117
- gl.bindAttribLocation(program, 2, "dash_ratio");
118
- gl.bindAttribLocation(program, 3, "dash_opacity");
119
-
120
- this.cameraBindingPoint = 0;
121
- this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
122
- const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
123
- gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
124
- }
125
-
126
-
127
- createVAO(centerObj, colorObj, dashRatioObj, dashOpacityObj) {
128
- const { gl } = this;
129
- const vao = gl.createVertexArray();
130
- gl.bindVertexArray(vao);
131
- { // make this a function end import from account module.
132
- const { buffer, stride = 0, offset = 0 } = centerObj;
133
- vaoAttributeLoader(gl, buffer, 0, 2, stride, offset, null);
134
- }
135
-
136
- {
137
- const { buffer, stride = 0, offset = 0 } = colorObj;
138
- vaoAttributeLoader(gl, buffer, 1, 4, stride, offset, null);
139
- }
140
- {
141
- const { buffer, stride = 0, offset = 0 } = dashRatioObj;
142
- vaoAttributeLoader(gl, buffer, 2, 1, stride, offset, null);
143
- }
144
- {
145
- const { buffer, stride = 0, offset = 0 } = dashOpacityObj;
146
- vaoAttributeLoader(gl, buffer, 3, 1, stride, offset, null);
147
- }
148
- gl.bindVertexArray(null);
149
- gl.bindVertexArray(null);
150
- return vao;
151
- }
152
-
153
-
154
- draw(vao, length, edgeCount, opacity) {
155
- const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
156
- gl.useProgram(program);
157
- if (this._lastOpacity !== opacity) {
158
- gl.uniform1f(program.uniforms.opacity, opacity);
159
- this._lastOpacity = opacity;
160
- }
161
- if (this._lastEdgeCount !== edgeCount) {
162
- gl.uniform1i(program.uniforms.edgeCount, edgeCount);
163
- this._lastEdgeCount = edgeCount;
164
- }
165
- gl.bindVertexArray(vao);
166
- cameraBlockTotem.bind(cameraBindingPoint);
167
- gl.drawArrays(gl.LINE_STRIP, 0, length * edgeCount)
168
- // gl.drawArrays(gl.POINTS, 0, length * EDGE_COUNT)
169
- cameraBlockTotem.unbind(cameraBindingPoint);
170
- gl.bindVertexArray(null);
171
- }
172
-
173
-
174
- free() {
175
- if (this.isFreed) return;
176
- CameraUniformBlockTotemCache.release(this.globe);
177
- this.gl.deleteProgram(this.program);
178
- this.isFreed = true;
179
- }
180
- }
181
-
182
-
183
-
184
- const CircleCache = Object.freeze({
185
- get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
186
- release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
187
- });
188
-
189
-
190
- function centerCoords2dflatDataCreator(globe, centerLong, centerLat, targetLong, targetLat, { startAngleOfCircle = null, edgeCount = EDGE_COUNT, radiusOffset = 0 } = {}) {
191
- const centerCoords2dflat = new Float32Array(edgeCount * 2);
192
- const radius2d = globe.Math.GetDist2D(centerLong, centerLat, targetLong, targetLat) + radiusOffset;
193
- let angle;
194
- if (startAngleOfCircle === null) {
195
- angle = globe.Math.GetAzimuthAngle(centerLong, centerLat, targetLong, targetLat);
196
- } else {
197
- angle = startAngleOfCircle;
198
- }
199
- const pointsLongLat = globe.Math.GetEllipseGeo(
200
- centerLong,
201
- centerLat,
202
- radius2d,
203
- radius2d,
204
- angle,
205
- 360 / (edgeCount - 2), // 1 for return to start point, 1 for cutting circles
206
- );
207
-
208
- let lastlg = pointsLongLat[0].long;
209
- let lastlt = pointsLongLat[0].lat;
210
-
211
- for (let i = 1; i < edgeCount; i++) {
212
- const { long: lg, lat: lt } = pointsLongLat[i - 1];
213
- if (manhattanDistance(lastlg, lastlt, lg, lt) < 170) {
214
- centerCoords2dflat.set(
215
- globe.api_GetMercator2DPoint(lg, lt)
216
- , i * 2);
217
- } else {
218
- centerCoords2dflat.set([NaN, NaN], i * 2);
219
- }
220
- lastlg = lg;
221
- lastlt = lt;
222
- }
223
- return centerCoords2dflat;
224
- }
225
-
226
-
227
- function centerCoords2dflatDataCreatorWithRadius(globe, centerLong, centerLat, radius2d, { startAngleOfCircle = null, edgeCount = EDGE_COUNT } = {}) {
228
- const centerCoords2dflat = new Float32Array(edgeCount * 2);
229
- const pointsLongLat = globe.Math.GetEllipseGeo(
230
- centerLong,
231
- centerLat,
232
- radius2d,
233
- radius2d,
234
- 0,
235
- 360 / (edgeCount - 2), // 1 for return to start point, 1 for cutting circles
236
- );
237
-
238
- let { long: lastlg, lat: lastlt } = pointsLongLat[0];
239
- for (let i = 1; i < edgeCount; i++) {
240
- const { long: lg, lat: lt } = pointsLongLat[i - 1];
241
- if (manhattanDistance(lastlg, lastlt, lg, lt) < 170) {
242
- centerCoords2dflat.set(
243
- globe.api_GetMercator2DPoint(lg, lt)
244
- , i * 2);
245
- } else {
246
- centerCoords2dflat.set([NaN, NaN], i * 2);
247
- }
248
- lastlg = lg;
249
- lastlt = lt;
250
- }
251
- return centerCoords2dflat;
252
- }
253
-
254
-
255
- function manhattanDistance(x1, y1, x2, y2) {
256
- return Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2));
257
- }
258
-
259
-
260
- export {
261
- CircleCache, EDGE_COUNT, centerCoords2dflatDataCreator, centerCoords2dflatDataCreatorWithRadius
262
- }