@pirireis/webglobeplugins 0.9.9 → 0.9.10
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 +15 -0
- package/Math/arc.js +65 -0
- package/Math/bounds/line-bbox.js +188 -0
- package/Math/constants.js +9 -0
- package/Math/frustum/camera.js +24 -0
- package/Math/frustum/from-globeinfo.js +48 -0
- package/Math/frustum/types.js +2 -0
- package/Math/globe-util/horizon-plane.js +112 -0
- package/Math/index.js +1 -0
- package/Math/juction/arc-plane.js +83 -0
- package/Math/juction/line-sphere.js +25 -0
- package/Math/juction/plane-plane.js +58 -0
- package/Math/line.js +56 -0
- package/Math/matrix4.js +1 -0
- package/Math/methods.js +201 -0
- package/Math/plane.js +60 -0
- package/Math/quaternion.js +104 -0
- package/Math/types.js +2 -0
- package/Math/utils.js +4 -0
- package/Math/vec3.js +126 -0
- package/algorithms/search-binary.js +19 -0
- package/altitude-locator/adaptors.js +1 -0
- package/altitude-locator/draw-subset-obj.js +18 -0
- package/altitude-locator/keymethod.js +1 -0
- package/altitude-locator/plugin.js +341 -0
- package/altitude-locator/types.js +23 -0
- package/arrowfield/adaptor.js +14 -0
- package/arrowfield/index.js +10 -0
- package/arrowfield/plugin.js +86 -0
- package/bearing-line/index.js +8 -0
- package/bearing-line/plugin.js +449 -0
- package/circle-line-chain/chain-list-map.js +205 -0
- package/circle-line-chain/init.js +1 -0
- package/circle-line-chain/plugin.js +424 -0
- package/circle-line-chain/util.js +5 -0
- package/compass-rose/compass-rose-padding-flat.js +225 -0
- package/compass-rose/compass-text-writer.js +153 -0
- package/compass-rose/index.js +7 -0
- package/compassrose/compassrose.js +296 -0
- package/compassrose/index.js +8 -0
- package/globe-types.js +1 -0
- package/heatwave/index.js +10 -0
- package/heatwave/isobar/objectarraylabels.js +202 -0
- package/heatwave/isobar/plugin.js +343 -0
- package/heatwave/isobar/quadtreecontours.js +300 -0
- package/heatwave/plugins/heatwaveglobeshell.js +206 -0
- package/jest.config.js +7 -0
- package/package.json +4 -4
- package/partialrings/buffer-manager.js +81 -0
- package/partialrings/index.js +41 -0
- package/partialrings/plugin.js +135 -0
- package/partialrings/program.js +286 -0
- package/pin/pin-object-array.js +305 -0
- package/pin/pin-point-totem.js +60 -0
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
- package/point-heat-map/index.js +1 -0
- package/point-heat-map/plugin-webworker.js +126 -0
- package/point-heat-map/point-to-heat-map-flow.js +127 -0
- package/point-tracks/key-methods.js +5 -0
- package/point-tracks/plugin.js +338 -0
- package/programs/arrowfield/index.js +7 -0
- package/programs/arrowfield/logic.js +257 -0
- package/programs/arrowfield/object.js +66 -0
- package/programs/data2legend/density-to-legend.js +101 -0
- package/programs/data2legend/point-to-density-texture.js +100 -0
- package/programs/float2legendwithratio/index.js +8 -0
- package/programs/float2legendwithratio/logic.js +171 -0
- package/programs/float2legendwithratio/object.js +110 -0
- package/programs/globe-util/is-globe-moved.js +21 -0
- package/programs/globeshell/index.js +8 -0
- package/programs/globeshell/noise/noises.js +1 -0
- package/programs/globeshell/wiggle/index.js +8 -0
- package/programs/globeshell/wiggle/logic.js +345 -0
- package/programs/globeshell/wiggle/object.js +72 -0
- package/programs/helpers/blender/index.js +1 -0
- package/programs/helpers/blender/program.js +79 -0
- package/programs/helpers/fadeaway/index.js +7 -0
- package/programs/helpers/fadeaway/logic.js +72 -0
- package/programs/helpers/fadeaway/object.js +20 -0
- package/programs/helpers/index.js +8 -0
- package/programs/index.js +58 -0
- package/programs/interface.js +1 -0
- package/programs/line-on-globe/angled-line.js +176 -0
- package/programs/line-on-globe/circle-accurate-3d.js +141 -0
- package/programs/line-on-globe/circle-accurate-flat.js +216 -0
- package/programs/line-on-globe/circle-accurate.js +178 -0
- package/programs/line-on-globe/circle.js +167 -0
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +159 -0
- package/programs/line-on-globe/index.js +1 -0
- package/programs/line-on-globe/lines-color-instanced-flat.js +136 -0
- package/programs/line-on-globe/linestrip.js +171 -0
- package/programs/line-on-globe/naive-accurate-flexible.js +195 -0
- package/programs/line-on-globe/to-the-surface.js +111 -0
- package/programs/line-on-globe/util.js +8 -0
- package/programs/picking/pickable-renderer.js +188 -0
- package/programs/point-on-globe/element-globe-surface-glow.js +142 -0
- package/programs/point-on-globe/element-point-glow.js +153 -0
- package/programs/point-on-globe/square-pixel-point.js +174 -0
- package/programs/programcache.js +131 -0
- package/programs/rings/distancering/circleflatprogram.js +156 -0
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +369 -0
- package/programs/rings/distancering/circlepaddysharedbuffer.js +357 -0
- package/programs/rings/distancering/index.js +14 -0
- package/programs/rings/distancering/paddyflatprogram.js +172 -0
- package/programs/rings/distancering/paddyflatprogram2d.js +174 -0
- package/programs/rings/distancering/paddyflatprogram3d.js +172 -0
- package/programs/rings/distancering/shader.js +1 -0
- package/programs/rings/index.js +17 -0
- package/programs/rings/partial-ring/piece-of-pie.js +275 -0
- package/programs/totems/camerauniformblock.js +160 -0
- package/programs/totems/canvas-webglobe-info.js +110 -0
- package/programs/totems/gpu-selection-uniform-block.js +108 -0
- package/programs/totems/index.js +40 -0
- package/programs/two-d/pixel-circle.js +1 -0
- package/programs/two-d/pixel-padding-for-compass.js +162 -0
- package/programs/util.js +17 -0
- package/programs/vectorfields/index.js +23 -0
- package/programs/vectorfields/logics/drawrectangleparticles.js +107 -0
- package/programs/vectorfields/logics/index.js +12 -0
- package/programs/vectorfields/logics/pixelbased.js +142 -0
- package/programs/vectorfields/logics/ubo.js +63 -0
- package/programs/vectorfields/pingpongbuffermanager.js +76 -0
- package/rangerings/enum.js +5 -0
- package/rangerings/index.js +15 -0
- package/rangerings/plugin.js +560 -0
- package/rangerings/rangeringangletext.js +329 -0
- package/rangerings/ring-account.js +117 -0
- package/shaders/fragment-toy/firework.js +58 -0
- package/shaders/fragment-toy/singularity.js +59 -0
- package/shape-on-terrain/arc/naive/plugin.js +252 -0
- package/timetracks/adaptors-line-strip.js +71 -0
- package/timetracks/adaptors.js +122 -0
- package/timetracks/index.js +19 -0
- package/timetracks/plugin-line-strip.js +250 -0
- package/timetracks/plugin.js +258 -0
- package/timetracks/program-line-strip.js +611 -0
- package/timetracks/program.js +772 -0
- package/timetracks/programpoint-line-strip.js +154 -0
- package/timetracks/programpoint.js +147 -0
- package/types.js +15 -0
- package/util/account/bufferoffsetmanager.js +179 -0
- package/util/account/index.js +23 -0
- package/util/account/single-attribute-buffer-management/buffer-manager.js +108 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +150 -0
- package/util/account/single-attribute-buffer-management/index.js +9 -0
- package/util/account/single-attribute-buffer-management/object-store.js +51 -0
- package/util/account/single-attribute-buffer-management/types.js +2 -0
- package/util/account/util.js +22 -0
- package/util/algorithms/index.js +1 -0
- package/util/algorithms/search-binary.js +28 -0
- package/util/check/get.js +18 -0
- package/util/check/index.js +1 -0
- package/util/check/typecheck.js +49 -0
- package/util/geometry/index.js +51 -0
- package/util/gl-util/buffer/attribute-loader.js +69 -0
- package/util/gl-util/buffer/index.js +6 -0
- package/util/gl-util/buffer/types.js +1 -0
- package/util/gl-util/draw-options/methods.js +38 -0
- package/util/gl-util/draw-options/types.js +15 -0
- package/util/gl-util/uniform-block/manager.js +156 -0
- package/util/gl-util/uniform-block/shader.js +1 -0
- package/util/gl-util/uniform-block/types.js +8 -0
- package/util/heatwavedatamanager/datamanager.js +152 -0
- package/util/heatwavedatamanager/index.js +10 -0
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +122 -0
- package/util/heatwavedatamanager/pointcoordsmeta.js +20 -0
- package/util/index.js +57 -0
- package/util/interpolation/index.js +1 -0
- package/util/interpolation/timetrack/index.js +5 -0
- package/util/interpolation/timetrack/timetrack-interpolator.js +79 -0
- package/util/interpolation/timetrack/web-worker-str.js +183 -0
- package/util/interpolation/timetrack/web-worker.js +48 -0
- package/util/jshelpers/data-filler.js +20 -0
- package/util/jshelpers/equality.js +20 -0
- package/util/jshelpers/index.js +37 -0
- package/util/jshelpers/timefilters.js +32 -0
- package/util/picking/fence.js +46 -0
- package/util/picking/picker-displayer.js +139 -0
- package/util/programs/draw-texture-on-canvas.js +89 -0
- package/util/programs/index.js +17 -0
- package/util/programs/shapesonglobe.js +214 -0
- package/util/programs/supersampletotextures.js +113 -0
- package/util/programs/texturetoglobe.js +182 -0
- package/util/shaderfunctions/geometrytransformations.js +340 -0
- package/util/shaderfunctions/index.js +18 -0
- package/util/shaderfunctions/nodata.js +11 -0
- package/util/shaderfunctions/noisefunctions.js +43 -0
- package/util/surface-line-data/arc-bboxes.js +25 -0
- package/util/surface-line-data/arcs-to-cuts.js +50 -0
- package/util/surface-line-data/cut-arc.js +1 -0
- package/util/surface-line-data/flow.js +28 -0
- package/util/surface-line-data/rbush-manager.js +1 -0
- package/util/surface-line-data/types.js +1 -0
- package/util/surface-line-data/web-worker.js +1 -0
- package/util/webglobe/gldefaultstates.js +7 -0
- package/util/webglobe/index.js +18 -0
- package/util/webglobe/rasteroverlay.js +78 -0
- package/util/webglobjectbuilders.js +388 -0
- package/util/webglobjectbuilders1.js +237 -0
- package/waveparticles/adaptor.js +17 -0
- package/waveparticles/index.js +10 -0
- package/waveparticles/plugin.js +266 -0
- package/wind/imagetovectorfieldandmagnitude.js +35 -0
- package/wind/index.js +14 -0
- package/wind/plugin.js +926 -0
- package/wind/vectorfieldimage.js +25 -0
- package/write-text/attached-text-writer.js +91 -0
- package/write-text/context-text.js +98 -0
- package/write-text/context-text3.js +155 -0
- package/write-text/index.js +5 -0
- package/write-text/writer-plugin.js +8 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const util_1 = require("./util");
|
|
4
|
+
const totems_1 = require("../totems");
|
|
5
|
+
const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
|
|
6
|
+
const programcache_1 = require("../programcache");
|
|
7
|
+
const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
|
|
8
|
+
require("../draw-options/types");
|
|
9
|
+
const methods_1 = require("../draw-options/methods");
|
|
10
|
+
const vs = `#version 300 es
|
|
11
|
+
${geometrytransformations_1.R_3D}
|
|
12
|
+
${totems_1.CameraUniformBlockString}
|
|
13
|
+
${geometrytransformations_1.cartesian3DToGLPosition}
|
|
14
|
+
in vec3 pos3D
|
|
15
|
+
in vec4 color;
|
|
16
|
+
out float ratio;
|
|
17
|
+
out flat vec4 vColor;
|
|
18
|
+
void main(){
|
|
19
|
+
if ( gl_VertexID == 0) {
|
|
20
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
21
|
+
ratio =0.0;
|
|
22
|
+
} else {
|
|
23
|
+
vec3 sea_level_pos3D = norm(pos3D) * R_3D;
|
|
24
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
25
|
+
ratio = 1.0;
|
|
26
|
+
}
|
|
27
|
+
vColor = color;
|
|
28
|
+
}`;
|
|
29
|
+
const fs = `#version 300 es
|
|
30
|
+
uniform float opacity;
|
|
31
|
+
uniform float phase;
|
|
32
|
+
uniform float fadeOpacity;
|
|
33
|
+
in flat vec4 vColor;
|
|
34
|
+
in float ratio;
|
|
35
|
+
out vec4 fragColor;
|
|
36
|
+
void main(){
|
|
37
|
+
fragColor = vec4( vColor.rgb, vColor.a * opacity);
|
|
38
|
+
if (fadeOpacity < 1.0) {
|
|
39
|
+
float alpha= mix( fadeOpacity, vColor.a, fract( ratio + phase ));
|
|
40
|
+
fragColor.a *= alpha;
|
|
41
|
+
}
|
|
42
|
+
}`;
|
|
43
|
+
class Logic {
|
|
44
|
+
constructor(globe) {
|
|
45
|
+
this.globe = globe;
|
|
46
|
+
this.gl = globe.gl;
|
|
47
|
+
this.program = (0, util_1.createProgram)(this.gl, vs, fs);
|
|
48
|
+
const { gl, program } = this;
|
|
49
|
+
this._opacity = {
|
|
50
|
+
lastValue: 1.0,
|
|
51
|
+
location: gl.getUniformLocation(program, 'opacity')
|
|
52
|
+
};
|
|
53
|
+
this._phase = {
|
|
54
|
+
lastValue: 1.0,
|
|
55
|
+
location: gl.getUniformLocation(program, 'phase')
|
|
56
|
+
};
|
|
57
|
+
this._fadeOpacity = {
|
|
58
|
+
lastValue: 1.0,
|
|
59
|
+
location: gl.getUniformBlockLocation(program, 'fadeOpacity')
|
|
60
|
+
};
|
|
61
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
62
|
+
gl.useProgram(program);
|
|
63
|
+
[this._opacity, this._phase, this._fadeOpacity].forEach((wrapper) => gl.uniform1f(wrapper.location, wrapper.lastValue));
|
|
64
|
+
gl.useProgram(currentProgram);
|
|
65
|
+
gl.useProgram(program);
|
|
66
|
+
gl.bindAttribLocation(program, 0, 'pos3D');
|
|
67
|
+
gl.bindAttribLocation(program, 1, 'color');
|
|
68
|
+
this.cameraUniformBlockTotem = new totems_1.CameraUniformBlockTotemCache.get(globe);
|
|
69
|
+
this.cameraBlockBindingPoint = 0;
|
|
70
|
+
const cameraBlockIndex = gl.getUniformBlockLocation(program, 'CameraUniformBlock');
|
|
71
|
+
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
72
|
+
}
|
|
73
|
+
createVao(pos3DObj, colorObj) {
|
|
74
|
+
const { gl } = this;
|
|
75
|
+
const vao = gl.createVertexArray();
|
|
76
|
+
const divisor = 1;
|
|
77
|
+
gl.bindVertexArray(vao);
|
|
78
|
+
(0, attribute_loader_1.attributeLoader)(gl, pos3DObj, 0, 3, { divisor });
|
|
79
|
+
(0, attribute_loader_1.attributeLoader)(gl, colorObj, 1, 4, { divisor, escapeValue: [-1, -1, -1, -1] });
|
|
80
|
+
gl.bindVertexArray(null);
|
|
81
|
+
this._vaoCache.push(vao);
|
|
82
|
+
return vao;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* @param {WebGL2RenderingContext.vertexArrayObject} vao
|
|
87
|
+
* @param {Render} drawOptions
|
|
88
|
+
*/
|
|
89
|
+
draw(vao, drawOptions, { opacity = 1.0, fadeOpacity = 1.0, }) {
|
|
90
|
+
const { globe, gl, program, _opacity, _fadeOpacity } = this;
|
|
91
|
+
gl.useProgram(program);
|
|
92
|
+
gl.bindVertexArray(vao);
|
|
93
|
+
if (fadeOpacity < 1.0) {
|
|
94
|
+
this._updatePhase();
|
|
95
|
+
globe.drawRender();
|
|
96
|
+
}
|
|
97
|
+
if (fadeOpacity !== _fadeOpacity.lastValue) {
|
|
98
|
+
_fadeOpacity.lastValue = fadeOpacity;
|
|
99
|
+
gl.uniform1f(_fadeOpacity.location, fadeOpacity);
|
|
100
|
+
}
|
|
101
|
+
if (opacity !== _opacity.lastValue) {
|
|
102
|
+
_opacity.lastValue = opacity;
|
|
103
|
+
gl.uniform1f(_opacity.location, opacity);
|
|
104
|
+
}
|
|
105
|
+
(0, methods_1.drawInstanced)(gl, gl.TRIANGLE_FAN, drawOptions);
|
|
106
|
+
}
|
|
107
|
+
_updatePhase() {
|
|
108
|
+
this._phase.lastValue = (Date.now() / 3.0) % 1000;
|
|
109
|
+
gl.uniform1f(_phase.location, _phase.lastValue);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PickableRendererProgramCache = void 0;
|
|
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
|
+
require("../../util/gl-util/draw-options/types");
|
|
9
|
+
const methods_1 = require("../../util/gl-util/draw-options/methods");
|
|
10
|
+
const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
|
|
11
|
+
const manager_1 = require("../../util/gl-util/uniform-block/manager");
|
|
12
|
+
const uniformBindingPoints = {
|
|
13
|
+
camera: 0,
|
|
14
|
+
flexible: 1
|
|
15
|
+
};
|
|
16
|
+
const uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
|
|
17
|
+
{ name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
|
|
18
|
+
{ name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
|
|
19
|
+
{ name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
|
|
20
|
+
{ name: "u_size", type: "float", value: new Float32Array([1.0]) },
|
|
21
|
+
{ name: "u_minimum_size", type: "float", value: new Float32Array([1.0]) },
|
|
22
|
+
{ name: "u_draw_mode", type: "int", value: new Int32Array([0]) }, // 0.0 for point, 1.0 for line
|
|
23
|
+
{ name: "u_is_circle", type: "bool", value: new Float32Array([1.0]) },
|
|
24
|
+
{ name: "u_dash_count", type: "float", value: new Float32Array([1.0]) },
|
|
25
|
+
{ name: "u_dash_opacity_multiplier", type: "float", value: new Float32Array([1.0]) },
|
|
26
|
+
{ name: "u_dash_phase", type: "float", value: new Float32Array([0.0]) },
|
|
27
|
+
], uniformBindingPoints.flexible);
|
|
28
|
+
const vs = `#version 300 es
|
|
29
|
+
${geometrytransformations_1.R}
|
|
30
|
+
${geometrytransformations_1.R_3D}
|
|
31
|
+
${totems_1.CameraUniformBlockString}
|
|
32
|
+
${geometrytransformations_1.mercatorXYToGLPosition}
|
|
33
|
+
${geometrytransformations_1.cartesian3DToGLPosition}
|
|
34
|
+
|
|
35
|
+
${uniformBlockManager.glslCode()}
|
|
36
|
+
|
|
37
|
+
precision highp float;
|
|
38
|
+
precision highp int;
|
|
39
|
+
|
|
40
|
+
in vec3 pos3D;
|
|
41
|
+
in vec2 pos2D;
|
|
42
|
+
in vec4 rgba;
|
|
43
|
+
in float size;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
flat out highp int vVertexID;
|
|
47
|
+
|
|
48
|
+
out vec4 v_rgba;
|
|
49
|
+
|
|
50
|
+
out float v_length;
|
|
51
|
+
|
|
52
|
+
void main() {
|
|
53
|
+
|
|
54
|
+
v_rgba = (rgba.r == -1.0) ? u_rgba : rgba;
|
|
55
|
+
v_rgba.a *= u_opacity;
|
|
56
|
+
gl_PointSize = max(((size == -1.0) ? u_size : size) * u_size_multiplier, u_minimum_size);
|
|
57
|
+
|
|
58
|
+
float size_fixer;
|
|
59
|
+
if(is3D){
|
|
60
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
61
|
+
size_fixer = smoothstep(0.15, 1.0, 0.5 * R_3D / gl_Position.w) ;
|
|
62
|
+
} else {
|
|
63
|
+
gl_Position = mercatorXYToGLPosition(pos2D);
|
|
64
|
+
size_fixer = smoothstep(2.0, 5.2, z_level);
|
|
65
|
+
}
|
|
66
|
+
gl_PointSize *= size_fixer;
|
|
67
|
+
switch (u_draw_mode) {
|
|
68
|
+
case 0:
|
|
69
|
+
vVertexID = gl_VertexID;
|
|
70
|
+
break;
|
|
71
|
+
case 1:
|
|
72
|
+
v_length = float(gl_VertexID % 2);
|
|
73
|
+
vVertexID = (gl_VertexID - gl_VertexID % 2) / 2; // a line takes two points
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}`;
|
|
79
|
+
const fs = `#version 300 es
|
|
80
|
+
precision highp float;
|
|
81
|
+
precision highp int;
|
|
82
|
+
|
|
83
|
+
${uniformBlockManager.glslCode()}
|
|
84
|
+
|
|
85
|
+
flat in highp int vVertexID;
|
|
86
|
+
|
|
87
|
+
in vec4 v_rgba;
|
|
88
|
+
in float v_length;
|
|
89
|
+
|
|
90
|
+
layout(location = 0) out vec4 fragColor;
|
|
91
|
+
layout(location = 1) out int vertexID;
|
|
92
|
+
|
|
93
|
+
void main() {
|
|
94
|
+
vertexID = vVertexID;
|
|
95
|
+
fragColor = v_rgba;
|
|
96
|
+
|
|
97
|
+
switch (u_draw_mode) {
|
|
98
|
+
case 0:
|
|
99
|
+
float d = distance(gl_PointCoord, vec2(0.5, 0.5));
|
|
100
|
+
if (u_is_circle) {
|
|
101
|
+
if (d > 0.5) discard;
|
|
102
|
+
fragColor.a *= smoothstep(0.5, 0.45, d);
|
|
103
|
+
}
|
|
104
|
+
if (u_dash_opacity_multiplier < 1.0) {
|
|
105
|
+
float dash = sin(d * 3.14159 * 2.0 * u_dash_count + u_dash_phase) * (1.0 - u_dash_opacity_multiplier) + u_dash_opacity_multiplier;
|
|
106
|
+
fragColor.a *= dash;
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case 1:
|
|
110
|
+
if (u_dash_opacity_multiplier < 1.0 && fract((v_length + u_dash_phase) * u_dash_count) < 0.5) {
|
|
111
|
+
fragColor.a *= u_dash_opacity_multiplier;
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}`;
|
|
116
|
+
class PointOnGlobeProgram {
|
|
117
|
+
constructor(globe) {
|
|
118
|
+
this.globe = globe;
|
|
119
|
+
this.gl = globe.gl;
|
|
120
|
+
this._isFreed = false;
|
|
121
|
+
this.program = (0, util_1.createProgram)(this.gl, vs, fs);
|
|
122
|
+
const { gl, program } = this;
|
|
123
|
+
// assign opacity
|
|
124
|
+
// assign attribute locations
|
|
125
|
+
gl.bindAttribLocation(program, 0, "pos3D");
|
|
126
|
+
gl.bindAttribLocation(program, 1, "pos2D");
|
|
127
|
+
gl.bindAttribLocation(program, 2, "rgba");
|
|
128
|
+
gl.bindAttribLocation(program, 3, "size");
|
|
129
|
+
// arrange camera uniform block
|
|
130
|
+
this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
|
|
131
|
+
this.cameraBlockTotem.assignBindingPoint(program, uniformBindingPoints.camera);
|
|
132
|
+
uniformBlockManager.assignBindingPoint(this.gl, this.program);
|
|
133
|
+
this._defaultUBO = uniformBlockManager.createUBO(this.gl);
|
|
134
|
+
this._defaultUBO.update(new Map([
|
|
135
|
+
["u_rgba", [1, 1, 1, 1]],
|
|
136
|
+
["u_opacity", [1.0]],
|
|
137
|
+
["u_size_multiplier", [1.0]],
|
|
138
|
+
["u_size", [1.0]],
|
|
139
|
+
["u_is_circle", [1.0]],
|
|
140
|
+
]));
|
|
141
|
+
}
|
|
142
|
+
createUBO() {
|
|
143
|
+
const ubo = uniformBlockManager.createUBO(this.gl);
|
|
144
|
+
return ubo;
|
|
145
|
+
}
|
|
146
|
+
createVAO(pos3DBufferObj, pos2DBufferObj, rgbaBufferObj, sizeBufferObj) {
|
|
147
|
+
const { gl } = this;
|
|
148
|
+
const vao = gl.createVertexArray();
|
|
149
|
+
gl.bindVertexArray(vao);
|
|
150
|
+
(0, attribute_loader_1.attributeLoader)(gl, pos3DBufferObj, 0, 3);
|
|
151
|
+
(0, attribute_loader_1.attributeLoader)(gl, pos2DBufferObj, 1, 2);
|
|
152
|
+
(0, attribute_loader_1.attributeLoader)(gl, rgbaBufferObj, 2, 4, { escapeValues: [-1, -1, -1, -1] });
|
|
153
|
+
(0, attribute_loader_1.attributeLoader)(gl, sizeBufferObj, 3, 1, { escapeValues: [-1] });
|
|
154
|
+
gl.bindVertexArray(null);
|
|
155
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
156
|
+
return vao;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
*
|
|
160
|
+
* @param {vertexArrayObject} vao
|
|
161
|
+
* @param {DrawRangeIndexParams} drawOptions
|
|
162
|
+
*/
|
|
163
|
+
draw(vao, drawOptions, ubo = null) {
|
|
164
|
+
const { gl, program } = this;
|
|
165
|
+
gl.useProgram(program);
|
|
166
|
+
gl.bindVertexArray(vao);
|
|
167
|
+
this.cameraBlockTotem.bind(uniformBindingPoints.camera);
|
|
168
|
+
ubo = ubo || this._defaultUBO;
|
|
169
|
+
ubo.bind();
|
|
170
|
+
(0, methods_1.drawArrays)(gl, gl.POINTS, drawOptions);
|
|
171
|
+
ubo.unbind();
|
|
172
|
+
this.cameraBlockTotem.unbind(uniformBindingPoints.camera);
|
|
173
|
+
gl.bindVertexArray(null);
|
|
174
|
+
}
|
|
175
|
+
free() {
|
|
176
|
+
if (this._isFreed)
|
|
177
|
+
return;
|
|
178
|
+
const { gl, globe } = this;
|
|
179
|
+
totems_1.CameraUniformBlockTotemCache.release(globe);
|
|
180
|
+
gl.deleteProgram(this.program);
|
|
181
|
+
this._isFreed = true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const PickableRendererProgramCache = Object.freeze({
|
|
185
|
+
get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram),
|
|
186
|
+
release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram)
|
|
187
|
+
});
|
|
188
|
+
exports.PickableRendererProgramCache = PickableRendererProgramCache;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* *
|
|
4
|
+
* * *
|
|
5
|
+
* * * *
|
|
6
|
+
* * *
|
|
7
|
+
* *
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ElementGlobeSufaceGlowCache = void 0;
|
|
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
|
+
{ name: "u_color", type: "vec4" },
|
|
20
|
+
{ name: "u_radius", type: "float" }
|
|
21
|
+
], 1);
|
|
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) {
|
|
71
|
+
this.globe = globe;
|
|
72
|
+
this.gl = globe.gl;
|
|
73
|
+
this._vaoCache = [];
|
|
74
|
+
this.program = (0, util_1.createProgram)(this.gl, vs, fs);
|
|
75
|
+
const { gl, program } = this;
|
|
76
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
77
|
+
gl.useProgram(program);
|
|
78
|
+
// set uniform locations
|
|
79
|
+
this._uniforms = {
|
|
80
|
+
edge_count_loc: gl.getUniformLocation(program, "edge_count"),
|
|
81
|
+
edge_count: 40,
|
|
82
|
+
opacity_loc: gl.getUniformLocation(program, "opacity"),
|
|
83
|
+
opacity: 1.0
|
|
84
|
+
};
|
|
85
|
+
// last values
|
|
86
|
+
gl.uniform1f(this._uniforms.edge_count_loc, this._uniforms.edge_count);
|
|
87
|
+
gl.uniform1f(this._uniforms.opacity_loc, this._uniforms.opacity);
|
|
88
|
+
gl.useProgram(currentProgram);
|
|
89
|
+
// assign attribute locations
|
|
90
|
+
gl.bindAttribLocation(program, 0, "pos3D");
|
|
91
|
+
gl.bindAttribLocation(program, 1, "radius");
|
|
92
|
+
gl.bindAttribLocation(program, 2, "color");
|
|
93
|
+
// camera uniform block
|
|
94
|
+
this.cameraUniformBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
|
|
95
|
+
this.cameraBlockBindingPoint = 0;
|
|
96
|
+
const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
97
|
+
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
98
|
+
uboBlockManager.assignBindingPoint(this.gl, this.program);
|
|
99
|
+
this._defaultUBO = uboBlockManager.createUBO(this.gl);
|
|
100
|
+
}
|
|
101
|
+
createVAO(pos3DObj, radiusObj, colorObj) {
|
|
102
|
+
const { gl } = this;
|
|
103
|
+
const vao = gl.createVertexArray();
|
|
104
|
+
const divisor = 1;
|
|
105
|
+
gl.bindVertexArray(vao);
|
|
106
|
+
// TODO constants to escape values
|
|
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] });
|
|
110
|
+
gl.bindVertexArray(null);
|
|
111
|
+
this._vaoCache.push(vao);
|
|
112
|
+
return vao;
|
|
113
|
+
}
|
|
114
|
+
draw(vao, drawOptions, opacity = 1.0, ubo = null) {
|
|
115
|
+
const { gl, program } = this;
|
|
116
|
+
gl.useProgram(program);
|
|
117
|
+
gl.bindVertexArray(vao);
|
|
118
|
+
if (opacity !== this._uniforms.opacity) {
|
|
119
|
+
gl.uniform1f(this._uniforms.opacity_loc, opacity);
|
|
120
|
+
this._uniforms.opacity = opacity;
|
|
121
|
+
}
|
|
122
|
+
ubo = ubo || this._defaultUBO;
|
|
123
|
+
ubo.bind();
|
|
124
|
+
(0, methods_1.drawInstanced)(gl, gl.TRIANGLE_FAN, drawOptions);
|
|
125
|
+
ubo.unbind();
|
|
126
|
+
gl.bindVertexArray(null);
|
|
127
|
+
}
|
|
128
|
+
free() {
|
|
129
|
+
if (this._isFreed)
|
|
130
|
+
return;
|
|
131
|
+
totems_1.CameraUniformBlockTotemCache.release(this.globe);
|
|
132
|
+
this.gl.deleteProgram(this.program);
|
|
133
|
+
for (const vao of this._vaoCache)
|
|
134
|
+
this.gl.deleteVertexArray(vao);
|
|
135
|
+
this._isFreed = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const ElementGlobeSufaceGlowCache = Object.freeze({
|
|
139
|
+
get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
140
|
+
release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe)
|
|
141
|
+
});
|
|
142
|
+
exports.ElementGlobeSufaceGlowCache = ElementGlobeSufaceGlowCache;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ElementPointGlowProgramCache = void 0;
|
|
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
|
+
{ name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
|
|
17
|
+
{ name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
|
|
18
|
+
{ name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
|
|
19
|
+
{ name: "u_size", type: "float", value: new Float32Array([1.0]) },
|
|
20
|
+
{ name: "u_minimumSize", type: "float", value: new Float32Array([25.0]) },
|
|
21
|
+
{ name: "u_phase", type: "float", value: new Float32Array([1.0]) },
|
|
22
|
+
], flexibleBlockBindingPoint);
|
|
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) {
|
|
97
|
+
this.globe = globe;
|
|
98
|
+
this.gl = globe.gl;
|
|
99
|
+
this.program = (0, util_1.createProgram)(this.gl, vs, fs);
|
|
100
|
+
const { gl, program } = this;
|
|
101
|
+
gl.bindAttribLocation(program, 0, "pos3D");
|
|
102
|
+
gl.bindAttribLocation(program, 1, "pos2D");
|
|
103
|
+
gl.bindAttribLocation(program, 2, "color");
|
|
104
|
+
gl.bindAttribLocation(program, 3, "size");
|
|
105
|
+
// assign uniform block
|
|
106
|
+
this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
|
|
107
|
+
this.cameraBlockTotem.assignBindingPoint(program, cameraBlockBindingPoint);
|
|
108
|
+
uniformBlockManager.assignBindingPoint(this.gl, this.program);
|
|
109
|
+
this._defaultUBO = uniformBlockManager.createUBO(this.gl);
|
|
110
|
+
}
|
|
111
|
+
createVAO(pos3DBuffer, pos2DBuffer, colorBuffer, sizeBuffer) {
|
|
112
|
+
const { gl } = this;
|
|
113
|
+
const vao = gl.createVertexArray();
|
|
114
|
+
gl.bindVertexArray(vao);
|
|
115
|
+
(0, attribute_loader_1.attributeLoader)(gl, pos3DBuffer, 0, 3);
|
|
116
|
+
(0, attribute_loader_1.attributeLoader)(gl, pos2DBuffer, 1, 2);
|
|
117
|
+
(0, attribute_loader_1.attributeLoader)(gl, colorBuffer, 2, 4, { escapeValues: [-1, -1, -1, -1] });
|
|
118
|
+
(0, attribute_loader_1.attributeLoader)(gl, sizeBuffer, 3, 1, { escapeValues: [-1] });
|
|
119
|
+
gl.bindVertexArray(null);
|
|
120
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
121
|
+
return vao;
|
|
122
|
+
}
|
|
123
|
+
createUBO() {
|
|
124
|
+
const ubo = uniformBlockManager.createUBO(this.gl);
|
|
125
|
+
return ubo;
|
|
126
|
+
}
|
|
127
|
+
draw(vao, drawOptions, ubo = null) {
|
|
128
|
+
const { gl, program, cameraBlockTotem } = this;
|
|
129
|
+
gl.useProgram(program);
|
|
130
|
+
gl.bindVertexArray(vao);
|
|
131
|
+
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
132
|
+
ubo = ubo || this._defaultUBO;
|
|
133
|
+
ubo.bind();
|
|
134
|
+
(0, methods_1.drawArrays)(gl, gl.POINTS, drawOptions);
|
|
135
|
+
ubo.unbind();
|
|
136
|
+
gl.bindVertexArray(null);
|
|
137
|
+
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
138
|
+
this.globe.DrawRender();
|
|
139
|
+
}
|
|
140
|
+
// for singleton cache interation
|
|
141
|
+
free() {
|
|
142
|
+
if (this._isFreed)
|
|
143
|
+
return;
|
|
144
|
+
totems_1.CameraUniformBlockTotemCache.release(this.globe);
|
|
145
|
+
this.gl.deleteProgram(this.program);
|
|
146
|
+
this._isFreed = true;
|
|
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)
|
|
152
|
+
});
|
|
153
|
+
exports.ElementPointGlowProgramCache = ElementPointGlowProgramCache;
|