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