diff options
Diffstat (limited to 'js/lib/rdge/materials/tunnel-material.js')
-rw-r--r-- | js/lib/rdge/materials/tunnel-material.js | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/js/lib/rdge/materials/tunnel-material.js b/js/lib/rdge/materials/tunnel-material.js index fe0fbd51..83bf9021 100644 --- a/js/lib/rdge/materials/tunnel-material.js +++ b/js/lib/rdge/materials/tunnel-material.js | |||
@@ -11,64 +11,63 @@ var TunnelMaterial = function TunnelMaterial() { | |||
11 | /////////////////////////////////////////////////////////////////////// | 11 | /////////////////////////////////////////////////////////////////////// |
12 | // Instance variables | 12 | // Instance variables |
13 | /////////////////////////////////////////////////////////////////////// | 13 | /////////////////////////////////////////////////////////////////////// |
14 | this._name = "TunnelMaterial"; | 14 | this._name = "TunnelMaterial"; |
15 | this._shaderName = "tunnel"; | 15 | this._shaderName = "tunnel"; |
16 | 16 | ||
17 | this._texMap = 'assets/images/rocky-normal.jpg'; | 17 | this._texMap = 'assets/images/rocky-normal.jpg'; |
18 | 18 | ||
19 | this._time = 0.0; | 19 | this._time = 0.0; |
20 | this._dTime = 0.001; | 20 | this._dTime = 0.001; |
21 | 21 | ||
22 | /////////////////////////////////////////////////////////////////////// | 22 | /////////////////////////////////////////////////////////////////////// |
23 | // Properties | 23 | // Properties |
24 | /////////////////////////////////////////////////////////////////////// | 24 | /////////////////////////////////////////////////////////////////////// |
25 | // all defined in parent PulseMaterial.js | 25 | // all defined in parent PulseMaterial.js |
26 | // load the local default value | 26 | // load the local default value |
27 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); | 27 | this._propValues[this._propNames[0]] = this._texMap.slice(0); |
28 | 28 | ||
29 | /////////////////////////////////////////////////////////////////////// | 29 | /////////////////////////////////////////////////////////////////////// |
30 | // Methods | 30 | // Methods |
31 | /////////////////////////////////////////////////////////////////////// | 31 | /////////////////////////////////////////////////////////////////////// |
32 | // duplcate method requirde | 32 | // duplcate method requirde |
33 | this.dup = function( world ) { | 33 | this.dup = function (world) { |
34 | // allocate a new uber material | 34 | // allocate a new uber material |
35 | var newMat = new TunnelMaterial(); | 35 | var newMat = new TunnelMaterial(); |
36 | 36 | ||
37 | // copy over the current values; | 37 | // copy over the current values; |
38 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | 38 | var propNames = [], propValues = [], propTypes = [], propLabels = []; |
39 | this.getAllProperties( propNames, propValues, propTypes, propLabels); | 39 | this.getAllProperties(propNames, propValues, propTypes, propLabels); |
40 | var n = propNames.length; | 40 | var n = propNames.length; |
41 | for (var i=0; i<n; i++) { | 41 | for (var i = 0; i < n; i++) { |
42 | newMat.setProperty( propNames[i], propValues[i] ); | 42 | newMat.setProperty(propNames[i], propValues[i]); |
43 | } | 43 | } |
44 | 44 | ||
45 | return newMat; | 45 | return newMat; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | this.init = function( world ) | 48 | this.init = function (world) { |
49 | { | 49 | // save the world |
50 | // save the world | 50 | if (world) this.setWorld(world); |
51 | if (world) this.setWorld( world ); | ||
52 | 51 | ||
53 | // set up the shader | 52 | // set up the shader |
54 | this._shader = new jshader(); | 53 | this._shader = new RDGE.jshader(); |
55 | this._shader.def = tunnelMaterialDef; | 54 | this._shader.def = tunnelMaterialDef; |
56 | this._shader.init(); | 55 | this._shader.init(); |
57 | 56 | ||
58 | // set up the material node | 57 | // set up the material node |
59 | this._materialNode = createMaterialNode("tunnelMaterial" + "_" + world.generateUniqueNodeID()); | 58 | this._materialNode = RDGE.createMaterialNode("tunnelMaterial" + "_" + world.generateUniqueNodeID()); |
60 | this._materialNode.setShader(this._shader); | 59 | this._materialNode.setShader(this._shader); |
61 | 60 | ||
62 | this._time = 0; | 61 | this._time = 0; |
63 | if (this._shader && this._shader['default']) { | 62 | if (this._shader && this._shader['default']) { |
64 | this._shader['default'].u_time.set( [this._time] ); | 63 | this._shader['default'].u_time.set([this._time]); |
65 | } | 64 | } |
66 | 65 | ||
67 | // set the shader values in the shader | 66 | // set the shader values in the shader |
68 | this.updateTexture(); | 67 | this.updateTexture(); |
69 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | 68 | this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); |
70 | this.update( 0 ); | 69 | this.update(0); |
71 | } | 70 | }; |
72 | }; | 71 | }; |
73 | 72 | ||
74 | /////////////////////////////////////////////////////////////////////////////////////// | 73 | /////////////////////////////////////////////////////////////////////////////////////// |