aboutsummaryrefslogtreecommitdiff
path: root/js/tools/Rotate3DToolBase.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-04-13 13:37:17 -0700
committerValerio Virgillito2012-04-13 13:37:17 -0700
commit5561e7cc43ae9f7cb9d1217ac02f9f136000e79c (patch)
treec058203a1a2e33385aab2136a32ca6988d015c4f /js/tools/Rotate3DToolBase.js
parent0a5504ebe8ada3ff19ff9bbf4d1ee820e1ba90d1 (diff)
downloadninja-5561e7cc43ae9f7cb9d1217ac02f9f136000e79c.tar.gz
fixed stage rotation
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/tools/Rotate3DToolBase.js')
-rwxr-xr-xjs/tools/Rotate3DToolBase.js35
1 files changed, 24 insertions, 11 deletions
diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js
index 9f23040f..2e121b0b 100755
--- a/js/tools/Rotate3DToolBase.js
+++ b/js/tools/Rotate3DToolBase.js
@@ -21,6 +21,10 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
21 21
22 _inLocalMode: { value: true, enumerable: true }, 22 _inLocalMode: { value: true, enumerable: true },
23 23
24 rotateStage: {
25 value: false
26 },
27
24 drawWithoutSnapping: 28 drawWithoutSnapping:
25 { 29 {
26 value: function(event) 30 value: function(event)
@@ -54,8 +58,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
54 this._origin[0] += dx; 58 this._origin[0] += dx;
55 this._origin[1] += dy; 59 this._origin[1] += dy;
56 60
57 61 if( this.rotateStage || (this.application.ninja.selectedElements.length === 1)) {
58 if(this.application.ninja.selectedElements.length === 1) {
59 this._startOriginArray[0][0] += dx; 62 this._startOriginArray[0][0] += dx;
60 this._startOriginArray[0][1] += dy; 63 this._startOriginArray[0][1] += dy;
61 } 64 }
@@ -128,7 +131,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
128 } 131 }
129 } 132 }
130 133
131 if(this._inLocalMode && (this.application.ninja.selectedElements.length === 1) ) 134 if(this._inLocalMode && (this.application.ninja.selectedElements.length === 1 || this.rotateStage) )
132 { 135 {
133 this._rotateLocally(mat); 136 this._rotateLocally(mat);
134 } 137 }
@@ -144,10 +147,15 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
144 147
145 _rotateLocally: { 148 _rotateLocally: {
146 value: function (rotMat) { 149 value: function (rotMat) {
147 var len = this.application.ninja.selectedElements.length; 150 var selectedElements = this.application.ninja.selectedElements;
151
152 if(this.rotateStage) {
153 selectedElements = [this.application.ninja.currentDocument.documentRoot];
154 }
155 var len = selectedElements.length;
148 for(var i = 0; i < len; i++) { 156 for(var i = 0; i < len; i++) {
149 var elt = this.application.ninja.selectedElements[i].elementModel.getProperty("elt"); 157 var elt = selectedElements[i].elementModel.getProperty("elt");
150 var curMat = this.application.ninja.selectedElements[i].elementModel.getProperty("mat"); 158 var curMat = selectedElements[i].elementModel.getProperty("mat");
151 159
152 // pre-translate by the transformation center 160 // pre-translate by the transformation center
153 var tMat = Matrix.I(4); 161 var tMat = Matrix.I(4);
@@ -171,7 +179,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
171 glmat4.multiply(mat, tMat, mat); 179 glmat4.multiply(mat, tMat, mat);
172 180
173 // while moving, set inline style to improve performance 181 // while moving, set inline style to improve performance
174 viewUtils.setMatrixForElement(this.application.ninja.selectedElements[i], mat, true ); 182 viewUtils.setMatrixForElement(selectedElements[i], mat, true );
175 } 183 }
176 } 184 }
177 }, 185 },
@@ -333,16 +341,21 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
333 return; 341 return;
334 } 342 }
335 343
336 var elt, eltCtr, ctrOffset, matInv; 344 var elt, element, eltCtr, ctrOffset, matInv;
337 345
338 if(this.application.ninja.selectedElements.length === 1) { 346 if(this.rotateStage || (this.application.ninja.selectedElements.length === 1)) {
339 elt = this._target; 347 elt = this._target;
340 348
341 if(shouldUpdateCenter) { 349 if(shouldUpdateCenter) {
342 eltCtr = this.application.ninja.selectedElements[0].elementModel.getProperty("ctr"); 350 if(this.rotateStage) {
351 element = this.application.ninja.currentDocument.documentRoot;
352 } else {
353 element = this.application.ninja.selectedElements[0];
354 }
355 eltCtr = element.elementModel.getProperty("ctr");
343 ctrOffset = vecUtils.vecSubtract(3, this._origin, eltCtr); 356 ctrOffset = vecUtils.vecSubtract(3, this._origin, eltCtr);
344 357
345 matInv = this.application.ninja.selectedElements[0].elementModel.getProperty("matInv"); 358 matInv = element.elementModel.getProperty("matInv");
346 ctrOffset = MathUtils.transformVector(ctrOffset, matInv); 359 ctrOffset = MathUtils.transformVector(ctrOffset, matInv);
347 360
348 elt.elementModel.props3D.m_transformCtr = ctrOffset; 361 elt.elementModel.props3D.m_transformCtr = ctrOffset;