@pirireis/webglobeplugins 1.5.4 → 1.5.5

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.4",
3
+ "version": "1.5.5",
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
+ }
@@ -263,6 +263,7 @@ export class ArcOnTerrainPlugin {
263
263
  indexes: null
264
264
  };
265
265
  program.draw(_attributeLoader, drawOptions, this._opacity, _arcUBOHandler);
266
+ console.log("draw3d arc");
266
267
  gl.enable(gl.DEPTH_TEST);
267
268
  }
268
269
  _buildArcs(subSetIDs = null) {
@@ -182,20 +182,27 @@ export default class TimeTrackMultiColorPlugin {
182
182
  draw3D(projMatrix, modelviewMatrix, transPos) {
183
183
  if (!this._ready)
184
184
  return;
185
- const { _headTime, _tailTime, program, _transporArr, globe } = this;
185
+ const { _headTime, _tailTime, program, _transporArr, globe, gl } = this;
186
186
  this.pointProgram?.draw();
187
187
  _transporArr.set([transPos.x, transPos.y, transPos.z], 0);
188
188
  const geomType = globe.api_GetCurrentGeometry();
189
+ // Save the framebuffer the globe is currently rendering into and pass it to the
190
+ // program so the final composite lands in the globe's render target. The globe may
191
+ // render to its own FBO (3D depth-buffered mode); forcing null would discard the
192
+ // output and break subsequent plugins.
193
+ const targetFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING);
189
194
  if (geomType === 0) {
190
- program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr);
195
+ program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr, null, targetFBO);
191
196
  }
192
197
  else if (geomType === 1) {
193
198
  const { width, height } = globe.api_GetCurrentWorldWH();
194
- program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr, [width, height]);
199
+ program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr, [width, height], targetFBO);
195
200
  }
196
201
  else {
197
202
  console.error("Unknown geometry type", geomType);
198
203
  }
204
+ // Restore the globe's framebuffer in case any internal step changed it.
205
+ gl.bindFramebuffer(gl.FRAMEBUFFER, targetFBO);
199
206
  }
200
207
  resize(width, height) {
201
208
  const { program, globe } = this;
@@ -533,7 +533,7 @@ void main() {
533
533
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
534
534
  gl.bindTexture(gl.TEXTURE_2D, null);
535
535
  }
536
- draw(u_head_time, u_tail_time, uProjectionMatrix, uModelViewMatrix, uTranslate, u_mapWH = null) {
536
+ draw(u_head_time, u_tail_time, uProjectionMatrix, uModelViewMatrix, uTranslate, u_mapWH = null, targetFBO = null) {
537
537
  const { gl, _lineProgram, _blurProgram, _blurRepetition } = this;
538
538
  this._resetTexture();
539
539
  gl.enable(gl.BLEND);
@@ -576,7 +576,10 @@ void main() {
576
576
  gl.drawArrays(gl.TRIANGLES, 0, 6);
577
577
  }
578
578
  // combine
579
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
579
+ // Composite into the globe's render target (targetFBO) instead of forcing the
580
+ // default framebuffer. The globe may render to its own FBO in 3D depth-buffered
581
+ // mode, so forcing null would discard the output and break subsequent plugins.
582
+ gl.bindFramebuffer(gl.FRAMEBUFFER, targetFBO);
580
583
  gl.useProgram(this._combineProgram.program);
581
584
  gl.bindVertexArray(this._combineProgram.vao);
582
585
  gl.activeTexture(gl.TEXTURE1);
@@ -369,6 +369,10 @@ export default class WindPlugin {
369
369
  this.lastdatas = [[], [], { x: 0, y: 0, z: 0 }];
370
370
  this._drawParticles = this._drawParticlesSphere;
371
371
  this._lastLOD = 0;
372
+ // Holds the framebuffer the globe was rendering into when draw3D was called.
373
+ // The globe may render to its own FBO (e.g. for depth-buffered 3D mode), so the
374
+ // wind plugin must restore it instead of forcing the default framebuffer (null).
375
+ this._prevFBO = null;
372
376
  }
373
377
  // Uniforms are loaded once, on initiation and when they are changed.
374
378
  set height(value) {
@@ -633,13 +637,16 @@ export default class WindPlugin {
633
637
  const gl = this.gl;
634
638
  this._drawScreen();
635
639
  this._updateParticles();
636
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
640
+ gl.bindFramebuffer(gl.FRAMEBUFFER, this._prevFBO);
637
641
  }
638
642
  // globe calls `draw3D` method on each frame
639
643
  draw3D(projMatrix, modelviewMatrix, transPos) {
640
644
  const gl = this.gl;
641
645
  if (this._doDraw()) {
642
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
646
+ // Save the framebuffer the globe is currently rendering into and restore it
647
+ // when we are done. The globe may render to its own FBO (3D depth-buffered
648
+ // mode), so we must not force the default framebuffer (null).
649
+ this._prevFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING);
643
650
  this.transPos.set([transPos.x, transPos.y, transPos.z], 0);
644
651
  this.projMatrix = projMatrix;
645
652
  this.modelviewMatrix = modelviewMatrix;
@@ -673,7 +680,7 @@ export default class WindPlugin {
673
680
  gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); // non-premultiplied alpha
674
681
  this._drawTexture(this.backgroundTexture, this._fadeOpacity);
675
682
  this._drawParticles();
676
- bindFramebuffer(gl, null);
683
+ bindFramebuffer(gl, this._prevFBO);
677
684
  this._drawTexture(this.screenTexture, 1.0);
678
685
  // gl.disable(gl.BLEND);
679
686
  // save the current screen as the background for the next frame
@@ -793,7 +800,10 @@ export default class WindPlugin {
793
800
  gl.bindVertexArray(null); // Add this line
794
801
  gl.enable(gl.BLEND);
795
802
  defaultblendfunction(gl);
796
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
803
+ // Restore the framebuffer the globe was rendering into before draw3D was called.
804
+ // Forcing null here would clobber the globe's FBO in 3D depth-buffered mode and
805
+ // break subsequent plugins (e.g. arc-plugin, plugin-line-strip).
806
+ gl.bindFramebuffer(gl.FRAMEBUFFER, this._prevFBO);
797
807
  gl.viewport(0, 0, globe.api_ScrW(), globe.api_ScrH());
798
808
  }
799
809
  _loadHeight() {