@pirireis/webglobeplugins 1.0.8 → 1.1.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.0.8",
3
+ "version": "1.1.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
+ }
@@ -17,6 +17,7 @@ class PickerDisplayer {
17
17
  _inProgress;
18
18
  _indexType; // R32I for Integer, R32F for Float
19
19
  _typedArrayConstructor;
20
+ _lastWidthHeight = null;
20
21
  constructor(globe, indexType = "R32I") {
21
22
  this.globe = globe;
22
23
  this.gl = globe.gl;
@@ -98,29 +99,29 @@ class PickerDisplayer {
98
99
  width = this.globe.api_ScrW();
99
100
  height = this.globe.api_ScrH();
100
101
  }
101
- const gl = this.gl;
102
- const saved = this._saveState();
103
- try {
104
- const { colorTexture, indexTexture } = this;
105
- gl.deleteTexture(colorTexture);
106
- gl.deleteTexture(indexTexture);
107
- const colorTextureNew = gl.createTexture();
108
- gl.bindTexture(gl.TEXTURE_2D, colorTextureNew);
109
- gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, width, height);
110
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
111
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
112
- const indexTextureNew = gl.createTexture();
113
- gl.bindTexture(gl.TEXTURE_2D, indexTextureNew);
114
- gl.texStorage2D(gl.TEXTURE_2D, 1, gl[this._indexType], width, height); // gl.R32I or gl.R32F
115
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
116
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
117
- gl.bindTexture(gl.TEXTURE_2D, null);
118
- this.colorTexture = colorTextureNew;
119
- this.indexTexture = indexTextureNew;
120
- }
121
- finally {
122
- this._restoreState(saved);
102
+ if (this._lastWidthHeight &&
103
+ this._lastWidthHeight.width === width &&
104
+ this._lastWidthHeight.height === height) {
105
+ return;
123
106
  }
107
+ this._lastWidthHeight = { width, height };
108
+ const gl = this.gl;
109
+ const { colorTexture, indexTexture } = this;
110
+ gl.deleteTexture(colorTexture);
111
+ gl.deleteTexture(indexTexture);
112
+ const colorTextureNew = gl.createTexture();
113
+ gl.bindTexture(gl.TEXTURE_2D, colorTextureNew);
114
+ gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, width, height);
115
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
116
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
117
+ const indexTextureNew = gl.createTexture();
118
+ gl.bindTexture(gl.TEXTURE_2D, indexTextureNew);
119
+ gl.texStorage2D(gl.TEXTURE_2D, 1, gl[this._indexType], width, height); // gl.R32I or gl.R32F
120
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
121
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
122
+ gl.bindTexture(gl.TEXTURE_2D, null);
123
+ this.colorTexture = colorTextureNew;
124
+ this.indexTexture = indexTextureNew;
124
125
  }
125
126
  clearTextures() {
126
127
  const gl = this.gl;
@@ -143,6 +144,7 @@ class PickerDisplayer {
143
144
  // call before drawing the scene with gl picker shader
144
145
  bindFBO() {
145
146
  const { gl, fbo } = this;
147
+ this.resize();
146
148
  gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
147
149
  // No need to bind textures or change ACTIVE_TEXTURE for framebufferTexture2D.
148
150
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.colorTexture, 0);