Skip to content

Commit

Permalink
fix(core): add guard for cullers pixel reading
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Aug 28, 2024
1 parent 5052f9d commit fdacb77
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -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)",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/core/Components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>();
Expand Down
27 changes: 17 additions & 10 deletions packages/core/src/core/Cullers/src/culler-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
27 changes: 17 additions & 10 deletions packages/core/src/core/ShadowedScene/src/distance-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit fdacb77

Please sign in to comment.