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.js55
1 files changed, 24 insertions, 31 deletions
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index 0080bf90..a3d09404 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -24,9 +24,6 @@ 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 _userContentLeft: { value: null},
28 _userContentTop: { value: null},
29
30 /////////////////////////////////////////////////////////////////////// 27 ///////////////////////////////////////////////////////////////////////
31 // Property accessors 28 // Property accessors
32 /////////////////////////////////////////////////////////////////////// 29 ///////////////////////////////////////////////////////////////////////
@@ -39,9 +36,6 @@ exports.ViewUtils = Montage.create(Component, {
39 }, 36 },
40 getViewportObj: { value: function() { return this.m_viewportObj; } }, 37 getViewportObj: { value: function() { return this.m_viewportObj; } },
41 38
42 setUserContentLeft: { value: function(value) { this._userContentLeft = value; }},
43 setUserContentTop: { value: function(value) { this._userContentTop = value; }},
44
45 getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, 39 getPerspectiveDistance: { value: function () { return this._perspectiveDist; } },
46 40
47 /////////////////////////////////////////////////////////////////////// 41 ///////////////////////////////////////////////////////////////////////
@@ -126,7 +120,7 @@ exports.ViewUtils = Montage.create(Component, {
126 var yVec = [0,1,0]; 120 var yVec = [0,1,0];
127 var zVec = [0,0,1]; 121 var zVec = [0,0,1];
128 122
129 var stage = this.application.ninja.currentDocument.documentRoot; 123 var stage = this.application.ninja.currentDocument.model.documentRoot;
130 var stageMat = this.getMatrixFromElement(stage); 124 var stageMat = this.getMatrixFromElement(stage);
131 125
132 var mat = glmat4.multiply( stageMat, objMat, [] ); 126 var mat = glmat4.multiply( stageMat, objMat, [] );
@@ -286,7 +280,7 @@ exports.ViewUtils = Montage.create(Component, {
286 // into stage world space. 280 // into stage world space.
287 postViewToStageWorld: { 281 postViewToStageWorld: {
288 value: function( localPt, elt ) { 282 value: function( localPt, elt ) {
289 if ((elt == null) || (elt === this.application.ninja.currentDocument.documentRoot)) return localPt; 283 if ((elt == null) || (elt === this.application.ninja.currentDocument.model.documentRoot)) return localPt;
290 284
291 // get the 3D transformation and 2D offset from the element 285 // get the 3D transformation and 2D offset from the element
292 var pt = localPt.slice(0); 286 var pt = localPt.slice(0);
@@ -313,7 +307,7 @@ exports.ViewUtils = Montage.create(Component, {
313 this.popViewportObj(); 307 this.popViewportObj();
314 308
315 // check if we are done 309 // check if we are done
316 if (parent === this.application.ninja.currentDocument.documentRoot) break; 310 if (parent === this.application.ninja.currentDocument.model.documentRoot) break;
317 311
318 if (this.elementHas3D( parent )) 312 if (this.elementHas3D( parent ))
319 { 313 {
@@ -342,13 +336,13 @@ exports.ViewUtils = Montage.create(Component, {
342 { 336 {
343 pt = this.childToParent( pt, child ); 337 pt = this.childToParent( pt, child );
344 338
345// if (child === this.application.ninja.currentDocument.documentRoot) break; 339// if (child === this.application.ninja.currentDocument.model.documentRoot) break;
346// child = child.offsetParent; 340// child = child.offsetParent;
347 341
348 if (child === this.application.ninja.currentDocument.documentRoot) break; 342 if (child === this.application.ninja.currentDocument.model.documentRoot) break;
349 if (child === this.application.ninja.currentDocument.documentRoot.parentNode) break; 343 if (child === this.application.ninja.currentDocument.model.documentRoot.parentNode) break;
350 child = child.offsetParent; 344 child = child.offsetParent;
351 if (child === this.application.ninja.currentDocument.documentRoot.parentNode) break; 345 if (child === this.application.ninja.currentDocument.model.documentRoot.parentNode) break;
352 } 346 }
353 347
354 ///////////////////////////////////////////////////////// 348 /////////////////////////////////////////////////////////
@@ -385,7 +379,7 @@ exports.ViewUtils = Montage.create(Component, {
385 // transform the bounds up the tree 379 // transform the bounds up the tree
386 var parent = child.offsetParent; 380 var parent = child.offsetParent;
387 // TODO - Should have a different way to check for new template mode 381 // TODO - Should have a different way to check for new template mode
388 if ( parent || ((child === this.application.ninja.currentDocument.documentRoot) && (child.id !== "UserContent")) ) 382 if ( parent || (child === this.application.ninja.currentDocument.model.documentRoot) )
389 { 383 {
390 this.setViewportObj( child ); 384 this.setViewportObj( child );
391 385
@@ -398,7 +392,7 @@ exports.ViewUtils = Montage.create(Component, {
398 { 392 {
399 // 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
400 // if (flatten) pt[2] = 0; 394 // if (flatten) pt[2] = 0;
401// var flatten = (parent !== this.application.ninja.currentDocument.documentRoot.parentNode) && (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");
402// if(flatten) 396// if(flatten)
403// { 397// {
404// pt[2] = 0; 398// pt[2] = 0;
@@ -458,7 +452,7 @@ exports.ViewUtils = Montage.create(Component, {
458 // get the four corners of the element in global space 452 // get the four corners of the element in global space
459 var bounds = this.getElementViewBounds3D( elt ); 453 var bounds = this.getElementViewBounds3D( elt );
460 var bounds3D = new Array(); 454 var bounds3D = new Array();
461 var stage = this.application.ninja.currentDocument.documentRoot; 455 var stage = this.application.ninja.currentDocument.model.documentRoot;
462 for (var i=0; i<3; i++) 456 for (var i=0; i<3; i++)
463 { 457 {
464 var gPt = this.localToGlobal( bounds[i], elt ); 458 var gPt = this.localToGlobal( bounds[i], elt );
@@ -683,7 +677,7 @@ exports.ViewUtils = Montage.create(Component, {
683 // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; 677 // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff;
684 // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; 678 // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff;
685 var offset = [xOff, yOff]; 679 var offset = [xOff, yOff];
686 if(elt.offsetParent && (elt.offsetParent !== this.application.ninja.currentDocument.documentRoot)) 680 if(elt.offsetParent && (elt.offsetParent !== this.application.ninja.currentDocument.model.documentRoot))
687 { 681 {
688 var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); 682 var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent);
689 683
@@ -699,12 +693,12 @@ exports.ViewUtils = Montage.create(Component, {
699 } 693 }
700 } 694 }
701 695
702 if(elt === this.application.ninja.currentDocument.documentRoot) 696 if(elt === this.application.ninja.currentDocument.model.documentRoot)
703 { 697 {
704 // 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
705 // Once we expose the document controller to ViewUtils 699 // Once we expose the document controller to ViewUtils
706 offset[0] += this._userContentLeft; 700 offset[0] += this.application.ninja.stage._userContentLeft;
707 offset[1] += this._userContentTop; 701 offset[1] += this.application.ninja.stage._userContentTop;
708 } 702 }
709 703
710 return offset; 704 return offset;
@@ -876,7 +870,7 @@ exports.ViewUtils = Montage.create(Component, {
876 { 870 {
877 value: function() 871 value: function()
878 { 872 {
879 var stage = this.application.ninja.currentDocument.documentRoot; 873 var stage = this.application.ninja.currentDocument.model.documentRoot;
880 874
881 this.pushViewportObj( stage ); 875 this.pushViewportObj( stage );
882 // put the point into screen space of the stage - requires 876 // put the point into screen space of the stage - requires
@@ -990,7 +984,7 @@ exports.ViewUtils = Montage.create(Component, {
990 glmat4.multiply( v2s, mat, mat ); 984 glmat4.multiply( v2s, mat, mat );
991 985
992 // TODO - Commenting out flatten support until new perspective workflow is fully working 986 // TODO - Commenting out flatten support until new perspective workflow is fully working
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"); 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");
994// if(flatten) 988// if(flatten)
995// { 989// {
996// glmat4.multiply( zMat, mat, mat ); 990// glmat4.multiply( zMat, mat, mat );
@@ -1004,10 +998,10 @@ exports.ViewUtils = Montage.create(Component, {
1004 998
1005 this.popViewportObj(); 999 this.popViewportObj();
1006 1000
1007 if (elt === this.application.ninja.currentDocument.documentRoot) break; 1001 if (elt === this.application.ninja.currentDocument.model.documentRoot) break;
1008 if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break; 1002 if (elt === this.application.ninja.currentDocument.model.documentRoot.parentNode) break;
1009 elt = elt.offsetParent; 1003 elt = elt.offsetParent;
1010 if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break; 1004 if (elt === this.application.ninja.currentDocument.model.documentRoot.parentNode) break;
1011 } 1005 }
1012 1006
1013 return mat; 1007 return mat;
@@ -1041,7 +1035,7 @@ exports.ViewUtils = Montage.create(Component, {
1041 // multiply all the matrices together 1035 // multiply all the matrices together
1042 //mat = s2v.multiply( mat ); 1036 //mat = s2v.multiply( mat );
1043 glmat4.multiply( s2v, mat, mat ); 1037 glmat4.multiply( s2v, mat, mat );
1044 if (elt === this.application.ninja.currentDocument.documentRoot) break; 1038 if (elt === this.application.ninja.currentDocument.model.documentRoot) break;
1045 //mat = objMat.multiply( mat ); 1039 //mat = objMat.multiply( mat );
1046 glmat4.multiply( objMat, mat, mat ); 1040 glmat4.multiply( objMat, mat, mat );
1047 if(shouldProject && pDist) 1041 if(shouldProject && pDist)
@@ -1090,7 +1084,7 @@ exports.ViewUtils = Montage.create(Component, {
1090 // multiply all the matrices together 1084 // multiply all the matrices together
1091 //mat = s2v.multiply( mat ); 1085 //mat = s2v.multiply( mat );
1092 glmat4.multiply( s2v, mat, mat ); 1086 glmat4.multiply( s2v, mat, mat );
1093 if (elt === this.application.ninja.currentDocument.documentRoot) break; 1087 if (elt === this.application.ninja.currentDocument.model.documentRoot) break;
1094 //mat = objMat.multiply( mat ); 1088 //mat = objMat.multiply( mat );
1095 if (shouldLocalTransform) { 1089 if (shouldLocalTransform) {
1096 glmat4.multiply( objMat, mat, mat ); 1090 glmat4.multiply( objMat, mat, mat );
@@ -1277,12 +1271,11 @@ exports.ViewUtils = Montage.create(Component, {
1277// 1271//
1278// STAGE ACCESSORS: 1272// STAGE ACCESSORS:
1279// activeDocument: this.application.ninja.currentDocument 1273// activeDocument: this.application.ninja.currentDocument
1280// userContent (stage): this.application.ninja.currentDocument.documentRoot 1274// userContent (stage): this.application.ninja.currentDocument.model.documentRoot
1281