diff options
author | Armen Kesablyan | 2012-06-19 00:45:26 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-19 00:45:26 -0700 |
commit | c59eb371559a3061ce53223e249ca97daace5968 (patch) | |
tree | f9540e26c0f273d35f92010605da65dd85bbe70c /js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | |
parent | 0f040acabfb7a4bf3138debec5aff869487ceb11 (diff) | |
parent | 918a4f5870e972b6e4e301c3237e065a1ffd26f5 (diff) | |
download | ninja-c59eb371559a3061ce53223e249ca97daace5968.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Diffstat (limited to 'js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js')
-rwxr-xr-x | js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | 121 |
1 files changed, 113 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..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 | ||
@@ -51,6 +51,61 @@ exports.ThreeD = Montage.create(Component, { | |||
51 | } | 51 | } |
52 | }, | 52 | }, |
53 | 53 | ||
54 | x3DControl: { | ||
55 | value: null, | ||
56 | serializable: true | ||
57 | }, | ||
58 | |||
59 | y3DControl: { | ||
60 | value: null, | ||
61 | serializable: true | ||
62 | }, | ||
63 | |||
64 | z3DControl: { | ||
65 | value: null, | ||
66 | serializable: true | ||
67 | }, | ||
68 | |||
69 | x3DLabel: { | ||
70 | value: null, | ||
71 | serializable: true | ||
72 | }, | ||
73 | |||
74 | y3DLabel: { | ||
75 | value: null, | ||
76 | serializable: true | ||
77 | }, | ||
78 | |||
79 | z3DLabel: { | ||
80 | value: null, | ||
81 | serializable: true | ||
82 | }, | ||
83 | |||
84 | xAngleControl: { | ||
85 | value: null, | ||
86 | serializable: true | ||
87 | }, | ||
88 | |||
89 | yAngleControl: { | ||
90 | value: null, | ||
91 | serializable: true | ||
92 | }, | ||
93 | |||
94 | zAngleControl: { | ||
95 | value: null, | ||
96 | serializable: true | ||
97 | }, | ||
98 | |||
99 | axisModeGroupControl: { | ||
100 | value: null, | ||
101 | serializable: true | ||
102 | }, | ||
103 | |||
104 | flattenControl: { | ||
105 | value: null, | ||
106 | serializable: true | ||
107 | }, | ||
108 | |||
54 | x3D: { | 109 | x3D: { |
55 | value: 0 | 110 | value: 0 |
56 | }, | 111 | }, |
@@ -107,6 +162,10 @@ exports.ThreeD = Montage.create(Component, { | |||
107 | value: null | 162 | value: null |
108 | }, | 163 | }, |
109 | 164 | ||
165 | _transformCtr: { | ||
166 | value: null | ||
167 | }, | ||
168 | |||
110 | handleAction: { | 169 | handleAction: { |
111 | value: function(event) { | 170 | value: function(event) { |
112 | if(event.currentTarget.identifier === "flatten") { | 171 | if(event.currentTarget.identifier === "flatten") { |
@@ -143,10 +202,20 @@ exports.ThreeD = Montage.create(Component, { | |||
143 | value : function(prop, value, item, inGlobalMode, isChanging){ | 202 | value : function(prop, value, item, inGlobalMode, isChanging){ |
144 | if(!this._curMat) { | 203 | if(!this._curMat) { |
145 | 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 | } | ||
146 | } | 211 | } |
147 | 212 | ||
148 | var curMat = this._curMat; | 213 | var curMat = this._curMat, |
149 | var delta = value.value; | 214 | delta = value.value, |
215 | isRotating = false, | ||
216 | xFormMat = Matrix.I(4), | ||
217 | tMat = Matrix.I(4), | ||
218 | mat = []; | ||
150 | if(inGlobalMode) { | 219 | if(inGlobalMode) { |
151 | 220 | ||
152 | if(!this._curProp) { | 221 | if(!this._curProp) { |
@@ -156,17 +225,19 @@ exports.ThreeD = Montage.create(Component, { | |||
156 | delta -= this._curProp; | 225 | delta -= this._curProp; |
157 | } | 226 | } |
158 | 227 | ||
159 | var xFormMat = Matrix.I(4); | ||
160 | switch (prop) | 228 | switch (prop) |
161 | { | 229 | { |
162 | case "xAngle": | 230 | case "xAngle": |
163 | xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); | 231 | xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); |
232 | isRotating = true; | ||
164 | break; | 233 | break; |
165 | case "yAngle": | 234 | case "yAngle": |
166 | xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); | 235 | xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); |
236 | isRotating = true; | ||
167 | break; | 237 | break; |
168 | case "zAngle": | 238 | case "zAngle": |
169 | xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); | 239 | xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); |
240 | isRotating = true; | ||
170 | break; | 241 | break; |
171 | case "x3D": | 242 | case "x3D": |
172 | xFormMat[12] = delta; | 243 | xFormMat[12] = delta; |
@@ -179,11 +250,45 @@ exports.ThreeD = Montage.create(Component, { | |||
179 | break; | 250 | break; |
180 | } | 251 | } |
181 | 252 | ||
182 | var mat = []; | ||
183 | if(inGlobalMode) { | 253 | if(inGlobalMode) { |
184 | 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 | } | ||
185 | } else { | 274 | } else { |
186 | 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 | } | ||
187 | } | 292 | } |
188 | 293 | ||
189 | if(isChanging) { |