aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/tunnel-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/tunnel-material.js')
-rw-r--r--js/lib/rdge/materials/tunnel-material.js40
1 files changed, 18 insertions, 22 deletions
diff --git a/js/lib/rdge/materials/tunnel-material.js b/js/lib/rdge/materials/tunnel-material.js
index 83bf9021..b833a251 100644
--- a/js/lib/rdge/materials/tunnel-material.js
+++ b/js/lib/rdge/materials/tunnel-material.js
@@ -6,6 +6,7 @@
6 6
7 7
8var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; 8var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
9var Texture = require("js/lib/rdge/texture").Texture;
9 10
10var TunnelMaterial = function TunnelMaterial() { 11var TunnelMaterial = function TunnelMaterial() {
11 /////////////////////////////////////////////////////////////////////// 12 ///////////////////////////////////////////////////////////////////////
@@ -14,37 +15,31 @@ var TunnelMaterial = function TunnelMaterial() {
14 this._name = "TunnelMaterial"; 15 this._name = "TunnelMaterial";
15 this._shaderName = "tunnel"; 16 this._shaderName = "tunnel";
16 17
17 this._texMap = 'assets/images/rocky-normal.jpg'; 18 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
18 19
19 this._time = 0.0; 20 this._time = 0.0;
20 this._dTime = 0.001; 21 this._dTime = 0.001;
21 22
22 /////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////
23 // Properties 24 // Material Property Accessors
24 /////////////////////////////////////////////////////////////////////// 25 ///////////////////////////////////////////////////////////////////////
25 // all defined in parent PulseMaterial.js 26 var u_tex0_index = 0, u_speed_index = 1;
26 // load the local default value 27 this._propNames = ["u_tex0", "u_speed" ];
27 this._propValues[this._propNames[0]] = this._texMap.slice(0); 28 this._propLabels = ["Texture map", "Speed" ];
29 this._propTypes = ["file", "float" ];
30 this._propValues = [];
31 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
32 this._propValues[this._propNames[u_speed_index]] = 1.0;
28 33
29 /////////////////////////////////////////////////////////////////////// 34 ///////////////////////////////////////////////////////////////////////
30 // Methods 35 // Material Property Accessors
31 /////////////////////////////////////////////////////////////////////// 36 ///////////////////////////////////////////////////////////////////////
32 // duplcate method requirde 37 this.isAnimated = function() { return true; };
33 this.dup = function (world) { 38 this.getShaderDef = function() { return tunnelMaterialDef; };
34 // allocate a new uber material
35 var newMat = new TunnelMaterial();
36
37 // copy over the current values;
38 var propNames = [], propValues = [], propTypes = [], propLabels = [];
39 this.getAllProperties(propNames, propValues, propTypes, propLabels);
40 var n = propNames.length;
41 for (var i = 0; i < n; i++) {
42 newMat.setProperty(propNames[i], propValues[i]);
43 }
44
45 return newMat;
46 };
47 39
40 ///////////////////////////////////////////////////////////////////////
41 // Methods
42 ///////////////////////////////////////////////////////////////////////
48 this.init = function (world) { 43 this.init = function (world) {
49 // save the world 44 // save the world
50 if (world) this.setWorld(world); 45 if (world) this.setWorld(world);
@@ -64,7 +59,7 @@ var TunnelMaterial = function TunnelMaterial() {
64 } 59 }
65 60
66 // set the shader values in the shader 61 // set the shader values in the shader
67 this.updateTexture(); 62 this.setShaderValues();
68 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 63 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
69 this.update(0); 64 this.update(0);
70 }; 65 };
@@ -99,6 +94,7 @@ var tunnelMaterialDef =
99 { 94 {
100 'u_tex0': { 'type' : 'tex2d' }, 95 'u_tex0': { 'type' : 'tex2d' },
101 'u_time' : { 'type' : 'float' }, 96 'u_time' : { 'type' : 'float' },
97 'u_speed' : { 'type' : 'float' },
102 'u_resolution' : { 'type' : 'vec2' } 98 'u_resolution' : { 'type' : 'vec2' }
103 }, 99 },
104 100