@pirireis/webglobeplugins 0.9.10 → 0.9.11

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