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