From fdeed8051c3af538d28ca3bc599121cea483c22c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 22 Mar 2012 15:47:56 -0700 Subject: Squashed commit of the following GL integration Signed-off-by: Valerio Virgillito --- js/lib/geom/line.js | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'js/lib/geom/line.js') diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index 4a935de8..e839e229 100755 --- a/js/lib/geom/line.js +++ b/js/lib/geom/line.js @@ -99,9 +99,47 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok this.geomType = function() { return this.GEOM_TYPE_LINE; } - /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// + this.exportJSON = function() + { + var jObj = + { + 'type' : this.geomType(), + 'xoff' : this._xOffset, + 'yoff' : this._yOffset, + 'width' : this._width, + 'height' : this._height, + 'xAdj' : this._xAdj, + 'yAdj' : this._yAdj, + 'slope' : this._slope, + 'strokeWidth' : this._strokeWidth, + 'strokeColor' : this._strokeColor, + 'strokeStyle' : this._strokeStyle, + 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), + 'materials' : this.exportMaterialsJSON() + }; + + return jObj; + }; + + this.importJSON = function( jObj ) + { + this._xOffset = jObj.xoff; + this._yOffset = jObj.yoff; + this._width = jObj.width; + this._height = jObj.height; + this._xAdj = jObj.xAdj; + this._yAdj = jObj.yAdj; + this._strokeWidth = jObj.strokeWidth; + this._slope = jObj.slope; + this._strokeStyle = jObj.strokeStyle; + this._strokeColor = jObj.strokeColor; + var strokeMaterialName = jObj.strokeMat; + this.importMaterialsJSON( jObj.materials ); + }; + this.export = function() { var rtnStr = "type: " + this.geomType() + "\n"; @@ -127,7 +165,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok if (this._strokeMaterial) { rtnStr += this._strokeMaterial.getName(); } else { - rtnStr += "flatMaterial"; + rtnStr += MaterialsModel.getDefaultMaterialName(); } rtnStr += "\n"; @@ -165,7 +203,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); if (!strokeMat) { console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.exportFlatMaterial(); + strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); } this._strokeMaterial = strokeMat; -- cgit v1.2.3