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 70f6b01b..ef91d158 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js | |||
@@ -191,65 +191,6 @@ var Rectangle = function GLRectangle() | |||
191 | /////////////////////////////////////////////////////////////////////// | 191 | /////////////////////////////////////////////////////////////////////// |
192 | // Methods | 192 | // Methods |
193 | /////////////////////////////////////////////////////////////////////// | 193 | /////////////////////////////////////////////////////////////////////// |
194 | /* | ||
195 | this.export = function() { | ||
196 | var rtnStr = "type: " + this.geomType() + "\n"; | ||
197 | |||
198 | ///////////////////////////////////////////////////////////////////////// | ||
199 | // | ||
200 | // world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, | ||
201 | // tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle | ||
202 | // | ||
203 | ///////////////////////////////////////////////////////////////////////////// | ||
204 | |||
205 | rtnStr += "xoff: " + this._xOffset + "\n"; | ||
206 | rtnStr += "yoff: " + this._yOffset + "\n"; | ||
207 | rtnStr += "width: " + this._width + "\n"; | ||
208 | rtnStr += "height: " + this._height + "\n"; | ||
209 | rtnStr += "strokeWidth: " + this._strokeWidth + "\n"; | ||
210 | |||
211 | if(this._strokeColor.gradientMode) { | ||
212 | rtnStr += "strokeGradientMode: " + this._strokeColor.gradientMode + "\n"; | ||
213 | rtnStr += "strokeColor: " + this.gradientToString(this._strokeColor.color) + "\n"; | ||
214 | } else { | ||
215 | rtnStr += "strokeColor: " + String(this._strokeColor) + "\n"; | ||
216 | } | ||
217 | |||
218 | if(this._fillColor.gradientMode) { | ||
219 | rtnStr += "fillGradientMode: " + this._fillColor.gradientMode + "\n"; | ||
220 | rtnStr += "fillColor: " + this.gradientToString(this._fillColor.color) + "\n"; | ||
221 | } else { | ||
222 | rtnStr += "fillColor: " + String(this._fillColor) + "\n"; | ||
223 | } | ||
224 | rtnStr += "tlRadius: " + this._tlRadius + "\n"; | ||
225 | rtnStr += "trRadius: " + this._trRadius + "\n"; | ||
226 | rtnStr += "blRadius: " + this._blRadius + "\n"; | ||
227 | rtnStr += "brRadius: " + this._brRadius + "\n"; | ||
228 | rtnStr += "innerRadius: " + this._innerRadius + "\n"; | ||
229 | rtnStr += "strokeStyle: " + this._strokeStyle + "\n"; | ||
230 | |||
231 | rtnStr += "strokeMat: "; | ||
232 | if (this._strokeMaterial) { | ||
233 | rtnStr += this._strokeMaterial.getName(); | ||
234 | } else { | ||
235 | rtnStr += MaterialsModel.getDefaultMaterialName(); | ||
236 | } | ||
237 | rtnStr += "\n"; | ||
238 | |||
239 | rtnStr += "fillMat: "; | ||
240 | if (this._fillMaterial) { | ||
241 | rtnStr += this._fillMaterial.getName(); | ||
242 | } else { | ||
243 | rtnStr += MaterialsModel.getDefaultMaterialName(); | ||
244 | } | ||
245 | rtnStr += "\n"; | ||
246 | |||
247 | rtnStr += this.exportMaterials(); | ||
248 | |||
249 | return rtnStr; | ||
250 | }; | ||
251 | */ | ||
252 | |||
253 | // JSON export | 194 | // JSON export |
254 | this.exportJSON = function() | 195 | this.exportJSON = function() |
255 | { | 196 | { |
@@ -294,58 +235,22 @@ var Rectangle = function GLRectangle() | |||
294 | this._strokeStyle = jObj.strokeStyle; | 235 | this._strokeStyle = jObj.strokeStyle; |
295 | var strokeMaterialName = jObj.strokeMat; | 236 | var strokeMaterialName = jObj.strokeMat; |
296 | var fillMaterialName = jObj.fillMat; | 237 | var fillMaterialName = jObj.fillMat; |
297 | this.importMaterialsJSON( jObj.materials ); | ||
298 | }; | ||
299 | 238 | ||
300 | this.import = function( importStr ) { | 239 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); |
301 | this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) ); | 240 | if (!strokeMat) { |
302 | this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) ); | 241 | console.log( "object material not found in library: " + strokeMaterialName ); |
303 | this._width = Number( this.getPropertyFromString( "width: ", importStr ) ); | 242 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); |
304 | this._height = Number( this.getPropertyFromString( "height: ", importStr ) ); | ||
305 | this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); | ||
306 | this._innerRadius = Number( this.getPropertyFromString( "innerRadius: ", importStr ) ); | ||
307 | this._strokeStyle = Number( this.getPropertyFromString( "strokeStyle: ", importStr ) ); | ||
308 | var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); | ||
309 | var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr ); | ||
310 | this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); | ||
311 | |||
312 | if(importStr.indexOf("fillGradientMode: ") < 0) { | ||
313 | this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" ); | ||
314 | } else { | ||
315 | this._fillColor = {}; | ||
316 | this._fillColor.gradientMode = this.getPropertyFromString( "fillGradientMode: ", importStr ); | ||
317 | this._fillColor.color = this.stringToGradient(this.getPropertyFromString( "fillColor: ", importStr )); | ||
318 | } | 243 | } |
244 | this._strokeMaterial = strokeMat; | ||
319 | 245 | ||
320 | if(importStr.indexOf("strokeGradientMode: ") < 0) | 246 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ); |
321 | { | 247 | if (!fillMat) { |
322 | this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); | 248 | console.log( "object material not found in library: " + fillMaterialName ); |
323 | } else { | 249 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); |
324 | this._strokeColor = {}; | ||
325 | this._strokeColor.gradientMode = this.getPropertyFromString( "strokeGradientMode: ", importStr ); | ||
326 | this._strokeColor.color = this.stringToGradient(this.getPropertyFromString( "strokeColor: ", importStr )); | ||
327 | } | 250 | } |
251 | this._fillMaterial = fillMat; | ||
328 | 252 | ||
329 | this._tlRadius = Number( this.getPropertyFromString( "tlRadius: ", importStr ) ); | 253 | this.importMaterialsJSON( jObj.materials ); |
330 | this._trRadius = Number( this.getPropertyFromString( "trRadius: ", importStr ) ); | ||
331 | this._blRadius = Number( this.getPropertyFromString( "blRadius: ", importStr ) ); | ||
332 | this._brRadius = Number( this.getPropertyFromString( "brRadius: ", importStr ) ); | ||
333 | |||
334 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | ||
335 | if (!strokeMat) { | ||
336 | console.log( "object material not found in library: " + strokeMaterialName ); | ||
337 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | ||
338 | } | ||
339 | this._strokeMaterial = strokeMat; | ||
340 | |||
341 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ); | ||
342 | if (!fillMat) { | ||
343 | console.log( "object material not found in library: " + fillMaterialName ); | ||
344 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | ||
345 | } | ||
346 | this._fillMaterial = fillMat; | ||
347 | |||
348 | this.importMaterials( importStr ); | ||
349 | }; | 254 | }; |
350 | 255 | ||
351 | this.buildBuffers = function() { | 256 | this.buildBuffers = function() { |
@@ -356,7 +261,7 @@ var Rectangle = function GLRectangle() | |||
356 | if (!world._useWebGL) return; | 261 | if (!world._useWebGL) return; |
357 | 262 | ||
358 | // make sure RDGE has the correct context | 263 | // make sure RDGE has the correct context |
359 | g_Engine.setContext( world.getCanvas().rdgeid ); | 264 | RDGE.globals.engine.setContext( world.getCanvas().rdgeid ); |
360 | 265 | ||
361 | // create the gl buffer | 266 | // create the gl buffer |
362 | var gl = world.getGLContext(); | 267 | var gl = world.getGLContext(); |
@@ -956,7 +861,7 @@ RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad, | |||
956 | } | 861 | } |
957 | 862 | ||
958 | // create the RDGE primitive | 863 | // create the RDGE primitive |
959 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); | 864 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); |
960 | }; | 865 | }; |
961 | 866 | ||
962 | RectangleFill.pushVertex = function( x, y, z ) { | 867 | RectangleFill.pushVertex = function( x, y, z ) { |
@@ -1188,7 +1093,7 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad, | |||
1188 | } | 1093 | } |
1189 | 1094 | ||
1190 | // create the RDGE primitive | 1095 | // create the RDGE primitive |
1191 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); | 1096 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); |
1192 | }; | 1097 | }; |
1193 | 1098 | ||
1194 | RectangleStroke.getRoundedCorner = function( ctr, insidePt, outsidePt ) { | 1099 | RectangleStroke.getRoundedCorner = function( ctr, insidePt, outsidePt ) { |
@@ -1274,7 +1179,7 @@ RectangleGeometry.create = function( ctr, width, height, material ) { | |||
1274 | } | 1179 | } |
1275 | 1180 | ||
1276 | // create the RDGE primitive | 1181 | // create the RDGE primitive |
1277 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); | 1182 | return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); |
1278 | }; | 1183 | }; |
1279 | 1184 | ||
1280 | RectangleGeometry.pushVertex = RectangleFill.pushVertex; | 1185 | RectangleGeometry.pushVertex = RectangleFill.pushVertex; |