diff --git a/src/renderers/webgl/WebGLProgram.js b/src/renderers/webgl/WebGLProgram.js index be6aea0c76bdc77d5f8d9d936d2b0598459dfd54..46475f2d5d4634c93ec3f621ed1e01803a479b0c 100644 --- a/src/renderers/webgl/WebGLProgram.js +++ b/src/renderers/webgl/WebGLProgram.js @@ -22,7 +22,6 @@ THREE.WebGLProgram = ( function () { function fetchUniformLocations( gl, program, identifiers ) { - var uniforms = {}; var n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS ); @@ -403,7 +402,7 @@ THREE.WebGLProgram = ( function () { } if ( haveDiagnostics ) { - + this.diagnostics = { runnable: runnable, @@ -436,30 +435,33 @@ THREE.WebGLProgram = ( function () { // set up caching for uniform locations - var _cachedUniforms; - - var getUniforms = function() { return _cachedUniforms; }; + var cachedUniforms; this.getUniforms = function() { - // fetch, cache, and next time just use a dumb accessor - _cachedUniforms = fetchUniformLocations( gl, program ); - this.getUniforms = getUniforms; - return _cachedUniforms; + if ( cachedUniforms === undefined ) { + + cachedUniforms = fetchUniformLocations( gl, program ); + + } + + return cachedUniforms; }; // set up caching for attribute locations - var _cachedAttributes; - - var getAttributes = function() { return _cachedAttributes; }; + var cachedAttributes; this.getAttributes = function() { - _cachedAttributes = fetchAttributeLocations( gl, program ); - this.getAttributes = getAttributes; - return _cachedAttributes; + if ( cachedAttributes === undefined ) { + + cachedAttributes = fetchAttributeLocations( gl, program ); + + } + + return cachedAttributes; };