diff options
author | Kris Kowal | 2012-07-06 11:52:06 -0700 |
---|---|---|
committer | Kris Kowal | 2012-07-06 15:01:48 -0700 |
commit | 648ee61ae84216d0236e0dbc211addc13b2cfa3a (patch) | |
tree | 8f0f55557bd0c47a84e49c1977c950645d284607 /js/helper-classes/3D/view-utils.js | |
parent | aedd14b18695d031f695d27dfbd94df5614495bb (diff) | |
download | ninja-648ee61ae84216d0236e0dbc211addc13b2cfa3a.tar.gz |
Expand tabs
Diffstat (limited to 'js/helper-classes/3D/view-utils.js')
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 318 |
1 files changed, 159 insertions, 159 deletions
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 3462428f..1973d254 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 ); |
@@ -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(); | 1356 | // window.stageManager.drawSelectionRec(true) this.getStage().draw(); |
1357 | // drawLayoutModule.drawLayout.redrawDocument(); | 1357 | // drawLayoutModule.drawLayout.redrawDocument(); |
1358 | 1358 | ||
1359 | // SELECTION MANAGER | 1359 | // SELECTION MANAGER |
1360 | // selected elements: this.application.ninja.selectedElements | 1360 | // selected elements: this.application.ninja.selectedElements |
1361 | // selectionManager this.application.ninja.selectionController | 1361 | // selectionManager this.application.ninja.selectionController |
1362 | // selected elements: this.application.ninja.selectionController.selectElements | 1362 | // selected elements: this.application.ninja.selectionController.selectElements |
1363 | // | 1363 | // |
1364 | // MISCELLANEOUS | 1364 | // MISCELLANEOUS |
1365 | // event.layerX/Y: var pt = viewUtils.getMousePoint(event); | 1365 | // event.layerX/Y: var pt = viewUtils.getMousePoint(event); |
1366 | 1366 | ||
1367 | getStage: { | 1367 | getStage: { |
1368 | value: function() | 1368 | value: function() |
1369 | { | 1369 | { |
1370 | return this.application.ninja.stage.snapManager.getStage(); | 1370 | return this.application.ninja.stage.snapManager.getStage(); |
1371 | } | 1371 | } |
1372 | }, | 1372 | }, |
1373 | 1373 | ||
1374 | clearStageTranslation: { | 1374 | clearStageTranslation: { |
1375 | value: function() { | 1375 | value: function() { |
@@ -1388,10 +1388,10 @@ exports.ViewUtils = Montage.create(Component, { | |||
1388 | var deltaMat = glmat4.multiply( targetMat, ucMatInv, [] ); | 1388 | var deltaMat = glmat4.multiply( targetMat, ucMatInv, [] ); |
1389 | this.setMatrixForElement(userContent, targetMat ); | 1389 | this.setMatrixForElement(userContent, targetMat ); |
1390 | } | 1390 | } |
1391 | } | 1391 | } |
1392 | }, | 1392 | }, |
1393 | 1393 | ||
1394 | setStageZoom: { | 1394 | setStageZoom: { |
1395 | value:function( globalPt, zoomFactor ) { | 1395 | value:function( globalPt, zoomFactor ) { |
1396 | var localPt; | 1396 | var localPt; |
1397 | var tmp1, tmp2, |