//Player chunk update
    public void ChunkLoadUpdate(float distance, Vector3Int chunkPos)
    {
        if (!data.useLOD)
        {
            return;
        }
        MarchingCubeChunk chunk = allPooledChunks.Find(x => x.chunkPosition == chunkPos);

        if (chunk != null)
        {
            chunk.GenerateMesh(data, colorData, chunkPos, this, triTable, edgeTable, edgeTable2, Mathf.RoundToInt(Mathf.Clamp(distance, 0, data.resolution - 1)), false);
        }
    }
 //Pre-generate the chunk pool for later use
 public void GenerateChunkPool(int _size)
 {
     GenerateTriTable();
     for (int x = -_size; x < _size; x++)
     {
         for (int z = -_size; z < _size; z++)
         {
             for (int y = -_size; y < _size; y++)
             {
                 MarchingCubeChunk chunk = Instantiate(chunkprefab, new Vector3(x, y, z) * 10, Quaternion.identity).GetComponent <MarchingCubeChunk>();
                 chunk.transform.parent = transform;
                 chunk.GenerateMesh(data, colorData, new Vector3Int(x, y, z), this, triTable, edgeTable, edgeTable2, data.useLOD ? Mathf.Clamp(data.LOD, 0, data.resolution - 1) : 0, true, true);
                 allPooledChunks.Add(chunk);
             }
         }
     }
 }