aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/line.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/line.js')
-rwxr-xr-xjs/lib/geom/line.js53
1 files changed, 50 insertions, 3 deletions
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js
index da63b21c..aa27fa87 100755
--- a/js/lib/geom/line.js
+++ b/js/lib/geom/line.js
@@ -99,9 +99,56 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
99 99
100 this.geomType = function() { return this.GEOM_TYPE_LINE; } 100 this.geomType = function() { return this.GEOM_TYPE_LINE; }
101 101
102 /////////////////////////////////////////////////////////////////////// 102 ///////////////////////////////////////////////////////////////////////
103 // Methods 103 // Methods
104 /////////////////////////////////////////////////////////////////////// 104 ///////////////////////////////////////////////////////////////////////
105 this.exportJSON = function()
106 {
107 var jObj =
108 {
109 'type' : this.geomType(),
110 'xoff' : this._xOffset,
111 'yoff' : this._yOffset,
112 'width' : this._width,
113 'height' : this._height,
114 'xAdj' : this._xAdj,
115 'yAdj' : this._yAdj,
116 'slope' : this._slope,
117 'strokeWidth' : this._strokeWidth,
118 'strokeColor' : this._strokeColor,
119 'strokeStyle' : this._strokeStyle,
120 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(),
121 'materials' : this.exportMaterialsJSON()
122 };
123
124 return jObj;
125 };
126
127 this.importJSON = function( jObj )
128 {
129 this._xOffset = jObj.xoff;
130 this._yOffset = jObj.yoff;
131 this._width = jObj.width;
132 this._height = jObj.height;
133 this._xAdj = jObj.xAdj;
134 this._yAdj = jObj.yAdj;
135 this._strokeWidth = jObj.strokeWidth;
136 this._slope = jObj.slope;
137 this._strokeStyle = jObj.strokeStyle;
138 this._strokeColor = jObj.strokeColor;
139 var strokeMaterialName = jObj.strokeMat;
140
141 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
142 if (!strokeMat) {
143 console.log( "object material not found in library: " + strokeMaterialName );
144 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
145 }
146 else
147 strokeMat = strokeMat.dup();
148 this._strokeMaterial = strokeMat;
149
150 };
151
105 this.export = function() { 152 this.export = function() {
106 var rtnStr = "type: " + this.geomType() + "\n"; 153 var rtnStr = "type: " + this.geomType() + "\n";
107 154
@@ -120,7 +167,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
120 if (this._strokeMaterial) { 167 if (this._strokeMaterial) {
121 rtnStr += this._strokeMaterial.getName(); 168 rtnStr += this._strokeMaterial.getName();
122 } else { 169 } else {
123 rtnStr += "flatMaterial"; 170 rtnStr += MaterialsModel.getDefaultMaterialName();
124 } 171 }
125 172
126 rtnStr += "\n"; 173 rtnStr += "\n";
@@ -150,7 +197,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
150 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); 197 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
151 if (!strokeMat) { 198 if (!strokeMat) {
152 console.log( "object material not found in library: " + strokeMaterialName ); 199 console.log( "object material not found in library: " + strokeMaterialName );
153 strokeMat = MaterialsModel.exportFlatMaterial(); 200 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
154 } 201 }
155 202
156 this._strokeMaterial = strokeMat; 203 this._strokeMaterial = strokeMat;