fetchAttributeLocations method

Map<String, dynamic> fetchAttributeLocations(
  1. dynamic gl,
  2. dynamic program
)

Implementation

Map<String, dynamic> fetchAttributeLocations(gl, program) {
  Map<String, dynamic> attributes = {};

  var n = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);

  for (var i = 0; i < n; i++) {
    var info = gl.getActiveAttrib(program, i);
    var name = info.name;

    // print( "THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE: name: ${name} i: ${i}");

    // attributes[name] = gl.getAttribLocation(program, name);

    var locationSize = 1;
    if (info.type == gl.FLOAT_MAT2) locationSize = 2;
    if (info.type == gl.FLOAT_MAT3) locationSize = 3;
    if (info.type == gl.FLOAT_MAT4) locationSize = 4;

    // console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i );

    attributes[name] = {
      "type": info.type,
      "location": gl.getAttribLocation(program, name),
      "locationSize": locationSize
    };
  }

  return attributes;
}