Skip to content

Commit 330b186

Browse files
committed
Curves: Clean up.
1 parent a36141f commit 330b186

File tree

8 files changed

+44
-12
lines changed

8 files changed

+44
-12
lines changed

src/extras/curves/CatmullRomCurve3.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ class CatmullRomCurve3 extends Curve {
181181
return point;
182182

183183
}
184+
184185
copy( source ) {
185186

186187
super.copy( source );
@@ -202,6 +203,7 @@ class CatmullRomCurve3 extends Curve {
202203
return this;
203204

204205
}
206+
205207
toJSON() {
206208

207209
const data = super.toJSON();
@@ -222,6 +224,7 @@ class CatmullRomCurve3 extends Curve {
222224
return data;
223225

224226
}
227+
225228
fromJSON( json ) {
226229

227230
super.fromJSON( json );

src/extras/curves/CubicBezierCurve.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class CubicBezierCurve extends Curve {
3232
return point;
3333

3434
}
35+
3536
copy( source ) {
3637

3738
super.copy( source );
@@ -44,6 +45,7 @@ class CubicBezierCurve extends Curve {
4445
return this;
4546

4647
}
48+
4749
toJSON() {
4850

4951
const data = super.toJSON();
@@ -56,6 +58,7 @@ class CubicBezierCurve extends Curve {
5658
return data;
5759

5860
}
61+
5962
fromJSON( json ) {
6063

6164
super.fromJSON( json );

src/extras/curves/CubicBezierCurve3.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CubicBezierCurve3 extends Curve {
1717
this.v3 = v3;
1818

1919
}
20+
2021
getPoint( t, optionalTarget = new Vector3() ) {
2122

2223
const point = optionalTarget;
@@ -32,6 +33,7 @@ class CubicBezierCurve3 extends Curve {
3233
return point;
3334

3435
}
36+
3537
copy( source ) {
3638

3739
super.copy( source );
@@ -44,6 +46,7 @@ class CubicBezierCurve3 extends Curve {
4446
return this;
4547

4648
}
49+
4750
toJSON() {
4851

4952
const data = super.toJSON();
@@ -56,6 +59,7 @@ class CubicBezierCurve3 extends Curve {
5659
return data;
5760

5861
}
62+
5963
fromJSON( json ) {
6064

6165
super.fromJSON( json );

src/extras/curves/EllipseCurve.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@ import { Vector2 } from '../../math/Vector2.js';
33

44
class EllipseCurve extends Curve {
55

6-
constructor( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
6+
constructor( aX = 0, aY = 0, xRadius = 1, yRadius = 1, aStartAngle = 0, aEndAngle = Math.PI * 2, aClockwise = false, aRotation = 0 ) {
77

88
super();
99

1010
this.type = 'EllipseCurve';
1111
this.isEllipseCurve = true;
1212

13-
this.aX = aX || 0;
14-
this.aY = aY || 0;
13+
this.aX = aX;
14+
this.aY = aY;
1515

16-
this.xRadius = xRadius || 1;
17-
this.yRadius = yRadius || 1;
16+
this.xRadius = xRadius;
17+
this.yRadius = yRadius;
1818

19-
this.aStartAngle = aStartAngle || 0;
20-
this.aEndAngle = aEndAngle || 2 * Math.PI;
19+
this.aStartAngle = aStartAngle;
20+
this.aEndAngle = aEndAngle;
2121

22-
this.aClockwise = aClockwise || false;
22+
this.aClockwise = aClockwise;
2323

24-
this.aRotation = aRotation || 0;
24+
this.aRotation = aRotation;
2525

2626
}
27+
2728
getPoint( t, optionalTarget ) {
2829

2930
const point = optionalTarget || new Vector2();
@@ -85,6 +86,7 @@ class EllipseCurve extends Curve {
8586
return point.set( x, y );
8687

8788
}
89+
8890
copy( source ) {
8991

9092
super.copy( source );
@@ -105,6 +107,7 @@ class EllipseCurve extends Curve {
105107
return this;
106108

107109
}
110+
108111
toJSON() {
109112

110113
const data = super.toJSON();
@@ -125,6 +128,7 @@ class EllipseCurve extends Curve {
125128
return data;
126129

127130
}
131+
128132
fromJSON( json ) {
129133

130134
super.fromJSON( json );

src/extras/curves/LineCurve.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class LineCurve extends Curve {
1414
this.v2 = v2;
1515

1616
}
17+
1718
getPoint( t, optionalTarget = new Vector2() ) {
1819

1920
const point = optionalTarget;
@@ -32,12 +33,14 @@ class LineCurve extends Curve {
3233
return point;
3334

3435
}
36+
3537
// Line curve is linear, so we can overwrite default getPointAt
3638
getPointAt( u, optionalTarget ) {
3739

3840
return this.getPoint( u, optionalTarget );
3941

4042
}
43+
4144
getTangent( t, optionalTarget ) {
4245

4346
const tangent = optionalTarget || new Vector2();
@@ -47,6 +50,7 @@ class LineCurve extends Curve {
4750
return tangent;
4851

4952
}
53+
5054
copy( source ) {
5155

5256
super.copy( source );
@@ -57,6 +61,7 @@ class LineCurve extends Curve {
5761
return this;
5862

5963
}
64+
6065
toJSON() {
6166

6267
const data = super.toJSON();
@@ -67,6 +72,7 @@ class LineCurve extends Curve {
6772
return data;
6873

6974
}
75+
7076
fromJSON( json ) {
7177

7278
super.fromJSON( json );

src/extras/curves/QuadraticBezierCurve.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class QuadraticBezierCurve extends Curve {
1616
this.v2 = v2;
1717

1818
}
19+
1920
getPoint( t, optionalTarget = new Vector2() ) {
2021

2122
const point = optionalTarget;
@@ -30,6 +31,7 @@ class QuadraticBezierCurve extends Curve {
3031
return point;
3132

3233
}
34+
3335
copy( source ) {
3436

3537
super.copy( source );
@@ -41,6 +43,7 @@ class QuadraticBezierCurve extends Curve {
4143
return this;
4244

4345
}
46+
4447
toJSON() {
4548

4649
const data = super.toJSON();
@@ -52,6 +55,7 @@ class QuadraticBezierCurve extends Curve {
5255
return data;
5356

5457
}
58+
5559
fromJSON( json ) {
5660

5761
super.fromJSON( json );

src/extras/curves/QuadraticBezierCurve3.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class QuadraticBezierCurve3 extends Curve {
1616
this.v2 = v2;
1717

1818
}
19+
1920
getPoint( t, optionalTarget = new Vector3() ) {
2021

2122
const point = optionalTarget;
@@ -31,6 +32,7 @@ class QuadraticBezierCurve3 extends Curve {
3132
return point;
3233

3334
}
35+
3436
copy( source ) {
3537

3638
super.copy( source );
@@ -42,6 +44,7 @@ class QuadraticBezierCurve3 extends Curve {
4244
return this;
4345

4446
}
47+
4548
toJSON() {
4649

4750
const data = super.toJSON();
@@ -53,6 +56,7 @@ class QuadraticBezierCurve3 extends Curve {
5356
return data;
5457

5558
}
59+
5660
fromJSON( json ) {
5761

5862
super.fromJSON( json );

src/extras/curves/SplineCurve.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class SplineCurve extends Curve {
1414
this.points = points;
1515

1616
}
17+
1718
getPoint( t, optionalTarget = new Vector2() ) {
1819

1920
const point = optionalTarget;
@@ -37,9 +38,10 @@ class SplineCurve extends Curve {
3738
return point;
3839

3940
}
41+
4042
copy( source ) {
4143

42-
Curve.prototype.copy.call( this, source );
44+
super.copy( source );
4345

4446
this.points = [];
4547

@@ -54,9 +56,10 @@ class SplineCurve extends Curve {
5456
return this;
5557

5658
}
59+
5760
toJSON() {
5861

59-
const data = Curve.prototype.toJSON.call( this );
62+
const data = super.toJSON();
6063

6164
data.points = [];
6265

@@ -70,9 +73,10 @@ class SplineCurve extends Curve {
7073
return data;
7174

7275
}
76+
7377
fromJSON( json ) {
7478

75-
Curve.prototype.fromJSON.call( this, json );
79+
super.fromJSON( json );
7680

7781
this.points = [];
7882

0 commit comments

Comments
 (0)