@pirireis/webglobeplugins 0.9.11 → 0.9.12

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 (166) hide show
  1. package/Math/angle-calculation.js +8 -8
  2. package/Math/arc.js +18 -18
  3. package/Math/bounds/line-bbox.js +78 -80
  4. package/Math/constants.js +3 -3
  5. package/Math/juction/arc-plane.js +23 -23
  6. package/Math/juction/line-sphere.js +11 -11
  7. package/Math/juction/plane-plane.js +11 -11
  8. package/Math/line.js +14 -16
  9. package/Math/methods.js +65 -70
  10. package/Math/plane.js +16 -18
  11. package/Math/quaternion.js +45 -49
  12. package/Math/utils.js +2 -2
  13. package/Math/vec3.js +42 -45
  14. package/algorithms/search-binary.js +4 -4
  15. package/altitude-locator/draw-subset-obj.js +7 -8
  16. package/altitude-locator/plugin.js +98 -114
  17. package/arrowfield/adaptor.js +3 -4
  18. package/arrowfield/index.js +2 -2
  19. package/arrowfield/plugin.js +62 -65
  20. package/bearing-line/index.js +1 -1
  21. package/bearing-line/plugin.js +200 -226
  22. package/circle-line-chain/chain-list-map.js +82 -88
  23. package/circle-line-chain/plugin.js +134 -165
  24. package/circle-line-chain/util.js +1 -1
  25. package/compass-rose/compass-rose-padding-flat.js +108 -133
  26. package/compass-rose/compass-text-writer.js +62 -70
  27. package/compass-rose/index.js +2 -2
  28. package/compassrose/compassrose.js +46 -50
  29. package/compassrose/index.js +1 -1
  30. package/heatwave/index.js +2 -2
  31. package/heatwave/isobar/objectarraylabels.js +44 -48
  32. package/heatwave/isobar/plugin.js +104 -123
  33. package/heatwave/isobar/quadtreecontours.js +76 -92
  34. package/heatwave/plugins/heatwaveglobeshell.js +69 -87
  35. package/index.js +11 -11
  36. package/package.json +1 -1
  37. package/partialrings/buffer-manager.js +32 -64
  38. package/partialrings/index.js +1 -1
  39. package/partialrings/plugin.js +48 -84
  40. package/partialrings/program.js +136 -47
  41. package/pin/pin-object-array.js +83 -86
  42. package/pin/pin-point-totem.js +21 -22
  43. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
  44. package/point-heat-map/plugin-webworker.js +40 -45
  45. package/point-heat-map/point-to-heat-map-flow.js +40 -42
  46. package/point-tracks/key-methods.js +1 -1
  47. package/point-tracks/plugin.js +137 -162
  48. package/programs/arrowfield/index.js +1 -1
  49. package/programs/arrowfield/logic.js +170 -62
  50. package/programs/arrowfield/object.js +33 -35
  51. package/programs/data2legend/density-to-legend.js +45 -21
  52. package/programs/data2legend/point-to-density-texture.js +52 -27
  53. package/programs/float2legendwithratio/index.js +1 -1
  54. package/programs/float2legendwithratio/logic.js +88 -42
  55. package/programs/float2legendwithratio/object.js +43 -46
  56. package/programs/globe-util/is-globe-moved.js +10 -11
  57. package/programs/globeshell/index.js +1 -1
  58. package/programs/globeshell/wiggle/index.js +1 -1
  59. package/programs/globeshell/wiggle/logic.js +191 -98
  60. package/programs/globeshell/wiggle/object.js +33 -35
  61. package/programs/helpers/blender/program.js +36 -19
  62. package/programs/helpers/fadeaway/index.js +1 -1
  63. package/programs/helpers/fadeaway/logic.js +35 -13
  64. package/programs/helpers/fadeaway/object.js +9 -10
  65. package/programs/helpers/index.js +1 -1
  66. package/programs/index.js +8 -8
  67. package/programs/line-on-globe/angled-line.js +91 -32
  68. package/programs/line-on-globe/circle-accurate-3d.js +82 -32
  69. package/programs/line-on-globe/circle-accurate-flat.js +108 -50
  70. package/programs/line-on-globe/circle-accurate.js +103 -33
  71. package/programs/line-on-globe/circle.js +97 -32
  72. package/programs/line-on-globe/degree-padding-around-circle-3d.js +83 -33
  73. package/programs/line-on-globe/lines-color-instanced-flat.js +79 -34
  74. package/programs/line-on-globe/linestrip.js +111 -45
  75. package/programs/line-on-globe/naive-accurate-flexible.js +120 -50
  76. package/programs/line-on-globe/to-the-surface.js +58 -29
  77. package/programs/line-on-globe/util.js +1 -1
  78. package/programs/picking/pickable-renderer.js +117 -33
  79. package/programs/point-on-globe/element-globe-surface-glow.js +78 -38
  80. package/programs/point-on-globe/element-point-glow.js +103 -35
  81. package/programs/point-on-globe/square-pixel-point.js +76 -27
  82. package/programs/programcache.js +13 -13
  83. package/programs/rings/distancering/circleflatprogram.js +63 -21
  84. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +156 -145
  85. package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -197
  86. package/programs/rings/distancering/index.js +4 -4
  87. package/programs/rings/distancering/paddyflatprogram.js +73 -20
  88. package/programs/rings/distancering/paddyflatprogram2d.js +75 -22
  89. package/programs/rings/distancering/paddyflatprogram3d.js +73 -20
  90. package/programs/rings/partial-ring/piece-of-pie.js +137 -35
  91. package/programs/totems/camerauniformblock.js +64 -51
  92. package/programs/totems/canvas-webglobe-info.js +48 -40
  93. package/programs/totems/gpu-selection-uniform-block.js +44 -40
  94. package/programs/totems/index.js +1 -1
  95. package/programs/two-d/pixel-padding-for-compass.js +90 -29
  96. package/programs/util.js +6 -7
  97. package/programs/vectorfields/index.js +1 -1
  98. package/programs/vectorfields/logics/drawrectangleparticles.js +70 -29
  99. package/programs/vectorfields/logics/index.js +3 -3
  100. package/programs/vectorfields/logics/pixelbased.js +91 -35
  101. package/programs/vectorfields/logics/ubo.js +31 -25
  102. package/programs/vectorfields/pingpongbuffermanager.js +30 -34
  103. package/rangerings/index.js +4 -4
  104. package/rangerings/plugin.js +202 -258
  105. package/rangerings/rangeringangletext.js +108 -120
  106. package/rangerings/ring-account.js +52 -69
  107. package/shaders/fragment-toy/firework.js +55 -1
  108. package/shaders/fragment-toy/singularity.js +55 -1
  109. package/timetracks/adaptors-line-strip.js +26 -37
  110. package/timetracks/adaptors.js +47 -61
  111. package/timetracks/index.js +4 -4
  112. package/timetracks/plugin-line-strip.js +63 -71
  113. package/timetracks/plugin.js +69 -77
  114. package/timetracks/program-line-strip.js +296 -103
  115. package/timetracks/program.js +419 -113
  116. package/timetracks/programpoint-line-strip.js +97 -44
  117. package/timetracks/programpoint.js +90 -44
  118. package/util/account/bufferoffsetmanager.js +72 -95
  119. package/util/account/index.js +1 -1
  120. package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -44
  121. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -94
  122. package/util/account/single-attribute-buffer-management/index.js +3 -3
  123. package/util/account/single-attribute-buffer-management/object-store.js +29 -30
  124. package/util/account/util.js +2 -4
  125. package/util/algorithms/search-binary.js +4 -4
  126. package/util/check/get.js +5 -5
  127. package/util/check/typecheck.js +13 -15
  128. package/util/geometry/index.js +9 -11
  129. package/util/gl-util/buffer/attribute-loader.js +8 -20
  130. package/util/gl-util/buffer/index.js +1 -1
  131. package/util/gl-util/draw-options/methods.js +8 -9
  132. package/util/gl-util/uniform-block/manager.js +67 -67
  133. package/util/heatwavedatamanager/datamanager.js +56 -116
  134. package/util/heatwavedatamanager/index.js +2 -2
  135. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +37 -40
  136. package/util/heatwavedatamanager/pointcoordsmeta.js +9 -10
  137. package/util/index.js +6 -6
  138. package/util/interpolation/timetrack/index.js +1 -1
  139. package/util/interpolation/timetrack/timetrack-interpolator.js +27 -29
  140. package/util/interpolation/timetrack/web-worker-str.js +179 -1
  141. package/util/interpolation/timetrack/web-worker.js +4 -4
  142. package/util/jshelpers/data-filler.js +7 -7
  143. package/util/jshelpers/timefilters.js +7 -7
  144. package/util/picking/fence.js +7 -7
  145. package/util/picking/picker-displayer.js +46 -52
  146. package/util/programs/draw-texture-on-canvas.js +39 -21
  147. package/util/programs/shapesonglobe.js +104 -64
  148. package/util/programs/supersampletotextures.js +45 -39
  149. package/util/programs/texturetoglobe.js +98 -48
  150. package/util/shaderfunctions/geometrytransformations.js +322 -27
  151. package/util/shaderfunctions/nodata.js +7 -1
  152. package/util/shaderfunctions/noisefunctions.js +39 -9
  153. package/util/surface-line-data/arcs-to-cuts.js +20 -23
  154. package/util/webglobe/rasteroverlay.js +35 -37
  155. package/util/webglobjectbuilders.js +55 -60
  156. package/util/webglobjectbuilders1.js +48 -49
  157. package/waveparticles/adaptor.js +6 -7
  158. package/waveparticles/index.js +2 -2
  159. package/waveparticles/plugin.js +79 -84
  160. package/wind/imagetovectorfieldandmagnitude.js +15 -15
  161. package/wind/index.js +4 -4
  162. package/wind/plugin.js +453 -251
  163. package/wind/vectorfieldimage.js +5 -5
  164. package/write-text/attached-text-writer.js +46 -48
  165. package/write-text/context-text.js +51 -58
  166. package/write-text/context-text3.js +69 -74
