From 74cda8443e4f3c6f3e29b5bf99c3615339a982a3 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 8 Aug 2012 15:02:19 -0700 Subject: IKNinja_1892 - [3D] Multiple objects fly off screen when translating in Z-axis. Signed-off-by: Nivesh Rajbhandari --- js/tools/Translate3DToolBase.js | 4 ++-- js/tools/TranslateObject3DTool.js | 19 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index b5008666..fd275a8a 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -166,7 +166,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, var len = selectedElements.length, self = this, - target = selectedElements[0], + target = this.clickedObject, curMat = viewUtils.getMatrixFromElement( target ), matInv = glmat4.inverse(this._startMat, []), nMat = glmat4.multiply(transMat, this._startMat, [] ); @@ -180,7 +180,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, var shouldUpdateStartMat = true; - if(this._clickedOnStage || ((this._handleMode === 2) && (len > 1))) + if(this._clickedOnStage || ((this._handleMode !== null) && (len > 1))) { shouldUpdateStartMat = false; } diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index a3ece1f9..5dfd2029 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -77,15 +77,12 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { else { this._delta = null; - //if(this._handleMode === 2) { - this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, this._inLocalMode); - //console.log( "dragPlane: " + this._dragPlane ); - snapManager.setupDragPlaneFromPlane(this._dragPlane); - do3DSnap = false; - - snapManager.enableElementSnap ( false ); - snapManager.enableGridSnap ( false ); - //} + this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, (this._inLocalMode && (this.application.ninja.selectedElements.length === 1))); + snapManager.setupDragPlaneFromPlane(this._dragPlane); + do3DSnap = false; + + snapManager.enableElementSnap ( false ); + snapManager.enableGridSnap ( false ); } if(this.application.ninja.selectedElements.length) { @@ -95,7 +92,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { // a snap on the mouse down var hitRec = snapManager.snap(point.x, point.y, do3DSnap); - if(this._handleMode === 2) + if(this._handleMode !== null) { // translate z doesn't snap to element so hitRec's element will always be different // from what the browser says we clicked on. So, skip this check. @@ -135,7 +132,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); } - if(this._handleMode === 2) + if(this._handleMode !== null) this.clickedObject = this._target; // parameterize the snap point on the target -- cgit v1.2.3