@pirireis/webglobeplugins 0.9.11 → 0.9.12
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 +8 -8
- package/Math/arc.js +18 -18
- package/Math/bounds/line-bbox.js +78 -80
- package/Math/constants.js +3 -3
- package/Math/juction/arc-plane.js +23 -23
- package/Math/juction/line-sphere.js +11 -11
- package/Math/juction/plane-plane.js +11 -11
- package/Math/line.js +14 -16
- package/Math/methods.js +65 -70
- package/Math/plane.js +16 -18
- package/Math/quaternion.js +45 -49
- package/Math/utils.js +2 -2
- package/Math/vec3.js +42 -45
- package/algorithms/search-binary.js +4 -4
- package/altitude-locator/draw-subset-obj.js +7 -8
- package/altitude-locator/plugin.js +98 -114
- package/arrowfield/adaptor.js +3 -4
- package/arrowfield/index.js +2 -2
- package/arrowfield/plugin.js +62 -65
- package/bearing-line/index.js +1 -1
- package/bearing-line/plugin.js +200 -226
- package/circle-line-chain/chain-list-map.js +82 -88
- package/circle-line-chain/plugin.js +134 -165
- package/circle-line-chain/util.js +1 -1
- package/compass-rose/compass-rose-padding-flat.js +108 -133
- package/compass-rose/compass-text-writer.js +62 -70
- package/compass-rose/index.js +2 -2
- package/compassrose/compassrose.js +46 -50
- package/compassrose/index.js +1 -1
- package/heatwave/index.js +2 -2
- package/heatwave/isobar/objectarraylabels.js +44 -48
- package/heatwave/isobar/plugin.js +104 -123
- package/heatwave/isobar/quadtreecontours.js +76 -92
- package/heatwave/plugins/heatwaveglobeshell.js +69 -87
- package/index.js +11 -11
- package/package.json +1 -1
- package/partialrings/buffer-manager.js +32 -64
- package/partialrings/index.js +1 -1
- package/partialrings/plugin.js +48 -84
- package/partialrings/program.js +136 -47
- package/pin/pin-object-array.js +83 -86
- package/pin/pin-point-totem.js +21 -22
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
- package/point-heat-map/plugin-webworker.js +40 -45
- package/point-heat-map/point-to-heat-map-flow.js +40 -42
- package/point-tracks/key-methods.js +1 -1
- package/point-tracks/plugin.js +137 -162
- package/programs/arrowfield/index.js +1 -1
- package/programs/arrowfield/logic.js +170 -62
- package/programs/arrowfield/object.js +33 -35
- package/programs/data2legend/density-to-legend.js +45 -21
- package/programs/data2legend/point-to-density-texture.js +52 -27
- package/programs/float2legendwithratio/index.js +1 -1
- package/programs/float2legendwithratio/logic.js +88 -42
- package/programs/float2legendwithratio/object.js +43 -46
- package/programs/globe-util/is-globe-moved.js +10 -11
- package/programs/globeshell/index.js +1 -1
- package/programs/globeshell/wiggle/index.js +1 -1
- package/programs/globeshell/wiggle/logic.js +191 -98
- package/programs/globeshell/wiggle/object.js +33 -35
- package/programs/helpers/blender/program.js +36 -19
- package/programs/helpers/fadeaway/index.js +1 -1
- package/programs/helpers/fadeaway/logic.js +35 -13
- package/programs/helpers/fadeaway/object.js +9 -10
- package/programs/helpers/index.js +1 -1
- package/programs/index.js +8 -8
- package/programs/line-on-globe/angled-line.js +91 -32
- package/programs/line-on-globe/circle-accurate-3d.js +82 -32
- package/programs/line-on-globe/circle-accurate-flat.js +108 -50
- package/programs/line-on-globe/circle-accurate.js +103 -33
- package/programs/line-on-globe/circle.js +97 -32
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +83 -33
- package/programs/line-on-globe/lines-color-instanced-flat.js +79 -34
- package/programs/line-on-globe/linestrip.js +111 -45
- package/programs/line-on-globe/naive-accurate-flexible.js +120 -50
- package/programs/line-on-globe/to-the-surface.js +58 -29
- package/programs/line-on-globe/util.js +1 -1
- package/programs/picking/pickable-renderer.js +117 -33
- package/programs/point-on-globe/element-globe-surface-glow.js +78 -38
- package/programs/point-on-globe/element-point-glow.js +103 -35
- package/programs/point-on-globe/square-pixel-point.js +76 -27
- package/programs/programcache.js +13 -13
- package/programs/rings/distancering/circleflatprogram.js +63 -21
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +156 -145
- package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -197
- package/programs/rings/distancering/index.js +4 -4
- package/programs/rings/distancering/paddyflatprogram.js +73 -20
- package/programs/rings/distancering/paddyflatprogram2d.js +75 -22
- package/programs/rings/distancering/paddyflatprogram3d.js +73 -20
- package/programs/rings/partial-ring/piece-of-pie.js +137 -35
- package/programs/totems/camerauniformblock.js +64 -51
- package/programs/totems/canvas-webglobe-info.js +48 -40
- package/programs/totems/gpu-selection-uniform-block.js +44 -40
- package/programs/totems/index.js +1 -1
- package/programs/two-d/pixel-padding-for-compass.js +90 -29
- package/programs/util.js +6 -7
- package/programs/vectorfields/index.js +1 -1
- package/programs/vectorfields/logics/drawrectangleparticles.js +70 -29
- package/programs/vectorfields/logics/index.js +3 -3
- package/programs/vectorfields/logics/pixelbased.js +91 -35
- package/programs/vectorfields/logics/ubo.js +31 -25
- package/programs/vectorfields/pingpongbuffermanager.js +30 -34
- package/rangerings/index.js +4 -4
- package/rangerings/plugin.js +202 -258
- package/rangerings/rangeringangletext.js +108 -120
- package/rangerings/ring-account.js +52 -69
- package/shaders/fragment-toy/firework.js +55 -1
- package/shaders/fragment-toy/singularity.js +55 -1
- package/timetracks/adaptors-line-strip.js +26 -37
- package/timetracks/adaptors.js +47 -61
- package/timetracks/index.js +4 -4
- package/timetracks/plugin-line-strip.js +63 -71
- package/timetracks/plugin.js +69 -77
- package/timetracks/program-line-strip.js +296 -103
- package/timetracks/program.js +419 -113
- package/timetracks/programpoint-line-strip.js +97 -44
- package/timetracks/programpoint.js +90 -44
- package/util/account/bufferoffsetmanager.js +72 -95
- package/util/account/index.js +1 -1
- package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -44
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -94
- package/util/account/single-attribute-buffer-management/index.js +3 -3
- package/util/account/single-attribute-buffer-management/object-store.js +29 -30
- package/util/account/util.js +2 -4
- package/util/algorithms/search-binary.js +4 -4
- package/util/check/get.js +5 -5
- package/util/check/typecheck.js +13 -15
- package/util/geometry/index.js +9 -11
- package/util/gl-util/buffer/attribute-loader.js +8 -20
- package/util/gl-util/buffer/index.js +1 -1
- package/util/gl-util/draw-options/methods.js +8 -9
- package/util/gl-util/uniform-block/manager.js +67 -67
- package/util/heatwavedatamanager/datamanager.js +56 -116
- package/util/heatwavedatamanager/index.js +2 -2
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +37 -40
- package/util/heatwavedatamanager/pointcoordsmeta.js +9 -10
- package/util/index.js +6 -6
- package/util/interpolation/timetrack/index.js +1 -1
- package/util/interpolation/timetrack/timetrack-interpolator.js +27 -29
- package/util/interpolation/timetrack/web-worker-str.js +179 -1
- package/util/interpolation/timetrack/web-worker.js +4 -4
- package/util/jshelpers/data-filler.js +7 -7
- package/util/jshelpers/timefilters.js +7 -7
- package/util/picking/fence.js +7 -7
- package/util/picking/picker-displayer.js +46 -52
- package/util/programs/draw-texture-on-canvas.js +39 -21
- package/util/programs/shapesonglobe.js +104 -64
- package/util/programs/supersampletotextures.js +45 -39
- package/util/programs/texturetoglobe.js +98 -48
- package/util/shaderfunctions/geometrytransformations.js +322 -27
- package/util/shaderfunctions/nodata.js +7 -1
- package/util/shaderfunctions/noisefunctions.js +39 -9
- package/util/surface-line-data/arcs-to-cuts.js +20 -23
- package/util/webglobe/rasteroverlay.js +35 -37
- package/util/webglobjectbuilders.js +55 -60
- package/util/webglobjectbuilders1.js +48 -49
- package/waveparticles/adaptor.js +6 -7
- package/waveparticles/index.js +2 -2
- package/waveparticles/plugin.js +79 -84
- package/wind/imagetovectorfieldandmagnitude.js +15 -15
- package/wind/index.js +4 -4
- package/wind/plugin.js +453 -251
- package/wind/vectorfieldimage.js +5 -5
- package/write-text/attached-text-writer.js +46 -48
- package/write-text/context-text.js +51 -58
- package/write-text/context-text3.js +69 -74
package/waveparticles/plugin.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const programs_1 = require("../programs");
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
const programs_2 = require("../programs");
|
|
6
|
+
const programs_3 = require("../programs");
|
|
7
|
+
const { PixelBasedMove, DrawRectangleParticles, PingPongBufferManager, WaveParticalUboManager } = programs_2.vectorfield;
|
|
8
|
+
const MoveParticle = PixelBasedMove;
|
|
9
|
+
const DrawParticle = DrawRectangleParticles;
|
|
10
10
|
/**
|
|
11
11
|
* STEPS:
|
|
12
12
|
* 1. move particle | buffers: read b1 write b2 | swap buffers b1 <-> b2
|
|
@@ -15,10 +15,9 @@ var DrawParticle = DrawRectangleParticles;
|
|
|
15
15
|
* 4. fade drawTexture1 to drawTexture2 | swap textures
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
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;
|
|
18
|
+
const MAX_PIXELS_ON_DIMENSION = 2200;
|
|
19
|
+
class Plugin {
|
|
20
|
+
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
21
|
this.id = id;
|
|
23
22
|
this.globe = null;
|
|
24
23
|
this.gl = null;
|
|
@@ -38,23 +37,23 @@ var Plugin = /** @class */ (function () {
|
|
|
38
37
|
this._dataHeight = dataHeight;
|
|
39
38
|
this._drawTextureMaxPixelOnDimension = drawTextureMaxPixelOnDimension;
|
|
40
39
|
this._globeshellparameters = {
|
|
41
|
-
minLon
|
|
42
|
-
maxLon
|
|
43
|
-
minLat
|
|
44
|
-
maxLat
|
|
40
|
+
minLon,
|
|
41
|
+
maxLon,
|
|
42
|
+
minLat,
|
|
43
|
+
maxLat,
|
|
45
44
|
};
|
|
46
45
|
this._stepIndex = 0;
|
|
47
46
|
this._fullCycleStepCount = 3;
|
|
48
47
|
this._isFreed = false;
|
|
49
48
|
}
|
|
50
|
-
|
|
49
|
+
init(globe, gl) {
|
|
51
50
|
this.globe = globe;
|
|
52
51
|
this.gl = gl;
|
|
53
52
|
this.moveParticle = new MoveParticle(gl);
|
|
54
53
|
this.drawParticle = new DrawParticle(gl);
|
|
55
54
|
this.fadeAway = new programs_3.FadeAway(gl);
|
|
56
55
|
this.globeShellWiggle = new programs_1.GlobeShellWiggle(gl, globe, this._globeshellparameters);
|
|
57
|
-
|
|
56
|
+
const inPositionLocation = this.moveParticle.getInPositionLocation();
|
|
58
57
|
this.bufferManager = new PingPongBufferManager(gl, this._particleCount, inPositionLocation);
|
|
59
58
|
this._rgVectorFieldTexture = this._createRGTexture();
|
|
60
59
|
this.waveUbo = new WaveParticalUboManager(gl, 0);
|
|
@@ -63,10 +62,10 @@ var Plugin = /** @class */ (function () {
|
|
|
63
62
|
this.setBBox(this._globeshellparameters);
|
|
64
63
|
this.setOpacity(this._opacity);
|
|
65
64
|
this.____drawIndex = 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
}
|
|
66
|
+
_createDrawTexture() {
|
|
67
|
+
const gl = this.gl;
|
|
68
|
+
const texture = gl.createTexture();
|
|
70
69
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
71
70
|
// gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2200, 2200, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
72
71
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this._drawTextureResolution.width, this._drawTextureResolution.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
@@ -76,14 +75,14 @@ var Plugin = /** @class */ (function () {
|
|
|
76
75
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
77
76
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
78
77
|
return texture;
|
|
79
|
-
}
|
|
80
|
-
|
|
78
|
+
}
|
|
79
|
+
_step() {
|
|
81
80
|
this._stepIndex = (this._stepIndex + 1) % this._fullCycleStepCount;
|
|
82
|
-
}
|
|
83
|
-
|
|
81
|
+
}
|
|
82
|
+
draw3D() {
|
|
84
83
|
if (this._isFreed)
|
|
85
84
|
return;
|
|
86
|
-
|
|
85
|
+
const { gl, moveParticle, drawParticle, bufferManager, globeShellWiggle, waveUbo, fadeAway, _rgVectorFieldTexture } = this;
|
|
87
86
|
gl.disable(gl.DEPTH_TEST);
|
|
88
87
|
if (this._stepIndex === 0) {
|
|
89
88
|
waveUbo.update({ random_seed: Math.random() });
|
|
@@ -93,8 +92,8 @@ var Plugin = /** @class */ (function () {
|
|
|
93
92
|
}
|
|
94
93
|
else if (this._stepIndex === 1) {
|
|
95
94
|
this.____drawIndex = 1 - this.____drawIndex;
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
const canvasWidth = gl.canvas.width;
|
|
96
|
+
const canvasHeight = gl.canvas.height;
|
|
98
97
|
// gl.viewport(0, 0, 2200, 2200);
|
|
99
98
|
gl.viewport(0, 0, this._drawTextureResolution.width, this._drawTextureResolution.height);
|
|
100
99
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
@@ -105,8 +104,8 @@ var Plugin = /** @class */ (function () {
|
|
|
105
104
|
gl.viewport(0, 0, canvasWidth, canvasHeight);
|
|
106
105
|
}
|
|
107
106
|
else {
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
const canvasWidth = gl.canvas.width;
|
|
108
|
+
const canvasHeight = gl.canvas.height;
|
|
110
109
|
// gl.viewport(0, 0, 2200, 2200);
|
|
111
110
|
gl.viewport(0, 0, this._drawTextureResolution.width, this._drawTextureResolution.height);
|
|
112
111
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
@@ -123,16 +122,16 @@ var Plugin = /** @class */ (function () {
|
|
|
123
122
|
globeShellWiggle.draw();
|
|
124
123
|
this._step();
|
|
125
124
|
gl.enable(gl.DEPTH_TEST);
|
|
126
|
-
}
|
|
127
|
-
|
|
125
|
+
}
|
|
126
|
+
setCycleStepCount(value) {
|
|
128
127
|
if (value < 3) {
|
|
129
128
|
this._fullCycleStepCount = 3;
|
|
130
129
|
}
|
|
131
130
|
this._fullCycleStepCount = value;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
}
|
|
132
|
+
_createRGTexture() {
|
|
133
|
+
const { gl, _dataWidth, _dataHeight, } = this;
|
|
134
|
+
const texture = gl.createTexture();
|
|
136
135
|
// R32F
|
|
137
136
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
138
137
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, null);
|
|
@@ -142,10 +141,10 @@ var Plugin = /** @class */ (function () {
|
|
|
142
141
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
143
142
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
144
143
|
return texture;
|
|
145
|
-
}
|
|
144
|
+
}
|
|
146
145
|
// TODO: free all resources
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
free() {
|
|
147
|
+
const { gl, fadeAway, globeShellWiggle, _rgVectorFieldTexture, bufferManager, waveUbo, _drawTextures, _frameBuffer } = this;
|
|
149
148
|
this._isFreed = true;
|
|
150
149
|
fadeAway.free();
|
|
151
150
|
globeShellWiggle.free();
|
|
@@ -158,16 +157,15 @@ var Plugin = /** @class */ (function () {
|
|
|
158
157
|
this.drawParticle = null;
|
|
159
158
|
bufferManager.free();
|
|
160
159
|
waveUbo.free();
|
|
161
|
-
_drawTextures.forEach(
|
|
160
|
+
_drawTextures.forEach(texture => gl.deleteTexture(texture));
|
|
162
161
|
gl.deleteFramebuffer(_frameBuffer);
|
|
163
|
-
}
|
|
162
|
+
}
|
|
164
163
|
// setters
|
|
165
|
-
|
|
164
|
+
setParticleCount(value) {
|
|
166
165
|
this._particleCount = value;
|
|
167
166
|
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;
|
|
167
|
+
}
|
|
168
|
+
setVectorFieldData(data, { dataWidth = null, dataHeight = null, flipY } = {}) {
|
|
171
169
|
if (dataWidth !== null && dataHeight !== null) {
|
|
172
170
|
this._dataWidth = dataWidth;
|
|
173
171
|
this._dataHeight = dataHeight;
|
|
@@ -176,25 +174,25 @@ var Plugin = /** @class */ (function () {
|
|
|
176
174
|
this._flipY = flipY;
|
|
177
175
|
}
|
|
178
176
|
this.__data = data;
|
|
179
|
-
|
|
177
|
+
const { gl, _dataWidth, _dataHeight } = this;
|
|
180
178
|
gl.bindTexture(gl.TEXTURE_2D, this._rgVectorFieldTexture);
|
|
181
179
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY);
|
|
182
180
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, data);
|
|
183
181
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
184
182
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
185
|
-
}
|
|
186
|
-
|
|
183
|
+
}
|
|
184
|
+
setHeight(value) {
|
|
187
185
|
this.globeShellWiggle.setHeight(value);
|
|
188
|
-
}
|
|
189
|
-
|
|
186
|
+
}
|
|
187
|
+
setDropRate(value) {
|
|
190
188
|
this.waveUbo.update({ drop_rate: value });
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
}
|
|
190
|
+
__readAndWriteTextureData() {
|
|
191
|
+
const { gl, _rgVectorFieldTexture, _dataWidth, _dataHeight } = this;
|
|
194
192
|
// Step 1: Bind the texture to a framebuffer
|
|
195
193
|
// Step 2: Read the texture data into a Float32Array
|
|
196
194
|
gl.bindTexture(gl.TEXTURE_2D, _rgVectorFieldTexture);
|
|
197
|
-
|
|
195
|
+
const textureData = new Float32Array(_dataWidth * _dataHeight * 2); // RG32F has 2 components per pixel
|
|
198
196
|
gl.readPixels(0, 0, _dataWidth, _dataHeight, gl.RG, gl.FLOAT, textureData);
|
|
199
197
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
200
198
|
// Step 3: Create a new texture and write the data back
|
|
@@ -203,18 +201,17 @@ var Plugin = /** @class */ (function () {
|
|
|
203
201
|
// Replace the old texture with the new one
|
|
204
202
|
this._rgVectorFieldTexture = this._createRGTexture();
|
|
205
203
|
this.setVectorFieldData(textureData);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
var horizon;
|
|
204
|
+
}
|
|
205
|
+
_drawTextureSizeFromBbox({ minLon, minLat, maxLon, maxLat }) {
|
|
206
|
+
let horizon;
|
|
210
207
|
if (minLon > 0 && maxLon < 0) {
|
|
211
208
|
horizon = 360 - minLon + maxLon;
|
|
212
209
|
}
|
|
213
210
|
else {
|
|
214
211
|
horizon = maxLon - minLon;
|
|
215
212
|
}
|
|
216
|
-
|
|
217
|
-
|
|
213
|
+
const vertical = maxLat - minLat;
|
|
214
|
+
let width, height;
|
|
218
215
|
if (horizon > vertical) {
|
|
219
216
|
width = this._drawTextureMaxPixelOnDimension;
|
|
220
217
|
height = Math.floor(this._drawTextureMaxPixelOnDimension * vertical / horizon);
|
|
@@ -224,48 +221,46 @@ var Plugin = /** @class */ (function () {
|
|
|
224
221
|
width = Math.floor(this._drawTextureMaxPixelOnDimension * horizon / vertical);
|
|
225
222
|
}
|
|
226
223
|
return {
|
|
227
|
-
width
|
|
228
|
-
height
|
|
224
|
+
width,
|
|
225
|
+
height
|
|
229
226
|
};
|
|
230
|
-
}
|
|
231
|
-
|
|
227
|
+
}
|
|
228
|
+
setDrawTextureMaxPixelOnDimension(value) {
|
|
232
229
|
this._drawTextureMaxPixelOnDimension = value;
|
|
233
230
|
this._drawTextureResolution = this._drawTextureSizeFromBbox(this._globeshellparameters);
|
|
234
231
|
this.waveUbo.update({ draw_texture_size: [this._drawTextureResolution.width, this._drawTextureResolution.height] });
|
|
235
232
|
this._drawTextures = [this._createDrawTexture(), this._createDrawTexture()];
|
|
236
|
-
}
|
|
237
|
-
|
|
233
|
+
}
|
|
234
|
+
setParticleSpeed(value) {
|
|
238
235
|
this.waveUbo.update({ range: value });
|
|
239
|
-
}
|
|
240
|
-
|
|
236
|
+
}
|
|
237
|
+
setFadeOpacity(value) {
|
|
241
238
|
this._fadeOpacity = value;
|
|
242
|
-
}
|
|
243
|
-
|
|
239
|
+
}
|
|
240
|
+
setOpacity(value) {
|
|
244
241
|
this.globeShellWiggle.setOpacity(value);
|
|
245
|
-
}
|
|
246
|
-
|
|
242
|
+
}
|
|
243
|
+
setParticleDimensions(tail, wing) {
|
|
247
244
|
if (0 < tail || 0 < wing) {
|
|
248
245
|
this.waveUbo.update({ tail_wing_base_limp: [tail, wing] });
|
|
249
246
|
}
|
|
250
247
|
else {
|
|
251
248
|
console.error("tail and wing must be greater than 0");
|
|
252
249
|
}
|
|
253
|
-
}
|
|
254
|
-
|
|
250
|
+
}
|
|
251
|
+
setParticleColor(color) {
|
|
255
252
|
if (color.length !== 3) {
|
|
256
253
|
console.error("color must be an array of rgb elements");
|
|
257
254
|
return;
|
|
258
255
|
}
|
|
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 });
|
|
256
|
+
this.waveUbo.update({ color });
|
|
257
|
+
}
|
|
258
|
+
setBBox({ minLon, minLat, maxLon, maxLat }) {
|
|
259
|
+
this._globeshellparameters = { minLon, minLat, maxLon, maxLat };
|
|
260
|
+
this.globeShellWiggle.setBBox({ minLon, minLat, maxLon, maxLat });
|
|
261
|
+
this._drawTextureResolution = this._drawTextureSizeFromBbox({ minLon, minLat, maxLon, maxLat });
|
|
266
262
|
this.waveUbo.update({ draw_texture_size: [this._drawTextureResolution.width, this._drawTextureResolution.height] });
|
|
267
263
|
this._drawTextures = [this._createDrawTexture(), this._createDrawTexture()];
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
}());
|
|
264
|
+
}
|
|
265
|
+
}
|
|
271
266
|
exports.default = Plugin;
|
|
@@ -11,24 +11,24 @@ exports.default = imageToMagnitude;
|
|
|
11
11
|
* @returns {Float32Array}
|
|
12
12
|
*/
|
|
13
13
|
function imageToMagnitude(imageData) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const { image, uMax, vMax, uMin, vMin, height, width } = imageData;
|
|
15
|
+
const canvas = document.createElement('canvas');
|
|
16
|
+
const ctx = canvas.getContext('2d');
|
|
17
17
|
canvas.width = width;
|
|
18
18
|
canvas.height = height;
|
|
19
19
|
ctx.drawImage(image, 0, 0, width, height);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
const img = ctx.getImageData(0, 0, width, height);
|
|
21
|
+
const data = img.data;
|
|
22
|
+
const magnitudeArray = new Float32Array(height * width);
|
|
23
|
+
const uDiff = uMax - uMin;
|
|
24
|
+
const vDiff = vMax - vMin;
|
|
25
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
26
|
+
const r = data[i];
|
|
27
|
+
const g = data[i + 1];
|
|
28
|
+
const u = uMin + (uDiff * r) / 255;
|
|
29
|
+
const v = vMin + (vDiff * g) / 255;
|
|
30
|
+
const magnitude = Math.sqrt(u * u + v * v);
|
|
31
|
+
const index = i / 4;
|
|
32
32
|
magnitudeArray[index] = magnitude;
|
|
33
33
|
}
|
|
34
34
|
return magnitudeArray;
|
package/wind/index.js
CHANGED
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createImageFromBase64 = exports.WindPlugin = exports.imageToMagnitude = exports.createVectorFieldImage = void 0;
|
|
7
|
-
|
|
7
|
+
const plugin_1 = __importDefault(require("./plugin"));
|
|
8
8
|
exports.WindPlugin = plugin_1.default;
|
|
9
|
-
|
|
9
|
+
const vectorfieldimage_1 = __importDefault(require("./vectorfieldimage"));
|
|
10
10
|
exports.createVectorFieldImage = vectorfieldimage_1.default;
|
|
11
|
-
|
|
11
|
+
const imagetovectorfieldandmagnitude_1 = __importDefault(require("./imagetovectorfieldandmagnitude"));
|
|
12
12
|
exports.imageToMagnitude = imagetovectorfieldandmagnitude_1.default;
|
|
13
|
-
|
|
13
|
+
const webglobjectbuilders_1 = require("../util/webglobjectbuilders");
|
|
14
14
|
Object.defineProperty(exports, "createImageFromBase64", { enumerable: true, get: function () { return webglobjectbuilders_1.createImageFromBase64; } });
|