@pirireis/webglobeplugins 0.9.11 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Math/angle-calculation.js +9 -11
- package/Math/arc.js +38 -41
- package/Math/bounds/line-bbox.js +79 -83
- package/Math/constants.js +4 -9
- package/Math/frustum/types.js +1 -2
- package/Math/juction/arc-plane.js +33 -36
- package/Math/juction/line-sphere.js +15 -18
- package/Math/juction/plane-plane.js +20 -23
- package/Math/line.js +42 -47
- package/Math/methods.js +69 -92
- package/Math/plane.js +33 -38
- package/Math/quaternion.js +48 -55
- package/Math/types.js +1 -2
- package/Math/utils.js +2 -4
- package/Math/vec3.js +46 -52
- package/algorithms/search-binary.js +5 -8
- package/altitude-locator/draw-subset-obj.js +8 -11
- package/altitude-locator/plugin.js +114 -133
- package/altitude-locator/types.js +1 -3
- package/arrowfield/adaptor.js +3 -7
- package/arrowfield/index.js +3 -10
- package/arrowfield/plugin.js +63 -69
- package/bearing-line/index.js +2 -8
- package/bearing-line/plugin.js +218 -248
- package/circle-line-chain/chain-list-map.js +82 -92
- package/circle-line-chain/plugin.js +147 -182
- package/circle-line-chain/util.js +1 -5
- package/compass-rose/compass-rose-padding-flat.js +111 -140
- package/compass-rose/compass-text-writer.js +63 -75
- package/compass-rose/index.js +3 -7
- package/compassrose/compassrose.js +50 -57
- package/compassrose/index.js +2 -8
- package/heatwave/index.js +3 -10
- package/heatwave/isobar/objectarraylabels.js +50 -56
- package/heatwave/isobar/plugin.js +111 -170
- package/heatwave/isobar/quadtreecontours.js +78 -96
- package/heatwave/plugins/heatwaveglobeshell.js +73 -94
- package/index.js +12 -58
- package/package.json +1 -1
- package/partialrings/buffer-manager.js +32 -70
- package/partialrings/index.js +2 -41
- package/partialrings/plugin.js +55 -98
- package/partialrings/program.js +141 -59
- package/pin/pin-object-array.js +89 -97
- package/pin/pin-point-totem.js +21 -22
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +11 -14
- package/point-heat-map/plugin-webworker.js +45 -53
- package/point-heat-map/point-to-heat-map-flow.js +46 -51
- package/point-tracks/key-methods.js +2 -5
- package/point-tracks/plugin.js +141 -170
- package/programs/arrowfield/index.js +2 -7
- package/programs/arrowfield/logic.js +172 -67
- package/programs/arrowfield/object.js +35 -43
- package/programs/data2legend/density-to-legend.js +47 -26
- package/programs/data2legend/point-to-density-texture.js +56 -34
- package/programs/float2legendwithratio/index.js +2 -8
- package/programs/float2legendwithratio/logic.js +88 -45
- package/programs/float2legendwithratio/object.js +45 -54
- package/programs/globe-util/is-globe-moved.js +10 -13
- package/programs/globeshell/index.js +2 -8
- package/programs/globeshell/wiggle/index.js +2 -8
- package/programs/globeshell/wiggle/logic.js +191 -101
- package/programs/globeshell/wiggle/object.js +35 -43
- package/programs/helpers/blender/program.js +36 -22
- package/programs/helpers/fadeaway/index.js +2 -7
- package/programs/helpers/fadeaway/logic.js +36 -17
- package/programs/helpers/fadeaway/object.js +11 -18
- package/programs/helpers/index.js +2 -8
- package/programs/index.js +9 -58
- package/programs/line-on-globe/angled-line.js +95 -39
- package/programs/line-on-globe/circle-accurate-3d.js +86 -39
- package/programs/line-on-globe/circle-accurate-flat.js +116 -64
- package/programs/line-on-globe/circle-accurate.js +113 -46
- package/programs/line-on-globe/circle.js +106 -44
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +89 -42
- package/programs/line-on-globe/lines-color-instanced-flat.js +84 -43
- package/programs/line-on-globe/linestrip.js +126 -63
- package/programs/line-on-globe/naive-accurate-flexible.js +126 -59
- package/programs/line-on-globe/to-the-surface.js +62 -35
- package/programs/line-on-globe/util.js +2 -5
- package/programs/picking/pickable-renderer.js +127 -46
- package/programs/point-on-globe/element-globe-surface-glow.js +83 -46
- package/programs/point-on-globe/element-point-glow.js +112 -47
- package/programs/point-on-globe/square-pixel-point.js +80 -34
- package/programs/programcache.js +14 -19
- package/programs/rings/distancering/circleflatprogram.js +76 -70
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +168 -194
- package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -200
- package/programs/rings/distancering/index.js +5 -14
- package/programs/rings/distancering/paddyflatprogram.js +87 -70
- package/programs/rings/distancering/paddyflatprogram2d.js +89 -72
- package/programs/rings/distancering/paddyflatprogram3d.js +87 -70
- package/programs/rings/index.js +1 -17
- package/programs/rings/partial-ring/piece-of-pie.js +144 -44
- package/programs/totems/camerauniformblock.js +65 -56
- package/programs/totems/canvas-webglobe-info.js +49 -45
- package/programs/totems/gpu-selection-uniform-block.js +45 -45
- package/programs/totems/index.js +2 -40
- package/programs/two-d/pixel-padding-for-compass.js +94 -36
- package/programs/util.js +7 -10
- package/programs/vectorfields/index.js +3 -23
- package/programs/vectorfields/logics/drawrectangleparticles.js +73 -35
- package/programs/vectorfields/logics/index.js +4 -12
- package/programs/vectorfields/logics/pixelbased.js +94 -41
- package/programs/vectorfields/logics/ubo.js +32 -32
- package/programs/vectorfields/pingpongbuffermanager.js +30 -37
- package/rangerings/enum.js +2 -5
- package/rangerings/index.js +5 -15
- package/rangerings/plugin.js +223 -286
- package/rangerings/rangeringangletext.js +122 -137
- package/rangerings/ring-account.js +53 -75
- package/shaders/fragment-toy/firework.js +55 -4
- package/shaders/fragment-toy/singularity.js +56 -5
- package/timetracks/adaptors-line-strip.js +27 -44
- package/timetracks/adaptors.js +48 -67
- package/timetracks/index.js +5 -19
- package/timetracks/plugin-line-strip.js +65 -79
- package/timetracks/plugin.js +71 -85
- package/timetracks/program-line-strip.js +297 -107
- package/timetracks/program.js +421 -118
- package/timetracks/programpoint-line-strip.js +98 -48
- package/timetracks/programpoint.js +91 -48
- package/util/account/bufferoffsetmanager.js +72 -98
- package/util/account/index.js +3 -23
- package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -48
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -98
- package/util/account/single-attribute-buffer-management/index.js +4 -9
- package/util/account/single-attribute-buffer-management/object-store.js +29 -34
- package/util/account/single-attribute-buffer-management/types.js +1 -2
- package/util/account/util.js +2 -8
- package/util/algorithms/search-binary.js +5 -8
- package/util/check/get.js +5 -9
- package/util/check/typecheck.js +13 -24
- package/util/geometry/index.js +10 -18
- package/util/gl-util/buffer/attribute-loader.js +10 -26
- package/util/gl-util/buffer/index.js +2 -5
- package/util/gl-util/draw-options/methods.js +10 -15
- package/util/gl-util/uniform-block/manager.js +69 -72
- package/util/heatwavedatamanager/datamanager.js +56 -119
- package/util/heatwavedatamanager/index.js +3 -10
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +38 -47
- package/util/heatwavedatamanager/pointcoordsmeta.js +9 -13
- package/util/index.js +13 -57
- package/util/interpolation/timetrack/index.js +2 -5
- package/util/interpolation/timetrack/timetrack-interpolator.js +30 -36
- package/util/interpolation/timetrack/web-worker-str.js +180 -5
- package/util/interpolation/timetrack/web-worker.js +4 -6
- package/util/jshelpers/data-filler.js +8 -11
- package/util/jshelpers/equality.js +1 -3
- package/util/jshelpers/index.js +2 -37
- package/util/jshelpers/timefilters.js +8 -10
- package/util/picking/fence.js +8 -11
- package/util/picking/picker-displayer.js +49 -58
- package/util/programs/draw-texture-on-canvas.js +41 -26
- package/util/programs/index.js +1 -17
- package/util/programs/shapesonglobe.js +104 -68
- package/util/programs/supersampletotextures.js +45 -43
- package/util/programs/texturetoglobe.js +99 -52
- package/util/shaderfunctions/geometrytransformations.js +323 -35
- package/util/shaderfunctions/index.js +2 -18
- package/util/shaderfunctions/nodata.js +8 -5
- package/util/shaderfunctions/noisefunctions.js +40 -12
- package/util/surface-line-data/arcs-to-cuts.js +20 -23
- package/util/webglobe/gldefaultstates.js +1 -4
- package/util/webglobe/index.js +2 -18
- package/util/webglobe/rasteroverlay.js +36 -41
- package/util/webglobjectbuilders.js +70 -93
- package/util/webglobjectbuilders1.js +63 -82
- package/waveparticles/adaptor.js +7 -10
- package/waveparticles/index.js +3 -10
- package/waveparticles/plugin.js +82 -90
- package/wind/imagetovectorfieldandmagnitude.js +16 -19
- package/wind/index.js +5 -14
- package/wind/plugin.js +454 -291
- package/wind/vectorfieldimage.js +6 -8
- package/write-text/attached-text-writer.js +48 -54
- package/write-text/context-text.js +52 -63
- package/write-text/context-text3.js +71 -80
- package/write-text/index.js +1 -5
|
@@ -1,12 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { createProgram } from "../../util";
|
|
2
|
+
import { globeProgramCache } from "../programcache";
|
|
3
|
+
import { CameraUniformBlockTotem } from "../totems";
|
|
4
|
+
const arrowVertexShader = `#version 300 es
|
|
5
|
+
#define R 6378.137
|
|
6
|
+
#define PI 3.1415926535897932384626433832795
|
|
7
|
+
#define POLE 20037508.34
|
|
8
|
+
#define POLE_BY_PI 6366198.2
|
|
9
|
+
#define HALF_PI 1.5707963267948966192313216916398
|
|
10
|
+
|
|
11
|
+
uniform sampler2D rotation; // rotation of arrow
|
|
12
|
+
|
|
13
|
+
out vec4 v_color;
|
|
14
|
+
|
|
15
|
+
layout(std140) uniform CameraBlock {
|
|
16
|
+
mat4 u_view;
|
|
17
|
+
mat4 u_projection;
|
|
18
|
+
vec3 u_translate;
|
|
19
|
+
bool u_is3D;
|
|
20
|
+
vec2 u_mapWH;
|
|
21
|
+
vec2 u_scrWH;
|
|
22
|
+
float u_zlevel;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
layout(std140) uniform ArrowBlock {
|
|
26
|
+
vec4 u_color;
|
|
27
|
+
vec2 u_bbox_offset_rad;
|
|
28
|
+
vec2 u_bbox_size_rad;
|
|
29
|
+
vec2 u_resolution;
|
|
30
|
+
float u_length_ratio;
|
|
31
|
+
float u_width_ratio;
|
|
32
|
+
float u_height;
|
|
33
|
+
float u_no_data_value;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
vec2 f_texCoord(){
|
|
37
|
+
float fID = float(gl_InstanceID);
|
|
38
|
+
float x = mod( fID, u_resolution.x ) / ( u_resolution.x - 1.0);
|
|
39
|
+
float y = 1.0 - floor( fID / u_resolution.x ) / ( u_resolution.y - 1.0);
|
|
40
|
+
return vec2(x, y);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
vec2 f_radCoord(vec2 texCoord){
|
|
44
|
+
float x = (texCoord.x * u_bbox_size_rad.x ) + u_bbox_offset_rad.x;
|
|
45
|
+
float y = (texCoord.y * u_bbox_size_rad.y ) + u_bbox_offset_rad.y;
|
|
46
|
+
return vec2(x, y);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
vec3 f_onSphere(vec2 radCoord){
|
|
50
|
+
float x = sin(radCoord.y) * cos(radCoord.x);
|
|
51
|
+
float y = sin(radCoord.y) * sin(radCoord.x);
|
|
52
|
+
float z = cos(radCoord.y);
|
|
53
|
+
return vec3(x, y, z) * (R + u_height);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
vec2 f_onFlat(vec2 radCoord){
|
|
58
|
+
float mercX = radCoord.x * POLE_BY_PI;
|
|
59
|
+
float mercY = log(tan(HALF_PI - radCoord.y * 0.5)) * POLE_BY_PI;
|
|
60
|
+
float normX = ( mercX - u_translate.x ) / u_mapWH.x;
|
|
61
|
+
float normY = ( mercY - u_translate.y ) / u_mapWH.y;
|
|
62
|
+
return vec2(normX, normY);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
void main() {
|
|
66
|
+
// escape if no data
|
|
67
|
+
vec2 texCoord = f_texCoord();
|
|
68
|
+
vec2 geoCoord = vec2( texCoord.x , 1.0 - texCoord.y );
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
float angle = texture(rotation, texCoord).r;
|
|
72
|
+
|
|
73
|
+
if ( angle == u_no_data_value ) {
|
|
74
|
+
gl_Position = vec4(-2.0, -2.0, 0.0, 1.0);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
vec2 arrowLimb;
|
|
78
|
+
if (0.0 == mod(float(gl_VertexID), 2.0)) {
|
|
79
|
+
arrowLimb = vec2(0.0, 0.0);
|
|
80
|
+
} else if (gl_VertexID == 1) {
|
|
81
|
+
// tail
|
|
82
|
+
arrowLimb = vec2( cos(angle), sin(angle)) * u_length_ratio / (170.0 );
|
|
83
|
+
} else if (gl_VertexID == 3) {
|
|
84
|
+
// right wing
|
|
85
|
+
arrowLimb = vec2( cos(angle + 0.45), sin(angle + 0.45)) * u_width_ratio / (170.0 );
|
|
86
|
+
} else if (gl_VertexID == 5) {
|
|
87
|
+
// left wing
|
|
88
|
+
arrowLimb = vec2( cos(angle - 0.45), sin(angle - 0.45)) * u_width_ratio / (170.0 );
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
vec2 radCoord = f_radCoord(geoCoord + arrowLimb);
|
|
93
|
+
if ( u_is3D ) {
|
|
94
|
+
vec3 spherePos = f_onSphere(radCoord);
|
|
95
|
+
gl_Position = u_projection * u_view * vec4(spherePos - u_translate, 1.0);
|
|
96
|
+
} else {
|
|
97
|
+
vec2 flatPos = f_onFlat(radCoord);
|
|
98
|
+
gl_Position = u_projection * vec4(
|
|
99
|
+
flatPos.x * u_scrWH.x,
|
|
100
|
+
(1.0 - flatPos.y) * u_scrWH.y,
|
|
101
|
+
0.0, 1.0
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
v_color = u_color;
|
|
107
|
+
gl_PointSize = 4.0;
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
110
|
+
const arrowFragmentShader = `#version 300 es
|
|
111
|
+
precision highp float;
|
|
112
|
+
in vec4 v_color;
|
|
113
|
+
out vec4 outColor;
|
|
114
|
+
|
|
115
|
+
void main() {
|
|
116
|
+
outColor = v_color;
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
export default class ArrowFieldLogic {
|
|
120
|
+
constructor() {
|
|
10
121
|
this.gl = null;
|
|
11
122
|
this.globe = null;
|
|
12
123
|
this.cameraUniformBlockTotem = null;
|
|
@@ -14,34 +125,34 @@ var ArrowFieldLogic = /** @class */ (function () {
|
|
|
14
125
|
this.cameraBlockBindingPoint = 0;
|
|
15
126
|
this.arrayBlockBindingPoint = 1;
|
|
16
127
|
}
|
|
17
|
-
|
|
128
|
+
init(globe, gl) {
|
|
18
129
|
this.gl = gl;
|
|
19
130
|
this.globe = globe;
|
|
20
|
-
this.cameraUniformBlockTotem =
|
|
131
|
+
this.cameraUniformBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
|
|
21
132
|
this.program = this._createProgram();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
133
|
+
}
|
|
134
|
+
_createProgram() {
|
|
135
|
+
const gl = this.gl;
|
|
136
|
+
const program = createProgram(gl, arrowVertexShader, arrowFragmentShader);
|
|
137
|
+
const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraBlock");
|
|
27
138
|
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
28
|
-
|
|
139
|
+
const arrowBlockIndex = gl.getUniformBlockIndex(program, "ArrowBlock");
|
|
29
140
|
gl.uniformBlockBinding(program, arrowBlockIndex, this.arrayBlockBindingPoint);
|
|
30
141
|
this.textureLocations = {
|
|
31
142
|
rotationLocation: gl.getUniformLocation(program, "rotation"),
|
|
32
143
|
};
|
|
33
144
|
return program;
|
|
34
|
-
}
|
|
35
|
-
|
|
145
|
+
}
|
|
146
|
+
getArrowBlockBufferManager() {
|
|
36
147
|
return new ArrowBlockBufferManager(this.gl, this.arrayBlockBindingPoint);
|
|
37
|
-
}
|
|
148
|
+
}
|
|
38
149
|
// initial load type is static.
|
|
39
150
|
// after that, it is dynamic.
|
|
40
|
-
|
|
151
|
+
getTextureManager(width, height) {
|
|
41
152
|
return new TextureManager(this.gl, width, height, this.textureLocations);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
153
|
+
}
|
|
154
|
+
draw(arrowBlockManager, textureManager, instanceCount) {
|
|
155
|
+
const { gl, cameraBlockBindingPoint, cameraUniformBlockTotem } = this;
|
|
45
156
|
gl.useProgram(this.program);
|
|
46
157
|
arrowBlockManager.bind();
|
|
47
158
|
textureManager.activate();
|
|
@@ -50,17 +161,15 @@ var ArrowFieldLogic = /** @class */ (function () {
|
|
|
50
161
|
// gl.drawArraysInstanced(gl.POINTS, 0, 4, instanceCount);
|
|
51
162
|
cameraUniformBlockTotem.unbind(cameraBlockBindingPoint);
|
|
52
163
|
arrowBlockManager.unbind();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
164
|
+
}
|
|
165
|
+
free() {
|
|
166
|
+
const { gl, program } = this;
|
|
56
167
|
gl.deleteProgram(program);
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var ArrowBlockBufferManager = /** @class */ (function () {
|
|
63
|
-
function ArrowBlockBufferManager(gl, bindingPoint) {
|
|
168
|
+
globeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
class ArrowBlockBufferManager {
|
|
172
|
+
constructor(gl, bindingPoint) {
|
|
64
173
|
this.gl = gl;
|
|
65
174
|
this.bindingPoint = bindingPoint;
|
|
66
175
|
this.ubo = gl.createBuffer();
|
|
@@ -69,9 +178,8 @@ var ArrowBlockBufferManager = /** @class */ (function () {
|
|
|
69
178
|
gl.bufferData(gl.UNIFORM_BUFFER, 56, gl.DYNAMIC_DRAW);
|
|
70
179
|
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
71
180
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
var _m = this, gl = _m.gl, ubo = _m.ubo;
|
|
181
|
+
update({ color = null, bboxOffsetRad = null, bboxSizeRad = null, resolution = null, tailLengthRatio = null, wingLengthRatio = null, height = null, opacity = null, noDataValue = null, } = {}) {
|
|
182
|
+
const { gl, ubo } = this;
|
|
75
183
|
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
76
184
|
if (color !== null)
|
|
77
185
|
gl.bufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array(color));
|
|
@@ -92,58 +200,55 @@ var ArrowBlockBufferManager = /** @class */ (function () {
|
|
|
92
200
|
if (noDataValue !== null)
|
|
93
201
|
gl.bufferSubData(gl.UNIFORM_BUFFER, 52, new Float32Array([noDataValue]));
|
|
94
202
|
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
203
|
+
}
|
|
204
|
+
bind() {
|
|
205
|
+
const { gl, ubo, bindingPoint } = this;
|
|
98
206
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, ubo);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
207
|
+
}
|
|
208
|
+
unbind() {
|
|
209
|
+
const { gl, bindingPoint } = this;
|
|
102
210
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, null);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
211
|
+
}
|
|
212
|
+
free() {
|
|
213
|
+
const { gl, ubo } = this;
|
|
106
214
|
gl.deleteBuffer(ubo);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
function TextureManager(gl, width, height, _a) {
|
|
112
|
-
var rotationLocation = _a.rotationLocation;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
class TextureManager {
|
|
218
|
+
constructor(gl, width, height, { rotationLocation }) {
|
|
113
219
|
this.gl = gl;
|
|
114
220
|
this.width = width;
|
|
115
221
|
this.height = height;
|
|
116
222
|
this.rotationLocation = rotationLocation;
|
|
117
223
|
this.rotationTexture = this._createFloatTexture();
|
|
118
224
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
225
|
+
_createFloatTexture() {
|
|
226
|
+
const { gl, width, height } = this;
|
|
227
|
+
const texture = gl.createTexture();
|
|
122
228
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
123
229
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
124
230
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
125
231
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.R32F, width, height, 0, gl.RED, gl.FLOAT, null);
|
|
126
232
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
127
233
|
return texture;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
234
|
+
}
|
|
235
|
+
setData(rotation) {
|
|
236
|
+
const { gl, rotationTexture, width, height } = this;
|
|
131
237
|
// gl flip y axis
|
|
132
238
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
133
239
|
gl.bindTexture(gl.TEXTURE_2D, rotationTexture);
|
|
134
240
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.R32F, width, height, 0, gl.RED, gl.FLOAT, rotation);
|
|
135
241
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
136
242
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
243
|
+
}
|
|
244
|
+
activate() {
|
|
245
|
+
const { gl, rotationTexture } = this;
|
|
140
246
|
gl.activeTexture(gl.TEXTURE0);
|
|
141
247
|
gl.bindTexture(gl.TEXTURE_2D, rotationTexture);
|
|
142
248
|
gl.uniform1i(this.rotationLocation, 0);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
249
|
+
}
|
|
250
|
+
free() {
|
|
251
|
+
const { gl, rotationTexture } = this;
|
|
146
252
|
gl.deleteTexture(rotationTexture);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
}());
|
|
253
|
+
}
|
|
254
|
+
}
|
|
@@ -1,68 +1,60 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// this contains vao, drawCount, ArrowBufferBlock, vao,
|
|
3
2
|
// how to, where to set instanced parameters
|
|
4
3
|
// the vectorfield buffer should be managed outside, since it can be static or dynamic.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var ArrowField = /** @class */ (function () {
|
|
13
|
-
function ArrowField(gl, globe, _a) {
|
|
14
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.minLon, minLon = _c === void 0 ? -180 : _c, _d = _b.maxLon, maxLon = _d === void 0 ? 180 : _d, _e = _b.minLat, minLat = _e === void 0 ? -90 : _e, _f = _b.maxLat, maxLat = _f === void 0 ? 90 : _f, _g = _b.height, height = _g === void 0 ? 0 : _g, _h = _b.opacity, opacity = _h === void 0 ? 1 : _h, _j = _b.color, color = _j === void 0 ? [0.04, 0.2, 0.8] : _j, _k = _b.targetWidth, targetWidth = _k === void 0 ? 100 : _k, _l = _b.targetHeight, targetHeight = _l === void 0 ? 100 : _l, _m = _b.dataWidth, dataWidth = _m === void 0 ? null : _m, _o = _b.dataHeight, dataHeight = _o === void 0 ? null : _o, _p = _b.tailLengthRatio, tailLengthRatio = _p === void 0 ? 1 : _p, _q = _b.wingLengthRatio, wingLengthRatio = _q === void 0 ? 0.5 : _q, _r = _b.noDataValue, noDataValue = _r === void 0 ? null : _r;
|
|
4
|
+
import Logic from './logic';
|
|
5
|
+
import { globeProgramCache } from '../programcache';
|
|
6
|
+
import { longlatbbox2normalbbox } from "../util";
|
|
7
|
+
export default class ArrowField {
|
|
8
|
+
constructor(gl, globe, { minLon = -180, maxLon = 180, minLat = -90, maxLat = 90, height = 0, opacity = 1, color = [0.04, 0.2, 0.8], targetWidth = 100, targetHeight = 100, dataWidth = null, dataHeight = null, tailLengthRatio = 1, wingLengthRatio = 0.5, noDataValue = null,
|
|
9
|
+
// maxMagnitude = null
|
|
10
|
+
} = {}) {
|
|
15
11
|
this.gl = gl;
|
|
16
12
|
this.globe = globe;
|
|
17
|
-
this.program =
|
|
13
|
+
this.program = globeProgramCache.getProgram(globe, Logic);
|
|
18
14
|
this.arrowBlockManager = this.program.getArrowBlockBufferManager();
|
|
19
15
|
this.instanceCount = targetWidth * targetHeight;
|
|
20
16
|
this.arrowBlockManager.update({ resolution: [targetWidth, targetHeight] });
|
|
21
17
|
this.textureManager = this.program.getTextureManager(dataWidth, dataHeight);
|
|
22
|
-
this.setBBox({ minLon
|
|
23
|
-
this.update({ height
|
|
18
|
+
this.setBBox({ minLon, maxLon, minLat, maxLat });
|
|
19
|
+
this.update({ height, opacity, color, tailLengthRatio, wingLengthRatio, noDataValue });
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.arrowBlockManager.update({ bboxSizeRad: bboxSizeRad, bboxOffsetRad: bboxOffsetRad });
|
|
21
|
+
setBBox({ minLon = -180, maxLon = 180, minLat = -90, maxLat = 90 } = {}) {
|
|
22
|
+
this.bbox = { minLon, maxLon, minLat, maxLat };
|
|
23
|
+
const { bboxSizeRad, bboxOffsetRad } = longlatbbox2normalbbox(this.bbox);
|
|
24
|
+
this.arrowBlockManager.update({ bboxSizeRad, bboxOffsetRad });
|
|
30
25
|
this.globe.DrawRender();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var _b = _a === void 0 ? {} : _a, height = _b.height, opacity = _b.opacity, color = _b.color, resolution = _b.resolution, tailLengthRatio = _b.tailLengthRatio, wingLengthRatio = _b.wingLengthRatio, noDataValue = _b.noDataValue;
|
|
26
|
+
}
|
|
27
|
+
update({ height, opacity, color, resolution, tailLengthRatio, wingLengthRatio, noDataValue } = {}) {
|
|
34
28
|
if (resolution) {
|
|
35
29
|
this.instanceCount = resolution[0] * resolution[1];
|
|
36
30
|
}
|
|
37
31
|
this.arrowBlockManager.update({
|
|
38
|
-
color
|
|
39
|
-
resolution
|
|
40
|
-
height
|
|
41
|
-
opacity
|
|
42
|
-
tailLengthRatio
|
|
43
|
-
wingLengthRatio
|
|
44
|
-
noDataValue
|
|
32
|
+
color,
|
|
33
|
+
resolution,
|
|
34
|
+
height,
|
|
35
|
+
opacity,
|
|
36
|
+
tailLengthRatio,
|
|
37
|
+
wingLengthRatio,
|
|
38
|
+
noDataValue,
|
|
45
39
|
});
|
|
46
40
|
this.globe.DrawRender();
|
|
47
|
-
}
|
|
48
|
-
|
|
41
|
+
}
|
|
42
|
+
setTargetResolution(width, height) {
|
|
49
43
|
this.instanceCount = width * height;
|
|
50
44
|
this.arrowBlockManager.update({ resolution: [width, height] });
|
|
51
45
|
this.globe.DrawRender();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
}
|
|
47
|
+
draw() {
|
|
48
|
+
const { program, arrowBlockManager, textureManager, instanceCount } = this;
|
|
55
49
|
program.draw(arrowBlockManager, textureManager, instanceCount);
|
|
56
|
-
}
|
|
57
|
-
|
|
50
|
+
}
|
|
51
|
+
setData(rotation) {
|
|
58
52
|
this.textureManager.setData(rotation);
|
|
59
53
|
this.globe.DrawRender();
|
|
60
|
-
}
|
|
61
|
-
|
|
54
|
+
}
|
|
55
|
+
free() {
|
|
62
56
|
this.arrowBlockManager.free();
|
|
63
57
|
this.textureManager.free();
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
}());
|
|
68
|
-
exports.default = ArrowField;
|
|
58
|
+
globeProgramCache.releaseProgram(this.gl, Logic);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,16 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { createProgram } from "../../util/";
|
|
2
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
3
|
+
const vs = `#version 300 es
|
|
4
|
+
precision highp float;
|
|
5
|
+
|
|
6
|
+
uniform sampler2D u_density_texture;
|
|
7
|
+
in vec2 a_position;
|
|
8
|
+
|
|
9
|
+
out vec2 v_texcoord;
|
|
10
|
+
|
|
11
|
+
void main() {
|
|
12
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
13
|
+
v_texcoord = a_position * 0.5 + 0.5;
|
|
14
|
+
}`;
|
|
15
|
+
const fs = `#version 300 es
|
|
16
|
+
precision highp float;
|
|
17
|
+
|
|
18
|
+
uniform sampler2D u_legend_texture;
|
|
19
|
+
uniform sampler2D u_density_texture;
|
|
20
|
+
|
|
21
|
+
uniform float u_opacity;
|
|
22
|
+
in vec2 v_texcoord;
|
|
23
|
+
out vec4 fragColor;
|
|
24
|
+
|
|
25
|
+
void main() {
|
|
26
|
+
float density = texture(u_density_texture, v_texcoord).r;
|
|
27
|
+
fragColor = texture(u_legend_texture, vec2(density, 0.5));
|
|
28
|
+
fragColor.a *= u_opacity * sqrt(density);
|
|
29
|
+
}`;
|
|
30
|
+
class DensityToLegendProgram {
|
|
31
|
+
constructor(globe) {
|
|
10
32
|
this.globe = globe;
|
|
11
33
|
this.gl = globe.gl;
|
|
12
|
-
this.program =
|
|
13
|
-
|
|
34
|
+
this.program = createProgram(globe.gl, vs, fs);
|
|
35
|
+
const { gl, program } = this;
|
|
14
36
|
this.uniforms = {
|
|
15
37
|
densityTexture: gl.getUniformLocation(program, "u_density_texture"),
|
|
16
38
|
legendTexture: gl.getUniformLocation(program, "u_legend_texture"),
|
|
@@ -21,9 +43,9 @@ var DensityToLegendProgram = /** @class */ (function () {
|
|
|
21
43
|
}
|
|
22
44
|
{
|
|
23
45
|
this.vao = gl.createVertexArray();
|
|
24
|
-
|
|
46
|
+
const a_positionLocation = gl.getAttribLocation(program, "a_position");
|
|
25
47
|
gl.bindVertexArray(this.vao);
|
|
26
|
-
|
|
48
|
+
const buffer = gl.createBuffer();
|
|
27
49
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
28
50
|
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
|
|
29
51
|
-1, -1,
|
|
@@ -39,14 +61,14 @@ var DensityToLegendProgram = /** @class */ (function () {
|
|
|
39
61
|
}
|
|
40
62
|
{
|
|
41
63
|
this._lastOpacity = 1;
|
|
42
|
-
|
|
64
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
43
65
|
gl.useProgram(program);
|
|
44
66
|
gl.uniform1f(this.uniforms.opacity, this._lastOpacity);
|
|
45
67
|
gl.useProgram(currentProgram);
|
|
46
68
|
}
|
|
47
69
|
}
|
|
48
|
-
|
|
49
|
-
|
|
70
|
+
draw(densityTexture, legendTexture, opacity) {
|
|
71
|
+
const { gl, program, uniforms } = this;
|
|
50
72
|
gl.useProgram(program);
|
|
51
73
|
gl.bindVertexArray(this.vao);
|
|
52
74
|
gl.activeTexture(gl.TEXTURE1);
|
|
@@ -61,17 +83,16 @@ var DensityToLegendProgram = /** @class */ (function () {
|
|
|
61
83
|
}
|
|
62
84
|
gl.drawArrays(gl.TRIANGLE_FAN, 0, 4);
|
|
63
85
|
gl.bindVertexArray(null);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
86
|
+
}
|
|
87
|
+
free() {
|
|
88
|
+
const gl = this.gl;
|
|
67
89
|
gl.deleteVertexArray(this.vao);
|
|
68
90
|
gl.deleteBuffer(this._buffer);
|
|
69
91
|
gl.deleteProgram(this.program);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, DensityToLegendProgram); }
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const densityToLegendProgramCache = {
|
|
95
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, DensityToLegendProgram),
|
|
96
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, DensityToLegendProgram)
|
|
76
97
|
};
|
|
77
|
-
|
|
98
|
+
export { densityToLegendProgramCache };
|
|
@@ -1,19 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { createProgram } from "../../util/";
|
|
2
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
3
|
+
import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems/camerauniformblock";
|
|
4
|
+
import { mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
|
|
5
|
+
const vs = `#version 300 es
|
|
6
|
+
precision highp float;
|
|
7
|
+
|
|
8
|
+
${CameraUniformBlockString}
|
|
9
|
+
${mercatorXYToGLPosition}
|
|
10
|
+
${cartesian3DToGLPosition}
|
|
11
|
+
|
|
12
|
+
in vec3 position;
|
|
13
|
+
uniform float pointSize;
|
|
14
|
+
|
|
15
|
+
void main() {
|
|
16
|
+
if (is3D) {
|
|
17
|
+
gl_Position = cartesian3DToGLPosition(position);
|
|
18
|
+
} else {
|
|
19
|
+
gl_Position = mercatorXYToGLPosition(position.xy);
|
|
20
|
+
}
|
|
21
|
+
gl_PointSize = pointSize;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
const fs = `#version 300 es
|
|
25
|
+
precision highp float;
|
|
26
|
+
out vec4 fragColor;
|
|
27
|
+
|
|
28
|
+
void main() {
|
|
29
|
+
float r = length(gl_PointCoord - 0.5) * 2.0;
|
|
30
|
+
if (r > 1.0) discard;
|
|
31
|
+
// float density = smoothstep(0.1, 1.0, 1.0 - r);
|
|
32
|
+
fragColor = vec4((15.0/16.0)*sqrt(1.0-sqrt(r)));
|
|
33
|
+
}`;
|
|
34
|
+
class PointHeatmapProgram {
|
|
35
|
+
constructor(globe) {
|
|
12
36
|
this.globe = globe;
|
|
13
37
|
this.gl = globe.gl;
|
|
14
38
|
this._isFreed = false;
|
|
15
|
-
this.program =
|
|
16
|
-
|
|
39
|
+
this.program = createProgram(globe.gl, vs, fs);
|
|
40
|
+
const { gl, program } = this;
|
|
17
41
|
this.uniforms = {
|
|
18
42
|
pointSize: gl.getUniformLocation(this.program, "pointSize"),
|
|
19
43
|
};
|
|
@@ -22,31 +46,30 @@ var PointHeatmapProgram = /** @class */ (function () {
|
|
|
22
46
|
}
|
|
23
47
|
{ // arrange camera uniform block
|
|
24
48
|
this.cameraBlockBingingPoint = 0;
|
|
25
|
-
this.cameraBlockTotem =
|
|
26
|
-
|
|
49
|
+
this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
50
|
+
const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
27
51
|
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBingingPoint);
|
|
28
52
|
}
|
|
29
53
|
{ // last values
|
|
30
54
|
this._lastPointSize = 0;
|
|
31
|
-
|
|
55
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
32
56
|
gl.useProgram(program);
|
|
33
57
|
gl.uniform1f(this.uniforms.pointSize, this._lastPointSize);
|
|
34
58
|
gl.useProgram(currentProgram);
|
|
35
59
|
}
|
|
36
60
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
createVAO(positionBuffer, vectorSize) {
|
|
62
|
+
const gl = this.gl;
|
|
63
|
+
const vao = gl.createVertexArray();
|
|
40
64
|
gl.bindVertexArray(vao);
|
|
41
65
|
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
|
42
66
|
gl.enableVertexAttribArray(0);
|
|
43
67
|
gl.vertexAttribPointer(0, vectorSize, gl.FLOAT, false, 0, 0);
|
|
44
68
|
gl.bindVertexArray(null);
|
|
45
69
|
return vao;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var gl = this.gl;
|
|
70
|
+
}
|
|
71
|
+
draw(vao, length, pointSize = 5.0) {
|
|
72
|
+
const gl = this.gl;
|
|
50
73
|
gl.useProgram(this.program);
|
|
51
74
|
if (pointSize !== this._lastPointSize) {
|
|
52
75
|
gl.uniform1f(this.uniforms.pointSize, pointSize);
|
|
@@ -57,19 +80,18 @@ var PointHeatmapProgram = /** @class */ (function () {
|
|
|
57
80
|
gl.drawArrays(gl.POINTS, 0, length);
|
|
58
81
|
this.cameraBlockTotem.unbind(this.cameraBlockBingingPoint);
|
|
59
82
|
gl.bindVertexArray(null);
|
|
60
|
-
}
|
|
61
|
-
|
|
83
|
+
}
|
|
84
|
+
free() {
|
|
62
85
|
if (this._isFreed)
|
|
63
86
|
return;
|
|
64
|
-
|
|
65
|
-
|
|
87
|
+
const { gl, globe } = this;
|
|
88
|
+
CameraUniformBlockTotemCache.release(globe);
|
|
66
89
|
gl.deleteProgram(this.program);
|
|
67
90
|
this._isFreed = true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, PointHeatmapProgram); }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const pointToDensityTextureCache = {
|
|
94
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, PointHeatmapProgram),
|
|
95
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, PointHeatmapProgram)
|
|
74
96
|
};
|
|
75
|
-
|
|
97
|
+
export { pointToDensityTextureCache };
|