فهرست منبع

Fix lerpVectors for when v1 === this

Pim Schreurs 5 سال پیش
والد
کامیت
2badf8fc4a
3فایلهای تغییر یافته به همراه15 افزوده شده و 3 حذف شده
  1. 4 1
      src/math/Vector2.js
  2. 5 1
      src/math/Vector3.js
  3. 6 1
      src/math/Vector4.js

+ 4 - 1
src/math/Vector2.js

@@ -422,7 +422,10 @@ Object.assign( Vector2.prototype, {
 
 	lerpVectors: function ( v1, v2, alpha ) {
 
-		return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+		this.x = v1.x + ( v2.x - v1.x ) * alpha;
+		this.y = v1.y + ( v2.y - v1.y ) * alpha;
+
+		return this;
 
 	},
 

+ 5 - 1
src/math/Vector3.js

@@ -502,7 +502,11 @@ Object.assign( Vector3.prototype, {
 
 	lerpVectors: function ( v1, v2, alpha ) {
 
-		return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+		this.x = v1.x + ( v2.x - v1.x ) * alpha;
+		this.y = v1.y + ( v2.y - v1.y ) * alpha;
+		this.z = v1.z + ( v2.z - v1.z ) * alpha;
+
+		return this;
 
 	},
 

+ 6 - 1
src/math/Vector4.js

@@ -594,7 +594,12 @@ Object.assign( Vector4.prototype, {
 
 	lerpVectors: function ( v1, v2, alpha ) {
 
-		return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+		this.x = v1.x + ( v2.x - v1.x ) * alpha;
+		this.y = v1.y + ( v2.y - v1.y ) * alpha;
+		this.z = v1.z + ( v2.z - v1.z ) * alpha;
+		this.w = v1.w + ( v2.w - v1.w ) * alpha;
+
+		return this;
 
 	},