aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/elements/element-controller.js13
-rwxr-xr-xjs/controllers/elements/stage-controller.js20
-rwxr-xr-xjs/controllers/styles-controller.js35
-rwxr-xr-xjs/data/pi/pi-data.js2
-rwxr-xr-xjs/helper-classes/3D/hit-record.js10
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js20
-rwxr-xr-xjs/helper-classes/3D/view-utils.js209
-rwxr-xr-xjs/models/properties-3d.js6
-rwxr-xr-xjs/tools/ShapeTool.js2
-rwxr-xr-xjs/tools/TagTool.js2
-rwxr-xr-xjs/tools/drawing-tool-base.js9
11 files changed, 220 insertions, 108 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index b8411ac0..0f17dd46 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -60,7 +60,7 @@ exports.ElementController = Montage.create(Component, {
60 60
61 for(var property in properties) { 61 for(var property in properties) {
62 this.application.ninja.stylesController.setElementStyle(element, property, properties[property]); 62 this.application.ninja.stylesController.setElementStyle(element, property, properties[property]);
63 } 63 }
64 } 64 }
65 }, 65 },
66 66
@@ -231,10 +231,6 @@ exports.ElementController = Montage.create(Component, {
231 return el.elementModel.props3D.perspectiveDist; 231 return el.elementModel.props3D.perspectiveDist;
232 } else { 232 } else {
233 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false); 233 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false);
234 if(dist == null) {
235 dist = 1400;
236 }
237
238 el.elementModel.props3D.perspectiveDist = dist; 234 el.elementModel.props3D.perspectiveDist = dist;
239 return dist; 235 return dist;
240 } 236 }
@@ -246,7 +242,12 @@ exports.ElementController = Montage.create(Component, {
246 value: function(el, props, index, update3DModel) { 242 value: function(el, props, index, update3DModel) {
247 var dist = props[index]["dist"], 243 var dist = props[index]["dist"],
248 mat = props[index]["mat"]; 244 mat = props[index]["mat"];
249 this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); 245 this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")");
246
247 this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform-style", "preserve-3d");
248
249 // TODO - We don't support perspective on individual elements yet
250// this.application.ninja.stylesController.setElementStyle(el, "-webkit-perspective", dist);
250 251
251 el.elementModel.props3D.matrix3d = mat; 252 el.elementModel.props3D.matrix3d = mat;
252 el.elementModel.props3D.perspectiveDist = dist; 253 el.elementModel.props3D.perspectiveDist = dist;
diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js
index dc916b1a..f376e40f 100755
--- a/js/controllers/elements/stage-controller.js
+++ b/js/controllers/elements/stage-controller.js
@@ -90,7 +90,7 @@ exports.StageController = Montage.create(ElementController, {
90 return el.elementModel.stageView.style.getProperty(p); 90 return el.elementModel.stageView.style.getProperty(p);
91 } 91 }
92 default: 92 default:
93 return ElementController.getProperty(el, p, false, true); 93 return ElementController.getProperty(el, p, true, true);
94 //console.log("Undefined Stage property ", p); 94 //console.log("Undefined Stage property ", p);
95 } 95 }
96 } 96 }
@@ -119,6 +119,7 @@ exports.StageController = Montage.create(ElementController, {
119 break; 119 break;
120 case "-webkit-transform-style": 120 case "-webkit-transform-style":
121 el.elementModel.stageView.style.setProperty(p, value); 121 el.elementModel.stageView.style.setProperty(p, value);
122 this.application.ninja.stage.updatedStage = true;
122 break; 123 break;
123 default: 124 default:
124 console.log("Undefined property ", p, "for the Stage Controller"); 125 console.log("Undefined property ", p, "for the Stage Controller");
@@ -178,5 +179,20 @@ exports.StageController = Montage.create(ElementController, {
178 return mat; 179 return mat;
179 } 180 }
180 } 181 }
181 } 182 },
183
184 getPerspectiveDist: {
185 value: function(el) {
186 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist)
187 {
188 return el.elementModel.props3D.perspectiveDist;
189 }
190 else
191 {
192 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, true);
193 el.elementModel.props3D.perspectiveDist = dist;
194 return dist;
195 }
196 }
197 },
182}); 198});
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 5d5f27ba..ec4314f9 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -1130,7 +1130,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1130 1130
1131 getMatrixFromElement : { 1131 getMatrixFromElement : {
1132 value: function(element, isStage) { 1132 value: function(element, isStage) {
1133 var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage), 1133 var xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage),
1134 mat; 1134 mat;
1135 1135
1136 if (xformStr) { 1136 if (xformStr) {
@@ -1163,26 +1163,29 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1163 1163
1164 getPerspectiveDistFromElement : { 1164 getPerspectiveDistFromElement : {
1165 value: function(element, isStage) { 1165 value: function(element, isStage) {
1166 var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage), 1166 var xformStr = this.getElementStyle(element, "-webkit-perspective", false, isStage),
1167 dist; 1167 dist;
1168 1168
1169 if (xformStr) { 1169 if(xformStr) {
1170 var index1 = xformStr.indexOf( "perspective("); 1170 dist = parseInt(xformStr);
1171 if (index1 >= 0) { 1171 } else {
1172 index1 += 12; // do not include 'perspective(' 1172 xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage);
1173 var index2 = xformStr.indexOf( ")", index1 ); 1173 if (xformStr) {
1174 if (index2 >= 0) { 1174 var index1 = xformStr.indexOf( "perspective(");
1175 var substr = xformStr.substr( index1, (index2-index1)); 1175 if (index1 >= 0) {
1176 if (substr && (substr.length > 0)) { 1176 index1 += 12; // do not include 'perspective('
1177 dist = parseInt( substr ); 1177 var index2 = xformStr.indexOf( ")", index1 );
1178 if (index2 >= 0) {
1179 var substr = xformStr.substr( index1, (index2-index1));
1180 if (substr && (substr.length > 0)) {
1181 dist = parseInt( substr );
1182 }
1178 } 1183 }
1179 } 1184 }
1180 } 1185 }
1181 } else { 1186 }
1182 xformStr = this.getElementStyle(element, "-webkit-perspective", false, isStage); 1187 if(isNaN(dist)) {
1183 if(xformStr) { 1188 dist = null;
1184 dist = parseInt(xformStr);
1185 }
1186 } 1189 }
1187 return dist; 1190 return dist;
1188 } 1191 }
diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js
index 07017f09..157c54ec 100755
--- a/js/data/pi/pi-data.js
+++ b/js/data/pi/pi-data.js
@@ -131,6 +131,8 @@ exports.PiData = Montage.create( Montage, {
131 type : "hottext", 131 type : "hottext",
132 id : "borderWidth", 132 id : "borderWidth",
133 prop : "border-width", 133 prop : "border-width",
134 defaultValue: 0,
135 valueMutator: parseFloat,
134 label : "Border", 136 label : "Border",
135 min : 0, 137 min : 0,
136 max : 100, 138 max : 100,
diff --git a/js/helper-classes/3D/hit-record.js b/js/helper-classes/3D/hit-record.js
index 2c60adc6..265bf2a4 100755
--- a/js/helper-classes/3D/hit-record.js
+++ b/js/helper-classes/3D/hit-record.js
@@ -232,7 +232,15 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
232 var elt = this.getElt(); 232 var elt = this.getElt();
233 viewUtils.pushViewportObj( elt ); 233 viewUtils.pushViewportObj( elt );
234 var viewPt = viewUtils.screenToView( scrPt[0], scrPt[1], scrPt[2] ); 234 var viewPt = viewUtils.screenToView( scrPt[0], scrPt[1], scrPt[2] );
235 var eyePt = viewUtils.getEyePoint(); 235 var eyePt;
236 if(viewUtils.getPerspectiveDistFromElement(elt))
237 {
238 eyePt = viewUtils.getEyePoint();
239 }
240 else
241 {
242 eyePt = [viewPt[0], viewPt[1], 1400];
243 }
236 var projPt = MathUtils.vecIntersectPlane( eyePt, MathUtils.vecSubtract(viewPt,eyePt), plane ); 244 var projPt = MathUtils.vecIntersectPlane( eyePt, MathUtils.vecSubtract(viewPt,eyePt), plane );
237 245
238 return projPt; 246 return projPt;
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index a401c363..02e81a62 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -229,7 +229,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
229 parentPt = [quadPt[0], quadPt[1], 0.0]; 229 parentPt = [quadPt[0], quadPt[1], 0.0];
230 else 230 else
231 parentPt = [xScreen, yScreen, 0.0]; 231 parentPt = [xScreen, yScreen, 0.0];
232 var vec = viewUtils.parentToChildVec(parentPt, stage); 232
233 var eyePt = [];
234 var vec = viewUtils.parentToChildVec(parentPt, stage, eyePt);
233 if (vec) 235 if (vec)
234 { 236 {
235 // activate the drag working plane 237 // activate the drag working plane
@@ -241,7 +243,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
241 var wp = currentWorkingPlane.slice(0); 243 var wp = currentWorkingPlane.slice(0);
242 var mat = viewUtils.getMatrixFromElement(stage); 244 var mat = viewUtils.getMatrixFromElement(stage);
243 wp = MathUtils.transformPlane(wp, mat); 245 wp = MathUtils.transformPlane(wp, mat);