aboutsummaryrefslogtreecommitdiff
path: root/js/tools/Translate3DToolBase.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/Translate3DToolBase.js')
-rwxr-xr-xjs/tools/Translate3DToolBase.js21
1 files changed, 9 insertions, 12 deletions
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index bf07e89e..f81ce6d6 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -138,11 +138,9 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
138 value: function (transMat) { 138 value: function (transMat) {
139 //console.log( "_translateGlobally, transMat: " + transMat ); 139 //console.log( "_translateGlobally, transMat: " + transMat );
140 var selectedElements = this.application.ninja.selectedElements; 140 var selectedElements = this.application.ninja.selectedElements;
141 if(this.rotateStage) {
142 selectedElements = [this.application.ninja.currentDocument.documentRoot];
143 }
144 141
145 var self = this, 142 var len = selectedElements.length,
143 self = this,
146 target = selectedElements[0], 144 target = selectedElements[0],
147 curMat = viewUtils.getMatrixFromElement( target ), 145 curMat = viewUtils.getMatrixFromElement( target ),
148 matInv = glmat4.inverse(this._startMat, []), 146 matInv = glmat4.inverse(this._startMat, []),
@@ -157,7 +155,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
157 155
158 var shouldUpdateStartMat = true; 156 var shouldUpdateStartMat = true;
159 157
160 if(this._clickedOnStage || ((this._handleMode === 2) && (this._targets.length > 1))) 158 if(this._clickedOnStage || ((this._handleMode === 2) && (len > 1)))
161 { 159 {
162 shouldUpdateStartMat = false; 160 shouldUpdateStartMat = false;
163 } 161 }
@@ -166,7 +164,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
166 this._startMat = nMat; 164 this._startMat = nMat;
167 } 165 }
168 166
169 this.application.ninja.selectedElements.forEach(function(element) { 167 selectedElements.forEach(function(element) {
170 curMat = element.elementModel.getProperty("mat").slice(0); 168 curMat = element.elementModel.getProperty("mat").slice(0);
171 169
172// glmat4.multiply(curMat, qMat, curMat); 170// glmat4.multiply(curMat, qMat, curMat);
@@ -273,7 +271,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
273 captureSelectionDrawn: { 271 captureSelectionDrawn: {
274 value: function(event){ 272 value: function(event){
275 this._origin = null; 273 this._origin = null;
276 this._targets = [];
277 this._startOriginArray = null; 274 this._startOriginArray = null;
278 275
279 var len = this.application.ninja.selectedElements.length; 276 var len = this.application.ninja.selectedElements.length;
@@ -294,7 +291,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
294 } 291 }
295 292
296 this._origin = viewUtils.localToGlobal(eltCtr, this.target); 293 this._origin = viewUtils.localToGlobal(eltCtr, this.target);
297 console.log( "Rotate3DToolBase.captureSelectionDrawn _origin: " + this._origin ); 294// console.log( "Rotate3DToolBase.captureSelectionDrawn _origin: " + this._origin );
298 this._updateTargets(); 295 this._updateTargets();
299 //this._setTransformOrigin(false); 296 //this._setTransformOrigin(false);
300 } 297 }
@@ -330,11 +327,11 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
330 for (i = 0; i < len; i++) 327 for (i = 0; i < len; i++)
331 { 328 {
332 // get the next element and localToGlobal matrix 329 // get the next element and localToGlobal matrix
333 elt = this._targets[i].elt; 330 var elt = this.application.ninja.selectedElements[i];
334 var l2g = this._targets[i].l2g; 331 var l2g = elt.elementModel.getProperty("l2g");
335 332
336 // get the element bounds in 'plane' space 333 // get the element bounds in 'plane' space
337 bounds = viewUtils.getElementViewBounds3D( elt ); 334 var bounds = viewUtils.getElementViewBounds3D( elt );
338 for (j=0; j<4; j++) 335 for (j=0; j<4; j++)
339 { 336 {
340 var localPt = bounds[j]; 337 var localPt = bounds[j];
@@ -354,7 +351,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
354 } 351 }
355 var stageWorldCtr = [ 0.5*(minPt[0] + maxPt[0]), 0.5*(minPt[1] + maxPt[1]), 0.5*(minPt[2] + maxPt[2]) ]; 352 var stageWorldCtr = [ 0.5*(minPt[0] + maxPt[0]), 0.5*(minPt[1] + maxPt[1]), 0.5*(minPt[2] + maxPt[2]) ];
356 var globalCtr = MathUtils.transformAndDivideHomogeneousPoint( stageWorldCtr, viewUtils.getStageWorldToGlobalMatrix() ); 353 var globalCtr = MathUtils.transformAndDivideHomogeneousPoint( stageWorldCtr, viewUtils.getStageWorldToGlobalMatrix() );
357 console.log( "resetting _origin to: " + this._origin ); 354// console.log( "resetting _origin to: " + this._origin );
358 355
359 return globalCtr; 356 return globalCtr;
360 } 357 }