diff options
author | Jose Antonio Marquez | 2012-03-01 18:13:18 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-03-01 18:13:18 -0800 |
commit | 66bc1f46938afc696b11878ebbb97d1fd361386e (patch) | |
tree | a4e8d066bf80a43f42ce971a3ca05ab88f457d16 /js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | |
parent | 80ac930684255dd24cecae70b488285a6058488e (diff) | |
parent | 61dd921d5bb06ab47ee84506dbaaeaf4895ebf42 (diff) | |
download | ninja-66bc1f46938afc696b11878ebbb97d1fd361386e.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into FileIO
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 | 265 |
1 files changed, 265 insertions, 0 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 new file mode 100755 index 00000000..35591afa --- /dev/null +++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | |||
@@ -0,0 +1,265 @@ | |||
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 | var item = this.item; | ||
44 | if(item) | ||
45 | { | ||
46 | this.x3D = item.elementModel.props3D.x3D; | ||
47 | this.y3D = item.elementModel.props3D.y3D; | ||
48 | this.z3D = item.elementModel.props3D.z3D; | ||
49 | |||
50 | this.xAngle = item.elementModel.props3D.xAngle; | ||
51 | this.yAngle = item.elementModel.props3D.yAngle; | ||
52 | this.zAngle = item.elementModel.props3D.zAngle; | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | }, | ||
57 | |||
58 | x3D: { | ||
59 | value: 0 | ||
60 | }, | ||
61 | |||
62 | y3D: { | ||
63 | value: 0 | ||
64 | }, | ||
65 | |||
66 | z3D: { | ||
67 | value: 0 | ||
68 | }, | ||
69 | |||
70 | xAngle: { | ||
71 | value: 0 | ||
72 | }, | ||
73 | |||
74 | yAngle: { | ||
75 | value: 0 | ||
76 | }, | ||
77 | |||
78 | zAngle: { | ||
79 | value: 0 | ||
80 | }, | ||
81 | |||
82 | _disableTranslation: { | ||
83 | value: true | ||
84 | }, | ||
85 | |||
86 | disableTranslation: { | ||
87 | get: function () { | ||
88 | return this._disableTranslation; | ||
89 | }, | ||
90 | set: function (value) { | ||
91 | if(value !== this._disableTranslation) { | ||
92 | this._disableTranslation = value; | ||
93 | this.needsDraw = true; | ||
94 | } | ||
95 | } | ||
96 | }, | ||
97 | |||
98 | item: { | ||
99 | value: null | ||
100 | }, | ||
101 | |||
102 | _curMat: { | ||
103 | value: null | ||
104 | }, | ||
105 | |||
106 | _curProp: { | ||
107 | value: null | ||
108 | }, | ||
109 | |||
110 | handleChange: { | ||
111 | value: function(event) { | ||
112 | if(event.wasSetByCode) { | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | this.apply3DProperties(event.currentTarget.identifier, | ||
117 | event.currentTarget, | ||
118 | this.item, | ||
119 | this.inGlobalMode, | ||
120 | false); | ||
121 | |||
122 | this._curMat = null; | ||
123 | this._curProp = null; | ||
124 | } | ||
125 | }, | ||
126 | |||
127 | handleChanging: { | ||
128 | value: function(event) { | ||
129 | if(event.wasSetByCode) { | ||
130 | return; | ||
131 | } | ||
132 | |||
133 | this.apply3DProperties(event.currentTarget.identifier, | ||
134 | event.currentTarget, | ||
135 | this.item, | ||
136 | this.inGlobalMode, | ||
137 | true); | ||
138 | } | ||
139 | }, | ||
140 | |||
141 | apply3DProperties : { | ||
142 | value : function(prop, value, item, inGlobalMode, isChanging){ | ||
143 | if(!this._curMat) | ||
144 | { | ||
145 | this._curMat = this.application.ninja.elementMediator.getMatrix(item); | ||
146 | } | ||
147 | var curMat = this._curMat; | ||
148 | var delta = value.value; | ||
149 | if(inGlobalMode) | ||
150 | { | ||
151 | if(!this._curProp) | ||
152 | { | ||
153 | this._curProp = this.application.ninja.elementMediator.get3DProperty(item, prop); | ||
154 | } | ||
155 | delta -= this._curProp; | ||
156 | } | ||
157 | |||
158 | var xFormMat = Matrix.I(4); | ||
159 | switch (prop) | ||
160 | { | ||
161 | case "xAngle": | ||
162 | xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); | ||
163 | break; | ||
164 | case "yAngle": | ||
165 | xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); | ||
166 | break; | ||
167 | case "zAngle": | ||
168 | xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); | ||
169 | break; | ||
170 | case "x3D": | ||
171 | xFormMat[12] = delta; | ||
172 | break; | ||
173 | case "y3D": | ||
174 | xFormMat[13] = delta; | ||
175 | break; | ||
176 | case "z3D": | ||
177 | xFormMat[14] = delta; | ||
178 | break; | ||
179 | } | ||
180 | |||
181 | var mat = []; | ||
182 | if(inGlobalMode) | ||
183 | { | ||
184 | glmat4.multiply(xFormMat, curMat, mat); | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | glmat4.multiply(curMat, xFormMat, mat); | ||
189 | } | ||
190 | |||
191 | if(isChanging) | ||
192 | { | ||
193 | this.application.ninja.elementMediator.setMatrix(item, mat, true); | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | this.application.ninja.elementMediator.setMatrix(item, mat, false); | ||
198 | |||
199 | if(!inGlobalMode) | ||
200 | { | ||
201 | value.value = 0; | ||
202 | } | ||
203 | } | ||
204 | } | ||
< |