From 9631a7110eef6c8e7fb4961794f4ab69e0f7ec26 Mon Sep 17 00:00:00 2001 From: ShaMan123 Date: Sat, 22 Aug 2026 11:32:34 +0300 Subject: [PATCH 1/2] fix(OrthoPerspectiveCamera): safeguard zero size --- packages/core/src/core/OrthoPerspectiveCamera/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/src/core/OrthoPerspectiveCamera/index.ts b/packages/core/src/core/OrthoPerspectiveCamera/index.ts index a70276357..a84f7a317 100644 --- a/packages/core/src/core/OrthoPerspectiveCamera/index.ts +++ b/packages/core/src/core/OrthoPerspectiveCamera/index.ts @@ -219,10 +219,15 @@ export class OrthoPerspectiveCamera extends SimpleCamera { return; } - if (!this.previousSize) return; - const size = this.currentWorld.renderer.getSize(); + if (!this.previousSize || size.x === 0 || size.y === 0) return; + + if (this.previousSize.x === 0 || this.previousSize.y === 0) { + this.previousSize.copy(size); + return; + } + const previousHeight = this.threeOrtho.top; const previousWidth = this.threeOrtho.right; From 5d6c9fe539a85bb440807a4985477f8b0ff8dd1f Mon Sep 17 00:00:00 2001 From: ShaMan123 Date: Sat, 22 Aug 2026 18:09:57 +0300 Subject: [PATCH 2/2] fixes --- packages/core/src/core/OrthoPerspectiveCamera/index.ts | 4 ++-- packages/core/src/core/Worlds/src/simple-camera.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/core/src/core/OrthoPerspectiveCamera/index.ts b/packages/core/src/core/OrthoPerspectiveCamera/index.ts index a84f7a317..7c5160802 100644 --- a/packages/core/src/core/OrthoPerspectiveCamera/index.ts +++ b/packages/core/src/core/OrthoPerspectiveCamera/index.ts @@ -219,9 +219,9 @@ export class OrthoPerspectiveCamera extends SimpleCamera { return; } - const size = this.currentWorld.renderer.getSize(); + if (!this.previousSize) return; - if (!this.previousSize || size.x === 0 || size.y === 0) return; + const size = this.currentWorld.renderer.getSize(); if (this.previousSize.x === 0 || this.previousSize.y === 0) { this.previousSize.copy(size); diff --git a/packages/core/src/core/Worlds/src/simple-camera.ts b/packages/core/src/core/Worlds/src/simple-camera.ts index c4bc99aef..0969e4f20 100644 --- a/packages/core/src/core/Worlds/src/simple-camera.ts +++ b/packages/core/src/core/Worlds/src/simple-camera.ts @@ -198,6 +198,16 @@ export class SimpleCamera extends BaseCamera implements Updateable, Disposable { */ updateAspect = () => { if (!this.currentWorld || !this.currentWorld.renderer) return; + if (this.currentWorld.renderer?.isResizeable()) { + const currentSize = this.currentWorld.renderer.getSize(); + // A collapsed or hidden container draws nothing. + // There is no aspect to derive from it, while applying one is + // destructive in both projections: a perspective camera takes + // `aspect = 0`, i.e. a non-finite projection matrix, and an orthographic + // one gets its extents scaled to zero. + // Keep the frustum we have. + if (currentSize.width === 0 || currentSize.height === 0) return; + } if (this.three instanceof THREE.OrthographicCamera) { this.onAspectUpdated.trigger(); return;