@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,46 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
require("../../util/gl-util/draw-options/types");
|
|
15
|
-
var ESCAPE_VALUE = -1;
|
|
16
|
-
var uniformBindingPoints = {
|
|
1
|
+
import { createProgram } from "../../util/webglobjectbuilders";
|
|
2
|
+
import "../interface";
|
|
3
|
+
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems";
|
|
4
|
+
import { cartesian3DToGLPosition, mercatorXYToGLPosition, } from "../../util/shaderfunctions/geometrytransformations.js";
|
|
5
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
6
|
+
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
7
|
+
import "../../util/gl-util/buffer/attribute-loader";
|
|
8
|
+
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
9
|
+
import "../../util/gl-util/uniform-block/types";
|
|
10
|
+
import { drawArrays } from "../../util/gl-util/draw-options/methods";
|
|
11
|
+
import "../../util/gl-util/draw-options/types";
|
|
12
|
+
const ESCAPE_VALUE = -1;
|
|
13
|
+
const uniformBindingPoints = {
|
|
17
14
|
camera: 0,
|
|
18
15
|
flexible: 1,
|
|
19
16
|
};
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const one = new Float32Array([1]);
|
|
18
|
+
const flexibleBlockManager = new UniformBlockManager('FlexibleAttributes', [
|
|
22
19
|
{ name: "u_color", type: "vec4", value: new Float32Array([0.12, 1, 0.1, 1]) },
|
|
23
20
|
{ name: "u_dash_opacity", type: "float", value: one },
|
|
24
21
|
{ name: "u_dash_length", type: "float", value: one },
|
|
25
22
|
], uniformBindingPoints.flexible);
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const vertexShaderSource = `#version 300 es
|
|
24
|
+
precision highp float;
|
|
25
|
+
|
|
26
|
+
${CameraUniformBlockString}
|
|
27
|
+
${cartesian3DToGLPosition}
|
|
28
|
+
${mercatorXYToGLPosition}
|
|
29
|
+
|
|
30
|
+
${flexibleBlockManager.glslCode()}
|
|
31
|
+
|
|
32
|
+
in vec3 position3d;
|
|
33
|
+
in vec2 position2d;
|
|
34
|
+
in vec4 color;
|
|
35
|
+
in float dash_length;
|
|
36
|
+
in float dash_opacity;
|
|
37
|
+
|
|
38
|
+
out float v_dash_length;
|
|
39
|
+
out float v_dash_opacity;
|
|
40
|
+
out vec4 v_color;
|
|
41
|
+
|
|
42
|
+
flat out vec3 v_flat_position;
|
|
43
|
+
out vec3 v_position;
|
|
44
|
+
|
|
45
|
+
void main() {
|
|
46
|
+
|
|
47
|
+
v_color = ( color.r == -1.0 ) ? u_color : color;
|
|
48
|
+
v_dash_length = ( dash_length == -1.0 ) ? u_dash_length : dash_length;
|
|
49
|
+
v_dash_opacity = ( dash_opacity == -1.0 ) ? u_dash_opacity : dash_opacity;
|
|
50
|
+
|
|
51
|
+
if ( is3D ) {
|
|
52
|
+
gl_Position = cartesian3DToGLPosition( position3d );
|
|
53
|
+
v_position = position3d;
|
|
54
|
+
v_flat_position = position3d;
|
|
55
|
+
} else {
|
|
56
|
+
gl_Position = mercatorXYToGLPosition( position2d );
|
|
57
|
+
v_position = vec3( position2d, 0.0 );
|
|
58
|
+
v_flat_position = vec3( position2d, 0.0 );
|
|
59
|
+
}
|
|
60
|
+
gl_PointSize = 4.0;
|
|
61
|
+
}`;
|
|
62
|
+
const fragmentShaderSource = `#version 300 es
|
|
63
|
+
precision highp float;
|
|
64
|
+
|
|
65
|
+
uniform float opacity;
|
|
66
|
+
|
|
67
|
+
in vec4 v_color;
|
|
68
|
+
in float v_dash_length;
|
|
69
|
+
in float v_dash_opacity;
|
|
70
|
+
|
|
71
|
+
flat in vec3 v_flat_position;
|
|
72
|
+
in vec3 v_position;
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
out vec4 outColor;
|
|
76
|
+
|
|
77
|
+
void main() {
|
|
78
|
+
outColor = v_color;
|
|
79
|
+
return;
|
|
80
|
+
float dash_length = v_dash_length;
|
|
81
|
+
float dash_opacity = v_dash_opacity;
|
|
82
|
+
|
|
83
|
+
if ( dash_length == 0.0 ) {
|
|
84
|
+
outColor = vec4( v_color.rgb, v_color.a * v_dash_opacity );
|
|
85
|
+
} else {
|
|
86
|
+
float dist = distance( v_flat_position, v_position );
|
|
87
|
+
// float alpha = mod( dist , v_dash_length * 2.0 ) / v_dash_length < 1.0 ? 1.0 : v_dash_opacity;
|
|
88
|
+
outColor = vec4( v_color.rgb, v_color.a * opacity );
|
|
89
|
+
}
|
|
90
|
+
}`;
|
|
28
91
|
console.log("LineStripProgram");
|
|
29
92
|
console.log(vertexShaderSource);
|
|
30
93
|
console.log(fragmentShaderSource);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
94
|
+
class Logic {
|
|
95
|
+
_vaosPublished = [];
|
|
96
|
+
_ubosPublished = [];
|
|
97
|
+
program;
|
|
98
|
+
gl;
|
|
99
|
+
globe;
|
|
100
|
+
cameraBlockTotem;
|
|
101
|
+
_defaultFlexibleUBO;
|
|
102
|
+
_opacity = {
|
|
103
|
+
value: 1,
|
|
104
|
+
location: null
|
|
105
|
+
};
|
|
106
|
+
constructor(globe) {
|
|
39
107
|
console.log("LineStripProgram globe", globe);
|
|
40
108
|
this.gl = globe.gl;
|
|
41
109
|
this.globe = globe;
|
|
42
|
-
this.program =
|
|
43
|
-
|
|
110
|
+
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
111
|
+
const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
|
|
44
112
|
this.gl.useProgram(this.program);
|
|
45
113
|
this._opacity.location = this.gl.getUniformLocation(this.program, "opacity");
|
|
46
114
|
this.gl.uniform1f(this._opacity.location, this._opacity.value);
|
|
@@ -50,61 +118,56 @@ var Logic = /** @class */ (function () {
|
|
|
50
118
|
this.gl.bindAttribLocation(this.program, 2, "color");
|
|
51
119
|
this.gl.bindAttribLocation(this.program, 3, "dash_length");
|
|
52
120
|
this.gl.bindAttribLocation(this.program, 4, "dash_opacity");
|
|
53
|
-
this.cameraBlockTotem =
|
|
121
|
+
this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
54
122
|
this.cameraBlockTotem.assignBindingPoint(this.program, uniformBindingPoints.camera);
|
|
55
123
|
flexibleBlockManager.assignBindingPoint(this.gl, this.program);
|
|
56
124
|
this._defaultFlexibleUBO = flexibleBlockManager.createUBO(this.gl);
|
|
57
125
|
this.gl.useProgram(currentProgram);
|
|
58
126
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var ubo = flexibleBlockManager.createUBO(this.gl, bufferReadType);
|
|
127
|
+
createUBO(bufferReadType = "STATIC_DRAW") {
|
|
128
|
+
const ubo = flexibleBlockManager.createUBO(this.gl, bufferReadType);
|
|
62
129
|
this._ubosPublished.push(ubo);
|
|
63
130
|
return ubo;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
131
|
+
}
|
|
132
|
+
createVAO(position3D, position2D, color, dashLength, dashOpacity) {
|
|
133
|
+
const { gl } = this;
|
|
134
|
+
const vao = gl.createVertexArray();
|
|
68
135
|
gl.bindVertexArray(vao);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
136
|
+
attributeLoader(gl, position3D, 0, 3);
|
|
137
|
+
attributeLoader(gl, position2D, 1, 2);
|
|
138
|
+
attributeLoader(gl, color, 2, 4, { escapeValues: [ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE] });
|
|
139
|
+
attributeLoader(gl, dashLength, 3, 1, { escapeValues: [ESCAPE_VALUE] });
|
|
140
|
+
attributeLoader(gl, dashOpacity, 4, 1, { escapeValues: [ESCAPE_VALUE] });
|
|
74
141
|
gl.bindVertexArray(null);
|
|
75
142
|
return vao;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (flexibleUBO === void 0) { flexibleUBO = null; }
|
|
80
|
-
var _a = this, gl = _a.gl, program = _a.program, cameraBlockTotem = _a.cameraBlockTotem;
|
|
143
|
+
}
|
|
144
|
+
draw(vao, drawOptions, opacity = 1, flexibleUBO = null) {
|
|
145
|
+
const { gl, program, cameraBlockTotem } = this;
|
|
81
146
|
gl.useProgram(program);
|
|
82
147
|
if (opacity !== this._opacity.value) {
|
|
83
148
|
this._opacity.value = opacity;
|
|
84
149
|
this.gl.uniform1f(this._opacity.location, this._opacity.value);
|
|
85
150
|
}
|
|
86
|
-
|
|
151
|
+
const ubo = flexibleUBO || this._defaultFlexibleUBO;
|
|
87
152
|
cameraBlockTotem.bind(uniformBindingPoints.camera);
|
|
88
153
|
ubo.bind();
|
|
89
154
|
gl.bindVertexArray(vao);
|
|
90
|
-
|
|
91
|
-
|
|
155
|
+
drawArrays(gl, gl.POINTS, drawOptions);
|
|
156
|
+
drawArrays(gl, gl.LINE_STRIP, drawOptions);
|
|
92
157
|
gl.bindVertexArray(null);
|
|
93
158
|
ubo.unbind();
|
|
94
159
|
cameraBlockTotem.unbind(uniformBindingPoints.camera);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.
|
|
99
|
-
this._ubosPublished.forEach(function (ubo) { return ubo.free(); });
|
|
160
|
+
}
|
|
161
|
+
free() {
|
|
162
|
+
this._vaosPublished.forEach((vao) => this.gl.deleteVertexArray(vao));
|
|
163
|
+
this._ubosPublished.forEach((ubo) => ubo.free());
|
|
100
164
|
this.gl.deleteProgram(this.program);
|
|
101
165
|
this._defaultFlexibleUBO.free();
|
|
102
|
-
|
|
166
|
+
CameraUniformBlockTotemCache.release(this.globe);
|
|
103
167
|
this.gl.deleteProgram(this.program);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); },
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export const LineStripProgramCache = Object.freeze({
|
|
171
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
172
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic),
|
|
110
173
|
});
|
|
@@ -1,37 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var GLOBE_MIDPOINT_COUNT = 30;
|
|
13
|
-
var escapeValue = -1.0;
|
|
14
|
-
var uniformBindingPoints = {
|
|
1
|
+
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems";
|
|
2
|
+
import { slerp, POLE, R_3D, mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
|
|
3
|
+
import { createProgram } from "../../util";
|
|
4
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
5
|
+
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
6
|
+
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
7
|
+
import "../../util/gl-util/draw-options/types";
|
|
8
|
+
import { drawInstanced } from "../../util/gl-util/draw-options/methods";
|
|
9
|
+
const GLOBE_MIDPOINT_COUNT = 30;
|
|
10
|
+
const escapeValue = -1.0;
|
|
11
|
+
const uniformBindingPoints = {
|
|
15
12
|
camera: 0,
|
|
16
13
|
flexible: 1
|
|
17
14
|
};
|
|
18
|
-
|
|
15
|
+
const uniformBlockManager = new UniformBlockManager('FlexibleAttibutes', [
|
|
19
16
|
{ name: 'u_color', type: 'vec4' },
|
|
20
17
|
{ name: 'u_dash_ratio', type: 'float' },
|
|
21
18
|
{ name: 'u_dash_opacity', type: 'float' }
|
|
22
19
|
], uniformBindingPoints.flexible);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const vertexShader = `#version 300 es
|
|
21
|
+
precision highp float;
|
|
22
|
+
|
|
23
|
+
${R_3D}
|
|
24
|
+
${CameraUniformBlockString}
|
|
25
|
+
${slerp}
|
|
26
|
+
${mercatorXYToGLPosition}
|
|
27
|
+
${cartesian3DToGLPosition}
|
|
28
|
+
|
|
29
|
+
${uniformBlockManager.glslCode()}
|
|
30
|
+
|
|
31
|
+
in vec2 start_position;
|
|
32
|
+
in vec3 start_position3d;
|
|
33
|
+
in vec2 end_position;
|
|
34
|
+
in vec3 end_position3d;
|
|
35
|
+
|
|
36
|
+
in float dash_ratio;
|
|
37
|
+
in float dash_opacity;
|
|
38
|
+
in vec4 color;
|
|
39
|
+
|
|
40
|
+
out float v_dash_ratio;
|
|
41
|
+
out float v_dash_opacity;
|
|
42
|
+
out vec4 v_color;
|
|
43
|
+
|
|
44
|
+
out vec2 v_limp;
|
|
45
|
+
out float interpolation;
|
|
46
|
+
|
|
47
|
+
void main() {
|
|
48
|
+
vec2 longLat;
|
|
49
|
+
|
|
50
|
+
v_color = (color.r == -1.0) ? u_color: color;
|
|
51
|
+
v_dash_ratio = (dash_ratio == -1.0) ? u_dash_ratio : dash_ratio;
|
|
52
|
+
v_dash_opacity = (dash_opacity == -1.0) ? u_dash_opacity : dash_opacity;
|
|
53
|
+
|
|
54
|
+
if (is3D) {
|
|
55
|
+
interpolation = float(gl_VertexID) / ${GLOBE_MIDPOINT_COUNT - 1}.0;
|
|
56
|
+
vec3 cartesian = slerp(start_position3d, end_position3d, interpolation);
|
|
57
|
+
gl_Position = cartesian3DToGLPosition(cartesian);
|
|
58
|
+
v_limp = vec2(0.0, 0.0);
|
|
59
|
+
} else {
|
|
60
|
+
if ( distance( start_position, end_position) > 30000000.0) { return; }
|
|
61
|
+
interpolation = float(gl_VertexID);
|
|
62
|
+
if (gl_VertexID % 2 == 0) {
|
|
63
|
+
longLat = start_position;
|
|
64
|
+
} else {
|
|
65
|
+
longLat = end_position;
|
|
66
|
+
}
|
|
67
|
+
v_limp = longLat;
|
|
68
|
+
gl_Position = mercatorXYToGLPosition(longLat);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
const fragmentShader = `#version 300 es
|
|
73
|
+
${POLE}
|
|
74
|
+
precision highp float;
|
|
75
|
+
|
|
76
|
+
uniform float opacity;
|
|
77
|
+
|
|
78
|
+
in float interpolation;
|
|
79
|
+
in vec2 v_limp;
|
|
80
|
+
in vec4 v_color;
|
|
81
|
+
in float v_dash_ratio;
|
|
82
|
+
in float v_dash_opacity;
|
|
83
|
+
|
|
84
|
+
out vec4 color;
|
|
85
|
+
|
|
86
|
+
void main() {
|
|
87
|
+
if (v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE) { discard; }
|
|
88
|
+
color = v_color;
|
|
89
|
+
color.a *= opacity;
|
|
90
|
+
if ( v_dash_ratio >= 1.0 ) { return; }
|
|
91
|
+
if (interpolation > 0.95) { return; }
|
|
92
|
+
if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5) { color.a *= v_dash_opacity; }
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
class Logic {
|
|
97
|
+
vaosPublished = [];
|
|
98
|
+
isFreed = false;
|
|
99
|
+
constructor(globe) {
|
|
29
100
|
this.globe = globe;
|
|
30
101
|
this.gl = globe.gl;
|
|
31
|
-
this.program =
|
|
102
|
+
this.program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
32
103
|
this._lastOpacity = 1.0;
|
|
33
|
-
|
|
34
|
-
|
|
104
|
+
const { gl, program } = this;
|
|
105
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
35
106
|
gl.useProgram(program);
|
|
36
107
|
// assign attribute locations
|
|
37
108
|
gl.bindAttribLocation(program, 0, "start_position");
|
|
@@ -44,7 +115,7 @@ var Logic = /** @class */ (function () {
|
|
|
44
115
|
this._opacityLocation = gl.getUniformLocation(program, "opacity");
|
|
45
116
|
gl.uniform1f(this._opacityLocation, this._lastOpacity);
|
|
46
117
|
gl.useProgram(currentProgram);
|
|
47
|
-
this.cameraBlockTotem =
|
|
118
|
+
this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
48
119
|
this.cameraBlockTotem.assignBindingPoint(program, uniformBindingPoints.camera);
|
|
49
120
|
this._ubosPublished = [];
|
|
50
121
|
uniformBlockManager.assignBindingPoint(this.gl, this.program);
|
|
@@ -60,9 +131,8 @@ var Logic = /** @class */ (function () {
|
|
|
60
131
|
* @param {number} flexibleOptions.dash_opacity
|
|
61
132
|
* @param {number} flexibleOptions.dash_ratio
|
|
62
133
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var _a = this, gl = _a.gl, program = _a.program, globe = _a.globe, cameraBlockTotem = _a.cameraBlockTotem, _defaultFlexibleUBO = _a._defaultFlexibleUBO;
|
|
134
|
+
draw(vao, drawOptions, opacity, flexibleUBO = null) {
|
|
135
|
+
const { gl, program, globe, cameraBlockTotem, _defaultFlexibleUBO } = this;
|
|
66
136
|
gl.useProgram(program);
|
|
67
137
|
cameraBlockTotem.bind(uniformBindingPoints.camera);
|
|
68
138
|
gl.bindVertexArray(vao);
|
|
@@ -71,17 +141,16 @@ var Logic = /** @class */ (function () {
|
|
|
71
141
|
this._lastOpacity = opacity;
|
|
72
142
|
}
|
|
73
143
|
// this._setFlexibleUniforms(flexibleOptions);
|
|
74
|
-
|
|
75
|
-
|
|
144
|
+
const vertexCount = globe.api_GetCurrentGeometry() === 0 ? GLOBE_MIDPOINT_COUNT : 2;
|
|
145
|
+
const ubo = flexibleUBO || _defaultFlexibleUBO;
|
|
76
146
|
ubo.bind();
|
|
77
|
-
|
|
147
|
+
drawInstanced(gl, gl.LINE_STRIP, drawOptions, vertexCount);
|
|
78
148
|
ubo.unbind();
|
|
79
149
|
gl.bindVertexArray(null);
|
|
80
150
|
cameraBlockTotem.unbind(uniformBindingPoints.camera);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var ubo = uniformBlockManager.createUBO(this.gl, bufferReadType);
|
|
151
|
+
}
|
|
152
|
+
createUBO(bufferReadType = "STATIC_DRAW") {
|
|
153
|
+
const ubo = uniformBlockManager.createUBO(this.gl, bufferReadType);
|
|
85
154
|
this._ubosPublished.push(ubo);
|
|
86
155
|
ubo.update(new Map([
|
|
87
156
|
["u_color", [1, 1, 1, 1]],
|
|
@@ -89,37 +158,35 @@ var Logic = /** @class */ (function () {
|
|
|
89
158
|
["u_dash_opacity", [1]]
|
|
90
159
|
]));
|
|
91
160
|
return ubo;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
161
|
+
}
|
|
162
|
+
createVAO(startPotision2DBufferObj, startPotision3DBufferObj, endPosition2DBufferObj, endPosition3DBufferObj, dashRatioBufferObj, dashOpacityBufferObj, colorBufferObj) {
|
|
163
|
+
const { gl } = this;
|
|
164
|
+
const vao = gl.createVertexArray();
|
|
96
165
|
gl.bindVertexArray(vao);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
166
|
+
const divisor = 1;
|
|
167
|
+
attributeLoader(gl, startPotision2DBufferObj, 0, 2, { divisor });
|
|
168
|
+
attributeLoader(gl, startPotision3DBufferObj, 1, 3, { divisor });
|
|
169
|
+
attributeLoader(gl, endPosition2DBufferObj, 2, 2, { divisor });
|
|
170
|
+
attributeLoader(gl, endPosition3DBufferObj, 3, 3, { divisor });
|
|
171
|
+
attributeLoader(gl, dashRatioBufferObj, 4, 1, { divisor, escapeValues: [escapeValue] });
|
|
172
|
+
attributeLoader(gl, dashOpacityBufferObj, 5, 1, { divisor, escapeValues: [escapeValue] });
|
|
173
|
+
attributeLoader(gl, colorBufferObj, 6, 4, { divisor, escapeValues: [escapeValue, escapeValue, escapeValue, escapeValue] });
|
|
105
174
|
gl.bindVertexArray(null);
|
|
106
175
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
107
176
|
this.vaosPublished.push(vao);
|
|
108
177
|
return vao;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
var _this = this;
|
|
178
|
+
}
|
|
179
|
+
free() {
|
|
112
180
|
if (this.isFreed)
|
|
113
181
|
return;
|
|
114
|
-
|
|
182
|
+
CameraUniformBlockTotemCache.release(this.globe);
|
|
115
183
|
this.gl.deleteProgram(this.program);
|
|
116
|
-
this.vaosPublished.forEach(
|
|
117
|
-
this._ubosPublished.forEach(
|
|
184
|
+
this.vaosPublished.forEach(vao => this.gl.deleteVertexArray(vao));
|
|
185
|
+
this._ubosPublished.forEach(ubo => ubo.free());
|
|
118
186
|
this.isFreed = true;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
export const LineOnGlobeCache = Object.freeze({
|
|
190
|
+
get: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic); },
|
|
191
|
+
release: (globe) => { return noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
|
|
125
192
|
});
|
|
@@ -1,20 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { createProgram } from './util';
|
|
2
|
+
import { CameraUniformBlockTotemCache, CameraUniformBlockString } from '../totems';
|
|
3
|
+
import { cartesian3DToGLPosition, R_3D } from '../../util/shaderfunctions/geometrytransformations';
|
|
4
|
+
import { noRegisterGlobeProgramCache } from '../programcache';
|
|
5
|
+
import { attributeLoader } from '../../util/gl-util/buffer/attribute-loader';
|
|
6
|
+
import '../draw-options/types';
|
|
7
|
+
import { drawInstanced } from '../draw-options/methods';
|
|
8
|
+
const vs = `#version 300 es
|
|
9
|
+
${R_3D}
|
|
10
|
+
${CameraUniformBlockString}
|
|
11
|
+
${cartesian3DToGLPosition}
|
|
12
|
+
in vec3 pos3D
|
|
13
|
+
in vec4 color;
|
|
14
|
+
out float ratio;
|
|
15
|
+
out flat vec4 vColor;
|
|
16
|
+
void main(){
|
|
17
|
+
if ( gl_VertexID == 0) {
|
|
18
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
19
|
+
ratio =0.0;
|
|
20
|
+
} else {
|
|
21
|
+
vec3 sea_level_pos3D = norm(pos3D) * R_3D;
|
|
22
|
+
gl_Position = cartesian3DToGLPosition(pos3D);
|
|
23
|
+
ratio = 1.0;
|
|
24
|
+
}
|
|
25
|
+
vColor = color;
|
|
26
|
+
}`;
|
|
27
|
+
const fs = `#version 300 es
|
|
28
|
+
uniform float opacity;
|
|
29
|
+
uniform float phase;
|
|
30
|
+
uniform float fadeOpacity;
|
|
31
|
+
in flat vec4 vColor;
|
|
32
|
+
in float ratio;
|
|
33
|
+
out vec4 fragColor;
|
|
34
|
+
void main(){
|
|
35
|
+
fragColor = vec4( vColor.rgb, vColor.a * opacity);
|
|
36
|
+
if (fadeOpacity < 1.0) {
|
|
37
|
+
float alpha= mix( fadeOpacity, vColor.a, fract( ratio + phase ));
|
|
38
|
+
fragColor.a *= alpha;
|
|
39
|
+
}
|
|
40
|
+
}`;
|
|
41
|
+
class Logic {
|
|
42
|
+
constructor(globe) {
|
|
14
43
|
this.globe = globe;
|
|
15
44
|
this.gl = globe.gl;
|
|
16
|
-
this.program =
|
|
17
|
-
|
|
45
|
+
this.program = createProgram(this.gl, vs, fs);
|
|
46
|
+
const { gl, program } = this;
|
|
18
47
|
this._opacity = {
|
|
19
48
|
lastValue: 1.0,
|
|
20
49
|
location: gl.getUniformLocation(program, 'opacity')
|
|
@@ -27,37 +56,36 @@ var Logic = /** @class */ (function () {
|
|
|
27
56
|
lastValue: 1.0,
|
|
28
57
|
location: gl.getUniformBlockLocation(program, 'fadeOpacity')
|
|
29
58
|
};
|
|
30
|
-
|
|
59
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
31
60
|
gl.useProgram(program);
|
|
32
|
-
[this._opacity, this._phase, this._fadeOpacity].forEach(
|
|
61
|
+
[this._opacity, this._phase, this._fadeOpacity].forEach((wrapper) => gl.uniform1f(wrapper.location, wrapper.lastValue));
|
|
33
62
|
gl.useProgram(currentProgram);
|
|
34
63
|
gl.useProgram(program);
|
|
35
64
|
gl.bindAttribLocation(program, 0, 'pos3D');
|
|
36
65
|
gl.bindAttribLocation(program, 1, 'color');
|
|
37
|
-
this.cameraUniformBlockTotem = new
|
|
66
|
+
this.cameraUniformBlockTotem = new CameraUniformBlockTotemCache.get(globe);
|
|
38
67
|
this.cameraBlockBindingPoint = 0;
|
|
39
|
-
|
|
68
|
+
const cameraBlockIndex = gl.getUniformBlockLocation(program, 'CameraUniformBlock');
|
|
40
69
|
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
41
70
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
71
|
+
createVao(pos3DObj, colorObj) {
|
|
72
|
+
const { gl } = this;
|
|
73
|
+
const vao = gl.createVertexArray();
|
|
74
|
+
const divisor = 1;
|
|
46
75
|
gl.bindVertexArray(vao);
|
|
47
|
-
|
|
48
|
-
|
|
76
|
+
attributeLoader(gl, pos3DObj, 0, 3, { divisor });
|
|
77
|
+
attributeLoader(gl, colorObj, 1, 4, { divisor, escapeValue: [-1, -1, -1, -1] });
|
|
49
78
|
gl.bindVertexArray(null);
|
|
50
79
|
this._vaoCache.push(vao);
|
|
51
80
|
return vao;
|
|
52
|
-
}
|
|
81
|
+
}
|
|
53
82
|
/**
|
|
54
83
|
*
|
|
55
84
|
* @param {WebGL2RenderingContext.vertexArrayObject} vao
|
|
56
85
|
* @param {Render} drawOptions
|
|
57
86
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var _d = this, globe = _d.globe, gl = _d.gl, program = _d.program, _opacity = _d._opacity, _fadeOpacity = _d._fadeOpacity;
|
|
87
|
+
draw(vao, drawOptions, { opacity = 1.0, fadeOpacity = 1.0, }) {
|
|
88
|
+
const { globe, gl, program, _opacity, _fadeOpacity } = this;
|
|
61
89
|
gl.useProgram(program);
|
|
62
90
|
gl.bindVertexArray(vao);
|
|
63
91
|
if (fadeOpacity < 1.0) {
|
|
@@ -72,11 +100,10 @@ var Logic = /** @class */ (function () {
|
|
|
72
100
|
_opacity.lastValue = opacity;
|
|
73
101
|
gl.uniform1f(_opacity.location, opacity);
|
|
74
102
|
}
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
103
|
+
drawInstanced(gl, gl.TRIANGLE_FAN, drawOptions);
|
|
104
|
+
}
|
|
105
|
+
_updatePhase() {
|
|
78
106
|
this._phase.lastValue = (Date.now() / 3.0) % 1000;
|
|
79
107
|
gl.uniform1f(_phase.location, _phase.lastValue);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
}());
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Z_ALPHA_MODE = void 0;
|
|
4
|
-
var Z_ALPHA_MODE = Object.freeze({
|
|
1
|
+
const Z_ALPHA_MODE = Object.freeze({
|
|
5
2
|
ON: 1,
|
|
6
3
|
OFF: 0
|
|
7
4
|
});
|
|
8
|
-
|
|
5
|
+
export { Z_ALPHA_MODE };
|