Explorar el Código

Added rotateAround method to Vector2

rotates the Vector2 with another 2D coordinate (e.g. another Vector2) as
the center.
aarman hace 10 años
padre
commit
1ab154bb8d
Se han modificado 1 ficheros con 11 adiciones y 0 borrados
  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;
+
 	}
 
 };