aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/controllers/elements/canvas-controller.js14
-rw-r--r--js/helper-classes/3D/draw-utils.js3
-rw-r--r--js/helper-classes/3D/snap-manager.js11
-rw-r--r--js/stage/stage.reel/stage.js51
-rw-r--r--js/tools/PanTool.js33
-rw-r--r--js/tools/ZoomTool.js39
6 files changed, 77 insertions, 74 deletions
diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js
index 21de9879..b5df3911 100644
--- a/js/controllers/elements/canvas-controller.js
+++ b/js/controllers/elements/canvas-controller.js
@@ -34,12 +34,12 @@ exports.CanvasController = Montage.create(ElementController, {
34 } 34 }
35 } 35 }
36 }, 36 },
37 37
38 setProperties: { 38 setProperties: {
39 value: function(el, props, index) { 39 value: function(el, props, index) {
40 for(var p in props) { 40 for(var p in props) {
41 el.elementModel.controller.setProperty(el, p, props[p][index]); 41 el.elementModel.controller.setProperty(el, p, props[p][index]);
42 } 42 }
43 } 43 }
44 } 44 }
45}); \ No newline at end of file 45}); \ No newline at end of file
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index c26a5cd1..fd96af4d 100644
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -1089,7 +1089,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
1089 var resMat = glmat4.multiply( tMat, mat, [] ); 1089 var resMat = glmat4.multiply( tMat, mat, [] );
1090 var origin = [0,0,0,1]; 1090 var origin = [0,0,0,1];
1091 1091
1092 var arrowSize = 50; 1092 var zoomFactor = this.application.ninja.documentBar.zoomFactor/100.0;
1093 var arrowSize = 50 / zoomFactor;
1093 var xAxis = [arrowSize,0,0,1]; 1094 var xAxis = [arrowSize,0,0,1];
1094 //var rO = resMat.multiply(origin); 1095 //var rO = resMat.multiply(origin);
1095 var rO = glmat4.multiplyVec3( resMat, origin, []); 1096 var rO = glmat4.multiplyVec3( resMat, origin, []);
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 3ed96082..8819f637 100644
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -1780,7 +1780,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1780 var mergedSnap = this.mergeHitRecords( hitRecs ); 1780 var mergedSnap = this.mergeHitRecords( hitRecs );
1781 if (mergedSnap) 1781 if (mergedSnap)
1782 { 1782 {
1783 while (hitRecs.length > 0) hitRecs.pop(); 1783 while (hitRecs.length > 0) hitRecs.pop();
1784 hitRecs.push( mergedSnap ); 1784 hitRecs.push( mergedSnap );
1785 //console.log( "merged snaps" ); 1785 //console.log( "merged snaps" );
1786 } 1786 }
@@ -1836,6 +1836,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1836 hSnap.setLocalPoint( localPt ); 1836 hSnap.setLocalPoint( localPt );
1837 hSnap.setScreenPoint( scrPt ); 1837 hSnap.setScreenPoint( scrPt );
1838 hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); 1838 hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED );
1839 hSnap.setElement( stage );
1840 hSnap.setPlane( [0,0,1,0] );
1841 hSnap.setPlaneMatrix( Matrix.I(4) );
1839 if (vSnap.hasAssociatedScreenPoint() ) 1842 if (vSnap.hasAssociatedScreenPoint() )
1840 hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() ); 1843 hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() );
1841 if (vSnap.hasAssociatedScreenPoint2() ) 1844 if (vSnap.hasAssociatedScreenPoint2() )
@@ -1882,6 +1885,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1882 hSnap.setLocalPoint( localPt ); 1885 hSnap.setLocalPoint( localPt );
1883 hSnap.setScreenPoint( scrPt ); 1886 hSnap.setScreenPoint( scrPt );
1884 hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); 1887 hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED );
1888 hSnap.setElement( stage );
1889 hSnap.setPlane( [0,0,1,0] );
1890 hSnap.setPlaneMatrix( Matrix.I(4) );
1885 if (vSnap.hasAssociatedScreenPoint() ) 1891 if (vSnap.hasAssociatedScreenPoint() )
1886 hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() ); 1892 hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() );
1887 if (vSnap.hasAssociatedScreenPoint2() ) 1893 if (vSnap.hasAssociatedScreenPoint2() )
@@ -1934,6 +1940,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1934 hSnap.setLocalPoint( localPt ); 1940 hSnap.setLocalPoint( localPt );
1935 hSnap.setScreenPoint( scrPt ); 1941 hSnap.setScreenPoint( scrPt );
1936 hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); 1942 hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED );
1943 hSnap.setElement( stage );
1944 hSnap.setPlane( [0,0,1,0] );
1945 hSnap.setPlaneMatrix( Matrix.I(4) );
1937 if (vSnap.hasAssociatedScreenPoint() ) 1946 if (vSnap.hasAssociatedScreenPoint() )
1938 hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() ); 1947 hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() );
1939 if (vSnap.hasAssociatedScreenPoint2() ) 1948 if (vSnap.hasAssociatedScreenPoint2() )
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 8c4efd58..9e2df5a2 100644
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -787,14 +787,9 @@ exports.Stage = Montage.create(Component, {
787 var userContent = this.application.ninja.currentDocument.documentRoot; 787 var userContent = this.application.ninja.currentDocument.documentRoot;
788 if (userContent) 788 if (userContent)
789 { 789 {
790 var w = userContent.offsetWidth, 790 var w = this._canvas.width,
791 h = userContent.offsetHeight; 791 h = this._canvas.height;
792 if(userContent.width) 792 var globalPt = [w/2, h/2, 0];
793 w = userContent.width;
794 if(userContent.height)
795 h = userContent.height;
796 var localPt = [ w/2, h/2, 0];
797 var globalPt = this.stageDeps.viewUtils.localToGlobal( localPt, userContent );
798 793
799 this.stageDeps.viewUtils.setStageZoom( globalPt, value/100 ); 794 this.stageDeps.viewUtils.setStageZoom( globalPt, value/100 );
800 795
@@ -811,6 +806,36 @@ exports.Stage = Montage.create(Component, {
811 } 806 }
812 }, 807 },
813 808
809 getPlaneForView:
810 {
811 value: function( side )
812 {
813 var plane = [0,0,1,0];
814 switch(side)
815 {
816 case "top":
817 plane = [0,1,0,0];
818 plane[3] = this.application.ninja.currentDocument.documentRoot.offsetHeight / 2.0;
819 break;
820
821 case "side":
822 plane = [1,0,0,0];
823 plane[3] = this.application.ninja.currentDocument.documentRoot.offsetWidth / 2.0;
824 break;
825
826 case "front":
827 plane = [0,0,1,0];
828 break;
829
830 default:
831 console.log( "unrecognized view in snapManager.getPlaneForView: " + side );
832 break;
833 }
834
835 return plane;
836 }
837 },
838
814 setStageView: { 839 setStageView: {
815 value: function(side) { 840 value: function(side) {
816 var mat, 841 var mat,
@@ -821,32 +846,26 @@ exports.Stage = Montage.create(Component, {
821 currentDoc.elementModel.props3D.ResetRotationValues(); 846 currentDoc.elementModel.props3D.ResetRotationValues();
822 847
823 848
824 switch(side) { 849 switch(side){
825 case "top": 850 case "top":
826 mat = Matrix.RotationX(Math.PI * 270.0/180.0); 851 mat = Matrix.RotationX(Math.PI * 270.0/180.0);
827
828 drawUtils.drawXY = drawUtils.drawYZ = false; 852 drawUtils.drawXY = drawUtils.drawYZ = false;
829 drawUtils.drawXZ = isDrawingGrid; 853 drawUtils.drawXZ = isDrawingGrid;
830 workingPlane = [0,1,0,0];
831 break; 854 break;
832 855
833 case "side": 856 case "side":
834 mat = Matrix.RotationY(Math.PI * 270/180); 857 mat = Matrix.RotationY(Math.PI * 270/180);
835
836 drawUtils.drawXY = drawUtils.drawXZ = false; 858 drawUtils.drawXY = drawUtils.drawXZ = false;
837 drawUtils.drawYZ = isDrawingGrid; 859 drawUtils.drawYZ = isDrawingGrid;
838 workingPlane = [1,0,0,0];
839 break; 860 break;
840 861
841 case "front": 862 case "front":
842 mat = Matrix.I(4); 863 mat = Matrix.I(4);
843
844 drawUtils.drawYZ = drawUtils.drawXZ = false; 864 drawUtils.drawYZ = drawUtils.drawXZ = false;
845 drawUtils.drawXY = isDrawingGrid; 865 drawUtils.drawXY = isDrawingGrid;
846 workingPlane = [0,0,1,0];
847 break; 866 break;
848 } 867 }
849 868 workingPlane = this.getPlaneForView( side );
850 869
851 this.stageDeps.viewUtils.setMatrixForElement(currentDoc, mat, false); 870 this.stageDeps.viewUtils.setMatrixForElement(currentDoc, mat, false);
852 871
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js
index ba40b020..71301d46 100644
--- a/js/tools/PanTool.js
+++ b/js/tools/PanTool.js
@@ -19,6 +19,7 @@ exports.PanTool = Montage.create(toolBase,
19 _globalPt :{value: [0,0] , writable:true}, 19 _globalPt :{value: [0,0] , writable:true},
20 _globalToUCWorld :{value: [] , writable:true}, 20 _globalToUCWorld :{value: [] , writable:true},
21 _lastGPt :{value: [0,0], writable:true}, 21 _lastGPt :{value: [0,0], writable:true},
22 _lastY :{value: 0, writable:true},
22 23
23 Configure: { 24 Configure: {
24 value: function ( doActivate ) 25 value: function ( doActivate )
@@ -43,6 +44,7 @@ exports.PanTool = Montage.create(toolBase,
43 HandleLeftButtonDown: { 44 HandleLeftButtonDown: {
44 value : function ( event ) { 45 value : function ( event ) {
45 this._isDrawing = true; 46 this._isDrawing = true;
47 this.isDrawing = true;
46 48