From bcddcf118d4ce93e8a2519ed455c6e25a701ce74 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sat, 17 Mar 2012 16:42:13 -0700 Subject: fixing the map styles and temporary disabling the 3d styles for elements. Signed-off-by: Valerio Virgillito --- js/controllers/elements/element-controller.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 70aba54e..efaa00ee 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -290,10 +290,10 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, value: function(el, props, index, update3DModel) { var dist = props[index]["dist"], mat = props[index]["mat"]; - this.application.ninja.stylesController.setElementStyle(el, - "-webkit-transform", - "perspective(" + dist + ") " + - "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); +// this.application.ninja.stylesController.setElementStyle(el, +// "-webkit-transform", +// "perspective(" + dist + ") " + +// "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); el.elementModel.props3D.matrix3d = mat; el.elementModel.props3D.perspectiveDist = dist; -- cgit v1.2.3 From a086ca62423a09807e2f3a79107249bc31d5e908 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sat, 17 Mar 2012 18:41:17 -0700 Subject: Adding back webkit-transform styles in set3DProperties. Changing "zoom" to "zoomValue" in map component to avoid scaling the map. Signed-off-by: Nivesh Rajbhandari Signed-off-by: Valerio Virgillito --- js/controllers/elements/element-controller.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index efaa00ee..70aba54e 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -290,10 +290,10 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, value: function(el, props, index, update3DModel) { var dist = props[index]["dist"], mat = props[index]["mat"]; -// this.application.ninja.stylesController.setElementStyle(el, -// "-webkit-transform", -// "perspective(" + dist + ") " + -// "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); + this.application.ninja.stylesController.setElementStyle(el, + "-webkit-transform", + "perspective(" + dist + ") " + + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); el.elementModel.props3D.matrix3d = mat; el.elementModel.props3D.perspectiveDist = dist; -- cgit v1.2.3 From 44d75ed17d56055ed9dbb8f91867bbdbc68924fa Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sun, 18 Mar 2012 22:21:14 -0700 Subject: fixing the selection of components. Temporary workaround for now. Signed-off-by: Valerio Virgillito --- js/controllers/elements/component-controller.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 83450d0f..260ee8a0 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js @@ -11,6 +11,8 @@ exports.ComponentController = Montage.create(ElementController, { getProperty: { value: function(el, prop) { + var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el); + switch(prop) { case "id": case "class": @@ -19,18 +21,20 @@ exports.ComponentController = Montage.create(ElementController, { case "width": case "height": if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) { - return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; + return component[prop]; } else { return ElementController.getProperty(el, prop, true); } default: - return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; + return component[prop]; } } }, setProperty: { value: function(el, p, value) { + var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el); + switch(p) { case "id": case "class": @@ -39,15 +43,14 @@ exports.ComponentController = Montage.create(ElementController, { case "width": case "height": if(el.nodeName === "IMG" && (p === "width" || p === "height")) { - this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; + component[p] = value; } else { ElementController.setProperty(el, p, value); } break; default: if(p === "min" || p === "max") value = parseFloat(value); - - this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; + component[p] = value; break; } -- cgit v1.2.3 From fff3c568e6884a867527390b9b77f45c63944aec Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 20 Mar 2012 06:04:41 -0700 Subject: Removing zoom from element's getMatrix. Zoom should only be checked on stage. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 16 ----------- js/controllers/elements/stage-controller.js | 41 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 16 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 70aba54e..b35251ad 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -228,22 +228,6 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, mat = this.transformStringToMat( xformStr ); if (!mat) mat = Matrix.I(4); - - var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom"); - if (zoom) - { - zoom = Number(zoom); - if (zoom != 1) - { - var zoomMat = Matrix.create( [ - [ zoom, 0, 0, 0], - [ 0, zoom, 0, 0], - [ 0, 0, zoom, 0], - [ 0, 0, 0, 1] - ] ); - glmat4.multiply( zoomMat, mat, mat ); - } - } } el.elementModel.props3D.matrix3d = mat; diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js index 34bb1fb5..97ea3aa5 100755 --- a/js/controllers/elements/stage-controller.js +++ b/js/controllers/elements/stage-controller.js @@ -129,5 +129,46 @@ exports.StageController = Montage.create(ElementController, { value: function(el, rule, selector) { el.elementModel.transitionStopRule.selectorText = selector; } + }, + + getMatrix: { + value: function(el) { + if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) + { + return el.elementModel.props3D.matrix3d.slice(0); + } + else + { + var mat; + + if (el) + { + var xformStr = this.application.ninja.elementMediator.getProperty(el, "-webkit-transform"); + if (xformStr) + mat = this.transformStringToMat( xformStr ); + if (!mat) + mat = Matrix.I(4); + + var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom"); + if (zoom) + { + zoom = Number(zoom); + if (zoom != 1) + { + var zoomMat = Matrix.create( [ + [ zoom, 0, 0, 0], + [ 0, zoom, 0, 0], + [ 0, 0, zoom, 0], + [ 0, 0, 0, 1] + ] ); + glmat4.multiply( zoomMat, mat, mat ); + } + } + } + + el.elementModel.props3D.matrix3d = mat; + return mat; + } + } } }); -- cgit v1.2.3 From e1c4f30a4c13d747fa69d78598e0961286bbe571 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 20 Mar 2012 10:59:05 -0700 Subject: Support button control in Properties Panel and use them for edit fill and stroke material. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index d72d9c14..b3ac9ddb 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -6,10 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, CanvasController = require("js/controllers/elements/canvas-controller").CanvasController, - njModule = require("js/lib/NJUtils"); - -var World = require("js/lib/drawing/world").World; -var MaterialsModel = require("js/models/materials-model").MaterialsModel; + njModule = require("js/lib/NJUtils"), + World = require("js/lib/drawing/world").World, + MaterialsModel = require("js/models/materials-model").MaterialsModel; exports.ShapesController = Montage.create(CanvasController, { @@ -100,6 +99,12 @@ exports.ShapesController = Montage.create(CanvasController, { el.elementModel.shapeModel.GLWorld.render(); } break; + case "editStrokeMaterial": + NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.strokeMaterial.getName()}); + break; + case "editFillMaterial": + NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); + break; default: CanvasController.setProperty(el, p, value); } -- cgit v1.2.3 From e52b0dcb9540b854a341a881de2d26aa753e9a82 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 16:18:38 -0700 Subject: Adding checkbox in PI to start/stop WebGL animation preview. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index b3ac9ddb..9b2fa618 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -105,6 +105,18 @@ exports.ShapesController = Montage.create(CanvasController, { case "editFillMaterial": NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); break; + case "animate": + if(value) + { + el.elementModel.shapeModel.animate = true; + el.elementModel.shapeModel.GLWorld.restartRenderLoop(); + } + else + { + el.elementModel.shapeModel.animate = false; + el.elementModel.shapeModel.GLWorld._canvas.task.stop(); + } + break; default: CanvasController.setProperty(el, p, value); } @@ -123,6 +135,7 @@ exports.ShapesController = Montage.create(CanvasController, { case "border": case "background": case "useWebGl": + case "animate": return this.getShapeProperty(el, p); case "strokeMaterial": case "fillMaterial": -- cgit v1.2.3 From 8e9ac98ea1001289cb3834b262200eee253cb408 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 23 Mar 2012 11:41:11 -0700 Subject: Respect play/pause WebGL animation when saving files and re-rendering caused by geometry changes. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 9b2fa618..b060b751 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -109,11 +109,13 @@ exports.ShapesController = Montage.create(CanvasController, { if(value) { el.elementModel.shapeModel.animate = true; + el.elementModel.shapeModel.GLWorld._previewAnimation = true; el.elementModel.shapeModel.GLWorld.restartRenderLoop(); } else { el.elementModel.shapeModel.animate = false; + el.elementModel.shapeModel.GLWorld._previewAnimation = false; el.elementModel.shapeModel.GLWorld._canvas.task.stop(); } break; -- cgit v1.2.3 From 86770d0dba6b137e651cbf5c8d240856be65857c Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 23 Mar 2012 14:59:51 -0700 Subject: Fixed a problem switching from 3D to 2D and back to 3D. --- js/controllers/elements/shapes-controller.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index b060b751..5b9e4672 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -504,13 +504,14 @@ exports.ShapesController = Montage.create(CanvasController, { var sm, fm, world, - worldData = el.elementModel.shapeModel.GLWorld.export(); + worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); if(worldData) { + worldData = this.flip3DSense (worldData ); world = new World(el, true); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = true; - world.import(worldData); + world.importJSON(worldData); el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); @@ -540,13 +541,14 @@ exports.ShapesController = Montage.create(CanvasController, { return; } var world, - worldData = el.elementModel.shapeModel.GLWorld.export(); + worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); if(worldData) { + worldData = this.flip3DSense (worldData ); world = new World(el, false); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = false; - world.import(worldData); + world.importJSON(worldData); el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); el.elementModel.shapeModel.strokeMaterial = null; @@ -558,6 +560,24 @@ exports.ShapesController = Montage.create(CanvasController, { } } } + }, + + flip3DSense: { + value: function( importStr ) + { + var jObj; + var index = importStr.indexOf( ';' ); + if ((importStr[0] === 'v') && (index < 24)) + { + // JSON format. separate the version info from the JSON info + //var vStr = importStr.substr( 0, index+1 ); + var jStr = importStr.substr( index+1 ); + jObj = JSON.parse( jStr ); + jObj.webGL = !jObj.webGL; + } + + return jObj; + } } }); -- cgit v1.2.3