diff options
Diffstat (limited to 'js/panels/properties.reel/sections/three-d-view.reel')
-rwxr-xr-x | js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html | 2 | ||||
-rwxr-xr-x | js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | 121 |
2 files changed, 113 insertions, 10 deletions
diff --git a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html index 5ef13fab..572e5a60 100755 --- a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html +++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.html | |||
@@ -219,7 +219,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
219 | "properties": { | 219 | "properties": { |
220 | "element": {"#": "rdioLocal"}, | 220 | "element": {"#": "rdioLocal"}, |
221 | "label": "Local", | 221 | "label": "Local", |
222 | "value": "Local", | ||
223 | "group": {"@": "axisModeGroup"}, | 222 | "group": {"@": "axisModeGroup"}, |
224 | "checked": true | 223 | "checked": true |
225 | } | 224 | } |
@@ -229,7 +228,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
229 | "properties": { | 228 | "properties": { |
230 | "element": {"#": "rdioGlobal"}, | 229 | "element": {"#": "rdioGlobal"}, |
231 | "label": "Global", | 230 | "label": "Global", |
232 | "value": "Global", | ||
233 | "group": {"@": "axisModeGroup"} | 231 | "group": {"@": "axisModeGroup"} |
234 | } | 232 | } |
235 | }, | 233 | }, |
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]; | ||