diff options
Diffstat (limited to 'js/lib/rdge/materials/julia-material.js')
-rw-r--r-- | js/lib/rdge/materials/julia-material.js | 52 |
1 files changed, 15 insertions, 37 deletions
diff --git a/js/lib/rdge/materials/julia-material.js b/js/lib/rdge/materials/julia-material.js index a06b1771..63367e16 100644 --- a/js/lib/rdge/materials/julia-material.js +++ b/js/lib/rdge/materials/julia-material.js | |||
@@ -14,7 +14,7 @@ var JuliaMaterial = function JuliaMaterial() { | |||
14 | this._name = "JuliaMaterial"; | 14 | this._name = "JuliaMaterial"; |
15 | this._shaderName = "julia"; | 15 | this._shaderName = "julia"; |
16 | 16 | ||
17 | this._texMap = 'assets/images/rocky-normal.jpg'; | 17 | this._defaultTexMap = 'assets/images/rocky-normal.jpg'; |
18 | 18 | ||
19 | this._time = 0.0; | 19 | this._time = 0.0; |
20 | this._dTime = 0.01; | 20 | this._dTime = 0.01; |
@@ -22,27 +22,22 @@ var JuliaMaterial = function JuliaMaterial() { | |||
22 | /////////////////////////////////////////////////////////////////////// | 22 | /////////////////////////////////////////////////////////////////////// |
23 | // Properties | 23 | // Properties |
24 | /////////////////////////////////////////////////////////////////////// | 24 | /////////////////////////////////////////////////////////////////////// |
25 | // properties inherited from PulseMaterial | 25 | var u_speed_index = 0; |
26 | this._propNames = [ "u_speed" ]; | ||
27 | this._propLabels = [ "Speed" ]; | ||
28 | this._propTypes = [ "float" ]; | ||
29 | this._propValues = []; | ||
30 | this._propValues[this._propNames[u_speed_index]] = 1.0; | ||
31 | |||
32 | /////////////////////////////////////////////////////////////////////// | ||
33 | // Material Property Accessors | ||
34 | /////////////////////////////////////////////////////////////////////// | ||
35 | this.isAnimated = function() { return true; }; | ||
36 | this.getShaderDef = function() { return JuliaMaterialDef; } | ||
26 | 37 | ||
27 | /////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////// |
28 | // Methods | 39 | // Methods |
29 | /////////////////////////////////////////////////////////////////////// | 40 | /////////////////////////////////////////////////////////////////////// |
30 | // duplcate method requirde | ||
31 | this.dup = function( world ) { | ||
32 | // get the current values; | ||
33 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
34 | this.getAllProperties(propNames, propValues, propTypes, propLabels); | ||
35 | |||
36 | // allocate a new material | ||
37 | var newMat = new JuliaMaterial(); | ||
38 | |||
39 | // copy over the current values; | ||
40 | var n = propNames.length; | ||
41 | for (var i = 0; i < n; i++) | ||
42 | newMat.setProperty(propNames[i], propValues[i]); | ||
43 | |||
44 | return newMat; | ||
45 | }; | ||
46 | 41 | ||
47 | this.init = function( world ) { | 42 | this.init = function( world ) { |
48 | // save the world | 43 | // save the world |
@@ -62,28 +57,11 @@ var JuliaMaterial = function JuliaMaterial() { | |||
62 | this._shader['default'].u_time.set( [this._time] ); | 57 | this._shader['default'].u_time.set( [this._time] ); |
63 | } | 58 | } |
64 | 59 | ||
65 | // set up the texture | ||
66 | var texMapName = this._propValues[this._propNames[0]]; | ||
67 | this._glTex = new Texture( world, texMapName ); | ||
68 | |||
69 | // set the shader values in the shader | 60 | // set the shader values in the shader |
61 | this.setShaderValues(); | ||
70 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | 62 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); |
71 | this.update( 0 ); | 63 | this.update( 0 ); |
72 | }; | 64 | }; |
73 | |||
74 | this.update = function( time ) { | ||
75 | var material = this._materialNode; | ||
76 | if (material) { | ||
77 | var technique = material.shaderProgram['default']; | ||
78 | var renderer = RDGE.globals.engine.getContext().renderer; | ||
79 | if (renderer && technique) { | ||
80 | if (this._shader && this._shader['default']) { | ||
81 | this._shader['default'].u_time.set( [this._time] ); | ||
82 | } | ||
83 | this._time = time; | ||
84 | } | ||
85 | } | ||
86 | }; | ||
87 | } | 65 | } |
88 | 66 | ||
89 | /////////////////////////////////////////////////////////////////////////////////////// | 67 | /////////////////////////////////////////////////////////////////////////////////////// |
@@ -113,8 +91,8 @@ var JuliaMaterialDef = | |||
113 | // parameters | 91 | // parameters |
114 | 'params' : | 92 | 'params' : |
115 | { | 93 | { |
116 | 'u_tex0': { 'type' : 'tex2d' }, | ||
117 | 'u_time' : { 'type' : 'float' }, | 94 | 'u_time' : { 'type' : 'float' }, |
95 | 'u_speed' : { 'type' : 'float' }, | ||
118 | 'u_resolution' : { 'type' : 'vec2' }, | 96 | 'u_resolution' : { 'type' : 'vec2' }, |
119 | }, | 97 | }, |
120 | 98 | ||