diff options
author | Valerio Virgillito | 2012-05-01 13:36:12 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-01 13:36:12 -0700 |
commit | e3fa4c7db57b63c5ac604c9420062de5d0fe413a (patch) | |
tree | 4b9a319286549f85d92bdb580d56318187dfd92b /js | |
parent | fb47c04b0a4d65f53d975311754aa0dd8a8a3f69 (diff) | |
parent | 84eec0ae4352c9f6e5986529cc70eed726d97a88 (diff) | |
download | ninja-e3fa4c7db57b63c5ac604c9420062de5d0fe413a.tar.gz |
Merge pull request #184 from mqg734/StageWebTemplate
Get working plane grid to draw for new stage web template workflow.
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/elements/body-controller.js | 40 | ||||
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 27 | ||||
-rwxr-xr-x | js/tools/RotateStage3DTool.js | 18 |
3 files changed, 75 insertions, 10 deletions
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 839d0787..14aeae24 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js | |||
@@ -51,5 +51,45 @@ exports.BodyController = Montage.create(ElementController, { | |||
51 | return dist; | 51 | return dist; |
52 | } | 52 | } |
53 | } | 53 | } |
54 | }, | ||
55 | |||
56 | getMatrix: { | ||
57 | value: function(el) { | ||
58 | if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) | ||
59 | { | ||
60 | return el.elementModel.props3D.matrix3d.slice(0); | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | var mat; | ||
65 | |||
66 | if (el) | ||
67 | { | ||
68 | mat = this.application.ninja.stylesController.getMatrixFromElement(el, true); | ||
69 | if (!mat) { | ||
70 | mat = Matrix.I(4); | ||
71 | } | ||
72 | |||
73 | var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom"); | ||
74 | if (zoom) | ||
75 | { | ||
76 | zoom = Number(zoom); | ||
77 | if (zoom != 1) | ||
78 | { | ||
79 | var zoomMat = Matrix.create( [ | ||
80 | [ zoom, 0, 0, 0], | ||
81 | [ 0, zoom, 0, 0], | ||
82 | [ 0, 0, zoom, 0], | ||
83 | [ 0, 0, 0, 1] | ||
84 | ] ); | ||
85 | glmat4.multiply( zoomMat, mat, mat ); | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | |||
90 | el.elementModel.props3D.matrix3d = mat; | ||
91 | return mat; | ||
92 | } | ||
93 | } | ||
54 | } | 94 | } |
55 | }); | 95 | }); |
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 7bd77c3a..81a740e0 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -583,17 +583,25 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
583 | // get a point that lies on the plane | 583 | // get a point that lies on the plane |
584 | var ptOnPlane = MathUtils.getPointOnPlane(this._workingPlane); | 584 | var ptOnPlane = MathUtils.getPointOnPlane(this._workingPlane); |
585 | 585 | ||
586 | // define the grid parameters | ||
587 | var width, | ||
588 | height, | ||
589 | nLines = 10; | ||
590 | |||
591 | // if(this.application.ninja.documentController.webTemplate) { | ||
592 | if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") { | ||
593 | width = this.application.ninja.currentDocument.documentRoot.scrollWidth; | ||
594 | height = this.application.ninja.currentDocument.documentRoot.scrollHeight; | ||
595 | } else { | ||
596 | width = this.snapManager.getStageWidth(); | ||
597 | height = this.snapManager.getStageHeight(); | ||
598 | } | ||
586 | // get a matrix from working plane space to the world | 599 | // get a matrix from working plane space to the world |
587 | var mat = this.getPlaneToWorldMatrix(zAxis, ptOnPlane); | 600 | var mat = this.getPlaneToWorldMatrix(zAxis, ptOnPlane); |
588 | var tMat = Matrix.Translation( [0.5*this.snapManager.getStageWidth(), 0.5*this.snapManager.getStageHeight(),0] ); | 601 | var tMat = Matrix.Translation( [0.5*width, 0.5*height, 0] ); |
589 | //mat = tMat.multiply(mat); | 602 | //mat = tMat.multiply(mat); |
590 | glmat4.multiply( tMat, mat, mat); | 603 | glmat4.multiply( tMat, mat, mat); |
591 | 604 | ||
592 | // define the grid parameters | ||
593 | var width = this.snapManager.getStageWidth(), | ||
594 | height = this.snapManager.getStageHeight(); | ||
595 | var nLines = 10; | ||
596 | |||
597 | // the positioning of the grid may depend on the view direction. | 605 | // the positioning of the grid may depend on the view direction. |
598 | var stage = this.snapManager.getStage(); | 606 | var stage = this.snapManager.getStage(); |
599 | var viewMat = this.viewUtils.getMatrixFromElement(stage); | 607 | var viewMat = this.viewUtils.getMatrixFromElement(stage); |
@@ -662,6 +670,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
662 | var offset = this.viewUtils.getElementOffset(this._sourceSpaceElt); | 670 | var offset = this.viewUtils.getElementOffset(this._sourceSpaceElt); |
663 | offset[2] = 0; | 671 | offset[2] = 0; |
664 | this.viewUtils.setViewportObj(this._sourceSpaceElt); | 672 | this.viewUtils.setViewportObj(this._sourceSpaceElt); |
673 | var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt ); | ||
665 | for (var i = 0; i < nLines; i++) { | 674 | for (var i = 0; i < nLines; i++) { |
666 | // transform the points from working plane space to world space | 675 | // transform the points from working plane space to world space |
667 | //var t0 = mat.multiply(p0), | 676 | //var t0 = mat.multiply(p0), |
@@ -671,8 +680,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
671 | 680 | ||
672 | // transform from world space to global screen space | 681 | // transform from world space to global screen space |
673 | if (this._sourceSpaceElt) { | 682 | if (this._sourceSpaceElt) { |
674 | t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt); | 683 | // t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt); |
675 | t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt); | 684 | // t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt); |
685 | t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat); | ||
686 | t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat); | ||
676 | } | 687 | } |
677 | 688 | ||
678 | // create a line from the endpoints | 689 | // create a line from the endpoints |
diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index d1701304..2a9c63db 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js | |||
@@ -96,6 +96,12 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | |||
96 | viewUtils.pushViewportObj( stage ); | 96 | viewUtils.pushViewportObj( stage ); |
97 | var eltCtr = viewUtils.getCenterOfProjection(); | 97 | var eltCtr = viewUtils.getCenterOfProjection(); |
98 | viewUtils.popViewportObj(); | 98 | viewUtils.popViewportObj(); |
99 | // if(this.application.ninja.documentController.webTemplate) | ||
100 | if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") | ||
101 | { | ||
102 | eltCtr[0] = stage.scrollWidth/2; | ||
103 | eltCtr[1] = stage.scrollHeight/2; | ||
104 | } | ||
99 | 105 | ||
100 | var curMat = viewUtils.getMatrixFromElement(stage); | 106 | var curMat = viewUtils.getMatrixFromElement(stage); |
101 | var curMatInv = glmat4.inverse(curMat, []); | 107 | var curMatInv = glmat4.inverse(curMat, []); |
@@ -113,8 +119,16 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | |||
113 | 119 | ||
114 | this._origin = viewUtils.localToGlobal(eltCtr, stage); | 120 | this._origin = viewUtils.localToGlobal(eltCtr, stage); |
115 | 121 | ||
116 | this._setTransformOrigin(false); | 122 | // if(this.application.ninja.documentController.webTemplate) |
117 | 123 | if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") | |
124 | { | ||
125 | this._startOriginArray = []; | ||
126 | this._startOriginArray.push(this._origin.slice()); | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | this._setTransformOrigin(false); | ||
131 | } | ||
118 | this.DrawHandles(); | 132 | this.DrawHandles(); |
119 | } | 133 | } |
120 | }, | 134 | }, |