diff options
author | hwc487 | 2012-04-05 17:09:51 -0700 |
---|---|---|
committer | hwc487 | 2012-04-05 17:09:51 -0700 |
commit | 2d21b01d6dd64af643f5f38818b57fcace05ea0b (patch) | |
tree | 44fac83294dae2efad48389ddb44cb1dbe06caad /js/helper-classes/3D/view-utils.js | |
parent | 7656b6eac7aec59697c6cddbe2a507fe9e4aa187 (diff) | |
parent | 96bfeee2e6b735b87e8482d6e2cf24d5224c6417 (diff) | |
download | ninja-2d21b01d6dd64af643f5f38818b57fcace05ea0b.tar.gz |
Merge branch 'Snapping' of github.com:ericmueller/ninja-internal into Snapping_II
Diffstat (limited to 'js/helper-classes/3D/view-utils.js')
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index a72b7906..392de0be 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js | |||
@@ -112,6 +112,13 @@ exports.ViewUtils = Montage.create(Component, { | |||
112 | var mat = this.getMatrixFromElement(elt); | 112 | var mat = this.getMatrixFromElement(elt); |
113 | var plane = [mat[8], mat[9], mat[10], mat[11]]; | 113 | var plane = [mat[8], mat[9], mat[10], mat[11]]; |
114 | 114 | ||
115 | var stage = this.application.ninja.currentDocument.documentRoot; | ||
116 | if (elt === stage) | ||
117 | { | ||
118 | xVec = [1,0,0]; | ||
119 | yVec = [0,1,0]; | ||
120 | } | ||
121 | |||
115 | // The translation value is a point on the plane | 122 | // The translation value is a point on the plane |
116 | this.pushViewportObj( elt ); | 123 | this.pushViewportObj( elt ); |
117 | var ptOnPlane = this.getCenterOfProjection(); | 124 | var ptOnPlane = this.getCenterOfProjection(); |
@@ -137,6 +144,12 @@ exports.ViewUtils = Montage.create(Component, { | |||
137 | var stageMat = this.getMatrixFromElement(stage); | 144 | var stageMat = this.getMatrixFromElement(stage); |
138 | var stagePlane = [stageMat[8], stageMat[9], stageMat[10], stageMat[11]]; | 145 | var stagePlane = [stageMat[8], stageMat[9], stageMat[10], stageMat[11]]; |
139 | 146 | ||
147 | if (elt === stage) | ||
148 | { | ||
149 | xVec = [1,0,0]; | ||
150 | yVec = [0,1,0]; | ||
151 | } | ||
152 | |||
140 | var xDot = Math.abs(vecUtils.vecDot(3, xVec, stagePlane)); | 153 | var xDot = Math.abs(vecUtils.vecDot(3, xVec, stagePlane)); |
141 | var yDot = Math.abs(vecUtils.vecDot(3, yVec, stagePlane)); | 154 | var yDot = Math.abs(vecUtils.vecDot(3, yVec, stagePlane)); |
142 | 155 | ||
@@ -788,35 +801,23 @@ exports.ViewUtils = Montage.create(Component, { | |||
788 | } | 801 | } |
789 | }, | 802 | }, |
790 | 803 | ||
791 | getStageWorldToGlobalMatrix: { | 804 | getStageWorldToGlobalMatrix: |
792 | value: function() { | 805 | { |
806 | value: function() | ||
807 | { | ||
793 | var stage = this.application.ninja.currentDocument.documentRoot; | 808 | var stage = this.application.ninja.currentDocument.documentRoot; |
794 | this.pushViewportObj( stage ); | 809 | this.pushViewportObj( stage ); |
795 | 810 | ||
796 | // get the matrix to the parent | 811 | // put the point into screen space of the stage - requires |
797 | var mat = Matrix.I(4); | 812 | // a translation to the top/left only |
798 | //var projMat = Matrix.I(4).multiply( this.getPerspectiveDistFromElement(stage) ); | ||
799 | var p = this.getPerspectiveDistFromElement(stage); | ||
800 | var projMat = glmat4.scale( Matrix.I(4), [p,p,p], [] ); | ||
801 | projMat[11] = -1; | ||
802 | var cop = this.getCenterOfProjection(); | 813 | var cop = this.getCenterOfProjection(); |
803 | var v2s = Matrix.Translation([cop[0], cop[1], 0]); | 814 | var v2s = Matrix.Translation([cop[0], cop[1], 0]); |
804 | 815 | ||
805 | //mat = v2s.multiply( projMat ); | ||
806 | mat = glmat4.multiply( v2s, projMat, [] ); | ||
807 | |||
808 | // offset to the parent | ||
809 | var offset = this.getElementOffset( stage ); | ||
810 | var offMat = Matrix.Translation([offset[0], offset[1], 0]); | ||
811 | //mat = offMat.multiply( mat ); | ||
812 | glmat4.multiply( offMat, mat, mat ); | ||
813 | |||
814 | this.popViewportObj(); | 816 | this.popViewportObj(); |
815 | 817 | ||
816 | // var mat2 = this.getLocalToGlobalMatrix( stage.parentElement ); | 818 | // append the localToGlobal matrix of the stage. |
817 | var mat2 = this.getLocalToGlobalMatrix( this._rootElement ); | 819 | var mat = this.getLocalToGlobalMatrix( stage ); |
818 | //var mat = mat2.multiply( mat ); | 820 | glmat4.multiply( mat, v2s ); |
819 | glmat4.multiply( mat2, mat, mat ); | ||
820 | 821 | ||
821 | return mat; | 822 | return mat; |
822 | } | 823 | } |