diff options
Diffstat (limited to 'js/lib/rdge/materials/material.js')
-rwxr-xr-x | js/lib/rdge/materials/material.js | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index 7e1f2ec5..6cfc4eb4 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js | |||
@@ -56,16 +56,12 @@ var Material = function GLMaterial( world ) { | |||
56 | // vertex deformation variables | 56 | // vertex deformation variables |
57 | this._hasVertexDeformation = false; | 57 | this._hasVertexDeformation = false; |
58 | this._vertexDeformationRange = [0, 0, 1, 1]; // (xMin, yMin, xMax, yMax) | 58 | this._vertexDeformationRange = [0, 0, 1, 1]; // (xMin, yMin, xMax, yMax) |
59 | this._vertexDeformationTolerance = 0.1; | 59 | this._vertexDeformationTolerance = 0.02; |
60 | 60 | ||
61 | // RDGE variables | 61 | // RDGE variables |
62 | this._shader = null; | 62 | this._shader = null; |
63 | this._materialNode = null; | 63 | this._materialNode = null; |
64 | 64 | ||
65 | // vertex deformation variables | ||
66 | this._hasVertexDeformation = false; | ||
67 | this._vertexDeformationRange = [0, 0, 1, 1]; // (xMin, yMin, xMax, yMax) | ||
68 | this._vertexDeformationTolerance = 0.02; | ||
69 | 65 | ||
70 | /////////////////////////////////////////////////////////////////////// | 66 | /////////////////////////////////////////////////////////////////////// |
71 | // Property Accessors | 67 | // Property Accessors |
@@ -201,6 +197,8 @@ var Material = function GLMaterial( world ) { | |||
201 | }; | 197 | }; |
202 | 198 | ||
203 | this.validateProperty = function( prop, value ) { | 199 | this.validateProperty = function( prop, value ) { |
200 | if(prop === "gradient") return true; | ||
201 | |||
204 | var rtnVal = false; | 202 | var rtnVal = false; |
205 | try | 203 | try |
206 | { | 204 | { |
@@ -264,6 +262,9 @@ var Material = function GLMaterial( world ) { | |||
264 | var material = this._materialNode; | 262 | var material = this._materialNode; |
265 | if (material) technique = material.shaderProgram[this.getTechniqueName()]; | 263 | if (material) technique = material.shaderProgram[this.getTechniqueName()]; |
266 | 264 | ||
265 | if(prop === "gradient") { | ||
266 | this.setGradientData(value); | ||
267 | } else { | ||
267 | switch (this.getPropertyType(prop)) | 268 | switch (this.getPropertyType(prop)) |
268 | { | 269 | { |
269 | case "angle": | 270 | case "angle": |
@@ -291,6 +292,7 @@ var Material = function GLMaterial( world ) { | |||
291 | if (technique) technique[prop].set( value ); | 292 | if (technique) technique[prop].set( value ); |
292 | break; | 293 | break; |
293 | } | 294 | } |
295 | } | ||
294 | }; | 296 | }; |
295 | 297 | ||
296 | this.setShaderValues = function() | 298 | this.setShaderValues = function() |
@@ -390,6 +392,10 @@ var Material = function GLMaterial( world ) { | |||
390 | throw new Error( "Material.init() must be overridden by subclass" ); | 392 | throw new Error( "Material.init() must be overridden by subclass" ); |
391 | }; | 393 | }; |
392 | 394 | ||
395 | this.resetToDefault = function() { | ||
396 | // materials should override this functinon | ||
397 | }; | ||
398 | |||
393 | this.update = function( time ) { | 399 | this.update = function( time ) { |
394 | // animated materials should implement the update method | 400 | // animated materials should implement the update method |
395 | }; | 401 | }; |
@@ -398,6 +404,10 @@ var Material = function GLMaterial( world ) { | |||
398 | // some materials need to preserve an aspect ratio - or someting else. | 404 | // some materials need to preserve an aspect ratio - or someting else. |
399 | }; | 405 | }; |
400 | 406 | ||
407 | this.fitToPrimitiveArray = function( primArray ) { | ||
408 | // some materials need to preserve an aspect ratio - or someting else. | ||
409 | }; | ||
410 | |||
401 | this.registerTexture = function( texture ) { | 411 | this.registerTexture = function( texture ) { |
402 | // the world needs to know about the texture map | 412 | // the world needs to know about the texture map |
403 | var world = this.getWorld(); | 413 | var world = this.getWorld(); |
@@ -422,6 +432,15 @@ var Material = function GLMaterial( world ) { | |||
422 | return tex; | 432 | return tex; |
423 | }; | 433 | }; |
424 | 434 | ||
435 | this.gradientType = null; | ||
436 | |||
437 | this.getGradientData = function() { | ||
438 | return null; | ||
439 | }; | ||
440 | |||
441 | this.setGradientData = function() { | ||
442 | // override in linear-gradient-material and radial-gradient-material | ||
443 | }; | ||
425 | }; | 444 | }; |
426 | 445 | ||
427 | if (typeof exports === "object") { | 446 | if (typeof exports === "object") { |