@pirireis/webglobeplugins 0.9.11 → 0.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/Math/angle-calculation.js +9 -11
  2. package/Math/arc.js +38 -41
  3. package/Math/bounds/line-bbox.js +79 -83
  4. package/Math/constants.js +4 -9
  5. package/Math/frustum/types.js +1 -2
  6. package/Math/juction/arc-plane.js +33 -36
  7. package/Math/juction/line-sphere.js +15 -18
  8. package/Math/juction/plane-plane.js +20 -23
  9. package/Math/line.js +42 -47
  10. package/Math/methods.js +69 -92
  11. package/Math/plane.js +33 -38
  12. package/Math/quaternion.js +48 -55
  13. package/Math/types.js +1 -2
  14. package/Math/utils.js +2 -4
  15. package/Math/vec3.js +46 -52
  16. package/algorithms/search-binary.js +5 -8
  17. package/altitude-locator/draw-subset-obj.js +8 -11
  18. package/altitude-locator/plugin.js +114 -133
  19. package/altitude-locator/types.js +1 -3
  20. package/arrowfield/adaptor.js +3 -7
  21. package/arrowfield/index.js +3 -10
  22. package/arrowfield/plugin.js +63 -69
  23. package/bearing-line/index.js +2 -8
  24. package/bearing-line/plugin.js +218 -248
  25. package/circle-line-chain/chain-list-map.js +82 -92
  26. package/circle-line-chain/plugin.js +147 -182
  27. package/circle-line-chain/util.js +1 -5
  28. package/compass-rose/compass-rose-padding-flat.js +111 -140
  29. package/compass-rose/compass-text-writer.js +63 -75
  30. package/compass-rose/index.js +3 -7
  31. package/compassrose/compassrose.js +50 -57
  32. package/compassrose/index.js +2 -8
  33. package/heatwave/index.js +3 -10
  34. package/heatwave/isobar/objectarraylabels.js +50 -56
  35. package/heatwave/isobar/plugin.js +111 -170
  36. package/heatwave/isobar/quadtreecontours.js +78 -96
  37. package/heatwave/plugins/heatwaveglobeshell.js +73 -94
  38. package/index.js +12 -58
  39. package/package.json +1 -1
  40. package/partialrings/buffer-manager.js +32 -70
  41. package/partialrings/index.js +2 -41
  42. package/partialrings/plugin.js +55 -98
  43. package/partialrings/program.js +141 -59
  44. package/pin/pin-object-array.js +89 -97
  45. package/pin/pin-point-totem.js +21 -22
  46. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +11 -14
  47. package/point-heat-map/plugin-webworker.js +45 -53
  48. package/point-heat-map/point-to-heat-map-flow.js +46 -51
  49. package/point-tracks/key-methods.js +2 -5
  50. package/point-tracks/plugin.js +141 -170
  51. package/programs/arrowfield/index.js +2 -7
  52. package/programs/arrowfield/logic.js +172 -67
  53. package/programs/arrowfield/object.js +35 -43
  54. package/programs/data2legend/density-to-legend.js +47 -26
  55. package/programs/data2legend/point-to-density-texture.js +56 -34
  56. package/programs/float2legendwithratio/index.js +2 -8
  57. package/programs/float2legendwithratio/logic.js +88 -45
  58. package/programs/float2legendwithratio/object.js +45 -54
  59. package/programs/globe-util/is-globe-moved.js +10 -13
  60. package/programs/globeshell/index.js +2 -8
  61. package/programs/globeshell/wiggle/index.js +2 -8
  62. package/programs/globeshell/wiggle/logic.js +191 -101
  63. package/programs/globeshell/wiggle/object.js +35 -43
  64. package/programs/helpers/blender/program.js +36 -22
  65. package/programs/helpers/fadeaway/index.js +2 -7
  66. package/programs/helpers/fadeaway/logic.js +36 -17
  67. package/programs/helpers/fadeaway/object.js +11 -18
  68. package/programs/helpers/index.js +2 -8
  69. package/programs/index.js +9 -58
  70. package/programs/line-on-globe/angled-line.js +95 -39
  71. package/programs/line-on-globe/circle-accurate-3d.js +86 -39
  72. package/programs/line-on-globe/circle-accurate-flat.js +116 -64
  73. package/programs/line-on-globe/circle-accurate.js +113 -46
  74. package/programs/line-on-globe/circle.js +106 -44
  75. package/programs/line-on-globe/degree-padding-around-circle-3d.js +89 -42
  76. package/programs/line-on-globe/lines-color-instanced-flat.js +84 -43
  77. package/programs/line-on-globe/linestrip.js +126 -63
  78. package/programs/line-on-globe/naive-accurate-flexible.js +126 -59
  79. package/programs/line-on-globe/to-the-surface.js +62 -35
  80. package/programs/line-on-globe/util.js +2 -5
  81. package/programs/picking/pickable-renderer.js +127 -46
  82. package/programs/point-on-globe/element-globe-surface-glow.js +83 -46
  83. package/programs/point-on-globe/element-point-glow.js +112 -47
  84. package/programs/point-on-globe/square-pixel-point.js +80 -34
  85. package/programs/programcache.js +14 -19
  86. package/programs/rings/distancering/circleflatprogram.js +76 -70
  87. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +168 -194
  88. package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -200
  89. package/programs/rings/distancering/index.js +5 -14
  90. package/programs/rings/distancering/paddyflatprogram.js +87 -70
  91. package/programs/rings/distancering/paddyflatprogram2d.js +89 -72
  92. package/programs/rings/distancering/paddyflatprogram3d.js +87 -70
  93. package/programs/rings/index.js +1 -17
  94. package/programs/rings/partial-ring/piece-of-pie.js +144 -44
  95. package/programs/totems/camerauniformblock.js +65 -56
  96. package/programs/totems/canvas-webglobe-info.js +49 -45
  97. package/programs/totems/gpu-selection-uniform-block.js +45 -45
  98. package/programs/totems/index.js +2 -40
  99. package/programs/two-d/pixel-padding-for-compass.js +94 -36
  100. package/programs/util.js +7 -10
  101. package/programs/vectorfields/index.js +3 -23
  102. package/programs/vectorfields/logics/drawrectangleparticles.js +73 -35
  103. package/programs/vectorfields/logics/index.js +4 -12
  104. package/programs/vectorfields/logics/pixelbased.js +94 -41
  105. package/programs/vectorfields/logics/ubo.js +32 -32
  106. package/programs/vectorfields/pingpongbuffermanager.js +30 -37
  107. package/rangerings/enum.js +2 -5
  108. package/rangerings/index.js +5 -15
  109. package/rangerings/plugin.js +223 -286
  110. package/rangerings/rangeringangletext.js +122 -137
  111. package/rangerings/ring-account.js +53 -75
  112. package/shaders/fragment-toy/firework.js +55 -4
  113. package/shaders/fragment-toy/singularity.js +56 -5
  114. package/timetracks/adaptors-line-strip.js +27 -44
  115. package/timetracks/adaptors.js +48 -67
  116. package/timetracks/index.js +5 -19
  117. package/timetracks/plugin-line-strip.js +65 -79
  118. package/timetracks/plugin.js +71 -85
  119. package/timetracks/program-line-strip.js +297 -107
  120. package/timetracks/program.js +421 -118
  121. package/timetracks/programpoint-line-strip.js +98 -48
  122. package/timetracks/programpoint.js +91 -48
  123. package/util/account/bufferoffsetmanager.js +72 -98
  124. package/util/account/index.js +3 -23
  125. package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -48
  126. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -98
  127. package/util/account/single-attribute-buffer-management/index.js +4 -9
  128. package/util/account/single-attribute-buffer-management/object-store.js +29 -34
  129. package/util/account/single-attribute-buffer-management/types.js +1 -2
  130. package/util/account/util.js +2 -8
  131. package/util/algorithms/search-binary.js +5 -8
  132. package/util/check/get.js +5 -9
  133. package/util/check/typecheck.js +13 -24
  134. package/util/geometry/index.js +10 -18
  135. package/util/gl-util/buffer/attribute-loader.js +10 -26
  136. package/util/gl-util/buffer/index.js +2 -5
  137. package/util/gl-util/draw-options/methods.js +10 -15
  138. package/util/gl-util/uniform-block/manager.js +69 -72
  139. package/util/heatwavedatamanager/datamanager.js +56 -119
  140. package/util/heatwavedatamanager/index.js +3 -10
  141. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +38 -47
  142. package/util/heatwavedatamanager/pointcoordsmeta.js +9 -13
  143. package/util/index.js +13 -57
  144. package/util/interpolation/timetrack/index.js +2 -5
  145. package/util/interpolation/timetrack/timetrack-interpolator.js +30 -36
  146. package/util/interpolation/timetrack/web-worker-str.js +180 -5
  147. package/util/interpolation/timetrack/web-worker.js +4 -6
  148. package/util/jshelpers/data-filler.js +8 -11
  149. package/util/jshelpers/equality.js +1 -3
  150. package/util/jshelpers/index.js +2 -37
  151. package/util/jshelpers/timefilters.js +8 -10
  152. package/util/picking/fence.js +8 -11
  153. package/util/picking/picker-displayer.js +49 -58
  154. package/util/programs/draw-texture-on-canvas.js +41 -26
  155. package/util/programs/index.js +1 -17
  156. package/util/programs/shapesonglobe.js +104 -68
  157. package/util/programs/supersampletotextures.js +45 -43
  158. package/util/programs/texturetoglobe.js +99 -52
  159. package/util/shaderfunctions/geometrytransformations.js +323 -35
  160. package/util/shaderfunctions/index.js +2 -18
  161. package/util/shaderfunctions/nodata.js +8 -5
  162. package/util/shaderfunctions/noisefunctions.js +40 -12
  163. package/util/surface-line-data/arcs-to-cuts.js +20 -23
  164. package/util/webglobe/gldefaultstates.js +1 -4
  165. package/util/webglobe/index.js +2 -18
  166. package/util/webglobe/rasteroverlay.js +36 -41
  167. package/util/webglobjectbuilders.js +70 -93
  168. package/util/webglobjectbuilders1.js +63 -82
  169. package/waveparticles/adaptor.js +7 -10
  170. package/waveparticles/index.js +3 -10
  171. package/waveparticles/plugin.js +82 -90
  172. package/wind/imagetovectorfieldandmagnitude.js +16 -19
  173. package/wind/index.js +5 -14
  174. package/wind/plugin.js +454 -291
  175. package/wind/vectorfieldimage.js +6 -8
  176. package/write-text/attached-text-writer.js +48 -54
  177. package/write-text/context-text.js +52 -63
  178. package/write-text/context-text3.js +71 -80
  179. package/write-text/index.js +1 -5
