aboutsummaryrefslogtreecommitdiff
path: root/js/tools/TranslateObject3DTool.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/TranslateObject3DTool.js')
-rwxr-xr-xjs/tools/TranslateObject3DTool.js80
1 files changed, 40 insertions, 40 deletions
diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js
index 421ace8f..08fc34f7 100755
--- a/js/tools/TranslateObject3DTool.js
+++ b/js/tools/TranslateObject3DTool.js
@@ -51,20 +51,20 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
51 { 51 {
52// console.log( "initializeSnapping" ); 52// console.log( "initializeSnapping" );
53 53
54 this._mouseDownHitRec = null; 54 this._mouseDownHitRec = null;
55 this._mouseUpHitRec = null; 55 this._mouseUpHitRec = null;
56 56
57 snapManager.clearAvoidList(); 57 snapManager.clearAvoidList();
58 snapManager.clearDragPlane(); 58 snapManager.clearDragPlane();
59 59
60 // the translate tool does snap align to the bounds of the object only. 60 // the translate tool does snap align to the bounds of the object only.
61 // turn off snap align to the cursor. This needs to be re-enabled in the mouse up method 61 // turn off snap align to the cursor. This needs to be re-enabled in the mouse up method
62 snapManager.enableSnapAlign( false ); 62 snapManager.enableSnapAlign( false );
63 63
64 // snap to element and snap to grid are conditionally enabled based 64 // snap to element and snap to grid are conditionally enabled based
65 // on the snap results of the mouse down. enable everything for the first snap 65 // on the snap results of the mouse down. enable everything for the first snap
66 this._snapToElements = snapManager.elementSnapEnabledAppLevel(); 66 this._snapToElements = snapManager.elementSnapEnabledAppLevel();
67 this._snapToGrid = snapManager.gridSnapEnabledAppLevel(); 67 this._snapToGrid = snapManager.gridSnapEnabledAppLevel();
68 68
69 this._dragPlane = null; 69 this._dragPlane = null;
70 this._clickedOnStage = false; 70 this._clickedOnStage = false;
@@ -72,8 +72,8 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
72 72
73 if(this._handleMode === null) 73 if(this._handleMode === null)
74 { 74 {
75 snapManager.enableElementSnap ( true ); 75 snapManager.enableElementSnap ( true );
76 snapManager.enableGridSnap ( true ); 76 snapManager.enableGridSnap ( true );
77 } 77 }
78 else 78 else
79 { 79 {
@@ -81,21 +81,21 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
81 //if(this._handleMode === 2) 81 //if(this._handleMode === 2)
82 { 82 {
83 this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, this._inLocalMode); 83 this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, this._inLocalMode);
84 //console.log( "dragPlane: " + this._dragPlane ); 84 //console.log( "dragPlane: " + this._dragPlane );
85 snapManager.setupDragPlaneFromPlane(this._dragPlane); 85 snapManager.setupDragPlaneFromPlane(this._dragPlane);
86 do3DSnap = false; 86 do3DSnap = false;
87 87
88 snapManager.enableElementSnap ( false ); 88 snapManager.enableElementSnap ( false );
89 snapManager.enableGridSnap ( false ); 89 snapManager.enableGridSnap ( false );
90 } 90 }
91 } 91 }
92 92
93 if(this.application.ninja.selectedElements.length) { 93 if(this.application.ninja.selectedElements.length) {
94 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); 94 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY));
95 95
96 // do the snap before setting up the avoid list to allow 96 // do the snap before setting up the avoid list to allow
97 // a snap on the mouse down 97 // a snap on the mouse down
98 var hitRec = snapManager.snap(point.x, point.y, do3DSnap); 98 var hitRec = snapManager.snap(point.x, point.y, do3DSnap);
99 99
100 if(this._handleMode === 2) 100 if(this._handleMode === 2)
101 { 101 {
@@ -111,7 +111,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
111 if(elt && (elt !== hitRec.getElement())) 111 if(elt && (elt !== hitRec.getElement()))
112 { 112 {
113 var otherSnap = snapManager.findHitRecordForElement(elt); 113 var otherSnap = snapManager.findHitRecordForElement(elt);
114 if (otherSnap) hitRec = otherSnap; 114 if (otherSnap) hitRec = otherSnap;
115 } 115 }
116 if(elt === this.application.ninja.currentDocument.model.domContainer) 116 if(elt === this.application.ninja.currentDocument.model.domContainer)
117 { 117 {
@@ -124,18 +124,18 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
124 snapManager.addToAvoidList(element); 124 snapManager.addToAvoidList(element);
125 }); 125 });
126 126
127 if (hitRec) 127 if (hitRec)
128 { 128 {
129 // disable snap attributes 129 // disable snap attributes
130 if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT) 130 if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT)
131 { 131 {
132 this._snapToElements = false; 132 this._snapToElements = false;
133 this._snapToGrid = false; 133 this._snapToGrid = false;
134 } 134 }
135 else if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT_CENTER) 135 else if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT_CENTER)
136 { 136 {
137 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); 137 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
138 } 138 }
139 139
140 if(this._handleMode === 2) 140 if(this._handleMode === 2)
141 this.clickedObject = this._target; 141 this.clickedObject = this._target;
@@ -162,19 +162,19 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
162 var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); 162 var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0);
163 this._shouldUseQuadPt = (sign == 0); 163 this._shouldUseQuadPt = (sign == 0);
164 164
165 var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); 165 var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane );
166 this._mouseDownHitRec = wpHitRec; 166 this._mouseDownHitRec = wpHitRec;
167 this._mouseUpHitRec = null; 167 this._mouseUpHitRec = null;
168 168
169 var pt = hitRec.getScreenPoint(); 169 var pt = hitRec.getScreenPoint();
170 this.downPoint.x = pt[0]; 170 this.downPoint.x = pt[0];
171 this.downPoint.y = pt[1]; 171 this.downPoint.y = pt[1];
172 172
173 // TODO - need to figure out snapManager dependency by drawUtils. 173 // TODO - need to figure out snapManager dependency by drawUtils.
174 // For now, bypassing by calling snapManager.drawLastHit(); 174 // For now, bypassing by calling snapManager.drawLastHit();
175// drawUtils.refreshDisplay(); 175// drawUtils.refreshDisplay();
176 snapManager.drawLastHit(); 176 snapManager.drawLastHit();
177 } 177 }
178 } 178 }
179 else 179 else
180 { 180 {