diff options
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 8 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 38 |
2 files changed, 29 insertions, 17 deletions
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 4dcda24a..e3756f32 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -22,6 +22,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
22 | // Instance variables | 22 | // Instance variables |
23 | /////////////////////////////////////////////////////////////////////// | 23 | /////////////////////////////////////////////////////////////////////// |
24 | 24 | ||
25 | currentStage: { value: null }, | ||
26 | |||
25 | // we keep a stack of working planes to facilitate working on other planes temporarily | 27 | // we keep a stack of working planes to facilitate working on other planes temporarily |
26 | _workingPlaneStack : { value: [], writable: true }, | 28 | _workingPlaneStack : { value: [], writable: true }, |
27 | 29 | ||
@@ -82,14 +84,14 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
82 | popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }}, | 84 | popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }}, |
83 | 85 | ||
84 | getStageWidth : { value: function () { | 86 | getStageWidth : { value: function () { |
85 | return parseInt(this.application.ninja.currentDocument.model.documentRoot.offsetWidth); | 87 | return parseInt(this.currentStage.offsetWidth); |
86 | }}, | 88 | }}, |
87 | 89 | ||
88 | getStageHeight : { value: function () { | 90 | getStageHeight : { value: function () { |
89 | return parseInt(this.application.ninja.currentDocument.model.documentRoot.offsetHeight); | 91 | return parseInt(this.currentStage.offsetHeight); |
90 | }}, | 92 | }}, |
91 | 93 | ||
92 | getStage : { value: function() { return this.application.ninja.currentDocument.model.documentRoot; }}, | 94 | getStage : { value: function() { return this.currentStage; }}, |
93 | 95 | ||
94 | getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }}, | 96 | getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }}, |
95 | getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }}, | 97 | getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }}, |
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 3c7ae6ff..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 | /////////////////////////////////////////////////////////////////////// |
@@ -285,7 +295,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
285 | // into stage world space. | 295 | // into stage world space. |
286 | postViewToStageWorld: { | 296 | postViewToStageWorld: { |
287 | value: function( localPt, elt ) { | 297 | value: function( localPt, elt ) { |
288 | if ((elt == null) || (elt === this.application.ninja.currentDocument.model.documentRoot)) return localPt; | 298 | if ((elt == null) || (elt === this._stageElement)) return localPt; |
289 | 299 | ||
290 | // get the 3D transformation and 2D offset from the element | 300 | // get the 3D transformation and 2D offset from the element |
291 | var pt = localPt.slice(0); | 301 | var pt = localPt.slice(0); |
@@ -312,7 +322,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
312 | this.popViewportObj(); | 322 | this.popViewportObj(); |
313 | 323 | ||
314 | // check if we are done | 324 | // check if we are done |
315 | if (parent === this.application.ninja.currentDocument.model.documentRoot) break; | 325 | if (parent === this._stageElement) break; |
316 | 326 | ||
317 | if (this.elementHas3D( parent )) | 327 | if (this.elementHas3D( parent )) |
318 | { | 328 | { |
@@ -344,10 +354,10 @@ exports.ViewUtils = Montage.create(Component, { | |||
344 | // if (child === this.application.ninja.currentDocument.model.documentRoot) break; | 354 | // if (child === this.application.ninja.currentDocument.model.documentRoot) break; |
345 | // child = child.offsetParent; | 355 | // child = child.offsetParent; |
346 | 356 | ||
347 | if (child === this.application.ninja.currentDocument.model.documentRoot) break; | 357 | if (child === this._stageElement) break; |
348 | if (child === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; | 358 | if (child === this._rootElement) break; |
349 | child = child.offsetParent; | 359 | child = child.offsetParent; |
350 | if (child === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; | 360 | if (child === this._rootElement) break; |
351 | } | 361 | } |
352 | 362 | ||
353 | ///////////////////////////////////////////////////////// | 363 | ///////////////////////////////////////////////////////// |
@@ -397,7 +407,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
397 | { | 407 | { |
398 | // 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 |
399 | // if (flatten) pt[2] = 0; | 409 | // if (flatten) pt[2] = 0; |
400 | // 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"); |
401 | // if(flatten) | 411 | // if(flatten) |
402 | // { | 412 | // { |
403 | // pt[2] = 0; | 413 | // pt[2] = 0; |
@@ -682,7 +692,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
682 | // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; | 692 | // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; |
683 | // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; | 693 | // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; |
684 | var offset = [xOff, yOff]; | 694 | var offset = [xOff, yOff]; |
685 | if(elt.offsetParent && (elt.offsetParent !== this.application.ninja.currentDocument.model.documentRoot)) | 695 | if(elt.offsetParent && (elt.offsetParent !== this._stageElement)) |
686 | { | 696 | { |
687 | var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); | 697 | var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); |
688 | 698 | ||
@@ -698,7 +708,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
698 | } | 708 | } |
699 | } | 709 | } |
700 | 710 | ||
701 | if(elt === this.application.ninja.currentDocument.model.documentRoot) | 711 | if(elt === this._stageElement) |
702 | { | 712 | { |
703 | // 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 |
704 | // Once we expose the document controller to ViewUtils | 714 | // Once we expose the document controller to ViewUtils |
@@ -989,7 +999,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
989 | glmat4.multiply( v2s, mat, mat ); | 999 | glmat4.multiply( v2s, mat, mat ); |
990 | 1000 | ||
991 | // 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 |
992 | // 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"); |
993 | // if(flatten) | 1003 | // if(flatten) |
994 | // { | 1004 | // { |
995 | // glmat4.multiply( zMat, mat, mat ); | 1005 | // glmat4.multiply( zMat, mat, mat ); |
@@ -1003,10 +1013,10 @@ exports.ViewUtils = Montage.create(Component, { | |||
1003 | 1013 | ||
1004 | this.popViewportObj(); | 1014 | this.popViewportObj(); |
1005 | 1015 | ||
1006 | if (elt === this.application.ninja.currentDocument.model.documentRoot) break; | 1016 | if (elt === this._stageElement) break; |
1007 | if (elt === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; | 1017 | if (elt === this._rootElement) break; |
1008 | elt = elt.offsetParent; | 1018 | elt = elt.offsetParent; |
1009 | if (elt === this.application.ninja.currentDocument.model.documentRoot.parentNode) break; | 1019 | if (elt === this._rootElement) break; |
1010 | } | 1020 | } |
1011 | 1021 | ||
1012 | return mat; | 1022 | return mat; |
@@ -1040,7 +1050,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
1040 | // multiply all the matrices together | 1050 | // multiply all the matrices together |
1041 | //mat = s2v.multiply( mat ); | 1051 | //mat = s2v.multiply( mat ); |
1042 | glmat4.multiply( s2v, mat, mat ); | 1052 | glmat4.multiply( s2v, mat, mat ); |
1043 | if (elt === this.application.ninja.currentDocument.model.documentRoot) break; | 1053 | if (elt === this._stageElement) break; |
1044 | //mat = objMat.multiply( mat ); | 1054 | //mat = objMat.multiply( mat ); |
1045 | glmat4.multiply( objMat, mat, mat ); | 1055 | glmat4.multiply( objMat, mat, mat ); |
1046 | if(shouldProject && pDist) | 1056 | if(shouldProject && pDist) |
@@ -1089,7 +1099,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
1089 | // multiply all the matrices together | 1099 | // multiply all the matrices together |
1090 | //mat = s2v.multiply( mat ); | 1100 | //mat = s2v.multiply( mat ); |
1091 | glmat4.multiply( s2v, mat, mat ); | 1101 | glmat4.multiply( s2v, mat, mat ); |
1092 | if (elt === this.application.ninja.currentDocument.model.documentRoot) break; | 1102 | if (elt === this._stageElement) break; |
1093 | //mat = objMat.multiply( mat ); | 1103 | //mat = objMat.multiply( mat ); |
1094 | if (shouldLocalTransform) { | 1104 | if (shouldLocalTransform) { |
1095 | glmat4.multiply( objMat, mat, mat ); | 1105 | glmat4.multiply( objMat, mat, mat ); |