HexaCrush implementation in JS