batches = {
const batches = [];
function makeBatch() {
return {
x: new Float32Array(50000),
y: new Float32Array(50000),
x0: new Float32Array(50000),
y0: new Float32Array(50000),
ix: new Uint32Array(50000),
half: new Float32Array(50000)
};
}
let batch = makeBatch();
let i = 0;
let ix = 0;
for (const row of fromIPC) {
for (let j = 0; j < row.Count; j += Math.ceil(Math.random() * 50)) {
const midX = (row.x + row.x0) / 2;
const midY = (row.y + row.y0) / 2;
batch.x[i] = row.x;
batch.y[i] = -row.y;
batch.x0[i] = midX;
batch.y0[i] = -midY;
batch.ix[i] = ix++;
batch.half[i] = 0;
i++;
batch.x[i] = midX;
batch.y[i] = -midY;
batch.x0[i] = row.x0;
batch.y0[i] = -row.y0;
batch.ix[i] = ix++;
batch.half[i] = 1;
i++;
if (i++ === 50000) {
batches.push(batch);
batch = makeBatch();
i = 0;
}
}
}
d3.shuffle(batches);
return batches.slice(0, batches.length - 1);
}