diff options
Diffstat (limited to 'js/lib/rdge/materials/material.js')
-rwxr-xr-x | js/lib/rdge/materials/material.js | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index 157fa7db..13251ce8 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js | |||
@@ -252,29 +252,6 @@ var Material = function GLMaterial( world ) { | |||
252 | return tex; | 252 | return tex; |
253 | }; | 253 | }; |
254 | 254 | ||
255 | this.findWorld = function( id, elt ) | ||
256 | { | ||
257 | if (elt.id && elt.id === id) | ||
258 | { | ||
259 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | ||
260 | { | ||
261 | var world = elt.elementModel.shapeModel.GLWorld; | ||
262 | return world; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | if (elt.children) | ||
267 | { | ||
268 | var nKids = elt.children.length; | ||
269 | for (var i=0; i<nKids; i++) | ||
270 | { | ||
271 | var child = elt.children[i]; | ||
272 | var world = this.findWorld( id, child ); | ||
273 | if (world) return world; | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | |||
278 | this.export = function() { | 255 | this.export = function() { |
279 | // this function should be overridden by subclasses | 256 | // this function should be overridden by subclasses |
280 | var exportStr = "material: " + this.getShaderName() + "\n" + "endMaterial\n"; | 257 | var exportStr = "material: " + this.getShaderName() + "\n" + "endMaterial\n"; |
@@ -290,78 +267,6 @@ var Material = function GLMaterial( world ) { | |||
290 | return rtnStr; | 267 | return rtnStr; |
291 | }; | 268 | }; |
292 | 269 | ||
293 | /* | ||
294 | this.setRenderProperties = function( glContext, shaderProgram ) | ||
295 | { | ||
296 | glContext.uniform1f( shaderProgram.materialShininessUniform, this._shininess ); | ||
297 | |||
298 | if (this._texture) | ||
299 | this.prepareTextureForRender( 0 ); | ||
300 | else | ||
301 | glContext.uniform1i( shaderProgram.useTextureUniform, false ); | ||
302 | |||
303 | var amb = this._ambient, diff = this._diffuse, spec = this._specular; | ||
304 | glContext.uniform4f( shaderProgram.materialAmbientUniform, amb[0], amb[1], amb[2], amb[3]); | ||
305 | glContext.uniform4f( shaderProgram.materialDiffuseUniform, diff[0], diff[1], diff[2], diff[3]); | ||
306 | glContext.uniform4f( shaderProgram.materialSpecularUniform, spec[0], spec[1], spec[2], spec[3]); | ||
307 | } | ||
308 | |||
309 | |||
310 | |||
311 | this.prepareTextureForRender = function ( index ) | ||
312 | { | ||
313 | // we will need to be able to handle multiple textures. | ||
314 | // currently only dealing with 1. | ||
315 | index = 0; | ||
316 | var texture = this._texture; | ||
317 | |||
318 | var gl = this.getWorld().getGLContext(); | ||
319 | var shaderProgram = this.getWorld().getShaderProgram(); | ||
320 | |||
321 | gl.activeTexture(gl.TEXTURE0); | ||
322 | gl.bindTexture(gl.TEXTURE_2D, texture); | ||
323 | gl.uniform1i(shaderProgram.samplerUniform, 0); | ||
324 | gl.uniform1i( shaderProgram.useTextureUniform, true ); | ||
325 | } | ||
326 | |||
327 | this.textureLoadHandler = function (event) | ||
328 | { | ||
329 | var texture = this._texture; | ||
330 | |||
331 | var gl = this._world.getGLContext(); | ||
332 | var shaderProgram = this._world.getShaderProgram(); | ||
333 | |||
334 | gl.activeTexture(gl.TEXTURE0); | ||
335 | gl.bindTexture(gl.TEXTURE_2D, texture); | ||
336 | gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); | ||
337 | gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.image); | ||
338 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); | ||
339 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); | ||
340 | |||
341 | // gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); | ||
342 | // gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); | ||
343 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); | ||
344 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); | ||
345 | |||
346 | gl.bindTexture(gl.TEXTURE_2D, null); | ||
347 | |||
348 | this._material._texture = this._texture; | ||
349 | this._world.render(); | ||
350 | } | ||
351 | |||
352 | |||
353 | this.loadTexture = function( path ) | ||
354 | { | ||
355 | var gl = this.getWorld().getGLContext(); | ||
356 | var tex = gl.createTexture(); | ||
357 | tex.image = new Image(); | ||
358 | tex.image._world = this._world; | ||
359 | tex.image._material = this; | ||
360 | tex.image._texture = tex; | ||
361 | tex.image.onload = this.textureLoadHandler; | ||
362 | tex.image.src = path; | ||
363 | } | ||
364 | */ | ||
365 | }; | 270 | }; |
366 | 271 | ||
367 | if (typeof exports === "object") { | 272 | if (typeof exports === "object") { |