aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials
diff options
context:
space:
mode:
authorhwc4872012-03-07 17:18:38 -0800
committerhwc4872012-03-07 17:18:38 -0800
commit9e812f35ffa751e9215c5427c0c44005bd357924 (patch)
treeaa26d7d4812eace4741cdc994eaf66c81ccadb43 /js/lib/rdge/materials
parent818582d389f504c915be0c9052fafa33e3e76c92 (diff)
downloadninja-9e812f35ffa751e9215c5427c0c44005bd357924.tar.gz
Fixed a few problems with Plasma material.
Diffstat (limited to 'js/lib/rdge/materials')
-rw-r--r--js/lib/rdge/materials/plasma-material.js30
1 files changed, 7 insertions, 23 deletions
diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js
index 62d0db70..86b1a93c 100644
--- a/js/lib/rdge/materials/plasma-material.js
+++ b/js/lib/rdge/materials/plasma-material.js
@@ -17,8 +17,6 @@ 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._color = [1,0,0,1];
21
22 20
23 /////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////
24 // Property Accessors 22 // Property Accessors
@@ -30,20 +28,12 @@ var PlasmaMaterial = function PlasmaMaterial() {
30 /////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////
31 // Material Property Accessors 29 // Material Property Accessors
32 /////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////
33 this._propNames = ["color"]; 31
34 this._propLabels = ["Color"]; 32 this.setProperty = function( prop, value )
35 this._propTypes = ["color"]; 33 {
36 this._propValues = []; 34 // plasma has no properties
37
38 this._propValues[ this._propNames[0] ] = this._color;
39
40 this.setProperty = function( prop, value ) {
41 // make sure we have legitimate imput
42 if (this.validateProperty( prop, value )) {
43 this._color = value.slice(0);
44 this._shader['default'][prop].set(value);
45 }
46 }; 35 };
36
47 /////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////
48 38
49 /////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////
@@ -65,8 +55,7 @@ var PlasmaMaterial = function PlasmaMaterial() {
65 55
66 // set the default value 56 // set the default value
67 this._time = 0; 57 this._time = 0;
68 this._shader['default'].u_time = this._time; 58 this._shader['default'].u_time.set( [this._time] );
69 this.setProperty( "color", [this._time, 0, 0, 1] );
70 59
71 // set up the material node 60 // set up the material node
72 this._materialNode = createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID()); 61 this._materialNode = createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID());
@@ -74,11 +63,7 @@ var PlasmaMaterial = function PlasmaMaterial() {
74 }; 63 };
75 64
76 this.update = function( time ) { 65 this.update = function( time ) {
77 this._shader['default'].u_time = this._time; 66 this._shader['default'].u_time.set( [this._time] );
78 var color = this.getProperty( "color" );
79 color[0] = this._time;
80 this.setProperty( "color", color );
81 //console.log( "update color to: " + color );
82 this._time += this._dTime; 67 this._time += this._dTime;
83 } 68 }
84 69
@@ -112,7 +97,6 @@ var plasmaShaderDef =
112 'params' : 97 'params' :
113 { 98 {
114 'u_time' : { 'type' : 'float' }, 99 'u_time' : { 'type' : 'float' },
115 'color' : { 'type' : 'vec4' }
116 }, 100 },
117 101
118 // render states 102 // render states