cells = {
const position = [];
const triangles = [];
const lines = [];
const color = [];
for (const boundary of h3CellBoundaries) {
const coords = boundary.map(([lat, lon]) => polarToCartesian(lon, lat, 1));
const offset = position.length;
const colorValue = coords.length === 6 ? [1, 1, 1] : [0, 0, 0];
coords.forEach(() => color.push(...colorValue));
position.push(...coords);
const range = d3.range(offset, offset + coords.length - 1);
range.forEach((d, i) => {
triangles.push(offset);
triangles.push(offset + i + 1);
triangles.push(offset + (((i + 1) % (coords.length - 1)) + 1));
});
const [, ...tail] = range;
range.forEach((d, i) => {
lines.push(offset + i + 1);
lines.push(offset + ((i + 1) % (coords.length - 1)) + 1);
});
}
return {
position: gl.regl.buffer(position),
triangles: gl.regl.elements({
primitive: "triangles",
count: triangles.length,
data: triangles
}),
lines: gl.regl.elements({
primitive: "lines",
count: lines.length,
data: lines
}),
color: gl.regl.buffer(color)
};
}