From 2d68f944e93b201deb46015392e706b7a24201c9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 8 Feb 2012 14:24:48 -0800 Subject: Fixed several typos in Materials import/export code to support toggling between 2d and 3d shape modes. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'js/controllers/elements/shapes-controller.js') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index e764de4e..b9c033aa 100644 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -63,11 +63,11 @@ exports.ShapesController = Montage.create(CanvasController, { canvas.height = el.height; this.application.ninja.elementMediator.replaceElement(el, canvas); NJevent("elementDeleted", el); - this.application.ninja.selectionController.selectElement(canvas); el = canvas; this.toggleWebGlMode(el, value); - el.elementModel.shapeModel.GLGeomObj.buildBuffers(); - break; + el.elementModel.shapeModel.GLWorld.render(); + this.application.ninja.selectionController.selectElement(el); + return; case "strokeMaterial": var sm = Object.create(MaterialsLibrary.getMaterial(value)); if(sm) @@ -338,13 +338,26 @@ exports.ShapesController = Montage.create(CanvasController, { { return; } - var world, + var sm, + fm, + world, worldData = el.elementModel.shapeModel.GLWorld.export(); if(worldData) { world = new GLWorld(el, true); el.elementModel.shapeModel.GLWorld = world; + el.elementModel.shapeModel.GLGeomObj.setWorld(world); el.elementModel.shapeModel.useWebGl = true; + sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); + fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); + if(sm && fm) + { + el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); + el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); + el.elementModel.shapeModel.strokeMaterial = sm; + el.elementModel.shapeModel.fillMaterial = fm; + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); + } world.import(worldData); } @@ -365,6 +378,10 @@ exports.ShapesController = Montage.create(CanvasController, { world = new GLWorld(el, false); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = false; + el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); + el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null); + el.elementModel.shapeModel.strokeMaterial = null; + el.elementModel.shapeModel.fillMaterial = null; world.import(worldData); } -- cgit v1.2.3 From 63e68c9ed57253994b7424dd03059064cc656e98 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 9 Feb 2012 15:52:45 -0800 Subject: Fixed switching between webGL and canvas 2d modes. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js/controllers/elements/shapes-controller.js') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index b9c033aa..44723a1e 100644 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -346,8 +346,10 @@ exports.ShapesController = Montage.create(CanvasController, { { world = new GLWorld(el, true); el.elementModel.shapeModel.GLWorld = world; - el.elementModel.shapeModel.GLGeomObj.setWorld(world); el.elementModel.shapeModel.useWebGl = true; + world.import(worldData); + el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); + sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); if(sm && fm) @@ -356,9 +358,7 @@ exports.ShapesController = Montage.create(CanvasController, { el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); el.elementModel.shapeModel.strokeMaterial = sm; el.elementModel.shapeModel.fillMaterial = fm; - el.elementModel.shapeModel.GLGeomObj.buildBuffers(); } - world.import(worldData); } } @@ -378,13 +378,13 @@ exports.ShapesController = Montage.create(CanvasController, { world = new GLWorld(el, false); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = false; + world.import(worldData); + el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null); el.elementModel.shapeModel.strokeMaterial = null; el.elementModel.shapeModel.fillMaterial = null; - world.import(worldData); } - } } -- cgit v1.2.3 From 9e40945a5bf4330d1088b56b8011ee625b1adab9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 10 Feb 2012 10:23:48 -0800 Subject: Support export/import of GLLine data. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'js/controllers/elements/shapes-controller.js') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 44723a1e..640119c4 100644 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -351,12 +351,17 @@ exports.ShapesController = Montage.create(CanvasController, { el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); - fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); - if(sm && fm) + if(sm) { el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); - el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); el.elementModel.shapeModel.strokeMaterial = sm; + } + fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); + // TODO - Use consts after GL code is converted to object literal notation +// if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== GLGeomObj.GEOM_TYPE_LINE) ) + if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== 3) ) + { + el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); el.elementModel.shapeModel.fillMaterial = fm; } } @@ -381,9 +386,13 @@ exports.ShapesController = Montage.create(CanvasController, { world.import(worldData); el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); - el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null); el.elementModel.shapeModel.strokeMaterial = null; - el.elementModel.shapeModel.fillMaterial = null; + // TODO - Use consts after GL code is converted to object literal notation + if(el.elementModel.shapeModel.GLGeomObj.geomType() !== 3) + { + el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null); + el.elementModel.shapeModel.fillMaterial = null; + } } } } -- cgit v1.2.3