diff options
Diffstat (limited to 'js/tools/Translate3DToolBase.js')
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 430 |
1 files changed, 215 insertions, 215 deletions
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 00408b6e..3e6f2ac6 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js | |||
@@ -41,16 +41,16 @@ var Montage = require("montage/core/core").Montage, | |||
41 | 41 | ||
42 | exports.Translate3DToolBase = Montage.create(ModifierToolBase, | 42 | exports.Translate3DToolBase = Montage.create(ModifierToolBase, |
43 | { | 43 | { |
44 | _inLocalMode: { value: true, enumerable: true }, | 44 | _inLocalMode: { value: true, enumerable: true }, |
45 | _clickedOnStage: { value: false }, | 45 | _clickedOnStage: { value: false }, |
46 | 46 | ||
47 | HandleDoubleClick : { | 47 | HandleDoubleClick : { |
48 | value : function() { | 48 | value : function() { |
49 | } | 49 | } |
50 | }, | 50 | }, |
51 | 51 | ||
52 | modifyElements : { | 52 | modifyElements : { |
53 | value : function(data, event) | 53 | value : function(data, event) |
54 | { | 54 | { |
55 | //console.log( "modifyElements, data: " + data.pt0 + " => " + data.pt1 ); | 55 | //console.log( "modifyElements, data: " + data.pt0 + " => " + data.pt1 ); |
56 | 56 | ||
@@ -94,7 +94,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
94 | this._delta = delta.slice(0); | 94 | this._delta = delta.slice(0); |
95 | } | 95 | } |
96 | 96 | ||
97 | //console.log( "modifyElements delta: " + delta ); | 97 | //console.log( "modifyElements delta: " + delta ); |
98 | var transMat = Matrix.Translation( delta ); | 98 | var transMat = Matrix.Translation( delta ); |
99 | 99 | ||
100 | //console.log( "Translate: " + delta ); | 100 | //console.log( "Translate: " + delta ); |
@@ -107,11 +107,11 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
107 | this._translateGlobally(transMat); | 107 | this._translateGlobally(transMat); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | }, | 110 | }, |
111 | 111 | ||
112 | 112 | ||
113 | Reset: { | 113 | Reset: { |
114 | value: function() { | 114 | value: function() { |
115 | var mat, iMat, dist, mod3dObject = [], self = this; | 115 | var mat, iMat, dist, mod3dObject = [], self = this; |
116 | 116 | ||
117 | this.application.ninja.selectedElements.forEach(function(element) { | 117 | this.application.ninja.selectedElements.forEach(function(element) { |
@@ -133,60 +133,60 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
133 | 133 | ||
134 | ElementsMediator.set3DProperties(mod3dObject, "Change", "rotateTool"); | 134 | ElementsMediator.set3DProperties(mod3dObject, "Change", "rotateTool"); |
135 | 135 | ||
136 | this.isDrawing = false; | 136 | this.isDrawing = false; |
137 | this.endDraw(event); | 137 | this.endDraw(event); |
138 | 138 | ||
139 | // Need to force stage to draw immediately so the new selection center is calculated | 139 | // Need to force stage to draw immediately so the new selection center is calculated |
140 | this.application.ninja.stage.draw(); | 140 | this.application.ninja.stage.draw(); |
141 | // And captureSelectionDrawn to draw the transform handles | 141 | // And captureSelectionDrawn to draw the transform handles |
142 | this.captureSelectionDrawn(null); | 142 | this.captureSelectionDrawn(null); |
143 | } | 143 | } |
144 | }, | 144 | }, |
145 | 145 | ||
146 | // We will only translate single elements locally | 146 | // We will only translate single elements locally |
147 | _translateLocally: { | 147 | _translateLocally: { |
148 | value: function (transMat) { | 148 | value: function (transMat) { |
149 | //console.log( "_translateLocally, startMat: " + this._startMat ); | 149 | //console.log( "_translateLocally, startMat: " + this._startMat ); |
150 | //console.log( "_translateLocally, transMat: " + transMat ); | 150 | //console.log( "_translateLocally, transMat: " + transMat ); |
151 | //console.log( "_translateLocally, startMat: " + this._startMat + ", transMat: " + transMat ); | 151 | //console.log( "_translateLocally, startMat: " + this._startMat + ", transMat: " + transMat ); |
152 | var mat = glmat4.multiply(this._startMat, transMat, []); | 152 | var mat = glmat4.multiply(this._startMat, transMat, []); |
153 | viewUtils.setMatrixForElement( this._target, mat, true ); | 153 | viewUtils.setMatrixForElement( this._target, mat, true ); |
154 | if(this._mode !== 1) | 154 | if(this._mode !== 1) |
155 | { | 155 | { |
156 | this._startMat = mat; | 156 | this._startMat = mat; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | }, | 159 | }, |
160 | 160 | ||
161 | _translateGlobally: { | 161 | _translateGlobally: { |
162 | value: function (transMat) { | 162 | value: function (transMat) { |
163 | //console.log( "_translateGlobally, transMat: " + transMat ); | 163 | //console.log( "_translateGlobally, transMat: " + transMat ); |
164 | var selectedElements = this.application.ninja.selectedElements; | 164 | var selectedElements = this.application.ninja.selectedElements; |
165 | 165 | ||
166 | var len = selectedElements.length, | 166 | var len = selectedElements.length, |
167 | self = this, | 167 | self = this, |
168 | target = selectedElements[0], | 168 | target = selectedElements[0], |
169 | curMat = viewUtils.getMatrixFromElement( target ), | 169 | curMat = viewUtils.getMatrixFromElement( target ), |
170 | matInv = glmat4.inverse(this._startMat, []), | 170 | matInv = glmat4.inverse(this._startMat, []), |
171 | nMat = glmat4.multiply(transMat, this._startMat, [] ); | 171 | nMat = glmat4.multiply(transMat, this._startMat, [] ); |
172 | // qMat = glmat4.multiply(matInv, nMat, []); | 172 | // qMat = glmat4.multiply(matInv, nMat, []); |
173 | 173 | ||
174 | if(this._mode === 1) { | 174 | if(this._mode === 1) { |
175 | if (len > 1) curMat = target.elementModel.getProperty("mat").slice(); | 175 | if (len > 1) curMat = target.elementModel.getProperty("mat").slice(); |
176 | var curInv = glmat4.inverse( curMat, [] ); | 176 | var curInv = glmat4.inverse( curMat, [] ); |
177 | transMat = glmat4.multiply( nMat, curInv, [] ); | 177 | transMat = glmat4.multiply( nMat, curInv, [] ); |
178 | } | 178 | } |
179 | 179 | ||
180 | var shouldUpdateStartMat = true; | 180 | var shouldUpdateStartMat = true; |
181 | 181 | ||
182 | if(this._clickedOnStage || ((this._handleMode === 2) && (len > 1))) | 182 | if(this._clickedOnStage || ((this._handleMode === 2) && (len > 1))) |
183 | { | 183 | { |
184 | shouldUpdateStartMat = false; | 184 | shouldUpdateStartMat = false; |
185 | } | 185 | } |
186 | else if(this._mode !== 1) | 186 | else if(this._mode !== 1) |
187 | { | 187 | { |
188 | this._startMat = nMat; | 188 | this._startMat = nMat; |
189 | } | 189 | } |
190 | 190 | ||
191 | selectedElements.forEach(function(element) { | 191 | selectedElements.forEach(function(element) { |
192 | curMat = element.elementModel.getProperty("mat").slice(0); | 192 | curMat = element.elementModel.getProperty("mat").slice(0); |
@@ -205,11 +205,11 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
205 | } | 205 | } |
206 | 206 | ||
207 | }); | 207 | }); |
208 | } | 208 | } |
209 | }, | 209 | }, |
210 | 210 | ||
211 | _updateTargets: { | 211 | _updateTargets: { |
212 | value: function(addToUndo) { | 212 | value: function(addToUndo) { |
213 | var mod3dObject = [], self = this; | 213 | var mod3dObject = [], self = this; |
214 | 214 | ||
215 | this.application.ninja.selectedElements.forEach(function(element) { | 215 | this.application.ninja.selectedElements.forEach(function(element) { |
@@ -223,7 +223,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
223 | } | 223 | } |
224 | }); | 224 | }); |
225 | 225 | ||
226 | if(addToUndo) { | 226 | if(addToUndo) { |
227 | ElementsMediator.set3DProperties(mod3dObject, "Change", "translateTool"); | 227 | ElementsMediator.set3DProperties(mod3dObject, "Change", "translateTool"); |
228 | 228 | ||
229 | if(this._origin && this._delta) { | 229 | if(this._origin && this._delta) { |
@@ -243,54 +243,54 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
243 | element.elementModel.setProperty("dist", viewUtils.getPerspectiveDistFromElement(element)); | 243 | element.elementModel.setProperty("dist", viewUtils.getPerspectiveDistFromElement(element)); |
244 | }); | 244 | }); |
245 | 245 | ||
246 | } | 246 | } |
247 | }, | 247 | }, |
248 | 248 | ||
249 | HandleAltKeyDown: { | 249 | HandleAltKeyDown: { |
250 | value: function(event) { | 250 | value: function(event) { |
251 | this._inLocalMode = !this._inLocalMode; | 251 | this._inLocalMode = !this._inLocalMode; |
252 | this.DrawHandles(); | 252 | this.DrawHandles(); |
253 | } | 253 | } |
254 | }, | 254 | }, |
255 | 255 | ||
256 | HandleAltKeyUp: { | 256 | HandleAltKeyUp: { |
257 | value: function(event) { | 257 | value: function(event) { |
258 | this._inLocalMode = !this._inLocalMode; | 258 | this._inLocalMode = !this._inLocalMode; |
259 | this.DrawHandles(); | 259 | this.DrawHandles(); |
260 | } | 260 | } |
261 | }, | 261 | }, |
262 | 262 | ||
263 | handleScroll: { | 263 | handleScroll: { |
264 | value: function(event) { | 264 | value: function(event) { |
265 | this.captureSelectionDrawn(null); | 265 | this.captureSelectionDrawn(null); |
266 | } | 266 | } |
267 | }, | 267 | }, |
268 | 268 | ||
269 | _updateHandlesOrigin: { | 269 | _updateHandlesOrigin: { |
270 | value: function () { | 270 | value: function () { |
271 | var ctr; | 271 | var ctr; |
272 | 272 | ||
273 | var len = this.application.ninja.selectedElements.length; | 273 | var len = this.application.ninja.selectedElements.length; |
274 | if(len > 0) | 274 | if(len > 0) |
275 | { | 275 | { |
276 | if(len === 1) | 276 | if(len === 1) |
277 | { | 277 | { |