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.js40
1 files changed, 20 insertions, 20 deletions
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 2289f963..e5044e09 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -210,7 +210,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
210 }, 210 },
211 211
212 snap : { 212 snap : {
213 value: function (xScreen, yScreen, snap3D, quadPt) 213 value: function (xScreen, yScreen, snap3D, quadPt)
214 { 214 {
215 // force a 3D snap if a 2D snap is requested but the 2D cache has not been initialized 215 // force a 3D snap if a 2D snap is requested but the 2D cache has not been initialized
216 if (!snap3D && !this._elementCache) snap3D = true; 216 if (!snap3D && !this._elementCache) snap3D = true;
@@ -282,7 +282,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
282 this.deactivateDragPlane(); 282 this.deactivateDragPlane();
283 283
284 this.setLastHit( rtnHit ); 284 this.setLastHit( rtnHit );
285 285
286 //rtnHit.test(); // DEBUG CODE. REMOVE THIS 286 //rtnHit.test(); // DEBUG CODE. REMOVE THIS
287 return rtnHit; 287 return rtnHit;
288 } 288 }
@@ -305,7 +305,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
305 var stageWorldPt0 = viewUtils.localToStageWorld( localPt0, stage ), 305 var stageWorldPt0 = viewUtils.localToStageWorld( localPt0, stage ),
306 stageWorldPt1 = viewUtils.localToStageWorld( localPt1, stage ); 306 stageWorldPt1 = viewUtils.localToStageWorld( localPt1, stage );
307 var vec = vecUtils.vecSubtract( 3, stageWorldPt1, stageWorldPt0 ); 307 var vec = vecUtils.vecSubtract( 3, stageWorldPt1, stageWorldPt0 );
308 308
309 var ptOnWorkingPlane = MathUtils.vecIntersectPlane(stageWorldPt0, vec, workingPlane); 309 var ptOnWorkingPlane = MathUtils.vecIntersectPlane(stageWorldPt0, vec, workingPlane);
310 310
311 var wpMat = drawUtils.getPlaneToWorldMatrix(workingPlane, MathUtils.getPointOnPlane(workingPlane)), 311 var wpMat = drawUtils.getPlaneToWorldMatrix(workingPlane, MathUtils.getPointOnPlane(workingPlane)),
@@ -1023,7 +1023,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1023 } 1023 }
1024 }, 1024 },
1025 1025
1026 hSnapToElements : 1026 hSnapToElements :
1027 { 1027 {
1028 value: function( elt, hitRecs, depth, globalScrPt ) 1028 value: function( elt, hitRecs, depth, globalScrPt )
1029 { 1029 {
@@ -1081,9 +1081,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1081 } 1081 }
1082 }, 1082 },
1083 1083
1084 snapToElement : 1084 snapToElement :
1085 { 1085 {
1086 value: function( elt, globalScrPt ) 1086 value: function( elt, globalScrPt )
1087 { 1087 {
1088 if (this.isAvoidedElement(elt) ) return null; 1088 if (this.isAvoidedElement(elt) ) return null;
1089 1089
@@ -1096,7 +1096,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1096 var eltMat = viewUtils.getLocalToGlobalMatrix( elt ); 1096 var eltMat = viewUtils.getLocalToGlobalMatrix( elt );
1097 for (var i=0; i<4; i++) 1097 for (var i=0; i<4; i++)
1098 bounds3D[i] = viewUtils.localToGlobal2(bounds[i], eltMat); 1098 bounds3D[i] = viewUtils.localToGlobal2(bounds[i], eltMat);
1099 1099
1100 var hitRec = this.snapToScreenBounds( elt, globalScrPt, bounds, bounds3D ); 1100 var hitRec = this.snapToScreenBounds( elt, globalScrPt, bounds, bounds3D );
1101 1101
1102 // see if we can snap to a contained geometry object 1102 // see if we can snap to a contained geometry object
@@ -1117,9 +1117,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1117 } 1117 }
1118 }, 1118 },
1119 1119
1120 snapToScreenBounds : 1120 snapToScreenBounds :
1121 { 1121 {
1122 value: function( elt, scrPt, bounds, bounds3D ) 1122 value: function( elt, scrPt, bounds, bounds3D )
1123 { 1123 {
1124 // push the element as the current viewport element 1124 // push the element as the current viewport element
1125 viewUtils.pushViewportObj( elt ); 1125 viewUtils.pushViewportObj( elt );
@@ -1328,9 +1328,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1328 } 1328 }
1329 }, 1329 },
1330 1330
1331 hSnapToContainedElements : 1331 hSnapToContainedElements :
1332 { 1332 {
1333 value: function( eyePt, dir, glObj, hitRec, targetScrPt ) 1333 value: function( eyePt, dir, glObj, hitRec, targetScrPt )
1334 { 1334 {
1335 if (!glObj) return false; 1335 if (!glObj) return false;
1336 1336
@@ -1345,7 +1345,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1345 1345
1346 doSnapToContainedElement: 1346 doSnapToContainedElement:
1347 { 1347 {
1348 value: function( eyePt, dir, glObj, hitRec, targetScrPt ) 1348 value: function( eyePt, dir, glObj, hitRec, targetScrPt )
1349 { 1349 {
1350 var rtnVal = false; 1350 var rtnVal = false;
1351 1351
@@ -1443,9 +1443,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1443 } 1443 }
1444 }, 1444 },
1445 1445
1446 snapToContainedElement : 1446 snapToContainedElement :
1447 { 1447 {
1448 value: function( eyePt, dir, glObj, hitRec, targetScrPt ) 1448 value: function( eyePt, dir, glObj, hitRec, targetScrPt )
1449 { 1449 {
1450 var rtnVal = false; 1450 var rtnVal = false;
1451 var elt = hitRec.getElement(); 1451 var elt = hitRec.getElement();
@@ -1466,10 +1466,10 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1466 case glObj.GEOM_TYPE_PATH: 1466 case glObj.GEOM_TYPE_PATH:
1467 // Snapping not implemented for these type, but don't throw an error... 1467 // Snapping not implemented for these type, but don't throw an error...
1468 break; 1468 break;
1469 1469
1470 case glObj.GEOM_TYPE_BRUSH_STROKE: 1470 case glObj.GEOM_TYPE_BRUSH_STROKE:
1471 break; //don't throw error because snapping not yet implemented 1471 break; //don't throw error because snapping not yet implemented
1472 1472
1473 case glObj.GEOM_TYPE_CUBIC_BEZIER: 1473 case glObj.GEOM_TYPE_CUBIC_BEZIER:
1474 rtnVal = this.doSnapToContainedElement( eyePt, dir, glObj, hitRec, targetScrPt ); 1474 rtnVal = this.doSnapToContainedElement( eyePt, dir, glObj, hitRec, targetScrPt );
1475 break; 1475 break;
@@ -1519,7 +1519,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1519 // add the projection matrix 1519 // add the projection matrix
1520 var projMat = world.makePerspectiveMatrix(); 1520 var projMat = world.makePerspectiveMatrix();
1521 //var projInv = projMat.inverse(); 1521 //var projInv = projMat.inverse();
1522 var projInv = glmat4.inverse(projMat, []); 1522 var projInv = glmat4.inverse(projMat, []);
1523 var camInv = world.getCameraMatInverse(); 1523 var camInv = world.getCameraMatInverse();
1524 //var glToNDC = projMat.multiply( camInv ); 1524 //var glToNDC = projMat.multiply( camInv );
1525 var glToNDC = glmat4.multiply( projMat, camInv, [] ); 1525 var glToNDC = glmat4.multiply( projMat, camInv, [] );
@@ -1569,9 +1569,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1569 } 1569 }
1570 }, 1570 },
1571 1571
1572 GLToView : 1572 GLToView :
1573 { 1573 {
1574 value: function( glPt, world ) 1574 value: function( glPt, world )
1575 { 1575 {
1576 var projMat = world.makePerspectiveMatrix(); 1576 var projMat = world.makePerspectiveMatrix();
1577 //var mat = projMat.multiply( world.getCameraMatInverse() ); 1577 //var mat = projMat.multiply( world.getCameraMatInverse() );
@@ -2134,7 +2134,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
2134 2134
2135 drawHit : 2135 drawHit :
2136 { 2136 {
2137 value: function( hitRec ) 2137 value: function( hitRec )
2138 { 2138 {
2139 if (hitRec) 2139 if (hitRec)
2140 { 2140 {