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