diff options
Diffstat (limited to 'js/tools/Translate3DToolBase.js')
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 005b9749..18e2b610 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js | |||
@@ -29,6 +29,8 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
29 | modifyElements : { | 29 | modifyElements : { |
30 | value : function(data, event) | 30 | value : function(data, event) |
31 | { | 31 | { |
32 | //console.log( "modifyElements, data: " + data.pt0 + " => " + data.pt1 ); | ||
33 | |||
32 | // form the translation vector and post translate the matrix by it. | 34 | // form the translation vector and post translate the matrix by it. |
33 | var delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); | 35 | var delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); |
34 | if(this._handleMode !== null) | 36 | if(this._handleMode !== null) |
@@ -71,6 +73,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
71 | 73 | ||
72 | var transMat = Matrix.Translation( delta ); | 74 | var transMat = Matrix.Translation( delta ); |
73 | 75 | ||
76 | //console.log( "Translate: " + delta ); | ||
74 | if(this._inLocalMode && (this._targets.length === 1) ) | 77 | if(this._inLocalMode && (this._targets.length === 1) ) |
75 | { | 78 | { |
76 | this._translateLocally(transMat); | 79 | this._translateLocally(transMat); |
@@ -130,6 +133,9 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
130 | // We will only translate single elements locally | 133 | // We will only translate single elements locally |
131 | _translateLocally: { | 134 | _translateLocally: { |
132 | value: function (transMat) { | 135 | value: function (transMat) { |
136 | //console.log( "_translateLocally, startMat: " + this._startMat ); | ||
137 | //console.log( "_translateLocally, transMat: " + transMat ); | ||
138 | //console.log( "_translateLocally, startMat: " + this._startMat + ", transMat: " + transMat ); | ||
133 | var mat = glmat4.multiply(this._startMat, transMat, []); | 139 | var mat = glmat4.multiply(this._startMat, transMat, []); |
134 | viewUtils.setMatrixForElement( this._target, mat, true ); | 140 | viewUtils.setMatrixForElement( this._target, mat, true ); |
135 | if(this._mode !== 1) | 141 | if(this._mode !== 1) |
@@ -141,14 +147,22 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
141 | 147 | ||
142 | _translateGlobally: { | 148 | _translateGlobally: { |
143 | value: function (transMat) { | 149 | value: function (transMat) { |
150 | //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat ); | ||
151 | //console.log( "_translateGlobally, transMat: " + transMat ); | ||
144 | var len = this._targets.length, | 152 | var len = this._targets.length, |
145 | i = 0, | 153 | i = 0, |
146 | item, | 154 | item, |
147 | elt, | 155 | elt, |
148 | curMat, | 156 | curMat = viewUtils.getMatrixFromElement( this._target ), |
149 | matInv = glmat4.inverse(this._startMat, []), | 157 | matInv = glmat4.inverse(this._startMat, []), |
150 | nMat = glmat4.multiply(transMat, this._startMat, [] ), | 158 | nMat = glmat4.multiply(transMat, this._startMat, [] ), |
151 | qMat = glmat4.multiply(matInv, nMat, []); | 159 | qMat = glmat4.multiply(matInv, nMat, []); |
160 | |||
161 | if (this._mode === 1) | ||
162 | { | ||
163 | var curInv = glmat4.inverse( curMat, [] ); | ||
164 | transMat = glmat4.multiply( nMat, curInv, [] ); | ||
165 | } | ||
152 | 166 | ||
153 | var shouldUpdateStartMat = true; | 167 | var shouldUpdateStartMat = true; |
154 | 168 | ||
@@ -177,6 +191,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
177 | 191 | ||
178 | if(shouldUpdateStartMat) | 192 | if(shouldUpdateStartMat) |
179 | { | 193 | { |
194 | //console.log( "\t\tshouldUpdateStartMat" ); | ||
180 | this._targets[i].mat = curMat; | 195 | this._targets[i].mat = curMat; |
181 | } | 196 | } |
182 | } | 197 | } |
@@ -184,7 +199,9 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
184 | }, | 199 | }, |
185 | 200 | ||
186 | _updateTargets: { | 201 | _updateTargets: { |
187 | value: function(addToUndoStack) { | 202 | value: function(addToUndoStack) |
203 | { | ||
204 | console.log( "_updateTargets" ); | ||
188 | var newStyles = [], | 205 | var newStyles = [], |
189 | previousStyles = [], | 206 | previousStyles = [], |
190 | len = this.application.ninja.selectedElements.length; | 207 | len = this.application.ninja.selectedElements.length; |