@@ -1,10 +1,8 @@
1
- "use strict";
2
1
  /**
3
2
  * Author: Toprak Nihat Deniz Ozturk
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var util_1 = require("../util");
7
- var TrackGlowLineProgram = /** @class */ (function () {
4
+ import { createProgram, defaultblendfunction, shaderfunctions } from "../util";
5
+ export default class TrackGlowLineProgram {
8
6
  /**
9
7
  * @param {WebGL2RenderingContext} gl
10
8
  * @param {number} width
@@ -19,8 +17,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
19
17
  * @param {number} options.finalAlphaRatio 0 ~ 1
20
18
  * @param {+int} options.blurRepetition 1 ~ inf default 2
21
19
  */
22
- function TrackGlowLineProgram(gl, attrBuffer, width, height, options) {
23
- if (options === void 0) { options = {}; }
20
+ constructor(gl, attrBuffer, width, height, options = {}) {
24
21
  this.gl = gl;
25
22
  this.program = null;
26
23
  this._premultipliedAlpha = false;
@@ -39,14 +36,13 @@ var TrackGlowLineProgram = /** @class */ (function () {
39
36
  this._totalLength = 0;
40
37
  this._initUniforms(options);
41
38
  }
42
- TrackGlowLineProgram.prototype._createInnerTextures = function () {
39
+ _createInnerTextures() {
43
40
  this._middleTexture = this._createTextures();
44
41
  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);
42
+ }
43
+ _initUniforms(options = {}) {
44
+ const { gl, _lineProgram, _blurProgram, _combineProgram } = this;
45
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
50
46
  gl.useProgram(_lineProgram.program);
51
47
  gl.uniform1f(_lineProgram.u_head_percentage, options.headPercentage || 1.0 / 30.0);
52
48
  gl.uniform1f(_lineProgram.u_route_alpha, options.routeAlpha || 0.025);
@@ -59,150 +55,187 @@ var TrackGlowLineProgram = /** @class */ (function () {
59
55
  gl.uniform1f(_combineProgram.u_gamma, options.gamma || 1.0);
60
56
  gl.uniform1f(_combineProgram.u_final_alpha_ratio, options.finalAlphaRatio || 1.0);
61
57
  gl.useProgram(currentProgram);
62
- };
63
- TrackGlowLineProgram.prototype.setPremultipliedAlpha = function (boolean) {
58
+ }
59
+ setPremultipliedAlpha(boolean) {
64
60
  if (typeof boolean !== 'boolean') {
65
61
  console.warn("boolean should be a boolean value, but got", boolean);
66
62
  return;
67
63
  }
68
64
  this._premultipliedAlpha = boolean;
69
- };
65
+ }
70
66
  /**
71
67
  * @param {number} alpha 0 ~ 1
72
68
  * @returns
73
69
  */
74
- TrackGlowLineProgram.prototype.setAlphaThreshold = function (alpha) {
70
+ setAlphaThreshold(alpha) {
75
71
  if (alpha < 0 || alpha > 1) {
76
72
  console.warn("alpha should be between 0 and 1, but got", alpha);
77
73
  return;
78
74
  }
79
- var _a = this, gl = _a.gl, _blurProgram = _a._blurProgram;
80
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
75
+ const { gl, _blurProgram } = this;
76
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
81
77
  gl.useProgram(_blurProgram.program);
82
78
  gl.uniform1f(_blurProgram.u_alpha_threshold, alpha);
83
79
  gl.useProgram(currentProgram);
84
- };
80
+ }
85
81
  /**
86
82
  * @param {number} gamma 0 ~ inf
87
83
  */
88
- TrackGlowLineProgram.prototype.setGamma = function (gamma) {
84
+ setGamma(gamma) {
89
85
  if (gamma < 0) {
90
86
  console.warn("gamma should be equal or greater than 0, but got", gamma);
91
87
  return;
92
88
  }
93
- var _a = this, gl = _a.gl, _combineProgram = _a._combineProgram;
94
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
89
+ const { gl, _combineProgram } = this;
90
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
95
91
  gl.useProgram(_combineProgram.program);
96
92
  gl.uniform1f(_combineProgram.u_gamma, gamma);
97
93
  gl.useProgram(currentProgram);
98
- };
94
+ }
99
95
  /**
100
96
  *
101
97
  * @param {number} exposure 0 ~ inf
102
98
  * @returns
103
99
  */
104
- TrackGlowLineProgram.prototype.setExposure = function (exposure) {
100
+ setExposure(exposure) {
105
101
  if (exposure < 0) {
106
102
  console.warn("exposure should be equal or greater than 0, but got", exposure);
107
103
  return;
108
104
  }
109
- var _a = this, gl = _a.gl, _combineProgram = _a._combineProgram;
110
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
105
+ const { gl, _combineProgram } = this;
106
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
111
107
  gl.useProgram(_combineProgram.program);
112
108
  gl.uniform1f(_combineProgram.u_exposure, exposure);
113
109
  gl.useProgram(currentProgram);
114
- };
110
+ }
115
111
  /**
116
112
  *
117
113
  * @param {number} ratio 0 ~ 1
118
114
  * @returns
119
115
  */
120
- TrackGlowLineProgram.prototype.setFinalAlphaRatio = function (ratio) {
116
+ setFinalAlphaRatio(ratio) {
121
117
  if (ratio < 0 || ratio > 1) {
122
118
  console.warn("ratio should be between 0 and 1, but got", ratio);
123
119
  return;
124
120
  }
125
- var _a = this, gl = _a.gl, _combineProgram = _a._combineProgram;
126
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
121
+ const { gl, _combineProgram } = this;
122
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
127
123
  gl.useProgram(_combineProgram.program);
128
124
  gl.uniform1f(_combineProgram.u_final_alpha_ratio, ratio);
129
125
  gl.useProgram(currentProgram);
130
- };
126
+ }
131
127
  /**
132
128
  * @param {Array.<Number>} weight [w1, w2, w3, w4, w5]
133
129
  */
134
- TrackGlowLineProgram.prototype.setBlurWeights = function (weights) {
130
+ setBlurWeights(weights) {
135
131
  if (weights.length !== 5) {
136
132
  console.warn("weights should be an array of 5 numbers, but got", weights);
137
133
  return;
138
134
  }
139
- var _a = this, gl = _a.gl, _blurProgram = _a._blurProgram;
140
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
135
+ const { gl, _blurProgram } = this;
136
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
141
137
  gl.useProgram(_blurProgram.program);
142
138
  gl.uniform1fv(_blurProgram.u_weight, weights);
143
139
  gl.useProgram(currentProgram);
144
- };
140
+ }
145
141
  /**
146
142
  * @param {number} routeAlpha 0 ~ 1
147
143
  */
148
- TrackGlowLineProgram.prototype.setRouteAlpha = function (routeAlpha) {
144
+ setRouteAlpha(routeAlpha) {
149
145
  if (routeAlpha < 0 || routeAlpha > 1) {
150
146
  console.warn("routeAlpha should be between 0 and 1, but got", routeAlpha);
151
147
  return;
152
148
  }
153
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
154
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
149
+ const { gl, _lineProgram } = this;
150
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
155
151
  gl.useProgram(_lineProgram.program);
156
152
  gl.uniform1f(_lineProgram.u_route_alpha, routeAlpha);
157
153
  gl.useProgram(currentProgram);
158
- };
159
- TrackGlowLineProgram.prototype.setGlow = function (boolean) {
154
+ }
155
+ setGlow(boolean) {
160
156
  if (typeof boolean !== 'boolean') {
161
157
  console.warn("boolean should be a boolean value, but got", boolean);
162
158
  return;
163
159
  }
164
- var _a = this, gl = _a.gl, _blurProgram = _a._blurProgram;
165
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
160
+ const { gl, _blurProgram } = this;
161
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
166
162
  gl.useProgram(_blurProgram.program);
167
163
  gl.uniform1i(_blurProgram.u_glow, boolean);
168
164
  gl.useProgram(currentProgram);
169
- };
165
+ }
170
166
  /**
171
167
  * blur uses pingpong effect. This number decides how many times the blur will be applied.
172
168
  * @param {+int} repetition
173
169
  * @returns
174
170
  */
175
- TrackGlowLineProgram.prototype.setBlurRepetition = function (repetition) {
171
+ setBlurRepetition(repetition) {
176
172
  if (repetition < 0 && repetition % 1 !== 0) {
177
173
  console.warn("repetition should be an integer greater than 0, but got", repetition);
178
174
  return;
179
175
  }
180
176
  this._blurRepetition = repetition;
181
- };
177
+ }
182
178
  /**
183
179
  * Head Is colored as white. This number decides proportion of the head according to the total length of the line.
184
180
  * @param {Number} percentage 0 ~ 1
185
181
  */
186
- TrackGlowLineProgram.prototype.setHeadPercentage = function (percentage) {
182
+ setHeadPercentage(percentage) {
187
183
  if (percentage < 0 || 1 < percentage) {
188
184
  console.warn("percentage should be between 0 and 1, but got", percentage);
189
185
  return;
190
186
  }
191
187
  ;
192
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
193
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
188
+ const { gl, _lineProgram } = this;
189
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
194
190
  gl.useProgram(_lineProgram.program);
195
191
  gl.uniform1f(_lineProgram.u_head_percentage, percentage);
196
192
  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();
193
+ }
194
+ _createCombineProgram() {
195
+ const gl = this.gl;
196
+ const vertexShader = `#version 300 es
197
+ precision lowp float;
198
+
199
+ in vec2 a_position;
200
+
201
+ out vec2 v_texcoord;
202
+
203
+ void main() {
204
+ gl_Position = vec4(a_position, 0.0, 1.0);
205
+ v_texcoord = a_position.xy * 0.5 + 0.5;
206
+ }
207
+ `;
208
+ const fragmentShader = `#version 300 es
209
+ precision lowp float;
210
+
211
+ in vec2 v_texcoord;
212
+
213
+ uniform sampler2D u_main_texture;
214
+ uniform sampler2D u_bloom_texture;
215
+
216
+ uniform float u_exposure;
217
+ uniform float u_gamma;
218
+ uniform float u_final_alpha_ratio;
219
+
220
+ out vec4 outColor;
221
+
222
+ void main() {
223
+ vec4 hdrColor = texture(u_main_texture, v_texcoord);
224
+ vec4 bloomColor = texture(u_bloom_texture, v_texcoord);
225
+ vec4 result;
226
+ if (bloomColor.a > 0.09){
227
+ result = bloomColor * u_exposure;
228
+ } else {
229
+ result = hdrColor + bloomColor * u_exposure;
230
+ }
231
+ result = pow(result, vec4(1.0 / u_gamma));
232
+ outColor = vec4(result.rgb, result.a * u_final_alpha_ratio);
233
+ }
234
+ `;
235
+ const program = createProgram(this.gl, vertexShader, fragmentShader);
236
+ const buffer = gl.createBuffer();
237
+ const a_position = gl.getAttribLocation(program, "a_position");
238
+ const vao = gl.createVertexArray();
206
239
  gl.bindVertexArray(vao);
207
240
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
208
241
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
@@ -225,14 +258,137 @@ var TrackGlowLineProgram = /** @class */ (function () {
225
258
  u_gamma: gl.getUniformLocation(program, "u_gamma"),
226
259
  u_final_alpha_ratio: gl.getUniformLocation(program, "u_final_alpha_ratio"),
227
260
  };
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");
261
+ }
262
+ _createBlurProgram() {
263
+ const gl = this.gl;
264
+ const vertexShader = `#version 300 es
265
+ precision highp float;
266
+
267
+ in vec2 a_position;
268
+ out vec2 v_texcoord;
269
+
270
+ void main() {
271
+ gl_Position = vec4(a_position, 0.0, 1.0);
272
+ v_texcoord = a_position.xy * 0.5 + 0.5;
273
+ }
274
+ `;
275
+ const fragmentShader = `#version 300 es
276
+ precision highp float;
277
+
278
+ in vec2 v_texcoord;
279
+
280
+ uniform sampler2D u_texture;
281
+ uniform bool u_horizontal;
282
+ uniform float u_weight[5];
283
+ uniform float u_alpha_threshold;
284
+ uniform bool u_glow;
285
+ out vec4 outColor;
286
+
287
+ void main()
288
+ {
289
+ vec2 tex_offset = vec2(
290
+ 1.0 / float(textureSize(u_texture, 0).x),
291
+ 1.0 / float(textureSize(u_texture, 0).y) ); // gets size of single texel
292
+ vec3 color = vec3(0.0);
293
+ float total_alpha = texture(u_texture, v_texcoord).a * u_weight[0];
294
+ if (total_alpha > 0.0){
295
+ color = texture(u_texture, v_texcoord).rgb;
296
+ }
297
+ vec2 offset = vec2(0.0);
298
+ float alpha;
299
+ float color_count = 0.0;
300
+ if (!u_glow){
301
+ if(u_horizontal){
302
+ for(int i = 1; i < 5; ++i)
303
+ {
304
+ offset = vec2(tex_offset.x * float(i), 0.0);
305
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
306
+
307
+ if (alpha > u_alpha_threshold){
308
+ // color = max( color, texture(u_texture, v_texcoord + offset).rgb);
309
+ color += texture(u_texture, v_texcoord + offset).rgb;
310
+ total_alpha += alpha;
311
+ color_count += 1.0;
312
+ }
313
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
314
+ if (alpha > u_alpha_threshold){
315
+ // color = max( color, texture(u_texture, v_texcoord - offset).rgb);
316
+ color += texture(u_texture, v_texcoord - offset).rgb ;
317
+ total_alpha += alpha;
318
+ color_count += 1.0;
319
+
320
+ }
321
+ }
322
+ } else {
323
+ for(int i = 1; i < 5; ++i)
324
+ {
325
+ offset = vec2(0.0, tex_offset.y * float(i));
326
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
327
+ if (alpha > u_alpha_threshold){
328
+ // color = max( color , texture(u_texture, v_texcoord + offset).rgb);
329
+ color += texture(u_texture, v_texcoord + offset).rgb;
330
+ total_alpha += alpha;
331
+ color_count += 1.0;
332
+
333
+ }
334
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
335
+ if (alpha > u_alpha_threshold){
336
+ // color = max( color, texture(u_texture, v_texcoord - offset).rgb );
337
+ color += texture(u_texture, v_texcoord - offset).rgb ;
338
+ total_alpha += alpha;
339
+ color_count += 1.0;
340
+
341
+ }
342
+ }
343
+
344
+ }
345
+ if (color_count > 0.0){
346
+ color /= color_count;
347
+ }
348
+ } else {
349
+ if(u_horizontal)
350
+ {
351
+ for(int i = 1; i < 5; ++i)
352
+ {
353
+ offset = vec2(tex_offset.x * float(i), 0.0);
354
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
355
+
356
+ if (alpha > u_alpha_threshold){
357
+ color = max( color, texture(u_texture, v_texcoord + offset).rgb);
358
+ total_alpha += alpha;
359
+ }
360
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
361
+ if (alpha > u_alpha_threshold){
362
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb);
363
+
364
+ total_alpha += alpha;
365
+ }
366
+ }
367
+ }
368
+ else
369
+ {
370
+ for(int i = 1; i < 5; ++i)
371
+ {
372
+ offset = vec2(0.0, tex_offset.y * float(i));
373
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
374
+ if (alpha > u_alpha_threshold){
375
+ color = max( color, texture(u_texture, v_texcoord + offset).rgb);
376
+ total_alpha += alpha;
377
+ }
378
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
379
+ if (alpha > u_alpha_threshold){
380
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb );
381
+ total_alpha += alpha;
382
+ }
383
+ }
384
+ }
385
+ }
386
+ outColor = vec4(color, total_alpha);
387
+ }
388
+ `;
389
+ const program = createProgram(this.gl, vertexShader, fragmentShader);
390
+ const buffer = gl.createBuffer();
391
+ const a_position = gl.getAttribLocation(program, "a_position");
236
392
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
237
393
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
238
394
  -1, -1,
@@ -242,7 +398,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
242
398
  1, 1,
243
399
  -1, 1,
244
400
  ]), gl.STATIC_DRAW);
245
- var vao = gl.createVertexArray();
401
+ const vao = gl.createVertexArray();
246
402
  gl.bindVertexArray(vao);
247
403
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
248
404
  gl.enableVertexAttribArray(a_position);
@@ -257,14 +413,84 @@ var TrackGlowLineProgram = /** @class */ (function () {
257
413
  u_alpha_threshold: gl.getUniformLocation(program, "u_alpha_threshold"),
258
414
  u_glow: gl.getUniformLocation(program, "u_glow"),
259
415
  };
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");
416
+ }
417
+ _createBlurProgramHOLD() {
418
+ const gl = this.gl;
419
+ const vertexShader = `#version 300 es
420
+ precision highp float;
421
+
422
+ in vec2 a_position;
423
+ out vec2 v_texcoord;
424
+
425
+ void main() {
426
+ gl_Position = vec4(a_position, 0.0, 1.0);
427
+ v_texcoord = a_position.xy * 0.5 + 0.5;
428
+ }
429
+ `;
430
+ const fragmentShader = `#version 300 es
431
+ precision highp float;
432
+
433
+ in vec2 v_texcoord;
434
+
435
+ uniform sampler2D u_texture;
436
+ uniform bool u_horizontal;
437
+ uniform float u_weight[5];
438
+ uniform float u_alpha_threshold;
439
+
440
+ out vec4 outColor;
441
+
442
+ void main()
443
+ {
444
+ vec2 tex_offset = vec2(1) / vec2(textureSize(u_texture, 0)); // gets size of single texel
445
+ vec3 color = vec3(0.0);
446
+ float total_alpha = texture(u_texture, v_texcoord).a * u_weight[0];
447
+ if (total_alpha > 0.0){
448
+ color = texture(u_texture, v_texcoord).rgb;
449
+ }
450
+ vec2 offset = vec2(0.0);
451
+ float alpha;
452
+
453
+ if(u_horizontal)
454
+ {
455
+ for(int i = 1; i < 5; ++i)
456
+ {
457
+ offset = vec2(tex_offset.x * float(i), 0.0);
458
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
459
+
460
+ if (alpha > u_alpha_threshold){
461
+ color = max( color, texture(u_texture, v_texcoord + offset).rgb);
462
+ total_alpha += alpha;
463
+ }
464
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
465
+ if (alpha > u_alpha_threshold){
466
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb);
467
+ total_alpha += alpha;
468
+ }
469
+ }
470
+ }
471
+ else
472
+ {
473
+ for(int i = 1; i < 5; ++i)
474
+ {
475
+ offset = vec2(0.0, tex_offset.y * float(i));
476
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
477
+ if (alpha > u_alpha_threshold){
478
+ color = max( color , texture(u_texture, v_texcoord + offset).rgb);
479
+ total_alpha += alpha;
480
+ }
481
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
482
+ if (alpha > u_alpha_threshold){
483
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb );
484
+ total_alpha += alpha;
485
+ }
486
+ }
487
+ }
488
+ outColor = vec4(color, total_alpha);
489
+ }
490
+ `;
491
+ const program = createProgram(this.gl, vertexShader, fragmentShader);
492
+ const buffer = gl.createBuffer();
493
+ const a_position = gl.getAttribLocation(program, "a_position");
268
494
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
269
495
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
270
496
  -1, -1,
@@ -274,7 +500,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
274
500
  1, 1,
275
501
  -1, 1,
276
502
  ]), gl.STATIC_DRAW);
277
- var vao = gl.createVertexArray();
503
+ const vao = gl.createVertexArray();
278
504
  gl.bindVertexArray(vao);
279
505
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
280
506
  gl.enableVertexAttribArray(a_position);
@@ -288,28 +514,108 @@ var TrackGlowLineProgram = /** @class */ (function () {
288
514
  u_weight: gl.getUniformLocation(program, "u_weight"),
289
515
  u_alpha_threshold: gl.getUniformLocation(program, "u_alpha_threshold"),
290
516
  };
291
- };
292
- TrackGlowLineProgram.prototype.resize = function (width, height) {
293
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
517
+ }
518
+ resize(width, height) {
519
+ const { gl, _lineProgram } = this;
294
520
  this._width = width;
295
521
  this._height = height;
296
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
522
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
297
523
  this._createInnerTextures();
298
524
  gl.useProgram(_lineProgram.program);
299
525
  gl.uniform2fv(_lineProgram.u_scrWH, [width, height]);
300
526
  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();
527
+ }
528
+ _createLineProgram() {
529
+ const gl = this.gl;
530
+ const vertexShader = `#version 300 es
531
+ precision highp float;
532
+
533
+ in vec3 a_position;
534
+ in float a_time;
535
+ in vec3 a_color;
536
+ in float a_track_start_time;
537
+ in float a_track_end_time;
538
+
539
+ uniform mat4 uModelViewMatrix;
540
+ uniform mat4 uProjectionMatrix;
541
+ uniform vec3 uTranslate;
542
+
543
+ uniform bool u_is_3d;
544
+ uniform vec2 u_mapWH;
545
+ uniform vec2 u_scrWH;
546
+
547
+ out float v_time;
548
+ out vec3 v_color;
549
+ out float v_track_start_time;
550
+ out float v_track_end_time;
551
+
552
+ ${shaderfunctions.pixelXYToCartesian3DPoint}
553
+ ${shaderfunctions.pixelXYToCartesian2DPoint}
554
+
555
+ void main() {
556
+ v_time = a_time;
557
+ v_color = a_color;
558
+ v_track_start_time = a_track_start_time;
559
+ v_track_end_time = a_track_end_time;
560
+ if (u_is_3d){
561
+ vec3 pos = pixelXYToCartesian3DPoint(a_position);
562
+ gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(pos - uTranslate, 1.0);
563
+ } else {
564
+ vec2 xy = pixelXYToCartesian2DPoint(a_position.xy, uTranslate.xy, u_mapWH, u_scrWH);
565
+ gl_Position = uProjectionMatrix * vec4(xy.x, xy.y, 0.0, 1.0);
566
+
567
+ }
568
+ gl_PointSize = 1.0;
569
+ }
570
+ `;
571
+ const fragmentShader = `#version 300 es
572
+ precision lowp float;
573
+
574
+ in float v_time;
575
+ in vec3 v_color;
576
+ in float v_track_start_time;
577
+ in float v_track_end_time;
578
+
579
+ uniform float u_head_time;
580
+ uniform float u_tail_time;
581
+
582
+ uniform float u_head_percentage;
583
+ uniform float u_route_alpha;
584
+
585
+ layout(location = 0) out vec4 outColor0;
586
+ layout(location = 1) out vec4 outColor1;
587
+
588
+
589
+ void main() {
590
+ if ( u_tail_time > v_track_end_time || u_head_time < v_track_start_time) discard;
591
+ // if ( v_time < u_tail_time || v_time > u_head_time) discard;
592
+
593
+ float gap = u_head_time - u_tail_time;
594
+ float head = gap * u_head_percentage;
595
+ float dist = u_head_time - v_time;
596
+ if ((v_time > u_head_time ) || (v_time < u_tail_time) ){
597
+
598
+ outColor0 = vec4(v_color , u_route_alpha);
599
+ } else if (dist < head) {
600
+ // white head
601
+ outColor0 = vec4(1.0, 1.0, 1.0, 0.77 + ( u_route_alpha * 0.23));
602
+ outColor1 = vec4(1.0, 1.0, 1.0, 0.77 + ( u_route_alpha * 0.23));
603
+ //
604
+ } else {
605
+ // colored body of lines
606
+ float alpha = ((gap - dist) / gap) / 2.0 + 0.5;
607
+ outColor0 = vec4(v_color , alpha );
608
+ outColor1 = vec4(v_color , alpha );
609
+ }
610
+ }
611
+ `;
612
+ const program = createProgram(this.gl, vertexShader, fragmentShader);
613
+ const a_position = gl.getAttribLocation(program, "a_position");
614
+ const a_time = gl.getAttribLocation(program, "a_time");
615
+ const a_track_start_time = gl.getAttribLocation(program, "a_track_start_time");
616
+ const a_track_end_time = gl.getAttribLocation(program, "a_track_end_time");
617
+ const a_color = gl.getAttribLocation(program, "a_color");
618
+ const vao = gl.createVertexArray();
313
619
  gl.bindVertexArray(vao);
314
620
  gl.bindBuffer(gl.ARRAY_BUFFER, this._inBuffer);
315
621
  gl.enableVertexAttribArray(a_position);
@@ -337,7 +643,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
337
643
  u_head_percentage: gl.getUniformLocation(program, "u_head_percentage"),
338
644
  u_route_alpha: gl.getUniformLocation(program, "u_route_alpha"),
339
645
  };
340
- };
646
+ }
341
647
  /**
342
648
  * @param { Float32Array} data // [x, y, z, time, x, y, z, time, ...]
343
649
  */
@@ -346,19 +652,19 @@ var TrackGlowLineProgram = /** @class */ (function () {
346
652
  // gl.bindBuffer(gl.ARRAY_BUFFER, this._inBuffer);
347
653
  // gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
348
654
  // }
349
- TrackGlowLineProgram.prototype.setIs3D = function (is3d) {
350
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram;
351
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
655
+ setIs3D(is3d) {
656
+ const { gl, _lineProgram } = this;
657
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
352
658
  gl.useProgram(_lineProgram.program);
353
659
  gl.uniform1i(_lineProgram.u_is_3d, is3d);
354
660
  gl.useProgram(currentProgram);
355
- };
356
- TrackGlowLineProgram.prototype.setTotalLength = function (totalLength) {
661
+ }
662
+ setTotalLength(totalLength) {
357
663
  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();
664
+ }
665
+ _createTextures() {
666
+ const { gl, _width, _height } = this;
667
+ const texture = gl.createTexture();
362
668
  gl.bindTexture(gl.TEXTURE_2D, texture);
363
669
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); // UNSIGNED_BYTE
364
670
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
@@ -367,9 +673,9 @@ var TrackGlowLineProgram = /** @class */ (function () {
367
673
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
368
674
  gl.bindTexture(gl.TEXTURE_2D, null);
369
675
  return texture;
370
- };
371
- TrackGlowLineProgram.prototype._resetTexture = function () {
372
- var _a = this, gl = _a.gl, _width = _a._width, _height = _a._height;
676
+ }
677
+ _resetTexture() {
678
+ const { gl, _width, _height } = this;
373
679
  gl.bindTexture(gl.TEXTURE_2D, this._middleTexture); // UNSIGNED_BYTE
374
680
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
375
681
  gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[0]);
@@ -377,10 +683,9 @@ var TrackGlowLineProgram = /** @class */ (function () {
377
683
  gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[1]);
378
684
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
379
685
  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;
686
+ }
687
+ draw(u_head_time, u_tail_time, uProjectionMatrix, uModelViewMatrix, uTranslate, u_mapWH = null) {
688
+ const { gl, _lineProgram, _blurProgram, _blurRepetition, _premultipliedAlpha } = this;
384
689
  this._resetTexture();
385
690
  // if (_premultipliedAlpha) {
386
691
  gl.enable(gl.BLEND);
@@ -415,7 +720,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
415
720
  { // blur ping pong
416
721
  gl.useProgram(_blurProgram.program);
417
722
  gl.bindVertexArray(_blurProgram.vao);
418
- for (var i = 0; i < _blurRepetition * 2; i++) {
723
+ for (let i = 0; i < _blurRepetition * 2; i++) {
419
724
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._blurFrameBuffers[i % 2]);
420
725
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._blurTextures[(i + 1) % 2], 0);
421
726
  gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[i % 2]);
@@ -425,7 +730,7 @@ var TrackGlowLineProgram = /** @class */ (function () {
425
730
  }
426
731
  }
427
732
  if (!_premultipliedAlpha) {
428
- (0, util_1.defaultblendfunction)(gl);
733
+ defaultblendfunction(gl);
429
734
  }
430
735
  { // combine
431
736
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
@@ -441,11 +746,11 @@ var TrackGlowLineProgram = /** @class */ (function () {
441
746
  }
442
747
  gl.bindVertexArray(null);
443
748
  if (_premultipliedAlpha) {
444
- (0, util_1.defaultblendfunction)(gl);
749
+ defaultblendfunction(gl);
445
750
  }
446
- };
447
- TrackGlowLineProgram.prototype.free = function () {
448
- var _a = this, gl = _a.gl, _lineProgram = _a._lineProgram, _blurProgram = _a._blurProgram, _combineProgram = _a._combineProgram;
751
+ }
752
+ free() {
753
+ const { gl, _lineProgram, _blurProgram, _combineProgram } = this;
449
754
  gl.deleteBuffer(this._inBuffer);
450
755
  gl.deleteFramebuffer(this._frameBuffer);
451
756
  gl.deleteFramebuffer(this._blurFrameBuffers[0]);
@@ -460,7 +765,5 @@ var TrackGlowLineProgram = /** @class */ (function () {
460
765
  gl.deleteProgram(_lineProgram.program);
461
766
  gl.deleteProgram(_blurProgram.program);
462
767
  gl.deleteProgram(_combineProgram.program);
463
- };
464
- return TrackGlowLineProgram;
465
- }());
466
- exports.default = TrackGlowLineProgram;
768
+ }
769
+ }