aboutsummaryrefslogtreecommitdiff
path: root/js/tools/Translate3DToolBase.js
diff options
context:
space:
mode:
authorJonathan Duran2012-04-10 08:13:00 -0700
committerJonathan Duran2012-04-10 08:13:00 -0700
commit58e049b68e03abbacde93206d2666361022c0858 (patch)
treef1ce6b8a378674d4abcac68acd0bcca93b838a39 /js/tools/Translate3DToolBase.js
parenta9050f96d814469f420bcf3630d16d576b62258e (diff)
parentbd43ce383b050d03b0f92cc923c517febc66ca28 (diff)
downloadninja-58e049b68e03abbacde93206d2666361022c0858.tar.gz
Merge branch 'refs/heads/NINJAmaster' into TimelineUber
Diffstat (limited to 'js/tools/Translate3DToolBase.js')
-rwxr-xr-xjs/tools/Translate3DToolBase.js38
1 files changed, 26 insertions, 12 deletions
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index 4dca6313..e4f1fb99 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);
@@ -91,22 +90,21 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
91 value : function() 90 value : function()
92 { 91 {
93 var item, 92 var item,
94 elt,
95 mat, 93 mat,
96 dist, 94 dist,
97 newStyles = [], 95 newStyles = [],
98 previousStyles = [], 96 previousStyles = [],
99 len = this._targets.length; 97 len = this.application.ninja.selectedElements.length;
100 for(var i = 0; i < len; i++) 98 for(var i = 0; i < len; i++)
101 { 99 {
102 // Reset to the identity matrix but retain the rotation values 100 // Reset to the identity matrix but retain the rotation values
103 item = this._targets[i]; 101 item = this.application.ninja.selectedElements[i];
104 mat = item.mat.slice(0); 102 mat = ElementsMediator.getMatrix(item);
105 mat[12] = 0; 103 mat[12] = 0;
106 mat[13] = 0; 104 mat[13] = 0;
107 mat[14] = 0; 105 mat[14] = 0;
108 106
109 dist = this._undoArray[i].dist; 107 dist = ElementsMediator.getPerspectiveDist(item);
110 108
111 var previousStyleStr = {dist:dist, mat:item.mat}; 109 var previousStyleStr = {dist:dist, mat:item.mat};
112 110
@@ -126,14 +124,20 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
126 this.isDrawing = false; 124 this.isDrawing = false;
127 this.endDraw(event); 125 this.endDraw(event);
128 126
129// this.UpdateSelection(true); 127
130 this.Configure(true); 128 // Need to force stage to draw immediately so the new selection center is calculated
129 this.application.ninja.stage.draw();
130 // And captureSelectionDrawn to draw the transform handles
131 this.captureSelectionDrawn(null);
131 } 132 }
132 }, 133 },
133 134
134 // We will only translate single elements locally 135 // We will only translate single elements locally
135 _translateLocally: { 136 _translateLocally: {
136 value: function (transMat) { 137 value: function (transMat) {
138 //console.log( "_translateLocally, startMat: " + this._startMat );
139 //console.log( "_translateLocally, transMat: " + transMat );
140 //console.log( "_translateLocally, startMat: " + this._startMat + ", transMat: " + transMat );
137 var mat = glmat4.multiply(this._startMat, transMat, []); 141 var mat = glmat4.multiply(this._startMat, transMat, []);
138 viewUtils.setMatrixForElement( this._target, mat, true ); 142 viewUtils.setMatrixForElement( this._target, mat, true );
139 if(this._mode !== 1) 143 if(this._mode !== 1)
@@ -145,14 +149,22 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
145 149
146 _translateGlobally: { 150 _translateGlobally: {
147 value: function (transMat) { 151 value: function (transMat) {
152 //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat );
153 //console.log( "_translateGlobally, transMat: " + transMat );
148 var len = this._targets.length, 154 var len = this._targets.length,
149 i = 0, 155 i = 0,
150 item, 156 item,
151 elt, 157 elt,
152 curMat, 158 curMat = viewUtils.getMatrixFromElement( this._target ),
153 matInv = glmat4.inverse(this._startMat, []), 159 matInv = glmat4.inverse(this._startMat, []),
154 nMat = glmat4.multiply(transMat, this._startMat, [] ), 160 nMat = glmat4.multiply(transMat, this._startMat, [] ),
155 qMat = glmat4.multiply(matInv, nMat, []); 161 qMat = glmat4.multiply(matInv, nMat, []);
162
163 if (this._mode === 1)
164 {
165 var curInv = glmat4.inverse( curMat, [] );
166 transMat = glmat4.multiply( nMat, curInv, [] );
167 }
156 168
157 var shouldUpdateStartMat = true; 169 var shouldUpdateStartMat = true;
158 170
@@ -181,6 +193,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
181 193
182 if(shouldUpdateStartMat) 194 if(shouldUpdateStartMat)
183 { 195 {
196 //console.log( "\t\tshouldUpdateStartMat" );
184 this._targets[i].mat = curMat; 197 this._targets[i].mat = curMat;
185 } 198 }
186 } 199 }
@@ -189,6 +202,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
189 202
190 _updateTargets: { 203 _updateTargets: {
191 value: function(addToUndoStack) { 204 value: function(addToUndoStack) {
205// console.log( "_updateTargets" );
192 var newStyles = [], 206 var newStyles = [],
193 previousStyles = [], 207 previousStyles = [],
194 len = this.application.ninja.selectedElements.length; 208 len = this.application.ninja.selectedElements.length;