aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/tools/Translate3DToolBase.js175
-rwxr-xr-xjs/tools/modifier-tool-base.js13
2 files changed, 100 insertions, 88 deletions
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index bd2b3af1..32132c9a 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -73,13 +73,13 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
73 73
74 var transMat = Matrix.Translation( delta ); 74 var transMat = Matrix.Translation( delta );
75 75
76 //console.log( "Translate: " + delta );
77 if(this._inLocalMode && (this._targets.length === 1) ) 76 if(this._inLocalMode && (this._targets.length === 1) )
78 { 77 {
79 this._translateLocally(transMat); 78 this._translateLocally(transMat);
80 } 79 }
81 else 80 else
82 { 81 {
82 console.log( "modifyElements delta: " + delta );
83 this._translateGlobally(transMat); 83 this._translateGlobally(transMat);
84 } 84 }
85 } 85 }
@@ -147,23 +147,23 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
147 147
148 _translateGlobally: { 148 _translateGlobally: {
149 value: function (transMat) { 149 value: function (transMat) {
150 //console.log( "_translateGlobally, transMat: " + transMat ); 150 //console.log( "_translateGlobally, transMat: " + transMat );
151 //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat ); 151 //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat );
152 var len = this._targets.length, 152 var len = this._targets.length,
153 i = 0, 153 i = 0,
154 item, 154 item,
155 elt, 155 elt,
156 curMat = viewUtils.getMatrixFromElement( this._target ), 156 curMat = viewUtils.getMatrixFromElement( this._target ),
157 matInv = glmat4.inverse(this._startMat, []), 157 matInv = glmat4.inverse(this._startMat, []),
158 nMat = glmat4.multiply(transMat, this._startMat, [] ), 158 nMat = glmat4.multiply(transMat, this._startMat, [] ),
159 qMat = glmat4.multiply(matInv, nMat, []); 159 qMat = glmat4.multiply(matInv, nMat, []);
160 160
161 if (this._mode === 1) 161 if (this._mode === 1)
162 { 162 {
163 if (len > 1) curMat = this._targets[0].mat.slice(); 163 if (len > 1) curMat = this._targets[0].mat.slice();
164 var curInv = glmat4.inverse( curMat, [] ); 164 var curInv = glmat4.inverse( curMat, [] );
165 transMat = glmat4.multiply( nMat, curInv, [] ); 165 transMat = glmat4.multiply( nMat, curInv, [] );
166 } 166 }
167 167
168 var shouldUpdateStartMat = true; 168 var shouldUpdateStartMat = true;
169 169
@@ -185,27 +185,27 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
185// glmat4.multiply(curMat, qMat, curMat); 185// glmat4.multiply(curMat, qMat, curMat);
186// 186//
187// viewUtils.setMatrixForElement( elt, curMat, true); 187// viewUtils.setMatrixForElement( elt, curMat, true);
188 curMat[12] += transMat[12]; 188 curMat[12] += transMat[12];
189 curMat[13] += transMat[13]; 189 curMat[13] += transMat[13];
190 curMat[14] += transMat[14]; 190 curMat[14] += transMat[14];
191 viewUtils.setMatrixForElement( elt, curMat, true); 191 viewUtils.setMatrixForElement( elt, curMat, true);
192 192
193 if(shouldUpdateStartMat) 193 if(shouldUpdateStartMat)
194 { 194 {
195 //console.log( "\t\tshouldUpdateStartMat" ); 195 //console.log( "\t\tshouldUpdateStartMat" );
196 this._targets[i].mat = curMat; 196 this._targets[i].mat = curMat;
197 } 197 }
198 } 198 }
199 } 199 }
200 }, 200 },
201 201
202 _updateTargets: { 202 _updateTargets: {
203 value: function(addToUndoStack) 203 value: function(addToUndoStack)
204 { 204 {
205 console.log( "_updateTargets" ); 205 //console.log( "_updateTargets" );
206 var newStyles = [], 206 var newStyles = [],
207 previousStyles = [], 207 previousStyles = [],
208 len = this.application.ninja.selectedElements.length; 208 len = this.application.ninja.selectedElements.length;
209 this._targets = []; 209 this._targets = [];
210 for(var i = 0; i < len; i++) 210 for(var i = 0; i < len; i++)
211 { 211 {
@@ -215,47 +215,47 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
215 var curMatInv = glmat4.inverse(curMat, []); 215 var curMatInv = glmat4.inverse(curMat, []);
216 216
217 this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); 217 this._targets.push({elt:elt, mat:curMat, matInv:curMatInv});
218 if(addToUndoStack) 218 if(addToUndoStack)
219 { 219 {
220 var previousStyleStr = {dist:this._undoArray[i].dist, mat:MathUtils.scientificToDecimal(this._undoArray[i].mat.slice(0), 5)}; 220 var previousStyleStr = {dist:this._undoArray[i].dist, mat:MathUtils.scientificToDecimal(this._undoArray[i].mat.slice(0), 5)};
221 221
222 var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), mat:MathUtils.scientificToDecimal(curMat, 5)}; 222 var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), mat:MathUtils.scientificToDecimal(curMat, 5)};
223 223
224 previousStyles.push(previousStyleStr); 224 previousStyles.push(previousStyleStr);
225 newStyles.push(newStyleStr); 225 newStyles.push(newStyleStr);
226 } 226 }
227 } 227 }
228 if(addToUndoStack) 228 if(addToUndoStack)
229 { 229 {
230 ElementsMediator.set3DProperties(this.application.ninja.selectedElements, 230 ElementsMediator.set3DProperties(this.application.ninja.selectedElements,
231 newStyles, 231 newStyles,
232 "Change", 232 "Change",
233 "translateTool", 233 "translateTool",
234 previousStyles 234 previousStyles
235 ); 235 );
236 if(this._origin && this._delta) 236 if(this._origin && this._delta)
237 { 237 {
238 if(this._handleMode !== null) 238 if(this._handleMode !== null)
239 { 239 {
240 this._origin[this._handleMode] += this._delta; 240 this._origin[this._handleMode] += this._delta;
241 } 241 }
242 else 242 else
243 { 243 {
244 this._origin[0] += this._delta[0]; 244 this._origin[0] += this._delta[0];
245 this._origin[1] += this._delta[1]; 245 this._origin[1] += this._delta[1];
246 } 246 }
247 } 247 }
248 this._delta = null; 248 this._delta = null;
249 } 249 }
250 // Save previous value for undo/redo 250 // Save previous value for undo/redo
251 this._undoArray = []; 251 this._undoArray = [];
252 for(i = 0, len = this._targets.length; i < len; i++) 252 for(i = 0, len = this._targets.length; i < len; i++)
253 { 253 {
254 var elt = this._targets[i].elt; 254 var elt = this._targets[i].elt;
255 var _mat = viewUtils.getMatrixFromElement(elt); 255 var _mat = viewUtils.getMatrixFromElement(elt);
256 var _dist = viewUtils.getPerspectiveDistFromElement(elt); 256 var _dist = viewUtils.getPerspectiveDistFromElement(elt);
257 this._undoArray.push({mat:_mat, dist:_dist}); 257 this._undoArray.push({mat:_mat, dist:_dist});
258 } 258 }
259 259
260 } 260 }
261 }, 261 },
@@ -305,27 +305,27 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
305 } 305 }
306 else 306 else
307 { 307 {
308 if(this._origin) 308 if(this._origin)
309 { 309 {
310 if(this._delta) 310 if(this._delta)
311 { 311 {
312 if(this._handleMode !== null) 312 if(this._handleMode !== null)
313 { 313 {
314// this._origin[this._handleMode] = this._delta; 314// this._origin[this._handleMode] = this._delta;
315 } 315 }
316 else 316 else
317 { 317 {
318 this._origin[0] += this._delta[0]; 318 this._origin[0] += this._delta[0];
319 this._origin[1] += this._delta[1]; 319 this._origin[1] += this._delta[1];
320 } 320 }
321 } 321 }
322 } 322 }
323 else 323 else
324 { 324 {
325 this._origin = drawUtils._selectionCtr.slice(0); 325 this._origin = drawUtils._selectionCtr.slice(0);
326 this._origin[0] += this.application.ninja.stage.userContentLeft; 326 this._origin[0] += this.application.ninja.stage.userContentLeft;
327 this._origin[1] += this.application.ninja.stage.userContentTop; 327 this._origin[1] += this.application.ninja.stage.userContentTop;
328 } 328 }
329 } 329 }
330 } 330 }