aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/plasma-material.js
diff options
context:
space:
mode:
authorKris Kowal2012-07-06 11:52:06 -0700
committerKris Kowal2012-07-06 15:01:48 -0700
commit648ee61ae84216d0236e0dbc211addc13b2cfa3a (patch)
tree8f0f55557bd0c47a84e49c1977c950645d284607 /js/lib/rdge/materials/plasma-material.js
parentaedd14b18695d031f695d27dfbd94df5614495bb (diff)
downloadninja-648ee61ae84216d0236e0dbc211addc13b2cfa3a.tar.gz
Expand tabs
Diffstat (limited to 'js/lib/rdge/materials/plasma-material.js')
-rw-r--r--js/lib/rdge/materials/plasma-material.js160
1 files changed, 80 insertions, 80 deletions
diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js
index 0b4923aa..8e51a9b0 100644
--- a/js/lib/rdge/materials/plasma-material.js
+++ b/js/lib/rdge/materials/plasma-material.js
@@ -34,37 +34,37 @@ var PlasmaMaterial = function PlasmaMaterial() {
34 /////////////////////////////////////////////////////////////////////// 34 ///////////////////////////////////////////////////////////////////////
35 // Instance variables 35 // Instance variables
36 /////////////////////////////////////////////////////////////////////// 36 ///////////////////////////////////////////////////////////////////////
37 this._name = "Plasma"; 37 this._name = "Plasma";
38 this._shaderName = "plasma"; 38 this._shaderName = "plasma";
39 39
40 this._time = 0.0; 40 this._time = 0.0;
41 this._dTime = 0.01; 41 this._dTime = 0.01;
42 this._speed = 1.0; 42 this._speed = 1.0;
43 43
44 this._wave = 0.0; 44 this._wave = 0.0;
45 this._wave1 = 0.6; 45 this._wave1 = 0.6;
46 this._wave2 = 0.8; 46 this._wave2 = 0.8;
47 47
48 /////////////////////////////////////////////////////////////////////// 48 ///////////////////////////////////////////////////////////////////////
49 // Properties 49 // Properties
50 /////////////////////////////////////////////////////////////////////// 50 ///////////////////////////////////////////////////////////////////////
51 this._propNames = ["u_wave", "u_wave1", "u_wave2", "u_speed"]; 51 this._propNames = ["u_wave", "u_wave1", "u_wave2", "u_speed"];
52 this._propLabels = ["Wave", "Wave 1", "Wave 2", "Speed"]; 52 this._propLabels = ["Wave", "Wave 1", "Wave 2", "Speed"];
53 this._propTypes = ["float", "float", "float", "float"]; 53 this._propTypes = ["float", "float", "float", "float"];
54 54
55 this._propValues = []; 55 this._propValues = [];
56 this._propValues[ this._propNames[0] ] = this._wave; 56 this._propValues[ this._propNames[0] ] = this._wave;
57 this._propValues[ this._propNames[1] ] = this._wave1; 57 this._propValues[ this._propNames[1] ] = this._wave1;
58 this._propValues[ this._propNames[2] ] = this._wave2; 58 this._propValues[ this._propNames[2] ] = this._wave2;
59 this._propValues[ this._propNames[3] ] = this._speed; 59 this._propValues[ this._propNames[3] ] = this._speed;
60 60
61 61
62 /////////////////////////////////////////////////////////////////////// 62 ///////////////////////////////////////////////////////////////////////
63 // Property Accessors 63 // Property Accessors
64 /////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////
65 this.getShaderName = function() { return this._shaderName; }; 65 this.getShaderName = function() { return this._shaderName; };
66 this.isAnimated = function() { return true; }; 66 this.isAnimated = function() { return true; };
67 this.getShaderDef = function() { return plasmaShaderDef; }; 67 this.getShaderDef = function() { return plasmaShaderDef; };
68 68
69 /////////////////////////////////////////////////////////////////////// 69 ///////////////////////////////////////////////////////////////////////
70 // Material Property Accessors 70 // Material Property Accessors
@@ -73,37 +73,37 @@ var PlasmaMaterial = function PlasmaMaterial() {
73 /////////////////////////////////////////////////////////////////////// 73 ///////////////////////////////////////////////////////////////////////
74 // Methods 74 // Methods
75 /////////////////////////////////////////////////////////////////////// 75 ///////////////////////////////////////////////////////////////////////
76 // duplcate method requirde 76 // duplcate method requirde
77 77
78 this.init = function( world) 78 this.init = function( world)
79 { 79 {
80 this.setWorld( world ); 80 this.setWorld( world );
81 81
82 // set up the shader 82 // set up the shader
83 this._shader = new RDGE.jshader(); 83 this._shader = new RDGE.jshader();
84 this._shader.def = plasmaShaderDef; 84 this._shader.def = plasmaShaderDef;
85 this._shader.init(); 85 this._shader.init();
86 86
87 // set the default value 87 // set the default value
88 this._time = 0; 88 this._time = 0;
89 this._shader['default'].u_time.set( [this._time] ); 89 this._shader['default'].u_time.set( [this._time] );
90 90
91 // set up the material node 91 // set up the material node
92 this._materialNode = RDGE.createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID()); 92 this._materialNode = RDGE.createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID());
93 this._materialNode.setShader(this._shader); 93 this._materialNode.setShader(this._shader);
94 94
95 this._time = 0; 95 this._time = 0;
96 if (this._shader && this._shader['default']) { 96 if (this._shader && this._shader['default']) {
97 this._shader['default'].u_time.set( [this._time] ); 97 this._shader['default'].u_time.set( [this._time] );
98 } 98 }
99 99
100 this.setShaderValues(); 100 this.setShaderValues();
101 }; 101 };
102 102
103 this.update = function( time ) { 103 this.update = function( time ) {
104 this._shader['default'].u_time.set( [this._time] ); 104 this._shader['default'].u_time.set( [this._time] );
105 this._time += this._dTime; 105 this._time += this._dTime;
106 }; 106 };
107}; 107};
108 108
109/////////////////////////////////////////////////////////////////////////////////////// 109///////////////////////////////////////////////////////////////////////////////////////
@@ -112,43 +112,43 @@ var PlasmaMaterial = function PlasmaMaterial() {
112// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 112// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
113var plasmaShaderDef = 113var plasmaShaderDef =
114{'shaders': 114{'shaders':
115 { 115 {
116 'defaultVShader':"assets/shaders/plasma.vert.glsl", 116 'defaultVShader':"assets/shaders/plasma.vert.glsl",
117 'defaultFShader':"assets/shaders/plasma.frag.glsl" 117 'defaultFShader':"assets/shaders/plasma.frag.glsl"
118 }, 118 },
119 'techniques': 119 'techniques':
120 { 120 {
121 'default': 121 'default':
122 [ 122 [
123 { 123 {
124 'vshader' : 'defaultVShader', 124 'vshader' : 'defaultVShader',
125 'fshader' : 'defaultFShader', 125 'fshader' : 'defaultFShader',
126 // attributes 126 // attributes
127 'attributes' : 127 'attributes' :
128 { 128 {
129 'vert' : { 'type' : 'vec3' }, 129 'vert' : { 'type' : 'vec3' },
130 'normal' : { 'type' : 'vec3' }, 130 'normal' : { 'type' : 'vec3' },
131 'texcoord' : { 'type' : 'vec2' } 131 'texcoord' : { 'type' : 'vec2' }
132 }, 132 },
133 // parameters 133 // parameters
134 'params' : 134 'params' :
135 { 135 {
136 'u_time' : { 'type' : 'float' }, 136 'u_time' : { 'type' : 'float' },
137 'u_speed': { 'type' : 'float' }, 137 'u_speed': { 'type' : 'float' },
138 'u_wave' : { 'type' : 'float' }, 138 'u_wave' : { 'type' : 'float' },
139 'u_wave1': { 'type' : 'float' }, 139 'u_wave1': { 'type' : 'float' },
140 'u_wave2': { 'type' : 'float' } 140 'u_wave2': { 'type' : 'float' }
141 }, 141 },
142 142
143 // render states 143 // render states
144 'states' : 144 'states' :
145 { 145 {
146 'depthEnable' : true, 146 'depthEnable' : true,
147 'offset':[1.0, 0.1] 147 'offset':[1.0, 0.1]
148 } 148 }
149 } 149 }
150 ] 150 ]
151 } 151 }
152}; 152};
153 153
154PlasmaMaterial.prototype = new Material(); 154PlasmaMaterial.prototype = new Material();