@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._premultipliedAlpha = false;
@@ -39,14 +38,13 @@ var TrackGlowLineProgram = /** @class */ (function () {
39
38
  this._totalLength = 0;
40
39
  this._initUniforms(options);
41
40
  }
42
- TrackGlowLineProgram.prototype._createInnerTextures = function () {
41
+ _createInnerTextures() {
43
42
  this._middleTexture = this._createTextures();
44
43
  this._blurTextures = [this._createTextures(), this._createTextures()];
45
- };
46
- TrackGlowLineProgram.prototype._initUniforms = function (options) {
47
- if (options === void 0) { options = {}; }
48
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram, _blurProgram = _a._blurProgram, _combineProgram = _a._combineProgram;
49
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
44
+ }
45
+ _initUniforms(options = {}) {
46
+ const { gl, _lineProgram, _blurProgram, _combineProgram } = this;
47
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
50
48
  gl.useProgram(_lineProgram.program);
51
49
  gl.uniform1f(_lineProgram.u_head_percentage, options.headPercentage || 1.0 / 30.0);
52
50
  gl.uniform1f(_lineProgram.u_route_alpha, options.routeAlpha || 0.025);
@@ -59,150 +57,187 @@ var TrackGlowLineProgram = /** @class */ (function () {
59
57
  gl.uniform1f(_combineProgram.u_gamma, options.gamma || 1.0);
60
58
  gl.uniform1f(_combineProgram.u_final_alpha_ratio, options.finalAlphaRatio || 1.0);
61
59
  gl.useProgram(currentProgram);
62
- };
63
- TrackGlowLineProgram.prototype.setPremultipliedAlpha = function (boolean) {
60
+ }
61
+ setPremultipliedAlpha(boolean) {
64
62
  if (typeof boolean !== 'boolean') {
65
63
  console.warn("boolean should be a boolean value, but got", boolean);
66
64
  return;
67
65
  }
68
66
  this._premultipliedAlpha = boolean;
69
- };
67
+ }
70
68
  /**
71
69
  * @param {number} alpha 0 ~ 1
72
70
  * @returns
73
71
  */
74
- TrackGlowLineProgram.prototype.setAlphaThreshold = function (alpha) {
72
+ setAlphaThreshold(alpha) {
75
73
  if (alpha < 0 || alpha > 1) {
76
74
  console.warn("alpha should be between 0 and 1, but got", alpha);
77
75
  return;
78
76
  }
79
- var _a = this, gl = _a.gl, _blurProgram = _a._blurProgram;
80
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
77
+ const { gl, _blurProgram } = this;
78
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
81
79
  gl.useProgram(_blurProgram.program);
82
80
  gl.uniform1f(_blurProgram.u_alpha_threshold, alpha);
83
81
  gl.useProgram(currentProgram);
84
- };
82
+ }
85
83
  /**
86
84
  * @param {number} gamma 0 ~ inf
87
85
  */
88
- TrackGlowLineProgram.prototype.setGamma = function (gamma) {
86
+ setGamma(gamma) {
89
87
  if (gamma < 0) {
90
88
  console.warn("gamma should be equal or greater than 0, but got", gamma);
91
89
  return;
92
90
  }
93
- var _a = this, gl = _a.gl, _combineProgram = _a._combineProgram;
94
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
91
+ const { gl, _combineProgram } = this;
92
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
95
93
  gl.useProgram(_combineProgram.program);
96
94
  gl.uniform1f(_combineProgram.u_gamma, gamma);
97
95
  gl.useProgram(currentProgram);
98
- };
96
+ }
99
97
  /**
100
98
  *
101
99
  * @param {number} exposure 0 ~ inf
102
100
  * @returns
103
101
  */
104
- TrackGlowLineProgram.prototype.setExposure = function (exposure) {
102
+ setExposure(exposure) {
105
103
  if (exposure < 0) {
106
104
  console.warn("exposure should be equal or greater than 0, but got", exposure);
107
105
  return;
108
106
  }
109
- var _a = this, gl = _a.gl, _combineProgram = _a._combineProgram;
110
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
107
+ const { gl, _combineProgram } = this;
108
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
111
109
  gl.useProgram(_combineProgram.program);
112
110
  gl.uniform1f(_combineProgram.u_exposure, exposure);
113
111
  gl.useProgram(currentProgram);
114
- };
112
+ }
115
113
  /**
116
114
  *
117
115
  * @param {number} ratio 0 ~ 1
118
116
  * @returns
119
117
  */
120
- TrackGlowLineProgram.prototype.setFinalAlphaRatio = function (ratio) {
118
+ setFinalAlphaRatio(ratio) {
121
119
  if (ratio < 0 || ratio > 1) {
122
120
  console.warn("ratio should be between 0 and 1, but got", ratio);
123
121
  return;
124
122
  }
125
- var _a = this, gl = _a.gl, _combineProgram = _a._combineProgram;
126
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
123
+ const { gl, _combineProgram } = this;
124
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
127
125
  gl.useProgram(_combineProgram.program);
128
126
  gl.uniform1f(_combineProgram.u_final_alpha_ratio, ratio);
129
127
  gl.useProgram(currentProgram);
130
- };
128
+ }
131
129
  /**
132
130
  * @param {Array.<Number>} weight [w1, w2, w3, w4, w5]
133
131
  */
134
- TrackGlowLineProgram.prototype.setBlurWeights = function (weights) {
132
+ setBlurWeights(weights) {
135
133
  if (weights.length !== 5) {
136
134
  console.warn("weights should be an array of 5 numbers, but got", weights);
137
135
  return;
138
136
  }
139
- var _a = this, gl = _a.gl, _blurProgram = _a._blurProgram;
140
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
137
+ const { gl, _blurProgram } = this;
138
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
141
139
  gl.useProgram(_blurProgram.program);
142
140
  gl.uniform1fv(_blurProgram.u_weight, weights);
143
141
  gl.useProgram(currentProgram);
144
- };
142
+ }
145
143
  /**
146
144
  * @param {number} routeAlpha 0 ~ 1
147
145
  */
148
- TrackGlowLineProgram.prototype.setRouteAlpha = function (routeAlpha) {
146
+ setRouteAlpha(routeAlpha) {
149
147
  if (routeAlpha < 0 || routeAlpha > 1) {
150
148
  console.warn("routeAlpha should be between 0 and 1, but got", routeAlpha);
151
149
  return;
152
150
  }
153
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
154
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
151
+ const { gl, _lineProgram } = this;
152
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
155
153
  gl.useProgram(_lineProgram.program);
156
154
  gl.uniform1f(_lineProgram.u_route_alpha, routeAlpha);
157
155
  gl.useProgram(currentProgram);
158
- };
159
- TrackGlowLineProgram.prototype.setGlow = function (boolean) {
156
+ }
157
+ setGlow(boolean) {
160
158
  if (typeof boolean !== 'boolean') {
161
159
  console.warn("boolean should be a boolean value, but got", boolean);
162
160
  return;
163
161
  }
164
- var _a = this, gl = _a.gl, _blurProgram = _a._blurProgram;
165
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
162
+ const { gl, _blurProgram } = this;
163
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
166
164
  gl.useProgram(_blurProgram.program);
167
165
  gl.uniform1i(_blurProgram.u_glow, boolean);
168
166
  gl.useProgram(currentProgram);
169
- };
167
+ }
170
168
  /**
171
169
  * blur uses pingpong effect. This number decides how many times the blur will be applied.
172
170
  * @param {+int} repetition
173
171
  * @returns
174
172
  */
175
- TrackGlowLineProgram.prototype.setBlurRepetition = function (repetition) {
173
+ setBlurRepetition(repetition) {
176
174
  if (repetition < 0 && repetition % 1 !== 0) {
177
175
  console.warn("repetition should be an integer greater than 0, but got", repetition);
178
176
  return;
179
177
  }
180
178
  this._blurRepetition = repetition;
181
- };
179
+ }
182
180
  /**
183
181
  * Head Is colored as white. This number decides proportion of the head according to the total length of the line.
184
182
  * @param {Number} percentage 0 ~ 1
185
183
  */
186
- TrackGlowLineProgram.prototype.setHeadPercentage = function (percentage) {
184
+ setHeadPercentage(percentage) {
187
185
  if (percentage < 0 || 1 < percentage) {
188
186
  console.warn("percentage should be between 0 and 1, but got", percentage);
189
187
  return;
190
188
  }
191
189
  ;
192
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
193
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
190
+ const { gl, _lineProgram } = this;
191
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
194
192
  gl.useProgram(_lineProgram.program);
195
193
  gl.uniform1f(_lineProgram.u_head_percentage, percentage);
196
194
  gl.useProgram(currentProgram);
197
- };
198
- TrackGlowLineProgram.prototype._createCombineProgram = function () {
199
- var gl = this.gl;
200
- var vertexShader = "#version 300 es\n precision lowp float;\n\n in vec2 a_position;\n\n out vec2 v_texcoord;\n\n void main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texcoord = a_position.xy * 0.5 + 0.5;\n }\n ";
201
- var fragmentShader = "#version 300 es\n precision lowp float;\n\n in vec2 v_texcoord;\n\n uniform sampler2D u_main_texture;\n uniform sampler2D u_bloom_texture;\n\n uniform float u_exposure;\n uniform float u_gamma;\n uniform float u_final_alpha_ratio;\n\n out vec4 outColor;\n\n void main() {\n vec4 hdrColor = texture(u_main_texture, v_texcoord); \n vec4 bloomColor = texture(u_bloom_texture, v_texcoord);\n vec4 result;\n if (bloomColor.a > 0.09){\n result = bloomColor * u_exposure;\n } else {\n result = hdrColor + bloomColor * u_exposure;\n }\n result = pow(result, vec4(1.0 / u_gamma));\n outColor = vec4(result.rgb, result.a * u_final_alpha_ratio);\n }\n ";
202
- var program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
203
- var buffer = gl.createBuffer();
204
- var a_position = gl.getAttribLocation(program, "a_position");
205
- var vao = gl.createVertexArray();
195
+ }
196
+ _createCombineProgram() {
197
+ const gl = this.gl;
198
+ const vertexShader = `#version 300 es
199
+ precision lowp float;
200
+
201
+ in vec2 a_position;
202
+
203
+ out vec2 v_texcoord;
204
+
205
+ void main() {
206
+ gl_Position = vec4(a_position, 0.0, 1.0);
207
+ v_texcoord = a_position.xy * 0.5 + 0.5;
208
+ }
209
+ `;
210
+ const fragmentShader = `#version 300 es
211
+ precision lowp float;
212
+
213
+ in vec2 v_texcoord;
214
+
215
+ uniform sampler2D u_main_texture;
216
+ uniform sampler2D u_bloom_texture;
217
+
218
+ uniform float u_exposure;
219
+ uniform float u_gamma;
220
+ uniform float u_final_alpha_ratio;
221
+
222
+ out vec4 outColor;
223
+
224
+ void main() {
225
+ vec4 hdrColor = texture(u_main_texture, v_texcoord);
226
+ vec4 bloomColor = texture(u_bloom_texture, v_texcoord);
227
+ vec4 result;
228
+ if (bloomColor.a > 0.09){
229
+ result = bloomColor * u_exposure;
230
+ } else {
231
+ result = hdrColor + bloomColor * u_exposure;
232
+ }
233
+ result = pow(result, vec4(1.0 / u_gamma));
234
+ outColor = vec4(result.rgb, result.a * u_final_alpha_ratio);
235
+ }
236
+ `;
237
+ const program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
238
+ const buffer = gl.createBuffer();
239
+ const a_position = gl.getAttribLocation(program, "a_position");
240
+ const vao = gl.createVertexArray();
206
241
  gl.bindVertexArray(vao);
207
242
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
208
243
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
@@ -225,14 +260,137 @@ var TrackGlowLineProgram = /** @class */ (function () {
225
260
  u_gamma: gl.getUniformLocation(program, "u_gamma"),
226
261
  u_final_alpha_ratio: gl.getUniformLocation(program, "u_final_alpha_ratio"),
227
262
  };
228
- };
229
- TrackGlowLineProgram.prototype._createBlurProgram = function () {
230
- var gl = this.gl;
231
- 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}\n";
232
- 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];\nuniform float u_alpha_threshold;\nuniform bool u_glow;\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 float color_count = 0.0;\n if (!u_glow){\n if(u_horizontal){\n for(int i = 1; i < 5; ++i)\n {\n offset = vec2(tex_offset.x * float(i), 0.0);\n alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];\n\n if (alpha > u_alpha_threshold){\n // color = max( color, texture(u_texture, v_texcoord + offset).rgb);\n color += texture(u_texture, v_texcoord + offset).rgb;\n total_alpha += alpha;\n color_count += 1.0;\n }\n alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];\n if (alpha > u_alpha_threshold){\n // color = max( color, texture(u_texture, v_texcoord - offset).rgb);\n color += texture(u_texture, v_texcoord - offset).rgb ;\n total_alpha += alpha;\n color_count += 1.0;\n\n }\n }\n} else {\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 if (alpha > u_alpha_threshold){\n // color = max( color , texture(u_texture, v_texcoord + offset).rgb);\n color += texture(u_texture, v_texcoord + offset).rgb;\n total_alpha += alpha;\n color_count += 1.0;\n\n }\n alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];\n if (alpha > u_alpha_threshold){\n // color = max( color, texture(u_texture, v_texcoord - offset).rgb );\n color += texture(u_texture, v_texcoord - offset).rgb ;\n total_alpha += alpha;\n color_count += 1.0;\n\n }\n }\n\n }\n if (color_count > 0.0){\n color /= color_count;\n }\n } else {\n if(u_horizontal)\n {\n for(int i = 1; i < 5; ++i)\n {\n offset = vec2(tex_offset.x * float(i), 0.0);\n alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];\n\n if (alpha > u_alpha_threshold){\n color = max( color, texture(u_texture, v_texcoord + offset).rgb);\n total_alpha += alpha;\n }\n alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];\n if (alpha > u_alpha_threshold){\n color = max( color, texture(u_texture, v_texcoord - offset).rgb);\n\n total_alpha += alpha;\n }\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 if (alpha > u_alpha_threshold){\n color = max( color, texture(u_texture, v_texcoord + offset).rgb);\n total_alpha += alpha;\n }\n alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];\n if (alpha > u_alpha_threshold){\n color = max( color, texture(u_texture, v_texcoord - offset).rgb );\n total_alpha += alpha;\n }\n }\n }\n }\n outColor = vec4(color, total_alpha);\n}\n";
233
- var program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
234
- var buffer = gl.createBuffer();
235
- var a_position = gl.getAttribLocation(program, "a_position");
263
+ }
264
+ _createBlurProgram() {
265
+ const gl = this.gl;
266
+ const vertexShader = `#version 300 es
267
+ precision highp float;
268
+
269
+ in vec2 a_position;
270
+ out vec2 v_texcoord;
271
+
272
+ void main() {
273
+ gl_Position = vec4(a_position, 0.0, 1.0);
274
+ v_texcoord = a_position.xy * 0.5 + 0.5;
275
+ }
276
+ `;
277
+ const fragmentShader = `#version 300 es
278
+ precision highp float;
279
+
280
+ in vec2 v_texcoord;
281
+
282
+ uniform sampler2D u_texture;
283
+ uniform bool u_horizontal;
284
+ uniform float u_weight[5];
285
+ uniform float u_alpha_threshold;
286
+ uniform bool u_glow;
287
+ out vec4 outColor;
288
+
289
+ void main()
290
+ {
291
+ vec2 tex_offset = vec2(
292
+ 1.0 / float(textureSize(u_texture, 0).x),
293
+ 1.0 / float(textureSize(u_texture, 0).y) ); // gets size of single texel
294
+ vec3 color = vec3(0.0);
295
+ float total_alpha = texture(u_texture, v_texcoord).a * u_weight[0];
296
+ if (total_alpha > 0.0){
297
+ color = texture(u_texture, v_texcoord).rgb;
298
+ }
299
+ vec2 offset = vec2(0.0);
300
+ float alpha;
301
+ float color_count = 0.0;
302
+ if (!u_glow){
303
+ if(u_horizontal){
304
+ for(int i = 1; i < 5; ++i)
305
+ {
306
+ offset = vec2(tex_offset.x * float(i), 0.0);
307
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
308
+
309
+ if (alpha > u_alpha_threshold){
310
+ // color = max( color, texture(u_texture, v_texcoord + offset).rgb);
311
+ color += texture(u_texture, v_texcoord + offset).rgb;
312
+ total_alpha += alpha;
313
+ color_count += 1.0;
314
+ }
315
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
316
+ if (alpha > u_alpha_threshold){
317
+ // color = max( color, texture(u_texture, v_texcoord - offset).rgb);
318
+ color += texture(u_texture, v_texcoord - offset).rgb ;
319
+ total_alpha += alpha;
320
+ color_count += 1.0;
321
+
322
+ }
323
+ }
324
+ } else {
325
+ for(int i = 1; i < 5; ++i)
326
+ {
327
+ offset = vec2(0.0, tex_offset.y * float(i));
328
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
329
+ if (alpha > u_alpha_threshold){
330
+ // color = max( color , texture(u_texture, v_texcoord + offset).rgb);
331
+ color += texture(u_texture, v_texcoord + offset).rgb;
332
+ total_alpha += alpha;
333
+ color_count += 1.0;
334
+
335
+ }
336
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
337
+ if (alpha > u_alpha_threshold){
338
+ // color = max( color, texture(u_texture, v_texcoord - offset).rgb );
339
+ color += texture(u_texture, v_texcoord - offset).rgb ;
340
+ total_alpha += alpha;
341
+ color_count += 1.0;
342
+
343
+ }
344
+ }
345
+
346
+ }
347
+ if (color_count > 0.0){
348
+ color /= color_count;
349
+ }
350
+ } else {
351
+ if(u_horizontal)
352
+ {
353
+ for(int i = 1; i < 5; ++i)
354
+ {
355
+ offset = vec2(tex_offset.x * float(i), 0.0);
356
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
357
+
358
+ if (alpha > u_alpha_threshold){
359
+ color = max( color, texture(u_texture, v_texcoord + offset).rgb);
360
+ total_alpha += alpha;
361
+ }
362
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
363
+ if (alpha > u_alpha_threshold){
364
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb);
365
+
366
+ total_alpha += alpha;
367
+ }
368
+ }
369
+ }
370
+ else
371
+ {
372
+ for(int i = 1; i < 5; ++i)
373
+ {
374
+ offset = vec2(0.0, tex_offset.y * float(i));
375
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
376
+ if (alpha > u_alpha_threshold){
377
+ color = max( color, texture(u_texture, v_texcoord + offset).rgb);
378
+ total_alpha += alpha;
379
+ }
380
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
381
+ if (alpha > u_alpha_threshold){
382
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb );
383
+ total_alpha += alpha;
384
+ }
385
+ }
386
+ }
387
+ }
388
+ outColor = vec4(color, total_alpha);
389
+ }
390
+ `;
391
+ const program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
392
+ const buffer = gl.createBuffer();
393
+ const a_position = gl.getAttribLocation(program, "a_position");
236
394
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
237
395
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
238
396
  -1, -1,
@@ -242,7 +400,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
242
400
  1, 1,
243
401
  -1, 1,
244
402
  ]), gl.STATIC_DRAW);
245
- var vao = gl.createVertexArray();
403
+ const vao = gl.createVertexArray();
246
404
  gl.bindVertexArray(vao);
247
405
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
248
406
  gl.enableVertexAttribArray(a_position);
@@ -257,14 +415,84 @@ var TrackGlowLineProgram = /** @class */ (function () {
257
415
  u_alpha_threshold: gl.getUniformLocation(program, "u_alpha_threshold"),
258
416
  u_glow: gl.getUniformLocation(program, "u_glow"),
259
417
  };
260
- };
261
- TrackGlowLineProgram.prototype._createBlurProgramHOLD = function () {
262
- var gl = this.gl;
263
- 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}\n";
264
- 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];\nuniform float u_alpha_threshold;\n\nout vec4 outColor;\n\nvoid main()\n{ \n vec2 tex_offset = vec2(1) / vec2(textureSize(u_texture, 0)); // 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 {\n for(int i = 1; i < 5; ++i)\n {\n offset = vec2(tex_offset.x * float(i), 0.0);\n alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];\n\n if (alpha > u_alpha_threshold){\n color = max( color, texture(u_texture, v_texcoord + offset).rgb);\n total_alpha += alpha;\n }\n alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];\n if (alpha > u_alpha_threshold){\n color = max( color, texture(u_texture, v_texcoord - offset).rgb);\n total_alpha += alpha;\n }\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 if (alpha > u_alpha_threshold){\n color = max( color , texture(u_texture, v_texcoord + offset).rgb);\n total_alpha += alpha;\n }\n alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];\n if (alpha > u_alpha_threshold){\n color = max( color, texture(u_texture, v_texcoord - offset).rgb );\n total_alpha += alpha;\n }\n }\n }\n outColor = vec4(color, total_alpha);\n}\n";
265
- var program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
266
- var buffer = gl.createBuffer();
267
- var a_position = gl.getAttribLocation(program, "a_position");
418
+ }
419
+ _createBlurProgramHOLD() {
420
+ const gl = this.gl;
421
+ const vertexShader = `#version 300 es
422
+ precision highp float;
423
+
424
+ in vec2 a_position;
425
+ out vec2 v_texcoord;
426
+
427
+ void main() {
428
+ gl_Position = vec4(a_position, 0.0, 1.0);
429
+ v_texcoord = a_position.xy * 0.5 + 0.5;
430
+ }
431
+ `;
432
+ const fragmentShader = `#version 300 es
433
+ precision highp float;
434
+
435
+ in vec2 v_texcoord;
436
+
437
+ uniform sampler2D u_texture;
438
+ uniform bool u_horizontal;
439
+ uniform float u_weight[5];
440
+ uniform float u_alpha_threshold;
441
+
442
+ out vec4 outColor;
443
+
444
+ void main()
445
+ {
446
+ vec2 tex_offset = vec2(1) / vec2(textureSize(u_texture, 0)); // gets size of single texel
447
+ vec3 color = vec3(0.0);
448
+ float total_alpha = texture(u_texture, v_texcoord).a * u_weight[0];
449
+ if (total_alpha > 0.0){
450
+ color = texture(u_texture, v_texcoord).rgb;
451
+ }
452
+ vec2 offset = vec2(0.0);
453
+ float alpha;
454
+
455
+ if(u_horizontal)
456
+ {
457
+ for(int i = 1; i < 5; ++i)
458
+ {
459
+ offset = vec2(tex_offset.x * float(i), 0.0);
460
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
461
+
462
+ if (alpha > u_alpha_threshold){
463
+ color = max( color, texture(u_texture, v_texcoord + offset).rgb);
464
+ total_alpha += alpha;
465
+ }
466
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
467
+ if (alpha > u_alpha_threshold){
468
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb);
469
+ total_alpha += alpha;
470
+ }
471
+ }
472
+ }
473
+ else
474
+ {
475
+ for(int i = 1; i < 5; ++i)
476
+ {
477
+ offset = vec2(0.0, tex_offset.y * float(i));
478
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
479
+ if (alpha > u_alpha_threshold){
480
+ color = max( color , texture(u_texture, v_texcoord + offset).rgb);
481
+ total_alpha += alpha;
482
+ }
483
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
484
+ if (alpha > u_alpha_threshold){
485
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb );
486
+ total_alpha += alpha;
487
+ }
488
+ }
489
+ }
490
+ outColor = vec4(color, total_alpha);
491
+ }
492
+ `;
493
+ const program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
494
+ const buffer = gl.createBuffer();
495
+ const a_position = gl.getAttribLocation(program, "a_position");
268
496
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
269
497
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
270
498
  -1, -1,
@@ -274,7 +502,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
274
502
  1, 1,
275
503
  -1, 1,
276
504
  ]), gl.STATIC_DRAW);
277
- var vao = gl.createVertexArray();
505
+ const vao = gl.createVertexArray();
278
506
  gl.bindVertexArray(vao);
279
507
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
280
508
  gl.enableVertexAttribArray(a_position);
@@ -288,28 +516,108 @@ var TrackGlowLineProgram = /** @class */ (function () {
288
516
  u_weight: gl.getUniformLocation(program, "u_weight"),
289
517
  u_alpha_threshold: gl.getUniformLocation(program, "u_alpha_threshold"),
290
518
  };
291
- };
292
- TrackGlowLineProgram.prototype.resize = function (width, height) {
293
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
519
+ }
520
+ resize(width, height) {
521
+ const { gl, _lineProgram } = this;
294
522
  this._width = width;
295
523
  this._height = height;
296
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
524
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
297
525
  this._createInnerTextures();
298
526
  gl.useProgram(_lineProgram.program);
299
527
  gl.uniform2fv(_lineProgram.u_scrWH, [width, height]);
300
528
  gl.useProgram(currentProgram);
301
- };
302
- TrackGlowLineProgram.prototype._createLineProgram = function () {
303
- var gl = this.gl;
304
- 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\n".concat(util_1.shaderfunctions.pixelXYToCartesian3DPoint, "\n").concat(util_1.shaderfunctions.pixelXYToCartesian2DPoint, "\n \nvoid main() {\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 gl_PointSize = 1.0;\n}\n");
305
- 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;\n\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 // if ( v_time < u_tail_time || v_time > u_head_time) discard;\n\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 if ((v_time > u_head_time ) || (v_time < u_tail_time) ){ \n \n outColor0 = vec4(v_color , u_route_alpha); \n } else if (dist < head) {\n // white head\n outColor0 = vec4(1.0, 1.0, 1.0, 0.77 + ( u_route_alpha * 0.23)); \n outColor1 = vec4(1.0, 1.0, 1.0, 0.77 + ( u_route_alpha * 0.23)); \n // \n } else {\n // colored body of lines\n float alpha = ((gap - dist) / gap) / 2.0 + 0.5;\n outColor0 = vec4(v_color , alpha ); \n outColor1 = vec4(v_color , alpha ); \n }\n}\n";
306
- var program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
307
- var a_position = gl.getAttribLocation(program, "a_position");
308
- var a_time = gl.getAttribLocation(program, "a_time");
309
- var a_track_start_time = gl.getAttribLocation(program, "a_track_start_time");
310
- var a_track_end_time = gl.getAttribLocation(program, "a_track_end_time");
311
- var a_color = gl.getAttribLocation(program, "a_color");
312
- var vao = gl.createVertexArray();
529
+ }
530
+ _createLineProgram() {
531
+ const gl = this.gl;
532
+ const vertexShader = `#version 300 es
533
+ precision highp float;
534
+
535
+ in vec3 a_position;
536
+ in float a_time;
537
+ in vec3 a_color;
538
+ in float a_track_start_time;
539
+ in float a_track_end_time;
540
+
541
+ uniform mat4 uModelViewMatrix;
542
+ uniform mat4 uProjectionMatrix;
543
+ uniform vec3 uTranslate;
544
+
545
+ uniform bool u_is_3d;
546
+ uniform vec2 u_mapWH;
547
+ uniform vec2 u_scrWH;
548
+
549
+ out float v_time;
550
+ out vec3 v_color;
551
+ out float v_track_start_time;
552
+ out float v_track_end_time;
553
+
554
+ ${util_1.shaderfunctions.pixelXYToCartesian3DPoint}
555
+ ${util_1.shaderfunctions.pixelXYToCartesian2DPoint}
556
+
557
+ void main() {
558
+ v_time = a_time;
559
+ v_color = a_color;
560
+ v_track_start_time = a_track_start_time;
561
+ v_track_end_time = a_track_end_time;
562
+ if (u_is_3d){
563
+ vec3 pos = pixelXYToCartesian3DPoint(a_position);
564
+ gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(pos - uTranslate, 1.0);
565
+ } else {
566
+ vec2 xy = pixelXYToCartesian2DPoint(a_position.xy, uTranslate.xy, u_mapWH, u_scrWH);
567
+ gl_Position = uProjectionMatrix * vec4(xy.x, xy.y, 0.0, 1.0);
568
+
569
+ }
570
+ gl_PointSize = 1.0;
571
+ }
572
+ `;
573
+ const fragmentShader = `#version 300 es
574
+ precision lowp float;
575
+
576
+ in float v_time;
577
+ in vec3 v_color;
578
+ in float v_track_start_time;
579
+ in float v_track_end_time;
580
+
581
+ uniform float u_head_time;
582
+ uniform float u_tail_time;
583
+
584
+ uniform float u_head_percentage;
585
+ uniform float u_route_alpha;
586
+
587
+ layout(location = 0) out vec4 outColor0;
588
+ layout(location = 1) out vec4 outColor1;
589
+
590
+
591
+ void main() {
592
+ if ( u_tail_time > v_track_end_time || u_head_time < v_track_start_time) discard;
593
+ // if ( v_time < u_tail_time || v_time > u_head_time) discard;
594
+
595
+ float gap = u_head_time - u_tail_time;
596
+ float head = gap * u_head_percentage;
597
+ float dist = u_head_time - v_time;
598
+ if ((v_time > u_head_time ) || (v_time < u_tail_time) ){
599
+
600
+ outColor0 = vec4(v_color , u_route_alpha);
601
+ } else if (dist < head) {
602
+ // white head
603
+ outColor0 = vec4(1.0, 1.0, 1.0, 0.77 + ( u_route_alpha * 0.23));
604
+ outColor1 = vec4(1.0, 1.0, 1.0, 0.77 + ( u_route_alpha * 0.23));
605
+ //
606
+ } else {
607
+ // colored body of lines
608
+ float alpha = ((gap - dist) / gap) / 2.0 + 0.5;
609
+ outColor0 = vec4(v_color , alpha );
610
+ outColor1 = vec4(v_color , alpha );
611
+ }
612
+ }
613
+ `;
614
+ const program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
615
+ const a_position = gl.getAttribLocation(program, "a_position");
616
+ const a_time = gl.getAttribLocation(program, "a_time");
617
+ const a_track_start_time = gl.getAttribLocation(program, "a_track_start_time");
618
+ const a_track_end_time = gl.getAttribLocation(program, "a_track_end_time");
619
+ const a_color = gl.getAttribLocation(program, "a_color");
620
+ const vao = gl.createVertexArray();
313
621
  gl.bindVertexArray(vao);
314
622
  gl.bindBuffer(gl.ARRAY_BUFFER, this._inBuffer);
315
623
  gl.enableVertexAttribArray(a_position);
@@ -337,7 +645,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
337
645
  u_head_percentage: gl.getUniformLocation(program, "u_head_percentage"),
338
646
  u_route_alpha: gl.getUniformLocation(program, "u_route_alpha"),
339
647
  };
340
- };
648
+ }
341
649
  /**
342
650
  * @param { Float32Array} data // [x, y, z, time, x, y, z, time, ...]
343
651
  */
