From b88ebb47d82fc1ffebea49c3bf182aaf3c9419af Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 15:53:11 -0800 Subject: Fixed issue with elements not drawing in the correct plane. When first adding an element, force the 3d model to update with the element's webkit transform values. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 59 +++++++++++++-------------- js/mediators/element-mediator.js | 5 +++ js/models/properties-3d.js | 4 +- 3 files changed, 36 insertions(+), 32 deletions(-) (limited to 'js') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index f254220c..30469db0 100644 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -127,36 +127,35 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, } else { - // TODO - for now, just return the identity matrix - return Matrix.I(4); -// var mat; -// -// if (elt) -// { -// var xformStr = ElementsMediator.getProperty(elt, "-webkit-transform"); -// if (xformStr) -// mat = this.transformStringToMat( xformStr ); -// if (!mat) -// mat = Matrix.I(4); -// -// if (elt.style && elt.style.zoom) -// { -// var zoom = Number(elt.style.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 ); -// } -// } -// } -// -// elt.elementModel.props3D.matrix3d = mat; -// return mat; + 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; } } }, diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 91b09475..a6f31703 100644 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -92,6 +92,11 @@ 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); + } if(!noEvent) NJevent("elementAdded", el); } }, diff --git a/js/models/properties-3d.js b/js/models/properties-3d.js index 3c809f06..cf4a045f 100644 --- a/js/models/properties-3d.js +++ b/js/models/properties-3d.js @@ -22,7 +22,7 @@ exports.Properties3D = Montage.create(Component, { _world : {value : null, enumerable:true}, // keep a referenceto the GLWorld (if any) // Keep track of 3d properties - matrix3d : {value : [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1], enumerable: true}, + matrix3d : {value : null, enumerable: true}, xAngle : {value : 0, enumerable: true}, yAngle : {value : 0, enumerable: true}, @@ -33,7 +33,7 @@ exports.Properties3D = Montage.create(Component, { z3D : {value : 0, enumerable: true}, //TODO - not sure if this should be part of the tool or stage or a utility - perspectiveDist : { value : 1400, enumerable: true}, + perspectiveDist : { value : null, enumerable: true}, perspectiveMode : { value : null, enumerable: true}, elementPlane : { value : null, enumerable: true}, -- cgit v1.2.3