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.js69
1 files changed, 14 insertions, 55 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index efb33292..2ac84452 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,25 +248,7 @@ 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
254 var str = this.getProperty(el, "-webkit-transform");
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 }
270
271 el.elementModel.props3D.perspectiveDist = dist; 252 el.elementModel.props3D.perspectiveDist = dist;
272 return dist; 253 return dist;
273 } 254 }
@@ -281,9 +262,17 @@ exports.ElementController = Montage.create(Component, {
281 mat = props[index]["mat"]; 262 mat = props[index]["mat"];
282 this.application.ninja.stylesController.setElementStyle(el, 263 this.application.ninja.stylesController.setElementStyle(el,
283 "-webkit-transform", 264 "-webkit-transform",
284 "perspective(" + dist + ") " +
285 "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); 265 "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")");
286 266
267 this.application.ninja.stylesController.setElementStyle(el,
268 "-webkit-transform-style",
269 "preserve-3d");
270
271 // TODO - We don't support perspective on individual elements yet
272// this.application.ninja.stylesController.setElementStyle(el,
273// "-webkit-perspective",
274// dist);
275
287 el.elementModel.props3D.matrix3d = mat; 276 el.elementModel.props3D.matrix3d = mat;
288 el.elementModel.props3D.perspectiveDist = dist; 277 el.elementModel.props3D.perspectiveDist = dist;
289 278
@@ -308,36 +297,6 @@ exports.ElementController = Montage.create(Component, {
308 elt.elementModel.props3D.z3D = ~~(elt3DInfo.translation[2]); 297 elt.elementModel.props3D.z3D = ~~(elt3DInfo.translation[2]);
309 } 298 }
310 } 299 }
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 } 300 }
301
343}); \ No newline at end of file 302}); \ No newline at end of file