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 | 842 |
1 files changed, 421 insertions, 421 deletions
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js index 7c5493c6..cecb0a71 100755 --- a/js/panels/Materials/materials-popup.reel/materials-popup.js +++ b/js/panels/Materials/materials-popup.reel/materials-popup.js | |||
@@ -51,26 +51,26 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
51 | serializable: true | 51 | serializable: true |
52 | }, | 52 | }, |
53 | 53 | ||
54 | // Material Properties | 54 | // Material Properties |
55 | _materialName: { | 55 | _materialName: { |
56 | enumerable: true, | 56 | enumerable: true, |
57 | value: "" | 57 | value: "" |
58 | }, | 58 | }, |
59 | 59 | ||
60 | _useSelection: { value: false, enumerable: true }, | 60 | _useSelection: { value: false, enumerable: true }, |
61 | _whichMaterial: { value: "fill", enumerable: true }, | 61 | _whichMaterial: { value: "fill", enumerable: true }, |
62 | _originalValues: {value: null, enumerable: true }, | 62 | _originalValues: {value: null, enumerable: true }, |
63 | 63 | ||
64 | captureAction: { | 64 | captureAction: { |
65 | value:function(event) { | 65 | value:function(event) { |
66 | switch(event._currentTarget.label) | 66 | switch(event._currentTarget.label) |
67 | { | 67 | { |
68 | case "Cancel": | 68 | case "Cancel": |
69 | console.log("Cancel material edit"); | 69 | console.log("Cancel material edit"); |
70 | this.revertToOriginalValues(); | 70 | this.revertToOriginalValues(); |
71 | break; | 71 | break; |
72 | case "OK": | 72 | case "OK": |
73 | console.log("Committing material with the following values:"); | 73 | console.log("Committing material with the following values:"); |
74 | for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++) | 74 | for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++) |
75 | { | 75 | { |
76 | var childControl = this.materialsProperties.childComponents[i]; | 76 | var childControl = this.materialsProperties.childComponents[i]; |
@@ -88,53 +88,53 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
88 | console.log("--------------"); | 88 | console.log("--------------"); |
89 | 89 | ||
90 | } | 90 | } |
91 | break; | 91 | break; |
92 | } | 92 | } |
93 | 93 | ||
94 | // Notify Materials Library to close popup | 94 | // Notify Materials Library to close popup |
95 | NJevent("hideMaterialPopup"); | 95 | NJevent("hideMaterialPopup"); |
96 | } | 96 | } |
97 | }, | 97 | }, |
98 | 98 | ||
99 | revertToOriginalValues: | 99 | revertToOriginalValues: |
100 | { | 100 | { |
101 | value: function() | 101 | value: function() |
102 | { | 102 | { |
103 | if (this._originalValues) | 103 | if (this._originalValues) |
104 | { | 104 | { |
105 | this._material.importJSON( this._originalValues ); | 105 | this._material.importJSON( this._originalValues ); |
106 | 106 | ||
107 | if (this._useSelection) | 107 | if (this._useSelection) |
108 | { | 108 | { |
109 | var selection = this.application.ninja.selectedElements; | 109 | var selection = this.application.ninja.selectedElements; |
110 | if (selection && (selection.length > 0)) | 110 | if (selection && (selection.length > 0)) |
111 | { | 111 | { |
112 | var nObjs = selection.length; | 112 | var nObjs = selection.length; |
113 | for (var iObj=0; iObj<nObjs; iObj++) | 113 | for (var iObj=0; iObj<nObjs; iObj++) |
114 | { | 114 | { |
115 | var canvas = selection[iObj]; | 115 | var canvas = selection[iObj]; |
116 | var obj; | 116 | var obj; |
117 | if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj; | 117 | if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj; |
118 | if (obj) | 118 | if (obj) |
119 | { | 119 | { |
120 | var matArray = obj._materialArray; | 120 | var matArray = obj._materialArray; |
121 | var matTypeArray = obj._materialTypeArray; | 121 | var matTypeArray = obj._materialTypeArray; |
122 | var nMats = matArray.length; | 122 | var nMats = matArray.length; |
123 | for (var iMat=0; iMat<nMats; iMat++) | 123 | for (var iMat=0; iMat<nMats; iMat++) |
124 | { | 124 | { |
125 | if (matTypeArray[iMat] === this._whichMaterial) | 125 | if (matTypeArray[iMat] === this._whichMaterial) |
126 | matArray[iMat].importJSON( this._originalValues ); | 126 | matArray[iMat].importJSON( this._originalValues ); |
127 | } | 127 | } |
128 | var world = obj.getWorld(); | 128 | var world = obj.getWorld(); |
129 | if (world) | 129 | if (world) |
130 | world.restartRenderLoop(); | 130 | world.restartRenderLoop(); |
131 | } | 131 | } |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | } | 136 | } |
137 | }, | 137 | }, |
138 | 138 | ||
139 | updatePreview: | 139 | updatePreview: |
140 | { | 140 | { |
@@ -165,8 +165,8 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
165 | console.log(event.propertyLabel + " changing to " + event.propertyValue); | 165 | console.log(event.propertyLabel + " changing to " + event.propertyValue); |
166 | } | 166 | } |
167 | 167 | ||
168 | if (event.propertyLabel && event.propertyValue) | 168 | if (event.propertyLabel && event.propertyValue) |
169 | this.applyProperty( event.propertyLabel, event.propertyValue ); | 169 | this.applyProperty( event.propertyLabel, event.propertyValue ); |
170 | } | 170 | } |
171 | }, | 171 | }, |
172 | 172 | ||
@@ -174,7 +174,7 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
174 | { | 174 | { |
175 | value: function(theEvent) | 175 | value: function(theEvent) |
176 | { | 176 | { |
177 | var event = theEvent._event; | 177 | var event = theEvent._event; |
178 | if(typeof event.propertyValue === "object") | 178 | if(typeof event.propertyValue === "object") |
179 | { | 179 | { |
180 | console.log(event.propertyLabel + " changed to "); | 180 | console.log(event.propertyLabel + " changed to "); |
@@ -185,316 +185,316 @@ exports.MaterialsPopup = Montage.create(Component, { | |||
185 | console.log(event.propertyLabel + " changed to " + event.propertyValue); | 185 | console.log(event.propertyLabel + " changed to " + event.propertyValue); |
186 | } | 186 | } |
187 | 187 | ||
188 | if (event.propertyLabel) | 188 | if (event.propertyLabel) |
189 | this.applyProperty( event.propertyLabel, event.propertyValue ); | 189 | this.applyProperty( event.propertyLabel, event.propertyValue ); |
190 | } | 190 | } |
191 | }, | 191 | }, |
192 | 192 | ||
193 | applyProperty: | 193 | applyProperty: |
194 | { | 194 | { |
195 | value: function( propLabel, propValue) | 195 | value: function( propLabel, propValue) |
196 | { | 196 | { |
197 | // find the property lable in the array | 197 | // find the property lable in the array |
198 | // This assumes no duplication in labels | 198 | // This assumes no duplication in labels |
199 | if (this._propLabels) | 199 | if (this._propLabels) |
200 | { | 200 | { |
201 | // the label cones through with a trailing ':'. remove that | 201 | // the label cones through with a trailing ':'. remove that |
202 | var ch = propLabel[ propLabel.length - 1]; | 202 | var ch = propLabel[ propLabel.length - 1]; |
203 | if (ch == ':') | 203 | if (ch == ':') |
204 | propLabel = propLabel.substr(0, propLabel.length - 1); | 204 | propLabel = propLabel.substr(0, propLabel.length - 1); |
205 | 205 | ||
206 | var index; | 206 | var index; |
207 | var nProps = this._propLabels.length; | 207 | var nProps = this._propLabels.length; |
208 | for (var i=0; i<nProps; i++) | 208 | for (var i=0; i<nProps; i++) |
209 | { | 209 | { |
210 | if (this._propLabels[i] == propLabel) | 210 | if (this._propLabels[i] == propLabel) |
211 | { | 211 | { |
212 | index = i; | 212 | index = i; |
213 | break; |