@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
@@ -3,8 +3,8 @@
3
3
  * Author: Toprak Nihat Deniz Ozturk
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var util_1 = require("../util");
7
- var TrackGlowLineProgram = /** @class */ (function () {
6
+ const util_1 = require("../util");
7
+ class TrackGlowLineProgram {
8
8
  /**
9
9
  * @param {WebGL2RenderingContext} gl
10
10
  * @param {number} width
@@ -19,8 +19,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
19
19
  * @param {number} options.finalAlphaRatio 0 ~ 1
20
20
  * @param {+int} options.blurRepetition 1 ~ inf default 2
21
21
  */
22
- function TrackGlowLineProgram(gl, attrBuffer, width, height, options) {
23
- if (options === void 0) { options = {}; }
22
+ constructor(gl, attrBuffer, width, height, options = {}) {
24
23
  this.gl = gl;
25
24
  this.program = null;
26
25
  // this._inBuffer = gl.createBuffer();
@@ -38,14 +37,13 @@ var TrackGlowLineProgram = /** @class */ (function () {
38
37
  this._totalLength = 0;
39
38
  this._initUniforms(options);
40
39
  }
41
- TrackGlowLineProgram.prototype._createInnerTextures = function () {
40
+ _createInnerTextures() {
42
41
  this._middleTexture = this._createTextures();
43
42
  this._blurTextures = [this._createTextures(), this._createTextures()];
44
- };
45
- TrackGlowLineProgram.prototype._initUniforms = function (options) {
46
- if (options === void 0) { options = {}; }
47
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram, _blurProgram = _a._blurProgram, _combineProgram = _a._combineProgram;
48
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
43
+ }
44
+ _initUniforms(options = {}) {
45
+ const { gl, _lineProgram, _blurProgram, _combineProgram } = this;
46
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
49
47
  gl.useProgram(_lineProgram.program);
50
48
  gl.uniform1f(_lineProgram.u_head_percentage, options.headPercentage || 1.0 / 30.0);
51
49
  gl.uniform1f(_lineProgram.u_route_alpha, options.routeAlpha || 0.025);
@@ -56,117 +54,146 @@ var TrackGlowLineProgram = /** @class */ (function () {
56
54
  gl.uniform1f(_combineProgram.u_gamma, options.gamma || 1.0);
57
55
  gl.uniform1f(_combineProgram.u_final_alpha_ratio, options.finalAlphaRatio || 1.0);
58
56
  gl.useProgram(currentProgram);
59
- };
57
+ }
60
58
  /**
61
59
  * @param {number} gamma 0 ~ inf
62
60
  */
63
- TrackGlowLineProgram.prototype.setGamma = function (gamma) {
61
+ setGamma(gamma) {
64
62
  if (gamma < 0) {
65
63
  console.warn("gamma should be equal or greater than 0, but got", gamma);
66
64
  return;
67
65
  }
68
- var _a = this, gl = _a.gl, _combineProgram = _a._combineProgram;
69
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
66
+ const { gl, _combineProgram } = this;
67
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
70
68
  gl.useProgram(_combineProgram.program);
71
69
  gl.uniform1f(_combineProgram.u_gamma, gamma);
72
70
  gl.useProgram(currentProgram);
73
- };
71
+ }
74
72
  /**
75
73
  *
76
74
  * @param {number} exposure 0 ~ inf
77
75
  * @returns
78
76
  */
79
- TrackGlowLineProgram.prototype.setExposure = function (exposure) {
77
+ setExposure(exposure) {
80
78
  if (exposure < 0) {
81
79
  console.warn("exposure should be equal or greater than 0, but got", exposure);
82
80
  return;
83
81
  }
84
- var _a = this, gl = _a.gl, _combineProgram = _a._combineProgram;
85
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
82
+ const { gl, _combineProgram } = this;
83
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
86
84
  gl.useProgram(_combineProgram.program);
87
85
  gl.uniform1f(_combineProgram.u_exposure, exposure);
88
86
  gl.useProgram(currentProgram);
89
- };
87
+ }
90
88
  /**
91
89
  *
92
90
  * @param {number} ratio 0 ~ 1
93
91
  * @returns
94
92
  */
95
- TrackGlowLineProgram.prototype.setFinalAlphaRatio = function (ratio) {
93
+ setFinalAlphaRatio(ratio) {
96
94
  if (ratio < 0 || ratio > 1) {
97
95
  console.warn("ratio should be between 0 and 1, but got", ratio);
98
96
  return;
99
97
  }
100
- var _a = this, gl = _a.gl, _combineProgram = _a._combineProgram;
101
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
98
+ const { gl, _combineProgram } = this;
99
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
102
100
  gl.useProgram(_combineProgram.program);
103
101
  gl.uniform1f(_combineProgram.u_final_alpha_ratio, ratio);
104
102
  gl.useProgram(currentProgram);
105
- };
103
+ }
106
104
  /**
107
105
  * @param {Array.<Number>} weight [w1, w2, w3, w4, w5]
108
106
  */
109
- TrackGlowLineProgram.prototype.setBlurWeights = function (weights) {
107
+ setBlurWeights(weights) {
110
108
  if (weights.length !== 5) {
111
109
  console.warn("weights should be an array of 5 numbers, but got", weights);
112
110
  return;
113
111
  }
114
- var _a = this, gl = _a.gl, _blurProgram = _a._blurProgram;
115
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
112
+ const { gl, _blurProgram } = this;
113
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
116
114
  gl.useProgram(_blurProgram.program);
117
115
  gl.uniform1fv(_blurProgram.u_weight, weights);
118
116
  gl.useProgram(currentProgram);
119
- };
117
+ }
120
118
  /**
121
119
  * @param {number} routeAlpha 0 ~ 1
122
120
  */
123
- TrackGlowLineProgram.prototype.setRouteAlpha = function (routeAlpha) {
121
+ setRouteAlpha(routeAlpha) {
124
122
  if (routeAlpha < 0 || routeAlpha > 1) {
125
123
  console.warn("routeAlpha should be between 0 and 1, but got", routeAlpha);
126
124
  return;
127
125
  }
128
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
129
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
126
+ const { gl, _lineProgram } = this;
127
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
130
128
  gl.useProgram(_lineProgram.program);
131
129
  gl.uniform1f(_lineProgram.u_route_alpha, routeAlpha);
132
130
  gl.useProgram(currentProgram);
133
- };
131
+ }
134
132
  /**
135
133
  * blur uses pingpong effect. This number decides how many times the blur will be applied.
136
134
  * @param {+int} repetition
137
135
  * @returns
138
136
  */
139
- TrackGlowLineProgram.prototype.setBlurRepetition = function (repetition) {
137
+ setBlurRepetition(repetition) {
140
138
  if (repetition < 0 && repetition % 1 !== 0) {
141
139
  console.warn("repetition should be an integer greater than 0, but got", repetition);
142
140
  return;
143
141
  }
144
142
  this._blurRepetition = repetition;
145
- };
143
+ }
146
144
  /**
147
145
  * Head Is colored as white. This number decides proportion of the head according to the total length of the line.
148
146
  * @param {Number} percentage 0 ~ 1
149
147
  */
150
- TrackGlowLineProgram.prototype.setHeadPercentage = function (percentage) {
148
+ setHeadPercentage(percentage) {
151
149
  if (percentage < 0 || 1 < percentage) {
152
150
  console.warn("percentage should be between 0 and 1, but got", percentage);
153
151
  return;
154
152
  }
155
153
  ;
156
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
157
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
154
+ const { gl, _lineProgram } = this;
155
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
158
156
  gl.useProgram(_lineProgram.program);
159
157
  gl.uniform1f(_lineProgram.u_head_percentage, percentage);
160
158
  gl.useProgram(currentProgram);
161
- };
162
- TrackGlowLineProgram.prototype._createDrawTextureProgram = function () {
163
- var gl = this.gl;
164
- var vertexShader = "#version 300 es\nprecision highp float;\n\nin vec2 a_position;\n\nout vec2 v_texcoord;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texcoord = a_position.xy * 0.5 + 0.5;\n}\n ";
165
- var fragmentShader = "#version 300 es\nprecision highp float;\n\nin vec2 v_texcoord;\n\nuniform sampler2D u_main_texture;\n\n\nuniform float u_final_alpha_ratio;\n\nout vec4 outColor;\n\nvoid main() {\n\n vec4 hdrColor = texture(u_main_texture, v_texcoord); \n outColor = hdrColor;\n outColor.a *= u_final_alpha_ratio;\n}\n ";
166
- var program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
167
- var buffer = gl.createBuffer();
168
- var a_position = gl.getAttribLocation(program, "a_position");
169
- var vao = gl.createVertexArray();
159
+ }
160
+ _createDrawTextureProgram() {
161
+ const gl = this.gl;
162
+ const vertexShader = `#version 300 es
163
+ precision highp float;
164
+
165
+ in vec2 a_position;
166
+
167
+ out vec2 v_texcoord;
168
+
169
+ void main() {
170
+ gl_Position = vec4(a_position, 0.0, 1.0);
171
+ v_texcoord = a_position.xy * 0.5 + 0.5;
172
+ }
173
+ `;
174
+ const fragmentShader = `#version 300 es
175
+ precision highp float;
176
+
177
+ in vec2 v_texcoord;
178
+
179
+ uniform sampler2D u_main_texture;
180
+
181
+
182
+ uniform float u_final_alpha_ratio;
183
+
184
+ out vec4 outColor;
185
+
186
+ void main() {
187
+
188
+ vec4 hdrColor = texture(u_main_texture, v_texcoord);
189
+ outColor = hdrColor;
190
+ outColor.a *= u_final_alpha_ratio;
191
+ }
192
+ `;
193
+ const program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
194
+ const buffer = gl.createBuffer();
195
+ const a_position = gl.getAttribLocation(program, "a_position");
196
+ const vao = gl.createVertexArray();
170
197
  gl.bindVertexArray(vao);
171
198
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
172
199
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
@@ -186,15 +213,49 @@ var TrackGlowLineProgram = /** @class */ (function () {
186
213
  u_main_texture: gl.getUniformLocation(program, "u_main_texture"),
187
214
  u_final_alpha_ratio: gl.getUniformLocation(program, "u_final_alpha_ratio"),
188
215
  };
189
- };
190
- TrackGlowLineProgram.prototype._createCombineProgram = function () {
191
- var gl = this.gl;
192
- var vertexShader = "#version 300 es\nprecision highp float;\n\nin vec2 a_position;\n\nout vec2 v_texcoord;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texcoord = a_position.xy * 0.5 + 0.5;\n}\n ";
193
- var fragmentShader = "#version 300 es\nprecision highp float;\n\nin vec2 v_texcoord;\n\nuniform sampler2D u_main_texture;\nuniform sampler2D u_bloom_texture;\n\nuniform float u_exposure;\nuniform float u_gamma;\nuniform float u_final_alpha_ratio;\n\nout vec4 outColor;\n\nvoid main() {\n\n vec4 hdrColor = texture(u_main_texture, v_texcoord); \n vec4 bloomColor = texture(u_bloom_texture, v_texcoord);\n vec4 result = hdrColor + bloomColor * u_exposure;\n result = pow(result, vec4(1.0 / u_gamma));\n result.a *= u_final_alpha_ratio;\n outColor = result;\n}\n ";
194
- var program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
195
- var buffer = gl.createBuffer();
196
- var a_position = gl.getAttribLocation(program, "a_position");
197
- var vao = gl.createVertexArray();
216
+ }
217
+ _createCombineProgram() {
218
+ const gl = this.gl;
219
+ const vertexShader = `#version 300 es
220
+ precision highp float;
221
+
222
+ in vec2 a_position;
223
+
224
+ out vec2 v_texcoord;
225
+
226
+ void main() {
227
+ gl_Position = vec4(a_position, 0.0, 1.0);
228
+ v_texcoord = a_position.xy * 0.5 + 0.5;
229
+ }
230
+ `;
231
+ const fragmentShader = `#version 300 es
232
+ precision highp float;
233
+
234
+ in vec2 v_texcoord;
235
+
236
+ uniform sampler2D u_main_texture;
237
+ uniform sampler2D u_bloom_texture;
238
+
239
+ uniform float u_exposure;
240
+ uniform float u_gamma;
241
+ uniform float u_final_alpha_ratio;
242
+
243
+ out vec4 outColor;
244
+
245
+ void main() {
246
+
247
+ vec4 hdrColor = texture(u_main_texture, v_texcoord);
248
+ vec4 bloomColor = texture(u_bloom_texture, v_texcoord);
249
+ vec4 result = hdrColor + bloomColor * u_exposure;
250
+ result = pow(result, vec4(1.0 / u_gamma));
251
+ result.a *= u_final_alpha_ratio;
252
+ outColor = result;
253
+ }
254
+ `;
255
+ const program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
256
+ const buffer = gl.createBuffer();
257
+ const a_position = gl.getAttribLocation(program, "a_position");
258
+ const vao = gl.createVertexArray();
198
259
  gl.bindVertexArray(vao);
199
260
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
200
261
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
@@ -217,14 +278,72 @@ var TrackGlowLineProgram = /** @class */ (function () {
217
278
  u_gamma: gl.getUniformLocation(program, "u_gamma"),
218
279
  u_final_alpha_ratio: gl.getUniformLocation(program, "u_final_alpha_ratio"),
219
280
  };
220
- };
221
- TrackGlowLineProgram.prototype._createBlurProgram = function () {
222
- var gl = this.gl;
223
- var vertexShader = "#version 300 es\nprecision highp float;\n\nin vec2 a_position;\nout vec2 v_texcoord;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texcoord = a_position.xy * 0.5 + 0.5;\n}";
224
- var fragmentShader = "#version 300 es\nprecision highp float;\n\nin vec2 v_texcoord;\n\nuniform sampler2D u_texture;\nuniform bool u_horizontal;\nuniform float u_weight[5];\nout vec4 outColor;\n\nvoid main()\n{ \n vec2 tex_offset = vec2( \n 1.0 / float(textureSize(u_texture, 0).x),\n 1.0 / float(textureSize(u_texture, 0).y) ); // gets size of single texel\n vec3 color = vec3(0.0);\n float total_alpha = texture(u_texture, v_texcoord).a * u_weight[0]; \n if (total_alpha > 0.0){\n color = texture(u_texture, v_texcoord).rgb;\n }\n vec2 offset = vec2(0.0);\n float alpha;\n\n if(u_horizontal){\n for(int i = 1; i < 5; ++i){\n offset = vec2(tex_offset.x * float(i), 0.0);\n alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];\n color = mix( color, texture(u_texture, v_texcoord + offset).rgb, alpha);\n total_alpha += alpha;\n alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];\n color = mix( color, texture(u_texture, v_texcoord - offset).rgb, alpha);\n total_alpha += alpha;\n }\n }\n else\n {\n for(int i = 1; i < 5; ++i)\n {\n offset = vec2(0.0, tex_offset.y * float(i));\n alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];\n color = mix( color, texture(u_texture, v_texcoord + offset).rgb, alpha);\n total_alpha += alpha;\n alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];\n color = mix( color, texture(u_texture, v_texcoord - offset).rgb, alpha);\n total_alpha += alpha;\n }\n }\n outColor = vec4(color, total_alpha);\n}\n";
225
- var program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
226
- var buffer = gl.createBuffer();
227
- var a_position = gl.getAttribLocation(program, "a_position");
281
+ }
282
+ _createBlurProgram() {
283
+ const gl = this.gl;
284
+ const vertexShader = `#version 300 es
285
+ precision highp float;
286
+
287
+ in vec2 a_position;
288
+ out vec2 v_texcoord;
289
+
290
+ void main() {
291
+ gl_Position = vec4(a_position, 0.0, 1.0);
292
+ v_texcoord = a_position.xy * 0.5 + 0.5;
293
+ }`;
294
+ const fragmentShader = `#version 300 es
295
+ precision highp float;
296
+
297
+ in vec2 v_texcoord;
298
+
299
+ uniform sampler2D u_texture;
300
+ uniform bool u_horizontal;
301
+ uniform float u_weight[5];
302
+ out vec4 outColor;
303
+
304
+ void main()
305
+ {
306
+ vec2 tex_offset = vec2(
307
+ 1.0 / float(textureSize(u_texture, 0).x),
308
+ 1.0 / float(textureSize(u_texture, 0).y) ); // gets size of single texel
309
+ vec3 color = vec3(0.0);
310
+ float total_alpha = texture(u_texture, v_texcoord).a * u_weight[0];
311
+ if (total_alpha > 0.0){
312
+ color = texture(u_texture, v_texcoord).rgb;
313
+ }
314
+ vec2 offset = vec2(0.0);
315
+ float alpha;
316
+
317
+ if(u_horizontal){
318
+ for(int i = 1; i < 5; ++i){
319
+ offset = vec2(tex_offset.x * float(i), 0.0);
320
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
321
+ color = mix( color, texture(u_texture, v_texcoord + offset).rgb, alpha);
322
+ total_alpha += alpha;
323
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
324
+ color = mix( color, texture(u_texture, v_texcoord - offset).rgb, alpha);
325
+ total_alpha += alpha;
326
+ }
327
+ }
328
+ else
329
+ {
330
+ for(int i = 1; i < 5; ++i)
331
+ {
332
+ offset = vec2(0.0, tex_offset.y * float(i));
333
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
334
+ color = mix( color, texture(u_texture, v_texcoord + offset).rgb, alpha);
335
+ total_alpha += alpha;
336
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
337
+ color = mix( color, texture(u_texture, v_texcoord - offset).rgb, alpha);
338
+ total_alpha += alpha;
339
+ }
340
+ }
341
+ outColor = vec4(color, total_alpha);
342
+ }
343
+ `;
344
+ const program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
345
+ const buffer = gl.createBuffer();
346
+ const a_position = gl.getAttribLocation(program, "a_position");
228
347
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
229
348
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
230
349
  -1, -1,
@@ -234,7 +353,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
234
353
  1, 1,
235
354
  -1, 1,
236
355
  ]), gl.STATIC_DRAW);
237
- var vao = gl.createVertexArray();
356
+ const vao = gl.createVertexArray();
238
357
  gl.bindVertexArray(vao);
239
358
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
240
359
  gl.enableVertexAttribArray(a_position);
@@ -247,28 +366,104 @@ var TrackGlowLineProgram = /** @class */ (function () {
247
366
  u_horizontal: gl.getUniformLocation(program, "u_horizontal"),
248
367
  u_weight: gl.getUniformLocation(program, "u_weight"),
249
368
  };
250
- };
251
- TrackGlowLineProgram.prototype.resize = function (width, height) {
252
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
369
+ }
370
+ resize(width, height) {
371
+ const { gl, _lineProgram } = this;
253
372
  this._width = width;
254
373
  this._height = height;
255
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
374
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
256
375
  this._createInnerTextures();
257
376
  gl.useProgram(_lineProgram.program);
258
377
  gl.uniform2fv(_lineProgram.u_scrWH, [width, height]);
259
378
  gl.useProgram(currentProgram);
260
- };
261
- TrackGlowLineProgram.prototype._createLineProgram = function () {
262
- var gl = this.gl;
263
- var vertexShader = "#version 300 es\nprecision highp float;\n\nin vec3 a_position;\nin float a_time;\nin vec3 a_color;\nin float a_track_start_time;\nin float a_track_end_time;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform vec3 uTranslate;\n\nuniform bool u_is_3d;\nuniform vec2 u_mapWH;\nuniform vec2 u_scrWH;\n\nout float v_time;\nout vec3 v_color;\nout float v_track_start_time;\nout float v_track_end_time;\n".concat(util_1.shaderfunctions.pixelXYToCartesian3DPoint, "\n").concat(util_1.shaderfunctions.pixelXYToCartesian2DPoint, "\n \nvoid main() {\n\n v_time = a_time;\n v_color = a_color;\n v_track_start_time = a_track_start_time;\n v_track_end_time = a_track_end_time;\n if (u_is_3d){\n vec3 pos = pixelXYToCartesian3DPoint(a_position);\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(pos - uTranslate, 1.0);\n } else {\n vec2 xy = pixelXYToCartesian2DPoint(a_position.xy, uTranslate.xy, u_mapWH, u_scrWH);\n gl_Position = uProjectionMatrix * vec4(xy.x, xy.y, 0.0, 1.0);\n }\n}\n");
264
- var fragmentShader = "#version 300 es\nprecision lowp float;\n\nin float v_time;\nin vec3 v_color;\nin float v_track_start_time;\nin float v_track_end_time;\nuniform float u_head_time;\nuniform float u_tail_time;\n\nuniform float u_head_percentage;\nuniform float u_route_alpha;\n\nlayout(location = 0) out vec4 outColor0;\nlayout(location = 1) out vec4 outColor1;\n\n\nvoid main() {\n if ( u_tail_time > v_track_end_time || u_head_time < v_track_start_time) discard;\n float gap = u_head_time - u_tail_time;\n float head = gap * u_head_percentage;\n float dist = u_head_time - v_time;\n\n if ((v_time > u_head_time ) || (v_time < u_tail_time) ){ \n outColor0 = vec4(v_color , u_route_alpha);\n return;\n } else if (dist < head) { \n // white head\n outColor1 = vec4(1.0, 1.0, 1.0, 1.0); \n // \n } else {\n // colored body of lines\n float alpha = ((gap - dist) / gap) * 0.4 + 0.6;\n // outColor0 = vec4(v_color , alpha ); \n outColor1 = vec4(v_color , alpha ); \n }\n outColor0 = vec4(v_color , 1.0);\n}\n";
265
- var program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
266
- var a_position = gl.getAttribLocation(program, "a_position");
267
- var a_time = gl.getAttribLocation(program, "a_time");
268
- var a_track_start_time = gl.getAttribLocation(program, "a_track_start_time");
269
- var a_track_end_time = gl.getAttribLocation(program, "a_track_end_time");
270
- var a_color = gl.getAttribLocation(program, "a_color");
271
- var vao = gl.createVertexArray();
379
+ }
380
+ _createLineProgram() {
381
+ const gl = this.gl;
382
+ const vertexShader = `#version 300 es
383
+ precision highp float;
384
+
385
+ in vec3 a_position;
386
+ in float a_time;
387
+ in vec3 a_color;
388
+ in float a_track_start_time;
389
+ in float a_track_end_time;
390
+
391
+ uniform mat4 uModelViewMatrix;
392
+ uniform mat4 uProjectionMatrix;
393
+ uniform vec3 uTranslate;
394
+
395
+ uniform bool u_is_3d;
396
+ uniform vec2 u_mapWH;
397
+ uniform vec2 u_scrWH;
398
+
399
+ out float v_time;
400
+ out vec3 v_color;
401
+ out float v_track_start_time;
402
+ out float v_track_end_time;
403
+ ${util_1.shaderfunctions.pixelXYToCartesian3DPoint}
404
+ ${util_1.shaderfunctions.pixelXYToCartesian2DPoint}
405
+
406
+ void main() {
407
+
408
+ v_time = a_time;
409
+ v_color = a_color;
410
+ v_track_start_time = a_track_start_time;
411
+ v_track_end_time = a_track_end_time;
412
+ if (u_is_3d){
413
+ vec3 pos = pixelXYToCartesian3DPoint(a_position);
414
+ gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(pos - uTranslate, 1.0);
415
+ } else {
416
+ vec2 xy = pixelXYToCartesian2DPoint(a_position.xy, uTranslate.xy, u_mapWH, u_scrWH);
417
+ gl_Position = uProjectionMatrix * vec4(xy.x, xy.y, 0.0, 1.0);
418
+ }
419
+ }
420
+ `;
421
+ const fragmentShader = `#version 300 es
422
+ precision lowp float;
423
+
424
+ in float v_time;
425
+ in vec3 v_color;
426
+ in float v_track_start_time;
427
+ in float v_track_end_time;
428
+ uniform float u_head_time;
429
+ uniform float u_tail_time;
430
+
431
+ uniform float u_head_percentage;
432
+ uniform float u_route_alpha;
433
+
434
+ layout(location = 0) out vec4 outColor0;
435
+ layout(location = 1) out vec4 outColor1;
436
+
437
+
438
+ void main() {
439
+ if ( u_tail_time > v_track_end_time || u_head_time < v_track_start_time) discard;
440
+ float gap = u_head_time - u_tail_time;
441
+ float head = gap * u_head_percentage;
442
+ float dist = u_head_time - v_time;
443
+
444
+ if ((v_time > u_head_time ) || (v_time < u_tail_time) ){
445
+ outColor0 = vec4(v_color , u_route_alpha);
446
+ return;
447
+ } else if (dist < head) {
448
+ // white head
449
+ outColor1 = vec4(1.0, 1.0, 1.0, 1.0);
450
+ //
451
+ } else {
452
+ // colored body of lines
453
+ float alpha = ((gap - dist) / gap) * 0.4 + 0.6;
454
+ // outColor0 = vec4(v_color , alpha );
455
+ outColor1 = vec4(v_color , alpha );
456
+ }
457
+ outColor0 = vec4(v_color , 1.0);
458
+ }
459
+ `;
460
+ const program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
461
+ const a_position = gl.getAttribLocation(program, "a_position");
462
+ const a_time = gl.getAttribLocation(program, "a_time");
463
+ const a_track_start_time = gl.getAttribLocation(program, "a_track_start_time");
464
+ const a_track_end_time = gl.getAttribLocation(program, "a_track_end_time");
465
+ const a_color = gl.getAttribLocation(program, "a_color");
466
+ const vao = gl.createVertexArray();
272
467
  gl.bindVertexArray(vao);
273
468
  gl.bindBuffer(gl.ARRAY_BUFFER, this._inBuffer);
274
469
  gl.enableVertexAttribArray(a_position);
@@ -296,7 +491,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
296
491
  u_head_percentage: gl.getUniformLocation(program, "u_head_percentage"),
297
492
  u_route_alpha: gl.getUniformLocation(program, "u_route_alpha"),
298
493
  };
299
- };
494
+ }
300
495
  /**
301
496
  * @param { Float32Array} data // [x, y, z, time, x, y, z, time, ...]
302
497
  */
@@ -305,19 +500,19 @@ var TrackGlowLineProgram = /** @class */ (function () {
305
500
  // gl.bindBuffer(gl.ARRAY_BUFFER, this._inBuffer);
306
501
  // gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
307
502
  // }
308
- TrackGlowLineProgram.prototype.setIs3D = function (is3d) {
309
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
310
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
503
+ setIs3D(is3d) {
504
+ const { gl, _lineProgram } = this;
505
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
311
506
  gl.useProgram(_lineProgram.program);
312
507
  gl.uniform1i(_lineProgram.u_is_3d, is3d);
313
508
  gl.useProgram(currentProgram);
314
- };
315
- TrackGlowLineProgram.prototype.setTotalLength = function (totalLength) {
509
+ }
510
+ setTotalLength(totalLength) {
316
511
  this._totalLength = totalLength;
317
- };
318
- TrackGlowLineProgram.prototype._createTextures = function () {
319
- var _a = this, gl = _a.gl, _width = _a._width, _height = _a._height;
320
- var texture = gl.createTexture();
512
+ }
513
+ _createTextures() {
514
+ const { gl, _width, _height } = this;
515
+ const texture = gl.createTexture();
321
516
  gl.bindTexture(gl.TEXTURE_2D, texture);
322
517
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); // UNSIGNED_BYTE
323
518
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
@@ -326,9 +521,9 @@ var TrackGlowLineProgram = /** @class */ (function () {
326
521
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
327
522
  gl.bindTexture(gl.TEXTURE_2D, null);
328
523
  return texture;
329
- };
330
- TrackGlowLineProgram.prototype._resetTexture = function () {
331
- var _a = this, gl = _a.gl, _width = _a._width, _height = _a._height;
524
+ }
525
+ _resetTexture() {
526
+ const { gl, _width, _height } = this;
332
527
  gl.bindTexture(gl.TEXTURE_2D, this._middleTexture); // UNSIGNED_BYTE
333
528
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
334
529
  gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[0]);
@@ -336,10 +531,9 @@ var TrackGlowLineProgram = /** @class */ (function () {
336
531
  gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[1]);
337
532
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
338
533
  gl.bindTexture(gl.TEXTURE_2D, null);
339
- };
340
- TrackGlowLineProgram.prototype.draw = function (u_head_time, u_tail_time, uProjectionMatrix, uModelViewMatrix, uTranslate, u_mapWH) {
341
- if (u_mapWH === void 0) { u_mapWH = null; }
342
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram, _blurProgram = _a._blurProgram, _blurRepetition = _a._blurRepetition;
534
+ }
535
+ draw(u_head_time, u_tail_time, uProjectionMatrix, uModelViewMatrix, uTranslate, u_mapWH = null) {
536
+ const { gl, _lineProgram, _blurProgram, _blurRepetition } = this;
343
537
  this._resetTexture();
344
538
  gl.enable(gl.BLEND);
345
539
  gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
@@ -372,7 +566,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
372
566
  { // blur ping pong
373
567
  gl.useProgram(_blurProgram.program);
374
568
  gl.bindVertexArray(_blurProgram.vao);
375
- for (var i = 0; i < _blurRepetition * 2; i++) {
569
+ for (let i = 0; i < _blurRepetition * 2; i++) {
376
570
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._blurFrameBuffers[i % 2]);
377
571
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._blurTextures[(i + 1) % 2], 0);
378
572
  gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[i % 2]);
@@ -395,9 +589,9 @@ var TrackGlowLineProgram = /** @class */ (function () {
395
589
  }
396
590
  gl.bindVertexArray(null);
397
591
  (0, util_1.defaultblendfunction)(gl);
398
- };
399
- TrackGlowLineProgram.prototype.free = function () {
400
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram, _blurProgram = _a._blurProgram, _combineProgram = _a._combineProgram;
592
+ }
593
+ free() {
594
+ const { gl, _lineProgram, _blurProgram, _combineProgram } = this;
401
595
  gl.deleteBuffer(this._inBuffer);
402
596
  gl.deleteFramebuffer(this._frameBuffer);
403
597
  gl.deleteFramebuffer(this._blurFrameBuffers[0]);
@@ -412,7 +606,6 @@ var TrackGlowLineProgram = /** @class */ (function () {
412
606
  gl.deleteProgram(_lineProgram.program);
413
607
  gl.deleteProgram(_blurProgram.program);
414
608
  gl.deleteProgram(_combineProgram.program);
415
- };
416
- return TrackGlowLineProgram;
417
- }());
609
+ }
610
+ }
418
611
  exports.default = TrackGlowLineProgram;