aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/geom-obj.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/geom-obj.js')
-rwxr-xr-xjs/lib/geom/geom-obj.js47
1 files changed, 47 insertions, 0 deletions
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 );