@@ -1,37 +1,111 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LineOnGlobeCache = void 0;
4
- var totems_1 = require("../totems");
5
- var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
6
- var util_1 = require("../../util");
7
- var programcache_1 = require("../programcache");
8
- var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
9
- var manager_1 = require("../../util/gl-util/uniform-block/manager");
4
+ const totems_1 = require("../totems");
5
+ const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
6
+ const util_1 = require("../../util");
7
+ const programcache_1 = require("../programcache");
8
+ const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
9
+ const manager_1 = require("../../util/gl-util/uniform-block/manager");
10
10
  require("../../util/gl-util/draw-options/types");
11
- var methods_1 = require("../../util/gl-util/draw-options/methods");
12
- var GLOBE_MIDPOINT_COUNT = 30;
13
- var escapeValue = -1.0;
14
- var uniformBindingPoints = {
11
+ const methods_1 = require("../../util/gl-util/draw-options/methods");
12
+ const GLOBE_MIDPOINT_COUNT = 30;
13
+ const escapeValue = -1.0;
14
+ const uniformBindingPoints = {
15
15
  camera: 0,
16
16
  flexible: 1
17
17
  };
18
- var uniformBlockManager = new manager_1.UniformBlockManager('FlexibleAttibutes', [
18
+ const uniformBlockManager = new manager_1.UniformBlockManager('FlexibleAttibutes', [
19
19
  { name: 'u_color', type: 'vec4' },
20
20
  { name: 'u_dash_ratio', type: 'float' },
21
21
  { name: 'u_dash_opacity', type: 'float' }
22
22
  ], uniformBindingPoints.flexible);
23
- var vertexShader = "#version 300 es\nprecision highp float;\n\n".concat(geometrytransformations_1.R_3D, "\n").concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.slerp, "\n").concat(geometrytransformations_1.mercatorXYToGLPosition, "\n").concat(geometrytransformations_1.cartesian3DToGLPosition, "\n\n").concat(uniformBlockManager.glslCode(), "\n\nin vec2 start_position;\nin vec3 start_position3d;\nin vec2 end_position;\nin vec3 end_position3d;\n\nin float dash_ratio;\nin float dash_opacity;\nin vec4 color;\n\nout float v_dash_ratio;\nout float v_dash_opacity;\nout vec4 v_color;\n\nout vec2 v_limp;\nout float interpolation;\n\nvoid main() {\n vec2 longLat;\n\n v_color = (color.r == -1.0) ? u_color: color;\n v_dash_ratio = (dash_ratio == -1.0) ? u_dash_ratio : dash_ratio;\n v_dash_opacity = (dash_opacity == -1.0) ? u_dash_opacity : dash_opacity;\n\n if (is3D) {\n interpolation = float(gl_VertexID) / ").concat(GLOBE_MIDPOINT_COUNT - 1, ".0;\n vec3 cartesian = slerp(start_position3d, end_position3d, interpolation);\n gl_Position = cartesian3DToGLPosition(cartesian);\n v_limp = vec2(0.0, 0.0);\n } else {\n if ( distance( start_position, end_position) > 30000000.0) { return; }\n interpolation = float(gl_VertexID);\n if (gl_VertexID % 2 == 0) {\n longLat = start_position;\n } else {\n longLat = end_position;\n }\n v_limp = longLat;\n gl_Position = mercatorXYToGLPosition(longLat);\n }\n}\n");
24
- var fragmentShader = "#version 300 es\n".concat(geometrytransformations_1.POLE, "\nprecision highp float;\n\nuniform float opacity;\n\nin float interpolation;\nin vec2 v_limp;\nin vec4 v_color;\nin float v_dash_ratio;\nin float v_dash_opacity;\n\nout vec4 color;\n\nvoid main() {\n if (v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE) { discard; }\n color = v_color;\n color.a *= opacity;\n if ( v_dash_ratio >= 1.0 ) { return; }\n if (interpolation > 0.95) { return; }\n if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5) { color.a *= v_dash_opacity; }\n\n}\n");
25
- var Logic = /** @class */ (function () {
26
- function Logic(globe) {
27
- this.vaosPublished = [];
28
- this.isFreed = false;
23
+ const vertexShader = `#version 300 es
24
+ precision highp float;
25
+
26
+ ${geometrytransformations_1.R_3D}
27
+ ${totems_1.CameraUniformBlockString}
28
+ ${geometrytransformations_1.slerp}
29
+ ${geometrytransformations_1.mercatorXYToGLPosition}
30
+ ${geometrytransformations_1.cartesian3DToGLPosition}
31
+
32
+ ${uniformBlockManager.glslCode()}
33
+
34
+ in vec2 start_position;
35
+ in vec3 start_position3d;
36
+ in vec2 end_position;
37
+ in vec3 end_position3d;
38
+
39
+ in float dash_ratio;
40
+ in float dash_opacity;
41
+ in vec4 color;
42
+
43
+ out float v_dash_ratio;
44
+ out float v_dash_opacity;
45
+ out vec4 v_color;
46
+
47
+ out vec2 v_limp;
48
+ out float interpolation;
49
+
50
+ void main() {
51
+ vec2 longLat;
52
+
53
+ v_color = (color.r == -1.0) ? u_color: color;
54
+ v_dash_ratio = (dash_ratio == -1.0) ? u_dash_ratio : dash_ratio;
55
+ v_dash_opacity = (dash_opacity == -1.0) ? u_dash_opacity : dash_opacity;
56
+
57
+ if (is3D) {
58
+ interpolation = float(gl_VertexID) / ${GLOBE_MIDPOINT_COUNT - 1}.0;
59
+ vec3 cartesian = slerp(start_position3d, end_position3d, interpolation);
60
+ gl_Position = cartesian3DToGLPosition(cartesian);
61
+ v_limp = vec2(0.0, 0.0);
62
+ } else {
63
+ if ( distance( start_position, end_position) > 30000000.0) { return; }
64
+ interpolation = float(gl_VertexID);
65
+ if (gl_VertexID % 2 == 0) {
66
+ longLat = start_position;
67
+ } else {
68
+ longLat = end_position;
69
+ }
70
+ v_limp = longLat;
71
+ gl_Position = mercatorXYToGLPosition(longLat);
72
+ }
73
+ }
74
+ `;
75
+ const fragmentShader = `#version 300 es
76
+ ${geometrytransformations_1.POLE}
77
+ precision highp float;
78
+
79
+ uniform float opacity;
80
+
81
+ in float interpolation;
82
+ in vec2 v_limp;
83
+ in vec4 v_color;
84
+ in float v_dash_ratio;
85
+ in float v_dash_opacity;
86
+
87
+ out vec4 color;
88
+
89
+ void main() {
90
+ if (v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE) { discard; }
91
+ color = v_color;
92
+ color.a *= opacity;
93
+ if ( v_dash_ratio >= 1.0 ) { return; }
94
+ if (interpolation > 0.95) { return; }
95
+ if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5) { color.a *= v_dash_opacity; }
96
+
97
+ }
98
+ `;
99
+ class Logic {
100
+ vaosPublished = [];
101
+ isFreed = false;
102
+ constructor(globe) {
29
103
  this.globe = globe;
30
104
  this.gl = globe.gl;
31
105
  this.program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
32
106
  this._lastOpacity = 1.0;
33
- var _a = this, gl = _a.gl, program = _a.program;
34
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
107
+ const { gl, program } = this;
108
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
35
109
  gl.useProgram(program);
36
110
  // assign attribute locations
37
111
  gl.bindAttribLocation(program, 0, "start_position");
@@ -60,9 +134,8 @@ var Logic = /** @class */ (function () {
60
134
  * @param {number} flexibleOptions.dash_opacity
61
135
  * @param {number} flexibleOptions.dash_ratio
62
136
  */
63
- Logic.prototype.draw = function (vao, drawOptions, opacity, flexibleUBO) {
64
- if (flexibleUBO === void 0) { flexibleUBO = null; }
65
- var _a = this, gl = _a.gl, program = _a.program, globe = _a.globe, cameraBlockTotem = _a.cameraBlockTotem, _defaultFlexibleUBO = _a._defaultFlexibleUBO;
137
+ draw(vao, drawOptions, opacity, flexibleUBO = null) {
138
+ const { gl, program, globe, cameraBlockTotem, _defaultFlexibleUBO } = this;
66
139
  gl.useProgram(program);
67
140
  cameraBlockTotem.bind(uniformBindingPoints.camera);
68
141
  gl.bindVertexArray(vao);
@@ -71,17 +144,16 @@ var Logic = /** @class */ (function () {
71
144
  this._lastOpacity = opacity;
72
145
  }
73
146
  // this._setFlexibleUniforms(flexibleOptions);
74
- var vertexCount = globe.api_GetCurrentGeometry() === 0 ? GLOBE_MIDPOINT_COUNT : 2;
75
- var ubo = flexibleUBO || _defaultFlexibleUBO;
147
+ const vertexCount = globe.api_GetCurrentGeometry() === 0 ? GLOBE_MIDPOINT_COUNT : 2;
148
+ const ubo = flexibleUBO || _defaultFlexibleUBO;
76
149
  ubo.bind();
77
150
  (0, methods_1.drawInstanced)(gl, gl.LINE_STRIP, drawOptions, vertexCount);
78
151
  ubo.unbind();
79
152
  gl.bindVertexArray(null);
80
153
  cameraBlockTotem.unbind(uniformBindingPoints.camera);
81
- };
82
- Logic.prototype.createUBO = function (bufferReadType) {
83
- if (bufferReadType === void 0) { bufferReadType = "STATIC_DRAW"; }
84
- var ubo = uniformBlockManager.createUBO(this.gl, bufferReadType);
154
+ }
155
+ createUBO(bufferReadType = "STATIC_DRAW") {
156
+ const ubo = uniformBlockManager.createUBO(this.gl, bufferReadType);
85
157
  this._ubosPublished.push(ubo);
86
158
  ubo.update(new Map([
87
159
  ["u_color", [1, 1, 1, 1]],
@@ -89,37 +161,35 @@ var Logic = /** @class */ (function () {
89
161
  ["u_dash_opacity", [1]]
90
162
  ]));
91
163
  return ubo;
92
- };
93
- Logic.prototype.createVAO = function (startPotision2DBufferObj, startPotision3DBufferObj, endPosition2DBufferObj, endPosition3DBufferObj, dashRatioBufferObj, dashOpacityBufferObj, colorBufferObj) {
94
- var gl = this.gl;
95
- var vao = gl.createVertexArray();
164
+ }
165
+ createVAO(startPotision2DBufferObj, startPotision3DBufferObj, endPosition2DBufferObj, endPosition3DBufferObj, dashRatioBufferObj, dashOpacityBufferObj, colorBufferObj) {
166
+ const { gl } = this;
167
+ const vao = gl.createVertexArray();
96
168
  gl.bindVertexArray(vao);
97
- var divisor = 1;
98
- (0, attribute_loader_1.attributeLoader)(gl, startPotision2DBufferObj, 0, 2, { divisor: divisor });
99
- (0, attribute_loader_1.attributeLoader)(gl, startPotision3DBufferObj, 1, 3, { divisor: divisor });
100
- (0, attribute_loader_1.attributeLoader)(gl, endPosition2DBufferObj, 2, 2, { divisor: divisor });
101
- (0, attribute_loader_1.attributeLoader)(gl, endPosition3DBufferObj, 3, 3, { divisor: divisor });
102
- (0, attribute_loader_1.attributeLoader)(gl, dashRatioBufferObj, 4, 1, { divisor: divisor, escapeValues: [escapeValue] });
103
- (0, attribute_loader_1.attributeLoader)(gl, dashOpacityBufferObj, 5, 1, { divisor: divisor, escapeValues: [escapeValue] });
104
- (0, attribute_loader_1.attributeLoader)(gl, colorBufferObj, 6, 4, { divisor: divisor, escapeValues: [escapeValue, escapeValue, escapeValue, escapeValue] });
169
+ const divisor = 1;
170
+ (0, attribute_loader_1.attributeLoader)(gl, startPotision2DBufferObj, 0, 2, { divisor });
171
+ (0, attribute_loader_1.attributeLoader)(gl, startPotision3DBufferObj, 1, 3, { divisor });
172
+ (0, attribute_loader_1.attributeLoader)(gl, endPosition2DBufferObj, 2, 2, { divisor });
173
+ (0, attribute_loader_1.attributeLoader)(gl, endPosition3DBufferObj, 3, 3, { divisor });
174
+ (0, attribute_loader_1.attributeLoader)(gl, dashRatioBufferObj, 4, 1, { divisor, escapeValues: [escapeValue] });
175
+ (0, attribute_loader_1.attributeLoader)(gl, dashOpacityBufferObj, 5, 1, { divisor, escapeValues: [escapeValue] });
176
+ (0, attribute_loader_1.attributeLoader)(gl, colorBufferObj, 6, 4, { divisor, escapeValues: [escapeValue, escapeValue, escapeValue, escapeValue] });
105
177
  gl.bindVertexArray(null);
106
178
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
107
179
  this.vaosPublished.push(vao);
108
180
  return vao;
109
- };
110
- Logic.prototype.free = function () {
111
- var _this = this;
181
+ }
182
+ free() {
112
183
  if (this.isFreed)
113
184
  return;
114
185
  totems_1.CameraUniformBlockTotemCache.release(this.globe);
115
186
  this.gl.deleteProgram(this.program);
116
- this.vaosPublished.forEach(function (vao) { return _this.gl.deleteVertexArray(vao); });
117
- this._ubosPublished.forEach(function (ubo) { return ubo.free(); });
187
+ this.vaosPublished.forEach(vao => this.gl.deleteVertexArray(vao));
188
+ this._ubosPublished.forEach(ubo => ubo.free());
118
189
  this.isFreed = true;
119
- };
120
- return Logic;
121
- }());
190
+ }
191
+ }
122
192
  exports.LineOnGlobeCache = Object.freeze({
123
- get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
124
- release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
193
+ get: (globe) => { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
194
+ release: (globe) => { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
125
195
  });
@@ -1,20 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var util_1 = require("./util");
4
- var totems_1 = require("../totems");
5
- var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
6
- var programcache_1 = require("../programcache");
7
- var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
3
+ const util_1 = require("./util");
4
+ const totems_1 = require("../totems");
5
+ const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
6
+ const programcache_1 = require("../programcache");
7
+ const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
8
8
  require("../draw-options/types");
9
- var methods_1 = require("../draw-options/methods");
10
- var vs = "#version 300 es\n".concat(geometrytransformations_1.R_3D, "\n").concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.cartesian3DToGLPosition, "\nin vec3 pos3D\nin vec4 color;\nout float ratio;\nout flat vec4 vColor;\nvoid main(){\n if ( gl_VertexID == 0) {\n gl_Position = cartesian3DToGLPosition(pos3D);\n ratio =0.0;\n } else {\n vec3 sea_level_pos3D = norm(pos3D) * R_3D;\n gl_Position = cartesian3DToGLPosition(pos3D);\n ratio = 1.0;\n }\n vColor = color; \n}");
11
- var fs = "#version 300 es\nuniform float opacity;\nuniform float phase;\nuniform float fadeOpacity;\nin flat vec4 vColor;\nin float ratio;\nout vec4 fragColor;\nvoid main(){\n fragColor = vec4( vColor.rgb, vColor.a * opacity);\n if (fadeOpacity < 1.0) {\n float alpha= mix( fadeOpacity, vColor.a, fract( ratio + phase ));\n fragColor.a *= alpha;\n } \n}";
12
- var Logic = /** @class */ (function () {
13
- function Logic(globe) {
9
+ const methods_1 = require("../draw-options/methods");
10
+ const vs = `#version 300 es
11
+ ${geometrytransformations_1.R_3D}
12
+ ${totems_1.CameraUniformBlockString}
13
+ ${geometrytransformations_1.cartesian3DToGLPosition}
14
+ in vec3 pos3D
15
+ in vec4 color;
16
+ out float ratio;
17
+ out flat vec4 vColor;
18
+ void main(){
19
+ if ( gl_VertexID == 0) {
20
+ gl_Position = cartesian3DToGLPosition(pos3D);
21
+ ratio =0.0;
22
+ } else {
23
+ vec3 sea_level_pos3D = norm(pos3D) * R_3D;
24
+ gl_Position = cartesian3DToGLPosition(pos3D);
25
+ ratio = 1.0;
26
+ }
27
+ vColor = color;
28
+ }`;
29
+ const fs = `#version 300 es
30
+ uniform float opacity;
31
+ uniform float phase;
32
+ uniform float fadeOpacity;
33
+ in flat vec4 vColor;
34
+ in float ratio;
35
+ out vec4 fragColor;
36
+ void main(){
37
+ fragColor = vec4( vColor.rgb, vColor.a * opacity);
38
+ if (fadeOpacity < 1.0) {
39
+ float alpha= mix( fadeOpacity, vColor.a, fract( ratio + phase ));
40
+ fragColor.a *= alpha;
41
+ }
42
+ }`;
43
+ class Logic {
44
+ constructor(globe) {
14
45
  this.globe = globe;
15
46
  this.gl = globe.gl;
16
47
  this.program = (0, util_1.createProgram)(this.gl, vs, fs);
17
- var _a = this, gl = _a.gl, program = _a.program;
48
+ const { gl, program } = this;
18
49
  this._opacity = {
19
50
  lastValue: 1.0,
20
51
  location: gl.getUniformLocation(program, 'opacity')
@@ -27,37 +58,36 @@ var Logic = /** @class */ (function () {
27
58
  lastValue: 1.0,
28
59
  location: gl.getUniformBlockLocation(program, 'fadeOpacity')
29
60
  };
30
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
61
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
31
62
  gl.useProgram(program);
32
- [this._opacity, this._phase, this._fadeOpacity].forEach(function (wrapper) { return gl.uniform1f(wrapper.location, wrapper.lastValue); });
63
+ [this._opacity, this._phase, this._fadeOpacity].forEach((wrapper) => gl.uniform1f(wrapper.location, wrapper.lastValue));
33
64
  gl.useProgram(currentProgram);
34
65
  gl.useProgram(program);
35
66
  gl.bindAttribLocation(program, 0, 'pos3D');
36
67
  gl.bindAttribLocation(program, 1, 'color');
37
68
  this.cameraUniformBlockTotem = new totems_1.CameraUniformBlockTotemCache.get(globe);
38
69
  this.cameraBlockBindingPoint = 0;
39
- var cameraBlockIndex = gl.getUniformBlockLocation(program, 'CameraUniformBlock');
70
+ const cameraBlockIndex = gl.getUniformBlockLocation(program, 'CameraUniformBlock');
40
71
  gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
41
72
  }
42
- Logic.prototype.createVao = function (pos3DObj, colorObj) {
43
- var gl = this.gl;
44
- var vao = gl.createVertexArray();
45
- var divisor = 1;
73
+ createVao(pos3DObj, colorObj) {
74
+ const { gl } = this;
75
+ const vao = gl.createVertexArray();
76
+ const divisor = 1;
46
77
  gl.bindVertexArray(vao);
47
- (0, attribute_loader_1.attributeLoader)(gl, pos3DObj, 0, 3, { divisor: divisor });
48
- (0, attribute_loader_1.attributeLoader)(gl, colorObj, 1, 4, { divisor: divisor, escapeValue: [-1, -1, -1, -1] });
78
+ (0, attribute_loader_1.attributeLoader)(gl, pos3DObj, 0, 3, { divisor });
79
+ (0, attribute_loader_1.attributeLoader)(gl, colorObj, 1, 4, { divisor, escapeValue: [-1, -1, -1, -1] });
49
80
  gl.bindVertexArray(null);
50
81
  this._vaoCache.push(vao);
51
82
  return vao;
52
- };
83
+ }
53
84
  /**
54
85
  *
55
86
  * @param {WebGL2RenderingContext.vertexArrayObject} vao
56
87
  * @param {Render} drawOptions
57
88
  */
58
- Logic.prototype.draw = function (vao, drawOptions, _a) {
59
- var _b = _a.opacity, opacity = _b === void 0 ? 1.0 : _b, _c = _a.fadeOpacity, fadeOpacity = _c === void 0 ? 1.0 : _c;
60
- var _d = this, globe = _d.globe, gl = _d.gl, program = _d.program, _opacity = _d._opacity, _fadeOpacity = _d._fadeOpacity;
89
+ draw(vao, drawOptions, { opacity = 1.0, fadeOpacity = 1.0, }) {
90
+ const { globe, gl, program, _opacity, _fadeOpacity } = this;
61
91
  gl.useProgram(program);
62
92
  gl.bindVertexArray(vao);
63
93
  if (fadeOpacity < 1.0) {
@@ -73,10 +103,9 @@ var Logic = /** @class */ (function () {
73
103
  gl.uniform1f(_opacity.location, opacity);
74
104
  }
75
105
  (0, methods_1.drawInstanced)(gl, gl.TRIANGLE_FAN, drawOptions);
76
- };
77
- Logic.prototype._updatePhase = function () {
106
+ }
107
+ _updatePhase() {
78
108
  this._phase.lastValue = (Date.now() / 3.0) % 1000;
79
109
  gl.uniform1f(_phase.location, _phase.lastValue);
80
- };
81
- return Logic;
82
- }());
110
+ }
111
+ }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Z_ALPHA_MODE = void 0;
4
- var Z_ALPHA_MODE = Object.freeze({
4
+ const Z_ALPHA_MODE = Object.freeze({
5
5
  ON: 1,
6
6
  OFF: 0
7
7
  });
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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");
4
+ const util_1 = require("../../util");
5
+ const totems_1 = require("../totems");
6
+ const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
7
+ const programcache_1 = require("../programcache");
8
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 = {
9
+ const methods_1 = require("../../util/gl-util/draw-options/methods");
10
+ const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
11
+ const manager_1 = require("../../util/gl-util/uniform-block/manager");
12
+ const uniformBindingPoints = {
13
13
  camera: 0,
14
14
  flexible: 1
15
15
  };
16
- var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
16
+ const uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
17
17
  { name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
18
18
  { name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
19
19
  { name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
@@ -25,15 +25,101 @@ var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
25
25
  { name: "u_dash_opacity_multiplier", type: "float", value: new Float32Array([1.0]) },
26
26
  { name: "u_dash_phase", type: "float", value: new Float32Array([0.0]) },
27
27
  ], 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) {
28
+ const vs = `#version 300 es
29
+ ${geometrytransformations_1.R}
30
+ ${geometrytransformations_1.R_3D}
31
+ ${totems_1.CameraUniformBlockString}
32
+ ${geometrytransformations_1.mercatorXYToGLPosition}
33
+ ${geometrytransformations_1.cartesian3DToGLPosition}
34
+
35
+ ${uniformBlockManager.glslCode()}
36
+
37
+ precision highp float;
38
+ precision highp int;
39
+
40
+ in vec3 pos3D;
41
+ in vec2 pos2D;
42
+ in vec4 rgba;
43
+ in float size;
44
+
45
+
46
+ flat out highp int vVertexID;
47
+
48
+ out vec4 v_rgba;
49
+
50
+ out float v_length;
51
+
52
+ void main() {
53
+
54
+ v_rgba = (rgba.r == -1.0) ? u_rgba : rgba;
55
+ v_rgba.a *= u_opacity;
56
+ gl_PointSize = max(((size == -1.0) ? u_size : size) * u_size_multiplier, u_minimum_size);
57
+
58
+ float size_fixer;
59
+ if(is3D){
60
+ gl_Position = cartesian3DToGLPosition(pos3D);
61
+ size_fixer = smoothstep(0.15, 1.0, 0.5 * R_3D / gl_Position.w) ;
62
+ } else {
63
+ gl_Position = mercatorXYToGLPosition(pos2D);
64
+ size_fixer = smoothstep(2.0, 5.2, z_level);
65
+ }
66
+ gl_PointSize *= size_fixer;
67
+ switch (u_draw_mode) {
68
+ case 0:
69
+ vVertexID = gl_VertexID;
70
+ break;
71
+ case 1:
72
+ v_length = float(gl_VertexID % 2);
73
+ vVertexID = (gl_VertexID - gl_VertexID % 2) / 2; // a line takes two points
74
+ break;
75
+ default:
76
+ break;
77
+ }
78
+ }`;
79
+ const fs = `#version 300 es
80
+ precision highp float;
81
+ precision highp int;
82
+
83
+ ${uniformBlockManager.glslCode()}
84
+
85
+ flat in highp int vVertexID;
86
+
87
+ in vec4 v_rgba;
88
+ in float v_length;
89
+
90
+ layout(location = 0) out vec4 fragColor;
91
+ layout(location = 1) out int vertexID;
92
+
93
+ void main() {
94
+ vertexID = vVertexID;
95
+ fragColor = v_rgba;
96
+
97
+ switch (u_draw_mode) {
98
+ case 0:
99
+ float d = distance(gl_PointCoord, vec2(0.5, 0.5));
100
+ if (u_is_circle) {
101
+ if (d > 0.5) discard;
102
+ fragColor.a *= smoothstep(0.5, 0.45, d);
103
+ }
104
+ if (u_dash_opacity_multiplier < 1.0) {
105
+ float dash = sin(d * 3.14159 * 2.0 * u_dash_count + u_dash_phase) * (1.0 - u_dash_opacity_multiplier) + u_dash_opacity_multiplier;
106
+ fragColor.a *= dash;
107
+ }
108
+ break;
109
+ case 1:
110
+ if (u_dash_opacity_multiplier < 1.0 && fract((v_length + u_dash_phase) * u_dash_count) < 0.5) {
111
+ fragColor.a *= u_dash_opacity_multiplier;
112
+ }
113
+ break;
114
+ }
115
+ }`;
116
+ class PointOnGlobeProgram {
117
+ constructor(globe) {
32
118
  this.globe = globe;
33
119
  this.gl = globe.gl;
34
120
  this._isFreed = false;
35
121
  this.program = (0, util_1.createProgram)(this.gl, vs, fs);
36
- var _a = this, gl = _a.gl, program = _a.program;
122
+ const { gl, program } = this;
37
123
  // assign opacity
38
124
  // assign attribute locations
39
125
  gl.bindAttribLocation(program, 0, "pos3D");
@@ -53,13 +139,13 @@ var PointOnGlobeProgram = /** @class */ (function () {
53
139
  ["u_is_circle", [1.0]],
54
140
  ]));
55
141
  }
56
- PointOnGlobeProgram.prototype.createUBO = function () {
57
- var ubo = uniformBlockManager.createUBO(this.gl);
142
+ createUBO() {
143
+ const ubo = uniformBlockManager.createUBO(this.gl);
58
144
  return ubo;
59
- };
60
- PointOnGlobeProgram.prototype.createVAO = function (pos3DBufferObj, pos2DBufferObj, rgbaBufferObj, sizeBufferObj) {
61
- var gl = this.gl;
62
- var vao = gl.createVertexArray();
145
+ }
146
+ createVAO(pos3DBufferObj, pos2DBufferObj, rgbaBufferObj, sizeBufferObj) {
147
+ const { gl } = this;
148
+ const vao = gl.createVertexArray();
63
149
  gl.bindVertexArray(vao);
64
150
  (0, attribute_loader_1.attributeLoader)(gl, pos3DBufferObj, 0, 3);
65
151
  (0, attribute_loader_1.attributeLoader)(gl, pos2DBufferObj, 1, 2);
@@ -68,15 +154,14 @@ var PointOnGlobeProgram = /** @class */ (function () {
68
154
  gl.bindVertexArray(null);
69
155
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
70
156
  return vao;
71
- };
157
+ }
72
158
  /**
73
159
  *
74
160
  * @param {vertexArrayObject} vao
75
161
  * @param {DrawRangeIndexParams} drawOptions
76
162
  */
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;
163
+ draw(vao, drawOptions, ubo = null) {
164
+ const { gl, program } = this;
80
165
  gl.useProgram(program);
81
166
  gl.bindVertexArray(vao);
82
167
  this.cameraBlockTotem.bind(uniformBindingPoints.camera);
@@ -86,19 +171,18 @@ var PointOnGlobeProgram = /** @class */ (function () {
86
171
  ubo.unbind();
87
172
  this.cameraBlockTotem.unbind(uniformBindingPoints.camera);
88
173
  gl.bindVertexArray(null);
89
- };
90
- PointOnGlobeProgram.prototype.free = function () {
174
+ }
175
+ free() {
91
176
  if (this._isFreed)
92
177
  return;
93
- var _a = this, gl = _a.gl, globe = _a.globe;
178
+ const { gl, globe } = this;
94
179
  totems_1.CameraUniformBlockTotemCache.release(globe);
95
180
  gl.deleteProgram(this.program);
96
181
  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); }
182
+ }
183
+ }
184
+ const PickableRendererProgramCache = Object.freeze({
185
+ get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram),
186
+ release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram)
103
187
  });
104
188
  exports.PickableRendererProgramCache = PickableRendererProgramCache;