aboutsummaryrefslogtreecommitdiff
path: root/js/tools/modifier-tool-base.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-04-09 10:33:35 -0700
committerValerio Virgillito2012-04-09 10:33:35 -0700
commitbd43ce383b050d03b0f92cc923c517febc66ca28 (patch)
tree91b95c6c9aef779a743b710105546a8ae74bff12 /js/tools/modifier-tool-base.js
parent86b98ea086b133f4efb247c39fc6200dcf383a65 (diff)
parentc62c5c4287a1ee8a276b32dc61f06abbc24818ec (diff)
downloadninja-bd43ce383b050d03b0f92cc923c517febc66ca28.tar.gz
Merge pull request #159 from mqg734/WebGLMaterials
3D tools, eyedropper, fill, ink-bucket, gradients and shape fixes.
Diffstat (limited to 'js/tools/modifier-tool-base.js')
-rwxr-xr-xjs/tools/modifier-tool-base.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index 46bb2e87..de73c861 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -9,8 +9,8 @@ var Montage = require("montage/core/core").Montage,
9 snapManager = require("js/helper-classes/3D/snap-manager").SnapManager, 9 snapManager = require("js/helper-classes/3D/snap-manager").SnapManager,
10 viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, 10 viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils,
11 vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, 11 vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils,
12 drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, 12 drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils;
13 Properties3D = ("js/models/properties-3d").Properties3D; 13// Properties3D = ("js/models/properties-3d").Properties3D;
14 14
15exports.ModifierToolBase = Montage.create(DrawingTool, { 15exports.ModifierToolBase = Montage.create(DrawingTool, {
16 16
@@ -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;
@@ -448,6 +456,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
448 { 456 {
449 this.isDrawing = true; 457 this.isDrawing = true;
450 this.application.ninja.stage.showSelectionBounds = false; 458 this.application.ninja.stage.showSelectionBounds = false;
459 this._updateTargets();
451 460
452 if(this._canSnap) 461 if(this._canSnap)
453 { 462 {
@@ -517,7 +526,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
517 526
518 // do the snap 527 // do the snap
519 var quadPt; 528 var quadPt;
520 if (mouseIsDown) 529 if (mouseIsDown && !do3DSnap && this._shouldUseQuadPt && (this._handleMode === null) && (this._mode === 0))
521 quadPt = this.GetQuadrantSnapPoint(x,y); 530 quadPt = this.GetQuadrantSnapPoint(x,y);
522 var hitRec = snapManager.snap(x, y, do3DSnap, quadPt ); 531 var hitRec = snapManager.snap(x, y, do3DSnap, quadPt );
523 532
@@ -757,6 +766,11 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
757 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); 766 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() );
758 this.eventManager.removeEventListener( "toolOptionsChange", this, false); 767 this.eventManager.removeEventListener( "toolOptionsChange", this, false);
759 this.eventManager.removeEventListener( "toolDoubleClick", this, false); 768 this.eventManager.removeEventListener( "toolDoubleClick", this, false);
769
770 if (this._targetedElement) {
771 this._targetedElement.classList.remove("active-element-outline");
772 this._targetedElement = null;
773 }
760 } 774 }
761 } 775 }
762 }, 776 },
@@ -785,7 +799,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
785 { 799 {
786 this.target = this.application.ninja.currentDocument.documentRoot; 800 this.target = this.application.ninja.currentDocument.documentRoot;
787 } 801 }
788 this._updateTargets(); 802// this._updateTargets();
789 } 803 }
790 else 804 else
791 { 805 {
@@ -806,6 +820,8 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
806 HandleLeftButtonDown: { 820 HandleLeftButtonDown: {
807 value: function(event) { 821 value: function(event) {
808 822
823// console.log( "modifier-tool-base.HandleLeftButtonDown" );
824
809 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));
810 this.downPoint.x = point.x; 826 this.downPoint.x = point.x;
811 this.downPoint.y = point.y; 827 this.downPoint.y = point.y;