aboutsummaryrefslogtreecommitdiff
path: root/js/tools/Translate3DToolBase.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/Translate3DToolBase.js')
-rwxr-xr-xjs/tools/Translate3DToolBase.js25
1 files changed, 19 insertions, 6 deletions
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index 4dca6313..0d36653d 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)
@@ -66,15 +68,12 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
66 delta[0] = 0; 68 delta[0] = 0;
67 delta[1] = 0; 69 delta[1] = 0;
68 } 70 }
69 else
70 {
71 delta[2] = 0;
72 }
73 this._delta = delta.slice(0); 71 this._delta = delta.slice(0);
74 } 72 }
75 73
76 var transMat = Matrix.Translation( delta ); 74 var transMat = Matrix.Translation( delta );
77 75
76 //console.log( "Translate: " + delta );
78 if(this._inLocalMode && (this._targets.length === 1) ) 77 if(this._inLocalMode && (this._targets.length === 1) )
79 { 78 {
80 this._translateLocally(transMat); 79 this._translateLocally(transMat);
@@ -134,6 +133,9 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
134 // We will only translate single elements locally 133 // We will only translate single elements locally
135 _translateLocally: { 134 _translateLocally: {
136 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 );
137 var mat = glmat4.multiply(this._startMat, transMat, []); 139 var mat = glmat4.multiply(this._startMat, transMat, []);
138 viewUtils.setMatrixForElement( this._target, mat, true ); 140 viewUtils.setMatrixForElement( this._target, mat, true );
139 if(this._mode !== 1) 141 if(this._mode !== 1)
@@ -145,14 +147,22 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
145 147
146 _translateGlobally: { 148 _translateGlobally: {
147 value: function (transMat) { 149 value: function (transMat) {
150 //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat );
151 //console.log( "_translateGlobally, transMat: " + transMat );
148 var len = this._targets.length, 152 var len = this._targets.length,
149 i = 0, 153 i = 0,
150 item, 154 item,
151 elt, 155 elt,
152 curMat, 156 curMat = viewUtils.getMatrixFromElement( this._target ),
153 matInv = glmat4.inverse(this._startMat, []), 157 matInv = glmat4.inverse(this._startMat, []),
154 nMat = glmat4.multiply(transMat, this._startMat, [] ), 158 nMat = glmat4.multiply(transMat, this._startMat, [] ),
155 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 }
156 166
157 var shouldUpdateStartMat = true; 167 var shouldUpdateStartMat = true;
158 168
@@ -181,6 +191,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
181 191
182 if(shouldUpdateStartMat) 192 if(shouldUpdateStartMat)
183 { 193 {
194 //console.log( "\t\tshouldUpdateStartMat" );
184 this._targets[i].mat = curMat; 195 this._targets[i].mat = curMat;
185 } 196 }
186 } 197 }
@@ -188,7 +199,9 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
188 }, 199 },
189 200
190 _updateTargets: { 201 _updateTargets: {
191 value: function(addToUndoStack) { 202 value: function(addToUndoStack)
203 {
204 console.log( "_updateTargets" );
192 var newStyles = [], 205 var newStyles = [],
193 previousStyles = [], 206 previousStyles = [],
194 len = this.application.ninja.selectedElements.length; 207 len = this.application.ninja.selectedElements.length;