aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/plasma-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/plasma-material.js')
-rw-r--r--js/lib/rdge/materials/plasma-material.js166
1 files changed, 83 insertions, 83 deletions
diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js
index 02af8ec0..14b6137a 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 this.resetToDefault = function() 108 this.resetToDefault = function()
109 { 109 {
@@ -115,52 +115,52 @@ var PlasmaMaterial = function PlasmaMaterial() {
115 var nProps = this._propNames.length; 115 var nProps = this._propNames.length;
116 for (var i=0; i<nProps; i++) 116 for (var i=0; i<nProps; i++)
117 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); 117 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
118 }; 118};
119}; 119};
120 120
121/////////////////////////////////////////////////////////////////////////////////////// 121///////////////////////////////////////////////////////////////////////////////////////
122// RDGE shader 122// RDGE shader
123 123
124// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 124// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
125var plasmaShaderDef = 125var plasmaShaderDef =
126{'shaders': 126{'shaders':
127 { 127 {
128 'defaultVShader':"assets/shaders/plasma.vert.glsl", 128 'defaultVShader':"assets/shaders/plasma.vert.glsl",
129 'defaultFShader':"assets/shaders/plasma.frag.glsl" 129 'defaultFShader':"assets/shaders/plasma.frag.glsl"
130 }, 130 },
131 'techniques': 131 'techniques':
132 { 132 {
133 'default': 133 'default':
134 [ 134 [
135 { 135 {
136 'vshader' : 'defaultVShader', 136 'vshader' : 'defaultVShader',
137 'fshader' : 'defaultFShader', 137 'fshader' : 'defaultFShader',
138 // attributes 138 // attributes
139 'attributes' : 139 'attributes' :
140 { 140 {
141 'vert' : { 'type' : 'vec3' }, 141 'vert' : { 'type' : 'vec3' },
142 'normal' : { 'type' : 'vec3' }, 142 'normal' : { 'type' : 'vec3' },
143 'texcoord' : { 'type' : 'vec2' } 143 'texcoord' : { 'type' : 'vec2' }
144 }, 144 },
145 // parameters 145 // parameters
146 'params' : 146 'params' :
147 { 147 {
148 'u_time' : { 'type' : 'float' }, 148 'u_time' : { 'type' : 'float' },
149 'u_speed': { 'type' : 'float' }, 149 'u_speed': { 'type' : 'float' },
150 'u_wave' : { 'type' : 'float' }, 150 'u_wave' : { 'type' : 'float' },
151 'u_wave1': { 'type' : 'float' }, 151 'u_wave1': { 'type' : 'float' },
152 'u_wave2': { 'type' : 'float' } 152 'u_wave2': { 'type' : 'float' }
153 }, 153 },
154 154
155 // render states 155 // render states
156 'states' : 156 'states' :
157 { 157 {
158 'depthEnable' : true, 158 'depthEnable' : true,
159 'offset':[1.0, 0.1] 159 'offset':[1.0, 0.1]
160 } 160 }
161 } 161 }
162 ] 162 ]
163 } 163 }
164}; 164};
165 165
166PlasmaMaterial.prototype = new Material(); 166PlasmaMaterial.prototype = new Material();