@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,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// export function createShader(gl, type, source) {
|
|
3
2
|
// const shader = gl.createShader(type);
|
|
4
3
|
// gl.shaderSource(shader, source);
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createShader = createShader;
|
|
7
|
-
exports.createProgram = createProgram;
|
|
8
|
-
exports.createProgramWrapper = createProgramWrapper;
|
|
9
|
-
exports.createTexture = createTexture;
|
|
10
|
-
exports.bindTexture = bindTexture;
|
|
11
|
-
exports.createBuffer = createBuffer;
|
|
12
|
-
exports.bindAttribute = bindAttribute;
|
|
13
|
-
exports.bindFramebuffer = bindFramebuffer;
|
|
14
|
-
exports.decodeBase64 = decodeBase64;
|
|
15
|
-
exports.createImageFromBase64 = createImageFromBase64;
|
|
16
|
-
exports.getColorRamp = getColorRamp;
|
|
17
|
-
exports.getColorRampDiscrate = getColorRampDiscrate;
|
|
18
|
-
exports.getColorRampInterpolated = getColorRampInterpolated;
|
|
19
|
-
exports.getColorRampModed = getColorRampModed;
|
|
20
|
-
exports.defaultColorRamp = defaultColorRamp;
|
|
21
|
-
exports.reloadCurrentGLProgram = reloadCurrentGLProgram;
|
|
22
4
|
// gl.compileShader(shader);
|
|
23
5
|
// if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
24
6
|
// throw new Error(gl.getShaderInfoLog(shader));
|
|
25
7
|
// }
|
|
26
8
|
// return shader;
|
|
27
9
|
// }
|
|
28
|
-
function createShader(gl, type, source) {
|
|
29
|
-
|
|
10
|
+
export function createShader(gl, type, source) {
|
|
11
|
+
const shader = gl.createShader(type);
|
|
30
12
|
gl.shaderSource(shader, source);
|
|
31
13
|
gl.compileShader(shader);
|
|
32
14
|
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
throw new Error(
|
|
15
|
+
const errorLog = gl.getShaderInfoLog(shader);
|
|
16
|
+
const shaderType = type === gl.VERTEX_SHADER ? 'VERTEX_SHADER' : 'FRAGMENT_SHADER';
|
|
17
|
+
const sourceWithLineNumbers = source.split('\n').map((line, i) => `${i + 1}: ${line}`).join('\n');
|
|
18
|
+
throw new Error(`Error compiling ${shaderType}:\n${errorLog}\nSource:\n${sourceWithLineNumbers}`);
|
|
37
19
|
}
|
|
38
20
|
return shader;
|
|
39
21
|
}
|
|
40
|
-
function createProgram(gl, vertexSource, fragmentSource) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
export function createProgram(gl, vertexSource, fragmentSource) {
|
|
23
|
+
const program = gl.createProgram();
|
|
24
|
+
const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
|
|
25
|
+
const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
|
|
44
26
|
gl.compileShader(vertexShader);
|
|
45
27
|
if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
|
|
46
28
|
console.error(gl.getShaderInfoLog(vertexShader));
|
|
@@ -60,10 +42,10 @@ function createProgram(gl, vertexSource, fragmentSource) {
|
|
|
60
42
|
}
|
|
61
43
|
return program;
|
|
62
44
|
}
|
|
63
|
-
function createProgramWrapper(gl, vertexSource, fragmentSource) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
export function createProgramWrapper(gl, vertexSource, fragmentSource) {
|
|
46
|
+
const program = gl.createProgram();
|
|
47
|
+
const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
|
|
48
|
+
const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
|
|
67
49
|
gl.attachShader(program, vertexShader);
|
|
68
50
|
gl.attachShader(program, fragmentShader);
|
|
69
51
|
gl.linkProgram(program);
|
|
@@ -71,21 +53,21 @@ function createProgramWrapper(gl, vertexSource, fragmentSource) {
|
|
|
71
53
|
// console.log(gl.getProgramInfoLog(program));
|
|
72
54
|
throw new Error(gl.getProgramInfoLog(program));
|
|
73
55
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
for (
|
|
77
|
-
|
|
56
|
+
const wrapper = { program: program };
|
|
57
|
+
const numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
|
|
58
|
+
for (let i = 0; i < numAttributes; i++) {
|
|
59
|
+
const attribute = gl.getActiveAttrib(program, i);
|
|
78
60
|
wrapper[attribute.name] = gl.getAttribLocation(program, attribute.name);
|
|
79
61
|
}
|
|
80
|
-
|
|
81
|
-
for (
|
|
82
|
-
|
|
62
|
+
const numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
|
|
63
|
+
for (let i = 0; i < numUniforms; i++) {
|
|
64
|
+
const uniform = gl.getActiveUniform(program, i);
|
|
83
65
|
wrapper[uniform.name] = gl.getUniformLocation(program, uniform.name);
|
|
84
66
|
}
|
|
85
67
|
return wrapper;
|
|
86
68
|
}
|
|
87
|
-
function createTexture(gl, filter, data, width, height) {
|
|
88
|
-
|
|
69
|
+
export function createTexture(gl, filter, data, width, height) {
|
|
70
|
+
const texture = gl.createTexture();
|
|
89
71
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
90
72
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
91
73
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
@@ -100,22 +82,22 @@ function createTexture(gl, filter, data, width, height) {
|
|
|
100
82
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
101
83
|
return texture;
|
|
102
84
|
}
|
|
103
|
-
function bindTexture(gl, texture, unit) {
|
|
85
|
+
export function bindTexture(gl, texture, unit) {
|
|
104
86
|
gl.activeTexture(gl.TEXTURE0 + unit);
|
|
105
87
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
106
88
|
}
|
|
107
|
-
function createBuffer(gl, data) {
|
|
108
|
-
|
|
89
|
+
export function createBuffer(gl, data) {
|
|
90
|
+
const buffer = gl.createBuffer();
|
|
109
91
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
110
92
|
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
|
111
93
|
return buffer;
|
|
112
94
|
}
|
|
113
|
-
function bindAttribute(gl, buffer, attribute, numComponents) {
|
|
95
|
+
export function bindAttribute(gl, buffer, attribute, numComponents) {
|
|
114
96
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
115
97
|
gl.enableVertexAttribArray(attribute);
|
|
116
98
|
gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);
|
|
117
99
|
}
|
|
118
|
-
function bindFramebuffer(gl, framebuffer, texture) {
|
|
100
|
+
export function bindFramebuffer(gl, framebuffer, texture) {
|
|
119
101
|
if (texture) {
|
|
120
102
|
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
121
103
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
|
|
@@ -124,34 +106,34 @@ function bindFramebuffer(gl, framebuffer, texture) {
|
|
|
124
106
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
125
107
|
}
|
|
126
108
|
}
|
|
127
|
-
function decodeBase64(data) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
for (
|
|
109
|
+
export function decodeBase64(data) {
|
|
110
|
+
const binary_string = atob(data);
|
|
111
|
+
const len = binary_string.length;
|
|
112
|
+
const bytes = new Uint8Array(len);
|
|
113
|
+
for (let i = 0; i < len; i++) {
|
|
132
114
|
bytes[i] = binary_string.charCodeAt(i);
|
|
133
115
|
}
|
|
134
116
|
return bytes;
|
|
135
117
|
}
|
|
136
|
-
function createImageFromBase64(encodedData) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
118
|
+
export function createImageFromBase64(encodedData) {
|
|
119
|
+
const bytes = decodeBase64(encodedData);
|
|
120
|
+
const blob = new Blob([bytes.buffer], { type: "image/png" });
|
|
121
|
+
const urlCreator = window.URL || window.webkitURL;
|
|
122
|
+
const imageUrl = urlCreator.createObjectURL(blob);
|
|
123
|
+
const image = new Image();
|
|
142
124
|
image.src = imageUrl;
|
|
143
125
|
return image;
|
|
144
126
|
}
|
|
145
|
-
function getColorRamp(colors) {
|
|
127
|
+
export function getColorRamp(colors) {
|
|
146
128
|
// console.log("getColorRamp", colors)
|
|
147
|
-
|
|
148
|
-
|
|
129
|
+
const canvas = document.createElement('canvas');
|
|
130
|
+
const ctx = canvas.getContext('2d');
|
|
149
131
|
canvas.width = 256;
|
|
150
132
|
canvas.height = 1;
|
|
151
|
-
|
|
152
|
-
for (
|
|
133
|
+
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
134
|
+
for (const stop in colors) {
|
|
153
135
|
// console.log("stop", stop);
|
|
154
|
-
gradient.addColorStop(colors[
|
|
136
|
+
gradient.addColorStop(colors[stop][0], colors[stop][1]);
|
|
155
137
|
// Alttaki satir ile gradienti cevirip, shaderda ki `speed_t = 1.0 - speed_t`' kaldirdim.
|
|
156
138
|
// gradientin en dusuk olmasi gereken siyah - mavi aralikta, mor renk gozlemledim.
|
|
157
139
|
// gradient.addColorStop( 1.0 - colors[stop][0], colors[stop][1]);
|
|
@@ -160,14 +142,14 @@ function getColorRamp(colors) {
|
|
|
160
142
|
ctx.fillRect(0, 0, 256, 1);
|
|
161
143
|
return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
|
|
162
144
|
}
|
|
163
|
-
function getColorRampDiscrate(values, thresholds) {
|
|
164
|
-
|
|
165
|
-
|
|
145
|
+
export function getColorRampDiscrate(values, thresholds) {
|
|
146
|
+
const canvas = document.createElement('canvas');
|
|
147
|
+
const ctx = canvas.getContext('2d');
|
|
166
148
|
canvas.width = 256;
|
|
167
149
|
canvas.height = 1;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
for (
|
|
150
|
+
const gap = 1.0 / 256;
|
|
151
|
+
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
152
|
+
for (let i = 0; i < thresholds.length - 1; i++) {
|
|
171
153
|
gradient.addColorStop(thresholds[i], values[i]);
|
|
172
154
|
gradient.addColorStop(thresholds[i + 1] - gap, values[i]);
|
|
173
155
|
}
|
|
@@ -176,16 +158,16 @@ function getColorRampDiscrate(values, thresholds) {
|
|
|
176
158
|
ctx.fillRect(0, 0, 256, 1);
|
|
177
159
|
return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
|
|
178
160
|
}
|
|
179
|
-
function getColorRampInterpolated(values, thresholds) {
|
|
180
|
-
|
|
181
|
-
|
|
161
|
+
export function getColorRampInterpolated(values, thresholds) {
|
|
162
|
+
const canvas = document.createElement('canvas');
|
|
163
|
+
const ctx = canvas.getContext('2d');
|
|
182
164
|
canvas.width = 256;
|
|
183
165
|
canvas.height = 1;
|
|
184
|
-
|
|
166
|
+
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
185
167
|
// const gap = 1.0 / 256;
|
|
186
168
|
// gradient.addColorStop(thresholds[0], values[0]);
|
|
187
169
|
// gradient.addColorStop(thresholds[0] + gap, values[1]);
|
|
188
|
-
for (
|
|
170
|
+
for (let i = 0; i < thresholds.length; i++) {
|
|
189
171
|
gradient.addColorStop(thresholds[i], values[i]);
|
|
190
172
|
}
|
|
191
173
|
// gradient.addColorStop(thresholds[thresholds.length - 1] - gap, values[values.length - 1]);
|
|
@@ -198,8 +180,7 @@ function getColorRampInterpolated(values, thresholds) {
|
|
|
198
180
|
* thresholds: n number of thresholds. Ex: [0, 10, 20]
|
|
199
181
|
* mode: [discrete, interpolated,]
|
|
200
182
|
*/
|
|
201
|
-
function getColorRampModed(values, thresholds, mode) {
|
|
202
|
-
if (mode === void 0) { mode = "interpolated"; }
|
|
183
|
+
export function getColorRampModed(values, thresholds, mode = "interpolated") {
|
|
203
184
|
if (mode === "discrete") {
|
|
204
185
|
return getColorRampDiscrate(values, thresholds);
|
|
205
186
|
}
|
|
@@ -210,8 +191,8 @@ function getColorRampModed(values, thresholds, mode) {
|
|
|
210
191
|
throw new Error("mode is not valid");
|
|
211
192
|
}
|
|
212
193
|
}
|
|
213
|
-
function defaultColorRamp() {
|
|
214
|
-
|
|
194
|
+
export function defaultColorRamp() {
|
|
195
|
+
const defaultRampColors = [
|
|
215
196
|
[0.0, '#5e4fa2'],
|
|
216
197
|
[0.15, '#3288bd'],
|
|
217
198
|
[0.20, '#66c2a5'],
|
|
@@ -225,12 +206,12 @@ function defaultColorRamp() {
|
|
|
225
206
|
];
|
|
226
207
|
return getColorRamp(defaultRampColors);
|
|
227
208
|
}
|
|
228
|
-
function reloadCurrentGLProgram() {
|
|
209
|
+
export function reloadCurrentGLProgram() {
|
|
229
210
|
return function (target, key, descriptor) {
|
|
230
|
-
|
|
211
|
+
const originalMethod = descriptor.value;
|
|
231
212
|
descriptor.value = function () {
|
|
232
|
-
|
|
233
|
-
|
|
213
|
+
const gl = target.gl;
|
|
214
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
234
215
|
originalMethod.apply(this, arguments);
|
|
235
216
|
gl.useProgram(currentProgram);
|
|
236
217
|
};
|
package/waveparticles/adaptor.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function centigradePlus90ToVectorArray(centigradeArray, noDataValue) {
|
|
5
|
-
if (noDataValue === void 0) { noDataValue = -9999; }
|
|
6
|
-
var vectorArray = new Float32Array(centigradeArray.length * 2);
|
|
7
|
-
for (var i = 0; i < centigradeArray.length; i++) {
|
|
1
|
+
function centigradePlus90ToVectorArray(centigradeArray, noDataValue = -9999) {
|
|
2
|
+
const vectorArray = new Float32Array(centigradeArray.length * 2);
|
|
3
|
+
for (let i = 0; i < centigradeArray.length; i++) {
|
|
8
4
|
if (centigradeArray[i] === noDataValue) {
|
|
9
5
|
vectorArray.set([0, 0], i * 2);
|
|
10
6
|
continue;
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const rad = (centigradeArray[i] + 90.0) * Math.PI / 180;
|
|
9
|
+
const x = Math.cos(rad);
|
|
10
|
+
const y = Math.sin(rad);
|
|
15
11
|
vectorArray.set([x, y], i * 2);
|
|
16
12
|
}
|
|
17
13
|
return vectorArray;
|
|
18
14
|
}
|
|
15
|
+
export { centigradePlus90ToVectorArray };
|
package/waveparticles/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.VectorFieldWaveParticle = exports.centigradePlus90ToVectorArray = void 0;
|
|
7
|
-
var plugin_1 = __importDefault(require("./plugin"));
|
|
8
|
-
exports.VectorFieldWaveParticle = plugin_1.default;
|
|
9
|
-
var adaptor_1 = require("./adaptor");
|
|
10
|
-
Object.defineProperty(exports, "centigradePlus90ToVectorArray", { enumerable: true, get: function () { return adaptor_1.centigradePlus90ToVectorArray; } });
|
|
1
|
+
import VectorFieldWaveParticle from "./plugin";
|
|
2
|
+
import { centigradePlus90ToVectorArray } from "./adaptor";
|
|
3
|
+
export { centigradePlus90ToVectorArray, VectorFieldWaveParticle };
|
package/waveparticles/plugin.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var MoveParticle = PixelBasedMove;
|
|
9
|
-
var DrawParticle = DrawRectangleParticles;
|
|
1
|
+
import { GlobeShellWiggle } from "../programs";
|
|
2
|
+
import { defaultblendfunction } from "../util";
|
|
3
|
+
import { vectorfield } from "../programs";
|
|
4
|
+
import { FadeAway } from "../programs";
|
|
5
|
+
const { PixelBasedMove, DrawRectangleParticles, PingPongBufferManager, WaveParticalUboManager } = vectorfield;
|
|
6
|
+
const MoveParticle = PixelBasedMove;
|
|
7
|
+
const DrawParticle = DrawRectangleParticles;
|
|
10
8
|
/**
|
|
11
9
|
* STEPS:
|
|
12
10
|
* 1. move particle | buffers: read b1 write b2 | swap buffers b1 <-> b2
|
|
@@ -15,10 +13,9 @@ var DrawParticle = DrawRectangleParticles;
|
|
|
15
13
|
* 4. fade drawTexture1 to drawTexture2 | swap textures
|
|
16
14
|
*
|
|
17
15
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _b = _a === void 0 ? {} : _a, dataWidth = _b.dataWidth, dataHeight = _b.dataHeight, _c = _b.fadeOpacity, fadeOpacity = _c === void 0 ? 0.83 : _c, _d = _b.opacity, opacity = _d === void 0 ? 0.75 : _d, _e = _b.minLon, minLon = _e === void 0 ? -180 : _e, _f = _b.minLat, minLat = _f === void 0 ? -90 : _f, _g = _b.maxLon, maxLon = _g === void 0 ? 180 : _g, _h = _b.maxLat, maxLat = _h === void 0 ? 90 : _h, _j = _b.patricleCount, patricleCount = _j === void 0 ? 8000 : _j, _k = _b.flipY, flipY = _k === void 0 ? true : _k, _l = _b.drawTextureMaxPixelOnDimension, drawTextureMaxPixelOnDimension = _l === void 0 ? MAX_PIXELS_ON_DIMENSION : _l;
|
|
16
|
+
const MAX_PIXELS_ON_DIMENSION = 2200;
|
|
17
|
+
export default class Plugin {
|
|
18
|
+
constructor(id, { dataWidth, dataHeight, fadeOpacity = 0.83, opacity = 0.75, minLon = -180, minLat = -90, maxLon = 180, maxLat = 90, patricleCount = 8000, flipY = true, drawTextureMaxPixelOnDimension = MAX_PIXELS_ON_DIMENSION } = {}) {
|
|
22
19
|
this.id = id;
|
|
23
20
|
this.globe = null;
|
|
24
21
|
this.gl = null;
|
|
@@ -38,23 +35,23 @@ var Plugin = /** @class */ (function () {
|
|
|
38
35
|
this._dataHeight = dataHeight;
|
|
39
36
|
this._drawTextureMaxPixelOnDimension = drawTextureMaxPixelOnDimension;
|
|
40
37
|
this._globeshellparameters = {
|
|
41
|
-
minLon
|
|
42
|
-
maxLon
|
|
43
|
-
minLat
|
|
44
|
-
maxLat
|
|
38
|
+
minLon,
|
|
39
|
+
maxLon,
|
|
40
|
+
minLat,
|
|
41
|
+
maxLat,
|
|
45
42
|
};
|
|
46
43
|
this._stepIndex = 0;
|
|
47
44
|
this._fullCycleStepCount = 3;
|
|
48
45
|
this._isFreed = false;
|
|
49
46
|
}
|
|
50
|
-
|
|
47
|
+
init(globe, gl) {
|
|
51
48
|
this.globe = globe;
|
|
52
49
|
this.gl = gl;
|
|
53
50
|
this.moveParticle = new MoveParticle(gl);
|
|
54
51
|
this.drawParticle = new DrawParticle(gl);
|
|
55
|
-
this.fadeAway = new
|
|
56
|
-
this.globeShellWiggle = new
|
|
57
|
-
|
|
52
|
+
this.fadeAway = new FadeAway(gl);
|
|
53
|
+
this.globeShellWiggle = new GlobeShellWiggle(gl, globe, this._globeshellparameters);
|
|
54
|
+
const inPositionLocation = this.moveParticle.getInPositionLocation();
|
|
58
55
|
this.bufferManager = new PingPongBufferManager(gl, this._particleCount, inPositionLocation);
|
|
59
56
|
this._rgVectorFieldTexture = this._createRGTexture();
|
|
60
57
|
this.waveUbo = new WaveParticalUboManager(gl, 0);
|
|
@@ -63,10 +60,10 @@ var Plugin = /** @class */ (function () {
|
|
|
63
60
|
this.setBBox(this._globeshellparameters);
|
|
64
61
|
this.setOpacity(this._opacity);
|
|
65
62
|
this.____drawIndex = 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
}
|
|
64
|
+
_createDrawTexture() {
|
|
65
|
+
const gl = this.gl;
|
|
66
|
+
const texture = gl.createTexture();
|
|
70
67
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
71
68
|
// gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2200, 2200, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
72
69
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this._drawTextureResolution.width, this._drawTextureResolution.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
@@ -76,14 +73,14 @@ var Plugin = /** @class */ (function () {
|
|
|
76
73
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
77
74
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
78
75
|
return texture;
|
|
79
|
-
}
|
|
80
|
-
|
|
76
|
+
}
|
|
77
|
+
_step() {
|
|
81
78
|
this._stepIndex = (this._stepIndex + 1) % this._fullCycleStepCount;
|
|
82
|
-
}
|
|
83
|
-
|
|
79
|
+
}
|
|
80
|
+
draw3D() {
|
|
84
81
|
if (this._isFreed)
|
|
85
82
|
return;
|
|
86
|
-
|
|
83
|
+
const { gl, moveParticle, drawParticle, bufferManager, globeShellWiggle, waveUbo, fadeAway, _rgVectorFieldTexture } = this;
|
|
87
84
|
gl.disable(gl.DEPTH_TEST);
|
|
88
85
|
if (this._stepIndex === 0) {
|
|
89
86
|
waveUbo.update({ random_seed: Math.random() });
|
|
@@ -93,8 +90,8 @@ var Plugin = /** @class */ (function () {
|
|
|
93
90
|
}
|
|
94
91
|
else if (this._stepIndex === 1) {
|
|
95
92
|
this.____drawIndex = 1 - this.____drawIndex;
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
const canvasWidth = gl.canvas.width;
|
|
94
|
+
const canvasHeight = gl.canvas.height;
|
|
98
95
|
// gl.viewport(0, 0, 2200, 2200);
|
|
99
96
|
gl.viewport(0, 0, this._drawTextureResolution.width, this._drawTextureResolution.height);
|
|
100
97
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
@@ -105,8 +102,8 @@ var Plugin = /** @class */ (function () {
|
|
|
105
102
|
gl.viewport(0, 0, canvasWidth, canvasHeight);
|
|
106
103
|
}
|
|
107
104
|
else {
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
const canvasWidth = gl.canvas.width;
|
|
106
|
+
const canvasHeight = gl.canvas.height;
|
|
110
107
|
// gl.viewport(0, 0, 2200, 2200);
|
|
111
108
|
gl.viewport(0, 0, this._drawTextureResolution.width, this._drawTextureResolution.height);
|
|
112
109
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
@@ -116,23 +113,23 @@ var Plugin = /** @class */ (function () {
|
|
|
116
113
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._drawTextures[1 - this.____drawIndex], 0);
|
|
117
114
|
fadeAway.draw(this._drawTextures[this.____drawIndex], this._fadeOpacity);
|
|
118
115
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
119
|
-
|
|
116
|
+
defaultblendfunction(gl);
|
|
120
117
|
gl.viewport(0, 0, canvasWidth, canvasHeight);
|
|
121
118
|
}
|
|
122
119
|
globeShellWiggle.setTexture(this._drawTextures[this.____drawIndex]);
|
|
123
120
|
globeShellWiggle.draw();
|
|
124
121
|
this._step();
|
|
125
122
|
gl.enable(gl.DEPTH_TEST);
|
|
126
|
-
}
|
|
127
|
-
|
|
123
|
+
}
|
|
124
|
+
setCycleStepCount(value) {
|
|
128
125
|
if (value < 3) {
|
|
129
126
|
this._fullCycleStepCount = 3;
|
|
130
127
|
}
|
|
131
128
|
this._fullCycleStepCount = value;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
}
|
|
130
|
+
_createRGTexture() {
|
|
131
|
+
const { gl, _dataWidth, _dataHeight, } = this;
|
|
132
|
+
const texture = gl.createTexture();
|
|
136
133
|
// R32F
|
|
137
134
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
138
135
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, null);
|
|
@@ -142,10 +139,10 @@ var Plugin = /** @class */ (function () {
|
|
|
142
139
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
143
140
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
144
141
|
return texture;
|
|
145
|
-
}
|
|
142
|
+
}
|
|
146
143
|
// TODO: free all resources
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
free() {
|
|
145
|
+
const { gl, fadeAway, globeShellWiggle, _rgVectorFieldTexture, bufferManager, waveUbo, _drawTextures, _frameBuffer } = this;
|
|
149
146
|
this._isFreed = true;
|
|
150
147
|
fadeAway.free();
|
|
151
148
|
globeShellWiggle.free();
|
|
@@ -158,16 +155,15 @@ var Plugin = /** @class */ (function () {
|
|
|
158
155
|
this.drawParticle = null;
|
|
159
156
|
bufferManager.free();
|
|
160
157
|
waveUbo.free();
|
|
161
|
-
_drawTextures.forEach(
|
|
158
|
+
_drawTextures.forEach(texture => gl.deleteTexture(texture));
|
|
162
159
|
gl.deleteFramebuffer(_frameBuffer);
|
|
163
|
-
}
|
|
160
|
+
}
|
|
164
161
|
// setters
|
|
165
|
-
|
|
162
|
+
setParticleCount(value) {
|
|
166
163
|
this._particleCount = value;
|
|
167
164
|
this.bufferManager.setParticleCount(value);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.dataWidth, dataWidth = _c === void 0 ? null : _c, _d = _b.dataHeight, dataHeight = _d === void 0 ? null : _d, flipY = _b.flipY;
|
|
165
|
+
}
|
|
166
|
+
setVectorFieldData(data, { dataWidth = null, dataHeight = null, flipY } = {}) {
|
|
171
167
|
if (dataWidth !== null && dataHeight !== null) {
|
|
172
168
|
this._dataWidth = dataWidth;
|
|
173
169
|
this._dataHeight = dataHeight;
|
|
@@ -176,25 +172,25 @@ var Plugin = /** @class */ (function () {
|
|
|
176
172
|
this._flipY = flipY;
|
|
177
173
|
}
|
|
178
174
|
this.__data = data;
|
|
179
|
-
|
|
175
|
+
const { gl, _dataWidth, _dataHeight } = this;
|
|
180
176
|
gl.bindTexture(gl.TEXTURE_2D, this._rgVectorFieldTexture);
|
|
181
177
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY);
|
|
182
178
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, data);
|
|
183
179
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
184
180
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
185
|
-
}
|
|
186
|
-
|
|
181
|
+
}
|
|
182
|
+
setHeight(value) {
|
|
187
183
|
this.globeShellWiggle.setHeight(value);
|
|
188
|
-
}
|
|
189
|
-
|
|
184
|
+
}
|
|
185
|
+
setDropRate(value) {
|
|
190
186
|
this.waveUbo.update({ drop_rate: value });
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
}
|
|
188
|
+
__readAndWriteTextureData() {
|
|
189
|
+
const { gl, _rgVectorFieldTexture, _dataWidth, _dataHeight } = this;
|
|
194
190
|
// Step 1: Bind the texture to a framebuffer
|
|
195
191
|
// Step 2: Read the texture data into a Float32Array
|
|
196
192
|
gl.bindTexture(gl.TEXTURE_2D, _rgVectorFieldTexture);
|
|
197
|
-
|
|
193
|
+
const textureData = new Float32Array(_dataWidth * _dataHeight * 2); // RG32F has 2 components per pixel
|
|
198
194
|
gl.readPixels(0, 0, _dataWidth, _dataHeight, gl.RG, gl.FLOAT, textureData);
|
|
199
195
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
200
196
|
// Step 3: Create a new texture and write the data back
|
|
@@ -203,18 +199,17 @@ var Plugin = /** @class */ (function () {
|
|
|
203
199
|
// Replace the old texture with the new one
|
|
204
200
|
this._rgVectorFieldTexture = this._createRGTexture();
|
|
205
201
|
this.setVectorFieldData(textureData);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
var horizon;
|
|
202
|
+
}
|
|
203
|
+
_drawTextureSizeFromBbox({ minLon, minLat, maxLon, maxLat }) {
|
|
204
|
+
let horizon;
|
|
210
205
|
if (minLon > 0 && maxLon < 0) {
|
|
211
206
|
horizon = 360 - minLon + maxLon;
|
|
212
207
|
}
|
|
213
208
|
else {
|
|
214
209
|
horizon = maxLon - minLon;
|
|
215
210
|
}
|
|
216
|
-
|
|
217
|
-
|
|
211
|
+
const vertical = maxLat - minLat;
|
|
212
|
+
let width, height;
|
|
218
213
|
if (horizon > vertical) {
|
|
219
214
|
width = this._drawTextureMaxPixelOnDimension;
|
|
220
215
|
height = Math.floor(this._drawTextureMaxPixelOnDimension * vertical / horizon);
|
|
@@ -224,48 +219,45 @@ var Plugin = /** @class */ (function () {
|
|
|
224
219
|
width = Math.floor(this._drawTextureMaxPixelOnDimension * horizon / vertical);
|
|
225
220
|
}
|
|
226
221
|
return {
|
|
227
|
-
width
|
|
228
|
-
height
|
|
222
|
+
width,
|
|
223
|
+
height
|
|
229
224
|
};
|
|
230
|
-
}
|
|
231
|
-
|
|
225
|
+
}
|
|
226
|
+
setDrawTextureMaxPixelOnDimension(value) {
|
|
232
227
|
this._drawTextureMaxPixelOnDimension = value;
|
|
233
228
|
this._drawTextureResolution = this._drawTextureSizeFromBbox(this._globeshellparameters);
|
|
234
229
|
this.waveUbo.update({ draw_texture_size: [this._drawTextureResolution.width, this._drawTextureResolution.height] });
|
|
235
230
|
this._drawTextures = [this._createDrawTexture(), this._createDrawTexture()];
|
|
236
|
-
}
|
|
237
|
-
|
|
231
|
+
}
|
|
232
|
+
setParticleSpeed(value) {
|
|
238
233
|
this.waveUbo.update({ range: value });
|
|
239
|
-
}
|
|
240
|
-
|
|
234
|
+
}
|
|
235
|
+
setFadeOpacity(value) {
|
|
241
236
|
this._fadeOpacity = value;
|
|
242
|
-
}
|
|
243
|
-
|
|
237
|
+
}
|
|
238
|
+
setOpacity(value) {
|
|
244
239
|
this.globeShellWiggle.setOpacity(value);
|
|
245
|
-
}
|
|
246
|
-
|
|
240
|
+
}
|
|
241
|
+
setParticleDimensions(tail, wing) {
|
|
247
242
|
if (0 < tail || 0 < wing) {
|
|
248
243
|
this.waveUbo.update({ tail_wing_base_limp: [tail, wing] });
|
|
249
244
|
}
|
|
250
245
|
else {
|
|
251
246
|
console.error("tail and wing must be greater than 0");
|
|
252
247
|
}
|
|
253
|
-
}
|
|
254
|
-
|
|
248
|
+
}
|
|
249
|
+
setParticleColor(color) {
|
|
255
250
|
if (color.length !== 3) {
|
|
256
251
|
console.error("color must be an array of rgb elements");
|
|
257
252
|
return;
|
|
258
253
|
}
|
|
259
|
-
this.waveUbo.update({ color
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.
|
|
264
|
-
this.
|
|
265
|
-
this._drawTextureResolution = this._drawTextureSizeFromBbox({ minLon: minLon, minLat: minLat, maxLon: maxLon, maxLat: maxLat });
|
|
254
|
+
this.waveUbo.update({ color });
|
|
255
|
+
}
|
|
256
|
+
setBBox({ minLon, minLat, maxLon, maxLat }) {
|
|
257
|
+
this._globeshellparameters = { minLon, minLat, maxLon, maxLat };
|
|
258
|
+
this.globeShellWiggle.setBBox({ minLon, minLat, maxLon, maxLat });
|
|
259
|
+
this._drawTextureResolution = this._drawTextureSizeFromBbox({ minLon, minLat, maxLon, maxLat });
|
|
266
260
|
this.waveUbo.update({ draw_texture_size: [this._drawTextureResolution.width, this._drawTextureResolution.height] });
|
|
267
261
|
this._drawTextures = [this._createDrawTexture(), this._createDrawTexture()];
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
}());
|
|
271
|
-
exports.default = Plugin;
|
|
262
|
+
}
|
|
263
|
+
}
|