aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Materials/materials-popup.reel/materials-popup.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Materials/materials-popup.reel/materials-popup.js')
-rwxr-xr-xjs/panels/Materials/materials-popup.reel/materials-popup.js124
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 0a32447e..75843b66 100755
--- a/js/panels/Materials/materials-popup.reel/materials-popup.js
+++ b/js/panels/Materials/materials-popup.reel/materials-popup.js
@@ -33,6 +33,9 @@ exports.MaterialsPopup = Montage.create(Component, {
33 value: "" 33 value: ""
34 }, 34 },
35 35
36 _useSelection: { value: false, enumerable: true },
37 _whichMaterial: { value: "fill", enumerable: true },
38
36 captureAction: { 39 captureAction: {
37 value:function(event) { 40 value:function(event) {
38 switch(event._currentTarget.label) 41 switch(event._currentTarget.label)
@@ -103,8 +106,9 @@ exports.MaterialsPopup = Montage.create(Component, {
103 106
104 _handlePropertyChange: 107 _handlePropertyChange:
105 { 108 {
106 value: function(event) 109 value: function(theEvent)
107 { 110 {
111 var event = theEvent._event;
108 if(typeof event.propertyValue === "object") 112 if(typeof event.propertyValue === "object")
109 { 113 {
110 console.log(event.propertyLabel + " changed to "); 114 console.log(event.propertyLabel + " changed to ");
@@ -148,6 +152,25 @@ exports.MaterialsPopup = Montage.create(Component, {
148 var value = this.decodeValue( this._propTypes[index], propValue ); 152 var value = this.decodeValue( this._propTypes[index], propValue );
149 this._material.setProperty( this._propNames[index], value ); 153 this._material.setProperty( this._propNames[index], value );
150 } 154 }
155
156 if (this._useSelection)
157 {
158 console.log( "apply to selection" );
159
160 var selection = this.application.ninja.selectedElements;
161 if (selection && (selection.length > 0))
162 {
163 var canvas = selection[0];
164 var obj;
165 if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj;
166 if (obj)
167 {
168 var world = obj.getWorld();
169 if (world)
170 world.restartRenderLoop();
171 }
172 }
173 }
151 } 174 }
152 } 175 }
153 }, 176 },
@@ -173,14 +196,20 @@ exports.MaterialsPopup = Montage.create(Component, {
173 rtnValue = value; 196 rtnValue = value;
174 break; 197 break;
175 198
199 case "angle":
200 rtnValue = value*3.14159/180.0;
201 break;
202
176 case "file": 203 case "file":
177 if (value && (value.length > 0)) 204 if (value && (value.length > 0))
178 { 205 {
179 var index = value.lastIndexOf( "/" ); 206 var index = value.lastIndexOf( "/" );
180 if (index < 0) index = value.lastIndexOf( "\\" ); 207 if (index < 0) index = value.lastIndexOf( "\\" );
181 if (index >= 0) 208 if (index >= 0)
209 {
182 value = value.substr( index+1 ); 210 value = value.substr( index+1 );
183 value = "assets\\images\\" + value; 211 value = "assets/images/" + value;
212 }
184 rtnValue = value.slice(0); 213 rtnValue = value.slice(0);
185 } 214 }
186 break; 215 break;
@@ -227,32 +256,71 @@ exports.MaterialsPopup = Montage.create(Component, {
227 loadMaterials: 256 loadMaterials:
228 { 257 {
229 enumerable: true, 258 enumerable: true,
230 value: function(materialID) 259 value: function(materialID, useSelection, whichMaterial)
231 { 260 {
232 //TODO - Hack to force repetition to draw. Setting .length = 0 did not work. 261 //TODO - Hack to force repetition to draw. Setting .length = 0 did not work.
233 this.materialsData = []; 262 this.materialsData = [];
234 263
235 this._materialName = materialID; 264 var material;
236 if( 265 this._materialName = materialID;
237 (materialID === "UberMaterial") || 266 if (useSelection)
238 (materialID === "FlatMaterial") ||
239 (materialID === "BumpMetalMaterial") ||
240 (materialID === "LinearGradientMaterial") ||
241 (materialID === "RadialGradientMaterial")
242 )
243 { 267 {
244 var material = MaterialsModel.getMaterial( materialID ); 268 this._useSelection = true;
245 if (material) 269 var selection = this.application.ninja.selectedElements;
270 if (selection && (selection.length > 0))
246 { 271 {
247 this._material = material; 272 var canvas = selection[0];
248 this.materialsData = this.getMaterialData( material ); 273 var obj;
274 this._whichMaterial = whichMaterial;
275 if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj;
276 if (obj)
277 material = (whichMaterial === 'stroke') ? obj.getStrokeMaterial() : obj.getFillMaterial();
249 } 278 }
250 } 279 }
251 else 280 else
252 { 281 {
253 this.materialsData = this[materialID]; 282 this._useSelection = false;
254 } 283
255 this.needsDraw = true; 284 if(
285 (materialID === "BumpMetalMaterial") ||
286 (materialID === "DeformMaterial") ||
287 (materialID === "FlatMaterial") ||
288 (materialID === "FlagMaterial") ||
289 (materialID === "FlyMaterial") ||
290 (materialID === "JuliaMaterial") ||
291 (materialID === "KeleidoscopeMaterial") ||
292 (materialID === "LinearGradientMaterial") ||
293 (materialID === "MandelMaterial") ||
294 (materialID === "PlasmaMaterial") ||
295 (materialID === "PulseMaterial") ||
296 (materialID === "RadialBlurMaterial") ||
297 (materialID === "RadialGradientMaterial") ||
298 (materialID === "ReliefTunnelMaterial") ||
299 (materialID === "SquareTunnelMaterial") ||
300 (materialID === "StarMaterial") ||
301 (materialID === "TaperMaterial") ||
302 (materialID === "TunnelMaterial") ||
303 (materialID === "TwistMaterial") ||
304 (materialID === "TwistVertMaterial") ||
305 (materialID === "UberMaterial") ||
306 (materialID === "WaterMaterial") ||
307 (materialID === "ZInvertMaterial")
308 )
309 {
310 material = MaterialsModel.getMaterial( materialID );
311 }
312 }
313
314 if (material)
315 {
316 this._material = material;
317 this.materialsData = this.getMaterialData( material );
318 }
319 else
320 {
321 this.materialsData = this[materialID];
322 }
323 this.needsDraw = true;
256 } 324 }
257 }, 325 },
258 326
@@ -291,6 +359,10 @@ exports.MaterialsPopup = Montage.create(Component, {
291 obj = this.createFloatData( propLabels[i], propValues[i] ); 359 obj = this.createFloatData( propLabels[i], propValues[i] );
292 break; 360 break;
293 361
362 case "angle":
363 obj = this.createFloatData( propLabels[i], propValues[i]*180.0/3.14159 );
364 break;
365
294 case "file": 366 case "file":
295 obj = this.createFileData( propLabels[i], propValues[i] ); 367 obj = this.createFileData( propLabels[i], propValues[i] );
296 break; 368 break;
@@ -319,7 +391,7 @@ exports.MaterialsPopup = Montage.create(Component, {
319 {