aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/elements/component-controller.js2
-rwxr-xr-xjs/controllers/elements/element-controller.js59
-rwxr-xr-xjs/controllers/elements/shapes-controller.js1
-rwxr-xr-xjs/controllers/elements/stage-controller.js12
-rwxr-xr-xjs/controllers/styles-controller.js66
5 files changed, 83 insertions, 57 deletions
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 260ee8a0..d902e4a1 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -16,6 +16,7 @@ exports.ComponentController = Montage.create(ElementController, {
16 switch(prop) { 16 switch(prop) {
17 case "id": 17 case "id":
18 case "class": 18 case "class":
19 case "-webkit-transform-style":
19 case "left": 20 case "left":
20 case "top": 21 case "top":
21 case "width": 22 case "width":
@@ -38,6 +39,7 @@ exports.ComponentController = Montage.create(ElementController, {
38 switch(p) { 39 switch(p) {
39 case "id": 40 case "id":
40 case "class": 41 case "class":
42 case "-webkit-transform-style":
41 case "left": 43 case "left":
42 case "top": 44 case "top":
43 case "width": 45 case "width":
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
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 5b9e4672..3f8f27d3 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -511,6 +511,7 @@ exports.ShapesController = Montage.create(CanvasController, {
511 world = new World(el, true); 511 world = new World(el, true);
512 el.elementModel.shapeModel.GLWorld = world; 512 el.elementModel.shapeModel.GLWorld = world;
513 el.elementModel.shapeModel.useWebGl = true; 513 el.elementModel.shapeModel.useWebGl = true;
514 el.elementModel.controller.setProperty(el, "-webkit-transform-style", "preserve-3d");
514 world.importJSON(worldData); 515 world.importJSON(worldData);
515 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); 516 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
516 517
diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js
index 97ea3aa5..f2c8fa2d 100755
--- a/js/controllers/elements/stage-controller.js
+++ b/js/controllers/elements/stage-controller.js
@@ -83,6 +83,8 @@ exports.StageController = Montage.create(ElementController, {
83 return el.elementModel.stageDimension.style.getProperty(p); 83 return el.elementModel.stageDimension.style.getProperty(p);
84 case "width": 84 case "width":
85 return el.elementModel.stageDimension.style.getProperty(p); 85 return el.elementModel.stageDimension.style.getProperty(p);
86 case "-webkit-transform-style":
87 return el.elementModel.stageView.style.getProperty(p);
86 default: 88 default:
87 return ElementController.getProperty(el, p, false, true); 89 return ElementController.getProperty(el, p, false, true);
88 //console.log("Undefined Stage property ", p); 90 //console.log("Undefined Stage property ", p);
@@ -111,6 +113,9 @@ exports.StageController = Montage.create(ElementController, {
111 this.application.ninja.currentDocument.iframe.height = parseInt(value) + 400; 113 this.application.ninja.currentDocument.iframe.height = parseInt(value) + 400;
112 el.elementModel.stageDimension.style.setProperty(p, value); 114 el.elementModel.stageDimension.style.setProperty(p, value);
113 break; 115 break;
116 case "-webkit-transform-style":
117 el.elementModel.stageView.style.setProperty(p, value);
118 break;
114 default: 119 default:
115 console.log("Undefined property ", p, "for the Stage Controller"); 120 console.log("Undefined property ", p, "for the Stage Controller");
116 } 121 }
@@ -143,11 +148,10 @@ exports.StageController = Montage.create(ElementController, {
143 148
144 if (el) 149 if (el)
145 { 150 {
146 var xformStr = this.application.ninja.elementMediator.getProperty(el, "-webkit-transform"); 151 mat = this.application.ninja.stylesController.getMatrixFromElement(el, true);
147 if (xformStr) 152 if (!mat) {
148 mat = this.transformStringToMat( xformStr );
149 if (!mat)
150 mat = Matrix.I(4); 153 mat = Matrix.I(4);
154 }
151 155
152 var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom"); 156 var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom");
153 if (zoom) 157 if (zoom)
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index addfc24e..5d5f27ba 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -836,7 +836,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
836 ///// For a given CSSKeyframesRule, we may add styles to the keyframe at 836 ///// For a given CSSKeyframesRule, we may add styles to the keyframe at
837 ///// given index. 837 ///// given index.
838 838
839 setKeyframeStyle : { 839 setKeyframeStyles : {
840 value : function(rule, keyframeIndex, property, value, useImportant) { 840 value : function(rule, keyframeIndex, property, value, useImportant) {
841 return this.setStyles(rule.cssRules[keyframeIndex], property, value, useImportant); 841 return this.setStyles(rule.cssRules[keyframeIndex], property, value, useImportant);
842 } 842 }
@@ -1124,6 +1124,70 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1124 } 1124 }
1125 }, 1125 },
1126 1126
1127 ///// Get Matrix From Element
1128 ///// Returns the matrix from an element's -webkit-transform
1129 //// TODO - This routine should eventually check for other transform styles, i.e., rotateX, translateZ, etc.
1130
1131 getMatrixFromElement : {
1132 value: function(element, isStage) {
1133 var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage),
1134 mat;
1135
1136 if (xformStr) {
1137 var index1 = xformStr.indexOf( "matrix3d(");
1138 if (index1 >= 0) {
1139 index1 += 9; // do not include 'matrix3d('
1140 var index2 = xformStr.indexOf( ")", index1 );
1141 if (index2 >= 0) {
1142 var substr = xformStr.substr( index1, (index2-index1));
1143 if (substr && (substr.length > 0)) {
1144 var numArray = substr.split(',');
1145 var nNums = numArray.length;
1146 if (nNums == 16) {
1147 // gl-matrix wants row order
1148 mat = numArray;
1149 for (var i=0; i<16; i++) {
1150 mat[i] = Number( mat[i] );