@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,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
|
|
11
|
-
var manager_1 = require("../../util/gl-util/uniform-block/manager");
|
|
12
|
-
var uniformBindingPoints = {
|
|
1
|
+
import { createProgram } from "../../util";
|
|
2
|
+
import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
|
|
3
|
+
import { mercatorXYToGLPosition, cartesian3DToGLPosition, R_3D, R } from "../../util/shaderfunctions/geometrytransformations";
|
|
4
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
5
|
+
import "../../util/gl-util/draw-options/types";
|
|
6
|
+
import { drawArrays } from "../../util/gl-util/draw-options/methods";
|
|
7
|
+
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
8
|
+
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
9
|
+
const uniformBindingPoints = {
|
|
13
10
|
camera: 0,
|
|
14
11
|
flexible: 1
|
|
15
12
|
};
|
|
16
|
-
|
|
13
|
+
const uniformBlockManager = new UniformBlockManager("FlexibleBlock", [
|
|
17
14
|
{ name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
|
|
18
15
|
{ name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
|
|
19
16
|
{ name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
|
|
@@ -25,15 +22,101 @@ var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
|
|
|
25
22
|
{ name: "u_dash_opacity_multiplier", type: "float", value: new Float32Array([1.0]) },
|
|
26
23
|
{ name: "u_dash_phase", type: "float", value: new Float32Array([0.0]) },
|
|
27
24
|
], uniformBindingPoints.flexible);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
const vs = `#version 300 es
|
|
26
|
+
${R}
|
|
27
|
+
${R_3D}
|
|
28
|
+
${CameraUniformBlockString}
|
|
29
|
+
${mercatorXYToGLPosition}
|
|
30
|
+
${cartesian3DToGLPosition}
|
|
31
|
+
|
|
32
|
+
${uniformBlockManager.glslCode()}
|
|
33
|
+
|
|
34
|
+
precision highp float;
|
|
35
|
+
precision highp int;
|
|
36
|
+
|
|
37
|
+
in vec3 pos3D;
|
|
38
|
+
in vec2 pos2D;
|
|
39
|
+
in vec4 rgba;
|
|
40
|
+
in float size;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
flat out highp int vVertexID;
|
|
44
|
+
|
|
45
|
+
out vec4 v_rgba;
|
|
46
|
+
|
|
47
|
+
out float v_length;
|
|
48
|
+
|
|
49
|
+
void main() {
|
|
50
|
+
|
|
51
|
+
v_rgba = (rgba.r == -1.0) ? u_rgba : rgba;
|
|
52
|
+
v_rgba.a *= u_opacity;
|
|
53
|
+
gl_PointSize = max(((size == -1.0) ? u_size : size) * u_size_multiplier, u_minimum_size);
|
|
54
|
+
|
|
55
|
+
float size_fixer;
|
|
56
|
+
if(is3D){
|
|
57
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
58
|
+
size_fixer = smoothstep(0.15, 1.0, 0.5 * R_3D / gl_Position.w) ;
|
|
59
|
+
} else {
|
|
60
|
+
gl_Position = mercatorXYToGLPosition(pos2D);
|
|
61
|
+
size_fixer = smoothstep(2.0, 5.2, z_level);
|
|
62
|
+
}
|
|
63
|
+
gl_PointSize *= size_fixer;
|
|
64
|
+
switch (u_draw_mode) {
|
|
65
|
+
case 0:
|
|
66
|
+
vVertexID = gl_VertexID;
|
|
67
|
+
break;
|
|
68
|
+
case 1:
|
|
69
|
+
v_length = float(gl_VertexID % 2);
|
|
70
|
+
vVertexID = (gl_VertexID - gl_VertexID % 2) / 2; // a line takes two points
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}`;
|
|
76
|
+
const fs = `#version 300 es
|
|
77
|
+
precision highp float;
|
|
78
|
+
precision highp int;
|
|
79
|
+
|
|
80
|
+
${uniformBlockManager.glslCode()}
|
|
81
|
+
|
|
82
|
+
flat in highp int vVertexID;
|
|
83
|
+
|
|
84
|
+
in vec4 v_rgba;
|
|
85
|
+
in float v_length;
|
|
86
|
+
|
|
87
|
+
layout(location = 0) out vec4 fragColor;
|
|
88
|
+
layout(location = 1) out int vertexID;
|
|
89
|
+
|
|
90
|
+
void main() {
|
|
91
|
+
vertexID = vVertexID;
|
|
92
|
+
fragColor = v_rgba;
|
|
93
|
+
|
|
94
|
+
switch (u_draw_mode) {
|
|
95
|
+
case 0:
|
|
96
|
+
float d = distance(gl_PointCoord, vec2(0.5, 0.5));
|
|
97
|
+
if (u_is_circle) {
|
|
98
|
+
if (d > 0.5) discard;
|
|
99
|
+
fragColor.a *= smoothstep(0.5, 0.45, d);
|
|
100
|
+
}
|
|
101
|
+
if (u_dash_opacity_multiplier < 1.0) {
|
|
102
|
+
float dash = sin(d * 3.14159 * 2.0 * u_dash_count + u_dash_phase) * (1.0 - u_dash_opacity_multiplier) + u_dash_opacity_multiplier;
|
|
103
|
+
fragColor.a *= dash;
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
case 1:
|
|
107
|
+
if (u_dash_opacity_multiplier < 1.0 && fract((v_length + u_dash_phase) * u_dash_count) < 0.5) {
|
|
108
|
+
fragColor.a *= u_dash_opacity_multiplier;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}`;
|
|
113
|
+
class PointOnGlobeProgram {
|
|
114
|
+
constructor(globe) {
|
|
32
115
|
this.globe = globe;
|
|
33
116
|
this.gl = globe.gl;
|
|
34
117
|
this._isFreed = false;
|
|
35
|
-
this.program =
|
|
36
|
-
|
|
118
|
+
this.program = createProgram(this.gl, vs, fs);
|
|
119
|
+
const { gl, program } = this;
|
|
37
120
|
// assign opacity
|
|
38
121
|
// assign attribute locations
|
|
39
122
|
gl.bindAttribLocation(program, 0, "pos3D");
|
|
@@ -41,7 +124,7 @@ var PointOnGlobeProgram = /** @class */ (function () {
|
|
|
41
124
|
gl.bindAttribLocation(program, 2, "rgba");
|
|
42
125
|
gl.bindAttribLocation(program, 3, "size");
|
|
43
126
|
// arrange camera uniform block
|
|
44
|
-
this.cameraBlockTotem =
|
|
127
|
+
this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
45
128
|
this.cameraBlockTotem.assignBindingPoint(program, uniformBindingPoints.camera);
|
|
46
129
|
uniformBlockManager.assignBindingPoint(this.gl, this.program);
|
|
47
130
|
this._defaultUBO = uniformBlockManager.createUBO(this.gl);
|
|
@@ -53,52 +136,50 @@ var PointOnGlobeProgram = /** @class */ (function () {
|
|
|
53
136
|
["u_is_circle", [1.0]],
|
|
54
137
|
]));
|
|
55
138
|
}
|
|
56
|
-
|
|
57
|
-
|
|
139
|
+
createUBO() {
|
|
140
|
+
const ubo = uniformBlockManager.createUBO(this.gl);
|
|
58
141
|
return ubo;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
142
|
+
}
|
|
143
|
+
createVAO(pos3DBufferObj, pos2DBufferObj, rgbaBufferObj, sizeBufferObj) {
|
|
144
|
+
const { gl } = this;
|
|
145
|
+
const vao = gl.createVertexArray();
|
|
63
146
|
gl.bindVertexArray(vao);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
147
|
+
attributeLoader(gl, pos3DBufferObj, 0, 3);
|
|
148
|
+
attributeLoader(gl, pos2DBufferObj, 1, 2);
|
|
149
|
+
attributeLoader(gl, rgbaBufferObj, 2, 4, { escapeValues: [-1, -1, -1, -1] });
|
|
150
|
+
attributeLoader(gl, sizeBufferObj, 3, 1, { escapeValues: [-1] });
|
|
68
151
|
gl.bindVertexArray(null);
|
|
69
152
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
70
153
|
return vao;
|
|
71
|
-
}
|
|
154
|
+
}
|
|
72
155
|
/**
|
|
73
156
|
*
|
|
74
157
|
* @param {vertexArrayObject} vao
|
|
75
158
|
* @param {DrawRangeIndexParams} drawOptions
|
|
76
159
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var _a = this, gl = _a.gl, program = _a.program;
|
|
160
|
+
draw(vao, drawOptions, ubo = null) {
|
|
161
|
+
const { gl, program } = this;
|
|
80
162
|
gl.useProgram(program);
|
|
81
163
|
gl.bindVertexArray(vao);
|
|
82
164
|
this.cameraBlockTotem.bind(uniformBindingPoints.camera);
|
|
83
165
|
ubo = ubo || this._defaultUBO;
|
|
84
166
|
ubo.bind();
|
|
85
|
-
|
|
167
|
+
drawArrays(gl, gl.POINTS, drawOptions);
|
|
86
168
|
ubo.unbind();
|
|
87
169
|
this.cameraBlockTotem.unbind(uniformBindingPoints.camera);
|
|
88
170
|
gl.bindVertexArray(null);
|
|
89
|
-
}
|
|
90
|
-
|
|
171
|
+
}
|
|
172
|
+
free() {
|
|
91
173
|
if (this._isFreed)
|
|
92
174
|
return;
|
|
93
|
-
|
|
94
|
-
|
|
175
|
+
const { gl, globe } = this;
|
|
176
|
+
CameraUniformBlockTotemCache.release(globe);
|
|
95
177
|
gl.deleteProgram(this.program);
|
|
96
178
|
this._isFreed = true;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram); }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const PickableRendererProgramCache = Object.freeze({
|
|
182
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram),
|
|
183
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram)
|
|
103
184
|
});
|
|
104
|
-
|
|
185
|
+
export { PickableRendererProgramCache };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* *
|
|
4
3
|
* * *
|
|
@@ -6,29 +5,72 @@
|
|
|
6
5
|
* * *
|
|
7
6
|
* *
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var manager_1 = require("../../util/gl-util/uniform-block/manager");
|
|
18
|
-
var uboBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
|
|
8
|
+
import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
|
|
9
|
+
import { PI, mercatorXYToGLPosition, cartesian3DToGLPosition, circleLimpFromLongLatRadCenterCartesian3D_accurate } from "../../util/shaderfunctions/geometrytransformations";
|
|
10
|
+
import { createProgram } from "../../util";
|
|
11
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
12
|
+
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
13
|
+
import { drawInstanced } from "../../util/gl-util/draw-options/methods";
|
|
14
|
+
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
15
|
+
const uboBlockManager = new UniformBlockManager("FlexibleBlock", [
|
|
19
16
|
{ name: "u_color", type: "vec4" },
|
|
20
17
|
{ name: "u_radius", type: "float" }
|
|
21
18
|
], 1);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const vs = `#version 300 es
|
|
20
|
+
${PI}
|
|
21
|
+
${CameraUniformBlockString}
|
|
22
|
+
${cartesian3DToGLPosition}
|
|
23
|
+
${circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
24
|
+
|
|
25
|
+
uniform float edge_count;
|
|
26
|
+
|
|
27
|
+
in vec3 pos3D;
|
|
28
|
+
in float radius;
|
|
29
|
+
in vec4 color;
|
|
30
|
+
|
|
31
|
+
${uboBlockManager.glslCode()}
|
|
32
|
+
|
|
33
|
+
out vec4 vColor;
|
|
34
|
+
|
|
35
|
+
void main() {
|
|
36
|
+
|
|
37
|
+
float radius_ = ( radius == -1.0 ) ? u_radius : radius;
|
|
38
|
+
vec4 color = ( color.r == -1.0 ) ? u_color : color;
|
|
39
|
+
|
|
40
|
+
if ( gl_VertexID == 0 ) {
|
|
41
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
42
|
+
vColor = vColor;
|
|
43
|
+
} else {
|
|
44
|
+
float angle = PI * 2.0 * float( gl_VertexID - 1 ) / edge_count;
|
|
45
|
+
vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(pos3D, radius, angle);
|
|
46
|
+
gl_Position = cartesian3DToGLPosition(position);
|
|
47
|
+
float distance = distance(position, pos3D);
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
vColor = vec4(color.rgb, color.a * (1.0 - distance / radius));
|
|
52
|
+
}
|
|
53
|
+
}`;
|
|
54
|
+
const fs = `#version 300 es
|
|
55
|
+
precision highp float;
|
|
56
|
+
|
|
57
|
+
uniform float opacity;
|
|
58
|
+
in vec4 vColor;
|
|
59
|
+
|
|
60
|
+
out vec4 fragColor;
|
|
61
|
+
|
|
62
|
+
void main() {
|
|
63
|
+
fragColor = vColor;
|
|
64
|
+
fragColor.a *= opacity;
|
|
65
|
+
}`;
|
|
66
|
+
class Logic {
|
|
67
|
+
constructor(globe) {
|
|
26
68
|
this.globe = globe;
|
|
27
69
|
this.gl = globe.gl;
|
|
28
70
|
this._vaoCache = [];
|
|
29
|
-
this.program =
|
|
30
|
-
|
|
31
|
-
|
|
71
|
+
this.program = createProgram(this.gl, vs, fs);
|
|
72
|
+
const { gl, program } = this;
|
|
73
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
32
74
|
gl.useProgram(program);
|
|
33
75
|
// set uniform locations
|
|
34
76
|
this._uniforms = {
|
|
@@ -46,30 +88,28 @@ var Logic = /** @class */ (function () {
|
|
|
46
88
|
gl.bindAttribLocation(program, 1, "radius");
|
|
47
89
|
gl.bindAttribLocation(program, 2, "color");
|
|
48
90
|
// camera uniform block
|
|
49
|
-
this.cameraUniformBlockTotem =
|
|
91
|
+
this.cameraUniformBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
50
92
|
this.cameraBlockBindingPoint = 0;
|
|
51
|
-
|
|
93
|
+
const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
52
94
|
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
53
95
|
uboBlockManager.assignBindingPoint(this.gl, this.program);
|
|
54
96
|
this._defaultUBO = uboBlockManager.createUBO(this.gl);
|
|
55
97
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
98
|
+
createVAO(pos3DObj, radiusObj, colorObj) {
|
|
99
|
+
const { gl } = this;
|
|
100
|
+
const vao = gl.createVertexArray();
|
|
101
|
+
const divisor = 1;
|
|
60
102
|
gl.bindVertexArray(vao);
|
|
61
103
|
// TODO constants to escape values
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
104
|
+
attributeLoader(gl, pos3DObj, 0, 3, { divisor });
|
|
105
|
+
attributeLoader(gl, radiusObj, 1, 1, { divisor, escapeValues: [-1] });
|
|
106
|
+
attributeLoader(gl, colorObj, 2, 4, { divisor, escapeValues: [-1, -1, -1, -1] });
|
|
65
107
|
gl.bindVertexArray(null);
|
|
66
108
|
this._vaoCache.push(vao);
|
|
67
109
|
return vao;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (ubo === void 0) { ubo = null; }
|
|
72
|
-
var _a = this, gl = _a.gl, program = _a.program;
|
|
110
|
+
}
|
|
111
|
+
draw(vao, drawOptions, opacity = 1.0, ubo = null) {
|
|
112
|
+
const { gl, program } = this;
|
|
73
113
|
gl.useProgram(program);
|
|
74
114
|
gl.bindVertexArray(vao);
|
|
75
115
|
if (opacity !== this._uniforms.opacity) {
|
|
@@ -78,25 +118,22 @@ var Logic = /** @class */ (function () {
|
|
|
78
118
|
}
|
|
79
119
|
ubo = ubo || this._defaultUBO;
|
|
80
120
|
ubo.bind();
|
|
81
|
-
|
|
121
|
+
drawInstanced(gl, gl.TRIANGLE_FAN, drawOptions);
|
|
82
122
|
ubo.unbind();
|
|
83
123
|
gl.bindVertexArray(null);
|
|
84
|
-
}
|
|
85
|
-
|
|
124
|
+
}
|
|
125
|
+
free() {
|
|
86
126
|
if (this._isFreed)
|
|
87
127
|
return;
|
|
88
|
-
|
|
128
|
+
CameraUniformBlockTotemCache.release(this.globe);
|
|
89
129
|
this.gl.deleteProgram(this.program);
|
|
90
|
-
for (
|
|
91
|
-
var vao = _a[_i];
|
|
130
|
+
for (const vao of this._vaoCache)
|
|
92
131
|
this.gl.deleteVertexArray(vao);
|
|
93
|
-
}
|
|
94
132
|
this._isFreed = true;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe); }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const ElementGlobeSufaceGlowCache = Object.freeze({
|
|
136
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
137
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe)
|
|
101
138
|
});
|
|
102
|
-
|
|
139
|
+
export { ElementGlobeSufaceGlowCache };
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var cameraBlockBindingPoint = 0;
|
|
14
|
-
var flexibleBlockBindingPoint = 1;
|
|
15
|
-
var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
|
|
1
|
+
import { createProgram } from "../../util";
|
|
2
|
+
import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
|
|
3
|
+
import { mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
|
|
4
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
5
|
+
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
6
|
+
import { drawArrays } from "../../util/gl-util/draw-options/methods";
|
|
7
|
+
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
8
|
+
import { singularity } from "../../shaders/fragment-toy/singularity";
|
|
9
|
+
import { firework } from "../../shaders/fragment-toy/firework";
|
|
10
|
+
const cameraBlockBindingPoint = 0;
|
|
11
|
+
const flexibleBlockBindingPoint = 1;
|
|
12
|
+
const uniformBlockManager = new UniformBlockManager("FlexibleBlock", [
|
|
16
13
|
{ name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
|
|
17
14
|
{ name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
|
|
18
15
|
{ name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
|
|
@@ -20,66 +17,134 @@ var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
|
|
|
20
17
|
{ name: "u_minimumSize", type: "float", value: new Float32Array([25.0]) },
|
|
21
18
|
{ name: "u_phase", type: "float", value: new Float32Array([1.0]) },
|
|
22
19
|
], flexibleBlockBindingPoint);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const vs = `#version 300 es
|
|
21
|
+
precision highp float;
|
|
22
|
+
|
|
23
|
+
${CameraUniformBlockString}
|
|
24
|
+
${mercatorXYToGLPosition}
|
|
25
|
+
${cartesian3DToGLPosition}
|
|
26
|
+
|
|
27
|
+
${uniformBlockManager.glslCode()}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
in vec3 pos3D;
|
|
31
|
+
in vec2 pos2D;
|
|
32
|
+
in vec4 color;
|
|
33
|
+
in float size;
|
|
34
|
+
|
|
35
|
+
out vec4 vColor;
|
|
36
|
+
flat out float v_size;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
void main() {
|
|
41
|
+
|
|
42
|
+
if(is3D){
|
|
43
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
gl_Position = mercatorXYToGLPosition(pos2D);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
gl_PointSize = max(
|
|
50
|
+
((size == -1.0) ? u_size : size ) * u_size_multiplier,
|
|
51
|
+
u_minimumSize);
|
|
52
|
+
v_size = gl_PointSize;
|
|
53
|
+
vColor = (color.r == -1.0) ? u_rgba : color;
|
|
54
|
+
vColor.a *= u_opacity;
|
|
55
|
+
|
|
56
|
+
}`;
|
|
57
|
+
const fs = `#version 300 es
|
|
58
|
+
precision highp float;
|
|
59
|
+
|
|
60
|
+
${uniformBlockManager.glslCode()}
|
|
61
|
+
|
|
62
|
+
in vec4 vColor;
|
|
63
|
+
out vec4 fragColor;
|
|
64
|
+
|
|
65
|
+
flat in float v_size;
|
|
66
|
+
|
|
67
|
+
${firework}
|
|
68
|
+
${singularity}
|
|
69
|
+
|
|
70
|
+
void main() {
|
|
71
|
+
fragColor = vColor;
|
|
72
|
+
|
|
73
|
+
float dist = distance(gl_PointCoord, vec2(0.5, 0.5)) * 2.0;
|
|
74
|
+
if ( dist > 1.0) discard;
|
|
75
|
+
|
|
76
|
+
// center glow
|
|
77
|
+
float center_alpha = smoothstep(0.5, 0.0, dist) * 0.3;
|
|
78
|
+
// center_alpha = smoothstep(0.0, 1.0, center_alpha);
|
|
79
|
+
|
|
80
|
+
// circle pattern
|
|
81
|
+
float threshold = fract(( - dist + u_phase - 0.5));
|
|
82
|
+
float circle_alpha = sin( threshold * 1.57 );
|
|
83
|
+
circle_alpha = smoothstep((v_size / (v_size + .5)), 1.0, circle_alpha);
|
|
84
|
+
|
|
85
|
+
float outer_circle_alpha = sin(dist * 1.57 );
|
|
86
|
+
outer_circle_alpha = smoothstep((v_size / (v_size + .5)), 1.0, outer_circle_alpha);
|
|
87
|
+
|
|
88
|
+
// fragColor = singularity(gl_PointCoord, u_phase);
|
|
89
|
+
|
|
90
|
+
fragColor.a *= smoothstep(0.0, 1.1, ( 0.4 * u_opacity + center_alpha + circle_alpha+ outer_circle_alpha));
|
|
91
|
+
}`;
|
|
92
|
+
class Logic {
|
|
93
|
+
constructor(globe) {
|
|
27
94
|
this.globe = globe;
|
|
28
95
|
this.gl = globe.gl;
|
|
29
|
-
this.program =
|
|
30
|
-
|
|
96
|
+
this.program = createProgram(this.gl, vs, fs);
|
|
97
|
+
const { gl, program } = this;
|
|
31
98
|
gl.bindAttribLocation(program, 0, "pos3D");
|
|
32
99
|
gl.bindAttribLocation(program, 1, "pos2D");
|
|
33
100
|
gl.bindAttribLocation(program, 2, "color");
|
|
34
101
|
gl.bindAttribLocation(program, 3, "size");
|
|
35
102
|
// assign uniform block
|
|
36
|
-
this.cameraBlockTotem =
|
|
103
|
+
this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
37
104
|
this.cameraBlockTotem.assignBindingPoint(program, cameraBlockBindingPoint);
|
|
38
105
|
uniformBlockManager.assignBindingPoint(this.gl, this.program);
|
|
39
106
|
this._defaultUBO = uniformBlockManager.createUBO(this.gl);
|
|
40
107
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
108
|
+
createVAO(pos3DBuffer, pos2DBuffer, colorBuffer, sizeBuffer) {
|
|
109
|
+
const { gl } = this;
|
|
110
|
+
const vao = gl.createVertexArray();
|
|
44
111
|
gl.bindVertexArray(vao);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
112
|
+
attributeLoader(gl, pos3DBuffer, 0, 3);
|
|
113
|
+
attributeLoader(gl, pos2DBuffer, 1, 2);
|
|
114
|
+
attributeLoader(gl, colorBuffer, 2, 4, { escapeValues: [-1, -1, -1, -1] });
|
|
115
|
+
attributeLoader(gl, sizeBuffer, 3, 1, { escapeValues: [-1] });
|
|
49
116
|
gl.bindVertexArray(null);
|
|
50
117
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
51
118
|
return vao;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
119
|
+
}
|
|
120
|
+
createUBO() {
|
|
121
|
+
const ubo = uniformBlockManager.createUBO(this.gl);
|
|
55
122
|
return ubo;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var _a = this, gl = _a.gl, program = _a.program, cameraBlockTotem = _a.cameraBlockTotem;
|
|
123
|
+
}
|
|
124
|
+
draw(vao, drawOptions, ubo = null) {
|
|
125
|
+
const { gl, program, cameraBlockTotem } = this;
|
|
60
126
|
gl.useProgram(program);
|
|
61
127
|
gl.bindVertexArray(vao);
|
|
62
128
|
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
63
129
|
ubo = ubo || this._defaultUBO;
|
|
64
130
|
ubo.bind();
|
|
65
|
-
|
|
131
|
+
drawArrays(gl, gl.POINTS, drawOptions);
|
|
66
132
|
ubo.unbind();
|
|
67
133
|
gl.bindVertexArray(null);
|
|
68
134
|
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
69
135
|
this.globe.DrawRender();
|
|
70
|
-
}
|
|
136
|
+
}
|
|
71
137
|
// for singleton cache interation
|
|
72
|
-
|
|
138
|
+
free() {
|
|
73
139
|
if (this._isFreed)
|
|
74
140
|
return;
|
|
75
|
-
|
|
141
|
+
CameraUniformBlockTotemCache.release(this.globe);
|
|
76
142
|
this.gl.deleteProgram(this.program);
|
|
77
143
|
this._isFreed = true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const ElementPointGlowProgramCache = Object.freeze({
|
|
147
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
148
|
+
release: globe => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
|
|
84
149
|
});
|
|
85
|
-
|
|
150
|
+
export { ElementPointGlowProgramCache };
|