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.js59
1 files changed, 29 insertions, 30 deletions
diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js
index 02172a6b..c1e5524c 100644
--- a/js/lib/rdge/materials/plasma-material.js
+++ b/js/lib/rdge/materials/plasma-material.js
@@ -17,32 +17,39 @@ var PlasmaMaterial = function PlasmaMaterial() {
17 this._dTime = 0.01; 17 this._dTime = 0.01;
18 this._speed = 1.0; 18 this._speed = 1.0;
19 19
20 this._wave = 0.0;
21 this._wave1 = 0.6;
22 this._wave2 = 0.8;
23
24 ///////////////////////////////////////////////////////////////////////
25 // Properties
26 ///////////////////////////////////////////////////////////////////////
27 this._propNames = ["u_wave", "u_wave1", "u_wave2", "u_speed"];
28 this._propLabels = ["Wave", "Wave 1", "Wave 2", "Speed"];
29 this._propTypes = ["float", "float", "float", "float"];
30
31 this._propValues = [];
32 this._propValues[ this._propNames[0] ] = this._wave;
33 this._propValues[ this._propNames[1] ] = this._wave1;
34 this._propValues[ this._propNames[2] ] = this._wave2;
35 this._propValues[ this._propNames[3] ] = this._speed;
36
20 37
21 /////////////////////////////////////////////////////////////////////// 38 ///////////////////////////////////////////////////////////////////////
22 // Property Accessors 39 // Property Accessors
23 /////////////////////////////////////////////////////////////////////// 40 ///////////////////////////////////////////////////////////////////////
24 this.getShaderName = function() { return this._shaderName; }; 41 this.getShaderName = function() { return this._shaderName; };
25
26 this.isAnimated = function() { return true; }; 42 this.isAnimated = function() { return true; };
43 this.getShaderDef = function() { return plasmaShaderDef; };
27 44
28 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
29 // Material Property Accessors 46 // Material Property Accessors
30 /////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////
31 48
32 this.setProperty = function( prop, value )
33 {
34 // plasma has no properties
35 };
36
37 ///////////////////////////////////////////////////////////////////////
38
39 /////////////////////////////////////////////////////////////////////// 49 ///////////////////////////////////////////////////////////////////////
40 // Methods 50 // Methods
41 /////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////
42 // duplcate method requirde 52 // duplcate method requirde
43 this.dup = function() {
44 return new PlasmaMaterial();
45 };
46 53
47 this.init = function( world) 54 this.init = function( world)
48 { 55 {
@@ -60,31 +67,19 @@ var PlasmaMaterial = function PlasmaMaterial() {
60 // set up the material node 67 // set up the material node
61 this._materialNode = RDGE.createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID()); 68 this._materialNode = RDGE.createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID());
62 this._materialNode.setShader(this._shader); 69 this._materialNode.setShader(this._shader);
70
71 this._time = 0;
72 if (this._shader && this._shader['default']) {
73 this._shader['default'].u_time.set( [this._time] );
74 }
75
76 this.setShaderValues();
63 }; 77 };
64 78
65 this.update = function( time ) { 79 this.update = function( time ) {
66 this._shader['default'].u_time.set( [this._time] ); 80 this._shader['default'].u_time.set( [this._time] );
67 this._time += this._dTime; 81 this._time += this._dTime;
68 }; 82 };
69
70 this.exportJSON = function()
71 {
72 var jObj =
73 {
74 'material' : this.getShaderName(),
75 'name' : this.getName(),
76 'speed' : this._speed,
77 'dTime' : this._dTime
78 };
79
80 return jObj;
81 };
82
83 this.importJSON = function( jObj )
84 {
85 this._speed = jObj.speed;
86 this._dTime = jObj.dTime;
87 };
88}; 83};
89 84
90/////////////////////////////////////////////////////////////////////////////////////// 85///////////////////////////////////////////////////////////////////////////////////////
@@ -115,6 +110,10 @@ var plasmaShaderDef =
115 'params' : 110 'params' :
116 { 111 {
117 'u_time' : { 'type' : 'float' }, 112 'u_time' : { 'type' : 'float' },
113 'u_speed': { 'type' : 'float' },
114 'u_wave' : { 'type' : 'float' },
115 'u_wave1': { 'type' : 'float' },
116 'u_wave2': { 'type' : 'float' }
118 }, 117 },
119 118
120 // render states 119 // render states