@pirireis/webglobeplugins 1.0.2 → 1.0.3
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.ts → angle-calculation.js} +14 -18
- package/Math/{arc-cdf-points.ts → arc-cdf-points.js} +272 -329
- package/Math/{arc-generate-points-exponantial.ts → arc-generate-points-exponantial.js} +254 -299
- package/Math/{arc.ts → arc.js} +292 -421
- package/Math/bounds/line-bbox.js +186 -225
- package/Math/{circle-cdf-points.ts → circle-cdf-points.js} +78 -143
- package/Math/{circle.ts → circle.js} +33 -49
- package/Math/{constants.ts → constants.js} +4 -12
- package/Math/contour/{quadtreecontours.ts → quadtreecontours.js} +300 -371
- package/Math/contour/quadtreecontours1.js +298 -336
- package/Math/{finite-line-2d.ts → finite-line-2d.js} +58 -68
- package/Math/{haversine.ts → haversine.js} +22 -33
- package/Math/index.js +1 -0
- package/Math/juction/{arc-plane.ts → arc-plane.js} +143 -203
- package/Math/juction/{line-sphere.ts → line-sphere.js} +22 -32
- package/Math/juction/{plane-plane.ts → plane-plane.js} +53 -62
- package/Math/{line.ts → line.js} +52 -84
- package/Math/matrix4.js +1 -0
- package/Math/{methods.ts → methods.js} +126 -182
- package/Math/{plane.ts → plane.js} +56 -92
- package/Math/{quaternion.ts → quaternion.js} +106 -128
- package/Math/templete-shapes/{grid-visually-equal.ts → grid-visually-equal.js} +65 -118
- package/Math/tessellation/constants.js +1 -0
- package/Math/tessellation/{methods.ts → methods.js} +49 -79
- package/Math/tessellation/{nearest-value-padding.ts → nearest-value-padding.js} +112 -147
- package/Math/tessellation/{spherical-triangle-area.ts → spherical-triangle-area.js} +99 -127
- package/Math/tessellation/{tile-merger.ts → tile-merger.js} +429 -578
- package/Math/tessellation/{triangle-tessellation.ts → triangle-tessellation.js} +386 -533
- package/Math/tessellation/types.js +1 -0
- package/Math/types.js +1 -0
- package/Math/utils.js +2 -3
- package/Math/{vec3.ts → vec3.js} +155 -227
- package/Math/{xyz-tile.ts → xyz-tile.js} +18 -26
- package/algorithms/search-binary.js +16 -14
- package/altitude-locator/adaptors.js +1 -0
- package/altitude-locator/keymethod.js +1 -0
- package/altitude-locator/plugin.js +344 -445
- package/altitude-locator/types.js +21 -26
- package/compass-rose/compass-rose-padding-flat.js +230 -274
- package/compass-rose/{compass-text-writer.ts → compass-text-writer.js} +155 -210
- package/compass-rose/index.js +3 -3
- package/{constants.ts → constants.js} +6 -8
- package/heatwave/datamanager.js +149 -168
- package/heatwave/heatwave.js +206 -261
- package/heatwave/index.js +5 -5
- package/heatwave/isobar.js +303 -340
- package/heatwave/{texture-point-sampler.ts → texture-point-sampler.js} +187 -220
- package/investigation-tools/draw/tiles/adapters.js +67 -0
- package/investigation-tools/draw/tiles/{tiles.ts → tiles.js} +128 -162
- package/jest.config.js +7 -6
- package/package.json +1 -1
- package/pin/pin-object-array1.js +300 -381
- package/pin/pin-point-totem1.js +60 -77
- package/programs/arrowfield/arrow-field.js +60 -89
- package/programs/arrowfield/logic.js +141 -173
- package/programs/data2legend/density-to-legend.js +68 -86
- package/programs/data2legend/point-to-density-texture.js +67 -84
- package/programs/float2legendwithratio/index.js +2 -3
- package/programs/float2legendwithratio/logic.js +118 -144
- package/programs/float2legendwithratio/object.js +104 -141
- package/programs/helpers/blender.js +58 -73
- package/programs/helpers/{fadeaway.ts → fadeaway.js} +60 -73
- package/programs/index.js +20 -19
- package/programs/line-on-globe/circle-accurate-3d.js +85 -112
- package/programs/line-on-globe/circle-accurate-flat.js +148 -200
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +102 -134
- package/programs/line-on-globe/index.js +1 -0
- package/programs/line-on-globe/lines-color-instanced-flat.js +80 -99
- package/programs/line-on-globe/linestrip/data.js +4 -0
- package/programs/line-on-globe/linestrip/{linestrip.ts → linestrip.js} +93 -152
- package/programs/line-on-globe/{naive-accurate-flexible.ts → naive-accurate-flexible.js} +126 -175
- package/programs/line-on-globe/util.js +5 -8
- package/programs/picking/pickable-polygon-renderer.js +98 -129
- package/programs/picking/pickable-renderer.js +98 -130
- package/programs/point-on-globe/element-globe-surface-glow.js +93 -122
- package/programs/point-on-globe/element-point-glow.js +80 -114
- package/programs/point-on-globe/square-pixel-point.js +121 -139
- package/programs/polygon-on-globe/{texture-dem-triangles.ts → texture-dem-triangles.js} +163 -207
- package/programs/{programcache.ts → programcache.js} +126 -134
- package/programs/rings/index.js +1 -1
- package/programs/rings/partial-ring/{piece-of-pie.ts → piece-of-pie.js} +152 -222
- package/programs/totems/camera-totem-attactment-interface.js +1 -0
- package/programs/totems/{camerauniformblock.ts → camerauniformblock.js} +225 -310
- package/programs/totems/{canvas-webglobe-info.ts → canvas-webglobe-info.js} +132 -147
- package/programs/totems/{dem-textures-manager.ts → dem-textures-manager.js} +257 -360
- package/programs/totems/{globe-changes.ts → globe-changes.js} +59 -79
- package/programs/totems/gpu-selection-uniform-block.js +99 -127
- package/programs/totems/{index.ts → index.js} +2 -2
- package/programs/two-d/pixel-padding-for-compass.js +87 -101
- package/programs/util.js +14 -19
- package/programs/vectorfields/logics/{constants.ts → constants.js} +4 -5
- package/programs/vectorfields/logics/{drawrectangleparticles.ts → drawrectangleparticles.js} +80 -115
- package/programs/vectorfields/logics/index.js +2 -4
- package/programs/vectorfields/logics/particle-ubo.js +16 -0
- package/programs/vectorfields/logics/{pixelbased.ts → pixelbased.js} +86 -115
- package/programs/vectorfields/logics/ubo.js +51 -57
- package/programs/vectorfields/{pingpongbuffermanager.ts → pingpongbuffermanager.js} +99 -113
- package/range-tools-on-terrain/bearing-line/{adapters.ts → adapters.js} +114 -154
- package/range-tools-on-terrain/bearing-line/{plugin.ts → plugin.js} +457 -569
- package/range-tools-on-terrain/bearing-line/types.js +1 -0
- package/range-tools-on-terrain/circle-line-chain/{adapters.ts → adapters.js} +85 -104
- package/range-tools-on-terrain/circle-line-chain/{chain-list-map.ts → chain-list-map.js} +382 -446
- package/range-tools-on-terrain/circle-line-chain/{plugin.ts → plugin.js} +464 -607
- package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
- package/range-tools-on-terrain/range-ring/{adapters.ts → adapters.js} +93 -114
- package/range-tools-on-terrain/range-ring/{enum.ts → enum.js} +2 -2
- package/range-tools-on-terrain/range-ring/{plugin.ts → plugin.js} +377 -444
- package/range-tools-on-terrain/range-ring/rangeringangletext.js +331 -0
- package/range-tools-on-terrain/range-ring/types.js +9 -0
- package/semiplugins/interface.js +1 -0
- package/semiplugins/lightweight/{line-plugin.ts → line-plugin.js} +221 -342
- package/semiplugins/lightweight/{piece-of-pie-plugin.ts → piece-of-pie-plugin.js} +200 -275
- package/semiplugins/shape-on-terrain/{arc-plugin.ts → arc-plugin.js} +481 -616
- package/semiplugins/shape-on-terrain/{circle-plugin.ts → circle-plugin.js} +444 -588
- package/semiplugins/shape-on-terrain/{padding-1-degree.ts → padding-1-degree.js} +539 -713
- package/semiplugins/shape-on-terrain/terrain-polygon/{adapters.ts → adapters.js} +55 -69
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{cache.ts → cache.js} +102 -149
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{index-polygon-map.ts → index-polygon-map.js} +45 -58
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{manager.ts → manager.js} +4 -4
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.js +177 -196
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{polygon-to-triangles.ts → polygon-to-triangles.js} +100 -144
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{random.ts → random.js} +121 -165
- package/semiplugins/shape-on-terrain/terrain-polygon/data/types.js +1 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{worker-contact.ts → worker-contact.js} +63 -81
- package/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +125 -146
- package/semiplugins/shape-on-terrain/terrain-polygon/{terrain-polygon.ts → terrain-polygon.js} +219 -265
- package/semiplugins/shape-on-terrain/terrain-polygon/types.js +8 -0
- package/semiplugins/shell/bbox-renderer/index.js +2 -0
- package/semiplugins/shell/bbox-renderer/{logic.ts → logic.js} +209 -273
- package/semiplugins/shell/bbox-renderer/object.js +75 -0
- package/semiplugins/type.js +1 -0
- package/semiplugins/utility/{container-plugin.ts → container-plugin.js} +94 -126
- package/semiplugins/utility/{object-pass-container-plugin.ts → object-pass-container-plugin.js} +80 -101
- package/shaders/fragment-toy/firework.js +1 -1
- package/shaders/fragment-toy/singularity.js +2 -5
- package/tracks/point-heat-map/adaptors/timetracksplugin-format-to-this.js +63 -78
- package/tracks/point-heat-map/index.js +1 -0
- package/tracks/point-heat-map/plugin-webworker.js +121 -148
- package/tracks/point-heat-map/point-to-heat-map-flow.js +121 -150
- package/tracks/point-tracks/key-methods.js +2 -3
- package/tracks/point-tracks/plugin.js +401 -487
- package/tracks/timetracks/adaptors-line-strip.js +65 -79
- package/tracks/timetracks/plugin-line-strip.js +240 -295
- package/tracks/timetracks/program-line-strip.js +411 -495
- package/tracks/timetracks/programpoint-line-strip.js +109 -137
- package/types.js +19 -0
- package/util/account/bufferoffsetmanager.js +176 -209
- package/util/account/create-buffermap-orchastration.js +39 -0
- package/util/account/index.js +3 -6
- package/util/account/single-attribute-buffer-management/{buffer-manager.ts → buffer-manager.js} +119 -151
- package/util/account/single-attribute-buffer-management/{buffer-orchestrator.ts → buffer-orchestrator.js} +212 -238
- package/util/account/single-attribute-buffer-management/{buffer-orchestrator1.ts → buffer-orchestrator1.js} +159 -184
- package/util/account/single-attribute-buffer-management/{index.ts → index.js} +4 -11
- package/util/account/single-attribute-buffer-management/{object-store.ts → object-store.js} +55 -76
- package/util/account/single-attribute-buffer-management/types.js +1 -0
- package/util/account/util.js +18 -22
- package/util/algorithms/index.js +1 -0
- package/util/algorithms/search-binary.js +25 -26
- package/util/build-strategy/{static-dynamic.ts → static-dynamic.js} +41 -50
- package/util/check/index.js +1 -0
- package/util/check/typecheck.js +66 -0
- package/util/{frame-counter-trigger.ts → frame-counter-trigger.js} +84 -99
- package/util/geometry/{index.ts → index.js} +121 -155
- package/util/gl-util/buffer/{attribute-loader.ts → attribute-loader.js} +62 -84
- package/util/gl-util/buffer/{index.ts → index.js} +3 -6
- package/util/gl-util/draw-options/{methods.ts → methods.js} +32 -47
- package/util/gl-util/uniform-block/{manager.ts → manager.js} +200 -232
- package/util/{globe-default-gl-states.ts → globe-default-gl-states.js} +4 -5
- package/util/{helper-methods.ts → helper-methods.js} +8 -9
- package/util/index.js +10 -9
- package/util/interpolation/index.js +1 -0
- package/util/interpolation/timetrack/index.js +2 -9
- package/util/interpolation/timetrack/timetrack-interpolator.js +79 -94
- package/util/interpolation/timetrack/web-worker.js +46 -51
- package/util/picking/{fence.ts → fence.js} +43 -47
- package/util/picking/{picker-displayer.ts → picker-displayer.js} +176 -226
- package/util/programs/draw-from-pixel-coords.js +164 -201
- package/util/programs/{draw-texture-on-canvas.ts → draw-texture-on-canvas.js} +69 -91
- package/util/programs/supersampletotextures.js +97 -130
- package/util/programs/texturetoglobe.js +128 -153
- package/util/shaderfunctions/{geometrytransformations.ts → geometrytransformations.js} +44 -106
- package/util/shaderfunctions/index.js +2 -2
- package/util/shaderfunctions/nodata.js +2 -4
- package/util/shaderfunctions/noisefunctions.js +7 -10
- package/util/{webglobjectbuilders.ts → webglobjectbuilders.js} +358 -446
- package/vectorfield/arrowfield/adaptor.js +11 -11
- package/vectorfield/arrowfield/index.js +3 -3
- package/vectorfield/arrowfield/plugin.js +83 -128
- package/vectorfield/waveparticles/adaptor.js +15 -16
- package/vectorfield/waveparticles/index.js +3 -3
- package/vectorfield/waveparticles/{plugin.ts → plugin.js} +415 -506
- package/vectorfield/wind/adapters/{image-to-fields.ts → image-to-fields.js} +61 -74
- package/vectorfield/wind/adapters/types.js +1 -0
- package/vectorfield/wind/{imagetovectorfieldandmagnitude.ts → imagetovectorfieldandmagnitude.js} +53 -78
- package/vectorfield/wind/index.js +5 -5
- package/vectorfield/wind/{plugin-persistant copy.ts → plugin-persistant copy.js } +364 -461
- package/vectorfield/wind/{plugin-persistant.ts → plugin-persistant.js} +375 -483
- package/vectorfield/wind/plugin.js +685 -883
- package/vectorfield/wind/vectorfieldimage.js +23 -27
- package/write-text/{context-text-bulk.ts → context-text-bulk.js} +200 -285
- package/write-text/context-text3.js +167 -0
- package/write-text/{context-text4.ts → context-text4.js} +146 -231
- package/write-text/context-textDELETE.js +94 -125
- package/write-text/objectarraylabels/{index.ts → index.js} +2 -2
- package/write-text/objectarraylabels/objectarraylabels.js +200 -247
- package/Math/matrix4.ts +0 -0
- package/Math/mesh/mapbox-delaunay.d.ts +0 -74
- package/Math/roadmap.md +0 -10
- package/Math/tessellation/constants.ts +0 -1
- package/Math/tessellation/roadmap.md +0 -48
- package/Math/tessellation/types.ts +0 -1
- package/Math/types.ts +0 -68
- package/investigation-tools/draw/tiles/adapters.ts +0 -133
- package/programs/line-on-globe/linestrip/data.ts +0 -29
- package/programs/polygon-on-globe/roadmap.md +0 -8
- package/programs/totems/camera-totem-attactment-interface.ts +0 -4
- package/programs/vectorfields/logics/particle-ubo.ts +0 -23
- package/publish.bat +0 -62
- package/range-tools-on-terrain/bearing-line/types.ts +0 -65
- package/range-tools-on-terrain/circle-line-chain/types.ts +0 -43
- package/range-tools-on-terrain/range-ring/rangeringangletext.ts +0 -396
- package/range-tools-on-terrain/range-ring/types.ts +0 -30
- package/semiplugins/interface.ts +0 -14
- package/semiplugins/shape-on-terrain/goal.md +0 -12
- package/semiplugins/shape-on-terrain/terrain-polygon/data/cache-shortcuts.md +0 -20
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.ts +0 -209
- package/semiplugins/shape-on-terrain/terrain-polygon/data/readme.md +0 -5
- package/semiplugins/shape-on-terrain/terrain-polygon/data/types.ts +0 -37
- package/semiplugins/shape-on-terrain/terrain-polygon/notes.md +0 -90
- package/semiplugins/shape-on-terrain/terrain-polygon/types.ts +0 -69
- package/semiplugins/shell/bbox-renderer/index.ts +0 -2
- package/semiplugins/shell/bbox-renderer/object.ts +0 -129
- package/semiplugins/type.ts +0 -8
- package/terrain-plugin.mmd +0 -83
- package/tests/Math/arc-sampling-test.js +0 -367
- package/tests/Math/arc-sampling-test.ts +0 -429
- package/tests/Math/arc.test.ts +0 -77
- package/tests/Math/junction/arc-limit.test.ts +0 -7
- package/tests/Math/junction/arc-plane-points.test.ts +0 -196
- package/tests/Math/junction/arc-plane.test.ts +0 -172
- package/tests/Math/junction/line-sphere.test.ts +0 -127
- package/tests/Math/junction/plane-plane.test.ts +0 -91
- package/tests/Math/plane-test.ts +0 -17
- package/tests/Math/plane.test.ts +0 -43
- package/tests/Math/vec3.test.ts +0 -33
- package/tracks/point-heat-map/readme.md +0 -15
- package/tracks/timetracks/readme.md +0 -1
- package/tsconfig.json +0 -22
- package/types/@pirireis/webglobe.d.ts +0 -102
- package/types/delaunator.d.ts +0 -40
- package/types/earcut.d.ts +0 -11
- package/types/rbush.d.ts +0 -57
- package/types.ts +0 -319
- package/util/account/create-buffermap-orchastration.ts +0 -85
- package/util/account/single-attribute-buffer-management/types.ts +0 -43
- package/util/check/typecheck.ts +0 -74
- package/vectorfield/wind/adapters/types.ts +0 -12
- package/write-text/context-text3.ts +0 -252
- package/write-text/objectarraylabels/objectarraylabels.d.ts +0 -72
|
@@ -1,200 +1,165 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Author: Toprak Nihat Deniz Ozturk
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {number}
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {number} options.
|
|
20
|
-
* @param {number} options.
|
|
21
|
-
* @param {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this._middleTexture =
|
|
43
|
-
this._blurTextures =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
gl.
|
|
69
|
-
gl.
|
|
70
|
-
|
|
71
|
-
gl.useProgram(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
gl
|
|
128
|
-
gl.
|
|
129
|
-
gl.useProgram(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
gl.useProgram(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* blur uses pingpong effect. This number decides how many times the blur will be applied.
|
|
167
|
-
* @param {+int} repetition
|
|
168
|
-
* @returns
|
|
169
|
-
*/
|
|
170
|
-
setBlurRepetition(repetition) {
|
|
171
|
-
if (repetition < 0 && repetition % 1 !== 0) {
|
|
172
|
-
console.warn("repetition should be an integer greater than 0, but got", repetition);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
this._blurRepetition = repetition;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Head Is colored as white. This number decides proportion of the head according to the total length of the line.
|
|
180
|
-
* @param {Number} percentage 0 ~ 1
|
|
181
|
-
*/
|
|
182
|
-
setHeadPercentage(percentage) {
|
|
183
|
-
if (percentage < 0 || 1 < percentage) {
|
|
184
|
-
console.warn("percentage should be between 0 and 1, but got", percentage);
|
|
185
|
-
return
|
|
186
|
-
};
|
|
187
|
-
const { gl, _lineProgram } = this;
|
|
188
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
189
|
-
gl.useProgram(_lineProgram.program);
|
|
190
|
-
gl.uniform1f(_lineProgram.u_head_percentage, percentage);
|
|
191
|
-
gl.useProgram(currentProgram);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
_createDrawTextureProgram() {
|
|
196
|
-
const gl = this.gl;
|
|
197
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Author: Toprak Nihat Deniz Ozturk
|
|
3
|
+
*/
|
|
4
|
+
// import { createProgram, defaultblendfunction, shaderfunctions } from "../../util";
|
|
5
|
+
import { createProgram } from "../../util/webglobjectbuilders";
|
|
6
|
+
import { defaultblendfunction } from "../../util/globe-default-gl-states";
|
|
7
|
+
import { pixelXYToCartesian2DPoint, pixelXYToCartesian3DPoint, } from "../../util/shaderfunctions";
|
|
8
|
+
export default class TrackGlowLineProgram {
|
|
9
|
+
/**
|
|
10
|
+
* @param {WebGL2RenderingContext} gl
|
|
11
|
+
* @param {number} width
|
|
12
|
+
* @param {number} height
|
|
13
|
+
* @param {Object} options
|
|
14
|
+
* @param {number} options.headPercentage 0 ~ 1
|
|
15
|
+
* @param {number} options.routeAlpha 0 ~ 1
|
|
16
|
+
* @param {Array.<Number>} options.weights [w1, w2, w3, w4, w5]
|
|
17
|
+
* @param {number} options.alphaThreshold 0 ~ 1
|
|
18
|
+
* @param {number} options.exposure 0 ~ inf
|
|
19
|
+
* @param {number} options.gamma 0 ~ inf
|
|
20
|
+
* @param {number} options.finalAlphaRatio 0 ~ 1
|
|
21
|
+
* @param {+int} options.blurRepetition 1 ~ inf default 2
|
|
22
|
+
*/
|
|
23
|
+
constructor(gl, attrBuffer, width, height, options = {}) {
|
|
24
|
+
this.gl = gl;
|
|
25
|
+
this.program = null;
|
|
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 || [0.55, 0.45045946, 0.3216216, 0.254054, 0.056216]);
|
|
53
|
+
gl.useProgram(_combineProgram.program);
|
|
54
|
+
gl.uniform1f(_combineProgram.u_exposure, options.exposure || 1.0);
|
|
55
|
+
gl.uniform1f(_combineProgram.u_gamma, options.gamma || 1.0);
|
|
56
|
+
gl.uniform1f(_combineProgram.u_final_alpha_ratio, options.finalAlphaRatio || 1.0);
|
|
57
|
+
gl.useProgram(currentProgram);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @param {number} gamma 0 ~ inf
|
|
61
|
+
*/
|
|
62
|
+
setGamma(gamma) {
|
|
63
|
+
if (gamma < 0) {
|
|
64
|
+
console.warn("gamma should be equal or greater than 0, but got", gamma);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const { gl, _combineProgram } = this;
|
|
68
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
69
|
+
gl.useProgram(_combineProgram.program);
|
|
70
|
+
gl.uniform1f(_combineProgram.u_gamma, gamma);
|
|
71
|
+
gl.useProgram(currentProgram);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param {number} exposure 0 ~ inf
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
setExposure(exposure) {
|
|
79
|
+
if (exposure < 0) {
|
|
80
|
+
console.warn("exposure should be equal or greater than 0, but got", exposure);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const { gl, _combineProgram } = this;
|
|
84
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
85
|
+
gl.useProgram(_combineProgram.program);
|
|
86
|
+
gl.uniform1f(_combineProgram.u_exposure, exposure);
|
|
87
|
+
gl.useProgram(currentProgram);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param {number} ratio 0 ~ 1
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
94
|
+
setFinalAlphaRatio(ratio) {
|
|
95
|
+
if (ratio < 0 || ratio > 1) {
|
|
96
|
+
console.warn("ratio should be between 0 and 1, but got", ratio);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const { gl, _combineProgram } = this;
|
|
100
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
101
|
+
gl.useProgram(_combineProgram.program);
|
|
102
|
+
gl.uniform1f(_combineProgram.u_final_alpha_ratio, ratio);
|
|
103
|
+
gl.useProgram(currentProgram);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @param {Array.<Number>} weight [w1, w2, w3, w4, w5]
|
|
107
|
+
*/
|
|
108
|
+
setBlurWeights(weights) {
|
|
109
|
+
if (weights.length !== 5) {
|
|
110
|
+
console.warn("weights should be an array of 5 numbers, but got", weights);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const { gl, _blurProgram } = this;
|
|
114
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
115
|
+
gl.useProgram(_blurProgram.program);
|
|
116
|
+
gl.uniform1fv(_blurProgram.u_weight, weights);
|
|
117
|
+
gl.useProgram(currentProgram);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @param {number} routeAlpha 0 ~ 1
|
|
121
|
+
*/
|
|
122
|
+
setRouteAlpha(routeAlpha) {
|
|
123
|
+
if (routeAlpha < 0 || routeAlpha > 1) {
|
|
124
|
+
console.warn("routeAlpha should be between 0 and 1, but got", routeAlpha);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const { gl, _lineProgram } = this;
|
|
128
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
129
|
+
gl.useProgram(_lineProgram.program);
|
|
130
|
+
gl.uniform1f(_lineProgram.u_route_alpha, routeAlpha);
|
|
131
|
+
gl.useProgram(currentProgram);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* blur uses pingpong effect. This number decides how many times the blur will be applied.
|
|
135
|
+
* @param {+int} repetition
|
|
136
|
+
* @returns
|
|
137
|
+
*/
|
|
138
|
+
setBlurRepetition(repetition) {
|
|
139
|
+
if (repetition < 0 && repetition % 1 !== 0) {
|
|
140
|
+
console.warn("repetition should be an integer greater than 0, but got", repetition);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this._blurRepetition = repetition;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Head Is colored as white. This number decides proportion of the head according to the total length of the line.
|
|
147
|
+
* @param {Number} percentage 0 ~ 1
|
|
148
|
+
*/
|
|
149
|
+
setHeadPercentage(percentage) {
|
|
150
|
+
if (percentage < 0 || 1 < percentage) {
|
|
151
|
+
console.warn("percentage should be between 0 and 1, but got", percentage);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
;
|
|
155
|
+
const { gl, _lineProgram } = this;
|
|
156
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
157
|
+
gl.useProgram(_lineProgram.program);
|
|
158
|
+
gl.uniform1f(_lineProgram.u_head_percentage, percentage);
|
|
159
|
+
gl.useProgram(currentProgram);
|
|
160
|
+
}
|
|
161
|
+
_createDrawTextureProgram() {
|
|
162
|
+
const gl = this.gl;
|
|
198
163
|
const vertexShader = `#version 300 es
|
|
199
164
|
precision highp float;
|
|
200
165
|
|
|
@@ -206,8 +171,7 @@ void main() {
|
|
|
206
171
|
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
207
172
|
v_texcoord = a_position.xy * 0.5 + 0.5;
|
|
208
173
|
}
|
|
209
|
-
`;
|
|
210
|
-
|
|
174
|
+
`;
|
|
211
175
|
const fragmentShader = `#version 300 es
|
|
212
176
|
precision highp float;
|
|
213
177
|
|
|
@@ -226,38 +190,33 @@ void main() {
|
|
|
226
190
|
outColor = hdrColor;
|
|
227
191
|
outColor.a *= u_final_alpha_ratio;
|
|
228
192
|
}
|
|
229
|
-
`;
|
|
230
|
-
const program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
gl.
|
|
236
|
-
gl.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
1,
|
|
240
|
-
1, 1,
|
|
241
|
-
|
|
242
|
-
1, 1,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
gl.
|
|
246
|
-
gl.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
_createCombineProgram() {
|
|
259
|
-
const gl = this.gl;
|
|
260
|
-
|
|
193
|
+
`;
|
|
194
|
+
const program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
195
|
+
const buffer = gl.createBuffer();
|
|
196
|
+
const a_position = gl.getAttribLocation(program, "a_position");
|
|
197
|
+
const vao = gl.createVertexArray();
|
|
198
|
+
gl.bindVertexArray(vao);
|
|
199
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
200
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
|
|
201
|
+
-1, -1,
|
|
202
|
+
1, -1,
|
|
203
|
+
1, 1,
|
|
204
|
+
-1, -1,
|
|
205
|
+
1, 1,
|
|
206
|
+
-1, 1,
|
|
207
|
+
]), gl.STATIC_DRAW);
|
|
208
|
+
gl.enableVertexAttribArray(a_position);
|
|
209
|
+
gl.vertexAttribPointer(a_position, 2, gl.FLOAT, false, 0, 0);
|
|
210
|
+
gl.bindVertexArray(null);
|
|
211
|
+
return {
|
|
212
|
+
program: program,
|
|
213
|
+
vao: vao,
|
|
214
|
+
u_main_texture: gl.getUniformLocation(program, "u_main_texture"),
|
|
215
|
+
u_final_alpha_ratio: gl.getUniformLocation(program, "u_final_alpha_ratio"),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
_createCombineProgram() {
|
|
219
|
+
const gl = this.gl;
|
|
261
220
|
const vertexShader = `#version 300 es
|
|
262
221
|
precision highp float;
|
|
263
222
|
|
|
@@ -269,8 +228,7 @@ void main() {
|
|
|
269
228
|
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
270
229
|
v_texcoord = a_position.xy * 0.5 + 0.5;
|
|
271
230
|
}
|
|
272
|
-
`;
|
|
273
|
-
|
|
231
|
+
`;
|
|
274
232
|
const fragmentShader = `#version 300 es
|
|
275
233
|
precision highp float;
|
|
276
234
|
|
|
@@ -294,41 +252,36 @@ void main() {
|
|
|
294
252
|
result.a *= u_final_alpha_ratio;
|
|
295
253
|
outColor = result;
|
|
296
254
|
}
|
|
297
|
-
`;
|
|
298
|
-
const program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
gl.
|
|
304
|
-
gl.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
1,
|
|
308
|
-
1, 1,
|
|
309
|
-
|
|
310
|
-
1, 1,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
gl.
|
|
314
|
-
gl.
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
_createBlurProgram() {
|
|
330
|
-
const gl = this.gl;
|
|
331
|
-
|
|
255
|
+
`;
|
|
256
|
+
const program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
257
|
+
const buffer = gl.createBuffer();
|
|
258
|
+
const a_position = gl.getAttribLocation(program, "a_position");
|
|
259
|
+
const vao = gl.createVertexArray();
|
|
260
|
+
gl.bindVertexArray(vao);
|
|
261
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
262
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
|
|
263
|
+
-1, -1,
|
|
264
|
+
1, -1,
|
|
265
|
+
1, 1,
|
|
266
|
+
-1, -1,
|
|
267
|
+
1, 1,
|
|
268
|
+
-1, 1,
|
|
269
|
+
]), gl.STATIC_DRAW);
|
|
270
|
+
gl.enableVertexAttribArray(a_position);
|
|
271
|
+
gl.vertexAttribPointer(a_position, 2, gl.FLOAT, false, 0, 0);
|
|
272
|
+
gl.bindVertexArray(null);
|
|
273
|
+
return {
|
|
274
|
+
program: program,
|
|
275
|
+
vao: vao,
|
|
276
|
+
u_main_texture: gl.getUniformLocation(program, "u_main_texture"),
|
|
277
|
+
u_bloom_texture: gl.getUniformLocation(program, "u_bloom_texture"),
|
|
278
|
+
u_exposure: gl.getUniformLocation(program, "u_exposure"),
|
|
279
|
+
u_gamma: gl.getUniformLocation(program, "u_gamma"),
|
|
280
|
+
u_final_alpha_ratio: gl.getUniformLocation(program, "u_final_alpha_ratio"),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
_createBlurProgram() {
|
|
284
|
+
const gl = this.gl;
|
|
332
285
|
const vertexShader = `#version 300 es
|
|
333
286
|
precision highp float;
|
|
334
287
|
|
|
@@ -338,7 +291,7 @@ out vec2 v_texcoord;
|
|
|
338
291
|
void main() {
|
|
339
292
|
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
340
293
|
v_texcoord = a_position.xy * 0.5 + 0.5;
|
|
341
|
-
}`;
|
|
294
|
+
}`;
|
|
342
295
|
const fragmentShader = `#version 300 es
|
|
343
296
|
precision highp float;
|
|
344
297
|
|
|
@@ -388,54 +341,45 @@ void main()
|
|
|
388
341
|
}
|
|
389
342
|
outColor = vec4(color, total_alpha);
|
|
390
343
|
}
|
|
391
|
-
`;
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
1, -1,
|
|
401
|
-
1, 1,
|
|
402
|
-
-1,
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
gl.
|
|
408
|
-
gl.
|
|
409
|
-
gl.
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
this.
|
|
430
|
-
gl.useProgram(_lineProgram.program);
|
|
431
|
-
gl.uniform2fv(_lineProgram.u_scrWH, [width, height]);
|
|
432
|
-
gl.useProgram(currentProgram);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
_createLineProgram() {
|
|
436
|
-
|
|
437
|
-
const gl = this.gl;
|
|
438
|
-
|
|
344
|
+
`;
|
|
345
|
+
const program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
346
|
+
const buffer = gl.createBuffer();
|
|
347
|
+
const a_position = gl.getAttribLocation(program, "a_position");
|
|
348
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
349
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
|
|
350
|
+
-1, -1,
|
|
351
|
+
1, -1,
|
|
352
|
+
1, 1,
|
|
353
|
+
-1, -1,
|
|
354
|
+
1, 1,
|
|
355
|
+
-1, 1,
|
|
356
|
+
]), gl.STATIC_DRAW);
|
|
357
|
+
const vao = gl.createVertexArray();
|
|
358
|
+
gl.bindVertexArray(vao);
|
|
359
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
360
|
+
gl.enableVertexAttribArray(a_position);
|
|
361
|
+
gl.vertexAttribPointer(a_position, 2, gl.FLOAT, false, 0, 0);
|
|
362
|
+
gl.bindVertexArray(null);
|
|
363
|
+
return {
|
|
364
|
+
program: program,
|
|
365
|
+
vao: vao,
|
|
366
|
+
u_texture: gl.getUniformLocation(program, "u_texture"),
|
|
367
|
+
u_horizontal: gl.getUniformLocation(program, "u_horizontal"),
|
|
368
|
+
u_weight: gl.getUniformLocation(program, "u_weight"),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
resize(width, height) {
|
|
372
|
+
const { gl, _lineProgram } = this;
|
|
373
|
+
this._width = width;
|
|
374
|
+
this._height = height;
|
|
375
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
376
|
+
this._createInnerTextures();
|
|
377
|
+
gl.useProgram(_lineProgram.program);
|
|
378
|
+
gl.uniform2fv(_lineProgram.u_scrWH, [width, height]);
|
|
379
|
+
gl.useProgram(currentProgram);
|
|
380
|
+
}
|
|
381
|
+
_createLineProgram() {
|
|
382
|
+
const gl = this.gl;
|
|
439
383
|
const vertexShader = `#version 300 es
|
|
440
384
|
precision highp float;
|
|
441
385
|
|
|
@@ -474,8 +418,7 @@ void main() {
|
|
|
474
418
|
gl_Position = uProjectionMatrix * vec4(xy.x, xy.y, 0.0, 1.0);
|
|
475
419
|
}
|
|
476
420
|
}
|
|
477
|
-
`;
|
|
478
|
-
|
|
421
|
+
`;
|
|
479
422
|
const fragmentShader = `#version 300 es
|
|
480
423
|
precision lowp float;
|
|
481
424
|
|
|
@@ -514,179 +457,152 @@ void main() {
|
|
|
514
457
|
}
|
|
515
458
|
outColor0 = vec4(v_color , 1.0);
|
|
516
459
|
}
|
|
517
|
-
`;
|
|
518
|
-
const program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
519
|
-
const a_position = gl.getAttribLocation(program, "a_position");
|
|
520
|
-
const a_time = gl.getAttribLocation(program, "a_time");
|
|
521
|
-
const a_track_start_time = gl.getAttribLocation(program, "a_track_start_time");
|
|
522
|
-
const a_track_end_time = gl.getAttribLocation(program, "a_track_end_time");
|
|
523
|
-
const a_color = gl.getAttribLocation(program, "a_color");
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
gl.
|
|
527
|
-
gl.
|
|
528
|
-
gl.
|
|
529
|
-
gl.
|
|
530
|
-
gl.
|
|
531
|
-
gl.
|
|
532
|
-
gl.
|
|
533
|
-
gl.
|
|
534
|
-
gl.
|
|
535
|
-
gl.
|
|
536
|
-
gl.
|
|
537
|
-
gl.
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
//
|
|
560
|
-
//
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
gl
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
const
|
|
585
|
-
gl.bindTexture(gl.TEXTURE_2D,
|
|
586
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
587
|
-
gl.
|
|
588
|
-
gl.
|
|
589
|
-
gl.
|
|
590
|
-
gl.
|
|
591
|
-
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
gl.
|
|
598
|
-
|
|
599
|
-
gl.
|
|
600
|
-
gl.
|
|
601
|
-
gl.
|
|
602
|
-
gl.
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
gl.
|
|
617
|
-
gl.
|
|
618
|
-
gl.
|
|
619
|
-
gl.drawBuffers([
|
|
620
|
-
gl.COLOR_ATTACHMENT0,
|
|
621
|
-
gl.
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
gl.useProgram(
|
|
625
|
-
gl.
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
gl.
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
gl.
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
gl.
|
|
637
|
-
gl.
|
|
638
|
-
gl.
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
gl.
|
|
645
|
-
gl.bindVertexArray(
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
gl.
|
|
657
|
-
gl.
|
|
658
|
-
gl.
|
|
659
|
-
gl.
|
|
660
|
-
gl.
|
|
661
|
-
gl.
|
|
662
|
-
gl.
|
|
663
|
-
gl.
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
gl.bindVertexArray(null);
|
|
669
|
-
defaultblendfunction(gl)
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
free() {
|
|
675
|
-
const { gl, _lineProgram, _blurProgram, _combineProgram } = this;
|
|
676
|
-
gl.deleteBuffer(this._inBuffer);
|
|
677
|
-
gl.deleteFramebuffer(this._frameBuffer);
|
|
678
|
-
gl.deleteFramebuffer(this._blurFrameBuffers[0]);
|
|
679
|
-
gl.deleteFramebuffer(this._blurFrameBuffers[1]);
|
|
680
|
-
// gl.deleteBuffer(this._middleTexture);
|
|
681
|
-
gl.deleteTexture(this._middleTexture);
|
|
682
|
-
gl.deleteTexture(this._blurTextures[0]);
|
|
683
|
-
gl.deleteTexture(this._blurTextures[1]);
|
|
684
|
-
gl.deleteVertexArray(_lineProgram.vao);
|
|
685
|
-
gl.deleteVertexArray(_blurProgram.vao);
|
|
686
|
-
gl.deleteVertexArray(_combineProgram.vao);
|
|
687
|
-
gl.deleteProgram(_lineProgram.program);
|
|
688
|
-
gl.deleteProgram(_blurProgram.program);
|
|
689
|
-
gl.deleteProgram(_combineProgram.program);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
|
|
460
|
+
`;
|
|
461
|
+
const program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
462
|
+
const a_position = gl.getAttribLocation(program, "a_position");
|
|
463
|
+
const a_time = gl.getAttribLocation(program, "a_time");
|
|
464
|
+
const a_track_start_time = gl.getAttribLocation(program, "a_track_start_time");
|
|
465
|
+
const a_track_end_time = gl.getAttribLocation(program, "a_track_end_time");
|
|
466
|
+
const a_color = gl.getAttribLocation(program, "a_color");
|
|
467
|
+
const vao = gl.createVertexArray();
|
|
468
|
+
gl.bindVertexArray(vao);
|
|
469
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._inBuffer);
|
|
470
|
+
gl.enableVertexAttribArray(a_position);
|
|
471
|
+
gl.vertexAttribPointer(a_position, 3, gl.FLOAT, false, 36, 0);
|
|
472
|
+
gl.enableVertexAttribArray(a_time);
|
|
473
|
+
gl.vertexAttribPointer(a_time, 1, gl.FLOAT, false, 36, 12);
|
|
474
|
+
gl.enableVertexAttribArray(a_color);
|
|
475
|
+
gl.vertexAttribPointer(a_color, 3, gl.FLOAT, false, 36, 16);
|
|
476
|
+
gl.enableVertexAttribArray(a_track_start_time);
|
|
477
|
+
gl.vertexAttribPointer(a_track_start_time, 1, gl.FLOAT, false, 36, 28);
|
|
478
|
+
gl.enableVertexAttribArray(a_track_end_time);
|
|
479
|
+
gl.vertexAttribPointer(a_track_end_time, 1, gl.FLOAT, false, 36, 32);
|
|
480
|
+
gl.bindVertexArray(null);
|
|
481
|
+
return {
|
|
482
|
+
program: program,
|
|
483
|
+
vao: vao,
|
|
484
|
+
u_head_time: gl.getUniformLocation(program, "u_head_time"),
|
|
485
|
+
u_tail_time: gl.getUniformLocation(program, "u_tail_time"),
|
|
486
|
+
uTranslate: gl.getUniformLocation(program, "uTranslate"),
|
|
487
|
+
uModelViewMatrix: gl.getUniformLocation(program, "uModelViewMatrix"),
|
|
488
|
+
uProjectionMatrix: gl.getUniformLocation(program, "uProjectionMatrix"),
|
|
489
|
+
u_is_3d: gl.getUniformLocation(program, "u_is_3d"),
|
|
490
|
+
u_mapWH: gl.getUniformLocation(program, "u_mapWH"),
|
|
491
|
+
u_scrWH: gl.getUniformLocation(program, "u_scrWH"),
|
|
492
|
+
u_head_percentage: gl.getUniformLocation(program, "u_head_percentage"),
|
|
493
|
+
u_route_alpha: gl.getUniformLocation(program, "u_route_alpha"),
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* @param { Float32Array} data // [x, y, z, time, x, y, z, time, ...]
|
|
498
|
+
*/
|
|
499
|
+
// setInBuffer(data) {
|
|
500
|
+
// const gl = this.gl;
|
|
501
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, this._inBuffer);
|
|
502
|
+
// gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
|
503
|
+
// }
|
|
504
|
+
setIs3D(is3d) {
|
|
505
|
+
const { gl, _lineProgram } = this;
|
|
506
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
507
|
+
gl.useProgram(_lineProgram.program);
|
|
508
|
+
gl.uniform1i(_lineProgram.u_is_3d, is3d);
|
|
509
|
+
gl.useProgram(currentProgram);
|
|
510
|
+
}
|
|
511
|
+
setTotalLength(totalLength) {
|
|
512
|
+
this._totalLength = totalLength;
|
|
513
|
+
}
|
|
514
|
+
_createTextures() {
|
|
515
|
+
const { gl, _width, _height } = this;
|
|
516
|
+
const texture = gl.createTexture();
|
|
517
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
518
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); // UNSIGNED_BYTE
|
|
519
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
520
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
521
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
522
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
523
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
524
|
+
return texture;
|
|
525
|
+
}
|
|
526
|
+
_resetTexture() {
|
|
527
|
+
const { gl, _width, _height } = this;
|
|
528
|
+
gl.bindTexture(gl.TEXTURE_2D, this._middleTexture); // UNSIGNED_BYTE
|
|
529
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
530
|
+
gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[0]);
|
|
531
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
532
|
+
gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[1]);
|
|
533
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
534
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
535
|
+
}
|
|
536
|
+
draw(u_head_time, u_tail_time, uProjectionMatrix, uModelViewMatrix, uTranslate, u_mapWH = null) {
|
|
537
|
+
const { gl, _lineProgram, _blurProgram, _blurRepetition } = this;
|
|
538
|
+
this._resetTexture();
|
|
539
|
+
gl.enable(gl.BLEND);
|
|
540
|
+
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
541
|
+
// draw lines
|
|
542
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
543
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._middleTexture, 0);
|
|
544
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT1, gl.TEXTURE_2D, this._blurTextures[0], 0);
|
|
545
|
+
gl.drawBuffers([
|
|
546
|
+
gl.COLOR_ATTACHMENT0,
|
|
547
|
+
gl.COLOR_ATTACHMENT1,
|
|
548
|
+
]);
|
|
549
|
+
gl.useProgram(_lineProgram.program);
|
|
550
|
+
gl.uniform1f(_lineProgram.u_head_time, u_head_time);
|
|
551
|
+
gl.uniform1f(_lineProgram.u_tail_time, u_tail_time);
|
|
552
|
+
gl.uniformMatrix4fv(_lineProgram.uProjectionMatrix, false, uProjectionMatrix);
|
|
553
|
+
if (u_mapWH) {
|
|
554
|
+
gl.uniform2fv(_lineProgram.u_mapWH, u_mapWH);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
gl.uniformMatrix4fv(_lineProgram.uModelViewMatrix, false, uModelViewMatrix);
|
|
558
|
+
}
|
|
559
|
+
gl.uniform3fv(_lineProgram.uTranslate, uTranslate);
|
|
560
|
+
gl.bindVertexArray(_lineProgram.vao);
|
|
561
|
+
gl.drawArrays(gl.LINE_STRIP, 0, this._totalLength);
|
|
562
|
+
gl.drawBuffers([
|
|
563
|
+
gl.COLOR_ATTACHMENT0,
|
|
564
|
+
gl.NONE
|
|
565
|
+
]);
|
|
566
|
+
// blur ping pong
|
|
567
|
+
gl.useProgram(_blurProgram.program);
|
|
568
|
+
gl.bindVertexArray(_blurProgram.vao);
|
|
569
|
+
for (let i = 0; i < _blurRepetition * 2; i++) {
|
|
570
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._blurFrameBuffers[i % 2]);
|
|
571
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._blurTextures[(i + 1) % 2], 0);
|
|
572
|
+
gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[i % 2]);
|
|
573
|
+
gl.uniform1i(_blurProgram.u_texture, 0);
|
|
574
|
+
gl.uniform1f(_blurProgram.u_horizontal, i % 2 === 0);
|
|
575
|
+
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
576
|
+
}
|
|
577
|
+
// combine
|
|
578
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
579
|
+
gl.useProgram(this._combineProgram.program);
|
|
580
|
+
gl.bindVertexArray(this._combineProgram.vao);
|
|
581
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
582
|
+
gl.bindTexture(gl.TEXTURE_2D, this._blurTextures[1]);
|
|
583
|
+
gl.uniform1i(this._combineProgram.u_bloom_texture, 1);
|
|
584
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
585
|
+
gl.bindTexture(gl.TEXTURE_2D, this._middleTexture);
|
|
586
|
+
gl.uniform1i(this._combineProgram.u_main_texture, 0);
|
|
587
|
+
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
588
|
+
gl.bindVertexArray(null);
|
|
589
|
+
defaultblendfunction(gl);
|
|
590
|
+
}
|
|
591
|
+
free() {
|
|
592
|
+
const { gl, _lineProgram, _blurProgram, _combineProgram } = this;
|
|
593
|
+
gl.deleteBuffer(this._inBuffer);
|
|
594
|
+
gl.deleteFramebuffer(this._frameBuffer);
|
|
595
|
+
gl.deleteFramebuffer(this._blurFrameBuffers[0]);
|
|
596
|
+
gl.deleteFramebuffer(this._blurFrameBuffers[1]);
|
|
597
|
+
// gl.deleteBuffer(this._middleTexture);
|
|
598
|
+
gl.deleteTexture(this._middleTexture);
|
|
599
|
+
gl.deleteTexture(this._blurTextures[0]);
|
|
600
|
+
gl.deleteTexture(this._blurTextures[1]);
|
|
601
|
+
gl.deleteVertexArray(_lineProgram.vao);
|
|
602
|
+
gl.deleteVertexArray(_blurProgram.vao);
|
|
603
|
+
gl.deleteVertexArray(_combineProgram.vao);
|
|
604
|
+
gl.deleteProgram(_lineProgram.program);
|
|
605
|
+
gl.deleteProgram(_blurProgram.program);
|
|
606
|
+
gl.deleteProgram(_combineProgram.program);
|
|
607
|
+
}
|
|
608
|
+
}
|