fetchAttributeLocations method

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

Implementation

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

  final n = gl.getProgramParameter(program, WebGL.ACTIVE_ATTRIBUTES).id;

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

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

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

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

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

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

  return attributes;
}