Skip to content

Commit 04e54ef

Browse files
committed
Refined Math.Clamp.
1 parent 6aae306 commit 04e54ef

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

v3/src/math/Clamp.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,7 @@
99
*/
1010
var Clamp = function (v, min, max)
1111
{
12-
if (v < min)
13-
{
14-
return min;
15-
}
16-
else if (max < v)
17-
{
18-
return max;
19-
}
20-
else
21-
{
22-
return v;
23-
}
12+
return Math.max(min, Math.min(max, value));
2413
};
2514

2615
module.exports = Clamp;

0 commit comments

Comments
 (0)