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