int curIndex = 0;
int[] modeStart = new int[]{ -1, -1, -1 };
int[] elementLengths = new int[groups.length];
for (int i = 0; i < groups.length; i++){
PrimitiveGroup group = groups[i];
elementLengths[i] = group.numIndices;
if (modeStart[group.type] == -1){
modeStart[group.type] = i;
}
int[] trimmedIndices = group.getTrimmedIndices();
for (int j = 0; j < trimmedIndices.length; j++){
ib.put(curIndex + j, trimmedIndices[j]);
}
curIndex += group.numIndices;