src/programs.js
function createUniformSetter(program, uniformInfo) {
    const location = gl.getUniformLocation(program, uniformInfo.name);
    const isArray = (uniformInfo.size > 1 && uniformInfo.name.substr(-3) === "[0]");
    const type = uniformInfo.type;
    const typeInfo = typeMap[type];
    if (!typeInfo) {
      throw ("unknown type: 0x" + type.toString(16)); // we should never get here.
    }
    let setter;
    if (typeInfo.bindPoint) {
      // it's a sampler
      const unit = textureUnit;
      textureUnit += uniformInfo.size;
      if (isArray) {
        setter = typeInfo.arraySetter(gl, type, unit, location, uniformInfo.size);
      } else {
        setter = typeInfo.setter(gl, type, unit, location, uniformInfo.size);
      }
    } else {
      if (typeInfo.arraySetter && isArray) {
        setter = typeInfo.arraySetter(gl, location);
      } else {
        setter = typeInfo.setter(gl, location);
      }
    }
    setter.location = location;
    return setter;
  }
function createUniformSetter(program, uniformInfo) {
    const location = gl.getUniformLocation(program, uniformInfo.name);
    const isArray = (uniformInfo.size > 1 && uniformInfo.name.substr(-3) === "[0]");
    const type = uniformInfo.type;
    const typeInfo = typeMap[type];
    if (!typeInfo) {
      throw ("unknown type: 0x" + type.toString(16)); // we should never get here.
    }
    let setter;
    if (typeInfo.bindPoint) {
      // it's a sampler
      const unit = textureUnit;
      textureUnit += uniformInfo.size;
      if (isArray) {
        setter = typeInfo.arraySetter(gl, type, unit, location, uniformInfo.size);
      } else {
        setter = typeInfo.setter(gl, type, unit, location, uniformInfo.size);
      }
    } else {
      if (typeInfo.arraySetter && isArray) {
        setter = typeInfo.arraySetter(gl, location);
      } else {
        setter = typeInfo.setter(gl, location);
      }
    }
    setter.location = location;
    return setter;
  }
function createUniformSetter ( program , uniformInfo ) { const location = gl . getUniformLocation ( program , uniformInfo . name ) ; const isArray = ( uniformInfo . size > 1 && uniformInfo . name . substr ( - 3 ) === "[0]" ) ; const type = uniformInfo . type ; const typeInfo = typeMap [ type ] ; if ( ! typeInfo ) { throw ( "unknown type: 0x" + type . toString ( 16 ) ) ; // we should never get here. } let setter ; if ( typeInfo . bindPoint ) { // it's a sampler const unit = textureUnit ; textureUnit += uniformInfo . size ; if ( isArray ) { setter = typeInfo . arraySetter ( gl , type , unit , location , uniformInfo . size ) ; } else { setter = typeInfo . setter ( gl , type , unit , location , uniformInfo . size ) ; } } else { if ( typeInfo . arraySetter && isArray ) { setter = typeInfo . arraySetter ( gl , location ) ; } else { setter = typeInfo . setter ( gl , location ) ; } } setter . location = location ; return setter ; }
Creates a setter for a uniform of the given program with it's
location embedded in the setter.
@param {WebGLProgram} program
@param {WebGLUniformInfo} uniformInfo
@returns {function} the created setter.
Creates a setter for a uniform of the given program with it s location embedded in the setter .