aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/snap-manager.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/3D/snap-manager.js')
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js35
1 files changed, 27 insertions, 8 deletions
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index cf8a91db..5b467b41 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -471,7 +471,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
471 value: function( plane ) { 471 value: function( plane ) {
472 this._elementCache = new Array; 472 this._elementCache = new Array;
473 473
474 var stage = this.getStage(); 474// var stage = this.getStage();
475 var stage = this.application.ninja.currentSelectedContainer || this.getStage();
475 this.hLoadElementCache( stage, plane, 0 ); 476 this.hLoadElementCache( stage, plane, 0 );
476 this._isCacheInvalid = false; 477 this._isCacheInvalid = false;
477 478
@@ -570,6 +571,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
570 571
571 hLoadElementCache : { 572 hLoadElementCache : {
572 value: function( elt, plane, depth ) { 573 value: function( elt, plane, depth ) {
574 if(depth > 1)
575 {
576 return;
577 }
578
573 if (depth > 0) 579 if (depth > 0)
574 { 580 {
575 // check if the element is on the specified plane 581 // check if the element is on the specified plane
@@ -590,8 +596,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
590 elt.elementModel.isIn2DSnapCache = false; 596 elt.elementModel.isIn2DSnapCache = false;
591 } 597 }
592 598
593 // TODO - Don't traverse components' children 599 // TODO - Don't traverse svg and components' children
594// if(elt.elementModel && elt.elementModel.isComponent)
595 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG")))) 600 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG"))))
596 { 601 {
597 return; 602 return;
@@ -964,7 +969,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
964 snapToElements : { 969 snapToElements : {
965 value: function( screenPt, hitRecs ) { 970 value: function( screenPt, hitRecs ) {
966 // start at the stage. 971 // start at the stage.
967 var stage = this.getStage(); 972// var stage = this.getStage();
973 var stage = this.application.ninja.currentSelectedContainer || this.getStage();
968 974
969 // the root should be the 'view' canvas, so the first matrix is the camera 975 // the root should be the 'view' canvas, so the first matrix is the camera
970 viewUtils.setViewportObj( stage ); 976 viewUtils.setViewportObj( stage );
@@ -980,6 +986,10 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
980 { 986 {
981 value: function( elt, hitRecs, depth, globalScrPt ) 987 value: function( elt, hitRecs, depth, globalScrPt )
982 { 988 {
989 if(depth > 1)
990 {
991 return;
992 }
983 // hit test the current object 993 // hit test the current object
984 var hit; 994 var hit;
985 if (depth > 0) // don't snap to the root 995 if (depth > 0) // don't snap to the root
@@ -1001,8 +1011,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1001 } 1011 }
1002 } 1012 }
1003 1013
1004 // TODO - Don't traverse components' children 1014 // TODO - Don't traverse svg and components' children
1005// if(elt.elementModel && elt.elementModel.isComponent)
1006 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG")))) 1015 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG"))))
1007 { 1016 {
1008 return; 1017 return;
@@ -1402,6 +1411,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1402 case glObj.GEOM_TYPE_PATH: 1411 case glObj.GEOM_TYPE_PATH:
1403 // Snapping not implemented for these type, but don't throw an error... 1412 // Snapping not implemented for these type, but don't throw an error...
1404 break; 1413 break;
1414 case glObj.GEOM_TYPE_BRUSH_STROKE:
1415 break; //don't throw error because snapping not yet implemented
1405 case glObj.GEOM_TYPE_CUBIC_BEZIER: 1416 case glObj.GEOM_TYPE_CUBIC_BEZIER:
1406 { 1417 {
1407 var nearVrt = glObj.getNearVertex( eyePt, dir ); 1418 var nearVrt = glObj.getNearVertex( eyePt, dir );
@@ -1978,12 +1989,20 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1978 }, 1989 },
1979 1990
1980 setupDragPlanes : { 1991 setupDragPlanes : {
1981 value: function( hitRec ) { 1992 value: function( hitRec, inGlobalMode ) {
1982 // get the location of the point in stage world space 1993 // get the location of the point in stage world space
1983 var elt = hitRec.getElt(); 1994 var elt = hitRec.getElt();
1984 var localPt = hitRec.getLocalPoint(); 1995 var localPt = hitRec.getLocalPoint();
1985 var planeMat = hitRec.getPlaneMatrix(); 1996 var planeMat = hitRec.getPlaneMatrix();
1986 var stageWorldPt = viewUtils.postViewToStageWorld( MathUtils.transformPoint(localPt,planeMat), elt ); 1997 var stageWorldPt;
1998 if(inGlobalMode)
1999 {
2000 stageWorldPt = MathUtils.transformPoint(localPt,planeMat);
2001 }
2002 else
2003 {
2004 stageWorldPt = viewUtils.postViewToStageWorld( MathUtils.transformPoint(localPt,planeMat), elt );
2005 }
1987 2006
1988 /* 2007 /*
1989 // get a working plane parallel to the current working plane through the stage world point 2008 // get a working plane parallel to the current working plane through the stage world point