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