aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/view-utils.js
diff options
context:
space:
mode:
authorArmen Kesablyan2012-05-23 14:34:58 -0700
committerArmen Kesablyan2012-05-23 14:34:58 -0700
commitc21db7f1e4a0582777bdb5366df5d023a915b779 (patch)
treec4d29cb4686101d4a480ae836d20187879cf5400 /js/helper-classes/3D/view-utils.js
parent3ed95247e9ea4b0a7833401ed6809647b7c4acbf (diff)
parent1a7e347810401e6262d9d7bad1c3583e6773993b (diff)
downloadninja-c21db7f1e4a0582777bdb5366df5d023a915b779.tar.gz
Merge branch 'refs/heads/dom-architecture' into binding
Conflicts: js/data/panels-data.js Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'js/helper-classes/3D/view-utils.js')
-rwxr-xr-xjs/helper-classes/3D/view-utils.js75
1 files changed, 25 insertions, 50 deletions
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index 8c338f84..0080bf90 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -18,18 +18,14 @@ 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 26
27 _currentDocument: { value: null , writable: true}, 27 _userContentLeft: { value: null},
28 _userContentLeft: { value: null , writable: true}, 28 _userContentTop: { value: null},
29 _userContentTop: { value: null , writable: true},
30
31 _rootElement: { value: null, writable: true},
32 _stageElement: { value: null, writable: true},
33 29
34 /////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////
35 // Property accessors 31 // Property accessors
@@ -43,18 +39,9 @@ exports.ViewUtils = Montage.create(Component, {
43 }, 39 },
44 getViewportObj: { value: function() { return this.m_viewportObj; } }, 40 getViewportObj: { value: function() { return this.m_viewportObj; } },
45 41
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; }}, 42 setUserContentLeft: { value: function(value) { this._userContentLeft = value; }},
55 setUserContentTop: { value: function(value) { this._userContentTop = value; }}, 43 setUserContentTop: { value: function(value) { this._userContentTop = value; }},
56 44
57
58 getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, 45 getPerspectiveDistance: { value: function () { return this._perspectiveDist; } },
59 46
60 /////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////
@@ -156,14 +143,6 @@ exports.ViewUtils = Montage.create(Component, {
156 viewDir = MathUtils.transformVector( [0,0,1], stageInv ); 143 viewDir = MathUtils.transformVector( [0,0,1], stageInv );
157 } 144 }
158 145
159 /*
160 if (elt === stage)
161 {
162 xVec = [1,0,0];
163 yVec = [0,1,0];
164 }
165 */
166
167 var plane; 146 var plane;
168 var xDot, yDot, zDot; 147 var xDot, yDot, zDot;
169 switch (axis) 148 switch (axis)
@@ -288,6 +267,11 @@ exports.ViewUtils = Montage.create(Component, {
288 value: function( localPt, elt ) { 267 value: function( localPt, elt ) {
289 this.pushViewportObj( elt ); 268 this.pushViewportObj( elt );
290 var viewPt = this.screenToView( localPt[0], localPt[1], localPt[2] ); 269 var viewPt = this.screenToView( localPt[0], localPt[1], localPt[2] );
270 if ((elt == null) || (elt === this._stageElement))
271 {
272 this.popViewportObj();
273 return viewPt;
274 }
291 var mat = this.getMatrixFromElement( elt ); 275 var mat = this.getMatrixFromElement( elt );
292 var worldPt = MathUtils.transformPoint( viewPt, mat ); 276 var worldPt = MathUtils.transformPoint( viewPt, mat );
293 var stageWorldPt = this.postViewToStageWorld( worldPt, elt ); 277 var stageWorldPt = this.postViewToStageWorld( worldPt, elt );
@@ -302,7 +286,7 @@ exports.ViewUtils = Montage.create(Component, {
302 // into stage world space. 286 // into stage world space.
303 postViewToStageWorld: { 287 postViewToStageWorld: {
304 value: function( localPt, elt ) { 288 value: function( localPt, elt ) {
305 if ((elt == null) || (elt === this._stageElement)) return localPt; 289 if ((elt == null) || (elt === this.application.ninja.currentDocument.documentRoot)) return localPt;
306 290
307 // get the 3D transformation and 2D offset from the element 291 // get the 3D transformation and 2D offset from the element
308 var pt = localPt.slice(0); 292 var pt = localPt.slice(0);
@@ -329,7 +313,7 @@ exports.ViewUtils = Montage.create(Component, {
329 this.popViewportObj(); 313 this.popViewportObj();
330 314
331 // check if we are done 315 // check if we are done
332 if (parent === this._stageElement) break; 316 if (parent === this.application.ninja.currentDocument.documentRoot) break;
333 317
334 if (this.elementHas3D( parent )) 318 if (this.elementHas3D( parent ))
335 { 319 {
@@ -358,13 +342,13 @@ exports.ViewUtils = Montage.create(Component, {
358 { 342 {
359 pt = this.childToParent( pt, child ); 343 pt = this.childToParent( pt, child );
360 344
361// if (child === this._stageElement) break; 345// if (child === this.application.ninja.currentDocument.documentRoot) break;
362// child = child.offsetParent; 346// child = child.offsetParent;
363 347
364 if (child === this._stageElement) break; 348 if (child === this.application.ninja.currentDocument.documentRoot) break;
365 if (child === this._rootElement) break; 349 if (child === this.application.ninja.currentDocument.documentRoot.parentNode) break;
366 child = child.offsetParent; 350 child = child.offsetParent;
367 if (child === this._rootElement) break; 351 if (child === this.application.ninja.currentDocument.documentRoot.parentNode) break;
368 } 352 }
369 353
370 ///////////////////////////////////////////////////////// 354 /////////////////////////////////////////////////////////
@@ -414,7 +398,7 @@ exports.ViewUtils = Montage.create(Component, {
414 { 398 {
415 // TODO - Commenting out flatten support until new perspective workflow is fully working 399 // TODO - Commenting out flatten support until new perspective workflow is fully working
416 // if (flatten) pt[2] = 0; 400 // if (flatten) pt[2] = 0;
417// var flatten = (parent !== this._rootElement) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); 401// var flatten = (parent !== this.application.ninja.currentDocument.documentRoot.parentNode) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d");
418// if(flatten) 402// if(flatten)
419// { 403// {
420// pt[2] = 0; 404// pt[2] = 0;
@@ -699,7 +683,7 @@ exports.ViewUtils = Montage.create(Component, {
699 // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; 683 // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff;
700 // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; 684 // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff;
701 var offset = [xOff, yOff]; 685 var offset = [xOff, yOff];
702 if(elt.offsetParent && (elt.offsetParent !== this._stageElement)) 686 if(elt.offsetParent && (elt.offsetParent !== this.application.ninja.currentDocument.documentRoot))
703 { 687 {
704 var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); 688 var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent);
705 689
@@ -715,7 +699,7 @@ exports.ViewUtils = Montage.create(Component, {
715 } 699 }
716 } 700 }
717 701
718 if(elt === this._stageElement) 702 if(elt === this.application.ninja.currentDocument.documentRoot)
719 { 703 {
720 // TODO - Call a routine from the user document controller to get the offsets/margins 704 // TODO - Call a routine from the user document controller to get the offsets/margins
721 // Once we expose the document controller to ViewUtils 705 // Once we expose the document controller to ViewUtils
@@ -1006,7 +990,7 @@ exports.ViewUtils = Montage.create(Component, {
1006 glmat4.multiply( v2s, mat, mat ); 990 glmat4.multiply( v2s, mat, mat );
1007 991
1008 // TODO - Commenting out flatten support until new perspective workflow is fully working 992 // TODO - Commenting out flatten support until new perspective workflow is fully working
1009// var flatten = (elt !== this._rootElement) && (elt.parentElement !== this._rootElement) && (ElementsMediator.getProperty(elt.parentElement, "-webkit-transform-style") !== "preserve-3d"); 993// var flatten = (elt !== this.application.ninja.currentDocument.documentRoot.parentNode) && (elt.parentElement !== this.application.ninja.currentDocument.documentRoot.parentNode) && (ElementsMediator.getProperty(elt.parentElement, "-webkit-transform-style") !== "preserve-3d");
1010// if(flatten) 994// if(flatten)
1011// { 995// {
1012// glmat4.multiply( zMat, mat, mat ); 996// glmat4.multiply( zMat, mat, mat );
@@ -1020,10 +1004,10 @@ exports.ViewUtils = Montage.create(Component, {
1020 1004
1021 this.popViewportObj(); 1005 this.popViewportObj();
1022 1006
1023 if (elt === this._stageElement) break; 1007 if (elt === this.application.ninja.currentDocument.documentRoot) break;
1024 if (elt === this._rootElement) break; 1008 if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break;
1025 elt = elt.offsetParent; 1009 elt = elt.offsetParent;
1026 if (elt === this._rootElement) break; 1010 if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break;
1027 } 1011 }
1028 1012
1029 return mat; 1013 return mat;
@@ -1057,7 +1041,7 @@ exports.ViewUtils = Montage.create(Component, {
1057 // multiply all the matrices together 1041 // multiply all the matrices together
1058 //mat = s2v.multiply( mat ); 1042 //mat = s2v.multiply( mat );
1059 glmat4.multiply( s2v, mat, mat ); 1043 glmat4.multiply( s2v, mat, mat );
1060 if (elt === this._stageElement) break; 1044 if (elt === this.application.ninja.currentDocument.documentRoot) break;
1061 //mat = objMat.multiply( mat ); 1045 //mat = objMat.multiply( mat );
1062 glmat4.multiply( objMat, mat, mat ); 1046 glmat4.multiply( objMat, mat, mat );
1063 if(shouldProject && pDist) 1047 if(shouldProject && pDist)
@@ -1106,7 +1090,7 @@ exports.ViewUtils = Montage.create(Component, {
1106 // multiply all the matrices together 1090 // multiply all the matrices together
1107 //mat = s2v.multiply( mat ); 1091 //mat = s2v.multiply( mat );
1108 glmat4.multiply( s2v, mat, mat ); 1092 glmat4.multiply( s2v, mat, mat );
1109 if (elt === this._stageElement) break; 1093 if (elt === this.application.ninja.currentDocument.docu