diff --git a/packages/core/package.json b/packages/core/package.json index 3cb648ae1..7a7b35d25 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@thatopen/components", "description": "Collection of core functionalities to author BIM apps.", - "version": "2.2.6", + "version": "2.2.7", "author": "That Open Company", "contributors": [ "Antonio Gonzalez Viegas (https://github.com/agviegas)", diff --git a/packages/core/src/core/Components/index.ts b/packages/core/src/core/Components/index.ts index d0dd59d86..1d19d42f4 100644 --- a/packages/core/src/core/Components/index.ts +++ b/packages/core/src/core/Components/index.ts @@ -14,7 +14,7 @@ export class Components implements Disposable { /** * The version of the @thatopen/components library. */ - static readonly release = "2.2.6"; + static readonly release = "2.2.7"; /** {@link Disposable.onDisposed} */ readonly onDisposed = new Event(); diff --git a/packages/core/src/core/Cullers/src/culler-renderer.ts b/packages/core/src/core/Cullers/src/culler-renderer.ts index 36ed374e2..1ba321d07 100644 --- a/packages/core/src/core/Cullers/src/culler-renderer.ts +++ b/packages/core/src/core/Cullers/src/culler-renderer.ts @@ -175,16 +175,23 @@ export class CullerRenderer { this.renderer.render(this.scene, camera); const context = this.renderer.getContext() as WebGL2RenderingContext; - await readPixelsAsync( - context, - 0, - 0, - this._width, - this._height, - context.RGBA, - context.UNSIGNED_BYTE, - this._buffer, - ); + + try { + await readPixelsAsync( + context, + 0, + 0, + this._width, + this._height, + context.RGBA, + context.UNSIGNED_BYTE, + this._buffer, + ); + } catch (e) { + // Pixels couldn't be read, possibly because culler was disposed + this.renderer.setRenderTarget(null); + return; + } this.renderer.setRenderTarget(null); diff --git a/packages/core/src/core/ShadowedScene/src/distance-renderer.ts b/packages/core/src/core/ShadowedScene/src/distance-renderer.ts index 188a5bef8..1f53007a7 100644 --- a/packages/core/src/core/ShadowedScene/src/distance-renderer.ts +++ b/packages/core/src/core/ShadowedScene/src/distance-renderer.ts @@ -240,16 +240,23 @@ void main() { this.renderer.render(this.scene, this.camera); const context = this.renderer.getContext() as WebGL2RenderingContext; - await readPixelsAsync( - context, - 0, - 0, - this._width, - this._height, - context.RGBA, - context.UNSIGNED_BYTE, - this._buffer, - ); + + try { + await readPixelsAsync( + context, + 0, + 0, + this._width, + this._height, + context.RGBA, + context.UNSIGNED_BYTE, + this._buffer, + ); + } catch (e) { + // Pixels couldn't be read, possibly because culler was disposed + this.renderer.setRenderTarget(null); + return; + } this.renderer.setRenderTarget(null);