diff options
author | Valerio Virgillito | 2012-06-12 16:49:45 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-06-12 16:49:45 -0700 |
commit | fcbb9a2e42b665766e0a38982a3c450fbaa1fdf4 (patch) | |
tree | 76a32e4d013d5ca49ba0b3fa92cab20a5c7123a2 | |
parent | 52ca1c95d6f000503f44fa5f3139557e770a7773 (diff) | |
parent | 7d49d995eba553d58d7612520ed9277941738054 (diff) | |
download | ninja-fcbb9a2e42b665766e0a38982a3c450fbaa1fdf4.tar.gz |
Merge branch 'refs/heads/master' into montage-v10-integration
-rwxr-xr-x | js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | 66 |
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 70fca99b..5839ac64 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 | ||
7 | var Montage = require("montage/core/core").Montage; | 7 | var Montage = require("montage/core/core").Montage, |
8 | var Component = require("montage/ui/component").Component; | 8 | Component = require("montage/ui/component").Component; |
9 | 9 | ||
10 | exports.ThreeD = Montage.create(Component, { | 10 | exports.ThreeD = Montage.create(Component, { |
11 | 11 | ||
@@ -162,6 +162,10 @@ exports.ThreeD = Montage.create(Component, { | |||
162 | value: null | 162 | value: null |
163 | }, | 163 | }, |
164 | 164 | ||
165 | _transformCtr: { | ||
166 | value: null | ||
167 | }, | ||
168 | |||
165 | handleAction: { | 169 | handleAction: { |
166 | value: function(event) { | 170 | value: function(event) { |
167 | if(event.currentTarget.identifier === "flatten") { | 171 | if(event.currentTarget.identifier === "flatten") { |
@@ -198,10 +202,20 @@ exports.ThreeD = Montage.create(Component, { | |||
198 | value : function(prop, value, item, inGlobalMode, isChanging){ | 202 | value : function(prop, value, item, inGlobalMode, isChanging){ |
199 | if(!this._curMat) { | 203 | if(!this._curMat) { |
200 | this._curMat = this.application.ninja.elementMediator.getMatrix(item); | 204 | this._curMat = this.application.ninja.elementMediator.getMatrix(item); |
205 | // this._transformCtr = item.elementModel.props3D.m_transformCtr || [0,0,0]; | ||
206 | // TODO - Always use the center for now until we support multiple selections | ||
207 | this._transformCtr = [0,0,0]; | ||
208 | if(inGlobalMode) { | ||
209 | this._transformCtr = MathUtils.transformPoint(this._transformCtr, this._curMat); | ||
210 | } | ||
201 | } | 211 | } |
202 | 212 | ||
203 | var curMat = this._curMat; | 213 | var curMat = this._curMat, |
204 | var delta = value.value; | 214 | delta = value.value, |
215 | isRotating = false, | ||
216 | xFormMat = Matrix.I(4), | ||
217 | tMat = Matrix.I(4), | ||
218 | mat = []; | ||
205 | if(inGlobalMode) { | 219 | if(inGlobalMode) { |
206 | 220 | ||
207 | if(!this._curProp) { | 221 | if(!this._curProp) { |
@@ -211,17 +225,19 @@ exports.ThreeD = Montage.create(Component, { | |||
211 | delta -= this._curProp; | 225 | delta -= this._curProp; |
212 | } | 226 | } |
213 | 227 | ||
214 | var xFormMat = Matrix.I(4); | ||
215 | switch (prop) | 228 | switch (prop) |
216 | { | 229 | { |
217 | case "xAngle": | 230 | case "xAngle": |
218 | xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); | 231 | xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); |
232 | isRotating = true; | ||
219 | break; | 233 | break; |
220 | case "yAngle": | 234 | case "yAngle": |
221 | xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); | 235 | xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); |
236 | isRotating = true; | ||
222 | break; | 237 | break; |
223 | case "zAngle": | 238 | case "zAngle": |
224 | xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); | 239 | xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); |
240 | isRotating = true; | ||
225 | break; | 241 | break; |
226 | case "x3D": | 242 | case "x3D": |
227 | xFormMat[12] = delta; | 243 | xFormMat[12] = delta; |
@@ -234,11 +250,45 @@ exports.ThreeD = Montage.create(Component, { | |||
234 | break; | 250 | break; |
235 | } | 251 | } |
236 | 252 | ||
237 | var mat = []; | ||
238 | if(inGlobalMode) { | 253 | if(inGlobalMode) { |
239 | glmat4.multiply(xFormMat, curMat, mat); | 254 | |
255 | if(isRotating) { | ||
256 | |||
257 | // pre-translate by the transformation center | ||
258 | tMat[12] = this._transformCtr[0]; | ||
259 | tMat[13] = this._transformCtr[1]; | ||
260 | tMat[14] = this._transformCtr[2]; | ||
261 | |||
262 | glmat4.multiply(tMat, xFormMat, mat); | ||
263 | |||
264 | // translate back | ||
265 | tMat[12] = -this._transformCtr[0]; | ||
266 | tMat[13] = -this._transformCtr[1]; | ||
267 | tMat[14] = -this._transformCtr[2]; | ||
268 | |||
269 | glmat4.multiply(mat, tMat, mat); | ||
270 | glmat4.multiply(mat, curMat, mat); | ||
271 | } else { | ||
272 | glmat4.multiply(xFormMat, curMat, mat); | ||
273 | } | ||
240 | } else { | 274 | } else { |
241 | glmat4.multiply(curMat, xFormMat, mat); | 275 | if(isRotating) { |
276 | tMat[12] = this._transformCtr[0]; | ||
277 | tMat[13] = this._transformCtr[1]; | ||
278 | tMat[14] = this._transformCtr[2]; | ||
279 | |||
280 | glmat4.multiply(curMat, tMat, mat); | ||
281 | |||
282 | // translate back | ||
283 | tMat[12] = -this._transformCtr[0]; | ||
284 | tMat[13] = -this._transformCtr[1]; | ||
285 | tMat[14] = -this._transformCtr[2]; | ||
286 | |||
287 | glmat4.multiply(mat, xFormMat, mat); | ||
288 | glmat4.multiply(mat, tMat, mat); | ||
289 | } else { | ||
290 | glmat4.multiply(curMat, xFormMat, mat); | ||
291 | } | ||
242 | } | 292 | } |
243 | 293 | ||
244 | if(isChanging) { | 294 | if(isChanging) { |