@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
|
@@ -8,27 +8,72 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.ElementGlobeSufaceGlowCache = void 0;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const totems_1 = require("../totems");
|
|
12
|
+
const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
|
|
13
|
+
const util_1 = require("../../util");
|
|
14
|
+
const programcache_1 = require("../programcache");
|
|
15
|
+
const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
|
|
16
|
+
const methods_1 = require("../../util/gl-util/draw-options/methods");
|
|
17
|
+
const manager_1 = require("../../util/gl-util/uniform-block/manager");
|
|
18
|
+
const uboBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
|
|
19
19
|
{ name: "u_color", type: "vec4" },
|
|
20
20
|
{ name: "u_radius", type: "float" }
|
|
21
21
|
], 1);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const vs = `#version 300 es
|
|
23
|
+
${geometrytransformations_1.PI}
|
|
24
|
+
${totems_1.CameraUniformBlockString}
|
|
25
|
+
${geometrytransformations_1.cartesian3DToGLPosition}
|
|
26
|
+
${geometrytransformations_1.circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
27
|
+
|
|
28
|
+
uniform float edge_count;
|
|
29
|
+
|
|
30
|
+
in vec3 pos3D;
|
|
31
|
+
in float radius;
|
|
32
|
+
in vec4 color;
|
|
33
|
+
|
|
34
|
+
${uboBlockManager.glslCode()}
|
|
35
|
+
|
|
36
|
+
out vec4 vColor;
|
|
37
|
+
|
|
38
|
+
void main() {
|
|
39
|
+
|
|
40
|
+
float radius_ = ( radius == -1.0 ) ? u_radius : radius;
|
|
41
|
+
vec4 color = ( color.r == -1.0 ) ? u_color : color;
|
|
42
|
+
|
|
43
|
+
if ( gl_VertexID == 0 ) {
|
|
44
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
45
|
+
vColor = vColor;
|
|
46
|
+
} else {
|
|
47
|
+
float angle = PI * 2.0 * float( gl_VertexID - 1 ) / edge_count;
|
|
48
|
+
vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(pos3D, radius, angle);
|
|
49
|
+
gl_Position = cartesian3DToGLPosition(position);
|
|
50
|
+
float distance = distance(position, pos3D);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
vColor = vec4(color.rgb, color.a * (1.0 - distance / radius));
|
|
55
|
+
}
|
|
56
|
+
}`;
|
|
57
|
+
const fs = `#version 300 es
|
|
58
|
+
precision highp float;
|
|
59
|
+
|
|
60
|
+
uniform float opacity;
|
|
61
|
+
in vec4 vColor;
|
|
62
|
+
|
|
63
|
+
out vec4 fragColor;
|
|
64
|
+
|
|
65
|
+
void main() {
|
|
66
|
+
fragColor = vColor;
|
|
67
|
+
fragColor.a *= opacity;
|
|
68
|
+
}`;
|
|
69
|
+
class Logic {
|
|
70
|
+
constructor(globe) {
|
|
26
71
|
this.globe = globe;
|
|
27
72
|
this.gl = globe.gl;
|
|
28
73
|
this._vaoCache = [];
|
|
29
74
|
this.program = (0, util_1.createProgram)(this.gl, vs, fs);
|
|
30
|
-
|
|
31
|
-
|
|
75
|
+
const { gl, program } = this;
|
|
76
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
32
77
|
gl.useProgram(program);
|
|
33
78
|
// set uniform locations
|
|
34
79
|
this._uniforms = {
|
|
@@ -48,28 +93,26 @@ var Logic = /** @class */ (function () {
|
|
|
48
93
|
// camera uniform block
|
|
49
94
|
this.cameraUniformBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
|
|
50
95
|
this.cameraBlockBindingPoint = 0;
|
|
51
|
-
|
|
96
|
+
const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
52
97
|
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
53
98
|
uboBlockManager.assignBindingPoint(this.gl, this.program);
|
|
54
99
|
this._defaultUBO = uboBlockManager.createUBO(this.gl);
|
|
55
100
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
101
|
+
createVAO(pos3DObj, radiusObj, colorObj) {
|
|
102
|
+
const { gl } = this;
|
|
103
|
+
const vao = gl.createVertexArray();
|
|
104
|
+
const divisor = 1;
|
|
60
105
|
gl.bindVertexArray(vao);
|
|
61
106
|
// TODO constants to escape values
|
|
62
|
-
(0, attribute_loader_1.attributeLoader)(gl, pos3DObj, 0, 3, { divisor
|
|
63
|
-
(0, attribute_loader_1.attributeLoader)(gl, radiusObj, 1, 1, { divisor
|
|
64
|
-
(0, attribute_loader_1.attributeLoader)(gl, colorObj, 2, 4, { divisor
|
|
107
|
+
(0, attribute_loader_1.attributeLoader)(gl, pos3DObj, 0, 3, { divisor });
|
|
108
|
+
(0, attribute_loader_1.attributeLoader)(gl, radiusObj, 1, 1, { divisor, escapeValues: [-1] });
|
|
109
|
+
(0, attribute_loader_1.attributeLoader)(gl, colorObj, 2, 4, { divisor, escapeValues: [-1, -1, -1, -1] });
|
|
65
110
|
gl.bindVertexArray(null);
|
|
66
111
|
this._vaoCache.push(vao);
|
|
67
112
|
return vao;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (ubo === void 0) { ubo = null; }
|
|
72
|
-
var _a = this, gl = _a.gl, program = _a.program;
|
|
113
|
+
}
|
|
114
|
+
draw(vao, drawOptions, opacity = 1.0, ubo = null) {
|
|
115
|
+
const { gl, program } = this;
|
|
73
116
|
gl.useProgram(program);
|
|
74
117
|
gl.bindVertexArray(vao);
|
|
75
118
|
if (opacity !== this._uniforms.opacity) {
|
|
@@ -81,22 +124,19 @@ var Logic = /** @class */ (function () {
|
|
|
81
124
|
(0, methods_1.drawInstanced)(gl, gl.TRIANGLE_FAN, drawOptions);
|
|
82
125
|
ubo.unbind();
|
|
83
126
|
gl.bindVertexArray(null);
|
|
84
|
-
}
|
|
85
|
-
|
|
127
|
+
}
|
|
128
|
+
free() {
|
|
86
129
|
if (this._isFreed)
|
|
87
130
|
return;
|
|
88
131
|
totems_1.CameraUniformBlockTotemCache.release(this.globe);
|
|
89
132
|
this.gl.deleteProgram(this.program);
|
|
90
|
-
for (
|
|
91
|
-
var vao = _a[_i];
|
|
133
|
+
for (const vao of this._vaoCache)
|
|
92
134
|
this.gl.deleteVertexArray(vao);
|
|
93
|
-
}
|
|
94
135
|
this._isFreed = true;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe); }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const ElementGlobeSufaceGlowCache = Object.freeze({
|
|
139
|
+
get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
140
|
+
release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe)
|
|
101
141
|
});
|
|
102
142
|
exports.ElementGlobeSufaceGlowCache = ElementGlobeSufaceGlowCache;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ElementPointGlowProgramCache = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
const util_1 = require("../../util");
|
|
5
|
+
const totems_1 = require("../totems");
|
|
6
|
+
const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
|
|
7
|
+
const programcache_1 = require("../programcache");
|
|
8
|
+
const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
|
|
9
|
+
const methods_1 = require("../../util/gl-util/draw-options/methods");
|
|
10
|
+
const manager_1 = require("../../util/gl-util/uniform-block/manager");
|
|
11
|
+
const singularity_1 = require("../../shaders/fragment-toy/singularity");
|
|
12
|
+
const firework_1 = require("../../shaders/fragment-toy/firework");
|
|
13
|
+
const cameraBlockBindingPoint = 0;
|
|
14
|
+
const flexibleBlockBindingPoint = 1;
|
|
15
|
+
const uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
|
|
16
16
|
{ name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
|
|
17
17
|
{ name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
|
|
18
18
|
{ name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
|
|
@@ -20,14 +20,84 @@ var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
|
|
|
20
20
|
{ name: "u_minimumSize", type: "float", value: new Float32Array([25.0]) },
|
|
21
21
|
{ name: "u_phase", type: "float", value: new Float32Array([1.0]) },
|
|
22
22
|
], flexibleBlockBindingPoint);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const vs = `#version 300 es
|
|
24
|
+
precision highp float;
|
|
25
|
+
|
|
26
|
+
${totems_1.CameraUniformBlockString}
|
|
27
|
+
${geometrytransformations_1.mercatorXYToGLPosition}
|
|
28
|
+
${geometrytransformations_1.cartesian3DToGLPosition}
|
|
29
|
+
|
|
30
|
+
${uniformBlockManager.glslCode()}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
in vec3 pos3D;
|
|
34
|
+
in vec2 pos2D;
|
|
35
|
+
in vec4 color;
|
|
36
|
+
in float size;
|
|
37
|
+
|
|
38
|
+
out vec4 vColor;
|
|
39
|
+
flat out float v_size;
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
void main() {
|
|
44
|
+
|
|
45
|
+
if(is3D){
|
|
46
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
gl_Position = mercatorXYToGLPosition(pos2D);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
gl_PointSize = max(
|
|
53
|
+
((size == -1.0) ? u_size : size ) * u_size_multiplier,
|
|
54
|
+
u_minimumSize);
|
|
55
|
+
v_size = gl_PointSize;
|
|
56
|
+
vColor = (color.r == -1.0) ? u_rgba : color;
|
|
57
|
+
vColor.a *= u_opacity;
|
|
58
|
+
|
|
59
|
+
}`;
|
|
60
|
+
const fs = `#version 300 es
|
|
61
|
+
precision highp float;
|
|
62
|
+
|
|
63
|
+
${uniformBlockManager.glslCode()}
|
|
64
|
+
|
|
65
|
+
in vec4 vColor;
|
|
66
|
+
out vec4 fragColor;
|
|
67
|
+
|
|
68
|
+
flat in float v_size;
|
|
69
|
+
|
|
70
|
+
${firework_1.firework}
|
|
71
|
+
${singularity_1.singularity}
|
|
72
|
+
|
|
73
|
+
void main() {
|
|
74
|
+
fragColor = vColor;
|
|
75
|
+
|
|
76
|
+
float dist = distance(gl_PointCoord, vec2(0.5, 0.5)) * 2.0;
|
|
77
|
+
if ( dist > 1.0) discard;
|
|
78
|
+
|
|
79
|
+
// center glow
|
|
80
|
+
float center_alpha = smoothstep(0.5, 0.0, dist) * 0.3;
|
|
81
|
+
// center_alpha = smoothstep(0.0, 1.0, center_alpha);
|
|
82
|
+
|
|
83
|
+
// circle pattern
|
|
84
|
+
float threshold = fract(( - dist + u_phase - 0.5));
|
|
85
|
+
float circle_alpha = sin( threshold * 1.57 );
|
|
86
|
+
circle_alpha = smoothstep((v_size / (v_size + .5)), 1.0, circle_alpha);
|
|
87
|
+
|
|
88
|
+
float outer_circle_alpha = sin(dist * 1.57 );
|
|
89
|
+
outer_circle_alpha = smoothstep((v_size / (v_size + .5)), 1.0, outer_circle_alpha);
|
|
90
|
+
|
|
91
|
+
// fragColor = singularity(gl_PointCoord, u_phase);
|
|
92
|
+
|
|
93
|
+
fragColor.a *= smoothstep(0.0, 1.1, ( 0.4 * u_opacity + center_alpha + circle_alpha+ outer_circle_alpha));
|
|
94
|
+
}`;
|
|
95
|
+
class Logic {
|
|
96
|
+
constructor(globe) {
|
|
27
97
|
this.globe = globe;
|
|
28
98
|
this.gl = globe.gl;
|
|
29
99
|
this.program = (0, util_1.createProgram)(this.gl, vs, fs);
|
|
30
|
-
|
|
100
|
+
const { gl, program } = this;
|
|
31
101
|
gl.bindAttribLocation(program, 0, "pos3D");
|
|
32
102
|
gl.bindAttribLocation(program, 1, "pos2D");
|
|
33
103
|
gl.bindAttribLocation(program, 2, "color");
|
|
@@ -38,9 +108,9 @@ var Logic = /** @class */ (function () {
|
|
|
38
108
|
uniformBlockManager.assignBindingPoint(this.gl, this.program);
|
|
39
109
|
this._defaultUBO = uniformBlockManager.createUBO(this.gl);
|
|
40
110
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
111
|
+
createVAO(pos3DBuffer, pos2DBuffer, colorBuffer, sizeBuffer) {
|
|
112
|
+
const { gl } = this;
|
|
113
|
+
const vao = gl.createVertexArray();
|
|
44
114
|
gl.bindVertexArray(vao);
|
|
45
115
|
(0, attribute_loader_1.attributeLoader)(gl, pos3DBuffer, 0, 3);
|
|
46
116
|
(0, attribute_loader_1.attributeLoader)(gl, pos2DBuffer, 1, 2);
|
|
@@ -49,14 +119,13 @@ var Logic = /** @class */ (function () {
|
|
|
49
119
|
gl.bindVertexArray(null);
|
|
50
120
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
51
121
|
return vao;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
122
|
+
}
|
|
123
|
+
createUBO() {
|
|
124
|
+
const ubo = uniformBlockManager.createUBO(this.gl);
|
|
55
125
|
return ubo;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var _a = this, gl = _a.gl, program = _a.program, cameraBlockTotem = _a.cameraBlockTotem;
|
|
126
|
+
}
|
|
127
|
+
draw(vao, drawOptions, ubo = null) {
|
|
128
|
+
const { gl, program, cameraBlockTotem } = this;
|
|
60
129
|
gl.useProgram(program);
|
|
61
130
|
gl.bindVertexArray(vao);
|
|
62
131
|
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
@@ -67,19 +136,18 @@ var Logic = /** @class */ (function () {
|
|
|
67
136
|
gl.bindVertexArray(null);
|
|
68
137
|
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
69
138
|
this.globe.DrawRender();
|
|
70
|
-
}
|
|
139
|
+
}
|
|
71
140
|
// for singleton cache interation
|
|
72
|
-
|
|
141
|
+
free() {
|
|
73
142
|
if (this._isFreed)
|
|
74
143
|
return;
|
|
75
144
|
totems_1.CameraUniformBlockTotemCache.release(this.globe);
|
|
76
145
|
this.gl.deleteProgram(this.program);
|
|
77
146
|
this._isFreed = true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const ElementPointGlowProgramCache = Object.freeze({
|
|
150
|
+
get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
151
|
+
release: globe => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
|
|
84
152
|
});
|
|
85
153
|
exports.ElementPointGlowProgramCache = ElementPointGlowProgramCache;
|
|
@@ -1,18 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PointOnGlobeProgramCache = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const util_1 = require("../../util");
|
|
5
|
+
const totems_1 = require("../totems");
|
|
6
|
+
const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
|
|
7
|
+
const programcache_1 = require("../programcache");
|
|
8
|
+
const vs = `#version 300 es
|
|
9
|
+
${totems_1.CameraUniformBlockString}
|
|
10
|
+
${geometrytransformations_1.mercatorXYToGLPosition}
|
|
11
|
+
${geometrytransformations_1.cartesian3DToGLPosition}
|
|
12
|
+
precision highp float;
|
|
13
|
+
precision highp int;
|
|
14
|
+
|
|
15
|
+
uniform int hovered_vertexID; // can be removed
|
|
16
|
+
|
|
17
|
+
in vec3 pos3D;
|
|
18
|
+
in vec2 pos2D;
|
|
19
|
+
in vec4 rgba;
|
|
20
|
+
|
|
21
|
+
uniform float pointSize;
|
|
22
|
+
uniform float hoveredPointSize;
|
|
23
|
+
|
|
24
|
+
flat out highp int vVertexID;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
out vec4 v_rgba;
|
|
28
|
+
|
|
29
|
+
void main() {
|
|
30
|
+
|
|
31
|
+
if(is3D){
|
|
32
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
33
|
+
}
|
|
34
|
+
else{
|
|
35
|
+
gl_Position = mercatorXYToGLPosition(pos2D);
|
|
36
|
+
}
|
|
37
|
+
if (hovered_vertexID == gl_VertexID) {
|
|
38
|
+
gl_PointSize = hoveredPointSize;
|
|
39
|
+
} else {
|
|
40
|
+
gl_PointSize = pointSize;
|
|
41
|
+
}
|
|
42
|
+
v_rgba = rgba;
|
|
43
|
+
vVertexID = gl_VertexID;
|
|
44
|
+
}`;
|
|
45
|
+
const fs = `#version 300 es
|
|
46
|
+
precision highp float;
|
|
47
|
+
|
|
48
|
+
uniform float opacity;
|
|
49
|
+
|
|
50
|
+
flat in highp int vVertexID;
|
|
51
|
+
in vec4 v_rgba;
|
|
52
|
+
|
|
53
|
+
layout(location = 0) out vec4 fragColor;
|
|
54
|
+
layout(location = 1) out int vertexID;
|
|
55
|
+
|
|
56
|
+
void main() {
|
|
57
|
+
vertexID = vVertexID;
|
|
58
|
+
fragColor = v_rgba;
|
|
59
|
+
fragColor.a *= opacity;
|
|
60
|
+
}`;
|
|
61
|
+
class PointOnGlobeProgram {
|
|
62
|
+
constructor(globe) {
|
|
12
63
|
this.globe = globe;
|
|
13
64
|
this.gl = globe.gl;
|
|
14
65
|
this.program = (0, util_1.createProgram)(this.gl, vs, fs);
|
|
15
|
-
|
|
66
|
+
const { gl, program } = this;
|
|
16
67
|
this.uniforms = {
|
|
17
68
|
opacity: gl.getUniformLocation(program, "opacity"),
|
|
18
69
|
hovered_vertexID: gl.getUniformLocation(program, "hovered_vertexID"),
|
|
@@ -25,7 +76,7 @@ var PointOnGlobeProgram = /** @class */ (function () {
|
|
|
25
76
|
this._lastPointSize = 2.0;
|
|
26
77
|
this._lastHoveredPointSize = 4.0;
|
|
27
78
|
this._lastHoveredID = -1;
|
|
28
|
-
|
|
79
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
29
80
|
gl.useProgram(program);
|
|
30
81
|
gl.uniform1f(this.uniforms.opacity, this._lastOpacity);
|
|
31
82
|
gl.uniform1f(this.uniforms.pointSize, this._lastPointSize);
|
|
@@ -43,13 +94,13 @@ var PointOnGlobeProgram = /** @class */ (function () {
|
|
|
43
94
|
{ // arrange camera uniform block
|
|
44
95
|
this.cameraBlockBingingPoint = 0;
|
|
45
96
|
this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
|
|
46
|
-
|
|
97
|
+
const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
47
98
|
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBingingPoint);
|
|
48
99
|
}
|
|
49
100
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
101
|
+
createVAO(pos3DBuffer, pos2DBuffer, rgbaBuffer) {
|
|
102
|
+
const { gl } = this;
|
|
103
|
+
const vao = gl.createVertexArray();
|
|
53
104
|
gl.bindVertexArray(vao);
|
|
54
105
|
// eslint-disable-next-line
|
|
55
106
|
{
|
|
@@ -72,12 +123,11 @@ var PointOnGlobeProgram = /** @class */ (function () {
|
|
|
72
123
|
gl.bindVertexArray(null);
|
|
73
124
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
74
125
|
return vao;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.opacity, opacity = _c === void 0 ? 1.0 : _c, _d = _b.hoveredID, hoveredID = _d === void 0 ? -1 : _d, _e = _b.pointSize, pointSize = _e === void 0 ? 2.0 : _e, _f = _b.hoveredPointSize, hoveredPointSize = _f === void 0 ? 4.0 : _f, _g = _b.elementBuffer, elementBuffer = _g === void 0 ? null : _g;
|
|
126
|
+
}
|
|
127
|
+
draw(vao, length, { opacity = 1.0, hoveredID = -1, pointSize = 2.0, hoveredPointSize = 4.0, elementBuffer = null } = {}) {
|
|
78
128
|
if (length === 0 || opacity === 0)
|
|
79
129
|
return;
|
|
80
|
-
|
|
130
|
+
const { gl, program, uniforms } = this;
|
|
81
131
|
gl.useProgram(program);
|
|
82
132
|
if (this._lastOpacity !== opacity) {
|
|
83
133
|
gl.uniform1f(uniforms.opacity, opacity);
|
|
@@ -107,19 +157,18 @@ var PointOnGlobeProgram = /** @class */ (function () {
|
|
|
107
157
|
}
|
|
108
158
|
this.cameraBlockTotem.unbind(this.cameraBlockBingingPoint);
|
|
109
159
|
gl.bindVertexArray(null);
|
|
110
|
-
}
|
|
111
|
-
|
|
160
|
+
}
|
|
161
|
+
free() {
|
|
112
162
|
if (this._isFreed)
|
|
113
163
|
return;
|
|
114
|
-
|
|
164
|
+
const { gl, globe } = this;
|
|
115
165
|
totems_1.CameraUniformBlockTotemCache.release(globe);
|
|
116
166
|
gl.deleteProgram(this.program);
|
|
117
167
|
this._isFreed = true;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram); }
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const PointOnGlobeProgramCache = Object.freeze({
|
|
171
|
+
get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram),
|
|
172
|
+
release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram)
|
|
124
173
|
});
|
|
125
174
|
exports.PointOnGlobeProgramCache = PointOnGlobeProgramCache;
|
package/programs/programcache.js
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.noRegisterGlobeProgramCache = exports.glProgramCache = exports.globeProgramCache = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const globeProgramCache = (function () {
|
|
18
|
+
const cache = new Map();
|
|
19
19
|
function getProgram(globe, ProgramClass) {
|
|
20
20
|
if (!cache.has(globe)) {
|
|
21
21
|
cache.set(globe, new Map());
|
|
@@ -26,7 +26,7 @@ var globeProgramCache = (function () {
|
|
|
26
26
|
program: new ProgramClass(),
|
|
27
27
|
count: 1
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
const firstObject = globe.DrawOrder.GetObj(0);
|
|
30
30
|
globe.api_RegisterPlugin(cache.get(globe).get(ProgramClass).program, firstObject);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
@@ -49,13 +49,13 @@ var globeProgramCache = (function () {
|
|
|
49
49
|
}
|
|
50
50
|
;
|
|
51
51
|
return Object.freeze({
|
|
52
|
-
getProgram
|
|
53
|
-
releaseProgram
|
|
52
|
+
getProgram,
|
|
53
|
+
releaseProgram
|
|
54
54
|
});
|
|
55
55
|
})();
|
|
56
56
|
exports.globeProgramCache = globeProgramCache;
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const glProgramCache = (function () {
|
|
58
|
+
const cache = new Map();
|
|
59
59
|
function getProgram(gl, ProgramClass) {
|
|
60
60
|
if (!cache.has(gl)) {
|
|
61
61
|
cache.set(gl, new Map());
|
|
@@ -87,13 +87,13 @@ var glProgramCache = (function () {
|
|
|
87
87
|
}
|
|
88
88
|
;
|
|
89
89
|
return Object.freeze({
|
|
90
|
-
getProgram
|
|
91
|
-
releaseProgram
|
|
90
|
+
getProgram,
|
|
91
|
+
releaseProgram
|
|
92
92
|
});
|
|
93
93
|
})();
|
|
94
94
|
exports.glProgramCache = glProgramCache;
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
const noRegisterGlobeProgramCache = (function () {
|
|
96
|
+
const cache = new Map();
|
|
97
97
|
function getProgram(globe, ProgramClass) {
|
|
98
98
|
if (!cache.has(globe)) {
|
|
99
99
|
cache.set(globe, new Map());
|
|
@@ -124,8 +124,8 @@ var noRegisterGlobeProgramCache = (function () {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
return Object.freeze({
|
|
127
|
-
getProgram
|
|
128
|
-
releaseProgram
|
|
127
|
+
getProgram,
|
|
128
|
+
releaseProgram
|
|
129
129
|
});
|
|
130
130
|
})();
|
|
131
131
|
exports.noRegisterGlobeProgramCache = noRegisterGlobeProgramCache;
|