Skip to content

Commit 47ef34e

Browse files
author
neko
committed
Fix broken ellipses
1 parent 8fb7813 commit 47ef34e

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/extras/core/Path.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ THREE.Path.prototype.ellipse = function ( aX, aY, xRadius, yRadius,
168168
THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius,
169169
aStartAngle, aEndAngle, aClockwise, aRotation ) {
170170

171-
var args = Array.prototype.slice.call( arguments );
171+
var args = [
172+
aX, aY,
173+
xRadius, yRadius,
174+
aStartAngle, aEndAngle,
175+
aClockwise,
176+
aRotation || 0 // aRotation is optional.
177+
];
172178
var curve = new THREE.EllipseCurve( aX, aY, xRadius, yRadius,
173179
aStartAngle, aEndAngle, aClockwise, aRotation );
174180
this.curves.push( curve );
@@ -387,7 +393,7 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
387393
yRadius = args[ 3 ],
388394
aStartAngle = args[ 4 ], aEndAngle = args[ 5 ],
389395
aClockwise = !! args[ 6 ],
390-
aRotation = args[ 7 ] || 0;
396+
aRotation = args[ 7 ];
391397

392398

393399
var deltaAngle = aEndAngle - aStartAngle;
@@ -419,9 +425,11 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
419425

420426
if ( aRotation !== 0 ) {
421427

428+
var x = tx, y = ty;
429+
422430
// Rotate the point about the center of the ellipse.
423-
tx = ( tx - aX ) * cos - ( ty - aY ) * sin + aX;
424-
ty = ( tx - aX ) * sin + ( ty - aY ) * cos + aY;
431+
tx = ( x - aX ) * cos - ( y - aY ) * sin + aX;
432+
ty = ( x - aX ) * sin + ( y - aY ) * cos + aY;
425433

426434
}
427435

src/extras/curves/EllipseCurve.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ THREE.EllipseCurve.prototype.getPoint = function ( t ) {
4949
var cos = Math.cos( this.aRotation );
5050
var sin = Math.sin( this.aRotation );
5151

52+
var tx = x, ty = y;
53+
5254
// Rotate the point about the center of the ellipse.
53-
x = ( x - this.aX ) * cos - ( y - this.aY ) * sin + this.aX;
54-
y = ( x - this.aX ) * sin + ( y - this.aY ) * cos + this.aY;
55+
x = ( tx - this.aX ) * cos - ( ty - this.aY ) * sin + this.aX;
56+
y = ( tx - this.aX ) * sin + ( ty - this.aY ) * cos + this.aY;
5557

5658
}
5759

0 commit comments

Comments
 (0)