diff options
Diffstat (limited to 'js/lib/geom/line.js')
-rwxr-xr-x | js/lib/geom/line.js | 44 |
1 files changed, 41 insertions, 3 deletions
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 | |||
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 | this.importMaterialsJSON( jObj.materials ); | ||
141 | }; | ||
142 | |||
105 | this.export = function() { | 143 | this.export = function() { |
106 | var rtnStr = "type: " + this.geomType() + "\n"; | 144 | var rtnStr = "type: " + this.geomType() + "\n"; |
107 | 145 | ||
@@ -127,7 +165,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok | |||
127 | if (this._strokeMaterial) { | 165 | if (this._strokeMaterial) { |
128 | rtnStr += this._strokeMaterial.getName(); | 166 | rtnStr += this._strokeMaterial.getName(); |
129 | } else { | 167 | } else { |
130 | rtnStr += "flatMaterial"; | 168 | rtnStr += MaterialsModel.getDefaultMaterialName(); |
131 | } | 169 | } |
132 | 170 | ||
133 | rtnStr += "\n"; | 171 | rtnStr += "\n"; |
@@ -165,7 +203,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok | |||
165 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | 203 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); |
166 | if (!strokeMat) { | 204 | if (!strokeMat) { |
167 | console.log( "object material not found in library: " + strokeMaterialName ); | 205 | console.log( "object material not found in library: " + strokeMaterialName ); |
168 | strokeMat = MaterialsModel.exportFlatMaterial(); | 206 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); |
169 | } | 207 | } |
170 | 208 | ||
171 | this._strokeMaterial = strokeMat; | 209 | this._strokeMaterial = strokeMat; |