From c29f53e1781d078ad36df746f2232b118c8ad143 Mon Sep 17 00:00:00 2001 From: FMS_Cat Date: Fri, 9 Oct 2020 22:16:44 +0900 Subject: [PATCH] feat: make `fitToBox()` abort itself when it is given an empty box --- src/CameraControls.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/CameraControls.ts b/src/CameraControls.ts index 96eb260..9958cd7 100755 --- a/src/CameraControls.ts +++ b/src/CameraControls.ts @@ -974,6 +974,13 @@ export class CameraControls extends EventDispatcher { ? _box3A.copy( box3OrObject as _THREE.Box3 ) : _box3A.setFromObject( box3OrObject as _THREE.Object3D ); + if ( aabb.isEmpty() ) { + + console.warn( 'camera-controls: fitTo() cannot be used with an empty box. Aborting' ); + return; + + } + // round to closest axis ( forward | backward | right | left | top | bottom ) const theta = roundToStep( this._sphericalEnd.theta, PI_HALF ); const phi = roundToStep( this._sphericalEnd.phi, PI_HALF );