From 4bec28fbd8371deceffd1563190cb5e399d554d3 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 16 Mar 2012 16:36:04 -0700 Subject: Squashed commit of SnapManagerFixes Signed-off-by: Valerio Virgillito --- js/tools/TranslateObject3DTool.js | 40 +++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'js/tools/TranslateObject3DTool.js') diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 92b9b2f7..60633e74 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -32,6 +32,7 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { this._snapToGrid = snapManager.gridSnapEnabledAppLevel(); this._dragPlane = null; + this._clickedOnStage = false; var do3DSnap = true; if(this._handleMode === null) @@ -43,9 +44,9 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { } else { - this._delta = 0; + this._delta = null; // special case for z-translation - if( this._handleMode && (this._handleMode === 2) ) + if(this._handleMode === 2) { this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target); snapManager.setupDragPlaneFromPlane(this._dragPlane); @@ -65,11 +66,25 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { // a snap on the mouse down var hitRec = snapManager.snap(point.x, point.y, do3DSnap); - // TODO - Check that hitRec's element matches element that browser says we clicked on - var elt = this.application.ninja.stage.GetElement(event); - if(elt !== hitRec.getElement()) + if(this._handleMode === 2) { - hitRec = snapManager.findHitRecordForElement(elt); + // 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. + } + else + { + // Check that hitRec's element matches element that browser says we clicked on + // TODO - This is still not working when using a handle that is on top of an + // element that is not currently selected + var elt = this.application.ninja.stage.GetSelectableElement(event); + if(elt && (elt !== hitRec.getElement())) + { + hitRec = snapManager.findHitRecordForElement(elt); + } + if(elt === this.application.ninja.currentSelectedContainer) + { + this._clickedOnStage = true; + } } // we don't want to snap to selected objects during the drag @@ -91,8 +106,17 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); } - // parameterize the snap point on the target - this._snapParam = this.parameterizeSnap( hitRec ); + if(this._handleMode === 2) + { + // TODO - not sure how to parameterize point in z-translate mode + this.clickedObject = this._target; + this._snapParam = [0, 0, 0]; + } + else + { + // parameterize the snap point on the target + this._snapParam = this.parameterizeSnap( hitRec ); + } if(!this._dragPlane) { -- cgit v1.2.3 From 331ea08655245e3532e48bf160d5f68a04d8723f Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 27 Mar 2012 16:38:52 -0700 Subject: IKNINJA-764 - The Local/Global options are not in synced with both 3D object rotate tool and 3D object translate tool. Signed-off-by: Nivesh Rajbhandari --- js/tools/TranslateObject3DTool.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'js/tools/TranslateObject3DTool.js') diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 60633e74..4fac8187 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -4,15 +4,22 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, +var Montage = require("montage/core/core").Montage, + Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; -exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { +exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { _toolID: { value: "translateObject3DTool" }, _canOperateOnStage: { value: true }, + _initializeToolHandles: { + value: function() { + this._inLocalMode = (this.options.selectedMode === "rotateLocally"); + } + }, + initializeSnapping : { value : function(event) { -- cgit v1.2.3 From dc9650af5760b1f93d6e93a383eabceacfdc0ad8 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 2 Apr 2012 15:40:25 -0700 Subject: Snapping fixes. --- js/tools/TranslateObject3DTool.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'js/tools/TranslateObject3DTool.js') diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 60633e74..7163f005 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -16,6 +16,8 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { initializeSnapping : { value : function(event) { + console.log( "initializeSnapping" ); + this._mouseDownHitRec = null; this._mouseUpHitRec = null; @@ -37,8 +39,6 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { if(this._handleMode === null) { -// this.doSelection(event); - snapManager.enableElementSnap ( true ); snapManager.enableGridSnap ( true ); } @@ -107,16 +107,10 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { } if(this._handleMode === 2) - { - // TODO - not sure how to parameterize point in z-translate mode this.clickedObject = this._target; - this._snapParam = [0, 0, 0]; - } - else - { - // parameterize the snap point on the target - this._snapParam = this.parameterizeSnap( hitRec ); - } + + // parameterize the snap point on the target + this._snapParam = this.parameterizeSnap( hitRec ); if(!this._dragPlane) { @@ -132,6 +126,11 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { } + // only do quadrant snapping if the 4 corners of the element are in the drag plane + + var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); + this._shouldUseQuadPt = (sign == 0); + var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); this._mouseDownHitRec = wpHitRec; this._mouseUpHitRec = null; -- cgit v1.2.3 From 8b60a68f0152c609ad94a931472680f313678d8d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 4 Apr 2012 11:17:50 -0700 Subject: We should require VecUtils instead of referring to the global reference since we will eventually remove that from the window object. Signed-off-by: Nivesh Rajbhandari --- js/tools/TranslateObject3DTool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/tools/TranslateObject3DTool.js') diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 7163f005..9fa49229 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -5,7 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot */ var Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, - drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, + vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; @@ -16,7 +16,7 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { initializeSnapping : { value : function(event) { - console.log( "initializeSnapping" ); +// console.log( "initializeSnapping" ); this._mouseDownHitRec = null; this._mouseUpHitRec = null; @@ -128,7 +128,7 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { // only do quadrant snapping if the 4 corners of the element are in the drag plane - var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); + var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); this._shouldUseQuadPt = (sign == 0); var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); -- cgit v1.2.3