@pirireis/webglobeplugins 0.8.20 → 0.8.22
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/package.json +1 -1
- package/waveparticles/plugin.js +27 -3
package/package.json
CHANGED
package/waveparticles/plugin.js
CHANGED
|
@@ -139,6 +139,7 @@ export default class Plugin {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
|
|
142
|
+
|
|
142
143
|
setCycleStepCount(value) {
|
|
143
144
|
if (value < 3) {
|
|
144
145
|
this._fullCycleStepCount = 3;
|
|
@@ -146,6 +147,8 @@ export default class Plugin {
|
|
|
146
147
|
this._fullCycleStepCount = value;
|
|
147
148
|
}
|
|
148
149
|
|
|
150
|
+
|
|
151
|
+
|
|
149
152
|
_createRGTexture() {
|
|
150
153
|
const { gl, _dataWidth, _dataHeight, } = this;
|
|
151
154
|
const texture = gl.createTexture();
|
|
@@ -156,12 +159,12 @@ export default class Plugin {
|
|
|
156
159
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
157
160
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
158
161
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
159
|
-
|
|
160
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY);
|
|
162
|
+
|
|
161
163
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
162
164
|
return texture;
|
|
163
165
|
}
|
|
164
166
|
|
|
167
|
+
|
|
165
168
|
// TODO: free all resources
|
|
166
169
|
free() {
|
|
167
170
|
const { gl, fadeAway, globeShellWiggle, _rgVectorFieldTexture, bufferManager, waveUbo, _drawTextures, _frameBuffer } = this;
|
|
@@ -193,9 +196,10 @@ export default class Plugin {
|
|
|
193
196
|
this._dataWidth = dataWidth;
|
|
194
197
|
this._dataHeight = dataHeight;
|
|
195
198
|
}
|
|
196
|
-
|
|
199
|
+
this.__data = data;
|
|
197
200
|
const { gl, _dataWidth, _dataHeight } = this;
|
|
198
201
|
gl.bindTexture(gl.TEXTURE_2D, this._rgVectorFieldTexture);
|
|
202
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY);
|
|
199
203
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, data);
|
|
200
204
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
201
205
|
}
|
|
@@ -210,6 +214,26 @@ export default class Plugin {
|
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
|
|
217
|
+
__readAndWriteTextureData() {
|
|
218
|
+
const { gl, _rgVectorFieldTexture, _dataWidth, _dataHeight } = this;
|
|
219
|
+
|
|
220
|
+
// Step 1: Bind the texture to a framebuffer
|
|
221
|
+
|
|
222
|
+
// Step 2: Read the texture data into a Float32Array
|
|
223
|
+
gl.bindTexture(gl.TEXTURE_2D, _rgVectorFieldTexture);
|
|
224
|
+
const textureData = new Float32Array(_dataWidth * _dataHeight * 2); // RG32F has 2 components per pixel
|
|
225
|
+
gl.readPixels(0, 0, _dataWidth, _dataHeight, gl.RG, gl.FLOAT, textureData);
|
|
226
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
227
|
+
// Step 3: Create a new texture and write the data back
|
|
228
|
+
|
|
229
|
+
// Step 4: Clean up
|
|
230
|
+
|
|
231
|
+
gl.deleteTexture(this._rgVectorFieldTexture);
|
|
232
|
+
|
|
233
|
+
// Replace the old texture with the new one
|
|
234
|
+
this._rgVectorFieldTexture = this._createRGTexture();
|
|
235
|
+
this.setVectorFieldData(textureData);
|
|
236
|
+
}
|
|
213
237
|
|
|
214
238
|
_drawTextureSizeFromBbox({ minLon, minLat, maxLon, maxLat }) {
|
|
215
239
|
let horizon;
|