|
@@ -1,5 +1,5 @@
|
|
|
import { Curve } from './Curve.js';
|
|
|
-import { LineCurve } from '../curves/LineCurve.js';
|
|
|
+import * as Curves from '../curves/Curves.js';
|
|
|
|
|
|
/**
|
|
|
* @author zz85 / http://www.lab4games.net/zz85/blog
|
|
@@ -40,7 +40,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
|
|
|
|
|
|
if ( ! startPoint.equals( endPoint ) ) {
|
|
|
|
|
|
- this.curves.push( new LineCurve( endPoint, startPoint ) );
|
|
|
+ this.curves.push( new Curves[ 'LineCurve' ]( endPoint, startPoint ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -217,6 +217,41 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
+ },
|
|
|
+
|
|
|
+ toJSON: function () {
|
|
|
+
|
|
|
+ var data = Curve.prototype.toJSON.call( this );
|
|
|
+
|
|
|
+ data.autoClose = this.autoClose;
|
|
|
+ data.curves = [];
|
|
|
+
|
|
|
+ for ( var i = 0, l = this.curves.length; i < l; i ++ ) {
|
|
|
+
|
|
|
+ var curve = this.curves[ i ];
|
|
|
+ data.curves.push( curve.toJSON() );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return data;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ fromJSON: function ( json ) {
|
|
|
+
|
|
|
+ Curve.prototype.fromJSON.call( this, json );
|
|
|
+
|
|
|
+ this.autoClose = json.autoClose;
|
|
|
+
|
|
|
+ for ( var i = 0, l = json.curves.length; i < l; i ++ ) {
|
|
|
+
|
|
|
+ var curve = json.curves[ i ];
|
|
|
+ this.curves.push( new Curves[ curve.type ]().fromJSON( curve ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return this;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
} );
|