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.js69
1 files changed, 25 insertions, 44 deletions
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index 00124900..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 ///////////////////////////////////////////////////////////////////////
@@ -299,7 +286,7 @@ exports.ViewUtils = Montage.create(Component, {
299 // into stage world space. 286 // into stage world space.
300 postViewToStageWorld: { 287 postViewToStageWorld: {
301 value: function( localPt, elt ) { 288 value: function( localPt, elt ) {
302 if ((elt == null) || (elt === this._stageElement)) return localPt; 289 if ((elt == null) || (elt === this.application.ninja.currentDocument.documentRoot)) return localPt;
303 290
304 // get the 3D transformation and 2D offset from the element 291 // get the 3D transformation and 2D offset from the element
305 var pt = localPt.slice(0); 292 var pt = localPt.slice(0);
@@ -326,7 +313,7 @@ exports.ViewUtils = Montage.create(Component, {
326 this.popViewportObj(); 313 this.popViewportObj();
327 314
328 // check if we are done 315 // check if we are done
329 if (parent === this._stageElement) break; 316 if (parent === this.application.ninja.currentDocument.documentRoot) break;
330 317
331 if (this.elementHas3D( parent )) 318 if (this.elementHas3D( parent ))
332 { 319 {
@@ -351,15 +338,17 @@ exports.ViewUtils = Montage.create(Component, {
351 338
352 // transform the bounds up the tree 339 // transform the bounds up the tree
353 var child = elt; 340 var child = elt;
354 var parent = elt.offsetParent; 341 while ( child )
355 while ( parent )
356 { 342 {
357 pt = this.childToParent( pt, child ); 343 pt = this.childToParent( pt, child );
358 344
359 if (parent === this._rootElement) break; 345// if (child === this.application.ninja.currentDocument.documentRoot) break;
346// child = child.offsetParent;
360 347
361 child = parent; 348 if (child === this.application.ninja.currentDocument.documentRoot) break;
362 parent = parent.offsetParent; 349 if (child === this.application.ninja.currentDocument.documentRoot.parentNode) break;
350 child = child.offsetParent;
351 if (child === this.application.ninja.currentDocument.documentRoot.parentNode) break;
363 } 352 }
364 353
365 ///////////////////////////////////////////////////////// 354 /////////////////////////////////////////////////////////
@@ -395,7 +384,8 @@ exports.ViewUtils = Montage.create(Component, {
395 384
396 // transform the bounds up the tree 385 // transform the bounds up the tree
397 var parent = child.offsetParent; 386 var parent = child.offsetParent;
398 if ( parent ) 387 // TODO - Should have a different way to check for new template mode
388 if ( parent || ((child === this.application.ninja.currentDocument.documentRoot) && (child.id !== "UserContent")) )
399 { 389 {
400 this.setViewportObj( child ); 390 this.setViewportObj( child );
401 391
@@ -408,7 +398,7 @@ exports.ViewUtils = Montage.create(Component, {
408 { 398 {
409 // 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
410 // if (flatten) pt[2] = 0; 400 // if (flatten) pt[2] = 0;
411// 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");
412// if(flatten) 402// if(flatten)
413// { 403// {
414// pt[2] = 0; 404// pt[2] = 0;
@@ -693,7 +683,7 @@ exports.ViewUtils = Montage.create(Component, {
693 // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; 683 // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff;
694 // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; 684 // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff;
695 var offset = [xOff, yOff]; 685 var offset = [xOff, yOff];
696 if(elt.offsetParent && (elt.offsetParent !== this._stageElement)) 686 if(elt.offsetParent && (elt.offsetParent !== this.application.ninja.currentDocument.documentRoot))
697 { 687 {
698 var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); 688 var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent);
699 689
@@ -709,7 +699,7 @@ exports.ViewUtils = Montage.create(Component, {
709 } 699 }
710 } 700 }
711 701
712 if(elt === this._stageElement) 702 if(elt === this.application.ninja.currentDocument.documentRoot)
713 { 703 {
714 // 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
715 // Once we expose the document controller to ViewUtils 705 // Once we expose the document controller to ViewUtils
@@ -1000,7 +990,7 @@ exports.ViewUtils = Montage.create(Component, {
1000 glmat4.multiply( v2s, mat, mat ); 990 glmat4.multiply( v2s, mat, mat );
1001 991
1002 // 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
1003// 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");
1004// if(flatten) 994// if(flatten)
1005// { 995// {
1006// glmat4.multiply( zMat, mat, mat ); 996// glmat4.multiply( zMat, mat, mat );
@@ -1014,10 +1004,10 @@ exports.ViewUtils = Montage.create(Component, {
1014 1004
1015 this.popViewportObj(); 1005 this.popViewportObj();
1016 1006
1017 if (elt === this._stageElement) break; 1007 if (elt === this.application.ninja.currentDocument.documentRoot) break;
1018 if (elt === this._rootElement) break; 1008 if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break;
1019 elt = elt.offsetParent; 1009 elt = elt.offsetParent;
1020 if (elt === this._rootElement) break; 1010 if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break;
1021 } 1011 }
1022 1012
1023 return mat; 1013 return mat;
@@ -1051,7 +1041,7 @@ exports.ViewUtils = Montage.create(Component, {
1051 // multiply all the matrices together 1041 // multiply all the matrices together
1052 //mat = s2v.multiply( mat ); 1042 //mat = s2v.multiply( mat );
1053 glmat4.multiply( s2v, mat, mat ); 1043 glmat4.multiply( s2v, mat, mat );
1054 if (elt === this._stageElement) break; 1044 if (elt === this.application.ninja.currentDocument.documentRoot) break;
1055 //mat = objMat.multiply( mat ); 1045 //mat = objMat.multiply( mat );
1056 glmat4.multiply( objMat, mat, mat ); 1046 glmat4.multiply( objMat, mat, mat );
1057 if(shouldProject && pDist) 1047 if(shouldProject && pDist)
@@ -1100,7 +1090,7 @@ exports.ViewUtils = Montage.create(Component, {
1100 // multiply all the matrices together 1090 // multiply all the matrices together
1101 //mat = s2v.multiply( mat ); 1091 //mat = s2v.multiply( mat );
1102 glmat4.multiply( s2v, mat, mat ); 1092 glmat4.multiply( s2v, mat, mat );
1103 if (elt === this._stageElement) break; 1093 if (elt === this.application.ninja.currentDocument.documentRoot) break;
1104 //mat = objMat.multiply( mat ); 1094 //mat = objMat.multiply( mat );
1105 if (shouldLocalTransform) { 1095 if (shouldLocalTransform) {
1106 glmat4.multiply( objMat, mat, mat ); 1096 glmat4.multiply( objMat, mat, mat );
@@ -1310,15 +1300,6 @@ exports.ViewUtils = Montage.create(Component, {
1310// MISCELLANEOUS 1300// MISCELLANEOUS
1311// event.layerX/Y: var pt = viewUtils.getMousePoint(event); 1301// event.layerX/Y: var pt = viewUtils.getMousePoint(event);
1312 1302
1313 getStageDimension: {
1314 value: function()
1315 {
1316 var width = parseInt(this.application.ninja.stage.documentRoot.elementModel.stageDimension.style.getProperty("width"));
1317 var height= parseInt(this.application.ninja.stage.documentRoot.elementModel.stageDimension.style.getProperty("height"));
1318 return[width,height];
1319 }
1320 },
1321
1322 getStage: { 1303 getStage: {
1323 value: function() 1304 value: function()
1324 { 1305 {