@@ -5,6 +5,7 @@ var CubicBezierCurve = require('./curves/cubicbezier/CubicBezierCurve');
55var EllipseCurve = require ( './curves/ellipse/EllipseCurve' ) ;
66var GameObjectFactory = require ( '../scene/plugins/GameObjectFactory' ) ;
77var LineCurve = require ( './curves/line/LineCurve' ) ;
8+ var MoveTo = require ( './MoveTo' ) ;
89var SplineCurve = require ( './curves/spline/SplineCurve' ) ;
910var Vector2 = require ( '../math/Vector2' ) ;
1011
@@ -31,6 +32,11 @@ var Path = new Class({
3132 this . startPoint = new Vector2 ( x , y ) ;
3233 } ,
3334
35+ moveTo : function ( x , y )
36+ {
37+ this . add ( new MoveTo ( x , y ) ) ;
38+ } ,
39+
3440 // Creates a line curve from the previous end point to x/y
3541 lineTo : function ( x , y )
3642 {
@@ -99,6 +105,13 @@ var Path = new Class({
99105 return this . add ( ellipse ) ;
100106 } ,
101107
108+ circleTo : function ( radius , clockwise , rotation )
109+ {
110+ if ( clockwise === undefined ) { clockwise = false ; }
111+
112+ return this . ellipseTo ( radius , radius , 0 , 360 , clockwise , rotation ) ;
113+ } ,
114+
102115 toJSON : function ( )
103116 {
104117 var out = [ ] ;
@@ -179,8 +192,6 @@ var Path = new Class({
179192 var curveLengths = this . getCurveLengths ( ) ;
180193 var i = 0 ;
181194
182- // To think about boundaries points.
183-
184195 while ( i < curveLengths . length )
185196 {
186197 if ( curveLengths [ i ] >= d )
@@ -201,10 +212,6 @@ var Path = new Class({
201212 return null ;
202213 } ,
203214
204- // We cannot use the default THREE.Curve getPoint() with getLength() because in
205- // THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath
206- // getPoint() depends on getLength
207-
208215 getLength : function ( )
209216 {
210217 var lens = this . getCurveLengths ( ) ;
@@ -215,15 +222,11 @@ var Path = new Class({
215222 // cacheLengths must be recalculated.
216223 updateArcLengths : function ( )
217224 {
218- this . needsUpdate = true ;
219- this . cacheLengths = null ;
225+ this . cacheLengths = [ ] ;
220226
221227 this . getCurveLengths ( ) ;
222228 } ,
223229
224- // Compute lengths and cache them
225- // We cannot overwrite getLengths() because UtoT mapping uses it.
226-
227230 getCurveLengths : function ( )
228231 {
229232 // We use cache values if curves and cache array are same length
@@ -281,6 +284,11 @@ var Path = new Class({
281284 {
282285 var curve = this . curves [ i ] ;
283286
287+ if ( ! curve . active )
288+ {
289+ continue ;
290+ }
291+
284292 var resolution = curve . getResolution ( divisions ) ;
285293
286294 var pts = curve . getPoints ( resolution ) ;
@@ -313,7 +321,14 @@ var Path = new Class({
313321 {
314322 for ( var i = 0 ; i < this . curves . length ; i ++ )
315323 {
316- this . curves [ i ] . draw ( graphics , pointsTotal ) ;
324+ var curve = this . curves [ i ] ;
325+
326+ if ( ! curve . active )
327+ {
328+ continue ;
329+ }
330+
331+ curve . draw ( graphics , pointsTotal ) ;
317332 }
318333
319334 return graphics ;
0 commit comments