فهرست منبع

Added rotateAround method to Vector2

rotates the Vector2 with another 2D coordinate (e.g. another Vector2) as
the center.
aarman 10 سال پیش
والد
کامیت
1ab154bb8d
1فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 11 0
      src/math/Vector2.js

+ 11 - 0
src/math/Vector2.js

@@ -449,6 +449,17 @@ THREE.Vector2.prototype = {
 
 		return this;
 
+	},
+
+	rotateAround: function ( center, rotation ) {
+
+		var x = this.x - center.x,	y = this.y - center.y;
+
+		this.x = center.x + x * Math.cos(rotation) - y * Math.sin(rotation);
+		this.y = center.y + y * Math.cos(rotation) + x * Math.sin(rotation);
+
+		return this;
+
 	}
 
 };