diff options
Diffstat (limited to 'js/lib/geom/rectangle.js')
-rwxr-xr-x | js/lib/geom/rectangle.js | 125 |
1 files changed, 15 insertions, 110 deletions
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index e511d5f4..91b1d426 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js | |||
@@ -187,65 +187,6 @@ var Rectangle = function GLRectangle() { | |||
187 | /////////////////////////////////////////////////////////////////////// | 187 | /////////////////////////////////////////////////////////////////////// |
188 | // Methods | 188 | // Methods |
189 | /////////////////////////////////////////////////////////////////////// | 189 | /////////////////////////////////////////////////////////////////////// |
190 | /* | ||
191 | this.export = function() { | ||
192 | var rtnStr = "type: " + this.geomType() + "\n"; | ||
193 | |||
194 | ///////////////////////////////////////////////////////////////////////// | ||
195 | // | ||
196 | // world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, | ||
197 | // tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle | ||
198 | // | ||
199 | ///////////////////////////////////////////////////////////////////////////// | ||
200 | |||
201 | rtnStr += "xoff: " + this._xOffset + "\n"; | ||
202 | rtnStr += "yoff: " + this._yOffset + "\n"; | ||
203 | rtnStr += "width: " + this._width + "\n"; | ||
204 | rtnStr += "height: " + this._height + "\n"; | ||
205 | rtnStr += "strokeWidth: " + this._strokeWidth + "\n"; | ||
206 | |||
207 | if(this._strokeColor.gradientMode) { | ||
208 | rtnStr += "strokeGradientMode: " + this._strokeColor.gradientMode + "\n"; | ||
209 | rtnStr += "strokeColor: " + this.gradientToString(this._strokeColor.color) + "\n"; | ||
210 | } else { | ||
211 | rtnStr += "strokeColor: " + String(this._strokeColor) + "\n"; | ||
212 | } | ||
213 | |||
214 | if(this._fillColor.gradientMode) { | ||
215 | rtnStr += "fillGradientMode: " + this._fillColor.gradientMode + "\n"; | ||
216 | rtnStr += "fillColor: " + this.gradientToString(this._fillColor.color) + "\n"; | ||
217 | } else { | ||
218 | rtnStr += "fillColor: " + String(this._fillColor) + "\n"; | ||
219 | } | ||
220 | rtnStr += "tlRadius: " + this._tlRadius + "\n"; | ||
221 | rtnStr += "trRadius: " + this._trRadius + "\n"; | ||
222 | rtnStr += "blRadius: " + this._blRadius + "\n"; | ||
223 | rtnStr += "brRadius: " + this._brRadius + "\n"; | ||
224 | rtnStr += "innerRadius: " + this._innerRadius + "\n"; | ||
225 | rtnStr += "strokeStyle: " + this._strokeStyle + "\n"; | ||
226 | |||
227 | rtnStr += "strokeMat: "; | ||
228 | if (this._strokeMaterial) { | ||
229 | rtnStr += this._strokeMaterial.getName(); | ||
230 | } else { | ||
231 | rtnStr += MaterialsModel.getDefaultMaterialName(); | ||
232 | } | ||
233 | rtnStr += "\n"; | ||
234 | |||
235 | rtnStr += "fillMat: "; | ||
236 | if (this._fillMaterial) { | ||
237 | rtnStr += this._fillMaterial.getName(); | ||
238 | } else { | ||
239 | rtnStr += MaterialsModel.getDefaultMaterialName(); | ||
240 | } | ||
241 | rtnStr += "\n"; | ||
242 | |||
243 | rtnStr += this.exportMaterials(); | ||
244 | |||
245 | return rtnStr; | ||
246 | }; | ||
247 | */ | ||
248 | |||
249 | // JSON export | 190 | // JSON export |
250 | this.exportJSON = function() | 191 | this.exportJSON = function() |
251 | { | 192 | { |
@@ -290,58 +231,22 @@ var Rectangle = function GLRectangle() { | |||
290 | this._strokeStyle = jObj.strokeStyle; | 231 | this._strokeStyle = jObj.strokeStyle; |
291 | var strokeMaterialName = jObj.strokeMat; | 232 | var strokeMaterialName = jObj.strokeMat; |
292 | var fillMaterialName = jObj.fillMat; | 233 | var fillMaterialName = jObj.fillMat; |
293 | this.importMaterialsJSON( jObj.materials ); | ||
294 | }; | ||
295 | 234 | ||
296 | this.import = function( importStr ) { | 235 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); |
297 | this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) ); | 236 | if (!strokeMat) { |
298 | this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) ); | 237 | console.log( "object material not found in library: " + strokeMaterialName ); |
299 | this._width = Number( this.getPropertyFromString( "width: ", importStr ) ); | 238 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); |
300 | this._height = Number( this.getPropertyFromString( "height: ", importStr ) ); | ||
301 | this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); | ||
302 | this._innerRadius = Number( this.getPropertyFromString( "innerRadius: ", importStr ) ); | ||
303 | this._strokeStyle = Number( this.getPropertyFromString( "strokeStyle: ", importStr ) ); | ||
304 | var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); | ||
305 | var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr ); | ||
306 | this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); | ||
307 | |||
308 | if(importStr.indexOf("fillGradientMode: ") < 0) { | ||
309 | this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" ); | ||
310 | } else { | ||
311 | this._fillColor = {}; | ||
312 | this._fillColor.gradientMode = this.getPropertyFromString( "fillGradientMode: ", importStr ); | ||
313 | this._fillColor.color = this.stringToGradient(this.getPropertyFromString( "fillColor: ", importStr )); | ||
314 | } | 239 | } |
240 | this._strokeMaterial = strokeMat; | ||
315 | 241 | ||
316 | if(importStr.indexOf("strokeGradientMode: ") < 0) | 242 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ); |
317 | { | 243 | if (!fillMat) { |
318 | this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); | 244 | console.log( "object material not found in library: " + fillMaterialName ); |
319 | } else { | 245 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); |
320 | this._strokeColor = {}; | ||
321 | this._strokeColor.gradientMode = this.getPropertyFromString( "strokeGradientMode: ", importStr ); | ||
322 | this._strokeColor.color = this.stringToGradient(this.getPropertyFromString( "strokeColor: ", importStr )); | ||
323 | } | 246 | } |
247 | this._fillMaterial = fillMat; | ||
324 | 248 | ||
325 | this._tlRadius = Number( this.getPropertyFromString( "tlRadius: ", importStr ) ); | 249 | this.importMaterialsJSON( jObj.materials ); |
326 | this._trRadius = Number( this.getPropertyFromString( "trRadius: ", importStr ) ); | ||
327 | this._blRadius = Number( this.getPropertyFromString( "blRadius: ", importStr ) ); | ||
328 | this._brRadius = Number( this.getPropertyFromString( "brRadius: ", importStr ) ); | ||
329 | |||
330 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | ||
331 | if (!strokeMat) { | ||
332 | console.log( "object material not found in library: " + strokeMaterialName ); | ||
333 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | ||
334 | } | ||
335 | this._strokeMaterial = strokeMat; | ||
336 | |||
337 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ); | ||
338 | if (!fillMat) { | ||
339 | console.log( "object material not found in library: " + fillMaterialName ); | ||
340 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | ||
341 | } | ||
342 | this._fillMaterial = fillMat; | ||
343 | |||
344 | this.importMaterials( importStr ); | ||
345 | }; | 250 | }; |
346 | 251 | ||
347 | this.buildBuffers = function() { | 252 | this.buildBuffers = function() { |
@@ -352,7 +257,7 @@ var Rectangle = function GLRectangle() { | |||
352 | if (!world._useWebGL) return; | 257 | if (!world._useWebGL) return; |
353 | 258 | ||
354 | // make sure RDGE has the correct context | 259 | // make sure RDGE has the correct context |
355 | g_Engine.setContext( world.getCanvas().rdgeid ); | 260 | RDGE.globals.engine.setContext( world.getCanvas().rdgeid ); |
356 | 261 | ||
357 | // create the gl buffer | 262 | // create the gl buffer |
358 | var gl = world.getGLContext(); | 263 | var gl = world.getGLContext(); |
@@ -952,7 +857,7 @@ RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad, | |||
952 | // } | 857 | // } |
953 | 858 | ||
954 | // create the RDGE primitive | 859 | // create the RDGE primitive |
955 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); | 860 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); |
956 | }; | 861 | }; |
957 | 862 | ||
958 | RectangleFill.pushVertex = function( x, y, z ) { | 863 | RectangleFill.pushVertex = function( x, y, z ) { |
@@ -1184,7 +1089,7 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad, | |||
1184 | // } | 1089 | // } |
1185 | 1090 | ||
1186 | // create the RDGE primitive | 1091 | // create the RDGE primitive |
1187 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); | 1092 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); |
1188 | }; | 1093 | }; |
1189 | 1094 | ||
1190 | RectangleStroke.getRoundedCorner = function( ctr, insidePt, outsidePt ) { | 1095 | RectangleStroke.getRoundedCorner = function( ctr, insidePt, outsidePt ) { |
@@ -1270,7 +1175,7 @@ RectangleGeometry.create = function( ctr, width, height, material ) { | |||
1270 | // } | 1175 | // } |
1271 | 1176 | ||
1272 | // create the RDGE primitive | 1177 | // create the RDGE primitive |
1273 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); | 1178 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); |
1274 | }; | 1179 | }; |
1275 | 1180 | ||
1276 | RectangleGeometry.pushVertex = RectangleFill.pushVertex; | 1181 | RectangleGeometry.pushVertex = RectangleFill.pushVertex; |