diff options
Diffstat (limited to 'js/tools')
-rwxr-xr-x | js/tools/Rotate3DToolBase.js | 35 | ||||
-rwxr-xr-x | js/tools/RotateObject3DTool.js | 1 | ||||
-rwxr-xr-x | js/tools/RotateStage3DTool.js | 5 | ||||
-rwxr-xr-x | js/tools/modifier-tool-base.js | 3 |
4 files changed, 30 insertions, 14 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; |
diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js index 27352231..902cf05d 100755 --- a/js/tools/RotateObject3DTool.js +++ b/js/tools/RotateObject3DTool.js | |||
@@ -18,6 +18,7 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, { | |||
18 | 18 | ||
19 | _initializeToolHandles: { | 19 | _initializeToolHandles: { |
20 | value: function() { | 20 | value: function() { |
21 | this.rotateStage = false; | ||
21 | if(!this._handles) | 22 | if(!this._handles) |
22 | { | 23 | { |
23 | this._handles = []; | 24 | this._handles = []; |
diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index adbf1b62..a980bf73 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js | |||
@@ -7,10 +7,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Rotate3DToolBase = require("js/tools/Rotate3DToolBase").Rotate3DToolBase, | 8 | Rotate3DToolBase = require("js/tools/Rotate3DToolBase").Rotate3DToolBase, |
9 | toolHandleModule = require("js/stage/tool-handle"), | 9 | toolHandleModule = require("js/stage/tool-handle"), |
10 | snapManager = require("js/helper-classes/3D/snap-manager").SnapManager, | ||
11 | viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, | 10 | viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, |
12 | vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, | 11 | vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, |
13 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, | ||
14 | ElementsMediator = require("js/mediators/element-mediator").ElementMediator; | 12 | ElementsMediator = require("js/mediators/element-mediator").ElementMediator; |
15 | 13 | ||
16 | exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | 14 | exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { |
@@ -23,6 +21,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | |||
23 | 21 | ||
24 | _initializeToolHandles: { | 22 | _initializeToolHandles: { |
25 | value: function() { | 23 | value: function() { |
24 | this.rotateStage = true; | ||
26 | if(!this._handles) | 25 | if(!this._handles) |
27 | { | 26 | { |
28 | this._handles = []; | 27 | this._handles = []; |
@@ -149,6 +148,6 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | |||
149 | // this.UpdateSelection(true); | 148 | // this.UpdateSelection(true); |
150 | this.Configure(true); | 149 | this.Configure(true); |
151 | } | 150 | } |
152 | } | 151 | } |
153 | 152 | ||
154 | }); | 153 | }); |
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 6de5d06c..8cd21a29 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js | |||
@@ -809,7 +809,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { | |||
809 | if(!this._activateOriginHandle) | 809 | if(!this._activateOriginHandle) |
810 | { | 810 | { |
811 | this.application.ninja.stage.drawNow = true; | 811 | this.application.ninja.stage.drawNow = true; |
812 | var canSnap = this._canSnap; | ||
813 | this._canSnap = true; | ||
812 | this.doSelection(event); | 814 | this.doSelection(event); |
815 | this._canSnap = canSnap; | ||
813 | } | 816 | } |
814 | } | 817 | } |
815 | 818 | ||