aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/square-tunnel-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/square-tunnel-material.js')
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js40
1 files changed, 18 insertions, 22 deletions
diff --git a/js/lib/rdge/materials/square-tunnel-material.js b/js/lib/rdge/materials/square-tunnel-material.js
index 73df4073..bffae254 100644
--- a/js/lib/rdge/materials/square-tunnel-material.js
+++ b/js/lib/rdge/materials/square-tunnel-material.js
@@ -5,6 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
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 SquareTunnelMaterial = function SquareTunnelMaterial() { 10var SquareTunnelMaterial = function SquareTunnelMaterial() {
10 /////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////
@@ -13,37 +14,31 @@ var SquareTunnelMaterial = function SquareTunnelMaterial() {
13 this._name = "SquareTunnelMaterial"; 14 this._name = "SquareTunnelMaterial";
14 this._shaderName = "squareTunnel"; 15 this._shaderName = "squareTunnel";
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;
20 21
21 /////////////////////////////////////////////////////////////////////// 22 ///////////////////////////////////////////////////////////////////////
22 // Properties 23 // Material Property Accessors
23 /////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////
24 // all defined in parent PulseMaterial.js 25 var u_tex0_index = 0, u_speed_index = 1;
25 // load the local default value 26 this._propNames = ["u_tex0", "u_speed" ];
26 this._propValues[this._propNames[0]] = this._texMap.slice(0); 27 this._propLabels = ["Texture map", "Speed" ];
28 this._propTypes = ["file", "float" ];
29 this._propValues = [];
30 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
31 this._propValues[this._propNames[u_speed_index]] = 1.0;
27 32
28 /////////////////////////////////////////////////////////////////////// 33 ///////////////////////////////////////////////////////////////////////
29 // Methods 34 // Material Property Accessors
30 /////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////
31 // duplcate method requirde 36 this.isAnimated = function() { return true; };
32 this.dup = function (world) { 37 this.getShaderDef = function() { return squareTunnelMaterialDef; };
33 // allocate a new uber material
34 var newMat = new SquareTunnelMaterial();
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 38
39 ///////////////////////////////////////////////////////////////////////
40 // Methods
41 ///////////////////////////////////////////////////////////////////////
47 this.init = function (world) { 42 this.init = function (world) {
48 // save the world 43 // save the world
49 if (world) this.setWorld(world); 44 if (world) this.setWorld(world);
@@ -63,7 +58,7 @@ var SquareTunnelMaterial = function SquareTunnelMaterial() {
63 } 58 }
64 59
65 // set the shader values in the shader 60 // set the shader values in the shader
66 this.updateTexture(); 61 this.setShaderValues();
67 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 62 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
68 this.update(0); 63 this.update(0);
69 }; 64 };
@@ -98,6 +93,7 @@ var squareTunnelMaterialDef =
98 { 93 {
99 'u_tex0': { 'type': 'tex2d' }, 94 'u_tex0': { 'type': 'tex2d' },
100 'u_time': { 'type': 'float' }, 95 'u_time': { 'type': 'float' },
96 'u_speed': { 'type': 'float' },
101 'u_resolution': { 'type': 'vec2' } 97 'u_resolution': { 'type': 'vec2' }
102 }, 98 },
103 99