@@ -33,39 +33,39 @@ import { Matrix4 } from '../../math/Matrix4.js';
3333 *
3434 **/
3535
36- function Curve ( ) {
36+ class Curve {
3737
38- this . type = 'Curve' ;
38+ constructor ( ) {
3939
40- this . arcLengthDivisions = 200 ;
40+ this . type = 'Curve' ;
4141
42- }
42+ this . arcLengthDivisions = 200 ;
4343
44- Object . assign ( Curve . prototype , {
44+ }
4545
4646 // Virtual base class method to overwrite and implement in subclasses
4747 // - t [0 .. 1]
4848
49- getPoint : function ( /* t, optionalTarget */ ) {
49+ getPoint ( /* t, optionalTarget */ ) {
5050
5151 console . warn ( 'THREE.Curve: .getPoint() not implemented.' ) ;
5252 return null ;
5353
54- } ,
54+ }
5555
5656 // Get point at relative position in curve according to arc length
5757 // - u [0 .. 1]
5858
59- getPointAt : function ( u , optionalTarget ) {
59+ getPointAt ( u , optionalTarget ) {
6060
6161 const t = this . getUtoTmapping ( u ) ;
6262 return this . getPoint ( t , optionalTarget ) ;
6363
64- } ,
64+ }
6565
6666 // Get sequence of points using getPoint( t )
6767
68- getPoints : function ( divisions = 5 ) {
68+ getPoints ( divisions = 5 ) {
6969
7070 const points = [ ] ;
7171
@@ -77,11 +77,11 @@ Object.assign( Curve.prototype, {
7777
7878 return points ;
7979
80- } ,
80+ }
8181
8282 // Get sequence of points using getPointAt( u )
8383
84- getSpacedPoints : function ( divisions = 5 ) {
84+ getSpacedPoints ( divisions = 5 ) {
8585
8686 const points = [ ] ;
8787
@@ -93,20 +93,20 @@ Object.assign( Curve.prototype, {
9393
9494 return points ;
9595
96- } ,
96+ }
9797
9898 // Get total curve arc length
9999
100- getLength : function ( ) {
100+ getLength ( ) {
101101
102102 const lengths = this . getLengths ( ) ;
103103 return lengths [ lengths . length - 1 ] ;
104104
105- } ,
105+ }
106106
107107 // Get list of cumulative segment lengths
108108
109- getLengths : function ( divisions ) {
109+ getLengths ( divisions ) {
110110
111111 if ( divisions === undefined ) divisions = this . arcLengthDivisions ;
112112
@@ -139,18 +139,18 @@ Object.assign( Curve.prototype, {
139139
140140 return cache ; // { sums: cache, sum: sum }; Sum is in the last element.
141141
142- } ,
142+ }
143143
144- updateArcLengths : function ( ) {
144+ updateArcLengths ( ) {
145145
146146 this . needsUpdate = true ;
147147 this . getLengths ( ) ;
148148
149- } ,
149+ }
150150
151151 // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
152152
153- getUtoTmapping : function ( u , distance ) {
153+ getUtoTmapping ( u , distance ) {
154154
155155 const arcLengths = this . getLengths ( ) ;
156156
@@ -223,14 +223,14 @@ Object.assign( Curve.prototype, {
223223
224224 return t ;
225225
226- } ,
226+ }
227227
228228 // Returns a unit vector tangent at t
229229 // In case any sub curve does not implement its tangent derivation,
230230 // 2 points a small delta apart will be used to find its gradient
231231 // which seems to give a reasonable approximation
232232
233- getTangent : function ( t , optionalTarget ) {
233+ getTangent ( t , optionalTarget ) {
234234
235235 const delta = 0.0001 ;
236236 let t1 = t - delta ;
@@ -250,16 +250,16 @@ Object.assign( Curve.prototype, {
250250
251251 return tangent ;
252252
253- } ,
253+ }
254254
255- getTangentAt : function ( u , optionalTarget ) {
255+ getTangentAt ( u , optionalTarget ) {
256256
257257 const t = this . getUtoTmapping ( u ) ;
258258 return this . getTangent ( t , optionalTarget ) ;
259259
260- } ,
260+ }
261261
262- computeFrenetFrames : function ( segments , closed ) {
262+ computeFrenetFrames ( segments , closed ) {
263263
264264 // see http://www.cs.indiana.edu/pub/techreports/TR425.pdf
265265
@@ -372,23 +372,23 @@ Object.assign( Curve.prototype, {
372372 binormals : binormals
373373 } ;
374374
375- } ,
375+ }
376376
377- clone : function ( ) {
377+ clone ( ) {
378378
379379 return new this . constructor ( ) . copy ( this ) ;
380380
381- } ,
381+ }
382382
383- copy : function ( source ) {
383+ copy ( source ) {
384384
385385 this . arcLengthDivisions = source . arcLengthDivisions ;
386386
387387 return this ;
388388
389- } ,
389+ }
390390
391- toJSON : function ( ) {
391+ toJSON ( ) {
392392
393393 const data = {
394394 metadata : {
@@ -403,17 +403,17 @@ Object.assign( Curve.prototype, {
403403
404404 return data ;
405405
406- } ,
406+ }
407407
408- fromJSON : function ( json ) {
408+ fromJSON ( json ) {
409409
410410 this . arcLengthDivisions = json . arcLengthDivisions ;
411411
412412 return this ;
413413
414414 }
415415
416- } ) ;
416+ }
417417
418418
419419export { Curve } ;
0 commit comments