Bladeren bron

inf. bounds (#25546)

ycw 2 jaren geleden
bovenliggende
commit
3e2a3734ee
2 gewijzigde bestanden met toevoegingen van 7 en 0 verwijderingen
  1. 2 0
      src/math/Box2.js
  2. 5 0
      test/unit/src/math/Box2.tests.js

+ 2 - 0
src/math/Box2.js

@@ -169,6 +169,8 @@ class Box2 {
 		this.min.max( box.min );
 		this.max.min( box.max );
 
+		if ( this.isEmpty() ) this.makeEmpty();
+
 		return this;
 
 	}

+ 5 - 0
test/unit/src/math/Box2.tests.js

@@ -349,6 +349,11 @@ export default QUnit.module( 'Maths', () => {
 			assert.ok( b.clone().intersect( c ).equals( b ), 'Passed!' );
 			assert.ok( c.clone().intersect( c ).equals( c ), 'Passed!' );
 
+			const d = new Box2( one2.clone().negate(), zero2.clone() );
+			const e = new Box2( one2.clone(), two2.clone() ).intersect( d );
+
+			assert.ok( e.min.equals( posInf2 ) && e.max.equals( negInf2 ), 'Infinite empty' );
+
 		} );
 
 		QUnit.test( 'union', ( assert ) => {