Bläddra i källkod

Merge pull request #6989 from neko1235/fix-ellipse-rotation

Fixing issues introduced in pull request #6953
Mr.doob 10 år sedan
förälder
incheckning
f8a1eec16b
2 ändrade filer med 16 tillägg och 6 borttagningar
  1. 12 4
      src/extras/core/Path.js
  2. 4 2
      src/extras/curves/EllipseCurve.js

+ 12 - 4
src/extras/core/Path.js

@@ -168,7 +168,13 @@ THREE.Path.prototype.ellipse = function ( aX, aY, xRadius, yRadius,
 THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius,
 									  aStartAngle, aEndAngle, aClockwise, aRotation ) {
 
-	var args = Array.prototype.slice.call( arguments );
+	var args = [
+		aX, aY,
+		xRadius, yRadius,
+		aStartAngle, aEndAngle,
+		aClockwise,
+		aRotation || 0 // aRotation is optional.
+	];
 	var curve = new THREE.EllipseCurve( aX, aY, xRadius, yRadius,
 									aStartAngle, aEndAngle, aClockwise, aRotation );
 	this.curves.push( curve );
@@ -387,7 +393,7 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 				yRadius = args[ 3 ],
 				aStartAngle = args[ 4 ], aEndAngle = args[ 5 ],
 				aClockwise = !! args[ 6 ],
-				aRotation = args[ 7 ] || 0;
+				aRotation = args[ 7 ];
 
 
 			var deltaAngle = aEndAngle - aStartAngle;
@@ -419,9 +425,11 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 
 				if ( aRotation !== 0 ) {
 
+					var x = tx, y = ty;
+
 					// Rotate the point about the center of the ellipse.
-					tx = ( tx - aX ) * cos - ( ty - aY ) * sin + aX;
-					ty = ( tx - aX ) * sin + ( ty - aY ) * cos + aY;
+					tx = ( x - aX ) * cos - ( y - aY ) * sin + aX;
+					ty = ( x - aX ) * sin + ( y - aY ) * cos + aY;
 
 				}
 

+ 4 - 2
src/extras/curves/EllipseCurve.js

@@ -49,9 +49,11 @@ THREE.EllipseCurve.prototype.getPoint = function ( t ) {
 		var cos = Math.cos( this.aRotation );
 		var sin = Math.sin( this.aRotation );
 
+		var tx = x, ty = y;
+
 		// Rotate the point about the center of the ellipse.
-		x = ( x - this.aX ) * cos - ( y - this.aY ) * sin + this.aX;
-		y = ( x - this.aX ) * sin + ( y - this.aY ) * cos + this.aY;
+		x = ( tx - this.aX ) * cos - ( ty - this.aY ) * sin + this.aX;
+		y = ( tx - this.aX ) * sin + ( ty - this.aY ) * cos + this.aY;
 
 	}