diff options
Diffstat (limited to 'js/controllers/elements/element-controller.js')
-rwxr-xr-x | js/controllers/elements/element-controller.js | 59 |
1 files changed, 7 insertions, 52 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index efb33292..fda3a3c5 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -228,11 +228,10 @@ exports.ElementController = Montage.create(Component, { | |||
228 | 228 | ||
229 | if (el) | 229 | if (el) |
230 | { | 230 | { |
231 | var xformStr = this.application.ninja.elementMediator.getProperty(el, "-webkit-transform"); | 231 | mat = this.application.ninja.stylesController.getMatrixFromElement(el, false); |
232 | if (xformStr) | 232 | if (!mat) { |
233 | mat = this.transformStringToMat( xformStr ); | ||
234 | if (!mat) | ||
235 | mat = Matrix.I(4); | 233 | mat = Matrix.I(4); |
234 | } | ||
236 | } | 235 | } |
237 | 236 | ||
238 | el.elementModel.props3D.matrix3d = mat; | 237 | el.elementModel.props3D.matrix3d = mat; |
@@ -249,23 +248,9 @@ exports.ElementController = Montage.create(Component, { | |||
249 | } | 248 | } |
250 | else | 249 | else |
251 | { | 250 | { |
252 | var dist = 1400; | 251 | var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false); |
253 | 252 | if(dist == null) { | |
254 | var str = this.getProperty(el, "-webkit-transform"); | 253 | dist = 1400; |
255 | if (str) | ||
256 | { | ||
257 | var index1 = str.indexOf( "perspective("); | ||
258 | if (index1 >= 0) | ||
259 | { | ||
260 | index1 += 12; // do not include 'perspective(' | ||
261 | var index2 = str.indexOf( ")", index1 ); | ||
262 | if (index2 >= 0) | ||
263 | { | ||
264 | var substr = str.substr( index1, (index2-index1)); | ||
265 | if (substr && (substr.length > 0)) | ||
266 | dist = MathUtils.styleToNumber( substr ); | ||
267 | } | ||
268 | } | ||
269 | } | 254 | } |
270 | 255 | ||
271 | el.elementModel.props3D.perspectiveDist = dist; | 256 | el.elementModel.props3D.perspectiveDist = dist; |
@@ -308,36 +293,6 @@ exports.ElementController = Montage.create(Component, { | |||
308 | elt.elementModel.props3D.z3D = ~~(elt3DInfo.translation[2]); | 293 | elt.elementModel.props3D.z3D = ~~(elt3DInfo.translation[2]); |
309 | } | 294 | } |
310 | } | 295 | } |
311 | }, | ||
312 | |||
313 | transformStringToMat: { | ||
314 | value: function( str ) { | ||
315 | var rtnMat; | ||
316 | |||
317 | var index1 = str.indexOf( "matrix3d("); | ||
318 | if (index1 >= 0) | ||
319 | { | ||
320 | index1 += 9; // do not include 'matrix3d(' | ||
321 | var index2 = str.indexOf( ")", index1 ); | ||
322 | if (index2 >= 0) | ||
323 | { | ||
324 | var substr = str.substr( index1, (index2-index1)); | ||
325 | if (substr && (substr.length > 0)) | ||
326 | { | ||
327 | var numArray = substr.split(','); | ||
328 | var nNums = numArray.length; | ||
329 | if (nNums == 16) | ||
330 | { | ||
331 | // gl-matrix wants row order | ||
332 | rtnMat = numArray; | ||
333 | for (var i=0; i<16; i++) | ||
334 | rtnMat[i] = Number( rtnMat[i] ); | ||
335 | } | ||
336 | } | ||
337 | } | ||
338 | } | ||
339 | |||
340 | return rtnMat; | ||
341 | } | ||
342 | } | 296 | } |
297 | |||
343 | }); \ No newline at end of file | 298 | }); \ No newline at end of file |