diff options
Diffstat (limited to 'js/lib/geom/geom-obj.js')
-rwxr-xr-x | js/lib/geom/geom-obj.js | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index f1aa9f8a..ce06498d 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js | |||
@@ -142,54 +142,56 @@ var GeomObj = function GLGeomObj() { | |||
142 | this.setMaterialColor = function(c, type) { | 142 | this.setMaterialColor = function(c, type) { |
143 | var i = 0, | 143 | var i = 0, |
144 | nMats = 0; | 144 | nMats = 0; |
145 | if(c.gradientMode) { | 145 | if(c) { |
146 | // Gradient support | 146 | if(c.gradientMode) { |
147 | if (this._materialArray && this._materialTypeArray) { | 147 | // Gradient support |
148 | nMats = this._materialArray.length; | 148 | if (this._materialArray && this._materialTypeArray) { |
149 | } | 149 | nMats = this._materialArray.length; |
150 | } | ||
150 | 151 | ||
151 | var stops = [], | 152 | var stops = [], |
152 | colors = c.color; | 153 | colors = c.color; |
153 | 154 | ||
154 | var len = colors.length; | 155 | var len = colors.length; |
155 | // TODO - Current shaders only support 4 color stops | 156 | // TODO - Current shaders only support 4 color stops |
156 | if(len > 4) { | 157 | if(len > 4) { |
157 | len = 4; | 158 | len = 4; |
158 | } | 159 | } |
159 | 160 | ||
160 | for(var n=0; n<len; n++) { | 161 | for(var n=0; n<len; n++) { |
161 | var position = colors[n].position/100; | 162 | var position = colors[n].position/100; |
162 | var cs = colors[n].value; | 163 | var cs = colors[n].value; |
163 | var stop = [cs.r/255, cs.g/255, cs.b/255, cs.a]; | 164 | var stop = [cs.r/255, cs.g/255, cs.b/255, cs.a]; |
164 | stops.push(stop); | 165 | stops.push(stop); |
165 | 166 | ||
166 | if (nMats === this._materialTypeArray.length) { | 167 | if (nMats === this._materialTypeArray.length) { |
167 | for (i=0; i<nMats; i++) { | 168 | for (i=0; i<nMats; i++) { |
168 | if (this._materialTypeArray[i] == type) { | 169 | if (this._materialTypeArray[i] == type) { |
169 | this._materialArray[i].setProperty( "color"+(n+1), stop.slice(0) ); | 170 | this._materialArray[i].setProperty( "color"+(n+1), stop.slice(0) ); |
170 | this._materialArray[i].setProperty( "colorStop"+(n+1), position ); | 171 | this._materialArray[i].setProperty( "colorStop"+(n+1), position ); |
172 | } | ||
171 | } | 173 | } |
172 | } | 174 | } |
173 | } | 175 | } |
174 | } | 176 | if (type === "fill") { |
175 | if (type === "fill") { | 177 | this._fillColor = c; |
176 | this._fillColor = c; | 178 | } else { |
177 | } else { | 179 | this._strokeColor = c; |
178 | this._strokeColor = c; | 180 | } |
179 | } | ||
180 | } else { | ||
181 | if (type === "fill") { | ||
182 | this._fillColor = c.slice(0); | ||
183 | } else { | 181 | } else { |
184 | this._strokeColor = c.slice(0); | 182 | if (type === "fill") { |
185 | } | 183 | this._fillColor = c.slice(0); |
184 | } else { | ||
185 | this._strokeColor = c.slice(0); | ||
186 | } | ||
186 | 187 | ||
187 | if (this._materialArray && this._materialTypeArray) { | 188 | if (this._materialArray && this._materialTypeArray) { |
188 | nMats = this._materialArray.length; | 189 | nMats = this._materialArray.length; |
189 | if (nMats === this._materialTypeArray.length) { | 190 | if (nMats === this._materialTypeArray.length) { |
190 | for (i=0; i<nMats; i++) { | 191 | for (i=0; i<nMats; i++) { |
191 | if (this._materialTypeArray[i] == type) { | 192 | if (this._materialTypeArray[i] == type) { |
192 | this._materialArray[i].setProperty( "color", c.slice(0) ); | 193 | this._materialArray[i].setProperty( "color", c.slice(0) ); |
194 | } | ||
193 | } | 195 | } |
194 | } | 196 | } |
195 | } | 197 | } |