@pirireis/webglobeplugins 0.9.6 → 0.9.7
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/package.json +5 -2
- package/Math/angle-calculation.js +0 -14
- package/Math/arc.ts +0 -76
- package/Math/bounds/line-bbox.js +0 -225
- package/Math/constants.ts +0 -11
- package/Math/frustum/camera.ts +0 -32
- package/Math/frustum/from-globeinfo.ts +0 -63
- package/Math/frustum/types.ts +0 -11
- package/Math/globe-util/horizon-plane.ts +0 -137
- package/Math/index.js +0 -0
- package/Math/juction/arc-plane.ts +0 -114
- package/Math/juction/line-sphere.ts +0 -30
- package/Math/juction/plane-plane.ts +0 -66
- package/Math/line.ts +0 -70
- package/Math/matrix4.ts +0 -0
- package/Math/methods.js +0 -237
- package/Math/plane.ts +0 -86
- package/Math/quaternion.ts +0 -120
- package/Math/roadmap.md +0 -10
- package/Math/types.ts +0 -45
- package/Math/utils.js +0 -3
- package/Math/vec3.ts +0 -155
- package/algorithms/search-binary.js +0 -14
- package/altitude-locator/adaptors.js +0 -0
- package/altitude-locator/draw-subset-obj.js +0 -27
- package/altitude-locator/keymethod.js +0 -0
- package/altitude-locator/plugin.js +0 -439
- package/altitude-locator/types.js +0 -26
- package/arrowfield/adaptor.js +0 -11
- package/arrowfield/index.js +0 -3
- package/arrowfield/plugin.js +0 -128
- package/bearing-line/index.js +0 -2
- package/bearing-line/plugin.js +0 -512
- package/circle-line-chain/chain-list-map.js +0 -221
- package/circle-line-chain/init.js +0 -0
- package/circle-line-chain/plugin.js +0 -469
- package/circle-line-chain/readme.md +0 -57
- package/circle-line-chain/util.js +0 -1
- package/compass-rose/compass-rose-padding-flat.js +0 -266
- package/compass-rose/compass-text-writer.js +0 -173
- package/compass-rose/index.js +0 -3
- package/compassrose/compassrose.js +0 -341
- package/compassrose/index.js +0 -2
- package/depth-locator/readme.md +0 -26
- package/globe-types.ts +0 -13
- package/heatwave/index.js +0 -4
- package/heatwave/isobar/objectarraylabels.js +0 -247
- package/heatwave/isobar/plugin.js +0 -340
- package/heatwave/isobar/quadtreecontours.js +0 -336
- package/heatwave/plugins/heatwaveglobeshell.js +0 -258
- package/jest.config.js +0 -6
- package/partialrings/buffer-manager.js +0 -89
- package/partialrings/goals.md +0 -17
- package/partialrings/index.js +0 -3
- package/partialrings/plugin.js +0 -160
- package/partialrings/program.js +0 -324
- package/pin/pin-object-array.js +0 -381
- package/pin/pin-point-totem.js +0 -77
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +0 -78
- package/point-heat-map/index.js +0 -0
- package/point-heat-map/plugin-webworker.js +0 -151
- package/point-heat-map/point-to-heat-map-flow.js +0 -150
- package/point-heat-map/readme.md +0 -15
- package/point-tracks/key-methods.js +0 -3
- package/point-tracks/plugin.js +0 -394
- package/programs/arrowfield/index.js +0 -2
- package/programs/arrowfield/logic.js +0 -286
- package/programs/arrowfield/object.js +0 -89
- package/programs/data2legend/density-to-legend.js +0 -115
- package/programs/data2legend/point-to-density-texture.js +0 -114
- package/programs/float2legendwithratio/index.js +0 -3
- package/programs/float2legendwithratio/logic.js +0 -194
- package/programs/float2legendwithratio/object.js +0 -141
- package/programs/globe-util/is-globe-moved.js +0 -27
- package/programs/globeshell/index.js +0 -2
- package/programs/globeshell/noise/noises.js +0 -0
- package/programs/globeshell/wiggle/index.js +0 -6
- package/programs/globeshell/wiggle/logic.js +0 -371
- package/programs/globeshell/wiggle/object.js +0 -93
- package/programs/helpers/blender/index.js +0 -0
- package/programs/helpers/blender/program.js +0 -91
- package/programs/helpers/fadeaway/index.js +0 -3
- package/programs/helpers/fadeaway/logic.js +0 -76
- package/programs/helpers/fadeaway/object.js +0 -20
- package/programs/helpers/index.js +0 -2
- package/programs/index.js +0 -21
- package/programs/interface.ts +0 -7
- package/programs/line-on-globe/angled-line.js +0 -206
- package/programs/line-on-globe/circle-accurate-3d.js +0 -167
- package/programs/line-on-globe/circle-accurate-flat.js +0 -262
- package/programs/line-on-globe/circle-accurate.js +0 -202
- package/programs/line-on-globe/circle.js +0 -191
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +0 -188
- package/programs/line-on-globe/index.js +0 -0
- package/programs/line-on-globe/lines-color-instanced-flat.js +0 -151
- package/programs/line-on-globe/linestrip.ts +0 -228
- package/programs/line-on-globe/naive-accurate-flexible.js +0 -239
- package/programs/line-on-globe/to-the-surface.js +0 -129
- package/programs/line-on-globe/util.js +0 -8
- package/programs/picking/pickable-renderer.js +0 -216
- package/programs/point-on-globe/element-globe-surface-glow.js +0 -168
- package/programs/point-on-globe/element-point-glow.js +0 -184
- package/programs/point-on-globe/square-pixel-point.js +0 -189
- package/programs/programcache.ts +0 -131
- package/programs/rings/distancering/circleflatprogram.js +0 -136
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -378
- package/programs/rings/distancering/circlepaddysharedbuffer.js +0 -420
- package/programs/rings/distancering/index.js +0 -5
- package/programs/rings/distancering/paddyflatprogram.js +0 -146
- package/programs/rings/distancering/paddyflatprogram2d.js +0 -150
- package/programs/rings/distancering/paddyflatprogram3d.js +0 -146
- package/programs/rings/distancering/shader.js +0 -0
- package/programs/rings/index.js +0 -1
- package/programs/rings/partial-ring/piece-of-pie.js +0 -315
- package/programs/totems/camerauniformblock.d.ts +0 -48
- package/programs/totems/camerauniformblock.js +0 -197
- package/programs/totems/canvas-webglobe-info.js +0 -136
- package/programs/totems/gpu-selection-uniform-block.js +0 -132
- package/programs/totems/index.ts +0 -2
- package/programs/two-d/pixel-circle.js +0 -0
- package/programs/two-d/pixel-padding-for-compass.js +0 -174
- package/programs/util.js +0 -20
- package/programs/vectorfields/index.js +0 -3
- package/programs/vectorfields/logics/drawrectangleparticles.js +0 -125
- package/programs/vectorfields/logics/index.js +0 -5
- package/programs/vectorfields/logics/pixelbased.js +0 -161
- package/programs/vectorfields/logics/ubo.js +0 -64
- package/programs/vectorfields/pingpongbuffermanager.js +0 -80
- package/publish.bat +0 -60
- package/rangerings/enum.js +0 -3
- package/rangerings/index.js +0 -5
- package/rangerings/plugin.js +0 -649
- package/rangerings/rangeringangletext.js +0 -368
- package/rangerings/ring-account.js +0 -129
- package/shaders/fragment-toy/firework.js +0 -55
- package/shaders/fragment-toy/singularity.js +0 -59
- package/shape-on-terrain/arc/naive/plugin.ts +0 -304
- package/shape-on-terrain/goal.md +0 -12
- package/tests/Math/junction/arc-plane.test.ts +0 -133
- package/tests/Math/junction/plane-plane.test.ts +0 -82
- package/tests/Math/plane.test.ts +0 -43
- package/tests/Math/vec3.test.ts +0 -14
- package/timetracks/adaptors-line-strip.js +0 -80
- package/timetracks/adaptors.js +0 -133
- package/timetracks/index.js +0 -6
- package/timetracks/plugin-line-strip.js +0 -295
- package/timetracks/plugin.js +0 -304
- package/timetracks/program-line-strip.js +0 -688
- package/timetracks/program.js +0 -850
- package/timetracks/programpoint-line-strip.js +0 -175
- package/timetracks/programpoint.js +0 -168
- package/timetracks/readme.md +0 -1
- package/tsconfig.json +0 -22
- package/types.ts +0 -17
- package/util/account/bufferoffsetmanager.js +0 -209
- package/util/account/index.js +0 -6
- package/util/account/single-attribute-buffer-management/buffer-manager.ts +0 -119
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.ts +0 -173
- package/util/account/single-attribute-buffer-management/index.ts +0 -13
- package/util/account/single-attribute-buffer-management/object-store.ts +0 -65
- package/util/account/single-attribute-buffer-management/types.ts +0 -39
- package/util/account/util.js +0 -22
- package/util/algorithms/index.js +0 -0
- package/util/algorithms/search-binary.js +0 -26
- package/util/check/get.js +0 -13
- package/util/check/index.js +0 -0
- package/util/check/typecheck.js +0 -39
- package/util/geometry/index.js +0 -53
- package/util/gl-util/buffer/attribute-loader.ts +0 -85
- package/util/gl-util/buffer/index.ts +0 -6
- package/util/gl-util/buffer/types.ts +0 -13
- package/util/gl-util/draw-options/methods.ts +0 -66
- package/util/gl-util/draw-options/types.ts +0 -28
- package/util/gl-util/uniform-block/manager.ts +0 -187
- package/util/gl-util/uniform-block/roadmap.md +0 -70
- package/util/gl-util/uniform-block/shader.js +0 -0
- package/util/gl-util/uniform-block/types.ts +0 -27
- package/util/heatwavedatamanager/datamanager.js +0 -168
- package/util/heatwavedatamanager/index.js +0 -3
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +0 -133
- package/util/heatwavedatamanager/pointcoordsmeta.js +0 -22
- package/util/index.js +0 -13
- package/util/interpolation/index.js +0 -0
- package/util/interpolation/timetrack/index.js +0 -9
- package/util/interpolation/timetrack/timetrack-interpolator.js +0 -88
- package/util/interpolation/timetrack/web-worker-str.js +0 -180
- package/util/interpolation/timetrack/web-worker.js +0 -51
- package/util/jshelpers/data-filler.js +0 -19
- package/util/jshelpers/equality.js +0 -17
- package/util/jshelpers/index.js +0 -1
- package/util/jshelpers/timefilters.js +0 -32
- package/util/picking/fence.js +0 -46
- package/util/picking/picker-displayer.js +0 -177
- package/util/programs/draw-texture-on-canvas.js +0 -102
- package/util/programs/index.js +0 -1
- package/util/programs/shapesonglobe.js +0 -246
- package/util/programs/supersampletotextures.js +0 -142
- package/util/programs/texturetoglobe.js +0 -203
- package/util/shaderfunctions/geometrytransformations.ts +0 -388
- package/util/shaderfunctions/index.js +0 -2
- package/util/shaderfunctions/nodata.js +0 -10
- package/util/shaderfunctions/noisefunctions.js +0 -44
- package/util/surface-line-data/arc-bboxes.ts +0 -42
- package/util/surface-line-data/arcs-to-cuts.js +0 -74
- package/util/surface-line-data/cut-arc.js +0 -0
- package/util/surface-line-data/flow.ts +0 -52
- package/util/surface-line-data/rbush-manager.js +0 -0
- package/util/surface-line-data/types.ts +0 -27
- package/util/surface-line-data/web-worker.js +0 -0
- package/util/webglobe/gldefaultstates.js +0 -5
- package/util/webglobe/index.js +0 -2
- package/util/webglobe/rasteroverlay.js +0 -96
- package/util/webglobjectbuilders.ts +0 -456
- package/util/webglobjectbuilders1.js +0 -271
- package/waveparticles/adaptor.js +0 -16
- package/waveparticles/index.js +0 -3
- package/waveparticles/plugin.js +0 -313
- package/wind/imagetovectorfieldandmagnitude.js +0 -39
- package/wind/index.js +0 -5
- package/wind/plugin.js +0 -1057
- package/wind/vectorfieldimage.js +0 -27
- package/write-text/attached-text-writer.js +0 -105
- package/write-text/context-text.js +0 -125
- package/write-text/context-text3.js +0 -178
- package/write-text/index.js +0 -1
- package/write-text/writer-plugin.js +0 -7
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// export function createShader(gl, type, source) {
|
|
3
|
-
// const shader = gl.createShader(type);
|
|
4
|
-
// gl.shaderSource(shader, source);
|
|
5
|
-
|
|
6
|
-
// gl.compileShader(shader);
|
|
7
|
-
// if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
8
|
-
// throw new Error(gl.getShaderInfoLog(shader));
|
|
9
|
-
// }
|
|
10
|
-
|
|
11
|
-
// return shader;
|
|
12
|
-
// }
|
|
13
|
-
|
|
14
|
-
export function createShader(gl, type, source) {
|
|
15
|
-
const shader = gl.createShader(type);
|
|
16
|
-
gl.shaderSource(shader, source);
|
|
17
|
-
|
|
18
|
-
gl.compileShader(shader);
|
|
19
|
-
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
20
|
-
const errorLog = gl.getShaderInfoLog(shader);
|
|
21
|
-
const shaderType = type === gl.VERTEX_SHADER ? 'VERTEX_SHADER' : 'FRAGMENT_SHADER';
|
|
22
|
-
const sourceWithLineNumbers = source.split('\n').map((line, i) => `${i + 1}: ${line}`).join('\n');
|
|
23
|
-
throw new Error(`Error compiling ${shaderType}:\n${errorLog}\nSource:\n${sourceWithLineNumbers}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return shader;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function createProgram(gl, vertexSource, fragmentSource) {
|
|
30
|
-
const program = gl.createProgram();
|
|
31
|
-
|
|
32
|
-
const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
|
|
33
|
-
const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
|
|
34
|
-
|
|
35
|
-
gl.compileShader(vertexShader);
|
|
36
|
-
if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
|
|
37
|
-
console.error(gl.getShaderInfoLog(vertexShader));
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
gl.compileShader(fragmentShader);
|
|
42
|
-
if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
|
|
43
|
-
console.error(gl.getShaderInfoLog(fragmentShader));
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
gl.attachShader(program, vertexShader);
|
|
48
|
-
gl.attachShader(program, fragmentShader);
|
|
49
|
-
gl.linkProgram(program);
|
|
50
|
-
|
|
51
|
-
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
52
|
-
console.error(gl.getProgramInfoLog(program));
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
return program;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function createProgramWrapper(gl, vertexSource, fragmentSource) {
|
|
59
|
-
const program = gl.createProgram();
|
|
60
|
-
|
|
61
|
-
const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
|
|
62
|
-
const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
|
|
63
|
-
|
|
64
|
-
gl.attachShader(program, vertexShader);
|
|
65
|
-
gl.attachShader(program, fragmentShader);
|
|
66
|
-
|
|
67
|
-
gl.linkProgram(program);
|
|
68
|
-
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
69
|
-
// console.log(gl.getProgramInfoLog(program));
|
|
70
|
-
throw new Error(gl.getProgramInfoLog(program));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const wrapper = { program: program };
|
|
74
|
-
|
|
75
|
-
const numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
|
|
76
|
-
for (let i = 0; i < numAttributes; i++) {
|
|
77
|
-
const attribute = gl.getActiveAttrib(program, i);
|
|
78
|
-
wrapper[attribute.name] = gl.getAttribLocation(program, attribute.name);
|
|
79
|
-
}
|
|
80
|
-
const numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
|
|
81
|
-
for (let i = 0; i < numUniforms; i++) {
|
|
82
|
-
const uniform = gl.getActiveUniform(program, i);
|
|
83
|
-
wrapper[uniform.name] = gl.getUniformLocation(program, uniform.name);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return wrapper;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function createTexture(gl, filter, data, width, height) {
|
|
90
|
-
const texture = gl.createTexture();
|
|
91
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
92
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
93
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
94
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
|
|
95
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
|
|
96
|
-
if (data instanceof Uint8Array) {
|
|
97
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);
|
|
98
|
-
} else {
|
|
99
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, data);
|
|
100
|
-
}
|
|
101
|
-
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
102
|
-
return texture;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function bindTexture(gl, texture, unit) {
|
|
106
|
-
gl.activeTexture(gl.TEXTURE0 + unit);
|
|
107
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function createBuffer(gl, data) {
|
|
111
|
-
const buffer = gl.createBuffer();
|
|
112
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
113
|
-
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
|
114
|
-
return buffer;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export function bindAttribute(gl, buffer, attribute, numComponents) {
|
|
118
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
119
|
-
gl.enableVertexAttribArray(attribute);
|
|
120
|
-
gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export function bindFramebuffer(gl, framebuffer, texture) {
|
|
124
|
-
if (texture) {
|
|
125
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
126
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
|
|
127
|
-
} else {
|
|
128
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
export function decodeBase64(data) {
|
|
134
|
-
const binary_string = atob(data);
|
|
135
|
-
const len = binary_string.length;
|
|
136
|
-
const bytes = new Uint8Array(len);
|
|
137
|
-
for (let i = 0; i < len; i++) {
|
|
138
|
-
bytes[i] = binary_string.charCodeAt(i);
|
|
139
|
-
}
|
|
140
|
-
return bytes;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
export function createImageFromBase64(encodedData) {
|
|
145
|
-
const bytes = decodeBase64(encodedData);
|
|
146
|
-
const blob = new Blob([bytes.buffer], { type: "image/png" });
|
|
147
|
-
const urlCreator = window.URL || window.webkitURL;
|
|
148
|
-
const imageUrl = urlCreator.createObjectURL(blob);
|
|
149
|
-
const image = new Image();
|
|
150
|
-
image.src = imageUrl;
|
|
151
|
-
return image;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
export function getColorRamp(colors) {
|
|
156
|
-
// console.log("getColorRamp", colors)
|
|
157
|
-
const canvas = document.createElement('canvas');
|
|
158
|
-
const ctx = canvas.getContext('2d');
|
|
159
|
-
|
|
160
|
-
canvas.width = 256;
|
|
161
|
-
canvas.height = 1;
|
|
162
|
-
|
|
163
|
-
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
164
|
-
|
|
165
|
-
for (const stop in colors) {
|
|
166
|
-
// console.log("stop", stop);
|
|
167
|
-
gradient.addColorStop(colors[stop][0], colors[stop][1]);
|
|
168
|
-
// Alttaki satir ile gradienti cevirip, shaderda ki `speed_t = 1.0 - speed_t`' kaldirdim.
|
|
169
|
-
// gradientin en dusuk olmasi gereken siyah - mavi aralikta, mor renk gozlemledim.
|
|
170
|
-
// gradient.addColorStop( 1.0 - colors[stop][0], colors[stop][1]);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
ctx.fillStyle = gradient;
|
|
174
|
-
ctx.fillRect(0, 0, 256, 1);
|
|
175
|
-
|
|
176
|
-
return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
export function getColorRampDiscrate(values, thresholds) {
|
|
181
|
-
|
|
182
|
-
const canvas = document.createElement('canvas');
|
|
183
|
-
const ctx = canvas.getContext('2d');
|
|
184
|
-
|
|
185
|
-
canvas.width = 256;
|
|
186
|
-
canvas.height = 1;
|
|
187
|
-
|
|
188
|
-
const gap = 1.0 / 256;
|
|
189
|
-
|
|
190
|
-
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
191
|
-
|
|
192
|
-
for (let i = 0; i < thresholds.length - 1; i++) {
|
|
193
|
-
gradient.addColorStop(thresholds[i], values[i]);
|
|
194
|
-
gradient.addColorStop(thresholds[i + 1] - gap
|
|
195
|
-
, values[i]);
|
|
196
|
-
}
|
|
197
|
-
gradient.addColorStop(thresholds[thresholds.length - 1], values[values.length - 1]);
|
|
198
|
-
ctx.fillStyle = gradient;
|
|
199
|
-
ctx.fillRect(0, 0, 256, 1);
|
|
200
|
-
|
|
201
|
-
return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export function getColorRampInterpolated(values, thresholds) {
|
|
205
|
-
|
|
206
|
-
const canvas = document.createElement('canvas');
|
|
207
|
-
const ctx = canvas.getContext('2d');
|
|
208
|
-
|
|
209
|
-
canvas.width = 256;
|
|
210
|
-
canvas.height = 1;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
214
|
-
|
|
215
|
-
// const gap = 1.0 / 256;
|
|
216
|
-
// gradient.addColorStop(thresholds[0], values[0]);
|
|
217
|
-
// gradient.addColorStop(thresholds[0] + gap, values[1]);
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
for (let i = 0; i < thresholds.length; i++) {
|
|
221
|
-
gradient.addColorStop(thresholds[i], values[i]);
|
|
222
|
-
}
|
|
223
|
-
// gradient.addColorStop(thresholds[thresholds.length - 1] - gap, values[values.length - 1]);
|
|
224
|
-
ctx.fillStyle = gradient;
|
|
225
|
-
ctx.fillRect(0, 0, 256, 1);
|
|
226
|
-
|
|
227
|
-
return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* values: n + 1 number of color hex values without alpha channel. Ex: ["#ff0000", "#00ff00", "#0000ff"]
|
|
232
|
-
* thresholds: n number of thresholds. Ex: [0, 10, 20]
|
|
233
|
-
* mode: [discrete, interpolated,]
|
|
234
|
-
*/
|
|
235
|
-
export function getColorRampModed(values, thresholds, mode = "interpolated") {
|
|
236
|
-
|
|
237
|
-
if (mode === "discrete") {
|
|
238
|
-
return getColorRampDiscrate(values, thresholds);
|
|
239
|
-
} else if (mode === "interpolated") {
|
|
240
|
-
return getColorRampInterpolated(values, thresholds);
|
|
241
|
-
} else {
|
|
242
|
-
throw new Error("mode is not valid");
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
export function defaultColorRamp() {
|
|
246
|
-
const defaultRampColors = [
|
|
247
|
-
[0.0, '#5e4fa2'],
|
|
248
|
-
[0.15, '#3288bd'],
|
|
249
|
-
[0.20, '#66c2a5'],
|
|
250
|
-
[0.25, '#66c2a5'],
|
|
251
|
-
[0.3, '#abdda4'],
|
|
252
|
-
[0.4, '#e6f598'],
|
|
253
|
-
[0.5, '#fee08b'],
|
|
254
|
-
[0.6, '#fdae61'],
|
|
255
|
-
[0.7, '#f46d43'],
|
|
256
|
-
[1.0, '#ff1e13']
|
|
257
|
-
];
|
|
258
|
-
return getColorRamp(defaultRampColors);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export function reloadCurrentGLProgram() {
|
|
262
|
-
return function (target, key, descriptor) {
|
|
263
|
-
const originalMethod = descriptor.value;
|
|
264
|
-
descriptor.value = function () {
|
|
265
|
-
const gl = target.gl;
|
|
266
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
267
|
-
originalMethod.apply(this, arguments);
|
|
268
|
-
gl.useProgram(currentProgram);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
package/waveparticles/adaptor.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
function centigradePlus90ToVectorArray(centigradeArray, noDataValue = -9999) {
|
|
2
|
-
const vectorArray = new Float32Array(centigradeArray.length * 2);
|
|
3
|
-
for (let i = 0; i < centigradeArray.length; i++) {
|
|
4
|
-
if (centigradeArray[i] === noDataValue) {
|
|
5
|
-
vectorArray.set([0, 0], i * 2);
|
|
6
|
-
continue;
|
|
7
|
-
}
|
|
8
|
-
const rad = (centigradeArray[i] + 90.0) * Math.PI / 180;
|
|
9
|
-
const x = Math.cos(rad);
|
|
10
|
-
const y = Math.sin(rad);
|
|
11
|
-
vectorArray.set([x, y], i * 2);
|
|
12
|
-
}
|
|
13
|
-
return vectorArray;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { centigradePlus90ToVectorArray }
|
package/waveparticles/index.js
DELETED
package/waveparticles/plugin.js
DELETED
|
@@ -1,313 +0,0 @@
|
|
|
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;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* STEPS:
|
|
11
|
-
* 1. move particle | buffers: read b1 write b2 | swap buffers b1 <-> b2
|
|
12
|
-
* 2. draw particles | read b1 to drawTexture1 |
|
|
13
|
-
* 3. globe shell drawTexture1
|
|
14
|
-
* 4. fade drawTexture1 to drawTexture2 | swap textures
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const MAX_PIXELS_ON_DIMENSION = 2200;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export default class Plugin {
|
|
23
|
-
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 } = {}) {
|
|
24
|
-
|
|
25
|
-
this.id = id;
|
|
26
|
-
this.globe = null;
|
|
27
|
-
this.gl = null;
|
|
28
|
-
this.moveParticle = null;
|
|
29
|
-
this.drawParticle = null;
|
|
30
|
-
this.bufferManager = null;
|
|
31
|
-
this._rgVectorFieldTexture = null;
|
|
32
|
-
this.globeShellWiggle = null;
|
|
33
|
-
this.waveUbo = null;
|
|
34
|
-
this._flipY = flipY;
|
|
35
|
-
this._drawTextureResolution = {};
|
|
36
|
-
this._frameBuffer = null;
|
|
37
|
-
this._fadeOpacity = fadeOpacity;
|
|
38
|
-
this._opacity = opacity;
|
|
39
|
-
this._particleCount = patricleCount;
|
|
40
|
-
this._dataWidth = dataWidth;
|
|
41
|
-
this._dataHeight = dataHeight;
|
|
42
|
-
this._drawTextureMaxPixelOnDimension = drawTextureMaxPixelOnDimension;
|
|
43
|
-
this._globeshellparameters = {
|
|
44
|
-
minLon,
|
|
45
|
-
maxLon,
|
|
46
|
-
minLat,
|
|
47
|
-
maxLat,
|
|
48
|
-
}
|
|
49
|
-
this._stepIndex = 0;
|
|
50
|
-
this._fullCycleStepCount = 3;
|
|
51
|
-
this._isFreed = false;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
init(globe, gl) {
|
|
55
|
-
this.globe = globe;
|
|
56
|
-
this.gl = gl;
|
|
57
|
-
this.moveParticle = new MoveParticle(gl);
|
|
58
|
-
this.drawParticle = new DrawParticle(gl);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.fadeAway = new FadeAway(gl);
|
|
62
|
-
|
|
63
|
-
this.globeShellWiggle = new GlobeShellWiggle(gl, globe, this._globeshellparameters);
|
|
64
|
-
const inPositionLocation = this.moveParticle.getInPositionLocation();
|
|
65
|
-
this.bufferManager = new PingPongBufferManager(gl, this._particleCount, inPositionLocation);
|
|
66
|
-
|
|
67
|
-
this._rgVectorFieldTexture = this._createRGTexture();
|
|
68
|
-
|
|
69
|
-
this.waveUbo = new WaveParticalUboManager(gl, 0);
|
|
70
|
-
|
|
71
|
-
this._drawTextures = [this._createDrawTexture(), this._createDrawTexture()];
|
|
72
|
-
this._frameBuffer = gl.createFramebuffer();
|
|
73
|
-
this.setBBox(this._globeshellparameters);
|
|
74
|
-
this.setOpacity(this._opacity);
|
|
75
|
-
this.____drawIndex = 0;
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
_createDrawTexture() {
|
|
80
|
-
const gl = this.gl
|
|
81
|
-
const texture = gl.createTexture();
|
|
82
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
83
|
-
// gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2200, 2200, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
84
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this._drawTextureResolution.width, this._drawTextureResolution.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
85
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
86
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
87
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
88
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
89
|
-
|
|
90
|
-
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
91
|
-
return texture;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
_step() {
|
|
96
|
-
this._stepIndex = (this._stepIndex + 1) % this._fullCycleStepCount;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
draw3D() {
|
|
100
|
-
if (this._isFreed) return;
|
|
101
|
-
const { gl, moveParticle, drawParticle, bufferManager, globeShellWiggle, waveUbo, fadeAway, _rgVectorFieldTexture } = this;
|
|
102
|
-
|
|
103
|
-
gl.disable(gl.DEPTH_TEST);
|
|
104
|
-
if (this._stepIndex === 0) {
|
|
105
|
-
waveUbo.update({ random_seed: Math.random() });
|
|
106
|
-
moveParticle.move(bufferManager, _rgVectorFieldTexture, waveUbo);
|
|
107
|
-
// 1s swap buffer b1 <-> b2
|
|
108
|
-
bufferManager.swap();
|
|
109
|
-
} else if (this._stepIndex === 1) {
|
|
110
|
-
this.____drawIndex = 1 - this.____drawIndex;
|
|
111
|
-
const canvasWidth = gl.canvas.width;
|
|
112
|
-
const canvasHeight = gl.canvas.height;
|
|
113
|
-
// gl.viewport(0, 0, 2200, 2200);
|
|
114
|
-
gl.viewport(0, 0, this._drawTextureResolution.width, this._drawTextureResolution.height);
|
|
115
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
116
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._drawTextures[this.____drawIndex], 0);
|
|
117
|
-
drawParticle.draw(bufferManager, _rgVectorFieldTexture, waveUbo);
|
|
118
|
-
// 2s bound frame buffer to null
|
|
119
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
120
|
-
gl.viewport(0, 0, canvasWidth, canvasHeight);
|
|
121
|
-
} else {
|
|
122
|
-
const canvasWidth = gl.canvas.width;
|
|
123
|
-
const canvasHeight = gl.canvas.height;
|
|
124
|
-
// gl.viewport(0, 0, 2200, 2200);
|
|
125
|
-
gl.viewport(0, 0, this._drawTextureResolution.width, this._drawTextureResolution.height);
|
|
126
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
127
|
-
gl.enable(gl.BLEND);
|
|
128
|
-
// gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
129
|
-
gl.blendFunc(gl.ONE, gl.ZERO)
|
|
130
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._drawTextures[1 - this.____drawIndex], 0);
|
|
131
|
-
fadeAway.draw(this._drawTextures[this.____drawIndex], this._fadeOpacity);
|
|
132
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
133
|
-
defaultblendfunction(gl);
|
|
134
|
-
gl.viewport(0, 0, canvasWidth, canvasHeight);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
globeShellWiggle.setTexture(this._drawTextures[this.____drawIndex]);
|
|
138
|
-
globeShellWiggle.draw();
|
|
139
|
-
this._step();
|
|
140
|
-
gl.enable(gl.DEPTH_TEST);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
setCycleStepCount(value) {
|
|
146
|
-
if (value < 3) {
|
|
147
|
-
this._fullCycleStepCount = 3;
|
|
148
|
-
}
|
|
149
|
-
this._fullCycleStepCount = value;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
_createRGTexture() {
|
|
155
|
-
const { gl, _dataWidth, _dataHeight, } = this;
|
|
156
|
-
const texture = gl.createTexture();
|
|
157
|
-
// R32F
|
|
158
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
159
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, null);
|
|
160
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
161
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
162
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
163
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
164
|
-
|
|
165
|
-
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
166
|
-
return texture;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
// TODO: free all resources
|
|
171
|
-
free() {
|
|
172
|
-
const { gl, fadeAway, globeShellWiggle, _rgVectorFieldTexture, bufferManager, waveUbo, _drawTextures, _frameBuffer } = this;
|
|
173
|
-
this._isFreed = true;
|
|
174
|
-
fadeAway.free();
|
|
175
|
-
globeShellWiggle.free();
|
|
176
|
-
gl.deleteTexture(_rgVectorFieldTexture);
|
|
177
|
-
// glProgramCache.releaseProgram(gl, MoveParticle);
|
|
178
|
-
this.moveParticle.free();
|
|
179
|
-
this.moveParticle = null
|
|
180
|
-
// glProgramCache.releaseProgram(gl, DrawParticle);
|
|
181
|
-
this.drawParticle.free();
|
|
182
|
-
this.drawParticle = null
|
|
183
|
-
bufferManager.free();
|
|
184
|
-
waveUbo.free();
|
|
185
|
-
_drawTextures.forEach(texture => gl.deleteTexture(texture));
|
|
186
|
-
gl.deleteFramebuffer(_frameBuffer);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
// setters
|
|
191
|
-
setParticleCount(value) {
|
|
192
|
-
this._particleCount = value;
|
|
193
|
-
this.bufferManager.setParticleCount(value);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
setVectorFieldData(data, { dataWidth = null, dataHeight = null, flipY } = {}) {
|
|
198
|
-
if (dataWidth !== null && dataHeight !== null) {
|
|
199
|
-
this._dataWidth = dataWidth;
|
|
200
|
-
this._dataHeight = dataHeight;
|
|
201
|
-
}
|
|
202
|
-
if (flipY !== undefined) {
|
|
203
|
-
this._flipY = flipY;
|
|
204
|
-
}
|
|
205
|
-
this.__data = data;
|
|
206
|
-
const { gl, _dataWidth, _dataHeight } = this;
|
|
207
|
-
gl.bindTexture(gl.TEXTURE_2D, this._rgVectorFieldTexture);
|
|
208
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY);
|
|
209
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, data);
|
|
210
|
-
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
211
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
setHeight(value) {
|
|
216
|
-
this.globeShellWiggle.setHeight(value);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
setDropRate(value) {
|
|
220
|
-
this.waveUbo.update({ drop_rate: value });
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
__readAndWriteTextureData() {
|
|
225
|
-
const { gl, _rgVectorFieldTexture, _dataWidth, _dataHeight } = this;
|
|
226
|
-
|
|
227
|
-
// Step 1: Bind the texture to a framebuffer
|
|
228
|
-
|
|
229
|
-
// Step 2: Read the texture data into a Float32Array
|
|
230
|
-
gl.bindTexture(gl.TEXTURE_2D, _rgVectorFieldTexture);
|
|
231
|
-
const textureData = new Float32Array(_dataWidth * _dataHeight * 2); // RG32F has 2 components per pixel
|
|
232
|
-
gl.readPixels(0, 0, _dataWidth, _dataHeight, gl.RG, gl.FLOAT, textureData);
|
|
233
|
-
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
234
|
-
// Step 3: Create a new texture and write the data back
|
|
235
|
-
|
|
236
|
-
// Step 4: Clean up
|
|
237
|
-
|
|
238
|
-
gl.deleteTexture(this._rgVectorFieldTexture);
|
|
239
|
-
|
|
240
|
-
// Replace the old texture with the new one
|
|
241
|
-
this._rgVectorFieldTexture = this._createRGTexture();
|
|
242
|
-
this.setVectorFieldData(textureData);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
_drawTextureSizeFromBbox({ minLon, minLat, maxLon, maxLat }) {
|
|
246
|
-
let horizon;
|
|
247
|
-
if (minLon > 0 && maxLon < 0) {
|
|
248
|
-
horizon = 360 - minLon + maxLon;
|
|
249
|
-
} else {
|
|
250
|
-
horizon = maxLon - minLon;
|
|
251
|
-
}
|
|
252
|
-
const vertical = maxLat - minLat;
|
|
253
|
-
let width, height;
|
|
254
|
-
if (horizon > vertical) {
|
|
255
|
-
width = this._drawTextureMaxPixelOnDimension;
|
|
256
|
-
height = Math.floor(this._drawTextureMaxPixelOnDimension * vertical / horizon);
|
|
257
|
-
} else {
|
|
258
|
-
height = this._drawTextureMaxPixelOnDimension;
|
|
259
|
-
width = Math.floor(this._drawTextureMaxPixelOnDimension * horizon / vertical);
|
|
260
|
-
}
|
|
261
|
-
return {
|
|
262
|
-
width,
|
|
263
|
-
height
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
setDrawTextureMaxPixelOnDimension(value) {
|
|
270
|
-
this._drawTextureMaxPixelOnDimension = value;
|
|
271
|
-
this._drawTextureResolution = this._drawTextureSizeFromBbox(this._globeshellparameters);
|
|
272
|
-
this.waveUbo.update({ draw_texture_size: [this._drawTextureResolution.width, this._drawTextureResolution.height] });
|
|
273
|
-
this._drawTextures = [this._createDrawTexture(), this._createDrawTexture()];
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
setParticleSpeed(value) {
|
|
277
|
-
this.waveUbo.update({ range: value });
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
setFadeOpacity(value) {
|
|
281
|
-
this._fadeOpacity = value;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
setOpacity(value) {
|
|
285
|
-
this.globeShellWiggle.setOpacity(value);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
setParticleDimensions(tail, wing) {
|
|
289
|
-
if (0 < tail || 0 < wing) {
|
|
290
|
-
this.waveUbo.update({ tail_wing_base_limp: [tail, wing] });
|
|
291
|
-
} else {
|
|
292
|
-
console.error("tail and wing must be greater than 0");
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
setParticleColor(color) {
|
|
297
|
-
if (color.length !== 3) {
|
|
298
|
-
console.error("color must be an array of rgb elements");
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
this.waveUbo.update({ color });
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
setBBox({ minLon, minLat, maxLon, maxLat }) {
|
|
306
|
-
this._globeshellparameters = { minLon, minLat, maxLon, maxLat };
|
|
307
|
-
this.globeShellWiggle.setBBox({ minLon, minLat, maxLon, maxLat });
|
|
308
|
-
this._drawTextureResolution = this._drawTextureSizeFromBbox({ minLon, minLat, maxLon, maxLat });
|
|
309
|
-
this.waveUbo.update({ draw_texture_size: [this._drawTextureResolution.width, this._drawTextureResolution.height] });
|
|
310
|
-
this._drawTextures = [this._createDrawTexture(), this._createDrawTexture()];
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {ImageData} imageData
|
|
3
|
-
* image
|
|
4
|
-
* uMax
|
|
5
|
-
* vMax
|
|
6
|
-
* height
|
|
7
|
-
* width
|
|
8
|
-
* @returns {Float32Array}
|
|
9
|
-
*/
|
|
10
|
-
export default function imageToMagnitude(imageData) {
|
|
11
|
-
const { image, uMax, vMax, uMin, vMin, height, width } = imageData;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const canvas = document.createElement('canvas');
|
|
16
|
-
const ctx = canvas.getContext('2d');
|
|
17
|
-
canvas.width = width;
|
|
18
|
-
canvas.height = height;
|
|
19
|
-
ctx.drawImage(image, 0, 0, width, height);
|
|
20
|
-
const img = ctx.getImageData(0, 0, width, height);
|
|
21
|
-
const data = img.data;
|
|
22
|
-
|
|
23
|
-
const magnitudeArray = new Float32Array(height * width);
|
|
24
|
-
|
|
25
|
-
const uDiff = uMax - uMin;
|
|
26
|
-
const vDiff = vMax - vMin;
|
|
27
|
-
|
|
28
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
29
|
-
const r = data[i];
|
|
30
|
-
const g = data[i + 1];
|
|
31
|
-
const u = uMin + (uDiff * r) / 255;
|
|
32
|
-
const v = vMin + (vDiff * g) / 255;
|
|
33
|
-
const magnitude = Math.sqrt(u * u + v * v);
|
|
34
|
-
const index = i / 4;
|
|
35
|
-
magnitudeArray[index] = magnitude;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return magnitudeArray;
|
|
39
|
-
}
|
package/wind/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import WindPlugin from "./plugin";
|
|
2
|
-
import createVectorFieldImage from "./vectorfieldimage";
|
|
3
|
-
import imageToMagnitude from "./imagetovectorfieldandmagnitude";
|
|
4
|
-
import { createImageFromBase64 } from "../util/webglobjectbuilders";
|
|
5
|
-
export { createVectorFieldImage, imageToMagnitude, WindPlugin, createImageFromBase64 };
|