diff options
Diffstat (limited to 'js/panels/Materials/materials-popup.reel/materials-popup.js')
-rwxr-xr-x | js/panels/Materials/materials-popup.reel/materials-popup.js | 124 |
1 files changed, 98 insertions, 26 deletions
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js index a4f758cf..5b9790b8 100755 --- a/js/panels/Materials/materials-popup.reel/materials-popup.js +++ b/js/panels/Materials/materials-popup.reel/materials-popup.js | |||
@@ -18,6 +18,9 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
18 | value: "" | 18 | value: "" |
19 | }, | 19 | }, |
20 | 20 | ||
21 | _useSelection: { value: false, enumerable: true }, | ||
22 | _whichMaterial: { value: "fill", enumerable: true }, | ||
23 | |||
21 | captureAction: { | 24 | captureAction: { |
22 | value:function(event) { | 25 | value:function(event) { |
23 | switch(event._currentTarget.label) | 26 | switch(event._currentTarget.label) |
@@ -88,8 +91,9 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
88 | 91 | ||
89 | _handlePropertyChange: | 92 | _handlePropertyChange: |
90 | { | 93 | { |
91 | value: function(event) | 94 | value: function(theEvent) |
92 | { | 95 | { |
96 | var event = theEvent._event; | ||
93 | if(typeof event.propertyValue === "object") | 97 | if(typeof event.propertyValue === "object") |
94 | { | 98 | { |
95 | console.log(event.propertyLabel + " changed to "); | 99 | console.log(event.propertyLabel + " changed to "); |
@@ -133,6 +137,25 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
133 | var value = this.decodeValue( this._propTypes[index], propValue ); | 137 | var value = this.decodeValue( this._propTypes[index], propValue ); |
134 | this._material.setProperty( this._propNames[index], value ); | 138 | this._material.setProperty( this._propNames[index], value ); |
135 | } | 139 | } |
140 | |||
141 | if (this._useSelection) | ||
142 | { | ||
143 | console.log( "apply to selection" ); | ||
144 | |||
145 | var selection = this.application.ninja.selectedElements; | ||
146 | if (selection && (selection.length > 0)) | ||
147 | { | ||
148 | var canvas = selection[0]; | ||
149 | var obj; | ||
150 | if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj; | ||
151 | if (obj) | ||
152 | { | ||
153 | var world = obj.getWorld(); | ||
154 | if (world) | ||
155 | world.restartRenderLoop(); | ||
156 | } | ||
157 | } | ||
158 | } | ||
136 | } | 159 | } |
137 | } | 160 | } |
138 | }, | 161 | }, |
@@ -158,14 +181,20 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
158 | rtnValue = value; | 181 | rtnValue = value; |
159 | break; | 182 | break; |
160 | 183 | ||
184 | case "angle": | ||
185 | rtnValue = value*3.14159/180.0; | ||
186 | break; | ||
187 | |||
161 | case "file": | 188 | case "file": |
162 | if (value && (value.length > 0)) | 189 | if (value && (value.length > 0)) |
163 | { | 190 | { |
164 | var index = value.lastIndexOf( "/" ); | 191 | var index = value.lastIndexOf( "/" ); |
165 | if (index < 0) index = value.lastIndexOf( "\\" ); | 192 | if (index < 0) index = value.lastIndexOf( "\\" ); |
166 | if (index >= 0) | 193 | if (index >= 0) |
194 | { | ||
167 | value = value.substr( index+1 ); | 195 | value = value.substr( index+1 ); |
168 | value = "assets\\images\\" + value; | 196 | value = "assets/images/" + value; |
197 | } | ||
169 | rtnValue = value.slice(0); | 198 | rtnValue = value.slice(0); |
170 | } | 199 | } |
171 | break; | 200 | break; |
@@ -212,32 +241,71 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
212 | loadMaterials: | 241 | loadMaterials: |
213 | { | 242 | { |
214 | enumerable: true, | 243 | enumerable: true, |
215 | value: function(materialID) | 244 | value: function(materialID, useSelection, whichMaterial) |
216 | { | 245 | { |
217 | //TODO - Hack to force repetition to draw. Setting .length = 0 did not work. | 246 | //TODO - Hack to force repetition to draw. Setting .length = 0 did not work. |
218 | this.materialsData = []; | 247 | this.materialsData = []; |
219 | 248 | ||
220 | this._materialName = materialID; | 249 | var material; |
221 | if( | 250 | this._materialName = materialID; |
222 | (materialID === "UberMaterial") || | 251 | if (useSelection) |
223 | (materialID === "FlatMaterial") || | ||
224 | (materialID === "BumpMetalMaterial") || | ||
225 | (materialID === "LinearGradientMaterial") || | ||
226 | (materialID === "RadialGradientMaterial") | ||
227 | ) | ||
228 | { | 252 | { |
229 | var material = MaterialsModel.getMaterial( materialID ); | 253 | this._useSelection = true; |
230 | if (material) | 254 | var selection = this.application.ninja.selectedElements; |
255 | if (selection && (selection.length > 0)) | ||
231 | { | 256 | { |
232 | this._material = material; | 257 | var canvas = selection[0]; |
233 | this.materialsData = this.getMaterialData( material ); | 258 | var obj; |
259 | this._whichMaterial = whichMaterial; | ||
260 | if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj; | ||
261 | if (obj) | ||
262 | material = (whichMaterial === 'stroke') ? obj.getStrokeMaterial() : obj.getFillMaterial(); | ||
234 | } | 263 | } |
235 | } | 264 | } |
236 | else | 265 | else |
237 | { | 266 | { |
238 | this.materialsData = this[materialID]; | 267 | this._useSelection = false; |
239 | } | 268 | |
240 | this.needsDraw = true; | 269 | if( |
270 | (materialID === "BumpMetalMaterial") || | ||
271 | (materialID === "DeformMaterial") || | ||
272 | (materialID === "FlatMaterial") || | ||
273 | (materialID === "FlagMaterial") || | ||
274 | (materialID === "FlyMaterial") || | ||
275 | (materialID === "JuliaMaterial") || | ||
276 | (materialID === "KeleidoscopeMaterial") || | ||
277 | (materialID === "LinearGradientMaterial") || | ||
278 | (materialID === "MandelMaterial") || | ||
279 | (materialID === "PlasmaMaterial") || | ||
280 | (materialID === "PulseMaterial") || | ||
281 | (materialID === "RadialBlurMaterial") || | ||
282 | (materialID === "RadialGradientMaterial") || | ||
283 | (materialID === "ReliefTunnelMaterial") || | ||
284 | (materialID === "SquareTunnelMaterial") || | ||
285 | (materialID === "StarMaterial") || | ||
286 | (materialID === "TaperMaterial") || | ||
287 | (materialID === "TunnelMaterial") || | ||
288 | (materialID === "TwistMaterial") || | ||
289 | (materialID === "TwistVertMaterial") || | ||
290 | (materialID === "UberMaterial") || | ||
291 | (materialID === "WaterMaterial") || | ||
292 | (materialID === "ZInvertMaterial") | ||
293 | ) | ||
294 | { | ||
295 | material = MaterialsModel.getMaterial( materialID ); | ||
296 | } | ||
297 | } | ||
298 | |||
299 | if (material) | ||
300 | { | ||
301 | this._material = material; | ||
302 | this.materialsData = this.getMaterialData( material ); | ||
303 | } | ||
304 | else | ||
305 | { | ||
306 | this.materialsData = this[materialID]; | ||
307 | } | ||
308 | this.needsDraw = true; | ||
241 | } | 309 | } |
242 | }, | 310 | }, |
243 | 311 | ||
@@ -276,6 +344,10 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
276 | obj = this.createFloatData( propLabels[i], propValues[i] ); | 344 | obj = this.createFloatData( propLabels[i], propValues[i] ); |
277 | break; | 345 | break; |
278 | 346 | ||
347 | case "angle": | ||
348 | obj = this.createFloatData( propLabels[i], propValues[i]*180.0/3.14159 ); | ||
349 | break; | ||
350 | |||
279 | case "file": | 351 | case "file": |
280 | obj = this.createFileData( propLabels[i], propValues[i] ); | 352 | obj = this.createFileData( propLabels[i], propValues[i] ); |
281 | break; | 353 | break; |
@@ -304,7 +376,7 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
304 | { |