aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/fly-material.js
diff options
context:
space:
mode:
authorhwc4872012-06-07 17:07:21 -0700
committerhwc4872012-06-07 17:07:21 -0700
commitdb2bb0ab5d2747f0d07878e3b8a7d2d10c755110 (patch)
tree7e3ca8a757aa0c28ccdbef2e773f54a5cfc13a98 /js/lib/rdge/materials/fly-material.js
parent6c994c4b90023cecf4fd0caafb404b859fe28f54 (diff)
downloadninja-db2bb0ab5d2747f0d07878e3b8a7d2d10c755110.tar.gz
Material cleanup
Diffstat (limited to 'js/lib/rdge/materials/fly-material.js')
-rw-r--r--js/lib/rdge/materials/fly-material.js38
1 files changed, 15 insertions, 23 deletions
diff --git a/js/lib/rdge/materials/fly-material.js b/js/lib/rdge/materials/fly-material.js
index 5e14f3af..12e18f7f 100644
--- a/js/lib/rdge/materials/fly-material.js
+++ b/js/lib/rdge/materials/fly-material.js
@@ -14,7 +14,7 @@ var FlyMaterial = function FlyMaterial() {
14 this._name = "FlyMaterial"; 14 this._name = "FlyMaterial";
15 this._shaderName = "fly"; 15 this._shaderName = "fly";
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,28 +24,24 @@ var FlyMaterial = function FlyMaterial() {
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, u_speed_index = 1;
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[u_tex0_index]] = this._defaultTexMap.slice(0);
33 this._propValues[this._propNames[u_speed_index]] = 1.0;
34
35 ///////////////////////////////////////////////////////////////////////
36 // Material Property Accessors
37 ///////////////////////////////////////////////////////////////////////
38 this.isAnimated = function() { return true; };
39 this.getShaderDef = function() { return flyMaterialDef; }
28 40
29 /////////////////////////////////////////////////////////////////////// 41 ///////////////////////////////////////////////////////////////////////
30 // Methods 42 // Methods
31 /////////////////////////////////////////////////////////////////////// 43 ///////////////////////////////////////////////////////////////////////
32 // duplcate method requirde 44 // duplcate method requirde
33 this.dup = function( world )
34 {
35 // get the current values;
36 var propNames = [], propValues = [], propTypes = [], propLabels = [];
37 this.getAllProperties(propNames, propValues, propTypes, propLabels);
38
39 // allocate a new material
40 var newMat = new FlyMaterial();
41
42 // copy over the current values;
43 var n = propNames.length;
44 for (var i = 0; i < n; i++)
45 newMat.setProperty(propNames[i], propValues[i]);
46
47 return newMat;
48 };
49 45
50 this.init = function( world ) { 46 this.init = function( world ) {
51 // save the world 47 // save the world
@@ -65,12 +61,8 @@ var FlyMaterial = function FlyMaterial() {
65 this._shader['default'].u_time.set( [this._time] ); 61 this._shader['default'].u_time.set( [this._time] );
66 } 62 }
67 63
68 // set up the texture
69 var texMapName = this._propValues[this._propNames[0]];
70 this._glTex = new Texture( world, texMapName );
71
72 // set the shader values in the shader 64 // set the shader values in the shader
73 this.updateTexture(); 65 this.setShaderValues();
74 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); 66 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
75 this.update( 0 ); 67 this.update( 0 );
76 }; 68 };