Browse Source

Math: Using max/min in clamp(). See #7326.

Mr.doob 9 years ago
parent
commit
70bd430c73
1 changed files with 2 additions and 4 deletions
  1. 2 4
      src/math/Math.js

+ 2 - 4
src/math/Math.js

@@ -42,11 +42,9 @@ THREE.Math = {
 
 	}(),
 
-	// Clamp value to range <a, b>
+	clamp: function ( value, min, max ) {
 
-	clamp: function ( x, a, b ) {
-
-		return ( x < a ) ? a : ( ( x > b ) ? b : x );
+		return Math.max( min, Math.min( max, value ) );
 
 	},