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