GenerateRegularGridUV method

void GenerateRegularGridUV(
  1. int w,
  2. int h
)

w: num horizontal points h: num vertical points

Implementation

void GenerateRegularGridUV(int w, int h) {
  assert(vertices.length == w * h, "grid vertices length mismatch");
  List<VM.Vector2> uvs = [];
  attributes[aTexUV] = uvs;

  for (int y = h - 1; y >= 0; --y) {
    for (int x = 0; x < w; ++x) {
      // we interchange x and y for historical reasons here
      uvs.add(VM.Vector2(y / (h - 1), x / (w - 1)));
    }
  }
  assert(uvs.length == w * h, "grid uvs lengths mismatch");
}