aboutsummaryrefslogtreecommitdiff
path: root/js/tools/modifier-tool-base.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-04-04 10:39:32 -0700
committerNivesh Rajbhandari2012-04-04 10:39:32 -0700
commitb9032fb0f656a6c029ef0c71c490bb5d5cd10d94 (patch)
tree0faee331bf5d28877bdafd46ea26a269abaa91b2 /js/tools/modifier-tool-base.js
parentdf0389e6a191ebbff4e4b5d6625007873c0737bd (diff)
parentdc9650af5760b1f93d6e93a383eabceacfdc0ad8 (diff)
downloadninja-b9032fb0f656a6c029ef0c71c490bb5d5cd10d94.tar.gz
Merge branch 'refs/heads/EricSnapping' into WebGLFileIO
Diffstat (limited to 'js/tools/modifier-tool-base.js')
-rwxr-xr-xjs/tools/modifier-tool-base.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index a1812650..5f2d29be 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -25,6 +25,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
25 _snapParam: { value: null }, 25 _snapParam: { value: null },
26 _snapIndex: { value: -1 }, 26 _snapIndex: { value: -1 },
27 _useQuadPt: { value: false }, 27 _useQuadPt: { value: false },
28 _shouldUseQuadPt: { value: false },
28 29
29 // we set snapping capabilities depending on the tool. 30 // we set snapping capabilities depending on the tool.
30 // The following variables are set in a tool's initializeSnapping method called on mouse down. 31 // The following variables are set in a tool's initializeSnapping method called on mouse down.
@@ -175,6 +176,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
175// } 176// }
176 } 177 }
177 178
179 // only do quadrant snapping if the 4 corners of the element are in the drag plane
180 var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0);
181 this._shouldUseQuadPt = (sign == 0)
182
178 var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); 183 var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane );
179 this._mouseDownHitRec = wpHitRec; 184 this._mouseDownHitRec = wpHitRec;
180 this._mouseUpHitRec = null; 185 this._mouseUpHitRec = null;
@@ -236,6 +241,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
236 } 241 }
237 } 242 }
238 243
244 //console.log( "ParameterizeSnap: " + paramPt );
239 return paramPt; 245 return paramPt;
240 } 246 }
241 }, 247 },
@@ -284,14 +290,16 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
284 y = x0 + ty*dy, 290 y = x0 + ty*dy,
285 z = 0.0; 291 z = 0.0;
286 var localPt = [x,y,z]; 292 var localPt = [x,y,z];
293
287 globalPt = viewUtils.localToGlobal( localPt, elt ); 294 globalPt = viewUtils.localToGlobal( localPt, elt );
288 295
289 // add in the delta 296 // add in the delta
290 var hitPt = this.GetObjectHitPoint(); 297 var hitPt = this.GetObjectHitPoint();
291 var scrPt = viewUtils.localToGlobal( hitPt, this._clickedObject ); 298 var scrPt = viewUtils.localToGlobal( hitPt, this._clickedObject );
292 var delta = [xEvent-scrPt[0], yEvent-scrPt[1]]; 299 var delta = [xEvent-scrPt[0], yEvent-scrPt[1], 0-scrPt[2]];
293 globalPt[0] += delta[0]; 300 globalPt[0] += delta[0];
294 globalPt[1] += delta[1]; 301 globalPt[1] += delta[1];
302 globalPt[2] += delta[2];
295 } 303 }
296 304
297 return globalPt; 305 return globalPt;
@@ -518,7 +526,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
518 526
519 // do the snap 527 // do the snap
520 var quadPt; 528 var quadPt;
521 if (mouseIsDown) 529 if (mouseIsDown && !do3DSnap && this._shouldUseQuadPt && (this._handleMode === null) && (this._mode === 0))
522 quadPt = this.GetQuadrantSnapPoint(x,y); 530 quadPt = this.GetQuadrantSnapPoint(x,y);
523 var hitRec = snapManager.snap(x, y, do3DSnap, quadPt ); 531 var hitRec = snapManager.snap(x, y, do3DSnap, quadPt );
524 532
@@ -812,6 +820,8 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
812 HandleLeftButtonDown: { 820 HandleLeftButtonDown: {
813 value: function(event) { 821 value: function(event) {
814 822
823 console.log( "modifier-tool-base.HandleLeftButtonDown" );
824
815 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); 825 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY));
816 this.downPoint.x = point.x; 826 this.downPoint.x = point.x;
817 this.downPoint.y = point.y; 827 this.downPoint.y = point.y;