Browse Source

Fix ellipses #3833

- aClockwise goes anti-clockwise
- The end point is now correct and no longer breaks path continuity
Emery 12 years ago
parent
commit
4d4bdcb77e
2 changed files with 10 additions and 9 deletions
  1. 1 1
      src/extras/core/Path.js
  2. 9 8
      src/extras/curves/EllipseCurve.js

+ 1 - 1
src/extras/core/Path.js

@@ -170,7 +170,7 @@ THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius,
 									aStartAngle, aEndAngle, aClockwise );
 									aStartAngle, aEndAngle, aClockwise );
 	this.curves.push( curve );
 	this.curves.push( curve );
 
 
-	var lastPoint = curve.getPoint(aClockwise ? 1 : 0);
+	var lastPoint = curve.getPoint(1);
 	args.push(lastPoint.x);
 	args.push(lastPoint.x);
 	args.push(lastPoint.y);
 	args.push(lastPoint.y);
 
 

+ 9 - 8
src/extras/curves/EllipseCurve.js

@@ -23,19 +23,20 @@ THREE.EllipseCurve.prototype = Object.create( THREE.Curve.prototype );
 
 
 THREE.EllipseCurve.prototype.getPoint = function ( t ) {
 THREE.EllipseCurve.prototype.getPoint = function ( t ) {
 
 
-	var deltaAngle = this.aEndAngle - this.aStartAngle;
-
-	if ( !this.aClockwise ) {
-
-		t = 1 - t;
+  var deltaAngle = this.aEndAngle - this.aStartAngle;
 
 
+	if ( this.aClockwise ) {
+    t = 1 - t;
+    deltaAngle = Math.PI*2 - deltaAngle;
+    var angle = this.aEndAngle + t * deltaAngle;
 	}
 	}
-
-	var angle = this.aStartAngle + t * deltaAngle;
+  else {
+    var angle = this.aStartAngle + t * deltaAngle;
+  }
 
 
 	var tx = this.aX + this.xRadius * Math.cos( angle );
 	var tx = this.aX + this.xRadius * Math.cos( angle );
 	var ty = this.aY + this.yRadius * Math.sin( angle );
 	var ty = this.aY + this.yRadius * Math.sin( angle );
 
 
 	return new THREE.Vector2( tx, ty );
 	return new THREE.Vector2( tx, ty );
+};
 
 
-};