aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements/element-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/elements/element-controller.js')
-rwxr-xr-xjs/controllers/elements/element-controller.js59
1 files changed, 7 insertions, 52 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index b35251ad..9cba6d94 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