diff options
author | hwc487 | 2012-01-27 15:52:36 -0800 |
---|---|---|
committer | hwc487 | 2012-01-27 15:52:36 -0800 |
commit | 86a801c057fc3b0580d6130be5740c2ee503444f (patch) | |
tree | 8b014e981273464afde4e0603cdf70c6e90eee48 /js/tools | |
parent | 302e3eb01037ff550bc93547cb8d5d0a0780b312 (diff) | |
download | ninja-86a801c057fc3b0580d6130be5740c2ee503444f.tar.gz |
updated from old repo
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/PanTool.js | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index ba40b020..73095c57 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 ) |
@@ -220,6 +221,7 @@ exports.PanTool = Montage.create(toolBase, | |||
220 | var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); | 221 | var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); |
221 | 222 | ||
222 | this._lastGPt = this._globalPt.slice(); | 223 | this._lastGPt = this._globalPt.slice(); |
224 | this._lastY = this._lastGPt[1]; | ||
223 | 225 | ||
224 | // set up the matrices we will be needing | 226 | // set up the matrices we will be needing |
225 | var eltToStageWorldMat = glmat4.multiply( ucMat, viewUtils.getObjToStageWorldMatrix(elt, true), []); | 227 | var eltToStageWorldMat = glmat4.multiply( ucMat, viewUtils.getObjToStageWorldMatrix(elt, true), []); |
@@ -275,14 +277,19 @@ exports.PanTool = Montage.create(toolBase, | |||
275 | { | 277 | { |
276 | if (this._isDrawing) | 278 | if (this._isDrawing) |
277 | { | 279 | { |
278 | //console.log( "PanTool.mouseMove (drag)" ); | ||
279 | |||
280 | // get the global screen point | 280 | // get the global screen point |
281 | var gPt = [point.x, point.y, this._globalPt[2]]; | 281 | var gPt = [point.x, point.y, this._globalPt[2]]; |
282 | if (this._altKeyDown) | ||
283 | { | ||
284 | var dy = 5*(point.y - this._lastY); | ||
285 | this._globalPt[2] += dy; | ||
286 | gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; | ||
287 | } | ||
282 | 288 | ||
283 | // update the scrollbars | 289 | // update the scrollbars |
284 | var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); | 290 | var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); |
285 | this._lastGPt = gPt.slice(); | 291 | this._lastGPt = gPt.slice(); |
292 | this._lastY = point.y; | ||
286 | 293 | ||
287 | var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, | 294 | var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, |
288 | oldTop = this.application.ninja.stage._iframeContainer.scrollTop; | 295 | oldTop = this.application.ninja.stage._iframeContainer.scrollTop; |
@@ -297,27 +304,13 @@ exports.PanTool = Montage.create(toolBase, | |||
297 | this.updateGlobalToUCWorldMatrix(); | 304 | this.updateGlobalToUCWorldMatrix(); |
298 | 305 | ||
299 | var wPt = MathUtils.transformAndDivideHomogeneousPoint( gPt, this._globalToUCWorld ); | 306 | var wPt = MathUtils.transformAndDivideHomogeneousPoint( gPt, this._globalToUCWorld ); |
300 | //console.log( "wPt: " + wPt ); | ||
301 | var delta = vecUtils.vecSubtract( 3, wPt, this._worldPt ); | 307 | var delta = vecUtils.vecSubtract( 3, wPt, this._worldPt ); |
302 | if (this._altKeyDown) | 308 | |
303 | { | 309 | if (!this._altKeyDown) |
304 | //console.log( "moveZ" ); | ||
305 | var dist = vecUtils.vecMag(2, delta); | ||
306 | delta[0] = 0; delta[1] = 0; delta[2] = dist; | ||
307 | var dy = point.y - this._globalPt[1]; | ||
308 | if (dy < 0) delta[2] = -delta[2]; | ||
309 | } | ||
310 | else | ||
311 | { | ||
312 | console.log( "NOT MOVING Z" ); | ||
313 | delta[2] = 0; | 310 | delta[2] = 0; |
314 | } | ||
315 | var transMat = Matrix.Translation( delta ); | 311 | var transMat = Matrix.Translation( delta ); |
316 | this._worldPt = wPt; | 312 | this._worldPt = wPt; |
317 | 313 | ||
318 | if (this._altKeyDown) | ||
319 | this._globalPt[1] = point.y; | ||
320 | |||
321 | // update everything | 314 | // update everything |
322 | this.applyDeltaMat( transMat ); | 315 | this.applyDeltaMat( transMat ); |
323 | } | 316 | } |