aboutsummaryrefslogtreecommitdiff
path: root/js/tools/TranslateObject3DTool.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/TranslateObject3DTool.js')
-rwxr-xr-xjs/tools/TranslateObject3DTool.js42
1 files changed, 33 insertions, 9 deletions
diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js
index 5157e39c..60633e74 100755
--- a/js/tools/TranslateObject3DTool.js
+++ b/js/tools/TranslateObject3DTool.js
@@ -32,6 +32,7 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, {
32 this._snapToGrid = snapManager.gridSnapEnabledAppLevel(); 32 this._snapToGrid = snapManager.gridSnapEnabledAppLevel();
33 33
34 this._dragPlane = null; 34 this._dragPlane = null;
35 this._clickedOnStage = false;
35 var do3DSnap = true; 36 var do3DSnap = true;
36 37
37 if(this._handleMode === null) 38 if(this._handleMode === null)
@@ -43,9 +44,9 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, {
43 } 44 }
44 else 45 else
45 { 46 {
46 this._delta = 0; 47 this._delta = null;
47 // special case for z-translation 48 // special case for z-translation
48 if( this._handleMode && (this._handleMode === 2) ) 49 if(this._handleMode === 2)
49 { 50 {
50 this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target); 51 this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target);
51 snapManager.setupDragPlaneFromPlane(this._dragPlane); 52 snapManager.setupDragPlaneFromPlane(this._dragPlane);
@@ -65,11 +66,25 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, {
65 // a snap on the mouse down 66 // a snap on the mouse down
66 var hitRec = snapManager.snap(point.x, point.y, do3DSnap); 67 var hitRec = snapManager.snap(point.x, point.y, do3DSnap);
67 68
68 // TODO - Check that hitRec's element matches element that browser says we clicked on 69 if(this._handleMode === 2)
69 var elt = this.application.ninja.stage.GetElement(event);
70 if(elt !== hitRec.getElement())
71 { 70 {
72 hitRec = snapManager.findHitRecordForElement(elt); 71 // translate z doesn't snap to element so hitRec's element will always be different
72 // from what the browser says we clicked on. So, skip this check.
73 }
74 else
75 {
76 // Check that hitRec's element matches element that browser says we clicked on
77 // TODO - This is still not working when using a handle that is on top of an
78 // element that is not currently selected
79 var elt = this.application.ninja.stage.GetSelectableElement(event);
80 if(elt && (elt !== hitRec.getElement()))
81 {
82 hitRec = snapManager.findHitRecordForElement(elt);
83 }
84 if(elt === this.application.ninja.currentSelectedContainer)
85 {
86 this._clickedOnStage = true;
87 }
73 } 88 }
74 89
75 // we don't want to snap to selected objects during the drag 90 // we don't want to snap to selected objects during the drag
@@ -91,8 +106,17 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, {
91 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); 106 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
92 } 107 }
93 108
94 // parameterize the snap point on the target 109 if(this._handleMode === 2)
95 this._snapParam = this.parameterizeSnap( hitRec ); 110 {
111 // TODO - not sure how to parameterize point in z-translate mode
112 this.clickedObject = this._target;
113 this._snapParam = [0, 0, 0];
114 }
115 else
116 {
117 // parameterize the snap point on the target
118 this._snapParam = this.parameterizeSnap( hitRec );
119 }
96 120
97 if(!this._dragPlane) 121 if(!this._dragPlane)
98 { 122 {
@@ -103,7 +127,7 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, {
103 } 127 }
104 else 128 else
105 { 129 {
106 this._dragPlane = snapManager.setupDragPlanes( hitRec ); 130 this._dragPlane = snapManager.setupDragPlanes( hitRec, true );
107 } 131 }
108 132
109 } 133 }