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.js724
1 files changed, 362 insertions, 362 deletions
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js
index 0d0435a4..501df282 100755
--- a/js/panels/Materials/materials-popup.reel/materials-popup.js
+++ b/js/panels/Materials/materials-popup.reel/materials-popup.js
@@ -79,25 +79,25 @@ exports.MaterialsPopup = Montage.create(Component, {
79 serializable: true 79 serializable: true
80 }, 80 },
81 81
82 // Material Properties 82 // Material Properties
83 _materialName: { 83 _materialName: {
84 enumerable: true, 84 enumerable: true,
85 value: "" 85 value: ""
86 }, 86 },
87 87
88 _useSelection: { value: false, enumerable: true }, 88 _useSelection: { value: false, enumerable: true },
89 _whichMaterial: { value: "fill", enumerable: true }, 89 _whichMaterial: { value: "fill", enumerable: true },
90 _originalValues: {value: null, enumerable: true }, 90 _originalValues: {value: null, enumerable: true },
91 91
92 captureAction: { 92 captureAction: {
93 value:function(event) { 93 value:function(event) {
94 switch(event._currentTarget.label) 94 switch(event._currentTarget.label)
95 { 95 {
96 case "Cancel": 96 case "Cancel":
97// console.log("Cancel material edit"); 97// console.log("Cancel material edit");
98 this.revertToOriginalValues(); 98 this.revertToOriginalValues();
99 break; 99 break;
100 case "OK": 100 case "OK":
101// console.log("Committing material with the following values:"); 101// console.log("Committing material with the following values:");
102 for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++) 102 for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++)
103 { 103 {
@@ -116,19 +116,19 @@ exports.MaterialsPopup = Montage.create(Component, {
116 console.log("--------------"); 116 console.log("--------------");
117 117
118 } 118 }
119 break; 119 break;
120 case "Save As...": 120 case "Save As...":
121 this.saveAs(); 121 this.saveAs();
122 break; 122 break;
123 case "Reset": 123 case "Reset":
124 this.reset(); 124 this.reset();
125 break; 125 break;
126 } 126 }
127 127
128 // Notify Materials Library to close popup 128 // Notify Materials Library to close popup
129 NJevent("hideMaterialPopup"); 129 NJevent("hideMaterialPopup");
130 } 130 }
131 }, 131 },
132 132
133 saveAs: 133 saveAs:
134 { 134 {
@@ -152,45 +152,45 @@ exports.MaterialsPopup = Montage.create(Component, {
152 } 152 }
153 }, 153 },
154 154
155 revertToOriginalValues: 155 revertToOriginalValues:
156 { 156 {
157 value: function() 157 value: function()
158 { 158 {
159 if (this._originalValues) 159 if (this._originalValues)
160 { 160 {
161 this._material.importJSON( this._originalValues ); 161 this._material.importJSON( this._originalValues );
162 162
163 if (this._useSelection) 163 if (this._useSelection)
164 { 164 {
165 var selection = this.application.ninja.selectedElements; 165 var selection = this.application.ninja.selectedElements;
166 if (selection && (selection.length > 0)) 166 if (selection && (selection.length > 0))
167 { 167 {
168 var nObjs = selection.length; 168 var nObjs = selection.length;
169 for (var iObj=0; iObj<nObjs; iObj++) 169 for (var iObj=0; iObj<nObjs; iObj++)
170 { 170 {
171 var canvas = selection[iObj]; 171 var canvas = selection[iObj];
172 var obj; 172 var obj;
173 if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj; 173 if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj;
174 if (obj) 174 if (obj)
175 { 175 {
176 var matArray = obj._materialArray; 176 var matArray = obj._materialArray;
177 var matTypeArray = obj._materialTypeArray; 177 var matTypeArray = obj._materialTypeArray;
178 var nMats = matArray.length; 178 var nMats = matArray.length;
179 for (var iMat=0; iMat<nMats; iMat++) 179 for (var iMat=0; iMat<nMats; iMat++)
180 { 180 {
181 if (matTypeArray[iMat] === this._whichMaterial) 181 if (matTypeArray[iMat] === this._whichMaterial)
182 matArray[iMat].importJSON( this._originalValues ); 182 matArray[iMat].importJSON( this._originalValues );
183 } 183 }
184 var world = obj.getWorld(); 184 var world = obj.getWorld();
185 if (world) 185 if (world)
186 world.restartRenderLoop(); 186 world.restartRenderLoop();
187 } 187 }
188 } 188 }
189 } 189 }
190 } 190 }
191 } 191 }
192 } 192 }
193 }, 193 },
194 194
195 updatePreview: 195 updatePreview:
196 { 196 {
@@ -221,8 +221,8 @@ exports.MaterialsPopup = Montage.create(Component, {
221// console.log(event.propertyLabel + " changing to " + event.propertyValue); 221// console.log(event.propertyLabel + " changing to " + event.propertyValue);
222// } 222// }
223 223
224 if (event.propertyLabel && event.propertyValue) 224 if (event.propertyLabel && event.propertyValue)
225 this.applyProperty( event.propertyLabel, event.propertyValue ); 225 this.applyProperty( event.propertyLabel, event.propertyValue );
226 } 226 }
227 }, 227 },
228 228
@@ -230,7 +230,7 @@ exports.MaterialsPopup = Montage.create(Component, {
230 { 230 {
231 value: function(theEvent) 231 value: function(theEvent)
232 { 232 {
233 var event = theEvent._event; 233 var event = theEvent._event;
234// if(typeof event.propertyValue === "object") 234// if(typeof event.propertyValue === "object")
235// { 235// {
236// console.log(event.propertyLabel + " changed to "); 236// console.log(event.propertyLabel + " changed to ");
@@ -241,70 +241,70 @@ exports.MaterialsPopup = Montage.create(Component, {
241// console.log(event.propertyLabel + " changed to " + event.propertyValue); 241// console.log(event.propertyLabel + " changed to " + event.propertyValue);
242// } 242// }
243 243
244 if (event.propertyLabel) 244 if (event.propertyLabel)
245 this.applyProperty( event.propertyLabel, event.propertyValue ); 245 this.applyProperty( event.propertyLabel, event.propertyValue );
246 } 246 }
247 }, 247 },
248 248
249 applyProperty: 249 applyProperty:
250 { 250 {
251 value: function( propLabel, propValue) 251 value: function( propLabel, propValue)
252 { 252 {
253 // find the property lable in the array 253 // find the property lable in the array
254 // This assumes no duplication in labels 254 // This assumes no duplication in labels
255 if (this._propLabels) 255 if (this._propLabels)
256 { 256 {
257 // the label cones through with a trailing ':'. remove that 257 // the label cones through with a trailing ':'. remove that
258 var ch = propLabel[ propLabel.length - 1]; 258 var ch = propLabel[ propLabel.length - 1];
259 if (ch == ':') 259 if (ch == ':')
260 propLabel = propLabel.substr(0, propLabel.length - 1);