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