aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/deform-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/deform-material.js')
-rw-r--r--js/lib/rdge/materials/deform-material.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js
index 70742c77..91202b24 100644
--- a/js/lib/rdge/materials/deform-material.js
+++ b/js/lib/rdge/materials/deform-material.js
@@ -14,7 +14,7 @@ var DeformMaterial = function DeformMaterial() {
14 this._name = "DeformMaterial"; 14 this._name = "DeformMaterial";
15 this._shaderName = "deform"; 15 this._shaderName = "deform";
16 16
17 this._texMap = 'assets/images/rocky-normal.jpg'; 17 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
18 18
19 this._time = 0.0; 19 this._time = 0.0;
20 this._dTime = 0.01; 20 this._dTime = 0.01;
@@ -24,11 +24,21 @@ var DeformMaterial = function DeformMaterial() {
24 /////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////
25 // all defined in parent PulseMaterial.js 25 // all defined in parent PulseMaterial.js
26 // load the local default value 26 // load the local default value
27 this._propValues[this._propNames[0]] = this._texMap.slice(0); 27 var u_tex0_index = 0;
28 this._propNames = ["u_tex0", "u_speed" ];
29 this._propLabels = ["Texture map", "Speed" ];
30 this._propTypes = ["file", "float" ];
31 this._propValues = [];
32 this._propValues[this._propNames[0]] = this._defaultTexMap.slice(0);
33 this._propValues[this._propNames[1]] = 1.0;
34
35 this._propValues[ this._propNames[ u_tex0_index] ] = this._defaultTexMap.slice(0);
28 36
29 /////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////
30 // Material Property Accessors 38 // Material Property Accessors
31 /////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////
40 this.isAnimated = function() { return true; };
41 this.getShaderDef = function() { return pulseMaterialDef; }
32 42
33 /////////////////////////////////////////////////////////////////////// 43 ///////////////////////////////////////////////////////////////////////
34 44
@@ -56,12 +66,8 @@ var DeformMaterial = function DeformMaterial() {
56 this._shader['default'].u_time.set([this._time]); 66 this._shader['default'].u_time.set([this._time]);
57 } 67 }
58 68
59 // set up the texture
60 var texMapName = this._propValues[this._propNames[0]];
61 this._glTex = new Texture( world, texMapName );
62
63 // set the shader values in the shader 69 // set the shader values in the shader
64 this.updateTexture(); 70 this.setShaderValues();
65 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 71 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
66 this.update(0); 72 this.update(0);
67 }; 73 };
@@ -96,6 +102,7 @@ var deformMaterialDef =
96 { 102 {
97 'u_tex0': { 'type' : 'tex2d' }, 103 'u_tex0': { 'type' : 'tex2d' },
98 'u_time' : { 'type' : 'float' }, 104 'u_time' : { 'type' : 'float' },
105 'u_speed' : { 'type' : 'float' },
99 'u_resolution' : { 'type' : 'vec2' } 106 'u_resolution' : { 'type' : 'vec2' }
100 }, 107 },
101 108