Explorar el Código

Box2, Box3: Escape ternary condition in "containsPoint" method (#28871)

* negate Box2.containsPoint

* negate Box3.containsPoint
satelllte hace 1 año
padre
commit
aee800916e
Se han modificado 2 ficheros con 5 adiciones y 5 borrados
  1. 2 2
      src/math/Box2.js
  2. 3 3
      src/math/Box3.js

+ 2 - 2
src/math/Box2.js

@@ -119,8 +119,8 @@ class Box2 {
 
 	containsPoint( point ) {
 
-		return point.x < this.min.x || point.x > this.max.x ||
-			point.y < this.min.y || point.y > this.max.y ? false : true;
+		return point.x >= this.min.x && point.x <= this.max.x &&
+			point.y >= this.min.y && point.y <= this.max.y;
 
 	}
 

+ 3 - 3
src/math/Box3.js

@@ -238,9 +238,9 @@ class Box3 {
 
 	containsPoint( point ) {
 
-		return point.x < this.min.x || point.x > this.max.x ||
-			point.y < this.min.y || point.y > this.max.y ||
-			point.z < this.min.z || point.z > this.max.z ? false : true;
+		return point.x >= this.min.x && point.x <= this.max.x &&
+			point.y >= this.min.y && point.y <= this.max.y &&
+			point.z >= this.min.z && point.z <= this.max.z;
 
 	}