diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/panels/properties/sections/three-d-view.reel/three-d-view.js | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/panels/properties/sections/three-d-view.reel/three-d-view.js')
-rw-r--r-- | js/panels/properties/sections/three-d-view.reel/three-d-view.js | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/js/panels/properties/sections/three-d-view.reel/three-d-view.js b/js/panels/properties/sections/three-d-view.reel/three-d-view.js new file mode 100644 index 00000000..38dbb110 --- /dev/null +++ b/js/panels/properties/sections/three-d-view.reel/three-d-view.js | |||
@@ -0,0 +1,219 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage; | ||
8 | var Component = require("montage/ui/component").Component; | ||
9 | |||
10 | exports.ThreeD = Montage.create(Component, { | ||
11 | |||
12 | inGlobalMode: { | ||
13 | value: false | ||
14 | }, | ||
15 | |||
16 | // TODO - booleans not working with boundValueMutator when bound to selectedIndex, so using index | ||
17 | // 0 = local; 1 = global | ||
18 | _axisMode: { | ||
19 | value: 0 | ||
20 | }, | ||
21 | |||
22 | axisMode: { | ||
23 | get: function() { | ||
24 | return this._axisMode; | ||
25 | }, | ||
26 | set: function(value) { | ||
27 | this._axisMode = value; | ||
28 | |||
29 | if(value === 0) | ||
30 | { | ||
31 | this.inGlobalMode = false; | ||
32 | this.x3D = 0; | ||
33 | this.y3D = 0; | ||
34 | this.z3D = 0; | ||
35 | |||
36 | this.xAngle = 0; | ||
37 | this.yAngle = 0; | ||
38 | this.zAngle = 0; | ||
39 | } | ||
40 | else | ||
41 | { | ||
42 | this.inGlobalMode = true; | ||
43 | if(this.application.ninja.selectedElements.length) | ||
44 | { | ||
45 | var item = this.application.ninja.selectedElements[0]._element; | ||
46 | if(item) | ||
47 | { | ||
48 | this.x3D = item.elementModel.props3D.x3D; | ||
49 | this.y3D = item.elementModel.props3D.y3D; | ||
50 | this.z3D = item.elementModel.props3D.z3D; | ||
51 | |||
52 | this.xAngle = item.elementModel.props3D.xAngle; | ||
53 | this.yAngle = item.elementModel.props3D.yAngle; | ||
54 | this.zAngle = item.elementModel.props3D.zAngle; | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | }, | ||
60 | |||
61 | x3D: { | ||
62 | value: 0 | ||
63 | }, | ||
64 | |||
65 | y3D: { | ||
66 | value: 0 | ||
67 | }, | ||
68 | |||
69 | z3D: { | ||
70 | value: 0 | ||
71 | }, | ||
72 | |||
73 | xAngle: { | ||
74 | value: 0 | ||
75 | }, | ||
76 | |||
77 | yAngle: { | ||
78 | value: 0 | ||
79 | }, | ||
80 | |||
81 | zAngle: { | ||
82 | value: 0 | ||
83 | }, | ||
84 | |||
85 | _disableTranslation: { | ||
86 | value: true | ||
87 | }, | ||
88 | |||
89 | disableTranslation: { | ||
90 | get: function () { | ||
91 | return this._disableTranslation; | ||
92 | }, | ||
93 | set: function (value) { | ||
94 | if(value !== this._disableTranslation) { | ||
95 | this._disableTranslation = value; | ||
96 | this.needsDraw = true; | ||
97 | } | ||
98 | } | ||
99 | }, | ||
100 | |||
101 | handleChange: { | ||
102 | value: function(event) { | ||
103 | if(event.wasSetByCode) { | ||
104 | return; | ||
105 | } | ||
106 | |||
107 | this.apply3DProperties(event.currentTarget.identifier, | ||
108 | event.currentTarget, | ||
109 | this.application.ninja.selectedElements[0]._element, | ||
110 | this.inGlobalMode, | ||
111 | false); | ||
112 | } | ||
113 | }, | ||
114 | |||
115 | handleChanging: { | ||
116 | value: function(event) { | ||
117 | if(event.wasSetByCode) { | ||
118 | return; | ||
119 | } | ||
120 | |||
121 | this.apply3DProperties(event.currentTarget.identifier, | ||
122 | event.currentTarget, | ||
123 | this.application.ninja.selectedElements[0]._element, | ||
124 | this.inGlobalMode, | ||
125 | true); | ||
126 | } | ||
127 | }, | ||
128 | |||
129 | apply3DProperties : { | ||
130 | value : function(prop, value, item, inGlobalMode, isChanging){ | ||
131 | // TODO - May want to use mediator instead | ||
132 | var curMat = item.elementModel.props3D.matrix3d; | ||
133 | var delta = value.value - item.elementModel.props3D[prop]; | ||
134 | |||
135 | var xFormMat = Matrix.I(4); | ||
136 | switch (prop) | ||
137 | { | ||
138 | case "xAngle": | ||
139 | xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); | ||
140 | break; | ||
141 | case "yAngle": | ||
142 | xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); | ||
143 | break; | ||
144 | case "zAngle": | ||
145 | xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); | ||
146 | break; | ||
147 | case "x3D": | ||
148 | xFormMat[12] = delta; | ||
149 | break; | ||
150 | case "y3D": | ||
151 | xFormMat[13] = delta; | ||
152 | break; | ||
153 | case "z3D": | ||
154 | xFormMat[14] = delta; | ||
155 | break; | ||
156 | } | ||
157 | |||
158 | var mat = []; | ||
159 | if(inGlobalMode) | ||
160 | { | ||
161 | glmat4.multiply(xFormMat, curMat, mat); | ||
162 | } | ||
163 | else | ||
164 | { | ||
165 | glmat4.multiply(curMat, xFormMat, mat); | ||
166 | } | ||
167 | |||
168 | if(isChanging) | ||
169 | { | ||
170 | this.application.ninja.elementMediator.setMatrix(item, mat, true); | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | this.application.ninja.elementMediator.setMatrix(item, mat, false); | ||
175 | |||
176 | if(!inGlobalMode) | ||
177 | { | ||
178 | value.value = 0; | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | }, | ||
183 | |||
184 | templateDidLoad : { | ||
185 | value: function() { | ||
186 | Object.defineBinding(this, "axisMode", { | ||
187 | boundObject: this.axisModeGroupControl, | ||
188 | boundObjectPropertyPath: "selectedIndex", | ||
189 | oneway: false | ||
190 | }); | ||
191 | |||
192 | } | ||
193 | }, | ||
194 | |||
195 | draw: { | ||
196 | value: function() { | ||
197 | if(this._disableTranslation) { | ||
198 | this.x3D = 0; | ||
199 | this.x3DControl.enabled = false; | ||
200 | this.y3D = 0; | ||
201 | this.y3DControl.enabled = false; | ||
202 | this.z3D = 0; | ||
203 | this.z3DControl.enabled = false; | ||
204 | |||
205 | this.x3DLabel.classList.add("disabled"); | ||
206 | this.y3DLabel.classList.add("disabled"); | ||
207 | this.z3DLabel.classList.add("disabled"); | ||
208 | } else { | ||
209 | this.x3DControl.enabled = true; | ||