From 49eba848c3006045c6096d21fd8262c9d98a35d8 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 20 Mar 2012 13:47:03 -0700 Subject: IKNINJA-1370 - Toggle WebGL on/off is no longer working in the PI. This bug was injected by some changes in GLWorld.import. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 4 ++-- js/lib/drawing/world.js | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index b3ac9ddb..9b0159d4 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -495,7 +495,7 @@ exports.ShapesController = Montage.create(CanvasController, { world = new World(el, true); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = true; - world.import(worldData); + world.import(worldData, true); el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); @@ -531,7 +531,7 @@ exports.ShapesController = Montage.create(CanvasController, { world = new World(el, false); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = false; - world.import(worldData); + world.import(worldData, true); el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); el.elementModel.shapeModel.strokeMaterial = null; diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 049145ce..c1ee0cd0 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -810,14 +810,17 @@ World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) return rtnNode; }; -World.prototype.import = function( importStr ) { +World.prototype.import = function( importStr, fromToggle ) { // import the worldattributes - not currently used // determine if the data was written for export (no Ninja objects) // or for save/restore //var index = importStr.indexOf( "scenedata: " ); - var index = importStr.indexOf( "webGL: " ); - this._useWebGL = (index >= 0) + // Skip if we are toggling between canvas2d and WebGL since importStr doesn't have the correct webGL value yet + if(!fromToggle) { + var index = importStr.indexOf( "webGL: " ); + this._useWebGL = (index >= 0) + } if (this._useWebGL) { // start RDGE -- cgit v1.2.3 From 862b0c33de7cdc8865db274d37744058256936e0 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 21 Mar 2012 12:01:44 -0700 Subject: We should draw tag outlines only for nodeType = 1. Signed-off-by: Nivesh Rajbhandari --- js/stage/layout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/stage/layout.js b/js/stage/layout.js index 6be2df1d..2de67538 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -162,7 +162,7 @@ exports.Layout = Montage.create(Component, { drawTagOutline: { value: function (item) { - if(!item) return; + if(!item || (item.nodeType !== 1)) return; // TODO Bind the layoutview mode to the current document // var mode = this.application.ninja.currentDocument.layoutMode; -- cgit v1.2.3 From 52fac825174d16e3ff6875fc497d3f3cfaf4812c Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 21 Mar 2012 12:02:36 -0700 Subject: Get matrix and perspective distance from styles controller. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 59 +++--------------------- js/controllers/elements/stage-controller.js | 7 ++- js/controllers/styles-controller.js | 66 ++++++++++++++++++++++++++- js/helper-classes/3D/view-utils.js | 48 ------------------- js/lib/NJUtils.js | 2 +- js/models/properties-3d.js | 50 ++++++++++---------- 6 files changed, 100 insertions(+), 132 deletions(-) diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index b35251ad..4f360bb9 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -223,11 +223,10 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, if (el) { - var xformStr = this.application.ninja.elementMediator.getProperty(el, "-webkit-transform"); - if (xformStr) - mat = this.transformStringToMat( xformStr ); - if (!mat) + mat = this.application.ninja.stylesController.getMatrixFromElement(el, false); + if (!mat) { mat = Matrix.I(4); + } } el.elementModel.props3D.matrix3d = mat; @@ -244,23 +243,9 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, } else { - var dist = 1400; - - var str = this.getProperty(el, "-webkit-transform"); - if (str) - { - var index1 = str.indexOf( "perspective("); - if (index1 >= 0) - { - index1 += 12; // do not include 'perspective(' - var index2 = str.indexOf( ")", index1 ); - if (index2 >= 0) - { - var substr = str.substr( index1, (index2-index1)); - if (substr && (substr.length > 0)) - dist = MathUtils.styleToNumber( substr ); - } - } + var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false); + if(dist === null) { + dist = 1400; } el.elementModel.props3D.perspectiveDist = dist; @@ -303,36 +288,6 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, elt.elementModel.props3D.z3D = ~~(elt3DInfo.translation[2]); } } - }, - - transformStringToMat: { - value: function( str ) { - var rtnMat; - - var index1 = str.indexOf( "matrix3d("); - if (index1 >= 0) - { - index1 += 9; // do not include 'matrix3d(' - var index2 = str.indexOf( ")", index1 ); - if (index2 >= 0) - { - var substr = str.substr( index1, (index2-index1)); - if (substr && (substr.length > 0)) - { - var numArray = substr.split(','); - var nNums = numArray.length; - if (nNums == 16) - { - // gl-matrix wants row order - rtnMat = numArray; - for (var i=0; i<16; i++) - rtnMat[i] = Number( rtnMat[i] ); - } - } - } - } - - return rtnMat; - } } + }); \ No newline at end of file diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js index 97ea3aa5..2734e226 100755 --- a/js/controllers/elements/stage-controller.js +++ b/js/controllers/elements/stage-controller.js @@ -143,11 +143,10 @@ exports.StageController = Montage.create(ElementController, { if (el) { - var xformStr = this.application.ninja.elementMediator.getProperty(el, "-webkit-transform"); - if (xformStr) - mat = this.transformStringToMat( xformStr ); - if (!mat) + mat = this.application.ninja.stylesController.getMatrixFromElement(el, true); + if (!mat) { mat = Matrix.I(4); + } var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom"); if (zoom) diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index addfc24e..5d5f27ba 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -836,7 +836,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// For a given CSSKeyframesRule, we may add styles to the keyframe at ///// given index. - setKeyframeStyle : { + setKeyframeStyles : { value : function(rule, keyframeIndex, property, value, useImportant) { return this.setStyles(rule.cssRules[keyframeIndex], property, value, useImportant); } @@ -1124,6 +1124,70 @@ var stylesController = exports.StylesController = Montage.create(Component, { } }, + ///// Get Matrix From Element + ///// Returns the matrix from an element's -webkit-transform + //// TODO - This routine should eventually check for other transform styles, i.e., rotateX, translateZ, etc. + + getMatrixFromElement : { + value: function(element, isStage) { + var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage), + mat; + + if (xformStr) { + var index1 = xformStr.indexOf( "matrix3d("); + if (index1 >= 0) { + index1 += 9; // do not include 'matrix3d(' + var index2 = xformStr.indexOf( ")", index1 ); + if (index2 >= 0) { + var substr = xformStr.substr( index1, (index2-index1)); + if (substr && (substr.length > 0)) { + var numArray = substr.split(','); + var nNums = numArray.length; + if (nNums == 16) { + // gl-matrix wants row order + mat = numArray; + for (var i=0; i<16; i++) { + mat[i] = Number( mat[i] ); + } + } + } + } + } + } + return mat; + } + }, + + ///// Get Perspective Distance From Element + ///// Returns the perspective from an element's -webkit-transform + + getPerspectiveDistFromElement : { + value: function(element, isStage) { + var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage), + dist; + + if (xformStr) { + var index1 = xformStr.indexOf( "perspective("); + if (index1 >= 0) { + index1 += 12; // do not include 'perspective(' + var index2 = xformStr.indexOf( ")", index1 ); + if (index2 >= 0) { + var substr = xformStr.substr( index1, (index2-index1)); + if (substr && (substr.length > 0)) { + dist = parseInt( substr ); + } + } + } + } else { + xformStr = this.getElementStyle(element, "-webkit-perspective", false, isStage); + if(xformStr) { + dist = parseInt(xformStr); + } + } + return dist; + } + }, + ///// Create Rule From Inline Style ///// Creates a rule for an inline style with a specified, or partially random selector. diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 5a820fc2..41fb8d20 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -1099,54 +1099,6 @@ exports.ViewUtils = Montage.create(Component, { } }, - transformStringToMat: { - value: function( str ) { - var rtnMat; - - var index1 = str.indexOf( "matrix3d("); - if (index1 >= 0) - { - index1 += 9; // do not include 'matrix3d(' - var index2 = str.indexOf( ")", index1 ); - if (index2 >= 0) - { - var substr = str.substr( index1, (index2-index1)); - if (substr && (substr.length > 0)) - { - var numArray = substr.split(','); - var nNums = numArray.length; - if (nNums == 16) - { - // gl-matrix wants row order - rtnMat = numArray; - for (var i=0; i<16; i++) - rtnMat[i] = Number( rtnMat[i] ); - - // the matrix as input is column major order. The Matrix - // class expects the numbers in row major order. - /* - var rowArray = new Array; - for (var i=0; i<4; i++) - { - rtnMat.push( numArray[i] ); - var row = new Array; - row.push( Number(numArray[i ]) ); - row.push( Number(numArray[i+ 4]) ); - row.push( Number(numArray[i+ 8]) ); - row.push( Number(numArray[i+12]) ); - rowArray.push( row ); - } - rtnMat = Matrix.create( rowArray ); - */ - } - } - } - } - - return rtnMat; - } - }, - pushViewportObj: { value: function( obj ) { this._viewportObjStack.push( this.m_viewportObj ); diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 4f1082f9..f611052b 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -94,7 +94,7 @@ exports.NJUtils = Object.create(Object.prototype, { ///// TODO: find a different place for this function makeElementModel: { value: function(el, selection, controller, isShape) { - var p3d = Montage.create(Properties3D).init(el); + var p3d = Montage.create(Properties3D).init(el, (selection === "Stage")); var shapeProps = null; if(isShape) { shapeProps = Montage.create(ShapeModel); diff --git a/js/models/properties-3d.js b/js/models/properties-3d.js index 0f82dc48..087e794f 100755 --- a/js/models/properties-3d.js +++ b/js/models/properties-3d.js @@ -5,7 +5,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot */ var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; + Component = require("montage/ui/component").Component, + NJUtils = require("js/lib/NJUtils").NJUtils; exports.Properties3D = Montage.create(Component, { @@ -39,16 +40,7 @@ exports.Properties3D = Montage.create(Component, { elementPlane : { value : null, enumerable: true}, init : { - value : function(elt) { - - this.m_azimuth = 0.0; - this.m_altitude = 0.0; - - this.m_endAzimuth = 0.0; - this.m_endAltitude = 0.0; - - this.m_transformCtr = null; - this.perspectiveDist = 1400; + value : function(elt, isStage) { // this.m_upVector = [0,1,0]; // this.m_viewDir = [0,0,1]; @@ -57,23 +49,29 @@ exports.Properties3D = Montage.create(Component, { // this.m_targetPos = [0,0,0]; // this.m_objStartPos = [0,0,0]; -// var mat = this.application.ninja.stage.stageDeps.viewUtils.getMatrixFromElement(elt).slice(0); -// var elt3DInfo = MathUtils.decomposeMatrix2(mat); -// if(elt3DInfo) -// { -// this.xAngle = ~~(elt3DInfo.rotation[0] * MathUtils.RAD_TO_DEG); -// this.yAngle = ~~(elt3DInfo.rotation[1] * MathUtils.RAD_TO_DEG); -// this.zAngle = ~~(elt3DInfo.rotation[2] * MathUtils.RAD_TO_DEG); -// -// this.x3D = ~~(elt3DInfo.translation[0]); -// this.y3D = ~~(elt3DInfo.translation[1]); -// this.z3D = ~~(elt3DInfo.translation[2]); -// -// this.matrix3d = mat; -// } + this.matrix3d = this.application.ninja.stylesController.getMatrixFromElement(elt, isStage); + this.perspectiveDist = this.application.ninja.stylesController.getPerspectiveDistFromElement(elt, isStage); - return this; + if(this.matrix3d) { + var elt3DInfo = MathUtils.decomposeMatrix2(this.matrix3d); + if(elt3DInfo) { + this.xAngle = ~~(elt3DInfo.rotation[0] * MathUtils.RAD_TO_DEG); + this.yAngle = ~~(elt3DInfo.rotation[1] * MathUtils.RAD_TO_DEG); + this.zAngle = ~~(elt3DInfo.rotation[2] * MathUtils.RAD_TO_DEG); + this.x3D = ~~(elt3DInfo.translation[0]); + this.y3D = ~~(elt3DInfo.translation[1]); + this.z3D = ~~(elt3DInfo.translation[2]); + } + } else { + this.matrix3d = Matrix.I(4); + } + + if(this.perspectiveDist === null) { + this.perspectiveDist = 1400; + } + + return this; } }, -- cgit v1.2.3 From 3987b73569e58843f2a91c0c6c4e4132f51ac247 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 21 Mar 2012 17:13:56 -0700 Subject: Do not set webkit-transform styles on elements unless 3d is used on them. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 2 +- js/lib/NJUtils.js | 5 ++- js/mediators/element-mediator.js | 9 +++-- js/tools/SelectionTool.js | 47 +++++++++++++++------------ js/tools/TagTool.js | 15 ++++----- js/tools/drawing-tool-base.js | 2 +- 6 files changed, 45 insertions(+), 35 deletions(-) diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 4f360bb9..9cba6d94 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -244,7 +244,7 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, else { var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false); - if(dist === null) { + if(dist == null) { dist = 1400; } diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index f611052b..cb877591 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -94,7 +94,10 @@ exports.NJUtils = Object.create(Object.prototype, { ///// TODO: find a different place for this function makeElementModel: { value: function(el, selection, controller, isShape) { - var p3d = Montage.create(Properties3D).init(el, (selection === "Stage")); + var p3d = Montage.create(Properties3D); + if(selection === "Stage") { + p3d.init(el, true); + } var shapeProps = null; if(isShape) { shapeProps = Montage.create(ShapeModel); diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index d62fa1f8..eac0ca54 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -90,9 +90,12 @@ exports.ElementMediator = Montage.create(NJComponent, { _addElement: { value: function(el, rules, noEvent) { ElementController.addElement(el, rules); - var p3d = this.get3DProperties(el); - if(p3d) { - el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); +// var p3d = this.get3DProperties(el); +// if(p3d) { +// el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); +// } + if(el.elementModel && el.elementModel.props3D) { + el.elementModel.props3D.init(el, false); } if(!noEvent) { this.application.ninja.documentController.activeDocument.needsSave = true; diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index f9411f48..e252e36b 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -318,18 +318,28 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); if(addToUndoStack) { + var prevX, + prevY, + prevW, + prevH, + _x, + _y, + _w, + _h, + previousMat, + previousStyleStr, + newStyleStr; if(!this._use3DMode) { - var previousMat = this._undoArray[i].mat.slice(0); - var prevX = this._undoArray[i]._x; - var prevY = this._undoArray[i]._y; - var prevW = this._undoArray[i]._w; - var prevH = this._undoArray[i]._h; - var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; - var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; - var _w = parseInt(ElementsMediator.getProperty(elt, "width")); - var _h = parseInt(ElementsMediator.getProperty(elt, "height")); + prevX = this._undoArray[i]._x; + prevY = this._undoArray[i]._y; + prevW = this._undoArray[i]._w; + prevH = this._undoArray[i]._h; + _x = parseInt(ElementsMediator.getProperty(elt, "left")); + _y = parseInt(ElementsMediator.getProperty(elt, "top")); + _w = parseInt(ElementsMediator.getProperty(elt, "width")); + _h = parseInt(ElementsMediator.getProperty(elt, "height")); previousLeft.push(prevX + "px"); previousTop.push(prevY + "px"); @@ -339,27 +349,22 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { newTop.push(_y + "px"); newWidth.push(_w + "px"); newHeight.push(_h + "px"); - - viewUtils.setMatrixForElement(elt, previousMat); - - this._targets[i].mat = previousMat; - this._targets[i].matInv = glmat4.inverse(previousMat, []); } else { - var previousMat = this._undoArray[i].mat.slice(0); - var prevW = this._undoArray[i]._w; - var prevH = this._undoArray[i]._h; - var _w = parseInt(ElementsMediator.getProperty(elt, "width")); - var _h = parseInt(ElementsMediator.getProperty(elt, "height")); + previousMat = this._undoArray[i].mat.slice(0); + prevW = this._undoArray[i]._w; + prevH = this._undoArray[i]._h; + _w = parseInt(ElementsMediator.getProperty(elt, "width")); + _h = parseInt(ElementsMediator.getProperty(elt, "height")); previousWidth.push(prevW + "px"); previousHeight.push(prevH + "px"); newWidth.push(_w + "px"); newHeight.push(_h + "px"); - var previousStyleStr = {dist:this._undoArray[i].dist, + previousStyleStr = {dist:this._undoArray[i].dist, mat:MathUtils.scientificToDecimal(previousMat, 5)}; - var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), + newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), mat:MathUtils.scientificToDecimal(curMat, 5)}; previousStyles.push(previousStyleStr); newStyles.push(newStyleStr); diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index e3f49bbe..6df49a7b 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js @@ -222,21 +222,20 @@ exports.TagTool = Montage.create(DrawingTool, { makeElement: { value: function(w, h, planeMat, midPt,tag) { - var styles; - var left = Math.round(midPt[0] - 0.5 * w); var top = Math.round(midPt[1] - 0.5 * h); - var matStr = DrawingToolBase.getElementMatrix(planeMat, midPt); - - styles = { + var styles = { 'position': 'absolute', 'top' : top + 'px', - 'left' : left + 'px', - '-webkit-transform-style' : 'preserve-3d', - '-webkit-transform' : matStr + 'left' : left + 'px' }; + if(!MathUtils.isIdentityMatrix(planeMat)) { + styles['-webkit-transform-style'] = 'preserve-3d'; + styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(planeMat, midPt); + } + // TODO - for canvas, set both as style and attribute. // Otherwise, we need to create a separate controller for canvas elements if(tag.tagName === "CANVAS") { diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 8d87605c..84602186 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -442,7 +442,7 @@ exports.DrawingToolBase = Montage.create(Montage, { flatMat = divMat; flatMatSafe = MathUtils.scientificToDecimal(flatMat, 10); - return "perspective(" + 1400 + ") matrix3d( " + flatMatSafe + ")"; + return "perspective(" + 1400 + ") matrix3d(" + flatMatSafe + ")"; } }, -- cgit v1.2.3 From 92854b266936f844370688da3b15d035a041e8c2 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 11:10:29 -0700 Subject: Translation handles do not redraw at correct location when double-clicking to reset. Signed-off-by: Nivesh Rajbhandari --- js/tools/Translate3DToolBase.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 07b6d04d..b7bce2be 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -126,8 +126,11 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, this.isDrawing = false; this.endDraw(event); -// this.UpdateSelection(true); - this.Configure(true); + + // Need to force stage to draw immediately so the new selection center is calculated + this.application.ninja.stage.draw(); + // And captureSelectionDrawn to draw the transform handles + this.captureSelectionDrawn(null); } }, -- cgit v1.2.3 From bead8ce9e292f030a4b2fba6ad7fd38fb4fe5199 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 11:16:39 -0700 Subject: IKNINJA-758 - The rotation value of the stage is not updated in the properties panel. Signed-off-by: Nivesh Rajbhandari --- js/mediators/element-mediator.js | 6 +++--- js/panels/properties.reel/properties.js | 15 +++++++++++++-- js/tools/RotateStage3DTool.js | 5 +++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index eac0ca54..a2440fb4 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -673,17 +673,17 @@ exports.ElementMediator = Montage.create(NJComponent, { }, setMatrix: { - value: function(el, mat, isChanging) { + value: function(el, mat, isChanging, source) { var dist = el.elementModel.controller["getPerspectiveDist"](el); el.elementModel.controller["set3DProperties"](el, [{mat:mat, dist:dist}], 0, !isChanging); if(isChanging) { - NJevent("elementChanging", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); + NJevent("elementChanging", {type : "setMatrix", source: source, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); } else { - NJevent("elementChange", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); + NJevent("elementChange", {type : "setMatrix", source: source, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); } } }, diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 40e9b86a..782dd138 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -147,8 +147,12 @@ exports.Properties = Montage.create(Component, { value: function(event) { // console.log("Element Change PI ", event.detail.source); // If the event comes from the pi don't need to update if(event.detail.source && event.detail.source !== "pi") { + var el = this.application.ninja.currentDocument.documentRoot; + if(this.application.ninja.selectedElements.length) { + el = this.application.ninja.selectedElements[0]._element || this.application.ninja.selectedElements[0]; + } + // TODO - This should only update the properties that were changed. - var el = this.application.ninja.selectedElements[0]._element || this.application.ninja.selectedElements[0]; this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); @@ -162,9 +166,9 @@ exports.Properties = Montage.create(Component, { this.threeD.xAngle = ElementsMediator.get3DProperty(el, "xAngle"); this.threeD.yAngle = ElementsMediator.get3DProperty(el, "yAngle"); this.threeD.zAngle = ElementsMediator.get3DProperty(el, "zAngle"); + } } } - } }, handleSelectionChange: { @@ -196,6 +200,13 @@ exports.Properties = Montage.create(Component, { this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(stage, "height")); this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(stage, "width")); + if(this.threeD.inGlobalMode) + { + this.threeD.xAngle = ElementsMediator.get3DProperty(stage, "xAngle"); + this.threeD.yAngle = ElementsMediator.get3DProperty(stage, "yAngle"); + this.threeD.zAngle = ElementsMediator.get3DProperty(stage, "zAngle"); + } + if(this.customPi !== stage.elementModel.pi) { // We need to unregister color chips from the previous selection from the Color Model var len = this.customSections.length; diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index 2b312e53..f5cc4040 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -76,7 +76,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { this._targets.push({elt:elt, mat:curMat, matInv:curMatInv, ctr:eltCtr}); - viewUtils.setMatrixForElement( elt, curMat, false ); + ElementsMediator.setMatrix(elt, curMat, false, "rotateStage3DTool"); } }, @@ -130,7 +130,8 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { // Reset stage to identity matrix var iMat = Matrix.I(4); - ElementsMediator.setMatrix(this.application.ninja.currentDocument.documentRoot, iMat, false); + ElementsMediator.setMatrix(this.application.ninja.currentDocument.documentRoot, + iMat, false, "rotateStage3DTool"); this.application.ninja.currentDocument.documentRoot.elementModel.props3D.m_transformCtr = null; // let the document and stage manager know about the zoom change -- cgit v1.2.3 From 6965b72f1f42f7280bc5e5e52d08b3d64d106831 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 13:07:48 -0700 Subject: IKNinja-1368 - Moving multiple selection of 2d elements starts changing the objects' relative positions. Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index e252e36b..aec5b6a3 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -465,11 +465,14 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } else { - curMat = item.mat.slice(0); - glmat4.multiply(curMat, qMat, curMat); - var previousMat = this._undoArray[i].mat.slice(0); - var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; - var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; +// curMat = item.mat.slice(0); +// glmat4.multiply(curMat, qMat, curMat); +// var previousMat = this._undoArray[i].mat.slice(0); +// var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; +// var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; + + var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12]; + var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13]; newLeft.push(_x + "px"); newTop.push(_y + "px"); @@ -582,6 +585,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { { // form the translation vector and post translate the matrix by it. delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); + delta[0] = ~~delta[0]; + delta[1] = ~~delta[1]; delta[2] = 0; var transMat = Matrix.Translation( delta ); this._moveElements(transMat); -- cgit v1.2.3 From 636014cf5d824909993d7dc3510fbe6ce2fc72f1 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 14:24:46 -0700 Subject: WebGL needs to have 3d styles to render. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 1 + js/tools/BrushTool.js | 2 +- js/tools/LineTool.js | 2 +- js/tools/PenTool.js | 2 +- js/tools/ShapeTool.js | 4 +--- js/tools/TagTool.js | 4 +++- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 9b0159d4..689bc421 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -495,6 +495,7 @@ exports.ShapesController = Montage.create(CanvasController, { world = new World(el, true); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = true; + el.elementModel.controller.setProperty(el, "-webkit-transform-style", "preserve-3d"); world.import(worldData, true); el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 4ce9976a..ac29f2f2 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js @@ -252,7 +252,7 @@ exports.BrushTool = Montage.create(ShapeTool, { if (!canvas) { var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); + var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas, this._useWebGL); ElementMediator.addElement(newCanvas, elementModel.data, true); // create all the GL stuff diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index a61f8f79..a1cf7eb0 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -89,7 +89,7 @@ exports.LineTool = Montage.create(ShapeTool, { } canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas); + var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas, this.options.use3D); ElementMediator.addElement(canvas, elementModel.data, true); canvas.elementModel.isShape = true; diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 60ef4f92..17756772 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -584,7 +584,7 @@ exports.PenTool = Montage.create(ShapeTool, { if (!canvas) { var newCanvas = null; newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas); + var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas, this._useWebGL); ElementMediator.addElement(newCanvas, elementModel.data, true); // create all the GL stuff diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index d3a36163..2124376d 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -6,8 +6,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, DrawingTool = require("js/tools/drawing-tool").DrawingTool, - viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, - drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, NJUtils = require("js/lib/NJUtils").NJUtils, ElementMediator = require("js/mediators/element-mediator").ElementMediator, ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, @@ -70,7 +68,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { { canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, - drawData.planeMat, drawData.midPt, canvas); + drawData.planeMat, drawData.midPt, canvas, this.options.use3D); ElementMediator.addElement(canvas, elementModel.data, true); canvas.elementModel.isShape = true; diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index 6df49a7b..2b6742e6 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js @@ -221,7 +221,7 @@ exports.TagTool = Montage.create(DrawingTool, { }, makeElement: { - value: function(w, h, planeMat, midPt,tag) { + value: function(w, h, planeMat, midPt,tag, isWebGl) { var left = Math.round(midPt[0] - 0.5 * w); var top = Math.round(midPt[1] - 0.5 * h); @@ -234,6 +234,8 @@ exports.TagTool = Montage.create(DrawingTool, { if(!MathUtils.isIdentityMatrix(planeMat)) { styles['-webkit-transform-style'] = 'preserve-3d'; styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(planeMat, midPt); + } else if(isWebGl) { + styles['-webkit-transform-style'] = 'preserve-3d'; } // TODO - for canvas, set both as style and attribute. -- cgit v1.2.3 From 1b7e627ae290dacec3a242445f3e6c5de302626a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 23 Mar 2012 10:51:26 -0700 Subject: Tweaking some styles in the materials popup. Signed-off-by: Nivesh Rajbhandari --- js/components/ui/color-chip.reel/color-chip.js | 2 + js/components/ui/input-group.reel/input-group.css | 15 ++++++- .../materials-popup.reel/materials-popup.css | 46 ++++++++++++++++++---- .../materials-popup.reel/materials-popup.html | 2 +- .../materials-popup.reel/materials-popup.js | 2 +- 5 files changed, 57 insertions(+), 10 deletions(-) diff --git a/js/components/ui/color-chip.reel/color-chip.js b/js/components/ui/color-chip.reel/color-chip.js index 7a7411da..4e64b2e8 100755 --- a/js/components/ui/color-chip.reel/color-chip.js +++ b/js/components/ui/color-chip.reel/color-chip.js @@ -56,6 +56,8 @@ var ColorChip = exports.ColorChip = Montage.create(Component, { if(this.hasIcon) { var icon = this.iconType || this.mode + "Icon"; this.application.ninja.colorController.addButton(icon, this.icon); + } else { + this.icon.style.display = "none"; } this.chipBtn.props = {side: 'right', align: 'top', wheel: true, palette: true, gradient: true, image: true, offset: this.offset}; diff --git a/js/components/ui/input-group.reel/input-group.css b/js/components/ui/input-group.reel/input-group.css index 0b7cd1ef..5707b17e 100755 --- a/js/components/ui/input-group.reel/input-group.css +++ b/js/components/ui/input-group.reel/input-group.css @@ -23,11 +23,24 @@ .propControl .inputRow div .hottext, .propControl .inputRow div .hottextInput, -.prop-controller .nj-skinned +.prop-controller .nj-skinned, +.prop-controller .hottext, +.prop-controller .hottextInput { border: 1px solid black; width: 30px !important; float:left; margin: 2px 0; text-align: center; +} + +.prop-controller .file-path +{ + width: 170px !important; +} + +.propControl .inputRow div.propControl +{ + float:left; + margin: 2px 0; } \ No newline at end of file diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.css b/js/panels/Materials/materials-popup.reel/materials-popup.css index 89233c64..2d339411 100755 --- a/js/panels/Materials/materials-popup.reel/materials-popup.css +++ b/js/panels/Materials/materials-popup.reel/materials-popup.css @@ -37,21 +37,53 @@ .mp_property { height:40px; + position: relative; } .mp_property > .prop-label { - float: left; - /*width:86px;*/ - margin: 0px 8px 2px 5px; + position:relative; + top:12px; + float: left; + width: 100px; } .mp_property > .prop-controller { - float: right; - clear: left; - width: auto; - margin: 0px 0px 3px 0px; + position:relative; + top:12px; + left: 10px; + float: left; +} + +.mp_property .hottext, +.mp_property .hottextInput +{ + width: 30px; +} + +.mp_property .button +{ + width: 30px; + height: 20px; +} + +.mp_property .inputRow +{ + top: 8px; + position: relative; +} + +.mp_properties_list +{ + padding-bottom: 8px; +} + +.mp_properties_list > .mp_property > .colortoolbar +{ + width: 27px !important; + height: 27px !important; + overflow:hidden !important; } .mp_buttons { diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.html b/js/panels/Materials/materials-popup.reel/materials-popup.html index 34f68554..ae0ee2c8 100755 --- a/js/panels/Materials/materials-popup.reel/materials-popup.html +++ b/js/panels/Materials/materials-popup.reel/materials-popup.html @@ -104,7 +104,7 @@
-
+
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js index b44761bc..bbccf45d 100755 --- a/js/panels/Materials/materials-popup.reel/materials-popup.js +++ b/js/panels/Materials/materials-popup.reel/materials-popup.js @@ -237,7 +237,7 @@ exports.MaterialsPopup = Montage.create(Component, { } else { - this.materialsData = this._dummyData1; + this.materialsData = this._dummyData1.slice(0); } this.needsDraw = true; -- cgit v1.2.3 From bda9f8f5829c943486f8850e68c991e83f8fb8c8 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Sat, 24 Mar 2012 13:50:46 -0700 Subject: Adding logic for flatten checkbox in PI. This requires minor modifications to both StageController and ComponentController. Also removing unused global3DSettings CSS. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/component-controller.js | 2 ++ js/controllers/elements/stage-controller.js | 5 ++++ .../templates/montage-html/default_html.css | 5 ---- js/document/templates/montage-html/index.html | 2 +- js/panels/properties.reel/properties.js | 13 +++++++++- .../sections/three-d-view.reel/three-d-view.html | 28 ++++++++++++++++++++-- .../sections/three-d-view.reel/three-d-view.js | 14 +++++++++++ 7 files changed, 60 insertions(+), 9 deletions(-) diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 83450d0f..fbe9a995 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js @@ -14,6 +14,7 @@ exports.ComponentController = Montage.create(ElementController, { switch(prop) { case "id": case "class": + case "-webkit-transform-style": case "left": case "top": case "width": @@ -34,6 +35,7 @@ exports.ComponentController = Montage.create(ElementController, { switch(p) { case "id": case "class": + case "-webkit-transform-style": case "left": case "top": case "width": diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js index 2734e226..f2c8fa2d 100755 --- a/js/controllers/elements/stage-controller.js +++ b/js/controllers/elements/stage-controller.js @@ -83,6 +83,8 @@ exports.StageController = Montage.create(ElementController, { return el.elementModel.stageDimension.style.getProperty(p); case "width": return el.elementModel.stageDimension.style.getProperty(p); + case "-webkit-transform-style": + return el.elementModel.stageView.style.getProperty(p); default: return ElementController.getProperty(el, p, false, true); //console.log("Undefined Stage property ", p); @@ -111,6 +113,9 @@ exports.StageController = Montage.create(ElementController, { this.application.ninja.currentDocument.iframe.height = parseInt(value) + 400; el.elementModel.stageDimension.style.setProperty(p, value); break; + case "-webkit-transform-style": + el.elementModel.stageView.style.setProperty(p, value); + break; default: console.log("Undefined property ", p, "for the Stage Controller"); } diff --git a/js/document/templates/montage-html/default_html.css b/js/document/templates/montage-html/default_html.css index 68300edf..1cdd7114 100755 --- a/js/document/templates/montage-html/default_html.css +++ b/js/document/templates/montage-html/default_html.css @@ -65,11 +65,6 @@ body display: none; } -.global3DSettings { - -webkit-transform-style: preserve-3d; - -webkit-transform: perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); -} - .elem-red-outline { outline: red solid thin; } \ No newline at end of file diff --git a/js/document/templates/montage-html/index.html b/js/document/templates/montage-html/index.html index edfab2b0..b3f68030 100755 --- a/js/document/templates/montage-html/index.html +++ b/js/document/templates/montage-html/index.html @@ -40,7 +40,7 @@ - + diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 782dd138..ca720ae7 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -166,9 +166,9 @@ exports.Properties = Montage.create(Component, { this.threeD.xAngle = ElementsMediator.get3DProperty(el, "xAngle"); this.threeD.yAngle = ElementsMediator.get3DProperty(el, "yAngle"); this.threeD.zAngle = ElementsMediator.get3DProperty(el, "zAngle"); - } } } + } }, handleSelectionChange: { @@ -207,6 +207,12 @@ exports.Properties = Montage.create(Component, { this.threeD.zAngle = ElementsMediator.get3DProperty(stage, "zAngle"); } + if(ElementsMediator.getProperty(stage, "-webkit-transform-style") === "preserve-3d") { + this.threeD.flatten = false; + } else { + this.threeD.flatten = true; + } + if(this.customPi !== stage.elementModel.pi) { // We need to unregister color chips from the previous selection from the Color Model var len = this.customSections.length; @@ -271,6 +277,11 @@ exports.Properties = Montage.create(Component, { this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); + if(ElementsMediator.getProperty(el, "-webkit-transform-style") === "preserve-3d") { + this.threeD.flatten = false; + } else { + this.threeD.flatten = true; + } if(this.threeD.inGlobalMode) { diff --git a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html index 18a7369e..b6c25baf 100755 --- a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html +++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html @@ -22,7 +22,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "xAngleControl": {"@": "threeDRotX"}, "yAngleControl": {"@": "threeDRotY"}, "zAngleControl": {"@": "threeDRotZ"}, - "axisModeGroupControl": {"@": "axisModeGroup"} + "axisModeGroupControl": {"@": "axisModeGroup"}, + "flattenControl": {"@": "flattenCheckbox"} } }, @@ -242,6 +243,29 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "value": "Global", "group": {"@": "axisModeGroup"} } + }, + "flattenCheckbox": { + "module": "montage/ui/checkbox.reel", + "name": "Checkbox", + "properties": { + "element": {"#": "flattenCh"}, + "identifier": "flatten", + "checked": false + }, + "bindings": { + "checked": { + "boundObject": {"@": "owner"}, + "boundObjectPropertyPath": "flatten", + "oneway": false + } + }, + "listeners": [ + { + "type": "action", + "listener": {"@": "owner"}, + "capture": false + } + ] } } @@ -335,7 +359,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
- +
diff --git a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js index 35591afa..0d3d111d 100755 --- a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js +++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js @@ -79,6 +79,10 @@ exports.ThreeD = Montage.create(Component, { value: 0 }, + flatten: { + value: false + }, + _disableTranslation: { value: true }, @@ -107,6 +111,16 @@ exports.ThreeD = Montage.create(Component, { value: null }, + handleAction: { + value: function(event) { + if(event.currentTarget.identifier === "flatten") { + this.application.ninja.elementMediator.setProperty([this.item], + "-webkit-transform-style", + event.currentTarget.checked ? ["flat"] : ["preserve-3d"]); + } + } + }, + handleChange: { value: function(event) { if(event.wasSetByCode) { -- cgit v1.2.3 From 62438ba52de51bb8ae20de07ec2f4dad55b9a929 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 27 Mar 2012 10:32:26 -0700 Subject: Build elements' properties3d values on file open. Signed-off-by: Nivesh Rajbhandari --- js/lib/NJUtils.js | 3 +++ js/models/properties-3d.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 0457120b..c01d865b 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -182,6 +182,9 @@ exports.NJUtils = Object.create(Object.prototype, { break; } this.makeElementModel(el, selection, controller, isShape); + if(el.elementModel && el.elementModel.props3D) { + el.elementModel.props3D.init(el, (selection === "Stage")); + } } }, diff --git a/js/models/properties-3d.js b/js/models/properties-3d.js index 087e794f..0a7cf8bb 100755 --- a/js/models/properties-3d.js +++ b/js/models/properties-3d.js @@ -67,7 +67,7 @@ exports.Properties3D = Montage.create(Component, { this.matrix3d = Matrix.I(4); } - if(this.perspectiveDist === null) { + if(this.perspectiveDist == null) { this.perspectiveDist = 1400; } -- cgit v1.2.3 From b1eb3f5cc37f6e58e765f24221c3f0445a3ee75a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 27 Mar 2012 10:50:06 -0700 Subject: Check for Viewport case in StageController styles lookup. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/stage-controller.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js index f2c8fa2d..dc916b1a 100755 --- a/js/controllers/elements/stage-controller.js +++ b/js/controllers/elements/stage-controller.js @@ -84,7 +84,11 @@ exports.StageController = Montage.create(ElementController, { case "width": return el.elementModel.stageDimension.style.getProperty(p); case "-webkit-transform-style": - return el.elementModel.stageView.style.getProperty(p); + if(el.id === "Viewport") { + return this.application.ninja.stylesController.getElementStyle(el, p, false, true); + } else { + return el.elementModel.stageView.style.getProperty(p); + } default: return ElementController.getProperty(el, p, false, true); //console.log("Undefined Stage property ", p); -- cgit v1.2.3 From 75e7d29352787ee8182928403ecae09627117d57 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 27 Mar 2012 16:09:51 -0700 Subject: IKNINJA-1378 - Line Tool's drawing preview changes tool canvas's line style. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 00b72490..dd23fbae 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -796,6 +796,8 @@ exports.Stage = Montage.create(Component, { drawLine: { value:function(x0, y0, x1, y1, strokeSize, strokeColor) { this.clearDrawingCanvas(); + var origStrokeStyle = this._drawingContext.strokeStyle; + var origLineWidth = this._drawingContext.lineWidth; this._drawingContext.strokeStyle = strokeColor; this._drawingContext.lineWidth = strokeSize; @@ -826,6 +828,9 @@ exports.Stage = Montage.create(Component, { var w = Math.round(Math.abs(x1-x0)); this._drawingContext.fillText("H: " + h, txtX + 38, txtY - 4); this._drawingContext.fillText("W: " + w, txtX - 5, txtY + 12); + + this._drawingContext.strokeStyle = origStrokeStyle; + this._drawingContext.lineWidth = origLineWidth; } }, -- cgit v1.2.3 From 331ea08655245e3532e48bf160d5f68a04d8723f Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 27 Mar 2012 16:38:52 -0700 Subject: IKNINJA-764 - The Local/Global options are not in synced with both 3D object rotate tool and 3D object translate tool. Signed-off-by: Nivesh Rajbhandari --- js/components/layout/tools-list.reel/tools-list.js | 1 + js/tools/RotateObject3DTool.js | 1 + js/tools/TranslateObject3DTool.js | 11 +++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/js/components/layout/tools-list.reel/tools-list.js b/js/components/layout/tools-list.reel/tools-list.js index 5ea6f70f..d68e8a56 100755 --- a/js/components/layout/tools-list.reel/tools-list.js +++ b/js/components/layout/tools-list.reel/tools-list.js @@ -56,6 +56,7 @@ exports.ToolsList = Montage.create(Component, { this.SubselectionTool.options = this.application.ninja.toolsProperties.subSelectionProperties; this.Rotate3DTool.options = this.application.ninja.toolsProperties.rotate3DProperties; + this.Translate3DTool.options = this.application.ninja.toolsProperties.rotate3DProperties; this.TagTool.options = this.application.ninja.toolsProperties.tagProperties; this.PenTool.options = this.application.ninja.toolsProperties.penProperties; this.TextTool.options = this.application.ninja.toolsProperties.textProperties; diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js index 72af6eff..27352231 100755 --- a/js/tools/RotateObject3DTool.js +++ b/js/tools/RotateObject3DTool.js @@ -51,6 +51,7 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { toolHandle._rotMat = Matrix.RotationZ( angle ); } } + this._inLocalMode = (this.options.selectedMode === "rotateLocally"); } }, diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 60633e74..4fac8187 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -4,15 +4,22 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, +var Montage = require("montage/core/core").Montage, + Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; -exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { +exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { _toolID: { value: "translateObject3DTool" }, _canOperateOnStage: { value: true }, + _initializeToolHandles: { + value: function() { + this._inLocalMode = (this.options.selectedMode === "rotateLocally"); + } + }, + initializeSnapping : { value : function(event) { -- cgit v1.2.3 From 6b61de58f0733b40f64ed996933ac89927e922a1 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 29 Mar 2012 12:01:21 -0700 Subject: We shouldn't set z to 0 for translate tool snapping because user may want to snap in 3d. Signed-off-by: Nivesh Rajbhandari --- js/tools/Translate3DToolBase.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 07b6d04d..005b9749 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -66,10 +66,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, delta[0] = 0; delta[1] = 0; } - else - { - delta[2] = 0; - } this._delta = delta.slice(0); } -- cgit v1.2.3 From 5b4f6b1618cf571a6bce5a631f976a008e04a64e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 29 Mar 2012 15:52:08 -0700 Subject: Updated shapes to always check for its stroke and fill colors and materials instead of relying on the shapeModel cache because it can get out of sync. Signed-off-by: Nivesh Rajbhandari --- js/controllers/el