@pirireis/webglobeplugins 0.8.20 → 0.8.21

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.8.20",
3
+ "version": "0.8.21",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -146,6 +146,23 @@ export default class Plugin {
146
146
  this._fullCycleStepCount = value;
147
147
  }
148
148
 
149
+
150
+ setFlipY(value) {
151
+ if (typeof value === "boolean") {
152
+ if (this._flipY === value) {
153
+ return;
154
+ }
155
+ // TODO: read data from texture and write it back instead of keeping on the cpu memory
156
+ this._flipY = value;
157
+ this.gl.deleteTexture(this._rgVectorFieldTexture);
158
+ this._rgVectorFieldTexture = this._createRGTexture();
159
+ this.setVectorFieldData(this.__data);
160
+ this.globe.DrawRender();
161
+ } else {
162
+ throw new Error("flipY must be a boolean value");
163
+ }
164
+ }
165
+
149
166
  _createRGTexture() {
150
167
  const { gl, _dataWidth, _dataHeight, } = this;
151
168
  const texture = gl.createTexture();
@@ -193,7 +210,7 @@ export default class Plugin {
193
210
  this._dataWidth = dataWidth;
194
211
  this._dataHeight = dataHeight;
195
212
  }
196
-
213
+ this.__data = data;
197
214
  const { gl, _dataWidth, _dataHeight } = this;
198
215
  gl.bindTexture(gl.TEXTURE_2D, this._rgVectorFieldTexture);
199
216
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, data);
@@ -210,6 +227,26 @@ export default class Plugin {
210
227
  }
211
228
 
212
229
 
230
+ __readAndWriteTextureData() {
231
+ const { gl, _rgVectorFieldTexture, _dataWidth, _dataHeight } = this;
232
+
233
+ // Step 1: Bind the texture to a framebuffer
234
+
235
+ // Step 2: Read the texture data into a Float32Array
236
+ gl.bindTexture(gl.TEXTURE_2D, _rgVectorFieldTexture);
237
+ const textureData = new Float32Array(_dataWidth * _dataHeight * 2); // RG32F has 2 components per pixel
238
+ gl.readPixels(0, 0, _dataWidth, _dataHeight, gl.RG, gl.FLOAT, textureData);
239
+ gl.bindTexture(gl.TEXTURE_2D, null);
240
+ // Step 3: Create a new texture and write the data back
241
+
242
+ // Step 4: Clean up
243
+
244
+ gl.deleteTexture(this._rgVectorFieldTexture);
245
+
246
+ // Replace the old texture with the new one
247
+ this._rgVectorFieldTexture = this._createRGTexture();
248
+ this.setVectorFieldData(textureData);
249
+ }
213
250
 
214
251
  _drawTextureSizeFromBbox({ minLon, minLat, maxLon, maxLat }) {
215
252
  let horizon;