@pirireis/webglobeplugins 1.5.5 → 1.6.0

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": "1.5.5",
3
+ "version": "1.6.0",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -15,4 +15,4 @@
15
15
  "peerDependencies": {
16
16
  "@pirireis/webglobe": "6.2.51^"
17
17
  }
18
- }
18
+ }
@@ -69,6 +69,10 @@ export default class Plugin {
69
69
  _ableToUseSpeedField = false;
70
70
  _initialSpeedFieldData = null;
71
71
  __adaptiveOpacity = 1;
72
+ // Holds the framebuffer the globe was rendering into when draw3D was called.
73
+ // The globe may render to its own FBO (e.g. for depth-buffered 3D mode), so the
74
+ // plugin must restore it instead of forcing the default framebuffer (null).
75
+ _prevFBO = null;
72
76
  constructor(id, options) {
73
77
  this.id = id;
74
78
  this.options = { ...this.options, ...options };
@@ -142,9 +146,13 @@ export default class Plugin {
142
146
  draw3D() {
143
147
  if (this._isFreed)
144
148
  return;
145
- const { gl, moveParticle, drawParticle, bufferManager, globeShellWiggle, waveUbo, fadeAway, _rgVectorFieldTexture } = this;
149
+ const { gl, moveParticle, drawParticle, bufferManager, globeShellWiggle, waveUbo, fadeAway, _rgVectorFieldTexture, globe } = this;
146
150
  if (!gl || !bufferManager || !globeShellWiggle || !waveUbo || !fadeAway || !_rgVectorFieldTexture)
147
151
  return;
152
+ // Save the framebuffer the globe is currently rendering into and restore it
153
+ // when we are done. The globe may render to its own FBO (3D depth-buffered
154
+ // mode), so we must not force the default framebuffer (null).
155
+ this._prevFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING);
148
156
  gl.disable(gl.DEPTH_TEST);
149
157
  switch (this._stepIndex) {
150
158
  case 0:
@@ -158,8 +166,8 @@ export default class Plugin {
158
166
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
159
167
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._drawTextures[this.____drawIndex], 0);
160
168
  drawParticle.draw(bufferManager, _rgVectorFieldTexture, waveUbo, this._colorFieldTexture, this._speedFieldTexture);
161
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
162
- gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
169
+ gl.bindFramebuffer(gl.FRAMEBUFFER, this._prevFBO);
170
+ gl.viewport(0, 0, globe.api_ScrW(), globe.api_ScrH());
163
171
  break;
164
172
  case 2:
165
173
  gl.viewport(0, 0, this._drawTextureResolution.width, this._drawTextureResolution.height);
@@ -168,15 +176,17 @@ export default class Plugin {
168
176
  gl.blendFunc(gl.ONE, gl.ZERO);
169
177
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._drawTextures[1 - this.____drawIndex], 0);
170
178
  fadeAway.draw(this._drawTextures[this.____drawIndex], this.options.fadeOpacity);
171
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
179
+ gl.bindFramebuffer(gl.FRAMEBUFFER, this._prevFBO);
172
180
  defaultblendfunction(gl);
173
- gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
181
+ gl.viewport(0, 0, globe.api_ScrW(), globe.api_ScrH());
174
182
  break;
175
183
  }
176
184
  globeShellWiggle.setTexture(this._drawTextures[this.____drawIndex]);
177
185
  globeShellWiggle.draw();
178
186
  this._step();
179
187
  gl.enable(gl.DEPTH_TEST);
188
+ // Restore the globe's framebuffer in case any internal step changed it.
189
+ gl.bindFramebuffer(gl.FRAMEBUFFER, this._prevFBO);
180
190
  }
181
191
  setCycleStepCount(value) {
182
192
  if (value < 3) {
@@ -339,7 +349,6 @@ export default class Plugin {
339
349
  console.error("Speed field data length does not match the specified dataWidth and dataHeight.");
340
350
  return;
341
351
  }
342
- console.log(data);
343
352
  gl.bindTexture(gl.TEXTURE_2D, this._speedFieldTexture);
344
353
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this.options.flipY);
345
354
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.R32F, this.options.dataWidth, this.options.dataHeight, 0, gl.RED, gl.FLOAT, data);
@@ -357,7 +366,6 @@ export default class Plugin {
357
366
  this.waveUbo?.updateSingle("min_magnitude_threshold", new Float32Array([value]));
358
367
  }
359
368
  setMaxSpeedThreshold(value) {
360
- console.log("setMaxSpeedThreshold called with value:", value);
361
369
  this.options.maxSpeedThreshold = value;
362
370
  this.waveUbo?.updateSingle("max_magnitude_threshold", new Float32Array([value]));
363
371
  }