aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-xjs/lib/geom/circle.js3
-rwxr-xr-xjs/lib/geom/geom-obj.js47
-rwxr-xr-xjs/lib/geom/rectangle.js4
3 files changed, 51 insertions, 3 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index dd82a4cc..ad77383b 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -577,9 +577,10 @@ var Circle = function GLCircle() {
577 } else { 577 } else {
578 rtnStr += "flatMaterial"; 578 rtnStr += "flatMaterial";
579 } 579 }
580
581 rtnStr += "\n"; 580 rtnStr += "\n";
582 581
582 rtnStr += this.exportMaterials();
583
583 return rtnStr; 584 return rtnStr;
584 }; 585 };
585 586
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js
index c5880843..852aab89 100755
--- a/js/lib/geom/geom-obj.js
+++ b/js/lib/geom/geom-obj.js
@@ -204,6 +204,53 @@ var GeomObj = function GLGeomObj() {
204 return fillMaterial; 204 return fillMaterial;
205 }; 205 };
206 206
207 this.exportMaterials = function()
208 {
209 var rtnStr = "";
210 if (this._materialArray && this._materialNodeArray)
211 {
212 var nMats = this._materialArray.length;
213 rtnStr += "nMaterials: " + nMats + "\n";
214 for (var i=0; i<nMats; i++)
215 {
216 var matNode = this._materialNodeArray[i];
217 rtnStr += "materialNodeName: " + matNode.name + "\n";
218
219 var material = this._materialArray[i];
220 rtnStr += material.export();
221 }
222 }
223 else
224 rtnStr += "nMaterials: 0\n" ;
225
226 return rtnStr;
227 }
228
229 this.importMaterials = function(importStr)
230 {
231 var nMaterials = Number( this.getPropertyFromString( "nMaterials: ", importStr ) );
232 for (var i=0; i<nMaterials; i++)
233 {
234 var mat;
235 var materialType = this.getPropertyFromString( "material: ", importStr );
236 switch (materialType)
237 {
238 case "flat": mat = new FlatMaterial(); break;
239
240 default:
241 console.log( "material type: " + materialType + " is not supported" );
242 break;
243 }
244
245 if (mat)
246 mat.import( importStr );
247
248 var endIndex = importStr.indexOf( "endMaterial\n" );
249 if (endIndex < 0) break;
250 importStr = importStr.substr( endIndex );
251 }
252 }
253
207 this.translate = function(v) { 254 this.translate = function(v) {
208 var mat = Matrix.Translation( v ); 255 var mat = Matrix.Translation( v );
209 //var mat2 = mat.multiply( this._matrix ); 256 //var mat2 = mat.multiply( this._matrix );
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index 81b385b3..f91e830c 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -218,7 +218,6 @@ var Rectangle = function GLRectangle() {
218 } else { 218 } else {
219 rtnStr += "flatMaterial"; 219 rtnStr += "flatMaterial";
220 } 220 }
221
222 rtnStr += "\n"; 221 rtnStr += "\n";
223 222
224 rtnStr += "fillMat: "; 223 rtnStr += "fillMat: ";
@@ -227,9 +226,10 @@ var Rectangle = function GLRectangle() {
227 } else { 226 } else {
228 rtnStr += "flatMaterial"; 227 rtnStr += "flatMaterial";
229 } 228 }
230
231 rtnStr += "\n"; 229 rtnStr += "\n";
232 230
231 rtnStr += this.exportMaterials();
232
233 return rtnStr; 233 return rtnStr;
234 }; 234 };
235 235