浏览代码

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

Mr.doob 10 年之前
父节点
当前提交
70bd430c73
共有 1 个文件被更改,包括 2 次插入4 次删除
  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 ) );
 
 
 	},
 	},