aboutsummaryrefslogtreecommitdiff
path: root/js/panels
diff options
context:
space:
mode:
authorAnanya Sen2012-06-13 10:55:11 -0700
committerAnanya Sen2012-06-13 10:55:11 -0700
commit43b7a4b954a28089e59c6397774c6a341369b6e5 (patch)
treec41e3c00eba05da551743f19166c278112def27b /js/panels
parent2bffaa0204adcab02c488ba81d845ed049f517de (diff)
parent5a7774f6769a7a682e21bafe0e57007668f16153 (diff)
downloadninja-43b7a4b954a28089e59c6397774c6a341369b6e5.tar.gz
Merge branch 'refs/heads/ninja-internal-master' into cut-copy-paste
Diffstat (limited to 'js/panels')
-rwxr-xr-xjs/panels/properties.reel/sections/three-d-view.reel/three-d-view.js66
1 files changed, 58 insertions, 8 deletions
diff --git a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js
index 104d474d..f8d158ce 100755
--- a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js
+++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js
@@ -4,8 +4,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7var Montage = require("montage/core/core").Montage; 7var Montage = require("montage/core/core").Montage,
8var Component = require("montage/ui/component").Component; 8 Component = require("montage/ui/component").Component;
9 9
10exports.ThreeD = Montage.create(Component, { 10exports.ThreeD = Montage.create(Component, {
11 11
@@ -107,6 +107,10 @@ exports.ThreeD = Montage.create(Component, {
107 value: null 107 value: null
108 }, 108 },
109 109
110 _transformCtr: {
111 value: null
112 },
113
110 handleAction: { 114 handleAction: {
111 value: function(event) { 115 value: function(event) {
112 if(event.currentTarget.identifier === "flatten") { 116 if(event.currentTarget.identifier === "flatten") {
@@ -143,10 +147,20 @@ exports.ThreeD = Montage.create(Component, {
143 value : function(prop, value, item, inGlobalMode, isChanging){ 147 value : function(prop, value, item, inGlobalMode, isChanging){
144 if(!this._curMat) { 148 if(!this._curMat) {
145 this._curMat = this.application.ninja.elementMediator.getMatrix(item); 149 this._curMat = this.application.ninja.elementMediator.getMatrix(item);
150// this._transformCtr = item.elementModel.props3D.m_transformCtr || [0,0,0];
151 // TODO - Always use the center for now until we support multiple selections
152 this._transformCtr = [0,0,0];
153 if(inGlobalMode) {
154 this._transformCtr = MathUtils.transformPoint(this._transformCtr, this._curMat);
155 }
146 } 156 }
147 157
148 var curMat = this._curMat; 158 var curMat = this._curMat,
149 var delta = value.value; 159 delta = value.value,
160 isRotating = false,
161 xFormMat = Matrix.I(4),
162 tMat = Matrix.I(4),
163 mat = [];
150 if(inGlobalMode) { 164 if(inGlobalMode) {
151 165
152 if(!this._curProp) { 166 if(!this._curProp) {
@@ -156,17 +170,19 @@ exports.ThreeD = Montage.create(Component, {
156 delta -= this._curProp; 170 delta -= this._curProp;
157 } 171 }
158 172
159 var xFormMat = Matrix.I(4);
160 switch (prop) 173 switch (prop)
161 { 174 {
162 case "xAngle": 175 case "xAngle":
163 xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); 176 xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta);
177 isRotating = true;
164 break; 178 break;
165 case "yAngle": 179 case "yAngle":
166 xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); 180 xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta);
181 isRotating = true;
167 break; 182 break;
168 case "zAngle": 183 case "zAngle":
169 xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); 184 xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta);
185 isRotating = true;
170 break; 186 break;
171 case "x3D": 187 case "x3D":
172 xFormMat[12] = delta; 188 xFormMat[12] = delta;
@@ -179,11 +195,45 @@ exports.ThreeD = Montage.create(Component, {
179 break; 195 break;
180 } 196 }
181 197
182 var mat = [];
183 if(inGlobalMode) { 198 if(inGlobalMode) {
184 glmat4.multiply(xFormMat, curMat, mat); 199
200 if(isRotating) {
201
202 // pre-translate by the transformation center
203 tMat[12] = this._transformCtr[0];
204 tMat[13] = this._transformCtr[1];
205 tMat[14] = this._transformCtr[2];
206
207 glmat4.multiply(tMat, xFormMat, mat);
208
209 // translate back
210 tMat[12] = -this._transformCtr[0];
211 tMat[13] = -this._transformCtr[1];
212 tMat[14] = -this._transformCtr[2];
213
214 glmat4.multiply(mat, tMat, mat);
215 glmat4.multiply(mat, curMat, mat);
216 } else {
217 glmat4.multiply(xFormMat, curMat, mat);
218 }
185 } else { 219 } else {
186 glmat4.multiply(curMat, xFormMat, mat); 220 if(isRotating) {
221 tMat[12] = this._transformCtr[0];
222 tMat[13] = this._transformCtr[1];
223 tMat[14] = this._transformCtr[2];
224
225 glmat4.multiply(curMat, tMat, mat);
226
227 // translate back
228 tMat[12] = -this._transformCtr[0];
229 tMat[13] = -this._transformCtr[1];
230 tMat[14] = -this._transformCtr[2];
231
232 glmat4.multiply(mat, xFormMat, mat);
233 glmat4.multiply(mat, tMat, mat);
234 } else {
235 glmat4.multiply(curMat, xFormMat, mat);
236 }
187 } 237 }
188 238
189 if(isChanging) { 239 if(isChanging) {