diff options
Diffstat (limited to 'js/lib/geom/line.js')
-rwxr-xr-x | js/lib/geom/line.js | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index 4a935de8..a706eb93 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 | ||
@@ -127,7 +174,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok | |||
127 | if (this._strokeMaterial) { | 174 | if (this._strokeMaterial) { |
128 | rtnStr += this._strokeMaterial.getName(); | 175 | rtnStr += this._strokeMaterial.getName(); |
129 | } else { | 176 | } else { |
130 | rtnStr += "flatMaterial"; | 177 | rtnStr += MaterialsModel.getDefaultMaterialName(); |
131 | } | 178 | } |
132 | 179 | ||
133 | rtnStr += "\n"; | 180 | rtnStr += "\n"; |
@@ -165,7 +212,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok | |||
165 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | 212 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); |
166 | if (!strokeMat) { | 213 | if (!strokeMat) { |
167 | console.log( "object material not found in library: " + strokeMaterialName ); | 214 | console.log( "object material not found in library: " + strokeMaterialName ); |
168 | strokeMat = MaterialsModel.exportFlatMaterial(); | 215 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); |
169 | } | 216 | } |
170 | 217 | ||
171 | this._strokeMaterial = strokeMat; | 218 | this._strokeMaterial = strokeMat; |