Browse Source

Updated builds.

Mr.doob 8 years ago
parent
commit
f29400f630
3 changed files with 127 additions and 98 deletions
  1. 27 13
      build/three.js
  2. 73 72
      build/three.min.js
  3. 27 13
      build/three.module.js

+ 27 - 13
build/three.js

@@ -738,7 +738,7 @@
 
 
 		clamp: function ( min, max ) {
 		clamp: function ( min, max ) {
 
 
-			// This function assumes min < max, if this assumption isn't true it will not operate correctly
+			// assumes min < max, componentwise
 
 
 			this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 			this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 			this.y = Math.max( min.y, Math.min( max.y, this.y ) );
 			this.y = Math.max( min.y, Math.min( max.y, this.y ) );
@@ -767,7 +767,7 @@
 
 
 			var length = this.length();
 			var length = this.length();
 
 
-			return this.multiplyScalar( Math.max( min, Math.min( max, length ) ) / length );
+			return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
 
 
 		},
 		},
 
 
@@ -842,7 +842,7 @@
 
 
 		normalize: function () {
 		normalize: function () {
 
 
-			return this.divideScalar( this.length() );
+			return this.divideScalar( this.length() || 1 );
 
 
 		},
 		},
 
 
@@ -879,7 +879,7 @@
 
 
 		setLength: function ( length ) {
 		setLength: function ( length ) {
 
 
-			return this.multiplyScalar( length / this.length() );
+			return this.normalize().multiplyScalar( length );
 
 
 		},
 		},
 
 
