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