@pirireis/webglobeplugins 0.0.1
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/arrowfield/adaptor.js +11 -0
- package/arrowfield/index.js +4 -0
- package/arrowfield/plugin.js +128 -0
- package/compassrose/compassrose.js +394 -0
- package/compassrose/index.js +2 -0
- package/heatwavemaps/index.js +4 -0
- package/heatwavemaps/isobar/objectarraylabels.js +247 -0
- package/heatwavemaps/isobar/plugin.js +337 -0
- package/heatwavemaps/isobar/quadtreecontours.js +338 -0
- package/heatwavemaps/plugins/heatwaveglobeshell.js +257 -0
- package/index.js +8 -0
- package/package.json +7 -0
- package/programs/arrowfield/index.js +2 -0
- package/programs/arrowfield/logic.js +284 -0
- package/programs/arrowfield/object.js +89 -0
- package/programs/float2legendwithratio/index.js +3 -0
- package/programs/float2legendwithratio/logic.js +189 -0
- package/programs/float2legendwithratio/object.js +132 -0
- package/programs/globeshell/index.js +2 -0
- package/programs/globeshell/noise/noises.js +0 -0
- package/programs/globeshell/wiggle/index.js +6 -0
- package/programs/globeshell/wiggle/logic.js +374 -0
- package/programs/globeshell/wiggle/object.js +94 -0
- package/programs/helpers/blender/index.js +0 -0
- package/programs/helpers/blender/program.js +91 -0
- package/programs/helpers/fadeaway/index.js +3 -0
- package/programs/helpers/fadeaway/logic.js +76 -0
- package/programs/helpers/fadeaway/object.js +20 -0
- package/programs/helpers/index.js +2 -0
- package/programs/index.js +21 -0
- package/programs/programcache.js +119 -0
- package/programs/rings/distancering/circleflatprogram.js +135 -0
- package/programs/rings/distancering/circlepaddysharedbuffer.js +502 -0
- package/programs/rings/distancering/index.js +5 -0
- package/programs/rings/distancering/paddyflatprogram.js +131 -0
- package/programs/rings/distancering/shader.js +0 -0
- package/programs/rings/index.js +9 -0
- package/programs/totems/camerauniformblock.js +129 -0
- package/programs/totems/index.js +2 -0
- package/programs/util.js +17 -0
- package/programs/vectorfields/index.js +3 -0
- package/programs/vectorfields/logics/drawrectangleparticles.js +125 -0
- package/programs/vectorfields/logics/index.js +5 -0
- package/programs/vectorfields/logics/pixelbased.js +161 -0
- package/programs/vectorfields/logics/ubo.js +64 -0
- package/programs/vectorfields/pingpongbuffermanager.js +80 -0
- package/rangerings/index.js +3 -0
- package/rangerings/rangerings.js +88 -0
- package/timetracks/adaptors.js +133 -0
- package/timetracks/index.js +3 -0
- package/timetracks/plugin.js +304 -0
- package/timetracks/program.js +850 -0
- package/timetracks/programpoint.js +168 -0
- package/util/datamanager/datamanager.js +168 -0
- package/util/datamanager/index.js +3 -0
- package/util/datamanager/pointcoordinatesdatacalculator.js +133 -0
- package/util/datamanager/pointcoordsmeta.js +22 -0
- package/util/geometry/geodatafromtexture.js +52 -0
- package/util/geometry/index.js +44 -0
- package/util/index.js +13 -0
- package/util/jshelpers/index.js +1 -0
- package/util/jshelpers/timefilters.js +32 -0
- package/util/jshelpers/timemethods.js +19 -0
- package/util/programs/index.js +2 -0
- package/util/programs/shapesonglobe.js +248 -0
- package/util/programs/supersampletotextures.js +142 -0
- package/util/programs/texturetoglobe.js +203 -0
- package/util/shaderfunctions/geometrytransformations.js +129 -0
- package/util/shaderfunctions/index.js +2 -0
- package/util/shaderfunctions/nodata.js +10 -0
- package/util/shaderfunctions/noisefunctions.js +44 -0
- package/util/webglobe/gldefaultstates.js +4 -0
- package/util/webglobe/index.js +2 -0
- package/util/webglobe/rasteroverlay.js +96 -0
- package/util/webglobjectbuilders.js +256 -0
- package/waveparticles/adaptor.js +16 -0
- package/waveparticles/index.js +4 -0
- package/waveparticles/plugin.js +281 -0
- package/wind/imagetovectorfieldandmagnitude.js +39 -0
- package/wind/index.js +7 -0
- package/wind/plugin.js +1032 -0
- package/wind/vectorfieldimage.js +27 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module programcache
|
|
3
|
+
* @description This module provides a cache for programs. It is used to avoid creating the same program multiple times.
|
|
4
|
+
*
|
|
5
|
+
* # globeProgramCache
|
|
6
|
+
* Creates and registers programs to the globe. To the 1st object in the draw order.
|
|
7
|
+
* The programs are generally sets sets a global uniform block.
|
|
8
|
+
*
|
|
9
|
+
* # glProgramCache
|
|
10
|
+
* Creates and manages programs that are not related to the globe but to the WebGL context.
|
|
11
|
+
* The programs created by are lightweight absraction of program logic with `constructer(gl)`.
|
|
12
|
+
* These programs are generally wrapped by another class with more functionality.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const globeProgramCache = (function () {
|
|
16
|
+
|
|
17
|
+
const cache = {};
|
|
18
|
+
function getProgram(globe, ProgramClass) {
|
|
19
|
+
if (!cache[globe]) { cache[globe] = {} };
|
|
20
|
+
if (!cache[globe][ProgramClass]) {
|
|
21
|
+
cache[globe][ProgramClass] = {
|
|
22
|
+
program: new ProgramClass(),
|
|
23
|
+
count: 1
|
|
24
|
+
}
|
|
25
|
+
const firstObject = globe.DrawOrder.GetObj(0)
|
|
26
|
+
globe.api_RegisterPlugin(cache[globe][ProgramClass].program, firstObject);
|
|
27
|
+
} else {
|
|
28
|
+
cache[globe][ProgramClass].count++;
|
|
29
|
+
}
|
|
30
|
+
return cache[globe][ProgramClass].program;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function releaseProgram(globe, ProgramClass) {
|
|
34
|
+
if (cache[globe] && cache[globe][ProgramClass]) {
|
|
35
|
+
cache[globe][ProgramClass].count--;
|
|
36
|
+
if (cache[globe][ProgramClass].count === 0) {
|
|
37
|
+
globe.api_UnRegisterPlugin(cache[globe][ProgramClass].program.id); // it calls program.free()
|
|
38
|
+
delete cache[globe][ProgramClass];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return Object.freeze({
|
|
44
|
+
getProgram,
|
|
45
|
+
releaseProgram
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
})();
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
const glProgramCache = (function () {
|
|
52
|
+
|
|
53
|
+
const cache = {};
|
|
54
|
+
function getProgram(gl, ProgramClass) {
|
|
55
|
+
if (!cache[gl]) { cache[gl] = {} };
|
|
56
|
+
if (!cache[gl][ProgramClass]) {
|
|
57
|
+
cache[gl][ProgramClass] = {
|
|
58
|
+
program: new ProgramClass(gl),
|
|
59
|
+
count: 1
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
cache[gl][ProgramClass].count++;
|
|
63
|
+
}
|
|
64
|
+
return cache[gl][ProgramClass].program;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function releaseProgram(gl, ProgramClass) {
|
|
68
|
+
if (cache[gl] && cache[gl][ProgramClass]) {
|
|
69
|
+
cache[gl][ProgramClass].count--;
|
|
70
|
+
if (cache[gl][ProgramClass].count === 0) {
|
|
71
|
+
cache[gl][ProgramClass].program.free();
|
|
72
|
+
delete cache[gl][ProgramClass];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return Object.freeze({
|
|
78
|
+
getProgram,
|
|
79
|
+
releaseProgram
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
})();
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const noRegisterGlobeProgramCache = (function () {
|
|
86
|
+
|
|
87
|
+
const cache = {};
|
|
88
|
+
|
|
89
|
+
function getProgram(globe, ProgramClass) {
|
|
90
|
+
if (!cache[globe]) { cache[globe] = {} };
|
|
91
|
+
if (!cache[globe][ProgramClass]) {
|
|
92
|
+
cache[globe][ProgramClass] = {
|
|
93
|
+
program: new ProgramClass(globe),
|
|
94
|
+
count: 1
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
cache[globe][ProgramClass].count++;
|
|
98
|
+
}
|
|
99
|
+
return cache[globe][ProgramClass].program;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function releaseProgram(globe, ProgramClass) {
|
|
103
|
+
if (cache[globe] && cache[globe][ProgramClass]) {
|
|
104
|
+
cache[globe][ProgramClass].count--;
|
|
105
|
+
if (cache[globe][ProgramClass].count === 0) {
|
|
106
|
+
cache[globe][ProgramClass].program.free();
|
|
107
|
+
delete cache[globe][ProgramClass];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return Object.freeze({
|
|
113
|
+
getProgram,
|
|
114
|
+
releaseProgram
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
})();
|
|
118
|
+
|
|
119
|
+
export { globeProgramCache, glProgramCache, noRegisterGlobeProgramCache };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { createProgram, shaderfunctions } from "../../../util";
|
|
2
|
+
import CameraUniformBlockTotem, { CameraUniformBlockString } from "../../totems/camerauniformblock";
|
|
3
|
+
import { noRegisterGlobeProgramCache, globeProgramCache } from "../../programcache";
|
|
4
|
+
|
|
5
|
+
const CIRCLE_EDGE_COUNT = 72;
|
|
6
|
+
|
|
7
|
+
const vertexShader = `#version 300 es ` +
|
|
8
|
+
shaderfunctions.PI +
|
|
9
|
+
shaderfunctions.R +
|
|
10
|
+
shaderfunctions.POLE +
|
|
11
|
+
CameraUniformBlockString +
|
|
12
|
+
shaderfunctions.mercatorXYTo2DPoint +
|
|
13
|
+
shaderfunctions.longLatRadToMercator +
|
|
14
|
+
shaderfunctions.longLatRadToCartesian3D +
|
|
15
|
+
shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
|
|
16
|
+
shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
|
|
17
|
+
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
|
|
18
|
+
|
|
19
|
+
uniform int compass;
|
|
20
|
+
uniform float circle_edge_count;
|
|
21
|
+
|
|
22
|
+
in vec2 center;
|
|
23
|
+
in float radius;
|
|
24
|
+
in vec4 color;
|
|
25
|
+
in float flag;
|
|
26
|
+
out vec4 v_color;
|
|
27
|
+
out vec2 v_limp;
|
|
28
|
+
|
|
29
|
+
void main() {
|
|
30
|
+
if( flag == 1.0 || radius == 0.0) return; // 1.0 is hide
|
|
31
|
+
v_color = color;
|
|
32
|
+
gl_PointSize = 2.0;
|
|
33
|
+
float angle = 3.1415926535897932384626433832795 * 2.0 * (float(gl_VertexID) / circle_edge_count);
|
|
34
|
+
if ( is3D ){
|
|
35
|
+
gl_Position = projection * view * vec4(
|
|
36
|
+
circleLimpFromLongLatRadCenterCartesian3D( center, radius, angle) - translate, 1.0);
|
|
37
|
+
v_limp = vec2(0.0, 0.0);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
vec2 limp;
|
|
41
|
+
if ( compass == 1 ){
|
|
42
|
+
limp = circleLimpFromLongLatRadCenterMercatorCompass(center, radius, angle);
|
|
43
|
+
} else {
|
|
44
|
+
limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius, angle);
|
|
45
|
+
}
|
|
46
|
+
v_limp = limp;
|
|
47
|
+
gl_Position = mercatorXYTo2DPoint(limp);
|
|
48
|
+
|
|
49
|
+
}`;
|
|
50
|
+
|
|
51
|
+
const fragmentShader = `#version 300 es
|
|
52
|
+
precision highp float;` +
|
|
53
|
+
shaderfunctions.POLE + `
|
|
54
|
+
|
|
55
|
+
in vec4 v_color;
|
|
56
|
+
in vec2 v_limp;
|
|
57
|
+
out vec4 outColor;
|
|
58
|
+
void main() {
|
|
59
|
+
if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ discard; }
|
|
60
|
+
outColor = v_color;
|
|
61
|
+
}`;
|
|
62
|
+
|
|
63
|
+
class Logic {
|
|
64
|
+
constructor(globe,) {
|
|
65
|
+
this.globe = globe;
|
|
66
|
+
this.gl = globe.gl;
|
|
67
|
+
this.program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
68
|
+
{ // bind positions so bufferManager can use them
|
|
69
|
+
this.gl.bindAttribLocation(this.program, 0, "center");
|
|
70
|
+
this.gl.bindAttribLocation(this.program, 1, "radius");
|
|
71
|
+
this.gl.bindAttribLocation(this.program, 2, "color");
|
|
72
|
+
this.gl.bindAttribLocation(this.program, 3, "flag");
|
|
73
|
+
}
|
|
74
|
+
this.cameraBlockBindingPoint = 0;
|
|
75
|
+
this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
|
|
76
|
+
const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
|
|
77
|
+
this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
78
|
+
|
|
79
|
+
this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
|
|
80
|
+
this._circleEdgeCountLocation = this.gl.getUniformLocation(this.program, "circle_edge_count");
|
|
81
|
+
this._circle_edge_count = CIRCLE_EDGE_COUNT;
|
|
82
|
+
this._compassmode = 1;
|
|
83
|
+
{
|
|
84
|
+
const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
|
|
85
|
+
this.gl.useProgram(this.program);
|
|
86
|
+
this.gl.uniform1i(this._compassLocation, 1);
|
|
87
|
+
this.gl.uniform1f(this._circleEdgeCountLocation, CIRCLE_EDGE_COUNT);
|
|
88
|
+
this.gl.useProgram(currentProgram);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
draw(attrBufferManager, compass, circle_edge_count) {
|
|
95
|
+
const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
|
|
96
|
+
gl.useProgram(program);
|
|
97
|
+
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
98
|
+
attrBufferManager.bindCircleVAO();
|
|
99
|
+
|
|
100
|
+
if (compass !== this._compassLocation) {
|
|
101
|
+
gl.uniform1i(this._compassLocation, compass);
|
|
102
|
+
this._compassmode = compass;
|
|
103
|
+
}
|
|
104
|
+
if (circle_edge_count !== this._circleEdgeCountLocation) {
|
|
105
|
+
gl.uniform1f(this._circleEdgeCountLocation, circle_edge_count);
|
|
106
|
+
this._circle_edge_count = circle_edge_count;
|
|
107
|
+
}
|
|
108
|
+
gl.drawArraysInstanced(gl.LINE_LOOP, 0, CIRCLE_EDGE_COUNT, attrBufferManager.length);
|
|
109
|
+
gl.bindVertexArray(null);
|
|
110
|
+
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
free() {
|
|
114
|
+
this.gl.deleteProgram(this.program);
|
|
115
|
+
globeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
export default class {
|
|
122
|
+
constructor(globe, gl) {
|
|
123
|
+
this.gl = gl;
|
|
124
|
+
this.globe = globe;
|
|
125
|
+
this.logic = noRegisterGlobeProgramCache.getProgram(globe, Logic);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
draw(attrBufferManager, compass, circle_edge_count) {
|
|
129
|
+
this.logic.draw(attrBufferManager, compass, circle_edge_count);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
free() {
|
|
133
|
+
noRegisterGlobeProgramCache.releaseProgram(this.gl, Logic);
|
|
134
|
+
}
|
|
135
|
+
}
|