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.js100
1 files changed, 55 insertions, 45 deletions
diff --git a/js/lib/rdge/materials/tunnel-material.js b/js/lib/rdge/materials/tunnel-material.js
index 0a96e23e..d197ce7f 100644
--- a/js/lib/rdge/materials/tunnel-material.js
+++ b/js/lib/rdge/materials/tunnel-material.js
@@ -50,19 +50,19 @@ var TunnelMaterial = function TunnelMaterial() {
50 /////////////////////////////////////////////////////////////////////// 50 ///////////////////////////////////////////////////////////////////////
51 // Material Property Accessors 51 // Material Property Accessors
52 /////////////////////////////////////////////////////////////////////// 52 ///////////////////////////////////////////////////////////////////////
53 var u_tex0_index = 0, u_speed_index = 1; 53 var u_tex0_index = 0, u_speed_index = 1;
54 this._propNames = ["u_tex0", "u_speed" ]; 54 this._propNames = ["u_tex0", "u_speed" ];
55 this._propLabels = ["Texture map", "Speed" ]; 55 this._propLabels = ["Texture map", "Speed" ];
56 this._propTypes = ["file", "float" ]; 56 this._propTypes = ["file", "float" ];
57 this._propValues = []; 57 this._propValues = [];
58 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0); 58 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
59 this._propValues[this._propNames[u_speed_index]] = 1.0; 59 this._propValues[this._propNames[u_speed_index]] = 1.0;
60 60
61 /////////////////////////////////////////////////////////////////////// 61 ///////////////////////////////////////////////////////////////////////
62 // Material Property Accessors 62 // Material Property Accessors
63 /////////////////////////////////////////////////////////////////////// 63 ///////////////////////////////////////////////////////////////////////
64 this.isAnimated = function() { return true; }; 64 this.isAnimated = function() { return true; };
65 this.getShaderDef = function() { return tunnelMaterialDef; }; 65 this.getShaderDef = function() { return tunnelMaterialDef; };
66 66
67 /////////////////////////////////////////////////////////////////////// 67 ///////////////////////////////////////////////////////////////////////
68 // Methods 68 // Methods
@@ -90,50 +90,60 @@ var TunnelMaterial = function TunnelMaterial() {
90 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 90 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
91 this.update(0); 91 this.update(0);
92 }; 92 };
93
94 this.resetToDefault = function()
95 {
96 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
97 this._propValues[this._propNames[u_speed_index]] = 1.0;
98
99 var nProps = this._propNames.length;
100 for (var i=0; i<nProps; i++)
101 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
102 };
93}; 103};
94 104
95/////////////////////////////////////////////////////////////////////////////////////// 105///////////////////////////////////////////////////////////////////////////////////////
96// RDGE shader 106// RDGE shader
97 107
98// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 108// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
99var tunnelMaterialDef = 109var tunnelMaterialDef =
100{'shaders': 110{'shaders':
101 { 111 {
102 'defaultVShader':"assets/shaders/Basic.vert.glsl", 112 'defaultVShader':"assets/shaders/Basic.vert.glsl",
103 'defaultFShader':"assets/shaders/Tunnel.frag.glsl" 113 'defaultFShader':"assets/shaders/Tunnel.frag.glsl"
104 }, 114 },
105 'techniques': 115 'techniques':
106 { 116 {
107 'default': 117 'default':
108 [ 118 [
109 { 119 {
110 'vshader' : 'defaultVShader', 120 'vshader' : 'defaultVShader',
111 'fshader' : 'defaultFShader', 121 'fshader' : 'defaultFShader',
112 // attributes 122 // attributes
113 'attributes' : 123 'attributes' :
114 { 124 {
115 'vert' : { 'type' : 'vec3' }, 125 'vert' : { 'type' : 'vec3' },
116 'normal' : { 'type' : 'vec3' }, 126 'normal' : { 'type' : 'vec3' },
117 'texcoord' : { 'type' : 'vec2' } 127 'texcoord' : { 'type' : 'vec2' }
118 }, 128 },
119 // parameters 129 // parameters
120 'params' : 130 'params' :
121 { 131 {
122 'u_tex0': { 'type' : 'tex2d' }, 132 'u_tex0': { 'type' : 'tex2d' },
123 'u_time' : { 'type' : 'float' }, 133 'u_time' : { 'type' : 'float' },
124 'u_speed' : { 'type' : 'float' }, 134 'u_speed' : { 'type' : 'float' },
125 'u_resolution' : { 'type' : 'vec2' } 135 'u_resolution' : { 'type' : 'vec2' }
126 }, 136 },
127 137
128 // render states 138 // render states
129 'states' : 139 'states' :
130 { 140 {
131 'depthEnable' : true, 141 'depthEnable' : true,
132 'offset':[1.0, 0.1] 142 'offset':[1.0, 0.1]
133 } 143 }
134 } 144 }
135 ] 145 ]
136 } 146 }
137}; 147};
138 148
139TunnelMaterial.prototype = new PulseMaterial(); 149TunnelMaterial.prototype = new PulseMaterial();