Skip to content

Commit 1439144

Browse files
committed
Added missing Curve constructor calls (opps!) and fixed tmpVec assignment in getLengths
1 parent bbfb8e4 commit 1439144

4 files changed

Lines changed: 20 additions & 7 deletions

File tree

v3/src/paths/curves/Curve.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ var Curve = new Class({
2020
function Curve ()
2121
{
2222
this.arcLengthDivisions = 200;
23+
24+
this.cacheArcLengths = [];
25+
26+
this.needsUpdate = true;
2327
},
2428

2529
// Get point at relative position in curve according to arc length
@@ -58,7 +62,9 @@ var Curve = new Class({
5862

5963
for (var d = 0; d <= divisions; d++)
6064
{
61-
points.push(this.getPointAt(d / divisions));
65+
var t = this.getUtoTmapping(d / divisions, null, divisions);
66+
67+
points.push(this.getPoint(t));
6268
}
6369

6470
return points;
@@ -79,9 +85,7 @@ var Curve = new Class({
7985
{
8086
if (divisions === undefined) { divisions = this.arcLengthDivisions; }
8187

82-
if (this.cacheArcLengths &&
83-
(this.cacheArcLengths.length === divisions + 1) &&
84-
!this.needsUpdate)
88+
if ((this.cacheArcLengths.length === divisions + 1) && !this.needsUpdate)
8589
{
8690
return this.cacheArcLengths;
8791
}
@@ -98,9 +102,12 @@ var Curve = new Class({
98102
for (var p = 1; p <= divisions; p++)
99103
{
100104
current = this.getPoint(p / divisions, tmpVec2B);
105+
101106
sum += current.distance(last);
107+
102108
cache.push(sum);
103-
last = current;
109+
110+
last.copy(current);
104111
}
105112

106113
this.cacheArcLengths = cache;
@@ -117,9 +124,9 @@ var Curve = new Class({
117124

118125
// Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
119126

120-
getUtoTmapping: function (u, distance)
127+
getUtoTmapping: function (u, distance, divisions)
121128
{
122-
var arcLengths = this.getLengths();
129+
var arcLengths = this.getLengths(divisions);
123130

124131
var i = 0;
125132
var il = arcLengths.length;

v3/src/paths/curves/cubicbezier/CubicBezierCurve.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var CubicBezierCurve = new Class({
1515

1616
function CubicBezierCurve (v0, v1, v2, v3)
1717
{
18+
Curve.call(this);
19+
1820
this.v0 = v0;
1921
this.v1 = v1;
2022
this.v2 = v2;

v3/src/paths/curves/ellipse/EllipseCurve.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ var EllipseCurve = new Class({
1313

1414
function EllipseCurve (aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation)
1515
{
16+
Curve.call(this);
17+
1618
this.aX = aX;
1719
this.aY = aY;
1820

v3/src/paths/curves/line/LineCurve.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ var LineCurve = new Class({
1717
// vec2s
1818
function LineCurve (v1, v2)
1919
{
20+
Curve.call(this);
21+
2022
this.v1 = v1;
2123
this.v2 = v2;
2224
},

0 commit comments

Comments
 (0)