@pirireis/webglobeplugins 0.9.6 → 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 +5 -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 -22
  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,189 +0,0 @@
1
- import { createProgram } from "../../util";
2
- import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
3
- import { mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
4
- import { noRegisterGlobeProgramCache } from "../programcache";
5
-
6
-
7
- const vs = `#version 300 es
8
- ${CameraUniformBlockString}
9
- ${mercatorXYToGLPosition}
10
- ${cartesian3DToGLPosition}
11
- precision highp float;
12
- precision highp int;
13
-
14
- uniform int hovered_vertexID; // can be removed
15
-
16
- in vec3 pos3D;
17
- in vec2 pos2D;
18
- in vec4 rgba;
19
-
20
- uniform float pointSize;
21
- uniform float hoveredPointSize;
22
-
23
- flat out highp int vVertexID;
24
-
25
-
26
- out vec4 v_rgba;
27
-
28
- void main() {
29
-
30
- if(is3D){
31
- gl_Position = cartesian3DToGLPosition(pos3D);
32
- }
33
- else{
34
- gl_Position = mercatorXYToGLPosition(pos2D);
35
- }
36
- if (hovered_vertexID == gl_VertexID) {
37
- gl_PointSize = hoveredPointSize;
38
- } else {
39
- gl_PointSize = pointSize;
40
- }
41
- v_rgba = rgba;
42
- vVertexID = gl_VertexID;
43
- }`;
44
-
45
- const fs = `#version 300 es
46
- precision highp float;
47
-
48
- uniform float opacity;
49
-
50
- flat in highp int vVertexID;
51
- in vec4 v_rgba;
52
-
53
- layout(location = 0) out vec4 fragColor;
54
- layout(location = 1) out int vertexID;
55
-
56
- void main() {
57
- vertexID = vVertexID;
58
- fragColor = v_rgba;
59
- fragColor.a *= opacity;
60
- }`;
61
-
62
-
63
- class PointOnGlobeProgram {
64
-
65
- constructor(globe) {
66
-
67
- this.globe = globe;
68
- this.gl = globe.gl;
69
-
70
- this.program = createProgram(this.gl, vs, fs);
71
-
72
- const { gl, program } = this;
73
-
74
-
75
- this.uniforms = {
76
- opacity: gl.getUniformLocation(program, "opacity"),
77
- hovered_vertexID: gl.getUniformLocation(program, "hovered_vertexID"),
78
- hoveredPointSize: gl.getUniformLocation(program, "hoveredPointSize"),
79
- pointSize: gl.getUniformLocation(program, "pointSize"),
80
- }
81
-
82
- // eslint-disable-next-line
83
- { // assign opacity
84
- this._lastOpacity = 1.0;
85
- this._lastPointSize = 2.0;
86
- this._lastHoveredPointSize = 4.0;
87
- this._lastHoveredID = -1;
88
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
89
- gl.useProgram(program);
90
- gl.uniform1f(this.uniforms.opacity, this._lastOpacity);
91
- gl.uniform1f(this.uniforms.pointSize, this._lastPointSize);
92
- gl.uniform1f(this.uniforms.hoveredPointSize, this._lastHoveredPointSize);
93
- gl.uniform1i(this.uniforms.hovered_vertexID, this._lastHoveredID);
94
- gl.useProgram(currentProgram);
95
- }
96
- // eslint-disable-next-line
97
- { // assign attribute locations
98
- gl.bindAttribLocation(program, 0, "pos3D");
99
- gl.bindAttribLocation(program, 1, "pos2D");
100
- gl.bindAttribLocation(program, 2, "rgba");
101
- }
102
- // eslint-disable-next-line
103
- { // arrange camera uniform block
104
- this.cameraBlockBingingPoint = 0;
105
- this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
106
- const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
107
- gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBingingPoint);
108
- }
109
- }
110
-
111
-
112
- createVAO(pos3DBuffer, pos2DBuffer, rgbaBuffer) {
113
- const { gl } = this;
114
- const vao = gl.createVertexArray();
115
- gl.bindVertexArray(vao);
116
- // eslint-disable-next-line
117
- {
118
- gl.bindBuffer(gl.ARRAY_BUFFER, pos3DBuffer);
119
- gl.enableVertexAttribArray(0);
120
- gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
121
- }
122
- // eslint-disable-next-line
123
- {
124
- gl.bindBuffer(gl.ARRAY_BUFFER, pos2DBuffer);
125
- gl.enableVertexAttribArray(1);
126
- gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
127
- }
128
- // eslint-disable-next-line
129
- {
130
- gl.bindBuffer(gl.ARRAY_BUFFER, rgbaBuffer);
131
- gl.enableVertexAttribArray(2);
132
- gl.vertexAttribPointer(2, 4, gl.FLOAT, false, 0, 0);
133
- }
134
-
135
- gl.bindVertexArray(null);
136
- gl.bindBuffer(gl.ARRAY_BUFFER, null);
137
- return vao;
138
- }
139
-
140
-
141
- draw(vao, length, { opacity = 1.0, hoveredID = -1, pointSize = 2.0, hoveredPointSize = 4.0, elementBuffer = null } = {}) {
142
- if (length === 0 || opacity === 0) return;
143
- const { gl, program, uniforms } = this;
144
- gl.useProgram(program);
145
- if (this._lastOpacity !== opacity) {
146
- gl.uniform1f(uniforms.opacity, opacity);
147
- this._lastOpacity = opacity;
148
- }
149
- if (this._lastPointSize !== pointSize) {
150
- gl.uniform1f(uniforms.pointSize, pointSize);
151
- this._lastPointSize = pointSize;
152
- }
153
- if (this._lastHoveredPointSize !== hoveredPointSize) {
154
- gl.uniform1f(uniforms.hoveredPointSize, hoveredPointSize);
155
- this._lastHoveredPointSize = hoveredPointSize;
156
- }
157
- if (this._lastHoveredID !== hoveredID) {
158
- gl.uniform1i(uniforms.hovered_vertexID, hoveredID);
159
- this._lastHoveredID = hoveredID;
160
- }
161
- gl.bindVertexArray(vao);
162
- this.cameraBlockTotem.bind(this.cameraBlockBingingPoint);
163
- if (elementBuffer) {
164
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer);
165
- gl.drawElements(gl.POINTS, length, gl.UNSIGNED_INT, 0);
166
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
167
- } else {
168
- gl.drawArrays(gl.POINTS, 0, length);
169
- }
170
- this.cameraBlockTotem.unbind(this.cameraBlockBingingPoint);
171
- gl.bindVertexArray(null);
172
- }
173
-
174
- free() {
175
- if (this._isFreed) return;
176
- const { gl, globe } = this;
177
- CameraUniformBlockTotemCache.release(globe);
178
- gl.deleteProgram(this.program);
179
- this._isFreed = true;
180
- }
181
- }
182
-
183
-
184
- const PointOnGlobeProgramCache = Object.freeze({
185
- get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram),
186
- release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram)
187
- });
188
-
189
- export { PointOnGlobeProgramCache };
@@ -1,131 +0,0 @@
1
- /**
2
- * @module programcache
3
- * @description This module provides a cache for programs. It is used to avoid creating the same program multiple times.
4
- *
5
- * # globeProgramCache
6
- * Creates and registers programs to the globe. To the 1st object in the draw order.
7
- * The programs are generally sets sets a global uniform block.
8
- *
9
- * # glProgramCache
10
- * Creates and manages programs that are not related to the globe but to the WebGL context.
11
- * The programs created by are lightweight absraction of program logic with `constructer(gl)`.
12
- * These programs are generally wrapped by another class with more functionality.
13
- */
14
-
15
- const globeProgramCache = (function () {
16
-
17
- const cache = new Map();
18
-
19
- function getProgram(globe: any, ProgramClass: any) {
20
- if (!cache.has(globe)) { cache.set(globe, new Map()) };
21
- if (!cache.get(globe).has(ProgramClass)) {
22
- cache.get(globe).set(ProgramClass, {
23
- program: new ProgramClass(),
24
- count: 1
25
- })
26
- const firstObject = globe.DrawOrder.GetObj(0)
27
- globe.api_RegisterPlugin(cache.get(globe).get(ProgramClass).program, firstObject);
28
- } else {
29
- cache.get(globe).get(ProgramClass).count++;
30
- }
31
- return cache.get(globe).get(ProgramClass).program;
32
- };
33
-
34
- function releaseProgram(globe: any, ProgramClass: any) {
35
- if (cache.has(globe) && cache.get(globe).has(ProgramClass)) {
36
- if (cache.get(globe).get(ProgramClass).count === 0) {
37
- throw new Error("The program counter is already 0, cannot release program");
38
- }
39
- cache.get(globe).get(ProgramClass).count--;
40
- if (cache.get(globe).get(ProgramClass).count === 0) {
41
- globe.api_UnRegisterPlugin(cache.get(globe).get(ProgramClass).program.id); // it calls program.free()
42
- cache.get(globe).delete(ProgramClass);
43
- }
44
- }
45
- };
46
-
47
- return Object.freeze({
48
- getProgram,
49
- releaseProgram
50
- });
51
-
52
- })();
53
-
54
-
55
- const glProgramCache = (function () {
56
-
57
- const cache = new Map();
58
-
59
- function getProgram(gl: WebGL2RenderingContext | WebGLRenderingContext, ProgramClass: any) {
60
- if (!cache.has(gl)) { cache.set(gl, new Map()) };
61
- if (!cache.get(gl).has(ProgramClass)) {
62
- cache.get(gl).set(ProgramClass, {
63
- program: new ProgramClass(gl),
64
- count: 1
65
- })
66
- } else {
67
- cache.get(gl).get(ProgramClass).count++;
68
- }
69
- return cache.get(gl).get(ProgramClass).program;
70
- };
71
-
72
- function releaseProgram(gl: WebGL2RenderingContext | WebGLRenderingContext, ProgramClass: any) {
73
- if (cache.has(gl) && cache.get(gl).has(ProgramClass)) {
74
- if (cache.get(gl).get(ProgramClass).count === 0) {
75
- throw new Error("The program counter is already 0, cannot release program");
76
- }
77
- cache.get(gl).get(ProgramClass).count--;
78
- if (cache.get(gl).get(ProgramClass).count === 0) {
79
- cache.get(gl).get(ProgramClass).program.free();
80
- cache.get(gl).delete(ProgramClass);
81
- }
82
- }
83
- };
84
-
85
- return Object.freeze({
86
- getProgram,
87
- releaseProgram
88
- });
89
-
90
- })();
91
-
92
-
93
- const noRegisterGlobeProgramCache = (function () {
94
-
95
- const cache = new Map();
96
-
97
- function getProgram(globe: any, ProgramClass: any) {
98
- if (!cache.has(globe)) { cache.set(globe, new Map()) };
99
- if (!cache.get(globe).has(ProgramClass)) {
100
- cache.get(globe).set(ProgramClass, {
101
- program: new ProgramClass(globe),
102
- count: 1
103
- })
104
- } else {
105
- cache.get(globe).get(ProgramClass).count++;
106
- }
107
- return cache.get(globe).get(ProgramClass).program;
108
- };
109
-
110
- function releaseProgram(globe: any, ProgramClass: any) {
111
- if (cache.has(globe) && cache.get(globe).has(ProgramClass)) {
112
- if (cache.get(globe).get(ProgramClass).count === 0) {
113
- throw new Error("The program counter is already 0, cannot release program");
114
- }
115
- cache.get(globe).get(ProgramClass).count--;
116
- if (cache.get(globe).get(ProgramClass).count === 0) {
117
- cache.get(globe).get(ProgramClass).program.free();
118
- cache.get(globe).delete(ProgramClass);
119
- }
120
- }
121
- }
122
-
123
-
124
- return Object.freeze({
125
- getProgram,
126
- releaseProgram
127
- });
128
-
129
- })();
130
-
131
- export { globeProgramCache, glProgramCache, noRegisterGlobeProgramCache };
@@ -1,136 +0,0 @@
1
- import { createProgram, shaderfunctions } from "../../../util";
2
- import CameraUniformBlockTotem, { CameraUniformBlockString } from "../../totems/camerauniformblock";
3
- import { noRegisterGlobeProgramCache, globeProgramCache } from "../../programcache";
4
-
5
- const CIRCLE_EDGE_COUNT = 360;
6
-
7
- const vertexShader = `#version 300 es ` +
8
- shaderfunctions.PI +
9
- shaderfunctions.R +
10
- shaderfunctions.POLE +
11
- CameraUniformBlockString +
12
- shaderfunctions.mercatorXYToGLPosition +
13
- shaderfunctions.longLatRadToMercator +
14
- shaderfunctions.longLatRadToCartesian3D +
15
- shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
16
- shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
17
- shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
18
-
19
- uniform int compass;
20
- uniform float circle_edge_count;
21
-
22
- uniform float opacity;
23
-
24
- in vec2 center;
25
- in float radius;
26
- in vec4 color;
27
- in float flag;
28
- out vec4 v_color;
29
- out vec2 v_limp;
30
-
31
- void main() {
32
- if( flag == 1.0 || radius == 0.0) return; // flag 1.0 is hide
33
- v_color = vec4(color.rgb, color.a * opacity);
34
- if ( gl_VertexID == 270 ) v_color.rgb += 0.2;
35
- float angle = 3.1415926535897932384626433832795 * 2.0 * (float(gl_VertexID) / circle_edge_count);
36
- if ( is3D ){
37
- gl_Position = projection * view * vec4(
38
- circleLimpFromLongLatRadCenterCartesian3D( center, radius, angle) - translate, 1.0);
39
- v_limp = vec2(0.0, 0.0);
40
- return;
41
- }
42
- vec2 limp;
43
- if ( compass == 1 ){
44
- limp = circleLimpFromLongLatRadCenterMercatorCompass(center, radius, angle);
45
- } else {
46
- limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius, angle);
47
- }
48
- v_limp = limp;
49
- gl_Position = mercatorXYToGLPosition(limp);
50
-
51
- }`;
52
-
53
- const fragmentShader = `#version 300 es
54
- precision highp float;` +
55
- shaderfunctions.POLE + `
56
-
57
- in vec4 v_color;
58
- in vec2 v_limp;
59
- out vec4 outColor;
60
- void main() {
61
- if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ discard; }
62
- outColor = v_color;
63
- }`;
64
-
65
- class Logic {
66
- constructor(globe) {
67
- this.globe = globe;
68
- this.gl = globe.gl;
69
- this.program = createProgram(this.gl, vertexShader, fragmentShader);
70
- { // bind positions so bufferManager can use them
71
- this.gl.bindAttribLocation(this.program, 0, "center");
72
- this.gl.bindAttribLocation(this.program, 1, "radius");
73
- this.gl.bindAttribLocation(this.program, 2, "color");
74
- this.gl.bindAttribLocation(this.program, 3, "flag");
75
- }
76
- this.cameraBlockBindingPoint = 0;
77
- this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
78
- const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
79
- this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
80
-
81
- this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
82
- this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
83
- this._circleEdgeCountLocation = this.gl.getUniformLocation(this.program, "circle_edge_count");
84
- this._circleEdgeCount = CIRCLE_EDGE_COUNT;
85
- this._compassmode = 1;
86
- this._opacity = 1.0;
87
- {
88
- const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
89
- this.gl.useProgram(this.program);
90
- this.gl.uniform1i(this._compassLocation, 1);
91
- this.gl.uniform1f(this._circleEdgeCountLocation, CIRCLE_EDGE_COUNT);
92
- this.gl.uniform1f(this._opacityLocation, 1.0);
93
-
94
- this.gl.useProgram(currentProgram);
95
- }
96
-
97
- }
98
-
99
-
100
- draw(attrBufferManager, compass, circleEdgeCount, opacity) {
101
- const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
102
- gl.useProgram(program);
103
- cameraBlockTotem.bind(cameraBlockBindingPoint);
104
- attrBufferManager.bindCircleVAO();
105
-
106
- if (compass !== this._compassmode) {
107
- gl.uniform1i(this._compassLocation, compass);
108
- this._compassmode = compass;
109
- }
110
-
111
- if (opacity !== this._opacity) {
112
- gl.uniform1f(this._opacityLocation, opacity);
113
- this._opacity = opacity;
114
- }
115
-
116
- if (circleEdgeCount !== this._circleEdgeCount) {
117
- gl.uniform1f(this._circleEdgeCountLocation, circleEdgeCount);
118
- this._circleEdgeCount = circleEdgeCount;
119
- }
120
- gl.drawArraysInstanced(gl.LINE_LOOP, 0, circleEdgeCount, attrBufferManager.length);
121
- gl.bindVertexArray(null);
122
- cameraBlockTotem.unbind(cameraBlockBindingPoint);
123
- }
124
-
125
- free() {
126
- this.gl.deleteProgram(this.program);
127
- globeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
128
-
129
- }
130
- }
131
-
132
-
133
- export const programCache = Object.freeze({
134
- getProgram: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
135
- releaseProgram: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
136
- });