aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes
diff options
context:
space:
mode:
authorArmen Kesablyan2012-05-14 11:45:11 -0700
committerArmen Kesablyan2012-05-14 11:45:11 -0700
commit9e6c0a247bd2f14d92278bcd97fff40277b71667 (patch)
tree4194388c03814b9168922dbf2907edf426295874 /js/helper-classes
parent9fc3b70bf57e10846e71808c6041fbc339a435d1 (diff)
parent27f4cacb39de1c2e3910748dadc9fc16d0655480 (diff)
downloadninja-9e6c0a247bd2f14d92278bcd97fff40277b71667.tar.gz
Merge branch 'refs/heads/masterDomArc' into binding
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js4
-rwxr-xr-xjs/helper-classes/3D/view-utils.js80
2 files changed, 67 insertions, 17 deletions
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 31e3e540..5a36e367 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -1949,6 +1949,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1949 var localPt = hitRec.getLocalPoint(); 1949 var localPt = hitRec.getLocalPoint();
1950 var planeMat = hitRec.getPlaneMatrix(); 1950 var planeMat = hitRec.getPlaneMatrix();
1951 var stageWorldPt; 1951 var stageWorldPt;
1952
1953 /*
1952 if(inGlobalMode) 1954 if(inGlobalMode)
1953 { 1955 {
1954 stageWorldPt = MathUtils.transformPoint(localPt,planeMat); 1956 stageWorldPt = MathUtils.transformPoint(localPt,planeMat);
@@ -1957,6 +1959,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1957 { 1959 {
1958 stageWorldPt = viewUtils.postViewToStageWorld( MathUtils.transformPoint(localPt,planeMat), elt ); 1960 stageWorldPt = viewUtils.postViewToStageWorld( MathUtils.transformPoint(localPt,planeMat), elt );
1959 } 1961 }
1962 */
1963 stageWorldPt = viewUtils.postViewToStageWorld( MathUtils.transformPoint(localPt,planeMat), elt );
1960 1964
1961 /* 1965 /*
1962 // get a working plane parallel to the current working plane through the stage world point 1966 // get a working plane parallel to the current working plane through the stage world point
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index 36d6f8c4..5dc099ee 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -124,35 +124,81 @@ exports.ViewUtils = Montage.create(Component, {
124 } 124 }
125 }, 125 },
126 126
127 getNormalToUnprojectedElementPlane: { 127 /*
128 value: function( elt ) { 128 * This method will return a normal to a plane containing the Z axis and either the
129 var mat = this.getMatrixFromElement(elt); 129 * x or y axis of the element.
130 */
131 getNormalToUnprojectedElementPlane:
132 {
133 value: function( elt, axis, localMode )
134 {
135 var objMat = this.getMatrixFromElement(elt);
136 var objMatInv = glmat4.inverse( objMat, [] );
130 137
131 var xVec = [mat[0], mat[1], mat[2], mat[3]]; 138 var xVec = [1,0,0];
132 var yVec = [mat[4], mat[5], mat[6], mat[7]]; 139 var yVec = [0,1,0];
140 var zVec = [0,0,1];
133 141
134 var stage = this.application.ninja.currentDocument.documentRoot; 142 var stage = this.application.ninja.currentDocument.documentRoot;
135 var stageMat = this.getMatrixFromElement(stage); 143 var stageMat = this.getMatrixFromElement(stage);
136 var stagePlane = [stageMat[8], stageMat[9], stageMat[10], stageMat[11]];
137 144
145 var mat = glmat4.multiply( stageMat, objMat, [] );
146
147 var viewDir;
148 if (localMode)
149 {
150 var matInv = glmat4.inverse( mat, [] );
151 viewDir = MathUtils.transformVector( [0,0,1], matInv );
152 }
153 else
154 {
155 var stageInv = glmat4.inverse( stageMat, [] );
156 viewDir = MathUtils.transformVector( [0,0,1], stageInv );
157 }
158
159 /*
138 if (elt === stage) 160 if (elt === stage)
139 { 161 {
140 xVec = [1,0,0]; 162 xVec = [1,0,0];
141 yVec = [0,1,0]; 163 yVec = [0,1,0];
142 } 164 }
165 */
143 166
144 var xDot = Math.abs(vecUtils.vecDot(3, xVec, stagePlane)); 167 var plane;
145 var yDot = Math.abs(vecUtils.vecDot(3, yVec, stagePlane)); 168 var xDot, yDot, zDot;
169 switch (axis)
170 {
171 case 0:
172 yDot = Math.abs(vecUtils.vecDot(3, yVec, viewDir));
173 zDot = Math.abs(vecUtils.vecDot(3, zVec, viewDir));
174 if(yDot > zDot)
175 plane = vecUtils.vecCross( 3, zVec, xVec );
176 else
177 plane = vecUtils.vecCross( 3, yVec, xVec );
178 break;
179
180 case 1:
181 xDot = Math.abs(vecUtils.vecDot(3, yVec, viewDir));
182 zDot = Math.abs(vecUtils.vecDot(3, zVec, viewDir));
183 if(xDot > zDot)
184 plane = vecUtils.vecCross( 3, zVec, yVec );
185 else
186 plane = vecUtils.vecCross( 3, xVec, yVec );
187 break;
188 break;
189
190 case 2:
191 xDot = Math.abs(vecUtils.vecDot(3, xVec, viewDir));
192 yDot = Math.abs(vecUtils.vecDot(3, yVec, viewDir));
193
194 if(xDot > yDot)
195 plane = vecUtils.vecCross( 3, yVec, zVec );
196 else
197 plane = vecUtils.vecCross( 3, xVec, zVec );
198 break;
199 }
146 200
147 var plane; 201 if (localMode) plane = MathUtils.transformVector( plane, objMat );
148 if(xDot > yDot)
149 {
150 plane = xVec;
151 }
152 else
153 {
154 plane = yVec;
155 }
156 202
157 // The translation value is a point on the plane 203 // The translation value is a point on the plane
158 this.pushViewportObj( elt ); 204 this.pushViewportObj( elt );