aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-03-21 12:02:36 -0700
committerNivesh Rajbhandari2012-03-21 12:02:36 -0700
commit52fac825174d16e3ff6875fc497d3f3cfaf4812c (patch)
tree16ca0fb16a1b53822cdc02db4c2b878fd6ac3e96 /js/controllers/elements
parent862b0c33de7cdc8865db274d37744058256936e0 (diff)
downloadninja-52fac825174d16e3ff6875fc497d3f3cfaf4812c.tar.gz
Get matrix and perspective distance from styles controller.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-xjs/controllers/elements/element-controller.js59
-rwxr-xr-xjs/controllers/elements/stage-controller.js7
2 files changed, 10 insertions, 56 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,
223 223
224 if (el) 224 if (el)
225 { 225 {
226 var xformStr = this.application.ninja.elementMediator.getProperty(el, "-webkit-transform"); 226 mat = this.application.ninja.stylesController.getMatrixFromElement(el, false);
227 if (xformStr) 227 if (!mat) {
228 mat = this.transformStringToMat( xformStr );
229 if (!mat)
230 mat = Matrix.I(4); 228 mat = Matrix.I(4);
229 }
231 } 230 }
232 231
233 el.elementModel.props3D.matrix3d = mat; 232 el.elementModel.props3D.matrix3d = mat;
@@ -244,23 +243,9 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
244 } 243 }
245 else 244 else
246 { 245 {
247 var dist = 1400; 246 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false);
248 247 if(dist === null) {
249 var str = this.getProperty(el, "-webkit-transform"); 248 dist = 1400;
250 if (str)
251 {
252 var index1 = str.indexOf( "perspective(");
253 if (index1 >= 0)
254 {
255 index1 += 12; // do not include 'perspective('
256 var index2 = str.indexOf( ")", index1 );
257 if (index2 >= 0)
258 {
259 var substr = str.substr( index1, (index2-index1));
260 if (substr && (substr.length > 0))
261 dist = MathUtils.styleToNumber( substr );
262 }
263 }
264 } 249 }
265 250
266 el.elementModel.props3D.perspectiveDist = dist; 251 el.elementModel.props3D.perspectiveDist = dist;
@@ -303,36 +288,6 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
303 elt.elementModel.props3D.z3D = ~~(elt3DInfo.translation[2]); 288 elt.elementModel.props3D.z3D = ~~(elt3DInfo.translation[2]);
304 } 289 }
305 } 290 }
306 },
307
308 transformStringToMat: {
309 value: function( str ) {
310 var rtnMat;
311
312 var index1 = str.indexOf( "matrix3d(");
313 if (index1 >= 0)
314 {
315 index1 += 9; // do not include 'matrix3d('
316 var index2 = str.indexOf( ")", index1 );
317 if (index2 >= 0)
318 {
319 var substr = str.substr( index1, (index2-index1));
320 if (substr && (substr.length > 0))
321 {
322 var numArray = substr.split(',');
323 var nNums = numArray.length;
324 if (nNums == 16)
325 {
326 // gl-matrix wants row order
327 rtnMat = numArray;
328 for (var i=0; i<16; i++)
329 rtnMat[i] = Number( rtnMat[i] );
330 }
331 }
332 }
333 }
334
335 return rtnMat;
336 }
337 } 291 }
292
338}); \ No newline at end of file 293}); \ 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, {
143 143
144 if (el) 144 if (el)
145 { 145 {
146 var xformStr = this.application.ninja.elementMediator.getProperty(el, "-webkit-transform"); 146 mat = this.application.ninja.stylesController.getMatrixFromElement(el, true);
147 if (xformStr) 147 if (!mat) {
148 mat = this.transformStringToMat( xformStr );
149 if (!mat)
150 mat = Matrix.I(4); 148 mat = Matrix.I(4);
149 }
151 150
152 var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom"); 151 var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom");
153 if (zoom) 152 if (zoom)