diff options
Diffstat (limited to 'js/panels/properties.reel/sections')
-rwxr-xr-x | js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js | 95 |
1 files changed, 44 insertions, 51 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 e16e3509..104d474d 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 | |||
@@ -26,8 +26,7 @@ exports.ThreeD = Montage.create(Component, { | |||
26 | set: function(value) { | 26 | set: function(value) { |
27 | this._axisMode = value; | 27 | this._axisMode = value; |
28 | 28 | ||
29 | if(value === 0) | 29 | if(value === 0) { |
30 | { | ||
31 | this.inGlobalMode = false; | 30 | this.inGlobalMode = false; |
32 | this.x3D = 0; | 31 | this.x3D = 0; |
33 | this.y3D = 0; | 32 | this.y3D = 0; |
@@ -36,13 +35,10 @@ exports.ThreeD = Montage.create(Component, { | |||
36 | this.xAngle = 0; | 35 | this.xAngle = 0; |
37 | this.yAngle = 0; | 36 | this.yAngle = 0; |
38 | this.zAngle = 0; | 37 | this.zAngle = 0; |
39 | } | 38 | } else { |
40 | else | ||
41 | { | ||
42 | this.inGlobalMode = true; | 39 | this.inGlobalMode = true; |
43 | var item = this.item; | 40 | var item = this.item; |
44 | if(item) | 41 | if(item) { |
45 | { | ||
46 | this.x3D = item.elementModel.props3D.x3D; | 42 | this.x3D = item.elementModel.props3D.x3D; |
47 | this.y3D = item.elementModel.props3D.y3D; | 43 | this.y3D = item.elementModel.props3D.y3D; |
48 | this.z3D = item.elementModel.props3D.z3D; | 44 | this.z3D = item.elementModel.props3D.z3D; |
@@ -114,8 +110,7 @@ exports.ThreeD = Montage.create(Component, { | |||
114 | handleAction: { | 110 | handleAction: { |
115 | value: function(event) { | 111 | value: function(event) { |
116 | if(event.currentTarget.identifier === "flatten") { | 112 | if(event.currentTarget.identifier === "flatten") { |
117 | this.application.ninja.elementMediator.setProperty([this.item], | 113 | this.application.ninja.elementMediator.setProperty([this.item], "-webkit-transform-style", |
118 | "-webkit-transform-style", | ||
119 | event.currentTarget.checked ? ["flat"] : ["preserve-3d"]); | 114 | event.currentTarget.checked ? ["flat"] : ["preserve-3d"]); |
120 | } | 115 | } |
121 | } | 116 | } |
@@ -127,11 +122,7 @@ exports.ThreeD = Montage.create(Component, { | |||
127 | return; | 122 | return; |
128 | } | 123 | } |
129 | 124 | ||
130 | this.apply3DProperties(event.currentTarget.identifier, | 125 | this.apply3DProperties(event.currentTarget.identifier, event.currentTarget, this.item, this.inGlobalMode, false); |
131 | event.currentTarget, | ||
132 | this.item, | ||
133 | this.inGlobalMode, | ||
134 | false); | ||
135 | 126 | ||
136 | this._curMat = null; | 127 | this._curMat = null; |
137 | this._curProp = null; | 128 | this._curProp = null; |
@@ -144,28 +135,24 @@ exports.ThreeD = Montage.create(Component, { | |||
144 | return; | 135 | return; |
145 | } | 136 | } |
146 | 137 | ||
147 | this.apply3DProperties(event.currentTarget.identifier, | 138 | this.apply3DProperties(event.currentTarget.identifier, event.currentTarget, this.item, this.inGlobalMode, true); |
148 | event.currentTarget, | ||
149 | this.item, | ||
150 | this.inGlobalMode, | ||
151 | true); | ||
152 | } | 139 | } |
153 | }, | 140 | }, |
154 | 141 | ||
155 | apply3DProperties : { | 142 | apply3DProperties : { |
156 | value : function(prop, value, item, inGlobalMode, isChanging){ | 143 | value : function(prop, value, item, inGlobalMode, isChanging){ |
157 | if(!this._curMat) | 144 | if(!this._curMat) { |
158 | { | ||
159 | this._curMat = this.application.ninja.elementMediator.getMatrix(item); | 145 | this._curMat = this.application.ninja.elementMediator.getMatrix(item); |
160 | } | 146 | } |
147 | |||
161 | var curMat = this._curMat; | 148 | var curMat = this._curMat; |
162 | var delta = value.value; | 149 | var delta = value.value; |
163 | if(inGlobalMode) | 150 | if(inGlobalMode) { |
164 | { | 151 | |
165 | if(!this._curProp) | 152 | if(!this._curProp) { |
166 | { | ||
167 | this._curProp = this.application.ninja.elementMediator.get3DProperty(item, prop); | 153 | this._curProp = this.application.ninja.elementMediator.get3DProperty(item, prop); |
168 | } | 154 | } |
155 | |||
169 | delta -= this._curProp; | 156 | delta -= this._curProp; |
170 | } | 157 | } |
171 | 158 | ||
@@ -193,31 +180,51 @@ exports.ThreeD = Montage.create(Component, { | |||
193 | } | 180 | } |
194 | 181 | ||
195 | var mat = []; | 182 | var mat = []; |
196 | if(inGlobalMode) | 183 | if(inGlobalMode) { |
197 | { | ||
198 | glmat4.multiply(xFormMat, curMat, mat); | 184 | glmat4.multiply(xFormMat, curMat, mat); |
199 | } | 185 | } else { |
200 | else | ||
201 | { | ||
202 | glmat4.multiply(curMat, xFormMat, mat); | 186 | glmat4.multiply(curMat, xFormMat, mat); |
203 | } | 187 | } |
204 | 188 | ||
205 | if(isChanging) | 189 | if(isChanging) { |
206 | { | ||
207 | this.application.ninja.elementMediator.setMatrix(item, mat, true); | 190 | this.application.ninja.elementMediator.setMatrix(item, mat, true); |
208 | } | 191 | } else { |
209 | else | ||
210 | { | ||
211 | this.application.ninja.elementMediator.setMatrix(item, mat, false); | 192 | this.application.ninja.elementMediator.setMatrix(item, mat, false); |
212 | 193 | ||
213 | if(!inGlobalMode) | 194 | if(!inGlobalMode) { |
214 | { | ||
215 | value.value = 0; | 195 | value.value = 0; |
216 | } | 196 | } |
217 | } | 197 | } |
218 | } | 198 | } |
219 | }, | 199 | }, |
220 | 200 | ||
201 | _currentDocument: { | ||
202 | value : null | ||
203 | }, | ||
204 | |||
205 | currentDocument : { | ||
206 | get : function() { | ||
207 | return this._currentDocument; | ||
208 | }, | ||
209 | set : function(value) { | ||
210 | if (value === this._currentDocument) { | ||
211 | return; | ||
212 | } | ||
213 | |||
214 | this._currentDocument = value; | ||
215 | |||
216 | if(this._currentDocument && this._currentDocument.currentView === "design") { | ||
217 | // Save a reference of the pi inside the document view to be able to clear | ||
218 | Object.defineBinding(this, "item", { | ||
219 | boundObject: this, | ||
220 | boundObjectPropertyPath: "application.ninja.selectedElements", | ||
221 | boundValueMutator: this._getSelectedItem, | ||
222 | oneway: true | ||
223 | }); | ||
224 | } | ||
225 | } | ||
226 | }, | ||
227 | |||
221 | templateDidLoad : { | 228 | templateDidLoad : { |
222 | value: function() { | 229 | value: function() { |
223 | Object.defineBinding(this, "axisMode", { | 230 | Object.defineBinding(this, "axisMode", { |
@@ -225,20 +232,6 @@ exports.ThreeD = Montage.create(Component, { | |||
225 | boundObjectPropertyPath: "selectedIndex", | 232 | boundObjectPropertyPath: "selectedIndex", |
226 | oneway: false | 233 | oneway: false |
227 | }); | 234 | }); |
228 | |||
229 | this.eventManager.addEventListener("openDocument", this, false); | ||
230 | } | ||
231 | }, | ||
232 | |||
233 | handleOpenDocument: { | ||
234 | value: function() { | ||
235 | |||
236 | Object.defineBinding(this, "item", { | ||
237 | boundObject: this, | ||
238 | boundObjectPropertyPath: "application.ninja.selectedElements", | ||
239 | boundValueMutator: this._getSelectedItem, | ||
240 | oneway: true | ||
241 | }); | ||
242 | } | 235 | } |
243 | }, | 236 | }, |
244 | 237 | ||