Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make fitToBox() abort itself when it is given an empty box #143

Merged
merged 1 commit into from
Oct 10, 2020
Merged
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
7 changes: 7 additions & 0 deletions src/CameraControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines +979 to +980
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose warn + early abort. Does it look good for you?


}

// 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 );
Expand Down