aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/view-utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/3D/view-utils.js')
-rwxr-xr-xjs/helper-classes/3D/view-utils.js328
1 files changed, 164 insertions, 164 deletions
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index 3462428f..b7070840 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -140,15 +140,15 @@ exports.ViewUtils = Montage.create(Component, {
140 }, 140 },
141 141
142 /* 142 /*
143 * This method will return a normal to a plane containing the Z axis and either the 143 * This method will return a normal to a plane containing the Z axis and either the
144 * x or y axis of the element. 144 * x or y axis of the element.
145 */ 145 */
146 getNormalToUnprojectedElementPlane: 146 getNormalToUnprojectedElementPlane:
147 { 147 {
148 value: function( elt, axis, localMode ) 148 value: function( elt, axis, localMode )
149 { 149 {
150 var objMat = this.getMatrixFromElement(elt); 150 var objMat = this.getMatrixFromElement(elt);
151 var objMatInv = glmat4.inverse( objMat, [] ); 151 var objMatInv = glmat4.inverse( objMat, [] );
152 152
153 var xVec = [1,0,0]; 153 var xVec = [1,0,0];
154 var yVec = [0,1,0]; 154 var yVec = [0,1,0];
@@ -157,55 +157,55 @@ exports.ViewUtils = Montage.create(Component, {
157 var stage = this.application.ninja.currentDocument.model.documentRoot; 157 var stage = this.application.ninja.currentDocument.model.documentRoot;
158 var stageMat = this.getMatrixFromElement(stage); 158 var stageMat = this.getMatrixFromElement(stage);
159 159
160 var mat = glmat4.multiply( stageMat, objMat, [] ); 160 var mat = glmat4.multiply( stageMat, objMat, [] );
161 161
162 var viewDir; 162 var viewDir;
163 if (localMode) 163 if (localMode)
164 { 164 {
165 var matInv = glmat4.inverse( mat, [] ); 165 var matInv = glmat4.inverse( mat, [] );
166 viewDir = MathUtils.transformVector( [0,0,1], matInv ); 166 viewDir = MathUtils.transformVector( [0,0,1], matInv );
167 } 167 }
168 else 168 else
169 { 169 {
170 var stageInv = glmat4.inverse( stageMat, [] ); 170 var stageInv = glmat4.inverse( stageMat, [] );
171 viewDir = MathUtils.transformVector( [0,0,1], stageInv ); 171 viewDir = MathUtils.transformVector( [0,0,1], stageInv );
172 } 172 }
173 173
174 var plane; 174 var plane;
175 var xDot, yDot, zDot; 175 var xDot, yDot, zDot;
176 switch (axis) 176 switch (axis)
177 { 177 {
178 case 0: 178 case 0:
179 yDot = Math.abs(vecUtils.vecDot(3, yVec, viewDir)); 179 yDot = Math.abs(vecUtils.vecDot(3, yVec, viewDir));
180 zDot = Math.abs(vecUtils.vecDot(3, zVec, viewDir)); 180 zDot = Math.abs(vecUtils.vecDot(3, zVec, viewDir));
181 if(yDot > zDot) 181 if(yDot > zDot)
182 plane = vecUtils.vecCross( 3, zVec, xVec ); 182 plane = vecUtils.vecCross( 3, zVec, xVec );
183 else 183 else
184 plane = vecUtils.vecCross( 3, yVec, xVec ); 184 plane = vecUtils.vecCross( 3, yVec, xVec );
185 break; 185 break;
186 186
187 case 1: 187 case 1:
188 xDot = Math.abs(vecUtils.vecDot(3, yVec, viewDir)); 188 xDot = Math.abs(vecUtils.vecDot(3, yVec, viewDir));
189 zDot = Math.abs(vecUtils.vecDot(3, zVec, viewDir)); 189 zDot = Math.abs(vecUtils.vecDot(3, zVec, viewDir));
190 if(xDot > zDot) 190 if(xDot > zDot)
191 plane = vecUtils.vecCross( 3, zVec, yVec ); 191 plane = vecUtils.vecCross( 3, zVec, yVec );
192 else 192 else
193 plane = vecUtils.vecCross( 3, xVec, yVec ); 193 plane = vecUtils.vecCross( 3, xVec, yVec );
194 break; 194 break;
195 break; 195 break;
196 196
197 case 2: 197 case 2:
198 xDot = Math.abs(vecUtils.vecDot(3, xVec, viewDir)); 198 xDot = Math.abs(vecUtils.vecDot(3, xVec, viewDir));
199 yDot = Math.abs(vecUtils.vecDot(3, yVec, viewDir)); 199 yDot = Math.abs(vecUtils.vecDot(3, yVec, viewDir));
200 200
201 if(xDot > yDot) 201 if(xDot > yDot)
202 plane = vecUtils.vecCross( 3, yVec, zVec ); 202 plane = vecUtils.vecCross( 3, yVec, zVec );
203 else 203 else
204 plane = vecUtils.vecCross( 3, xVec, zVec ); 204 plane = vecUtils.vecCross( 3, xVec, zVec );
205 break; 205 break;
206 } 206 }
207 207
208 if (localMode) plane = MathUtils.transformVector( plane, objMat ); 208 if (localMode) plane = MathUtils.transformVector( plane, objMat );
209 209
210 // The translation value is a point on the plane 210 // The translation value is a point on the plane
211 this.pushViewportObj( elt ); 211 this.pushViewportObj( elt );
@@ -332,11 +332,11 @@ exports.ViewUtils = Montage.create(Component, {
332 value: function( localPt, elt ) { 332 value: function( localPt, elt ) {
333 this.pushViewportObj( elt ); 333 this.pushViewportObj( elt );
334 var viewPt = this.screenToView( localPt[0], localPt[1], localPt[2] ); 334 var viewPt = this.screenToView( localPt[0], localPt[1], localPt[2] );
335 if ((elt == null) || (elt === this._stageElement)) 335 if ((elt == null) || (elt === this._stageElement))
336 { 336 {
337 this.popViewportObj(); 337 this.popViewportObj();
338 return viewPt; 338 return viewPt;
339 } 339 }
340 var mat = this.getMatrixFromElement( elt ); 340 var mat = this.getMatrixFromElement( elt );
341 var worldPt = MathUtils.transformPoint( viewPt, mat ); 341 var worldPt = MathUtils.transformPoint( viewPt, mat );
342 var stageWorldPt = this.postViewToStageWorld( worldPt, elt ); 342 var stageWorldPt = this.postViewToStageWorld( worldPt, elt );
@@ -571,7 +571,7 @@ exports.ViewUtils = Montage.create(Component, {
571 return localPlane; 571 return localPlane;
572 } 572 }
573 }, 573 },
574 574
575 parentToChild: { 575 parentToChild: {
576 value: function( parentPt, child, passthrough ) { 576 value: function( parentPt, child, passthrough ) {
577 var pt = parentPt.slice(0); 577 var pt = parentPt.slice(0);
@@ -620,7 +620,7 @@ exports.ViewUtils = Montage.create(Component, {
620 return childPt; 620 return childPt;
621 } 621 }
622 }, 622 },
623 623
624 parentToChildWorld: { 624 parentToChildWorld: {
625 value: function( parentPt, child ) { 625 value: function( parentPt, child ) {
626 var pt = parentPt.slice(0); 626 var pt = parentPt.slice(0);
@@ -694,7 +694,7 @@ exports.ViewUtils = Montage.create(Component, {
694 return vec; 694 return vec;
695 } 695 }
696 }, 696 },
697 697
698 getElementBounds: { 698 getElementBounds: {
699 value: function( elt, localSpace ) { 699 value: function( elt, localSpace ) {
700 // optional argument localSpace, if true, puts the top left at (0,0). 700 // optional argument localSpace, if true, puts the top left at (0,0).
@@ -876,7 +876,7 @@ exports.ViewUtils = Montage.create(Component, {
876 } 876 }
877 }, 877 },
878 878
879 879
880 unproject: { 880 unproject: {
881 value: function( pt ) { 881 value: function( pt ) {
882 if(!this._perspectiveDist) 882 if(!this._perspectiveDist)
@@ -968,7 +968,7 @@ exports.ViewUtils = Montage.create(Component, {
968 return viewPt; 968 return viewPt;
969 } 969 }
970 }, 970 },
971 971
972 globalScreenToLocalWorld: { 972 globalScreenToLocalWorld: {
973 value: function( globalPt, elt ) { 973 value: function( globalPt, elt ) {
974 var objPt = this.globalToLocal( globalPt, elt ); 974 var objPt = this.globalToLocal( globalPt, elt );
@@ -1336,40 +1336,40 @@ exports.ViewUtils = Montage.create(Component, {
1336/////////////////////////////////////////////////////////////////////////////////// 1336///////////////////////////////////////////////////////////////////////////////////
1337// Montage update map 1337// Montage update map
1338// 1338//
1339// NO LONGER SUPPORTED: 1339// NO LONGER SUPPORTED:
1340// stageManagerModule 1340// stageManagerModule
1341// drawLayoutModule 1341// drawLayoutModule
1342// 1342//
1343// STAGE ACCESSORS: 1343// STAGE ACCESSORS:
1344// activeDocument: this.application.ninja.currentDocument 1344// activeDocument: this.application.ninja.currentDocument
1345// userContent (stage): this.application.ninja.currentDocument.model.documentRoot 1345// userContent (stage): this.application.ninja.currentDocument.model.documentRoot
1346// stageManager: this.application.ninja.stage // MainApp\js\stage\stage.reel\stage.js 1346// stageManager: this.application.ninja.stage // MainApp\js\stage\stage.reel\stage.js
1347// stageManager._canvas: this.application.ninja.stage.canvas 1347// stageManager._canvas: this.application.ninja.stage.canvas
1348// stageManager.layoutCanvas: this.application.ninja.stage.layoutCanvas 1348// stageManager.layoutCanvas: this.application.ninja.stage.layoutCanvas
1349// stageManager.drawingCanvas: this.application.ninja.stage.drawingCanvas 1349// stageManager.drawingCanvas: this.application.ninja.stage.drawingCanvas
1350// viewUtils: stage.viewUtils; 1350// viewUtils: stage.viewUtils;
1351// snapManager stage.snapManager; 1351// snapManager stage.snapManager;
1352// 1352//
1353// REDRAW FUNCTIONS 1353// REDRAW FUNCTIONS
1354// window.stageManager.drawSelectionRec(true): this.application.ninja.stage.updateStage = true; 1354// window.stageManager.drawSelectionRec(true): this.application.ninja.stage.updateStage = true;
1355// drawLayoutModule.drawLayout.redrawDocument() OR 1355// drawLayoutModule.drawLayout.redrawDocument() OR
1356// window.stageManager.drawSelectionRec(true) this.getStage().draw();