@pirireis/webglobeplugins 0.9.11 → 0.9.13

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 (179) hide show
  1. package/Math/angle-calculation.js +9 -11
  2. package/Math/arc.js +38 -41
  3. package/Math/bounds/line-bbox.js +79 -83
  4. package/Math/constants.js +4 -9
  5. package/Math/frustum/types.js +1 -2
  6. package/Math/juction/arc-plane.js +33 -36
  7. package/Math/juction/line-sphere.js +15 -18
  8. package/Math/juction/plane-plane.js +20 -23
  9. package/Math/line.js +42 -47
  10. package/Math/methods.js +69 -92
  11. package/Math/plane.js +33 -38
  12. package/Math/quaternion.js +48 -55
  13. package/Math/types.js +1 -2
  14. package/Math/utils.js +2 -4
  15. package/Math/vec3.js +46 -52
  16. package/algorithms/search-binary.js +5 -8
  17. package/altitude-locator/draw-subset-obj.js +8 -11
  18. package/altitude-locator/plugin.js +114 -133
  19. package/altitude-locator/types.js +1 -3
  20. package/arrowfield/adaptor.js +3 -7
  21. package/arrowfield/index.js +3 -10
  22. package/arrowfield/plugin.js +63 -69
  23. package/bearing-line/index.js +2 -8
  24. package/bearing-line/plugin.js +218 -248
  25. package/circle-line-chain/chain-list-map.js +82 -92
  26. package/circle-line-chain/plugin.js +147 -182
  27. package/circle-line-chain/util.js +1 -5
  28. package/compass-rose/compass-rose-padding-flat.js +111 -140
  29. package/compass-rose/compass-text-writer.js +63 -75
  30. package/compass-rose/index.js +3 -7
  31. package/compassrose/compassrose.js +50 -57
  32. package/compassrose/index.js +2 -8
  33. package/heatwave/index.js +3 -10
  34. package/heatwave/isobar/objectarraylabels.js +50 -56
  35. package/heatwave/isobar/plugin.js +111 -170
  36. package/heatwave/isobar/quadtreecontours.js +78 -96
  37. package/heatwave/plugins/heatwaveglobeshell.js +73 -94
  38. package/index.js +12 -58
  39. package/package.json +1 -1
  40. package/partialrings/buffer-manager.js +32 -70
  41. package/partialrings/index.js +2 -41
  42. package/partialrings/plugin.js +55 -98
  43. package/partialrings/program.js +141 -59
  44. package/pin/pin-object-array.js +89 -97
  45. package/pin/pin-point-totem.js +21 -22
  46. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +11 -14
  47. package/point-heat-map/plugin-webworker.js +45 -53
  48. package/point-heat-map/point-to-heat-map-flow.js +46 -51
  49. package/point-tracks/key-methods.js +2 -5
  50. package/point-tracks/plugin.js +141 -170
  51. package/programs/arrowfield/index.js +2 -7
  52. package/programs/arrowfield/logic.js +172 -67
  53. package/programs/arrowfield/object.js +35 -43
  54. package/programs/data2legend/density-to-legend.js +47 -26
  55. package/programs/data2legend/point-to-density-texture.js +56 -34
  56. package/programs/float2legendwithratio/index.js +2 -8
  57. package/programs/float2legendwithratio/logic.js +88 -45
  58. package/programs/float2legendwithratio/object.js +45 -54
  59. package/programs/globe-util/is-globe-moved.js +10 -13
  60. package/programs/globeshell/index.js +2 -8
  61. package/programs/globeshell/wiggle/index.js +2 -8
  62. package/programs/globeshell/wiggle/logic.js +191 -101
  63. package/programs/globeshell/wiggle/object.js +35 -43
  64. package/programs/helpers/blender/program.js +36 -22
  65. package/programs/helpers/fadeaway/index.js +2 -7
  66. package/programs/helpers/fadeaway/logic.js +36 -17
  67. package/programs/helpers/fadeaway/object.js +11 -18
  68. package/programs/helpers/index.js +2 -8
  69. package/programs/index.js +9 -58
  70. package/programs/line-on-globe/angled-line.js +95 -39
  71. package/programs/line-on-globe/circle-accurate-3d.js +86 -39
  72. package/programs/line-on-globe/circle-accurate-flat.js +116 -64
  73. package/programs/line-on-globe/circle-accurate.js +113 -46
  74. package/programs/line-on-globe/circle.js +106 -44
  75. package/programs/line-on-globe/degree-padding-around-circle-3d.js +89 -42
  76. package/programs/line-on-globe/lines-color-instanced-flat.js +84 -43
  77. package/programs/line-on-globe/linestrip.js +126 -63
  78. package/programs/line-on-globe/naive-accurate-flexible.js +126 -59
  79. package/programs/line-on-globe/to-the-surface.js +62 -35
  80. package/programs/line-on-globe/util.js +2 -5
  81. package/programs/picking/pickable-renderer.js +127 -46
  82. package/programs/point-on-globe/element-globe-surface-glow.js +83 -46
  83. package/programs/point-on-globe/element-point-glow.js +112 -47
  84. package/programs/point-on-globe/square-pixel-point.js +80 -34
  85. package/programs/programcache.js +14 -19
  86. package/programs/rings/distancering/circleflatprogram.js +76 -70
  87. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +168 -194
  88. package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -200
  89. package/programs/rings/distancering/index.js +5 -14
  90. package/programs/rings/distancering/paddyflatprogram.js +87 -70
  91. package/programs/rings/distancering/paddyflatprogram2d.js +89 -72
  92. package/programs/rings/distancering/paddyflatprogram3d.js +87 -70
  93. package/programs/rings/index.js +1 -17
  94. package/programs/rings/partial-ring/piece-of-pie.js +144 -44
  95. package/programs/totems/camerauniformblock.js +65 -56
  96. package/programs/totems/canvas-webglobe-info.js +49 -45
  97. package/programs/totems/gpu-selection-uniform-block.js +45 -45
  98. package/programs/totems/index.js +2 -40
  99. package/programs/two-d/pixel-padding-for-compass.js +94 -36
  100. package/programs/util.js +7 -10
  101. package/programs/vectorfields/index.js +3 -23
  102. package/programs/vectorfields/logics/drawrectangleparticles.js +73 -35
  103. package/programs/vectorfields/logics/index.js +4 -12
  104. package/programs/vectorfields/logics/pixelbased.js +94 -41
  105. package/programs/vectorfields/logics/ubo.js +32 -32
  106. package/programs/vectorfields/pingpongbuffermanager.js +30 -37
  107. package/rangerings/enum.js +2 -5
  108. package/rangerings/index.js +5 -15
  109. package/rangerings/plugin.js +223 -286
  110. package/rangerings/rangeringangletext.js +122 -137
  111. package/rangerings/ring-account.js +53 -75
  112. package/shaders/fragment-toy/firework.js +55 -4
  113. package/shaders/fragment-toy/singularity.js +56 -5
  114. package/timetracks/adaptors-line-strip.js +27 -44
  115. package/timetracks/adaptors.js +48 -67
  116. package/timetracks/index.js +5 -19
  117. package/timetracks/plugin-line-strip.js +65 -79
  118. package/timetracks/plugin.js +71 -85
  119. package/timetracks/program-line-strip.js +297 -107
  120. package/timetracks/program.js +421 -118
  121. package/timetracks/programpoint-line-strip.js +98 -48
  122. package/timetracks/programpoint.js +91 -48
  123. package/util/account/bufferoffsetmanager.js +72 -98
  124. package/util/account/index.js +3 -23
  125. package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -48
  126. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -98
  127. package/util/account/single-attribute-buffer-management/index.js +4 -9
  128. package/util/account/single-attribute-buffer-management/object-store.js +29 -34
  129. package/util/account/single-attribute-buffer-management/types.js +1 -2
  130. package/util/account/util.js +2 -8
  131. package/util/algorithms/search-binary.js +5 -8
  132. package/util/check/get.js +5 -9
  133. package/util/check/typecheck.js +13 -24
  134. package/util/geometry/index.js +10 -18
  135. package/util/gl-util/buffer/attribute-loader.js +10 -26
  136. package/util/gl-util/buffer/index.js +2 -5
  137. package/util/gl-util/draw-options/methods.js +10 -15
  138. package/util/gl-util/uniform-block/manager.js +69 -72
  139. package/util/heatwavedatamanager/datamanager.js +56 -119
  140. package/util/heatwavedatamanager/index.js +3 -10
  141. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +38 -47
  142. package/util/heatwavedatamanager/pointcoordsmeta.js +9 -13
  143. package/util/index.js +13 -57
  144. package/util/interpolation/timetrack/index.js +2 -5
  145. package/util/interpolation/timetrack/timetrack-interpolator.js +30 -36
  146. package/util/interpolation/timetrack/web-worker-str.js +180 -5
  147. package/util/interpolation/timetrack/web-worker.js +4 -6
  148. package/util/jshelpers/data-filler.js +8 -11
  149. package/util/jshelpers/equality.js +1 -3
  150. package/util/jshelpers/index.js +2 -37
  151. package/util/jshelpers/timefilters.js +8 -10
  152. package/util/picking/fence.js +8 -11
  153. package/util/picking/picker-displayer.js +49 -58
  154. package/util/programs/draw-texture-on-canvas.js +41 -26
  155. package/util/programs/index.js +1 -17
  156. package/util/programs/shapesonglobe.js +104 -68
  157. package/util/programs/supersampletotextures.js +45 -43
  158. package/util/programs/texturetoglobe.js +99 -52
  159. package/util/shaderfunctions/geometrytransformations.js +323 -35
  160. package/util/shaderfunctions/index.js +2 -18
  161. package/util/shaderfunctions/nodata.js +8 -5
  162. package/util/shaderfunctions/noisefunctions.js +40 -12
  163. package/util/surface-line-data/arcs-to-cuts.js +20 -23
  164. package/util/webglobe/gldefaultstates.js +1 -4
  165. package/util/webglobe/index.js +2 -18
  166. package/util/webglobe/rasteroverlay.js +36 -41
  167. package/util/webglobjectbuilders.js +70 -93
  168. package/util/webglobjectbuilders1.js +63 -82
  169. package/waveparticles/adaptor.js +7 -10
  170. package/waveparticles/index.js +3 -10
  171. package/waveparticles/plugin.js +82 -90
  172. package/wind/imagetovectorfieldandmagnitude.js +16 -19
  173. package/wind/index.js +5 -14
  174. package/wind/plugin.js +454 -291
  175. package/wind/vectorfieldimage.js +6 -8
  176. package/write-text/attached-text-writer.js +48 -54
  177. package/write-text/context-text.js +52 -63
  178. package/write-text/context-text3.js +71 -80
  179. package/write-text/index.js +1 -5
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PickableRendererProgramCache = void 0;
4
- var util_1 = require("../../util");
5
- var totems_1 = require("../totems");
6
- var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
7
- var programcache_1 = require("../programcache");
8
- require("../../util/gl-util/draw-options/types");
9
- var methods_1 = require("../../util/gl-util/draw-options/methods");
10
- var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
11
- var manager_1 = require("../../util/gl-util/uniform-block/manager");
12
- var uniformBindingPoints = {
1
+ import { createProgram } from "../../util";
2
+ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
3
+ import { mercatorXYToGLPosition, cartesian3DToGLPosition, R_3D, R } from "../../util/shaderfunctions/geometrytransformations";
4
+ import { noRegisterGlobeProgramCache } from "../programcache";
5
+ import "../../util/gl-util/draw-options/types";
6
+ import { drawArrays } from "../../util/gl-util/draw-options/methods";
7
+ import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
8
+ import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
9
+ const uniformBindingPoints = {
13
10
  camera: 0,
14
11
  flexible: 1
15
12
  };
16
- var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
13
+ const uniformBlockManager = new UniformBlockManager("FlexibleBlock", [
17
14
  { name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
18
15
  { name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
19
16
  { name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
@@ -25,15 +22,101 @@ var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
25
22
  { name: "u_dash_opacity_multiplier", type: "float", value: new Float32Array([1.0]) },
26
23
  { name: "u_dash_phase", type: "float", value: new Float32Array([0.0]) },
27
24
  ], uniformBindingPoints.flexible);
28
- var vs = "#version 300 es\n".concat(geometrytransformations_1.R, "\n").concat(geometrytransformations_1.R_3D, "\n").concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.mercatorXYToGLPosition, "\n").concat(geometrytransformations_1.cartesian3DToGLPosition, "\n\n").concat(uniformBlockManager.glslCode(), "\n\nprecision highp float;\nprecision highp int;\n\nin vec3 pos3D;\nin vec2 pos2D;\nin vec4 rgba;\nin float size;\n\n\nflat out highp int vVertexID;\n\nout vec4 v_rgba;\n\nout float v_length;\n\nvoid main() {\n \n v_rgba = (rgba.r == -1.0) ? u_rgba : rgba;\n v_rgba.a *= u_opacity;\n gl_PointSize = max(((size == -1.0) ? u_size : size) * u_size_multiplier, u_minimum_size);\n \n float size_fixer; \n if(is3D){\n gl_Position = cartesian3DToGLPosition(pos3D);\n size_fixer = smoothstep(0.15, 1.0, 0.5 * R_3D / gl_Position.w) ;\n } else {\n gl_Position = mercatorXYToGLPosition(pos2D);\n size_fixer = smoothstep(2.0, 5.2, z_level);\n }\n gl_PointSize *= size_fixer;\n switch (u_draw_mode) {\n case 0:\n vVertexID = gl_VertexID;\n break;\n case 1:\n v_length = float(gl_VertexID % 2);\n vVertexID = (gl_VertexID - gl_VertexID % 2) / 2; // a line takes two points\n break;\n default:\n break;\n }\n}");
29
- var fs = "#version 300 es\nprecision highp float;\nprecision highp int;\n\n".concat(uniformBlockManager.glslCode(), "\n\nflat in highp int vVertexID;\n\nin vec4 v_rgba;\nin float v_length;\n\nlayout(location = 0) out vec4 fragColor;\nlayout(location = 1) out int vertexID;\n\nvoid main() {\n vertexID = vVertexID; \n fragColor = v_rgba;\n\n switch (u_draw_mode) {\n case 0:\n float d = distance(gl_PointCoord, vec2(0.5, 0.5));\n if (u_is_circle) {\n if (d > 0.5) discard;\n fragColor.a *= smoothstep(0.5, 0.45, d);\n }\n if (u_dash_opacity_multiplier < 1.0) {\n float dash = sin(d * 3.14159 * 2.0 * u_dash_count + u_dash_phase) * (1.0 - u_dash_opacity_multiplier) + u_dash_opacity_multiplier;\n fragColor.a *= dash;\n }\n break;\n case 1:\n if (u_dash_opacity_multiplier < 1.0 && fract((v_length + u_dash_phase) * u_dash_count) < 0.5) {\n fragColor.a *= u_dash_opacity_multiplier;\n }\n break;\n }\n}");
30
- var PointOnGlobeProgram = /** @class */ (function () {
31
- function PointOnGlobeProgram(globe) {
25
+ const vs = `#version 300 es
26
+ ${R}
27
+ ${R_3D}
28
+ ${CameraUniformBlockString}
29
+ ${mercatorXYToGLPosition}
30
+ ${cartesian3DToGLPosition}
31
+
32
+ ${uniformBlockManager.glslCode()}
33
+
34
+ precision highp float;
35
+ precision highp int;
36
+
37
+ in vec3 pos3D;
38
+ in vec2 pos2D;
39
+ in vec4 rgba;
40
+ in float size;
41
+
42
+
43
+ flat out highp int vVertexID;
44
+
45
+ out vec4 v_rgba;
46
+
47
+ out float v_length;
48
+
49
+ void main() {
50
+
51
+ v_rgba = (rgba.r == -1.0) ? u_rgba : rgba;
52
+ v_rgba.a *= u_opacity;
53
+ gl_PointSize = max(((size == -1.0) ? u_size : size) * u_size_multiplier, u_minimum_size);
54
+
55
+ float size_fixer;
56
+ if(is3D){
57
+ gl_Position = cartesian3DToGLPosition(pos3D);
58
+ size_fixer = smoothstep(0.15, 1.0, 0.5 * R_3D / gl_Position.w) ;
59
+ } else {
60
+ gl_Position = mercatorXYToGLPosition(pos2D);
61
+ size_fixer = smoothstep(2.0, 5.2, z_level);
62
+ }
63
+ gl_PointSize *= size_fixer;
64
+ switch (u_draw_mode) {
65
+ case 0:
66
+ vVertexID = gl_VertexID;
67
+ break;
68
+ case 1:
69
+ v_length = float(gl_VertexID % 2);
70
+ vVertexID = (gl_VertexID - gl_VertexID % 2) / 2; // a line takes two points
71
+ break;
72
+ default:
73
+ break;
74
+ }
75
+ }`;
76
+ const fs = `#version 300 es
77
+ precision highp float;
78
+ precision highp int;
79
+
80
+ ${uniformBlockManager.glslCode()}
81
+
82
+ flat in highp int vVertexID;
83
+
84
+ in vec4 v_rgba;
85
+ in float v_length;
86
+
87
+ layout(location = 0) out vec4 fragColor;
88
+ layout(location = 1) out int vertexID;
89
+
90
+ void main() {
91
+ vertexID = vVertexID;
92
+ fragColor = v_rgba;
93
+
94
+ switch (u_draw_mode) {
95
+ case 0:
96
+ float d = distance(gl_PointCoord, vec2(0.5, 0.5));
97
+ if (u_is_circle) {
98
+ if (d > 0.5) discard;
99
+ fragColor.a *= smoothstep(0.5, 0.45, d);
100
+ }
101
+ if (u_dash_opacity_multiplier < 1.0) {
102
+ float dash = sin(d * 3.14159 * 2.0 * u_dash_count + u_dash_phase) * (1.0 - u_dash_opacity_multiplier) + u_dash_opacity_multiplier;
103
+ fragColor.a *= dash;
104
+ }
105
+ break;
106
+ case 1:
107
+ if (u_dash_opacity_multiplier < 1.0 && fract((v_length + u_dash_phase) * u_dash_count) < 0.5) {
108
+ fragColor.a *= u_dash_opacity_multiplier;
109
+ }
110
+ break;
111
+ }
112
+ }`;
113
+ class PointOnGlobeProgram {
114
+ constructor(globe) {
32
115
  this.globe = globe;
33
116
  this.gl = globe.gl;
34
117
  this._isFreed = false;
35
- this.program = (0, util_1.createProgram)(this.gl, vs, fs);
36
- var _a = this, gl = _a.gl, program = _a.program;
118
+ this.program = createProgram(this.gl, vs, fs);
119
+ const { gl, program } = this;
37
120
  // assign opacity
38
121
  // assign attribute locations
39
122
  gl.bindAttribLocation(program, 0, "pos3D");
@@ -41,7 +124,7 @@ var PointOnGlobeProgram = /** @class */ (function () {
41
124
  gl.bindAttribLocation(program, 2, "rgba");
42
125
  gl.bindAttribLocation(program, 3, "size");
43
126
  // arrange camera uniform block
44
- this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
127
+ this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
45
128
  this.cameraBlockTotem.assignBindingPoint(program, uniformBindingPoints.camera);
46
129
  uniformBlockManager.assignBindingPoint(this.gl, this.program);
47
130
  this._defaultUBO = uniformBlockManager.createUBO(this.gl);
@@ -53,52 +136,50 @@ var PointOnGlobeProgram = /** @class */ (function () {
53
136
  ["u_is_circle", [1.0]],
54
137
  ]));
55
138
  }
56
- PointOnGlobeProgram.prototype.createUBO = function () {
57
- var ubo = uniformBlockManager.createUBO(this.gl);
139
+ createUBO() {
140
+ const ubo = uniformBlockManager.createUBO(this.gl);
58
141
  return ubo;
59
- };
60
- PointOnGlobeProgram.prototype.createVAO = function (pos3DBufferObj, pos2DBufferObj, rgbaBufferObj, sizeBufferObj) {
61
- var gl = this.gl;
62
- var vao = gl.createVertexArray();
142
+ }
143
+ createVAO(pos3DBufferObj, pos2DBufferObj, rgbaBufferObj, sizeBufferObj) {
144
+ const { gl } = this;
145
+ const vao = gl.createVertexArray();
63
146
  gl.bindVertexArray(vao);
64
- (0, attribute_loader_1.attributeLoader)(gl, pos3DBufferObj, 0, 3);
65
- (0, attribute_loader_1.attributeLoader)(gl, pos2DBufferObj, 1, 2);
66
- (0, attribute_loader_1.attributeLoader)(gl, rgbaBufferObj, 2, 4, { escapeValues: [-1, -1, -1, -1] });
67
- (0, attribute_loader_1.attributeLoader)(gl, sizeBufferObj, 3, 1, { escapeValues: [-1] });
147
+ attributeLoader(gl, pos3DBufferObj, 0, 3);
148
+ attributeLoader(gl, pos2DBufferObj, 1, 2);
149
+ attributeLoader(gl, rgbaBufferObj, 2, 4, { escapeValues: [-1, -1, -1, -1] });
150
+ attributeLoader(gl, sizeBufferObj, 3, 1, { escapeValues: [-1] });
68
151
  gl.bindVertexArray(null);
69
152
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
70
153
  return vao;
71
- };
154
+ }
72
155
  /**
73
156
  *
74
157
  * @param {vertexArrayObject} vao
75
158
  * @param {DrawRangeIndexParams} drawOptions
76
159
  */
77
- PointOnGlobeProgram.prototype.draw = function (vao, drawOptions, ubo) {
78
- if (ubo === void 0) { ubo = null; }
79
- var _a = this, gl = _a.gl, program = _a.program;
160
+ draw(vao, drawOptions, ubo = null) {
161
+ const { gl, program } = this;
80
162
  gl.useProgram(program);
81
163
  gl.bindVertexArray(vao);
82
164
  this.cameraBlockTotem.bind(uniformBindingPoints.camera);
83
165
  ubo = ubo || this._defaultUBO;
84
166
  ubo.bind();
85
- (0, methods_1.drawArrays)(gl, gl.POINTS, drawOptions);
167
+ drawArrays(gl, gl.POINTS, drawOptions);
86
168
  ubo.unbind();
87
169
  this.cameraBlockTotem.unbind(uniformBindingPoints.camera);
88
170
  gl.bindVertexArray(null);
89
- };
90
- PointOnGlobeProgram.prototype.free = function () {
171
+ }
172
+ free() {
91
173
  if (this._isFreed)
92
174
  return;
93
- var _a = this, gl = _a.gl, globe = _a.globe;
94
- totems_1.CameraUniformBlockTotemCache.release(globe);
175
+ const { gl, globe } = this;
176
+ CameraUniformBlockTotemCache.release(globe);
95
177
  gl.deleteProgram(this.program);
96
178
  this._isFreed = true;
97
- };
98
- return PointOnGlobeProgram;
99
- }());
100
- var PickableRendererProgramCache = Object.freeze({
101
- get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram); },
102
- release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram); }
179
+ }
180
+ }
181
+ const PickableRendererProgramCache = Object.freeze({
182
+ get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram),
183
+ release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram)
103
184
  });
104
- exports.PickableRendererProgramCache = PickableRendererProgramCache;
185
+ export { PickableRendererProgramCache };
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * *
4
3
  * * *
@@ -6,29 +5,72 @@
6
5
  * * *
7
6
  * *
8
7
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ElementGlobeSufaceGlowCache = void 0;
11
- var totems_1 = require("../totems");
12
- var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
13
- var util_1 = require("../../util");
14
- var programcache_1 = require("../programcache");
15
- var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
16
- var methods_1 = require("../../util/gl-util/draw-options/methods");
17
- var manager_1 = require("../../util/gl-util/uniform-block/manager");
18
- var uboBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
8
+ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
9
+ import { PI, mercatorXYToGLPosition, cartesian3DToGLPosition, circleLimpFromLongLatRadCenterCartesian3D_accurate } from "../../util/shaderfunctions/geometrytransformations";
10
+ import { createProgram } from "../../util";
11
+ import { noRegisterGlobeProgramCache } from "../programcache";
12
+ import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
13
+ import { drawInstanced } from "../../util/gl-util/draw-options/methods";
14
+ import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
15
+ const uboBlockManager = new UniformBlockManager("FlexibleBlock", [
19
16
  { name: "u_color", type: "vec4" },
20
17
  { name: "u_radius", type: "float" }
21
18
  ], 1);
22
- var vs = "#version 300 es\n".concat(geometrytransformations_1.PI, "\n").concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.cartesian3DToGLPosition, "\n").concat(geometrytransformations_1.circleLimpFromLongLatRadCenterCartesian3D_accurate, "\n\nuniform float edge_count;\n\nin vec3 pos3D;\nin float radius;\nin vec4 color;\n\n").concat(uboBlockManager.glslCode(), "\n\nout vec4 vColor;\n\nvoid main() {\n\n float radius_ = ( radius == -1.0 ) ? u_radius : radius;\n vec4 color = ( color.r == -1.0 ) ? u_color : color;\n\n if ( gl_VertexID == 0 ) {\n gl_Position = cartesian3DToGLPosition(pos3D);\n vColor = vColor;\n } else {\n float angle = PI * 2.0 * float( gl_VertexID - 1 ) / edge_count;\n vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(pos3D, radius, angle);\n gl_Position = cartesian3DToGLPosition(position);\n float distance = distance(position, pos3D);\n\n \n\n vColor = vec4(color.rgb, color.a * (1.0 - distance / radius));\n }\n}");
23
- var fs = "#version 300 es\nprecision highp float;\n\nuniform float opacity;\nin vec4 vColor;\n\nout vec4 fragColor;\n\nvoid main() {\n fragColor = vColor;\n fragColor.a *= opacity;\n}";
24
- var Logic = /** @class */ (function () {
25
- function Logic(globe) {
19
+ const vs = `#version 300 es
20
+ ${PI}
21
+ ${CameraUniformBlockString}
22
+ ${cartesian3DToGLPosition}
23
+ ${circleLimpFromLongLatRadCenterCartesian3D_accurate}
24
+
25
+ uniform float edge_count;
26
+
27
+ in vec3 pos3D;
28
+ in float radius;
29
+ in vec4 color;
30
+
31
+ ${uboBlockManager.glslCode()}
32
+
33
+ out vec4 vColor;
34
+
35
+ void main() {
36
+
37
+ float radius_ = ( radius == -1.0 ) ? u_radius : radius;
38
+ vec4 color = ( color.r == -1.0 ) ? u_color : color;
39
+
40
+ if ( gl_VertexID == 0 ) {
41
+ gl_Position = cartesian3DToGLPosition(pos3D);
42
+ vColor = vColor;
43
+ } else {
44
+ float angle = PI * 2.0 * float( gl_VertexID - 1 ) / edge_count;
45
+ vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(pos3D, radius, angle);
46
+ gl_Position = cartesian3DToGLPosition(position);
47
+ float distance = distance(position, pos3D);
48
+
49
+
50
+
51
+ vColor = vec4(color.rgb, color.a * (1.0 - distance / radius));
52
+ }
53
+ }`;
54
+ const fs = `#version 300 es
55
+ precision highp float;
56
+
57
+ uniform float opacity;
58
+ in vec4 vColor;
59
+
60
+ out vec4 fragColor;
61
+
62
+ void main() {
63
+ fragColor = vColor;
64
+ fragColor.a *= opacity;
65
+ }`;
66
+ class Logic {
67
+ constructor(globe) {
26
68
  this.globe = globe;
27
69
  this.gl = globe.gl;
28
70
  this._vaoCache = [];
29
- this.program = (0, util_1.createProgram)(this.gl, vs, fs);
30
- var _a = this, gl = _a.gl, program = _a.program;
31
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
71
+ this.program = createProgram(this.gl, vs, fs);
72
+ const { gl, program } = this;
73
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
32
74
  gl.useProgram(program);
33
75
  // set uniform locations
34
76
  this._uniforms = {
@@ -46,30 +88,28 @@ var Logic = /** @class */ (function () {
46
88
  gl.bindAttribLocation(program, 1, "radius");
47
89
  gl.bindAttribLocation(program, 2, "color");
48
90
  // camera uniform block
49
- this.cameraUniformBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
91
+ this.cameraUniformBlockTotem = CameraUniformBlockTotemCache.get(globe);
50
92
  this.cameraBlockBindingPoint = 0;
51
- var cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
93
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
52
94
  gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
53
95
  uboBlockManager.assignBindingPoint(this.gl, this.program);
54
96
  this._defaultUBO = uboBlockManager.createUBO(this.gl);
55
97
  }
56
- Logic.prototype.createVAO = function (pos3DObj, radiusObj, colorObj) {
57
- var gl = this.gl;
58
- var vao = gl.createVertexArray();
59
- var divisor = 1;
98
+ createVAO(pos3DObj, radiusObj, colorObj) {
99
+ const { gl } = this;
100
+ const vao = gl.createVertexArray();
101
+ const divisor = 1;
60
102
  gl.bindVertexArray(vao);
61
103
  // TODO constants to escape values
62
- (0, attribute_loader_1.attributeLoader)(gl, pos3DObj, 0, 3, { divisor: divisor });
63
- (0, attribute_loader_1.attributeLoader)(gl, radiusObj, 1, 1, { divisor: divisor, escapeValues: [-1] });
64
- (0, attribute_loader_1.attributeLoader)(gl, colorObj, 2, 4, { divisor: divisor, escapeValues: [-1, -1, -1, -1] });
104
+ attributeLoader(gl, pos3DObj, 0, 3, { divisor });
105
+ attributeLoader(gl, radiusObj, 1, 1, { divisor, escapeValues: [-1] });
106
+ attributeLoader(gl, colorObj, 2, 4, { divisor, escapeValues: [-1, -1, -1, -1] });
65
107
  gl.bindVertexArray(null);
66
108
  this._vaoCache.push(vao);
67
109
  return vao;
68
- };
69
- Logic.prototype.draw = function (vao, drawOptions, opacity, ubo) {
70
- if (opacity === void 0) { opacity = 1.0; }
71
- if (ubo === void 0) { ubo = null; }
72
- var _a = this, gl = _a.gl, program = _a.program;
110
+ }
111
+ draw(vao, drawOptions, opacity = 1.0, ubo = null) {
112
+ const { gl, program } = this;
73
113
  gl.useProgram(program);
74
114
  gl.bindVertexArray(vao);
75
115
  if (opacity !== this._uniforms.opacity) {
@@ -78,25 +118,22 @@ var Logic = /** @class */ (function () {
78
118
  }
79
119
  ubo = ubo || this._defaultUBO;
80
120
  ubo.bind();
81
- (0, methods_1.drawInstanced)(gl, gl.TRIANGLE_FAN, drawOptions);
121
+ drawInstanced(gl, gl.TRIANGLE_FAN, drawOptions);
82
122
  ubo.unbind();
83
123
  gl.bindVertexArray(null);
84
- };
85
- Logic.prototype.free = function () {
124
+ }
125
+ free() {
86
126
  if (this._isFreed)
87
127
  return;
88
- totems_1.CameraUniformBlockTotemCache.release(this.globe);
128
+ CameraUniformBlockTotemCache.release(this.globe);
89
129
  this.gl.deleteProgram(this.program);
90
- for (var _i = 0, _a = this._vaoCache; _i < _a.length; _i++) {
91
- var vao = _a[_i];
130
+ for (const vao of this._vaoCache)
92
131
  this.gl.deleteVertexArray(vao);
93
- }
94
132
  this._isFreed = true;
95
- };
96
- return Logic;
97
- }());
98
- var ElementGlobeSufaceGlowCache = Object.freeze({
99
- get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
100
- release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe); }
133
+ }
134
+ }
135
+ const ElementGlobeSufaceGlowCache = Object.freeze({
136
+ get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
137
+ release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe)
101
138
  });
102
- exports.ElementGlobeSufaceGlowCache = ElementGlobeSufaceGlowCache;
139
+ export { ElementGlobeSufaceGlowCache };
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ElementPointGlowProgramCache = void 0;
4
- var util_1 = require("../../util");
5
- var totems_1 = require("../totems");
6
- var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
7
- var programcache_1 = require("../programcache");
8
- var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
9
- var methods_1 = require("../../util/gl-util/draw-options/methods");
10
- var manager_1 = require("../../util/gl-util/uniform-block/manager");
11
- var singularity_1 = require("../../shaders/fragment-toy/singularity");
12
- var firework_1 = require("../../shaders/fragment-toy/firework");
13
- var cameraBlockBindingPoint = 0;
14
- var flexibleBlockBindingPoint = 1;
15
- var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
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
+ import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
6
+ import { drawArrays } from "../../util/gl-util/draw-options/methods";
7
+ import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
8
+ import { singularity } from "../../shaders/fragment-toy/singularity";
9
+ import { firework } from "../../shaders/fragment-toy/firework";
10
+ const cameraBlockBindingPoint = 0;
11
+ const flexibleBlockBindingPoint = 1;
12
+ const uniformBlockManager = new UniformBlockManager("FlexibleBlock", [
16
13
  { name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
17
14
  { name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
18
15
  { name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
@@ -20,66 +17,134 @@ var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
20
17
  { name: "u_minimumSize", type: "float", value: new Float32Array([25.0]) },
21
18
  { name: "u_phase", type: "float", value: new Float32Array([1.0]) },
22
19
  ], flexibleBlockBindingPoint);
23
- var vs = "#version 300 es\nprecision highp float;\n\n".concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.mercatorXYToGLPosition, "\n").concat(geometrytransformations_1.cartesian3DToGLPosition, "\n\n").concat(uniformBlockManager.glslCode(), "\n\n\nin vec3 pos3D;\nin vec2 pos2D;\nin vec4 color;\nin float size;\n\nout vec4 vColor;\nflat out float v_size;\n\n\n\nvoid main() {\n\n if(is3D){\n gl_Position = cartesian3DToGLPosition(pos3D);\n }\n else {\n gl_Position = mercatorXYToGLPosition(pos2D);\n }\n\n gl_PointSize = max(\n ((size == -1.0) ? u_size : size ) * u_size_multiplier,\n u_minimumSize);\n v_size = gl_PointSize;\n vColor = (color.r == -1.0) ? u_rgba : color;\n vColor.a *= u_opacity;\n\n}");
24
- var fs = "#version 300 es\nprecision highp float;\n\n".concat(uniformBlockManager.glslCode(), "\n\nin vec4 vColor;\nout vec4 fragColor;\n\nflat in float v_size;\n\n").concat(firework_1.firework, "\n").concat(singularity_1.singularity, " \n\nvoid main() {\n fragColor = vColor;\n\n float dist = distance(gl_PointCoord, vec2(0.5, 0.5)) * 2.0;\n if ( dist > 1.0) discard;\n\n // center glow\n float center_alpha = smoothstep(0.5, 0.0, dist) * 0.3;\n // center_alpha = smoothstep(0.0, 1.0, center_alpha);\n\n // circle pattern\n float threshold = fract(( - dist + u_phase - 0.5));\n float circle_alpha = sin( threshold * 1.57 );\n circle_alpha = smoothstep((v_size / (v_size + .5)), 1.0, circle_alpha);\n\n float outer_circle_alpha = sin(dist * 1.57 );\n outer_circle_alpha = smoothstep((v_size / (v_size + .5)), 1.0, outer_circle_alpha);\n\n // fragColor = singularity(gl_PointCoord, u_phase);\n\n fragColor.a *= smoothstep(0.0, 1.1, ( 0.4 * u_opacity + center_alpha + circle_alpha+ outer_circle_alpha)); \n}");
25
- var Logic = /** @class */ (function () {
26
- function Logic(globe) {
20
+ const vs = `#version 300 es
21
+ precision highp float;
22
+
23
+ ${CameraUniformBlockString}
24
+ ${mercatorXYToGLPosition}
25
+ ${cartesian3DToGLPosition}
26
+
27
+ ${uniformBlockManager.glslCode()}
28
+
29
+
30
+ in vec3 pos3D;
31
+ in vec2 pos2D;
32
+ in vec4 color;
33
+ in float size;
34
+
35
+ out vec4 vColor;
36
+ flat out float v_size;
37
+
38
+
39
+
40
+ void main() {
41
+
42
+ if(is3D){
43
+ gl_Position = cartesian3DToGLPosition(pos3D);
44
+ }
45
+ else {
46
+ gl_Position = mercatorXYToGLPosition(pos2D);
47
+ }
48
+
49
+ gl_PointSize = max(
50
+ ((size == -1.0) ? u_size : size ) * u_size_multiplier,
51
+ u_minimumSize);
52
+ v_size = gl_PointSize;
53
+ vColor = (color.r == -1.0) ? u_rgba : color;
54
+ vColor.a *= u_opacity;
55
+
56
+ }`;
57
+ const fs = `#version 300 es
58
+ precision highp float;
59
+
60
+ ${uniformBlockManager.glslCode()}
61
+
62
+ in vec4 vColor;
63
+ out vec4 fragColor;
64
+
65
+ flat in float v_size;
66
+
67
+ ${firework}
68
+ ${singularity}
69
+
70
+ void main() {
71
+ fragColor = vColor;
72
+
73
+ float dist = distance(gl_PointCoord, vec2(0.5, 0.5)) * 2.0;
74
+ if ( dist > 1.0) discard;
75
+
76
+ // center glow
77
+ float center_alpha = smoothstep(0.5, 0.0, dist) * 0.3;
78
+ // center_alpha = smoothstep(0.0, 1.0, center_alpha);
79
+
80
+ // circle pattern
81
+ float threshold = fract(( - dist + u_phase - 0.5));
82
+ float circle_alpha = sin( threshold * 1.57 );
83
+ circle_alpha = smoothstep((v_size / (v_size + .5)), 1.0, circle_alpha);
84
+
85
+ float outer_circle_alpha = sin(dist * 1.57 );
86
+ outer_circle_alpha = smoothstep((v_size / (v_size + .5)), 1.0, outer_circle_alpha);
87
+
88
+ // fragColor = singularity(gl_PointCoord, u_phase);
89
+
90
+ fragColor.a *= smoothstep(0.0, 1.1, ( 0.4 * u_opacity + center_alpha + circle_alpha+ outer_circle_alpha));
91
+ }`;
92
+ class Logic {
93
+ constructor(globe) {
27
94
  this.globe = globe;
28
95
  this.gl = globe.gl;
29
- this.program = (0, util_1.createProgram)(this.gl, vs, fs);
30
- var _a = this, gl = _a.gl, program = _a.program;
96
+ this.program = createProgram(this.gl, vs, fs);
97
+ const { gl, program } = this;
31
98
  gl.bindAttribLocation(program, 0, "pos3D");
32
99
  gl.bindAttribLocation(program, 1, "pos2D");
33
100
  gl.bindAttribLocation(program, 2, "color");
34
101
  gl.bindAttribLocation(program, 3, "size");
35
102
  // assign uniform block
36
- this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
103
+ this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
37
104
  this.cameraBlockTotem.assignBindingPoint(program, cameraBlockBindingPoint);
38
105
  uniformBlockManager.assignBindingPoint(this.gl, this.program);
39
106
  this._defaultUBO = uniformBlockManager.createUBO(this.gl);
40
107
  }
41
- Logic.prototype.createVAO = function (pos3DBuffer, pos2DBuffer, colorBuffer, sizeBuffer) {
42
- var gl = this.gl;
43
- var vao = gl.createVertexArray();
108
+ createVAO(pos3DBuffer, pos2DBuffer, colorBuffer, sizeBuffer) {
109
+ const { gl } = this;
110
+ const vao = gl.createVertexArray();
44
111
  gl.bindVertexArray(vao);
45
- (0, attribute_loader_1.attributeLoader)(gl, pos3DBuffer, 0, 3);
46
- (0, attribute_loader_1.attributeLoader)(gl, pos2DBuffer, 1, 2);
47
- (0, attribute_loader_1.attributeLoader)(gl, colorBuffer, 2, 4, { escapeValues: [-1, -1, -1, -1] });
48
- (0, attribute_loader_1.attributeLoader)(gl, sizeBuffer, 3, 1, { escapeValues: [-1] });
112
+ attributeLoader(gl, pos3DBuffer, 0, 3);
113
+ attributeLoader(gl, pos2DBuffer, 1, 2);
114
+ attributeLoader(gl, colorBuffer, 2, 4, { escapeValues: [-1, -1, -1, -1] });
115
+ attributeLoader(gl, sizeBuffer, 3, 1, { escapeValues: [-1] });
49
116
  gl.bindVertexArray(null);
50
117
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
51
118
  return vao;
52
- };
53
- Logic.prototype.createUBO = function () {
54
- var ubo = uniformBlockManager.createUBO(this.gl);
119
+ }
120
+ createUBO() {
121
+ const ubo = uniformBlockManager.createUBO(this.gl);
55
122
  return ubo;
56
- };
57
- Logic.prototype.draw = function (vao, drawOptions, ubo) {
58
- if (ubo === void 0) { ubo = null; }
59
- var _a = this, gl = _a.gl, program = _a.program, cameraBlockTotem = _a.cameraBlockTotem;
123
+ }
124
+ draw(vao, drawOptions, ubo = null) {
125
+ const { gl, program, cameraBlockTotem } = this;
60
126
  gl.useProgram(program);
61
127
  gl.bindVertexArray(vao);
62
128
  cameraBlockTotem.bind(cameraBlockBindingPoint);
63
129
  ubo = ubo || this._defaultUBO;
64
130
  ubo.bind();
65
- (0, methods_1.drawArrays)(gl, gl.POINTS, drawOptions);
131
+ drawArrays(gl, gl.POINTS, drawOptions);
66
132
  ubo.unbind();
67
133
  gl.bindVertexArray(null);
68
134
  cameraBlockTotem.unbind(cameraBlockBindingPoint);
69
135
  this.globe.DrawRender();
70
- };
136
+ }
71
137
  // for singleton cache interation
72
- Logic.prototype.free = function () {
138
+ free() {
73
139
  if (this._isFreed)
74
140
  return;
75
- totems_1.CameraUniformBlockTotemCache.release(this.globe);
141
+ CameraUniformBlockTotemCache.release(this.globe);
76
142
  this.gl.deleteProgram(this.program);
77
143
  this._isFreed = true;
78
- };
79
- return Logic;
80
- }());
81
- var ElementPointGlowProgramCache = Object.freeze({
82
- get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
83
- release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
144
+ }
145
+ }
146
+ const ElementPointGlowProgramCache = Object.freeze({
147
+ get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
148
+ release: globe => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
84
149
  });
85
- exports.ElementPointGlowProgramCache = ElementPointGlowProgramCache;
150
+ export { ElementPointGlowProgramCache };