aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/relief-tunnel-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/relief-tunnel-material.js')
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js44
1 files changed, 21 insertions, 23 deletions
diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js
index 06b0cf46..9404e359 100644
--- a/js/lib/rdge/materials/relief-tunnel-material.js
+++ b/js/lib/rdge/materials/relief-tunnel-material.js
@@ -6,44 +6,41 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
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 ReliefTunnelMaterial = function ReliefTunnelMaterial() { 11var ReliefTunnelMaterial = function ReliefTunnelMaterial()
12{
11 /////////////////////////////////////////////////////////////////////// 13 ///////////////////////////////////////////////////////////////////////
12 // Instance variables 14 // Instance variables
13 /////////////////////////////////////////////////////////////////////// 15 ///////////////////////////////////////////////////////////////////////
14 this._name = "ReliefTunnelMaterial"; 16 this._name = "ReliefTunnelMaterial";
15 this._shaderName = "reliefTunnel"; 17 this._shaderName = "reliefTunnel";
16 18
17 this._texMap = 'assets/images/rocky-normal.jpg'; 19 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
18 20
19 this._time = 0.0; 21 this._time = 0.0;
20 this._dTime = 0.01; 22 this._dTime = 0.01;
21 23
22 /////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////
23 // Properties 25 // Material Property Accessors
24 /////////////////////////////////////////////////////////////////////// 26 ///////////////////////////////////////////////////////////////////////
25 // all defined in parent PulseMaterial.js 27 var u_tex0_index = 0, u_speed_index = 1;
26 // load the local default value 28 this._propNames = ["u_tex0", "u_speed" ];
27 this._propValues[this._propNames[0]] = this._texMap.slice(0); 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
28 /////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////
29 // Methods 36 // Material Property Accessors
30 /////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////
31 // duplcate method requirde 38 this.isAnimated = function() { return true; };
32 this.dup = function (world) { 39 this.getShaderDef = function() { return reliefTunnelMaterialDef; };
33 // allocate a new uber material
34 var newMat = new ReliefTunnelMaterial();
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
44 return newMat;
45 };
46 40
41 ///////////////////////////////////////////////////////////////////////
42 // Methods
43 ///////////////////////////////////////////////////////////////////////
47 this.init = function (world) { 44 this.init = function (world) {
48 // save the world 45 // save the world
49 if (world) this.setWorld(world); 46 if (world) this.setWorld(world);
@@ -63,7 +60,7 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() {
63 } 60 }
64 61
65 // set the shader values in the shader 62 // set the shader values in the shader
66 this.updateTexture(); 63 this.setShaderValues();
67 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 64 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
68 this.update(0); 65 this.update(0);
69 }; 66 };
@@ -98,6 +95,7 @@ var reliefTunnelMaterialDef =
98 { 95 {
99 'u_tex0': { 'type': 'tex2d' }, 96 'u_tex0': { 'type': 'tex2d' },
100 'u_time': { 'type': 'float' }, 97 'u_time': { 'type': 'float' },
98 'u_speed': { 'type': 'float' },
101 'u_resolution': { 'type': 'vec2' } 99 'u_resolution': { 'type': 'vec2' }
102 }, 100 },
103 101