aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements/shapes-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/elements/shapes-controller.js')
-rwxr-xr-x[-rw-r--r--]js/controllers/elements/shapes-controller.js42
1 files changed, 32 insertions, 10 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index b9c033aa..e0bff70c 100644..100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -59,6 +59,7 @@ exports.ShapesController = Montage.create(CanvasController, {
59 break; 59 break;
60 case "useWebGl": 60 case "useWebGl":
61 var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true); 61 var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true);
62 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom());
62 canvas.width = el.width; 63 canvas.width = el.width;
63 canvas.height = el.height; 64 canvas.height = el.height;
64 this.application.ninja.elementMediator.replaceElement(el, canvas); 65 this.application.ninja.elementMediator.replaceElement(el, canvas);
@@ -249,6 +250,10 @@ exports.ShapesController = Montage.create(CanvasController, {
249 setColor: { 250 setColor: {
250 value: function(el, color, isFill) { 251 value: function(el, color, isFill) {
251 var webGl = color.webGlColor || color.color.webGlColor; 252 var webGl = color.webGlColor || color.color.webGlColor;
253 if(!webGl)
254 {
255 webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color);
256 }
252 if(isFill) 257 if(isFill)
253 { 258 {
254 el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); 259 el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl);
@@ -260,6 +265,14 @@ exports.ShapesController = Montage.create(CanvasController, {
260 el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl); 265 el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl);
261 this.setShapeProperty(el, "stroke", webGl); 266 this.setShapeProperty(el, "stroke", webGl);
262 this.setShapeProperty(el, "border", color); 267 this.setShapeProperty(el, "border", color);
268 if(color.strokeInfo)
269 {
270 var strokeWidth = this.GetValueInPixels(color.strokeInfo.strokeSize,
271 color.strokeInfo.strokeUnits);
272 el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(strokeWidth);
273 this.setShapeProperty(el, "strokeSize", color.strokeInfo.strokeSize + " "
274 + color.strokeInfo.strokeUnits);
275 }
263 } 276 }
264 el.elementModel.shapeModel.GLWorld.render(); 277 el.elementModel.shapeModel.GLWorld.render();
265 } 278 }
@@ -346,19 +359,24 @@ exports.ShapesController = Montage.create(CanvasController, {
346 { 359 {
347 world = new GLWorld(el, true); 360 world = new GLWorld(el, true);
348 el.elementModel.shapeModel.GLWorld = world; 361 el.elementModel.shapeModel.GLWorld = world;
349 el.elementModel.shapeModel.GLGeomObj.setWorld(world);
350 el.elementModel.shapeModel.useWebGl = true; 362 el.elementModel.shapeModel.useWebGl = true;
363 world.import(worldData);
364 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
365
351 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 366 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
352 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 367 if(sm)
353 if(sm && fm)
354 { 368 {
355 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); 369 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm);
356 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
357 el.elementModel.shapeModel.strokeMaterial = sm; 370 el.elementModel.shapeModel.strokeMaterial = sm;
371 }
372 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
373 // TODO - Use consts after GL code is converted to object literal notation
374// if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== GLGeomObj.GEOM_TYPE_LINE) )
375 if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== 3) )
376 {
377 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
358 el.elementModel.shapeModel.fillMaterial = fm; 378 el.elementModel.shapeModel.fillMaterial = fm;
359 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
360 } 379 }
361 world.import(worldData);
362 } 380 }
363 381
364 } 382 }
@@ -378,13 +396,17 @@ exports.ShapesController = Montage.create(CanvasController, {
378 world = new GLWorld(el, false); 396 world = new GLWorld(el, false);
379 el.elementModel.shapeModel.GLWorld = world; 397 el.elementModel.shapeModel.GLWorld = world;
380 el.elementModel.shapeModel.useWebGl = false; 398 el.elementModel.shapeModel.useWebGl = false;
399 world.import(worldData);
400 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
381 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); 401 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null);
382 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null);
383 el.elementModel.shapeModel.strokeMaterial = null; 402 el.elementModel.shapeModel.strokeMaterial = null;
384 el.elementModel.shapeModel.fillMaterial = null; 403 // TODO - Use consts after GL code is converted to object literal notation
385 world.import(worldData); 404 if(el.elementModel.shapeModel.GLGeomObj.geomType() !== 3)
405 {
406 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null);
407 el.elementModel.shapeModel.fillMaterial = null;
408 }
386 } 409 }
387
388 } 410 }
389 } 411 }
390 412