@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,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var camerauniformblock_1 = require("../totems/camerauniformblock");
|
|
8
|
-
var programcache_1 = require("../programcache");
|
|
9
|
-
var util_1 = require("../../util/account/util");
|
|
10
|
-
var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
|
|
11
|
-
var Pole = 20037508.34;
|
|
1
|
+
import { createProgram } from "../../util/webglobjectbuilders";
|
|
2
|
+
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
|
|
3
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
4
|
+
import { vaoAttributeLoader } from "../../util/account/util";
|
|
5
|
+
import { mercatorXYToGLPosition, POLE } from "../../util/shaderfunctions/geometrytransformations";
|
|
6
|
+
const Pole = 20037508.34;
|
|
12
7
|
/**
|
|
13
8
|
* Warning:
|
|
14
9
|
* Insert the points from the second index and skip 1 point as you placed 361 points
|
|
@@ -16,27 +11,87 @@ var Pole = 20037508.34;
|
|
|
16
11
|
/**
|
|
17
12
|
* Plus 1 for returning to the start point. 1 for cutting the circle into pieces.
|
|
18
13
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
const EDGE_COUNT = 62;
|
|
15
|
+
const ESCAPE_VALUE = 200000000;
|
|
16
|
+
const vertexShaderSource = `#version 300 es
|
|
17
|
+
precision highp float;
|
|
18
|
+
|
|
19
|
+
# define escape_value ${ESCAPE_VALUE}.0
|
|
20
|
+
|
|
21
|
+
${CameraUniformBlockString}
|
|
22
|
+
${mercatorXYToGLPosition}
|
|
23
|
+
|
|
24
|
+
uniform int edge_count;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
in vec2 position2d;
|
|
28
|
+
in vec4 color;
|
|
29
|
+
in float dash_ratio;
|
|
30
|
+
in float dash_opacity;
|
|
31
|
+
|
|
32
|
+
out float interpolation;
|
|
33
|
+
out vec4 v_color;
|
|
34
|
+
out float v_dash_ratio;
|
|
35
|
+
out float v_dash_opacity;
|
|
36
|
+
out vec2 v_limp;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
void main() {
|
|
40
|
+
if ( position2d.x == escape_value && position2d.y == escape_value){ return; }
|
|
41
|
+
interpolation = float( gl_VertexID % edge_count ) / float(edge_count);
|
|
42
|
+
if ( gl_VertexID % edge_count == 0 ) { return; } // cut on the first point.
|
|
43
|
+
if ( is3D ) {
|
|
44
|
+
return;
|
|
45
|
+
v_limp = vec2(0.0, 0.0);
|
|
46
|
+
} else {
|
|
47
|
+
v_limp = position2d;
|
|
48
|
+
gl_Position = mercatorXYToGLPosition( position2d);
|
|
49
|
+
}
|
|
50
|
+
v_dash_ratio = dash_ratio;
|
|
51
|
+
v_dash_opacity = dash_opacity;
|
|
52
|
+
v_color = color;
|
|
53
|
+
gl_PointSize = 15.0;
|
|
54
|
+
|
|
55
|
+
}`;
|
|
56
|
+
const fragmentShaderSource = `#version 300 es
|
|
57
|
+
${POLE}
|
|
58
|
+
precision highp float;
|
|
59
|
+
uniform float opacity;
|
|
60
|
+
in vec4 v_color;
|
|
61
|
+
in float v_dash_ratio;
|
|
62
|
+
in float v_dash_opacity;
|
|
63
|
+
in float interpolation;
|
|
64
|
+
in vec2 v_limp;
|
|
65
|
+
out vec4 color;
|
|
66
|
+
void main() {
|
|
67
|
+
if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){
|
|
68
|
+
discard;
|
|
69
|
+
// color = vec4(0.0,0.0,0.0,0.0);
|
|
70
|
+
// return;
|
|
71
|
+
}
|
|
72
|
+
color = v_color;
|
|
73
|
+
color.a *= opacity;
|
|
74
|
+
if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
|
|
75
|
+
if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
|
|
76
|
+
color.a *= v_dash_opacity;
|
|
77
|
+
}
|
|
78
|
+
}`;
|
|
79
|
+
class Logic {
|
|
80
|
+
constructor(globe) {
|
|
26
81
|
this.globe = globe;
|
|
27
82
|
this.gl = globe.gl;
|
|
28
83
|
this._lastOpacity = 1.0;
|
|
29
84
|
this._lastMercatorMode = 0;
|
|
30
85
|
this._lastEdgeCount = EDGE_COUNT;
|
|
31
|
-
this.program =
|
|
32
|
-
|
|
86
|
+
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
87
|
+
const { gl, program } = this;
|
|
33
88
|
this.program.uniforms = {
|
|
34
89
|
opacity: gl.getUniformLocation(program, "opacity"),
|
|
35
90
|
edgeCount: gl.getUniformLocation(program, "edge_count"),
|
|
36
91
|
mercator_calculation_mode: gl.getUniformLocation(program, "mercator_calculation_mode")
|
|
37
92
|
};
|
|
38
93
|
// initial uniform values
|
|
39
|
-
|
|
94
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
40
95
|
gl.useProgram(program);
|
|
41
96
|
gl.uniform1f(program.uniforms.opacity, 1.0);
|
|
42
97
|
gl.uniform1i(program.uniforms.edgeCount, EDGE_COUNT);
|
|
@@ -48,36 +103,36 @@ var Logic = /** @class */ (function () {
|
|
|
48
103
|
gl.bindAttribLocation(program, 2, "dash_ratio");
|
|
49
104
|
gl.bindAttribLocation(program, 3, "dash_opacity");
|
|
50
105
|
this.cameraBindingPoint = 0;
|
|
51
|
-
this.cameraBlockTotem =
|
|
52
|
-
|
|
106
|
+
this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
107
|
+
const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
53
108
|
gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
|
|
54
109
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
110
|
+
createVAO(centerObj, colorObj, dashRatioObj, dashOpacityObj) {
|
|
111
|
+
const { gl } = this;
|
|
112
|
+
const vao = gl.createVertexArray();
|
|
58
113
|
gl.bindVertexArray(vao);
|
|
59
114
|
{ // make this a function end import from account module.
|
|
60
|
-
|
|
61
|
-
|
|
115
|
+
const { buffer, stride = 0, offset = 0 } = centerObj;
|
|
116
|
+
vaoAttributeLoader(gl, buffer, 0, 2, stride, offset, null);
|
|
62
117
|
}
|
|
63
118
|
{
|
|
64
|
-
|
|
65
|
-
|
|
119
|
+
const { buffer, stride = 0, offset = 0 } = colorObj;
|
|
120
|
+
vaoAttributeLoader(gl, buffer, 1, 4, stride, offset, null);
|
|
66
121
|
}
|
|
67
122
|
{
|
|
68
|
-
|
|
69
|
-
|
|
123
|
+
const { buffer, stride = 0, offset = 0 } = dashRatioObj;
|
|
124
|
+
vaoAttributeLoader(gl, buffer, 2, 1, stride, offset, null);
|
|
70
125
|
}
|
|
71
126
|
{
|
|
72
|
-
|
|
73
|
-
|
|
127
|
+
const { buffer, stride = 0, offset = 0 } = dashOpacityObj;
|
|
128
|
+
vaoAttributeLoader(gl, buffer, 3, 1, stride, offset, null);
|
|
74
129
|
}
|
|
75
130
|
gl.bindVertexArray(null);
|
|
76
131
|
gl.bindVertexArray(null);
|
|
77
132
|
return vao;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
133
|
+
}
|
|
134
|
+
draw(vao, length, edgeCount, opacity) {
|
|
135
|
+
const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
|
|
81
136
|
gl.useProgram(program);
|
|
82
137
|
if (this._lastOpacity !== opacity) {
|
|
83
138
|
gl.uniform1f(program.uniforms.opacity, opacity);
|
|
@@ -93,37 +148,34 @@ var Logic = /** @class */ (function () {
|
|
|
93
148
|
// gl.drawArrays(gl.POINTS, 0, length * EDGE_COUNT)
|
|
94
149
|
cameraBlockTotem.unbind(cameraBindingPoint);
|
|
95
150
|
gl.bindVertexArray(null);
|
|
96
|
-
}
|
|
97
|
-
|
|
151
|
+
}
|
|
152
|
+
free() {
|
|
98
153
|
if (this.isFreed)
|
|
99
154
|
return;
|
|
100
|
-
|
|
155
|
+
CameraUniformBlockTotemCache.release(this.globe);
|
|
101
156
|
this.gl.deleteProgram(this.program);
|
|
102
157
|
this.isFreed = true;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const CircleCache = Object.freeze({
|
|
161
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
162
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
|
|
109
163
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var radius2d = globe.Math.GetDist2D(centerLong, centerLat, targetLong, targetLat) + radiusOffset;
|
|
115
|
-
var angle;
|
|
164
|
+
function centerCoords2dflatDataCreator(globe, centerLong, centerLat, targetLong, targetLat, { startAngleOfCircle = null, edgeCount = EDGE_COUNT, radiusOffset = 0 } = {}) {
|
|
165
|
+
const centerCoords2dflat = new Float32Array(edgeCount * 2);
|
|
166
|
+
const radius2d = globe.Math.GetDist2D(centerLong, centerLat, targetLong, targetLat) + radiusOffset;
|
|
167
|
+
let angle;
|
|
116
168
|
if (startAngleOfCircle === null) {
|
|
117
169
|
angle = globe.Math.GetAzimuthAngle(centerLong, centerLat, targetLong, targetLat);
|
|
118
170
|
}
|
|
119
171
|
else {
|
|
120
172
|
angle = startAngleOfCircle;
|
|
121
173
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
for (
|
|
126
|
-
|
|
174
|
+
const pointsLongLat = globe.Math.GetEllipseGeo(centerLong, centerLat, radius2d, radius2d, angle, 360 / (edgeCount - 2));
|
|
175
|
+
let lastlg = pointsLongLat[0].long;
|
|
176
|
+
let lastlt = pointsLongLat[0].lat;
|
|
177
|
+
for (let i = 1; i < edgeCount; i++) {
|
|
178
|
+
const { long: lg, lat: lt } = pointsLongLat[i - 1];
|
|
127
179
|
if (manhattanDistance(lastlg, lastlt, lg, lt) < 170) {
|
|
128
180
|
centerCoords2dflat.set(globe.api_GetMercator2DPoint(lg, lt), i * 2);
|
|
129
181
|
}
|
|
@@ -135,13 +187,12 @@ function centerCoords2dflatDataCreator(globe, centerLong, centerLat, targetLong,
|
|
|
135
187
|
}
|
|
136
188
|
return centerCoords2dflat;
|
|
137
189
|
}
|
|
138
|
-
function centerCoords2dflatDataCreatorWithRadius(globe, centerLong, centerLat, radius2d,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
var _f = pointsLongLat[i - 1], lg = _f.long, lt = _f.lat;
|
|
190
|
+
function centerCoords2dflatDataCreatorWithRadius(globe, centerLong, centerLat, radius2d, { startAngleOfCircle = null, edgeCount = EDGE_COUNT } = {}) {
|
|
191
|
+
const centerCoords2dflat = new Float32Array(edgeCount * 2);
|
|
192
|
+
const pointsLongLat = globe.Math.GetEllipseGeo(centerLong, centerLat, radius2d, radius2d, 0, 360 / (edgeCount - 2));
|
|
193
|
+
let { long: lastlg, lat: lastlt } = pointsLongLat[0];
|
|
194
|
+
for (let i = 1; i < edgeCount; i++) {
|
|
195
|
+
const { long: lg, lat: lt } = pointsLongLat[i - 1];
|
|
145
196
|
if (manhattanDistance(lastlg, lastlt, lg, lt) < 170) {
|
|
146
197
|
centerCoords2dflat.set(globe.api_GetMercator2DPoint(lg, lt), i * 2);
|
|
147
198
|
}
|
|
@@ -156,3 +207,4 @@ function centerCoords2dflatDataCreatorWithRadius(globe, centerLong, centerLat, r
|
|
|
156
207
|
function manhattanDistance(x1, y1, x2, y2) {
|
|
157
208
|
return Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2));
|
|
158
209
|
}
|
|
210
|
+
export { CircleCache, EDGE_COUNT, centerCoords2dflatDataCreator, centerCoords2dflatDataCreatorWithRadius };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var programcache_1 = require("../programcache");
|
|
7
|
-
var util_1 = require("../../util/account/util");
|
|
8
|
-
var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
|
|
1
|
+
import { createProgram } from "../../util/webglobjectbuilders";
|
|
2
|
+
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
|
|
3
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
4
|
+
import { vaoAttributeLoader } from "../../util/account/util";
|
|
5
|
+
import { longLatRadToMercator, longLatRadToCartesian3D, cartesian3DToGLPosition, mercatorXYToGLPosition, realDistanceOnSphereR1, circleLimpFromLongLatRadCenterCartesian3D_accurate, circleLimpFromLongLatRadCenterMercatorCompass_accurate, circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate, POLE } from "../../util/shaderfunctions/geometrytransformations";
|
|
9
6
|
/**
|
|
10
7
|
* TODO:
|
|
11
8
|
* 1. integrate geometry functions for radius angle and center
|
|
@@ -14,21 +11,92 @@ var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytran
|
|
|
14
11
|
* TODO:
|
|
15
12
|
* center_position is too small or doenst loaded as expected.
|
|
16
13
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const EDGE_COUNT_ON_SPHERE = 360;
|
|
15
|
+
const vertexShaderSource = `#version 300 es
|
|
16
|
+
precision highp float;
|
|
17
|
+
${CameraUniformBlockString}
|
|
18
|
+
${longLatRadToMercator}
|
|
19
|
+
${longLatRadToCartesian3D}
|
|
20
|
+
${cartesian3DToGLPosition}
|
|
21
|
+
${mercatorXYToGLPosition}
|
|
22
|
+
${realDistanceOnSphereR1}
|
|
23
|
+
${circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
24
|
+
${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
|
|
25
|
+
${circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate}
|
|
26
|
+
|
|
27
|
+
uniform float edge_count;
|
|
28
|
+
|
|
29
|
+
in vec2 center_position;
|
|
30
|
+
in vec3 center_position3d;
|
|
31
|
+
in float radius;
|
|
32
|
+
in vec4 color;
|
|
33
|
+
in float dash_ratio;
|
|
34
|
+
in float dash_opacity;
|
|
35
|
+
|
|
36
|
+
out float interpolation;
|
|
37
|
+
out vec4 v_color;
|
|
38
|
+
out float v_dash_ratio;
|
|
39
|
+
out float v_dash_opacity;
|
|
40
|
+
out vec2 v_limp;
|
|
41
|
+
void main() {
|
|
42
|
+
interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE}.0;
|
|
43
|
+
float angle = PI * 2.0 * interpolation;
|
|
44
|
+
if ( is3D ) {
|
|
45
|
+
|
|
46
|
+
vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, radius, angle);
|
|
47
|
+
|
|
48
|
+
gl_Position = cartesian3DToGLPosition(position);
|
|
49
|
+
v_limp = vec2(0.0, 0.0);
|
|
50
|
+
} else {
|
|
51
|
+
vec2 position;
|
|
52
|
+
if ( radius < 0.0) {
|
|
53
|
+
float cosine1 = cos(asin(tanh(center_position.y / 6378137.0)));
|
|
54
|
+
position = circleLimpFromLongLatRadCenterMercatorCompass_accurate(center_position, radius / cosine1 , angle);
|
|
55
|
+
} else {
|
|
56
|
+
position = circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate( center_position, radius, angle);
|
|
57
|
+
}
|
|
58
|
+
v_limp = position;
|
|
59
|
+
gl_Position = mercatorXYToGLPosition( position);
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
v_dash_ratio = dash_ratio;
|
|
63
|
+
v_dash_opacity = dash_opacity;
|
|
64
|
+
v_color = color;
|
|
65
|
+
gl_PointSize = 3.0;
|
|
66
|
+
|
|
67
|
+
}`;
|
|
68
|
+
const fragmentShaderSource = `#version 300 es
|
|
69
|
+
${POLE}
|
|
70
|
+
precision highp float;
|
|
71
|
+
uniform float opacity;
|
|
72
|
+
in vec4 v_color;
|
|
73
|
+
in float v_dash_ratio;
|
|
74
|
+
in float v_dash_opacity;
|
|
75
|
+
in float interpolation;
|
|
76
|
+
in vec2 v_limp;
|
|
77
|
+
out vec4 color;
|
|
78
|
+
void main() {
|
|
79
|
+
if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ color = vec4(0.0,0.0,0.0,0.0); return; }
|
|
80
|
+
color = v_color;
|
|
81
|
+
color.a *= opacity;
|
|
82
|
+
if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
|
|
83
|
+
if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
|
|
84
|
+
color.a *= v_dash_opacity;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
class Logic {
|
|
89
|
+
constructor(globe) {
|
|
22
90
|
this.globe = globe;
|
|
23
91
|
this.gl = globe.gl;
|
|
24
92
|
this._lastOpacity = 1.0;
|
|
25
|
-
this.program =
|
|
26
|
-
|
|
93
|
+
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
94
|
+
const { gl, program } = this;
|
|
27
95
|
this.program.uniforms = {
|
|
28
96
|
opacity: gl.getUniformLocation(program, "opacity")
|
|
29
97
|
};
|
|
30
98
|
{ // initial uniform values
|
|
31
|
-
|
|
99
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
32
100
|
gl.useProgram(program);
|
|
33
101
|
gl.uniform1f(program.uniforms.opacity, 1.0);
|
|
34
102
|
gl.useProgram(currentProgram);
|
|
@@ -42,45 +110,45 @@ var Logic = /** @class */ (function () {
|
|
|
42
110
|
gl.bindAttribLocation(program, 5, "dash_opacity");
|
|
43
111
|
}
|
|
44
112
|
this.cameraBindingPoint = 0;
|
|
45
|
-
this.cameraBlockTotem =
|
|
46
|
-
|
|
113
|
+
this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
114
|
+
const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
47
115
|
gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
|
|
48
116
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
117
|
+
createVAO(centerObj, center3dObj, radiusObj, colorObj, dashRatioObj, dashOpacityObj) {
|
|
118
|
+
const { gl } = this;
|
|
119
|
+
const vao = gl.createVertexArray();
|
|
120
|
+
const divisor = 1;
|
|
53
121
|
gl.bindVertexArray(vao);
|
|
54
122
|
{ // make this a function end import from account module.
|
|
55
|
-
|
|
56
|
-
|
|
123
|
+
const { buffer, stride = 0, offset = 0 } = centerObj;
|
|
124
|
+
vaoAttributeLoader(gl, buffer, 0, 2, stride, offset, divisor);
|
|
57
125
|
}
|
|
58
126
|
{ // make this a function end import from account module.
|
|
59
|
-
|
|
60
|
-
|
|
127
|
+
const { buffer, stride = 0, offset = 0 } = center3dObj;
|
|
128
|
+
vaoAttributeLoader(gl, buffer, 1, 3, stride, offset, divisor);
|
|
61
129
|
}
|
|
62
130
|
{
|
|
63
|
-
|
|
64
|
-
|
|
131
|
+
const { buffer, stride = 0, offset = 0 } = radiusObj;
|
|
132
|
+
vaoAttributeLoader(gl, buffer, 2, 1, stride, offset, divisor);
|
|
65
133
|
}
|
|
66
134
|
{
|
|
67
|
-
|
|
68
|
-
|
|
135
|
+
const { buffer, stride = 0, offset = 0 } = colorObj;
|
|
136
|
+
vaoAttributeLoader(gl, buffer, 3, 4, stride, offset, divisor);
|
|
69
137
|
}
|
|
70
138
|
{
|
|
71
|
-
|
|
72
|
-
|
|
139
|
+
const { buffer, stride = 0, offset = 0 } = dashRatioObj;
|
|
140
|
+
vaoAttributeLoader(gl, buffer, 4, 1, stride, offset, divisor);
|
|
73
141
|
}
|
|
74
142
|
{
|
|
75
|
-
|
|
76
|
-
|
|
143
|
+
const { buffer, stride = 0, offset = 0 } = dashOpacityObj;
|
|
144
|
+
vaoAttributeLoader(gl, buffer, 5, 1, stride, offset, divisor);
|
|
77
145
|
}
|
|
78
146
|
gl.bindVertexArray(null);
|
|
79
147
|
gl.bindVertexArray(null);
|
|
80
148
|
return vao;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
149
|
+
}
|
|
150
|
+
draw(vao, length, opacity) {
|
|
151
|
+
const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
|
|
84
152
|
gl.useProgram(program);
|
|
85
153
|
if (this._lastOpacity !== opacity) {
|
|
86
154
|
gl.uniform1f(program.uniforms.opacity, opacity);
|
|
@@ -92,17 +160,16 @@ var Logic = /** @class */ (function () {
|
|
|
92
160
|
gl.drawArraysInstanced(gl.POINTS, 0, EDGE_COUNT_ON_SPHERE + 1, length);
|
|
93
161
|
cameraBlockTotem.unbind(cameraBindingPoint);
|
|
94
162
|
gl.bindVertexArray(null);
|
|
95
|
-
}
|
|
96
|
-
|
|
163
|
+
}
|
|
164
|
+
free() {
|
|
97
165
|
if (this.isFreed)
|
|
98
166
|
return;
|
|
99
|
-
|
|
167
|
+
CameraUniformBlockTotemCache.release(this.globe);
|
|
100
168
|
this.gl.deleteProgram(this.program);
|
|
101
169
|
this.isFreed = true;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export const CircleCache = Object.freeze({
|
|
173
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
174
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
|
|
108
175
|
});
|