aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/plasma-material.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-03-13 11:15:34 -0700
committerValerio Virgillito2012-03-13 11:15:34 -0700
commitf6b958360d82854bdaf51848e7fd715d1f633179 (patch)
tree80f6c08bb730089bdd3f26310df8d2363f9ba863 /js/lib/rdge/materials/plasma-material.js
parentc24f58c10231c30d3a8a4c9fb9a4f395dd746180 (diff)
parent4d7b86f55c504ee4e8c2460cf6b60cb9a2cf18f0 (diff)
downloadninja-f6b958360d82854bdaf51848e7fd715d1f633179.tar.gz
Merge pull request #105 from joseeight/FileIO-Build-Candidate
File I/O adding webGL/canvas data functionality
Diffstat (limited to 'js/lib/rdge/materials/plasma-material.js')
-rw-r--r--js/lib/rdge/materials/plasma-material.js37
1 files changed, 12 insertions, 25 deletions
diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js
index 9ecc2b48..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 ///////////////////////////////////////////////////////////////////////
@@ -54,7 +44,10 @@ var PlasmaMaterial = function PlasmaMaterial() {
54 return new PlasmaMaterial(); 44 return new PlasmaMaterial();
55 }; 45 };
56 46
57 this.init = function() { 47 this.init = function( world)
48 {
49 this.setWorld( world );
50
58 // set up the shader 51 // set up the shader
59 this._shader = new jshader(); 52 this._shader = new jshader();
60 this._shader.def = plasmaShaderDef; 53 this._shader.def = plasmaShaderDef;
@@ -62,20 +55,15 @@ var PlasmaMaterial = function PlasmaMaterial() {
62 55
63 // set the default value 56 // set the default value
64 this._time = 0; 57 this._time = 0;
65 this._shader['default'].u_time = this._time; 58 this._shader['default'].u_time.set( [this._time] );
66 this.setProperty( "color", [this._time, 0, 0, 1] );
67 59
68 // set up the material node 60 // set up the material node
69 this._materialNode = createMaterialNode("plasmaMaterial"); 61 this._materialNode = createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID());
70 this._materialNode.setShader(this._shader); 62 this._materialNode.setShader(this._shader);
71 }; 63 };
72 64
73 this.update = function( time ) { 65 this.update = function( time ) {
74 this._shader['default'].u_time = this._time; 66 this._shader['default'].u_time.set( [this._time] );
75 var color = this.getProperty( "color" );
76 color[0] = this._time;
77 this.setProperty( "color", color );
78 //console.log( "update color to: " + color );
79 this._time += this._dTime; 67 this._time += this._dTime;
80 } 68 }
81 69
@@ -109,7 +97,6 @@ var plasmaShaderDef =
109 'params' : 97 'params' :
110 { 98 {
111 'u_time' : { 'type' : 'float' }, 99 'u_time' : { 'type' : 'float' },
112 'color' : { 'type' : 'vec4' }
113 }, 100 },
114 101
115 // render states 102 // render states