Browse Source

Merge pull request #5915 from WestLangley/dev-lerp

Added Vector*.lerpVectors()
Mr.doob 10 years ago
parent
commit
6261a4f38f

+ 10 - 0
docs/api/math/Vector2.html

@@ -181,6 +181,16 @@
 		Linear interpolation between this vector and v, where alpha is the percent along the line.
 		Linear interpolation between this vector and v, where alpha is the percent along the line.
 		</div>
 		</div>
 
 
+		<h3>[method:Vector2 lerpVectors]([page:Vector2 v1], [page:Vector2 v2], [page:Float alpha]) [page:Vector2 this]</h3>
+		<div>
+		v1 -- [page:Vector2] <br />
+		v2 -- [page:Vector2] <br />
+		alpha -- [page:Float] between 0 and 1.
+		</div>
+		<div>
+		Sets this vector to be the vector linearly interpolated between *v1* and *v2* with *alpha* factor.
+		</div>
+
 		<h3>[method:undefined setComponent]([page:Integer index], [page:Float value])</h3>
 		<h3>[method:undefined setComponent]([page:Integer index], [page:Float value])</h3>
 		<div>
 		<div>
 		index -- 0 or 1 <br />
 		index -- 0 or 1 <br />

+ 10 - 0
docs/api/math/Vector3.html

@@ -342,6 +342,16 @@
 		Linear Interpolation between this vector and vector v, where alpha is the percent along the line.
 		Linear Interpolation between this vector and vector v, where alpha is the percent along the line.
 		</div>
 		</div>
 
 
+		<h3>[method:Vector3 lerpVectors]([page:Vector3 v1], [page:Vector3 v2], [page:Float alpha]) [page:Vector3 this]</h3>
+		<div>
+		v1 -- [page:Vector3] <br />
+		v2 -- [page:Vector3] <br />
+		alpha -- [page:Float] between 0 and 1.
+		</div>
+		<div>
+		Sets this vector to be the vector linearly interpolated between *v1* and *v2* with *alpha* factor.
+		</div>
+
 		<h3>[method:Float angleTo]([page:Vector3 v])</h3>
 		<h3>[method:Float angleTo]([page:Vector3 v])</h3>
 		<div>
 		<div>
 		v -- [page:Vector3]
 		v -- [page:Vector3]

+ 5 - 0
docs/api/math/Vector4.html

@@ -113,6 +113,11 @@
 		Linearly interpolate between this vector and *v* with *alpha* factor.
 		Linearly interpolate between this vector and *v* with *alpha* factor.
 		</div>
 		</div>
 
 
+		<h3>[method:Vector4 lerpVectors]( [page:Vector4 v1], [page:Vector4 v2], [page:Float alpha] ) [page:Vector4 this]</h3>
+		<div>
+		Sets this vector to be the vector linearly interpolated between *v1* and *v2* with *alpha* factor.
+		</div>
+
 		<h3>[method:Vector4 clone]()</h3>
 		<h3>[method:Vector4 clone]()</h3>
 		<div>
 		<div>
 		Clones this vector.
 		Clones this vector.

+ 8 - 0
src/math/Vector2.js

@@ -369,6 +369,14 @@ THREE.Vector2.prototype = {
 
 
 	},
 	},
 
 
+	lerpVectors: function ( v1, v2, alpha ) {
+
+	    this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+
+	    return this;
+
+	},
+
 	equals: function ( v ) {
 	equals: function ( v ) {
 
 
 		return ( ( v.x === this.x ) && ( v.y === this.y ) );
 		return ( ( v.x === this.x ) && ( v.y === this.y ) );

+ 8 - 0
src/math/Vector3.js

@@ -597,6 +597,14 @@ THREE.Vector3.prototype = {
 
 
 	},
 	},
 
 
+	lerpVectors: function ( v1, v2, alpha ) {
+
+	    this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+
+	    return this;
+
+	},
+
 	cross: function ( v, w ) {
 	cross: function ( v, w ) {
 
 
 		if ( w !== undefined ) {
 		if ( w !== undefined ) {

+ 8 - 0
src/math/Vector4.js

@@ -615,6 +615,14 @@ THREE.Vector4.prototype = {
 
 
 	},
 	},
 
 
+	lerpVectors: function ( v1, v2, alpha ) {
+
+	    this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+
+	    return this;
+
+	},
+
 	equals: function ( v ) {
 	equals: function ( v ) {
 
 
 		return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );
 		return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );