Skip to content

Commit 09c7789

Browse files
committed
Box2/Box3: Return center/size when empty. See mrdoob#9675.
1 parent efad557 commit 09c7789

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/math/Box2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ Box2.prototype = {
8989
center: function ( optionalTarget ) {
9090

9191
var result = optionalTarget || new Vector2();
92-
return result.addVectors( this.min, this.max ).multiplyScalar( 0.5 );
92+
return this.isEmpty() ? result.set( 0, 0 ) : result.addVectors( this.min, this.max ).multiplyScalar( 0.5 );
9393

9494
},
9595

9696
size: function ( optionalTarget ) {
9797

9898
var result = optionalTarget || new Vector2();
99-
return result.subVectors( this.max, this.min );
99+
return this.isEmpty() ? result.set( 0, 0 ) : result.subVectors( this.max, this.min );
100100

101101
},
102102

src/math/Box3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Box3.prototype = {
211211
size: function ( optionalTarget ) {
212212

213213
var result = optionalTarget || new Vector3();
214-
return result.subVectors( this.max, this.min );
214+
return this.isEmpty() ? result.set( 0, 0, 0 ) : result.subVectors( this.max, this.min );
215215

216216
},
217217

0 commit comments

Comments
 (0)