diff options
author | Ananya Sen | 2012-06-04 10:43:29 -0700 |
---|---|---|
committer | Ananya Sen | 2012-06-04 10:43:29 -0700 |
commit | 6fb29883329c9c42a8b406128b92c0e6323a47be (patch) | |
tree | 07f46e88bccf9cdb7d4e6818e1b646b0d19f05b9 /js/helper-classes/3D/view-utils.js | |
parent | cf097ec69e35c07ecae5a105ed5eeb78291c9ac2 (diff) | |
parent | c1ec69879028220b0c3f11ad6e24035bf527802c (diff) | |
download | ninja-6fb29883329c9c42a8b406128b92c0e6323a47be.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into cut-copy-paste
Conflicts:
js/ninja.reel/ninja.html
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/helper-classes/3D/view-utils.js')
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index a3d09404..5a128408 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js | |||
@@ -24,6 +24,9 @@ exports.ViewUtils = Montage.create(Component, { | |||
24 | // keep a stack of viewport objects | 24 | // keep a stack of viewport objects |
25 | _viewportObjStack: { value: []}, | 25 | _viewportObjStack: { value: []}, |
26 | 26 | ||
27 | _rootElement: { value: null}, | ||
28 | _stageElement: { value: null}, | ||
29 | |||
27 | /////////////////////////////////////////////////////////////////////// | 30 | /////////////////////////////////////////////////////////////////////// |
28 | // Property accessors | 31 | // Property accessors |
29 | /////////////////////////////////////////////////////////////////////// | 32 | /////////////////////////////////////////////////////////////////////// |
@@ -36,6 +39,13 @@ exports.ViewUtils = Montage.create(Component, { | |||
36 | }, | 39 | }, |
37 | getViewportObj: { value: function() { return this.m_viewportObj; } }, | 40 | getViewportObj: { value: function() { return this.m_viewportObj; } }, |
38 | 41 | ||
42 | setRootElement: { value: function( elt ) { this._rootElement = elt; } }, | ||
43 | getRootElement: { value: function () { return this._rootElement; } }, | ||
44 | |||
45 | setStageElement: { value: function( elt ) { this._stageElement = elt; } }, | ||
46 | getStageElement: { value: function () { return this._stageElement; } }, | ||
47 | |||
48 | |||
39 | getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, | 49 | getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, |
40 | 50 | ||
41 | /////////////////////////////////////////////////////////////////////// | 51 | /////////////////////////////////////////////////////////////////////// |
@@ -195,7 +205,12 @@ exports.ViewUtils = Montage.create(Component, { | |||
195 | 205 | ||
196 | getPerspectiveDistFromElement: { | 206 | getPerspectiveDistFromElement: { |
197 | value: function( elt ) { | 207 | value: function( elt ) { |
198 | return ElementsMediator.getPerspectiveDist(elt); | 208 | var pDist = ElementsMediator.getPerspectiveDist(elt); |
209 | if(pDist === "none") { | ||
210 | return null; | ||
211 | } else { | ||
212 | return pDist; | ||
213 | } | ||
199 | } | 214 | } |
200 | }, | 215 | }, |
201 | 216 | ||
@@ -280,7 +295,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
280 | // into stage world space. | 295 | // into stage world space. |
281 | postViewToStageWorld: { | 296 | postViewToStageWorld: { |
282 | value: function( localPt, elt ) { | 297 | value: function( localPt, elt ) { |
283 | if ((elt == null) || (elt === this.application.ninja.currentDocument.model.documentRoot)) return localPt; | 298 | if ((elt == null) || (elt === this._stageElement)) return localPt; |
284 | 299 | ||
285 | // get the 3D transformation and 2D offset from the element | 300 | // get the 3D transformation and 2D offset from the element |
286 | var pt = localPt.slice(0); | 301 | var pt = localPt.slice(0); |
@@ -307,7 +322,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
307 | this.popViewportObj(); | 322 | this.popViewportObj(); |
308 | 323 | ||
309 | // check if we are done | 324 | // check if we are done |
310 | if (parent === this.application.ninja.currentDocument.model.documentRoot) break; | 325 | if (parent === this._stageElement) break; |
311 | 326 | ||
312 | if (this.elementHas3D( parent )) | 327 | if (this.elementHas3D( parent )) |
313 | { | 328 | { |
@@ -339,10 +354,10 @@ exports.ViewUtils = Montage.create(Component, { | |||
339 | // if (child === this.application.ninja.currentDocument.model.documentRoot) break; | 354 | // if (child === this.application.ninja.currentDocument.model.documentRoot) break; |
340 | // child = child.offsetParent; | 355 | // child = child.offsetParent; |
341 | 356 | ||
342 | if (child === this.application.ninja.currentDocument.model.documentRoot) break; | 357 | if (child === this._stageElement) break; |
343 | if (child === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; | 358 | if (child === this._rootElement) break; |
344 | child = child.offsetParent; | 359 | child = child.offsetParent; |
345 | if (child === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; | 360 | if (child === this._rootElement) break; |
346 | } | 361 | } |
347 | 362 | ||
348 | ///////////////////////////////////////////////////////// | 363 | ///////////////////////////////////////////////////////// |
@@ -392,7 +407,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
392 | { | 407 | { |
393 | // TODO - Commenting out flatten support until new perspective workflow is fully working | 408 | // TODO - Commenting out flatten support until new perspective workflow is fully working |
394 | // if (flatten) pt[2] = 0; | 409 | // if (flatten) pt[2] = 0; |
395 | // var flatten = (parent !== this.application.ninja.currentDocument.model.documentRoot.parentNode) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); | 410 | // var flatten = (parent !== this._rootElement) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); |
396 | // if(flatten) | 411 | // if(flatten) |
397 | // { | 412 | // { |
398 | // pt[2] = 0; | 413 | // pt[2] = 0; |
@@ -677,7 +692,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
677 | // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; | 692 | // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; |
678 | // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; | 693 | // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; |
679 | var offset = [xOff, yOff]; | 694 | var offset = [xOff, yOff]; |
680 | if(elt.offsetParent && (elt.offsetParent !== this.application.ninja.currentDocument.model.documentRoot)) | 695 | if(elt.offsetParent && (elt.offsetParent !== this._stageElement)) |
681 | { | 696 | { |
682 | var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); | 697 | var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); |
683 | 698 | ||
@@ -693,7 +708,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
693 | } | 708 | } |
694 | } | 709 | } |
695 | 710 | ||
696 | if(elt === this.application.ninja.currentDocument.model.documentRoot) | 711 | if(elt === this._stageElement) |
697 | { | 712 | { |
698 | // TODO - Call a routine from the user document controller to get the offsets/margins | 713 | // TODO - Call a routine from the user document controller to get the offsets/margins |
699 | // Once we expose the document controller to ViewUtils | 714 | // Once we expose the document controller to ViewUtils |
@@ -984,7 +999,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
984 | glmat4.multiply( v2s, mat, mat ); | 999 | glmat4.multiply( v2s, mat, mat ); |
985 | 1000 | ||
986 | // TODO - Commenting out flatten support until new perspective workflow is fully working | 1001 | // TODO - Commenting out flatten support until new perspective workflow is fully working |
987 | // var flatten = (elt !== this.application.ninja.currentDocument.model.documentRoot.parentNode) && (elt.parentElement !== this.application.ninja.currentDocument.model.documentRoot.parentNode) && (ElementsMediator.getProperty(elt.parentElement, "-webkit-transform-style") !== "preserve-3d"); | 1002 | // var flatten = (elt !== this._rootElement) && (elt.parentElement !== this._rootElement) && (ElementsMediator.getProperty(elt.parentElement, "-webkit-transform-style") !== "preserve-3d"); |
988 | // if(flatten) | 1003 | // if(flatten) |
989 | // { | 1004 | // { |
990 | // glmat4.multiply( zMat, mat, mat ); | 1005 | // glmat4.multiply( zMat, mat, mat ); |
@@ -998,10 +1013,10 @@ exports.ViewUtils = Montage.create(Component, { | |||
998 | 1013 | ||
999 | this.popViewportObj(); | 1014 | this.popViewportObj(); |
1000 | 1015 | ||
1001 | if (elt === this.application.ninja.currentDocument.model.documentRoot) break; | 1016 | if (elt === this._stageElement) break; |
1002 | if (elt === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; | 1017 | if (elt === this._rootElement) break; |
1003 | elt = elt.offsetParent; | 1018 | elt = elt.offsetParent; |
1004 | if (elt === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; | 1019 | if (elt === this._rootElement) break; |
1005 | } | 1020 | } |
1006 | 1021 | ||
1007 | return mat; | 1022 | return mat; |
@@ -1035,7 +1050,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
1035 | // multiply all the matrices together | 1050 | // multiply all the matrices together |
1036 | //mat = s2v.multiply( mat ); | 1051 | //mat = s2v.multiply( mat ); |
1037 | glmat4.multiply( s2v, mat, mat ); | 1052 | glmat4.multiply( s2v, mat, mat ); |
1038 | if (elt === this.application.ninja.currentDocument.model.documentRoot) break; | 1053 | if (elt === this._stageElement) break; |
1039 | //mat = objMat.multiply( mat ); | 1054 | //mat = objMat.multiply( mat ); |
1040 | glmat4.multiply( objMat, mat, mat ); | 1055 | glmat4.multiply( objMat, mat, mat ); |
1041 | if(shouldProject && pDist) | 1056 | if(shouldProject && pDist) |
@@ -1084,7 +1099,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
1084 | // multiply all the matrices together | 1099 | // multiply all the matrices together |
1085 | //mat = s2v.multiply( mat ); | 1100 | //mat = s2v.multiply( mat ); |
1086 | glmat4.multiply( s2v, mat, mat ); | 1101 | glmat4.multiply( s2v, mat, mat ); |
1087 | if (elt === this.application.ninja.currentDocument.model.documentRoot) break; | 1102 | if (elt === this._stageElement) break; |
1088 | //mat = objMat.multiply( mat ); | 1103 | //mat = objMat.multiply( mat ); |
1089 | if (shouldLocalTransform) { | 1104 | if (shouldLocalTransform) { |
1090 | glmat4.multiply( objMat, mat, mat ); | 1105 | glmat4.multiply( objMat, mat, mat ); |
@@ -1320,14 +1335,6 @@ exports.ViewUtils = Montage.create(Component, { | |||
1320 | } | 1335 | } |
1321 | }, | 1336 | }, |
1322 | 1337 | ||
1323 | getCurrentDocument: | ||
1324 | { | ||
1325 | value: function() | ||
1326 | { | ||
1327 | return snapManagerModule.SnapManager.application.ninja.currentDocument; | ||
1328 | } | ||
1329 | }, | ||
1330 | |||
1331 | setStageZoom: { | 1338 | setStageZoom: { |
1332 | value:function( globalPt, zoomFactor ) { | 1339 | value:function( globalPt, zoomFactor ) { |
1333 | var localPt; | 1340 | var localPt; |