diff options
Diffstat (limited to 'js/lib/rdge/materials/material.js')
-rwxr-xr-x | js/lib/rdge/materials/material.js | 69 |
1 files changed, 42 insertions, 27 deletions
diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index 65448c0c..1864b84e 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js | |||
@@ -177,6 +177,8 @@ var Material = function GLMaterial( world ) { | |||
177 | }; | 177 | }; |
178 | 178 | ||
179 | this.validateProperty = function( prop, value ) { | 179 | this.validateProperty = function( prop, value ) { |
180 | if(prop === "gradient") return true; | ||
181 | |||
180 | var rtnVal = false; | 182 | var rtnVal = false; |
181 | try | 183 | try |
182 | { | 184 | { |
@@ -240,33 +242,37 @@ var Material = function GLMaterial( world ) { | |||
240 | var material = this._materialNode; | 242 | var material = this._materialNode; |
241 | if (material) technique = material.shaderProgram[this.getTechniqueName()]; | 243 | if (material) technique = material.shaderProgram[this.getTechniqueName()]; |
242 | 244 | ||
243 | switch (this.getPropertyType(prop)) | 245 | if(prop === "gradient") { |
244 | { | 246 | this.setGradientData(value); |
245 | case "angle": | 247 | } else { |
246 | case "float": | 248 | switch (this.getPropertyType(prop)) |
247 | this._propValues[prop] = value; | 249 | { |
248 | if (technique) technique[prop].set( [value] ); | 250 | case "angle": |
249 | break; | 251 | case "float": |
250 | 252 | this._propValues[prop] = value; | |
251 | case "file": | 253 | if (technique) technique[prop].set( [value] ); |
252 | this._propValues[prop] = value.slice(); | 254 | break; |
253 | if (technique) | 255 | |
254 | { | 256 | case "file": |
255 | var glTex = new Texture( this.getWorld(), value ); | 257 | this._propValues[prop] = value.slice(); |
256 | this._glTextures[prop] = glTex; | 258 | if (technique) |
257 | glTex.render(); | 259 | { |
258 | var tex = glTex.getTexture(); | 260 | var glTex = new Texture( this.getWorld(), value ); |
259 | if (tex) technique[prop].set( tex ); | 261 | this._glTextures[prop] = glTex; |
260 | } | 262 | glTex.render(); |
261 | break; | 263 | var tex = glTex.getTexture(); |
262 | 264 | if (tex) technique[prop].set( tex ); | |
263 | case "color": | 265 | } |
264 | case "vector2d": | 266 | break; |
265 | case "vector3d": | 267 | |
266 | this._propValues[prop] = value.slice(); | 268 | case "color": |
267 | if (technique) technique[prop].set( value ); | 269 | case "vector2d": |
268 | break; | 270 | case "vector3d": |
269 | } | 271 | this._propValues[prop] = value.slice(); |
272 | if (technique) technique[prop].set( value ); | ||
273 | break; | ||
274 | } | ||
275 | } | ||
270 | }; | 276 | }; |
271 | 277 | ||
272 | this.setShaderValues = function() | 278 | this.setShaderValues = function() |
@@ -398,6 +404,15 @@ var Material = function GLMaterial( world ) { | |||
398 | return tex; | 404 | return tex; |
399 | }; | 405 | }; |
400 | 406 | ||
407 | this.gradientType = null; | ||
408 | |||
409 | this.getGradientData = function() { | ||
410 | return null; | ||
411 | }; | ||
412 | |||
413 | this.setGradientData = function() { | ||
414 | // override in linear-gradient-material and radial-gradient-material | ||
415 | }; | ||
401 | }; | 416 | }; |
402 | 417 | ||
403 | if (typeof exports === "object") { | 418 | if (typeof exports === "object") { |