aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/pulse-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/pulse-material.js')
-rw-r--r--js/lib/rdge/materials/pulse-material.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js
index 2075d1ff..47059533 100644
--- a/js/lib/rdge/materials/pulse-material.js
+++ b/js/lib/rdge/materials/pulse-material.js
@@ -96,12 +96,12 @@ var PulseMaterial = function PulseMaterial() {
96 this._dTime = 0.01; 96 this._dTime = 0.01;
97 97
98 // set up the shader 98 // set up the shader
99 this._shader = new jshader(); 99 this._shader = new RDGE.jshader();
100 this._shader.def = pulseMaterialDef; 100 this._shader.def = pulseMaterialDef;
101 this._shader.init(); 101 this._shader.init();
102 102
103 // set up the material node 103 // set up the material node
104 this._materialNode = createMaterialNode("pulseMaterial" + "_" + world.generateUniqueNodeID()); 104 this._materialNode = RDGE.createMaterialNode("pulseMaterial" + "_" + world.generateUniqueNodeID());
105 this._materialNode.setShader(this._shader); 105 this._materialNode.setShader(this._shader);
106 106
107 this._time = 0; 107 this._time = 0;
@@ -120,12 +120,12 @@ var PulseMaterial = function PulseMaterial() {
120 var material = this._materialNode; 120 var material = this._materialNode;
121 if (material) { 121 if (material) {
122 var technique = material.shaderProgram['default']; 122 var technique = material.shaderProgram['default'];
123 var renderer = g_Engine.getContext().renderer; 123 var renderer = RDGE.globals.engine.getContext().renderer;
124 if (renderer && technique) { 124 if (renderer && technique) {
125 var texMapName = this._propValues[this._propNames[0]]; 125 var texMapName = this._propValues[this._propNames[0]];
126 var wrap = 'REPEAT', mips = true; 126 var wrap = 'REPEAT', mips = true;
127 var tex = this.loadTexture( texMapName, wrap, mips ); 127 var tex = this.loadTexture( texMapName, wrap, mips );
128 128
129 if (tex) { 129 if (tex) {
130 technique.u_tex0.set( tex ); 130 technique.u_tex0.set( tex );
131 } 131 }
@@ -139,7 +139,7 @@ var PulseMaterial = function PulseMaterial() {
139 if (material) 139 if (material)
140 { 140 {
141 var technique = material.shaderProgram['default']; 141 var technique = material.shaderProgram['default'];
142 var renderer = g_Engine.getContext().renderer; 142 var renderer = RDGE.globals.engine.getContext().renderer;
143 if (renderer && technique) { 143 if (renderer && technique) {
144 if (this._shader && this._shader['default']) { 144 if (this._shader && this._shader['default']) {
145 this._shader['default'].u_time.set( [this._time] ); 145 this._shader['default'].u_time.set( [this._time] );
@@ -155,7 +155,7 @@ var PulseMaterial = function PulseMaterial() {
155 var material = this._materialNode; 155 var material = this._materialNode;
156 if (material) { 156 if (material) {
157 var technique = material.shaderProgram['default']; 157 var technique = material.shaderProgram['default'];
158 var renderer = g_Engine.getContext().renderer; 158 var renderer = RDGE.globals.engine.getContext().renderer;
159 if (renderer && technique) { 159 if (renderer && technique) {
160 technique.u_resolution.set( res ); 160 technique.u_resolution.set( res );
161 } 161 }
@@ -176,29 +176,29 @@ var PulseMaterial = function PulseMaterial() {
176 return jObj; 176 return jObj;
177 }; 177 };
178 178
179 this.importJSON = function( jObj ) 179 this.importJSON = function( jObj ) {
180 {
181 if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); 180 if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" );
182 this.setName( jObj.name ); 181 this.setName( jObj.name );
183 182
184 try { 183 try {
185 this._propValues[this._propNames[0]] = jObj.texture; 184 this._propValues[this._propNames[0]] = jObj.texture;
186 this._texMap = jObj.texture; 185 this._texMap = jObj.texture;
187 if (jObj.dTime) 186 if (jObj.dTime) {
188 this._dTime = jObj.dTime; 187 this._dTime = jObj.dTime;
188 }
189 } 189 }
190 catch (e) 190 catch (e)
191 { 191 {
192 throw new Error( "could not import material: " + jObj ); 192 throw new Error( "could not import material: " + jObj );
193 } 193 }
194 } 194 };
195 195
196 196
197 this.export = function() { 197 this.export = function() {
198 // every material needs the base type and instance name 198 // every material needs the base type and instance name
199 var exportStr = "material: " + this.getShaderName() + "\n"; 199 var exportStr = "material: " + this.getShaderName() + "\n";
200 exportStr += "name: " + this.getName() + "\n"; 200 exportStr += "name: " + this.getName() + "\n";
201 201
202 var world = this.getWorld(); 202 var world = this.getWorld();
203 if (!world) 203 if (!world)
204 throw new Error( "no world in material.export, " + this.getName() ); 204 throw new Error( "no world in material.export, " + this.getName() );