aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/fly-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/fly-material.js')
-rw-r--r--js/lib/rdge/materials/fly-material.js33
1 files changed, 17 insertions, 16 deletions
diff --git a/js/lib/rdge/materials/fly-material.js b/js/lib/rdge/materials/fly-material.js
index 37bef66a..7b880a2e 100644
--- a/js/lib/rdge/materials/fly-material.js
+++ b/js/lib/rdge/materials/fly-material.js
@@ -5,6 +5,7 @@
5 </copyright> */ 5 </copyright> */
6 6
7var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; 7var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
8var Texture = require("js/lib/rdge/texture").Texture;
8 9
9var FlyMaterial = function FlyMaterial() { 10var FlyMaterial = function FlyMaterial() {
10 /////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////
@@ -13,7 +14,7 @@ var FlyMaterial = function FlyMaterial() {
13 this._name = "FlyMaterial"; 14 this._name = "FlyMaterial";
14 this._shaderName = "fly"; 15 this._shaderName = "fly";
15 16
16 this._texMap = 'assets/images/rocky-normal.jpg'; 17 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
17 18
18 this._time = 0.0; 19 this._time = 0.0;
19 this._dTime = 0.01; 20 this._dTime = 0.01;
@@ -23,25 +24,24 @@ var FlyMaterial = function FlyMaterial() {
23 /////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////
24 // all defined in parent PulseMaterial.js 25 // all defined in parent PulseMaterial.js
25 // load the local default value 26 // load the local default value
26 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; };
27 40
28 /////////////////////////////////////////////////////////////////////// 41 ///////////////////////////////////////////////////////////////////////
29 // Methods 42 // Methods
30 /////////////////////////////////////////////////////////////////////// 43 ///////////////////////////////////////////////////////////////////////
31 // duplcate method requirde 44 // duplcate method requirde
32 this.dup = function( world ) {
33 // allocate a new uber material
34 var newMat = new FlyMaterial();
35
36 // copy over the current values;
37 var propNames = [], propValues = [], propTypes = [], propLabels = [];
38 this.getAllProperties( propNames, propValues, propTypes, propLabels);
39 var n = propNames.length;
40 for (var i=0; i<n; i++)
41 newMat.setProperty( propNames[i], propValues[i] );
42
43 return newMat;
44 };
45 45
46 this.init = function( world ) { 46 this.init = function( world ) {
47 // save the world 47 // save the world
@@ -62,7 +62,7 @@ var FlyMaterial = function FlyMaterial() {
62 } 62 }
63 63
64 // set the shader values in the shader 64 // set the shader values in the shader
65 this.updateTexture(); 65 this.setShaderValues();
66 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); 66 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
67 this.update( 0 ); 67 this.update( 0 );
68 }; 68 };
@@ -98,6 +98,7 @@ var flyMaterialDef =
98 { 98 {
99 'u_tex0': { 'type' : 'tex2d' }, 99 'u_tex0': { 'type' : 'tex2d' },
100 'u_time' : { 'type' : 'float' }, 100 'u_time' : { 'type' : 'float' },
101 'u_speed' : { 'type' : 'float' },
101 'u_resolution' : { 'type' : 'vec2' }, 102 'u_resolution' : { 'type' : 'vec2' },
102 }, 103 },
103 104