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