Advertisement
Guest User

Untitled

a guest
Apr 7th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function genData(count) {
  2.     count = count|0;
  3.     var verts = new Float32Array(count * 8);
  4.     var mark_idx = new Float32Array(count * 4);
  5.  
  6.     var indices = new Uint32Array(count * 6);
  7.  
  8.     for (var i = 0; i < count; i++) {
  9.         var vOff = i * 8;
  10.  
  11.         verts[vOff + 0] = -1.0;
  12.         verts[vOff + 1] = -1.0;
  13.         verts[vOff + 2] =  1.0;
  14.         verts[vOff + 3] = -1.0;
  15.         verts[vOff + 4] =  1.0;
  16.         verts[vOff + 5] =  1.0;
  17.         verts[vOff + 6] = -1.0;
  18.         verts[vOff + 7] =  1.0;
  19.  
  20.         var iOff = i * 4;
  21.  
  22.         for (var b = 0; b < 4; b++) {
  23.             mark_idx[iOff + b] = i;
  24.         }
  25.  
  26.         var ixOff = i * 6;
  27.  
  28.         indices[ixOff + 0] = iOff + 0;
  29.         indices[ixOff + 1] = iOff + 1;
  30.         indices[ixOff + 2] = iOff + 2;
  31.         indices[ixOff + 3] = iOff + 0;
  32.         indices[ixOff + 4] = iOff + 2;
  33.         indices[ixOff + 5] = iOff + 3;
  34.  
  35.     }
  36.  
  37.     return {verts: verts, mark_idx: mark_idx, indices: indices};
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement