aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/star-material.js
diff options
context:
space:
mode:
authorhwc4872012-06-12 10:28:26 -0700
committerhwc4872012-06-12 10:28:26 -0700
commitd4ca478ad313c6c20834e410ba14ad3a5e7b20bf (patch)
tree28e44c5ab1b2f9dbfd32aedba51402ac2d26a0ff /js/lib/rdge/materials/star-material.js
parentdb2bb0ab5d2747f0d07878e3b8a7d2d10c755110 (diff)
downloadninja-d4ca478ad313c6c20834e410ba14ad3a5e7b20bf.tar.gz
Material cleanup & bug fixes.
Diffstat (limited to 'js/lib/rdge/materials/star-material.js')
-rw-r--r--js/lib/rdge/materials/star-material.js44
1 files changed, 20 insertions, 24 deletions
diff --git a/js/lib/rdge/materials/star-material.js b/js/lib/rdge/materials/star-material.js
index 000d44b0..9f94b8c3 100644
--- a/js/lib/rdge/materials/star-material.js
+++ b/js/lib/rdge/materials/star-material.js
@@ -14,37 +14,32 @@ var StarMaterial = function StarMaterial() {
14 this._name = "StarMaterial"; 14 this._name = "StarMaterial";
15 this._shaderName = "star"; 15 this._shaderName = "star";
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;
21 21
22 /////////////////////////////////////////////////////////////////////// 22 ///////////////////////////////////////////////////////////////////////
23 // Properties 23 // Property Accessors
24 /////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////
25 // all defined in parent PulseMaterial.js 25 this.isAnimated = function() { return true; };
26 // load the local default value 26 this.getShaderDef = function() { return starMaterialDef; }
27 this._propValues[this._propNames[0]] = this._texMap.slice(0); 27
28 ///////////////////////////////////////////////////////////////////////
29 // Material Property Accessors
30 ///////////////////////////////////////////////////////////////////////
31 var u_tex0_index = 0, u_speed_index = 1;
32 this._propNames = ["u_tex0", "u_speed" ];
33 this._propLabels = ["Texture map", "Speed" ];
34 this._propTypes = ["file", "float" ];
35 this._propValues = [];
36 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
37 this._propValues[this._propNames[u_speed_index]] = 1.0;
38 ///////////////////////////////////////////////////////////////////////
28 39
29 /////////////////////////////////////////////////////////////////////// 40 ///////////////////////////////////////////////////////////////////////
30 // Methods 41 // Methods
31 /////////////////////////////////////////////////////////////////////// 42 ///////////////////////////////////////////////////////////////////////
32 // duplcate method requirde
33 this.dup = function () {
34 // get the current values;
35 var propNames = [], propValues = [], propTypes = [], propLabels = [];
36 this.getAllProperties(propNames, propValues, propTypes, propLabels);
37
38 // allocate a new material
39 var newMat = new StarMaterial();
40
41 // copy over the current values;
42 var n = propNames.length;
43 for (var i = 0; i < n; i++)
44 newMat.setProperty(propNames[i], propValues[i]);
45
46 return newMat;
47 };
48 43
49 this.init = function (world) { 44 this.init = function (world) {
50 // save the world 45 // save the world
@@ -69,7 +64,7 @@ var StarMaterial = function StarMaterial() {
69 this._glTex = new Texture( world, texMapName ); 64 this._glTex = new Texture( world, texMapName );
70 65
71 // set the shader values in the shader 66 // set the shader values in the shader
72 this.updateTexture(); 67 this.setShaderValues();
73 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 68 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
74 this.update(0); 69 this.update(0);
75 }; 70 };
@@ -104,6 +99,7 @@ var starMaterialDef =
104 { 99 {
105 'u_tex0': { 'type': 'tex2d' }, 100 'u_tex0': { 'type': 'tex2d' },
106 'u_time': { 'type': 'float' }, 101 'u_time': { 'type': 'float' },
102 'u_speed': { 'type': 'float' },
107 'u_resolution': { 'type': 'vec2' } 103 'u_resolution': { 'type': 'vec2' }
108 }, 104 },
109 105