Browse Source

Box2, Box3: Escape ternary condition in "intersectsBox" method (#28872)

* negate Box2.intersectsBox

* negate Box3.intersectsBox
satelllte 1 year ago
parent
commit
91f0857b27
2 changed files with 5 additions and 5 deletions
  1. 2 2
      src/math/Box2.js
  2. 3 3
      src/math/Box3.js

+ 2 - 2
src/math/Box2.js

@@ -147,8 +147,8 @@ class Box2 {
 
 		// using 4 splitting planes to rule out intersections
 
-		return box.max.x < this.min.x || box.min.x > this.max.x ||
-			box.max.y < this.min.y || box.min.y > this.max.y ? false : true;
+		return box.max.x >= this.min.x && box.min.x <= this.max.x &&
+			box.max.y >= this.min.y && box.min.y <= this.max.y;
 
 	}
 

+ 3 - 3
src/math/Box3.js

@@ -268,9 +268,9 @@ class Box3 {
 	intersectsBox( box ) {
 
 		// using 6 splitting planes to rule out intersections.
-		return box.max.x < this.min.x || box.min.x > this.max.x ||
-			box.max.y < this.min.y || box.min.y > this.max.y ||
-			box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
+		return box.max.x >= this.min.x && box.min.x <= this.max.x &&
+			box.max.y >= this.min.y && box.min.y <= this.max.y &&
+			box.max.z >= this.min.z && box.min.z <= this.max.z;
 
 	}