Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/core/src/core/OrthoPerspectiveCamera/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ export class OrthoPerspectiveCamera extends SimpleCamera {

const size = this.currentWorld.renderer.getSize();

if (this.previousSize.x === 0 || this.previousSize.y === 0) {
this.previousSize.copy(size);
return;
}

const previousHeight = this.threeOrtho.top;
const previousWidth = this.threeOrtho.right;

Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/core/Worlds/src/simple-camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down