@@ -346,19 +654,19 @@ var TrackGlowLineProgram = /** @class */ (function () {
346
654
  // gl.bindBuffer(gl.ARRAY_BUFFER, this._inBuffer);
347
655
  // gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
348
656
  // }
349
- TrackGlowLineProgram.prototype.setIs3D = function (is3d) {
350
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
351
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
657
+ setIs3D(is3d) {
658
+ const { gl, _lineProgram } = this;
659
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
352
660
  gl.useProgram(_lineProgram.program);
353
661
  gl.uniform1i(_lineProgram.u_is_3d, is3d);
354
662
  gl.useProgram(currentProgram);
355
- };
356
- TrackGlowLineProgram.prototype.setTotalLength = function (totalLength) {
663
+ }
664
+ setTotalLength(totalLength) {
357
665
  this._totalLength = totalLength;
358
- };
359
- TrackGlowLineProgram.prototype._createTextures = function () {
360
- var _a = this, gl = _a.gl, _width = _a._width, _height = _a._height;
361
- var texture = gl.createTexture();
666
+ }
667
+ _createTextures() {
668
+ const { gl, _width, _height } = this;
669
+ const texture = gl.createTexture();
362
670
  gl.bindTexture(gl.TEXTURE_2D, texture);
363
671
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); // UNSIGNED_BYTE
364
672
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
@@ -367,9 +675,9 @@ var TrackGlowLineProgram = /** @class */ (function () {
367
675
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
368
676
  gl.bindTexture(gl.TEXTURE_2D, null);
369
677
  return texture;
370
- };
371
- TrackGlowLineProgram.prototype._resetTexture = function () {
372
- var _a = this, gl = _a.gl, _width = _a._width, _height = _a._height;
678
+ }
679
+ _resetTexture() {
680
+ const { gl, _width, _height } = this;
373
681
  gl.bindTexture(gl.TEXTURE_2D, this._middleTexture); // UNSIGNED_BYTE
374
682
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
375
683
  gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[0]);
@@ -377,10 +685,9 @@ var TrackGlowLineProgram = /** @class */ (function () {
377
685
  gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[1]);
378
686
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
379
687
  gl.bindTexture(gl.TEXTURE_2D, null);
380
- };
381
- TrackGlowLineProgram.prototype.draw = function (u_head_time, u_tail_time, uProjectionMatrix, uModelViewMatrix, uTranslate, u_mapWH) {
382
- if (u_mapWH === void 0) { u_mapWH = null; }
383
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram, _blurProgram = _a._blurProgram, _blurRepetition = _a._blurRepetition, _premultipliedAlpha = _a._premultipliedAlpha;
688
+ }
689
+ draw(u_head_time, u_tail_time, uProjectionMatrix, uModelViewMatrix, uTranslate, u_mapWH = null) {
690
+ const { gl, _lineProgram, _blurProgram, _blurRepetition, _premultipliedAlpha } = this;
384
691
  this._resetTexture();
385
692
  // if (_premultipliedAlpha) {
386
693
  gl.enable(gl.BLEND);
@@ -415,7 +722,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
415
722
  { // blur ping pong
416
723
  gl.useProgram(_blurProgram.program);
417
724
  gl.bindVertexArray(_blurProgram.vao);
418
- for (var i = 0; i < _blurRepetition * 2; i++) {
725
+ for (let i = 0; i < _blurRepetition * 2; i++) {
419
726
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._blurFrameBuffers[i % 2]);
420
727
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._blurTextures[(i + 1) % 2], 0);
421
728
  gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[i % 2]);
@@ -443,9 +750,9 @@ var TrackGlowLineProgram = /** @class */ (function () {
443
750
  if (_premultipliedAlpha) {
444
751
  (0, util_1.defaultblendfunction)(gl);
445
752
  }
446
- };
447
- TrackGlowLineProgram.prototype.free = function () {
448
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram, _blurProgram = _a._blurProgram, _combineProgram = _a._combineProgram;
753
+ }
754
+ free() {
755
+ const { gl, _lineProgram, _blurProgram, _combineProgram } = this;
449
756
  gl.deleteBuffer(this._inBuffer);
450
757
  gl.deleteFramebuffer(this._frameBuffer);
451
758
  gl.deleteFramebuffer(this._blurFrameBuffers[0]);
@@ -460,7 +767,6 @@ var TrackGlowLineProgram = /** @class */ (function () {
460
767
  gl.deleteProgram(_lineProgram.program);
461
768
  gl.deleteProgram(_blurProgram.program);
462
769
  gl.deleteProgram(_combineProgram.program);
463
- };
464
- return TrackGlowLineProgram;
465
- }());
770
+ }
771
+ }
466
772
  exports.default = TrackGlowLineProgram;