aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/view-utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/3D/view-utils.js')
-rwxr-xr-xjs/helper-classes/3D/view-utils.js53
1 files changed, 20 insertions, 33 deletions
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index 8c338f84..20f61be1 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 ///////////////////////////////////////////////////////////////////////
@@ -302,7 +289,7 @@ exports.ViewUtils = Montage.create(Component, {
302 // into stage world space. 289 // into stage world space.
303 postViewToStageWorld: { 290 postViewToStageWorld: {
304 value: function( localPt, elt ) { 291 value: function( localPt, elt ) {
305 if ((elt == null) || (elt === this._stageElement)) return localPt; 292 if ((elt == null) || (elt === this.application.ninja.currentDocument.documentRoot)) return localPt;
306 293
307 // get the 3D transformation and 2D offset from the element 294 // get the 3D transformation and 2D offset from the element
308 var pt = localPt.slice(0); 295 var pt = localPt.slice(0);
@@ -329,7 +316,7 @@ exports.ViewUtils = Montage.create(Component, {
329 this.popViewportObj(); 316 this.popViewportObj();
330 317
331 // check if we are done 318 // check if we are done
332 if (parent === this._stageElement) break; 319 if (parent === this.application.ninja.currentDocument.documentRoot) break;
333 320
334 if (this.elementHas3D( parent )) 321 if (this.elementHas3D( parent ))
335 { 322 {
@@ -358,13 +345,13 @@ exports.ViewUtils = Montage.create(Component, {
358 { 345 {
359 pt = this.childToParent( pt, child ); 346 pt = this.childToParent( pt, child );
360 347
361// if (child === this._stageElement) break; 348// if (child === this.application.ninja.currentDocument.documentRoot) break;
362// child = child.offsetParent; 349// child = child.offsetParent;
363 350
364 if (child === this._stageElement) break; 351 if (child === this.application.ninja.currentDocument.documentRoot) break;
365 if (child === this._rootElement) break; 352 if (child === this.application.ninja.currentDocument.documentRoot.parentNode) break;
366 child = child.offsetParent; 353 child = child.offsetParent;
367 if (child === this._rootElement) break; 354 if (child === this.application.ninja.currentDocument.documentRoot.parentNode) break;
368 } 355 }
369 356
370 ///////////////////////////////////////////////////////// 357 /////////////////////////////////////////////////////////
@@ -414,7 +401,7 @@ exports.ViewUtils = Montage.create(Component, {
414 { 401 {
415 // TODO - Commenting out flatten support until new perspective workflow is fully working 402 // TODO - Commenting out flatten support until new perspective workflow is fully working
416 // if (flatten) pt[2] = 0; 403 // if (flatten) pt[2] = 0;
417// var flatten = (parent !== this._rootElement) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); 404// var flatten = (parent !== this.application.ninja.currentDocument.documentRoot.parentNode) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d");
418// if(flatten) 405// if(flatten)
419// { 406// {
420// pt[2] = 0; 407// pt[2] = 0;
@@ -699,7 +686,7 @@ exports.ViewUtils = Montage.create(Component, {
699 // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; 686 // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff;
700 // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; 687 // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff;
701 var offset = [xOff, yOff]; 688 var offset = [xOff, yOff];
702 if(elt.offsetParent && (elt.offsetParent !== this._stageElement)) 689 if(elt.offsetParent && (elt.offsetParent !== this.application.ninja.currentDocument.documentRoot))
703 { 690 {
704 var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); 691 var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent);
705 692
@@ -715,7 +702,7 @@ exports.ViewUtils = Montage.create(Component, {
715 } 702 }
716 } 703 }
717 704
718 if(elt === this._stageElement) 705 if(elt === this.application.ninja.currentDocument.documentRoot)
719 { 706 {
720 // TODO - Call a routine from the user document controller to get the offsets/margins 707 // TODO - Call a routine from the user document controller to get the offsets/margins
721 // Once we expose the document controller to ViewUtils 708 // Once we expose the document controller to ViewUtils
@@ -1006,7 +993,7 @@ exports.ViewUtils = Montage.create(Component, {
1006 glmat4.multiply( v2s, mat, mat ); 993 glmat4.multiply( v2s, mat, mat );
1007 994
1008 // TODO - Commenting out flatten support until new perspective workflow is fully working 995 // 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"); 996// 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) 997// if(flatten)
1011// { 998// {
1012// glmat4.multiply( zMat, mat, mat ); 999// glmat4.multiply( zMat, mat, mat );
@@ -1020,10 +1007,10 @@ exports.ViewUtils = Montage.create(Component, {
1020 1007
1021 this.popViewportObj(); 1008 this.popViewportObj();
1022 1009
1023 if (elt === this._stageElement) break; 1010 if (elt === this.application.ninja.currentDocument.documentRoot) break;
1024 if (elt === this._rootElement) break; 1011 if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break;
1025 elt = elt.offsetParent; 1012 elt = elt.offsetParent;
1026 if (elt === this._rootElement) break; 1013 if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break;
1027 } 1014 }
1028 1015
1029 return mat; 1016 return mat;
@@ -1057,7 +1044,7 @@ exports.ViewUtils = Montage.create(Component, {
1057 // multiply all the matrices together 1044 // multiply all the matrices together
1058 //mat = s2v.multiply( mat ); 1045 //mat = s2v.multiply( mat );
1059 glmat4.multiply( s2v, mat, mat ); 1046 glmat4.multiply( s2v, mat, mat );
1060 if (elt === this._stageElement) break; 1047 if (elt === this.application.ninja.currentDocument.documentRoot) break;
1061 //mat = objMat.multiply( mat ); 1048 //mat = objMat.multiply( mat );
1062 glmat4.multiply( objMat, mat, mat ); 1049 glmat4.multiply( objMat, mat, mat );
1063 if(shouldProject && pDist) 1050 if(shouldProject && pDist)
@@ -1106,7 +1093,7 @@ exports.ViewUtils = Montage.create(Component, {
1106 // multiply all the matrices together 1093 // multiply all the matrices together
1107 //mat = s2v.multiply( mat ); 1094 //mat = s2v.multiply( mat );
1108 glmat4.multiply( s2v, mat, mat ); 1095 glmat4.multiply( s2v, mat, mat );
1109 if (elt === this._stageElement) break; 1096 if (elt === this.application.ninja.currentDocument.documentRoot) break;
1110 //mat = objMat.multiply( mat ); 1097 //mat = objMat.multiply( mat );
1111 if (shouldLocalTransform) { 1098 if (shouldLocalTransform) {
1112 glmat4.multiply( objMat, mat, mat ); 1099 glmat4.multiply( objMat, mat, mat );