diff options
author | Kruti Shah | 2012-05-31 10:44:45 -0700 |
---|---|---|
committer | Kruti Shah | 2012-05-31 10:44:45 -0700 |
commit | c350cc1c060fdf17357ddadce024267943784593 (patch) | |
tree | 453f86e88f1ee1dfda6fb4b7cc7b17e306e39536 /js/helper-classes/3D/view-utils.js | |
parent | fdc4f5c7f81ae3b9adeca2232e60268b4be594a2 (diff) | |
parent | 121d0e616f48aa7cd048763554089c20a1883d7a (diff) | |
download | ninja-c350cc1c060fdf17357ddadce024267943784593.tar.gz |
Merge branch 'refs/heads/TimelineUberjd' into TimelineUber
Conflicts:
js/panels/Timeline/Layer.reel/Layer.js
Signed-off-by: Kruti Shah <kruti.shah@motorola.com>
Diffstat (limited to 'js/helper-classes/3D/view-utils.js')
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 101 |
1 files changed, 36 insertions, 65 deletions
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 919f7c50..a3d09404 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js | |||
@@ -18,18 +18,11 @@ exports.ViewUtils = Montage.create(Component, { | |||
18 | // Instance variables | 18 | // Instance variables |
19 | /////////////////////////////////////////////////////////////////////// | 19 | /////////////////////////////////////////////////////////////////////// |
20 | 20 | ||
21 | m_viewportObj : { value: null, writable: true}, | 21 | m_viewportObj : { value: null}, |
22 | _perspectiveDist: { value: null, writable: true}, | 22 | _perspectiveDist: { value: null}, |
23 | 23 | ||
24 | // keep a stack of viewport objects | 24 | // keep a stack of viewport objects |
25 | _viewportObjStack: { value: [], writable: true }, | 25 | _viewportObjStack: { value: []}, |
26 | |||
27 | _currentDocument: { value: null , writable: true}, | ||
28 | _userContentLeft: { value: null , writable: true}, | ||
29 | _userContentTop: { value: null , writable: true}, | ||
30 | |||
31 | _rootElement: { value: null, writable: true}, | ||
32 | _stageElement: { value: null, writable: true}, | ||
33 | 26 | ||
34 | /////////////////////////////////////////////////////////////////////// | 27 | /////////////////////////////////////////////////////////////////////// |
35 | // Property accessors | 28 | // Property accessors |
@@ -43,18 +36,6 @@ exports.ViewUtils = Montage.create(Component, { | |||
43 | }, | 36 | }, |
44 | getViewportObj: { value: function() { return this.m_viewportObj; } }, | 37 | getViewportObj: { value: function() { return this.m_viewportObj; } }, |
45 | 38 | ||
46 | setRootElement: { value: function( elt ) { this._rootElement = elt; } }, | ||
47 | getRootElement: { value: function () { return this._rootElement; } }, | ||
48 | |||
49 | setStageElement: { value: function( elt ) { this._stageElement = elt; } }, | ||
50 | getStageElement: { value: function () { return this._stageElement; } }, | ||
51 | |||
52 | setCurrentDocument: { value: function(value) { this._currentDocument = value; }}, | ||
53 | |||
54 | setUserContentLeft: { value: function(value) { this._userContentLeft = value; }}, | ||
55 | setUserContentTop: { value: function(value) { this._userContentTop = value; }}, | ||
56 | |||
57 | |||
58 | getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, | 39 | getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, |
59 | 40 | ||
60 | /////////////////////////////////////////////////////////////////////// | 41 | /////////////////////////////////////////////////////////////////////// |
@@ -139,7 +120,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
139 | var yVec = [0,1,0]; | 120 | var yVec = [0,1,0]; |
140 | var zVec = [0,0,1]; | 121 | var zVec = [0,0,1]; |
141 | 122 | ||
142 | var stage = this.application.ninja.currentDocument.documentRoot; | 123 | var stage = this.application.ninja.currentDocument.model.documentRoot; |
143 | var stageMat = this.getMatrixFromElement(stage); | 124 | var stageMat = this.getMatrixFromElement(stage); |
144 | 125 | ||
145 | var mat = glmat4.multiply( stageMat, objMat, [] ); | 126 | var mat = glmat4.multiply( stageMat, objMat, [] ); |
@@ -156,14 +137,6 @@ exports.ViewUtils = Montage.create(Component, { | |||
156 | viewDir = MathUtils.transformVector( [0,0,1], stageInv ); | 137 | viewDir = MathUtils.transformVector( [0,0,1], stageInv ); |
157 | } | 138 | } |
158 | 139 | ||
159 | /* | ||
160 | if (elt === stage) | ||
161 | { | ||
162 | xVec = [1,0,0]; | ||
163 | yVec = [0,1,0]; | ||
164 | } | ||
165 | */ | ||
166 | |||
167 | var plane; | 140 | var plane; |
168 | var xDot, yDot, zDot; | 141 | var xDot, yDot, zDot; |
169 | switch (axis) | 142 | switch (axis) |
@@ -288,6 +261,11 @@ exports.ViewUtils = Montage.create(Component, { | |||
288 | value: function( localPt, elt ) { | 261 | value: function( localPt, elt ) { |
289 | this.pushViewportObj( elt ); | 262 | this.pushViewportObj( elt ); |
290 | var viewPt = this.screenToView( localPt[0], localPt[1], localPt[2] ); | 263 | var viewPt = this.screenToView( localPt[0], localPt[1], localPt[2] ); |
264 | if ((elt == null) || (elt === this._stageElement)) | ||
265 | { | ||
266 | this.popViewportObj(); | ||
267 | return viewPt; | ||
268 | } | ||
291 | var mat = this.getMatrixFromElement( elt ); | 269 | var mat = this.getMatrixFromElement( elt ); |
292 | var worldPt = MathUtils.transformPoint( viewPt, mat ); | 270 | var worldPt = MathUtils.transformPoint( viewPt, mat ); |
293 | var stageWorldPt = this.postViewToStageWorld( worldPt, elt ); | 271 | var stageWorldPt = this.postViewToStageWorld( worldPt, elt ); |
@@ -302,7 +280,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
302 | // into stage world space. | 280 | // into stage world space. |
303 | postViewToStageWorld: { | 281 | postViewToStageWorld: { |
304 | value: function( localPt, elt ) { | 282 | value: function( localPt, elt ) { |
305 | if ((elt == null) || (elt === this._stageElement)) return localPt; | 283 | if ((elt == null) || (elt === this.application.ninja.currentDocument.model.documentRoot)) return localPt; |
306 | 284 | ||
307 | // get the 3D transformation and 2D offset from the element | 285 | // get the 3D transformation and 2D offset from the element |
308 | var pt = localPt.slice(0); | 286 | var pt = localPt.slice(0); |
@@ -329,7 +307,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
329 | this.popViewportObj(); | 307 | this.popViewportObj(); |
330 | 308 | ||
331 | // check if we are done | 309 | // check if we are done |
332 | if (parent === this._stageElement) break; | 310 | if (parent === this.application.ninja.currentDocument.model.documentRoot) break; |
333 | 311 | ||
334 | if (this.elementHas3D( parent )) | 312 | if (this.elementHas3D( parent )) |
335 | { | 313 | { |
@@ -354,15 +332,17 @@ exports.ViewUtils = Montage.create(Component, { | |||
354 | 332 | ||
355 | // transform the bounds up the tree | 333 | // transform the bounds up the tree |
356 | var child = elt; | 334 | var child = elt; |
357 | var parent = elt.offsetParent; | 335 | while ( child ) |
358 | while ( parent ) | ||
359 | { | 336 | { |
360 | pt = this.childToParent( pt, child ); | 337 | pt = this.childToParent( pt, child ); |
361 | 338 | ||
362 | if (parent === this._rootElement) break; | 339 | // if (child === this.application.ninja.currentDocument.model.documentRoot) break; |
340 | // child = child.offsetParent; | ||
363 | 341 | ||
364 | child = parent; | 342 | if (child === this.application.ninja.currentDocument.model.documentRoot) break; |
365 | parent = parent.offsetParent; | 343 | if (child === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; |
344 | child = child.offsetParent; | ||
345 | if (child === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; | ||
366 | } | 346 | } |
367 | 347 | ||
368 | ///////////////////////////////////////////////////////// | 348 | ///////////////////////////////////////////////////////// |
@@ -398,7 +378,8 @@ exports.ViewUtils = Montage.create(Component, { | |||
398 | 378 | ||
399 | // transform the bounds up the tree | 379 | // transform the bounds up the tree |
400 | var parent = child.offsetParent; | 380 | var parent = child.offsetParent; |
401 | if ( parent ) | 381 | // TODO - Should have a different way to check for new template mode |
382 | if ( parent || (child === this.application.ninja.currentDocument.model.documentRoot) ) | ||
402 | { | 383 | { |
403 | this.setViewportObj( child ); | 384 | this.setViewportObj( child ); |
404 | 385 | ||
@@ -411,7 +392,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
411 | { | 392 | { |
412 | // TODO - Commenting out flatten support until new perspective workflow is fully working | 393 | // TODO - Commenting out flatten support until new perspective workflow is fully working |
413 | // if (flatten) pt[2] = 0; | 394 | // if (flatten) pt[2] = 0; |
414 | // var flatten = (parent !== this._rootElement) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); | 395 | // var flatten = (parent !== this.application.ninja.currentDocument.model.documentRoot.parentNode) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); |
415 | // if(flatten) | 396 | // if(flatten) |
416 | // { | 397 | // { |
417 | // pt[2] = 0; | 398 | // pt[2] = 0; |
@@ -471,7 +452,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
471 | // get the four corners of the element in global space | 452 | // get the four corners of the element in global space |
472 | var bounds = this.getElementViewBounds3D( elt ); | 453 | var bounds = this.getElementViewBounds3D( elt ); |
473 | var bounds3D = new Array(); | 454 | var bounds3D = new Array(); |
474 | var stage = this.application.ninja.currentDocument.documentRoot; | 455 | var stage = this.application.ninja.currentDocument.model.documentRoot; |
475 | for (var i=0; i<3; i++) | 456 | for (var i=0; i<3; i++) |
476 | { | 457 | { |
477 | var gPt = this.localToGlobal( bounds[i], elt ); | 458 | var gPt = this.localToGlobal( bounds[i], elt ); |
@@ -696,7 +677,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
696 | // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; | 677 | // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; |
697 | // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; | 678 | // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; |
698 | var offset = [xOff, yOff]; | 679 | var offset = [xOff, yOff]; |
699 | if(elt.offsetParent && (elt.offsetParent !== this._stageElement)) | 680 | if(elt.offsetParent && (elt.offsetParent !== this.application.ninja.currentDocument.model.documentRoot)) |
700 | { | 681 | { |
701 | var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); | 682 | var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); |
702 | 683 | ||
@@ -712,12 +693,12 @@ exports.ViewUtils = Montage.create(Component, { | |||
712 | } | 693 | } |
713 | } | 694 | } |
714 | 695 | ||
715 | if(elt === this._stageElement) | 696 | if(elt === this.application.ninja.currentDocument.model.documentRoot) |
716 | { | 697 | { |
717 | // TODO - Call a routine from the user document controller to get the offsets/margins | 698 | // TODO - Call a routine from the user document controller to get the offsets/margins |
718 | // Once we expose the document controller to ViewUtils | 699 | // Once we expose the document controller to ViewUtils |
719 | offset[0] += this._userContentLeft; | 700 | offset[0] += this.application.ninja.stage._userContentLeft; |
720 | offset[1] += this._userContentTop; | 701 | offset[1] += this.application.ninja.stage._userContentTop; |
721 | } | 702 | } |
722 | 703 | ||
723 | return offset; | 704 | return offset; |
@@ -889,7 +870,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
889 | { | 870 | { |
890 | value: function() | 871 | value: function() |
891 | { | 872 | { |
892 | var stage = this.application.ninja.currentDocument.documentRoot; | 873 | var stage = this.application.ninja.currentDocument.model.documentRoot; |
893 | 874 | ||