@pirireis/webglobeplugins 0.9.8 → 0.9.9
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/index.js +58 -15
- package/package.json +1 -1
- package/dist/Math/angle-calculation.js +0 -15
- package/dist/Math/arc.js +0 -65
- package/dist/Math/bounds/line-bbox.js +0 -188
- package/dist/Math/constants.js +0 -9
- package/dist/Math/frustum/camera.js +0 -24
- package/dist/Math/frustum/from-globeinfo.js +0 -48
- package/dist/Math/frustum/types.js +0 -2
- package/dist/Math/globe-util/horizon-plane.js +0 -112
- package/dist/Math/index.js +0 -1
- package/dist/Math/juction/arc-plane.js +0 -83
- package/dist/Math/juction/line-sphere.js +0 -25
- package/dist/Math/juction/plane-plane.js +0 -58
- package/dist/Math/line.js +0 -56
- package/dist/Math/matrix4.js +0 -1
- package/dist/Math/methods.js +0 -201
- package/dist/Math/plane.js +0 -60
- package/dist/Math/quaternion.js +0 -104
- package/dist/Math/types.js +0 -2
- package/dist/Math/utils.js +0 -4
- package/dist/Math/vec3.js +0 -126
- package/dist/algorithms/search-binary.js +0 -19
- package/dist/altitude-locator/adaptors.js +0 -1
- package/dist/altitude-locator/draw-subset-obj.js +0 -18
- package/dist/altitude-locator/keymethod.js +0 -1
- package/dist/altitude-locator/plugin.js +0 -341
- package/dist/altitude-locator/types.js +0 -23
- package/dist/arrowfield/adaptor.js +0 -14
- package/dist/arrowfield/index.js +0 -10
- package/dist/arrowfield/plugin.js +0 -86
- package/dist/bearing-line/index.js +0 -8
- package/dist/bearing-line/plugin.js +0 -449
- package/dist/circle-line-chain/chain-list-map.js +0 -205
- package/dist/circle-line-chain/init.js +0 -1
- package/dist/circle-line-chain/plugin.js +0 -424
- package/dist/circle-line-chain/util.js +0 -5
- package/dist/compass-rose/compass-rose-padding-flat.js +0 -225
- package/dist/compass-rose/compass-text-writer.js +0 -153
- package/dist/compass-rose/index.js +0 -7
- package/dist/compassrose/compassrose.js +0 -296
- package/dist/compassrose/index.js +0 -8
- package/dist/globe-types.js +0 -1
- package/dist/heatwave/index.js +0 -10
- package/dist/heatwave/isobar/objectarraylabels.js +0 -202
- package/dist/heatwave/isobar/plugin.js +0 -343
- package/dist/heatwave/isobar/quadtreecontours.js +0 -300
- package/dist/heatwave/plugins/heatwaveglobeshell.js +0 -206
- package/dist/index.js +0 -58
- package/dist/jest.config.js +0 -7
- package/dist/partialrings/buffer-manager.js +0 -81
- package/dist/partialrings/index.js +0 -41
- package/dist/partialrings/plugin.js +0 -135
- package/dist/partialrings/program.js +0 -286
- package/dist/pin/pin-object-array.js +0 -305
- package/dist/pin/pin-point-totem.js +0 -60
- package/dist/point-heat-map/adaptors/timetracksplugin-format-to-this.js +0 -66
- package/dist/point-heat-map/index.js +0 -1
- package/dist/point-heat-map/plugin-webworker.js +0 -126
- package/dist/point-heat-map/point-to-heat-map-flow.js +0 -127
- package/dist/point-tracks/key-methods.js +0 -5
- package/dist/point-tracks/plugin.js +0 -338
- package/dist/programs/arrowfield/index.js +0 -7
- package/dist/programs/arrowfield/logic.js +0 -257
- package/dist/programs/arrowfield/object.js +0 -66
- package/dist/programs/data2legend/density-to-legend.js +0 -101
- package/dist/programs/data2legend/point-to-density-texture.js +0 -100
- package/dist/programs/float2legendwithratio/index.js +0 -8
- package/dist/programs/float2legendwithratio/logic.js +0 -171
- package/dist/programs/float2legendwithratio/object.js +0 -110
- package/dist/programs/globe-util/is-globe-moved.js +0 -21
- package/dist/programs/globeshell/index.js +0 -8
- package/dist/programs/globeshell/noise/noises.js +0 -1
- package/dist/programs/globeshell/wiggle/index.js +0 -8
- package/dist/programs/globeshell/wiggle/logic.js +0 -345
- package/dist/programs/globeshell/wiggle/object.js +0 -72
- package/dist/programs/helpers/blender/index.js +0 -1
- package/dist/programs/helpers/blender/program.js +0 -79
- package/dist/programs/helpers/fadeaway/index.js +0 -7
- package/dist/programs/helpers/fadeaway/logic.js +0 -72
- package/dist/programs/helpers/fadeaway/object.js +0 -20
- package/dist/programs/helpers/index.js +0 -8
- package/dist/programs/index.js +0 -58
- package/dist/programs/interface.js +0 -1
- package/dist/programs/line-on-globe/angled-line.js +0 -176
- package/dist/programs/line-on-globe/circle-accurate-3d.js +0 -141
- package/dist/programs/line-on-globe/circle-accurate-flat.js +0 -216
- package/dist/programs/line-on-globe/circle-accurate.js +0 -178
- package/dist/programs/line-on-globe/circle.js +0 -167
- package/dist/programs/line-on-globe/degree-padding-around-circle-3d.js +0 -159
- package/dist/programs/line-on-globe/index.js +0 -1
- package/dist/programs/line-on-globe/lines-color-instanced-flat.js +0 -136
- package/dist/programs/line-on-globe/linestrip.js +0 -171
- package/dist/programs/line-on-globe/naive-accurate-flexible.js +0 -195
- package/dist/programs/line-on-globe/to-the-surface.js +0 -111
- package/dist/programs/line-on-globe/util.js +0 -8
- package/dist/programs/picking/pickable-renderer.js +0 -188
- package/dist/programs/point-on-globe/element-globe-surface-glow.js +0 -142
- package/dist/programs/point-on-globe/element-point-glow.js +0 -153
- package/dist/programs/point-on-globe/square-pixel-point.js +0 -174
- package/dist/programs/programcache.js +0 -131
- package/dist/programs/rings/distancering/circleflatprogram.js +0 -156
- package/dist/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -369
- package/dist/programs/rings/distancering/circlepaddysharedbuffer.js +0 -357
- package/dist/programs/rings/distancering/index.js +0 -14
- package/dist/programs/rings/distancering/paddyflatprogram.js +0 -172
- package/dist/programs/rings/distancering/paddyflatprogram2d.js +0 -174
- package/dist/programs/rings/distancering/paddyflatprogram3d.js +0 -172
- package/dist/programs/rings/distancering/shader.js +0 -1
- package/dist/programs/rings/index.js +0 -17
- package/dist/programs/rings/partial-ring/piece-of-pie.js +0 -275
- package/dist/programs/totems/camerauniformblock.js +0 -160
- package/dist/programs/totems/canvas-webglobe-info.js +0 -110
- package/dist/programs/totems/gpu-selection-uniform-block.js +0 -108
- package/dist/programs/totems/index.js +0 -40
- package/dist/programs/two-d/pixel-circle.js +0 -1
- package/dist/programs/two-d/pixel-padding-for-compass.js +0 -162
- package/dist/programs/util.js +0 -17
- package/dist/programs/vectorfields/index.js +0 -23
- package/dist/programs/vectorfields/logics/drawrectangleparticles.js +0 -107
- package/dist/programs/vectorfields/logics/index.js +0 -12
- package/dist/programs/vectorfields/logics/pixelbased.js +0 -142
- package/dist/programs/vectorfields/logics/ubo.js +0 -63
- package/dist/programs/vectorfields/pingpongbuffermanager.js +0 -76
- package/dist/rangerings/enum.js +0 -5
- package/dist/rangerings/index.js +0 -15
- package/dist/rangerings/plugin.js +0 -560
- package/dist/rangerings/rangeringangletext.js +0 -329
- package/dist/rangerings/ring-account.js +0 -117
- package/dist/shaders/fragment-toy/firework.js +0 -58
- package/dist/shaders/fragment-toy/singularity.js +0 -59
- package/dist/shape-on-terrain/arc/naive/plugin.js +0 -252
- package/dist/timetracks/adaptors-line-strip.js +0 -71
- package/dist/timetracks/adaptors.js +0 -122
- package/dist/timetracks/index.js +0 -19
- package/dist/timetracks/plugin-line-strip.js +0 -250
- package/dist/timetracks/plugin.js +0 -258
- package/dist/timetracks/program-line-strip.js +0 -611
- package/dist/timetracks/program.js +0 -772
- package/dist/timetracks/programpoint-line-strip.js +0 -154
- package/dist/timetracks/programpoint.js +0 -147
- package/dist/types.js +0 -15
- package/dist/util/account/bufferoffsetmanager.js +0 -179
- package/dist/util/account/index.js +0 -23
- package/dist/util/account/single-attribute-buffer-management/buffer-manager.js +0 -108
- package/dist/util/account/single-attribute-buffer-management/buffer-orchestrator.js +0 -150
- package/dist/util/account/single-attribute-buffer-management/index.js +0 -9
- package/dist/util/account/single-attribute-buffer-management/object-store.js +0 -51
- package/dist/util/account/single-attribute-buffer-management/types.js +0 -2
- package/dist/util/account/util.js +0 -22
- package/dist/util/algorithms/index.js +0 -1
- package/dist/util/algorithms/search-binary.js +0 -28
- package/dist/util/check/get.js +0 -18
- package/dist/util/check/index.js +0 -1
- package/dist/util/check/typecheck.js +0 -49
- package/dist/util/geometry/index.js +0 -51
- package/dist/util/gl-util/buffer/attribute-loader.js +0 -69
- package/dist/util/gl-util/buffer/index.js +0 -6
- package/dist/util/gl-util/buffer/types.js +0 -1
- package/dist/util/gl-util/draw-options/methods.js +0 -38
- package/dist/util/gl-util/draw-options/types.js +0 -15
- package/dist/util/gl-util/uniform-block/manager.js +0 -156
- package/dist/util/gl-util/uniform-block/shader.js +0 -1
- package/dist/util/gl-util/uniform-block/types.js +0 -8
- package/dist/util/heatwavedatamanager/datamanager.js +0 -152
- package/dist/util/heatwavedatamanager/index.js +0 -10
- package/dist/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +0 -122
- package/dist/util/heatwavedatamanager/pointcoordsmeta.js +0 -20
- package/dist/util/index.js +0 -57
- package/dist/util/interpolation/index.js +0 -1
- package/dist/util/interpolation/timetrack/index.js +0 -5
- package/dist/util/interpolation/timetrack/timetrack-interpolator.js +0 -79
- package/dist/util/interpolation/timetrack/web-worker-str.js +0 -183
- package/dist/util/interpolation/timetrack/web-worker.js +0 -48
- package/dist/util/jshelpers/data-filler.js +0 -20
- package/dist/util/jshelpers/equality.js +0 -20
- package/dist/util/jshelpers/index.js +0 -37
- package/dist/util/jshelpers/timefilters.js +0 -32
- package/dist/util/picking/fence.js +0 -46
- package/dist/util/picking/picker-displayer.js +0 -139
- package/dist/util/programs/draw-texture-on-canvas.js +0 -89
- package/dist/util/programs/index.js +0 -17
- package/dist/util/programs/shapesonglobe.js +0 -214
- package/dist/util/programs/supersampletotextures.js +0 -113
- package/dist/util/programs/texturetoglobe.js +0 -182
- package/dist/util/shaderfunctions/geometrytransformations.js +0 -340
- package/dist/util/shaderfunctions/index.js +0 -18
- package/dist/util/shaderfunctions/nodata.js +0 -11
- package/dist/util/shaderfunctions/noisefunctions.js +0 -43
- package/dist/util/surface-line-data/arc-bboxes.js +0 -25
- package/dist/util/surface-line-data/arcs-to-cuts.js +0 -50
- package/dist/util/surface-line-data/cut-arc.js +0 -1
- package/dist/util/surface-line-data/flow.js +0 -28
- package/dist/util/surface-line-data/rbush-manager.js +0 -1
- package/dist/util/surface-line-data/types.js +0 -1
- package/dist/util/surface-line-data/web-worker.js +0 -1
- package/dist/util/webglobe/gldefaultstates.js +0 -7
- package/dist/util/webglobe/index.js +0 -18
- package/dist/util/webglobe/rasteroverlay.js +0 -78
- package/dist/util/webglobjectbuilders.js +0 -388
- package/dist/util/webglobjectbuilders1.js +0 -237
- package/dist/waveparticles/adaptor.js +0 -17
- package/dist/waveparticles/index.js +0 -10
- package/dist/waveparticles/plugin.js +0 -266
- package/dist/wind/imagetovectorfieldandmagnitude.js +0 -35
- package/dist/wind/index.js +0 -14
- package/dist/wind/plugin.js +0 -926
- package/dist/wind/vectorfieldimage.js +0 -25
- package/dist/write-text/attached-text-writer.js +0 -91
- package/dist/write-text/context-text.js +0 -98
- package/dist/write-text/context-text3.js +0 -155
- package/dist/write-text/index.js +0 -5
- package/dist/write-text/writer-plugin.js +0 -8
|
@@ -1,266 +0,0 @@
|
|
|
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;
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/wind/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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; } });
|