@@ -1670,7 +1670,7 @@
 
 
 		clamp: function ( min, max ) {
 		clamp: function ( min, max ) {
 
 
-			// This function assumes min < max, if this assumption isn't true it will not operate correctly
+			// assumes min < max, componentwise
 
 
 			this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 			this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 			this.y = Math.max( min.y, Math.min( max.y, this.y ) );
 			this.y = Math.max( min.y, Math.min( max.y, this.y ) );
@@ -1683,11 +1683,17 @@
 
 
 		clampScalar: function () {
 		clampScalar: function () {
 
 
-			var min = new Vector4();
-			var max = new Vector4();
+			var min, max;
 
 
 			return function clampScalar( minVal, maxVal ) {
 			return function clampScalar( minVal, maxVal ) {
 
 
+				if ( min === undefined ) {
+
+					min = new Vector4();
+					max = new Vector4();
+
+				}
+
 				min.set( minVal, minVal, minVal, minVal );
 				min.set( minVal, minVal, minVal, minVal );
 				max.set( maxVal, maxVal, maxVal, maxVal );
 				max.set( maxVal, maxVal, maxVal, maxVal );
 
 
@@ -1697,6 +1703,14 @@
 
 
 		}(),
 		}(),
 
 
+		clampLength: function ( min, max ) {
+
+			var length = this.length();
+
+			return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
+
+		},
+
 		floor: function () {
 		floor: function () {
 
 
 			this.x = Math.floor( this.x );
 			this.x = Math.floor( this.x );
@@ -1778,13 +1792,13 @@
 
 
 		normalize: function () {
 		normalize: function () {
 
 
-			return this.divideScalar( this.length() );
+			return this.divideScalar( this.length() || 1 );
 
 
 		},
 		},
 
 
 		setLength: function ( length ) {
 		setLength: function ( length ) {
 
 
-			return this.multiplyScalar( length / this.length() );
+			return this.normalize().multiplyScalar( length );
 
 
 		},
 		},
 
 
@@ -2956,7 +2970,7 @@
 
 
 		clamp: function ( min, max ) {
 		clamp: function ( min, max ) {
 
 
-			// This function assumes min < max, if this assumption isn't true it will not operate correctly
+			// assumes min < max, componentwise
 
 
 			this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 			this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 			this.y = Math.max( min.y, Math.min( max.y, this.y ) );
 			this.y = Math.max( min.y, Math.min( max.y, this.y ) );
@@ -2986,7 +3000,7 @@
 
 
 			var length = this.length();
 			var length = this.length();
 
 
-			return this.multiplyScalar( Math.max( min, Math.min( max, length ) ) / length );
+			return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
 
 
 		},
 		},
 
 
@@ -3068,13 +3082,13 @@
 
 
 		normalize: function () {
 		normalize: function () {
 
 
-			return this.divideScalar( this.length() );
+			return this.divideScalar( this.length() || 1 );
 
 
 		},
 		},
 
 
 		setLength: function ( length ) {
 		setLength: function ( length ) {
 
 
-			return this.multiplyScalar( length / this.length() );
+			return this.normalize().multiplyScalar( length );
 
 
 		},
 		},
 
 

File diff suppressed because it is too large
+ 73 - 72
build/three.min.js


+ 27 - 13
build/three.module.js

@@ -732,7 +732,7 @@ Object.assign( Vector2.prototype, {
 
 
 	clamp: function ( min, max ) {
 	clamp: function ( min, max ) {
 
 
-		// This function assumes min < max, if this assumption isn't true it will not operate correctly
+		// assumes min < max, componentwise
 
 
 		this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 		this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 		this.y = Math.max( min.y, Math.min( max.y, this.y ) );
 		this.y = Math.max( min.y, Math.min( max.y, this.y ) );
@@ -761,7 +761,7 @@ Object.assign( Vector2.prototype, {
 
 
 		var length = this.length();
 		var length = this.length();
 
 
-		return this.multiplyScalar( Math.max( min, Math.min( max, length ) ) / length );
+		return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
 
 
 	},
 	},
 
 
@@ -836,7 +836,7 @@ Object.assign( Vector2.prototype, {
 
 
 	normalize: function () {
 	normalize: function () {
 
 
-		return this.divideScalar( this.length() );
+		return this.divideScalar( this.length() || 1 );
 
 
 	},
 	},
 
 
@@ -873,7 +873,7 @@ Object.assign( Vector2.prototype, {
 
 
 	setLength: function ( length ) {
 	setLength: function ( length ) {
 
 
-		return this.multiplyScalar( length / this.length() );
+		return this.normalize().multiplyScalar( length );
 
 
 	},
 	},
 
 
@@ -1664,7 +1664,7 @@ Object.assign( Vector4.prototype, {
 
 
 	clamp: function ( min, max ) {
 	clamp: function ( min, max ) {
 
 
-		// This function assumes min < max, if this assumption isn't true it will not operate correctly
+		// assumes min < max, componentwise
 
 
 		this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 		this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 		this.y = Math.max( min.y, Math.min( max.y, this.y ) );
 		this.y = Math.max( min.y, Math.min( max.y, this.y ) );
@@ -1677,11 +1677,17 @@ Object.assign( Vector4.prototype, {
 
 
 	clampScalar: function () {
 	clampScalar: function () {
 
 
-		var min = new Vector4();
-		var max = new Vector4();
+		var min, max;
 
 
 		return function clampScalar( minVal, maxVal ) {
 		return function clampScalar( minVal, maxVal ) {
 
 
+			if ( min === undefined ) {
+
+				min = new Vector4();
+				max = new Vector4();
+
+			}
+
 			min.set( minVal, minVal, minVal, minVal );
 			min.set( minVal, minVal, minVal, minVal );
 			max.set( maxVal, maxVal, maxVal, maxVal );
 			max.set( maxVal, maxVal, maxVal, maxVal );
 
 
@@ -1691,6 +1697,14 @@ Object.assign( Vector4.prototype, {
 
 
 	}(),
 	}(),
 
 
+	clampLength: function ( min, max ) {
+
+		var length = this.length();
+
+		return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
+
+	},
+
 	floor: function () {
 	floor: function () {
 
 
 		this.x = Math.floor( this.x );
 		this.x = Math.floor( this.x );
@@ -1772,13 +1786,13 @@ Object.assign( Vector4.prototype, {
 
 
 	normalize: function () {
 	normalize: function () {
 
 
-		return this.divideScalar( this.length() );
+		return this.divideScalar( this.length() || 1 );
 
 
 	},
 	},
 
 
 	setLength: function ( length ) {
 	setLength: function ( length ) {
 
 
-		return this.multiplyScalar( length / this.length() );
+		return this.normalize().multiplyScalar( length );
 
 
 	},
 	},
 
 
@@ -2950,7 +2964,7 @@ Object.assign( Vector3.prototype, {
 
 
 	clamp: function ( min, max ) {
 	clamp: function ( min, max ) {
 
 
-		// This function assumes min < max, if this assumption isn't true it will not operate correctly
+		// assumes min < max, componentwise
 
 
 		this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 		this.x = Math.max( min.x, Math.min( max.x, this.x ) );
 		this.y = Math.max( min.y, Math.min( max.y, this.y ) );
 		this.y = Math.max( min.y, Math.min( max.y, this.y ) );
@@ -2980,7 +2994,7 @@ Object.assign( Vector3.prototype, {
 
 
 		var length = this.length();
 		var length = this.length();
 
 
-		return this.multiplyScalar( Math.max( min, Math.min( max, length ) ) / length );
+		return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
 
 
 	},
 	},
 
 
@@ -3062,13 +3076,13 @@ Object.assign( Vector3.prototype, {
 
 
 	normalize: function () {
 	normalize: function () {
 
 
-		return this.divideScalar( this.length() );
+		return this.divideScalar( this.length() || 1 );
 
 
 	},
 	},
 
 
 	setLength: function ( length ) {
 	setLength: function ( length ) {
 
 
-		return this.multiplyScalar( length / this.length() );
+		return this.normalize().multiplyScalar( length );
 
 
 	},
 	},
 
 

Some files were not shown because too many files changed in this diff