public void RebuildCache()
    {
        voxModelsCache.Clear();
        terIds.Clear();
        tilesFolder = tilesFolder.Trim();
        if (!Directory.Exists(tilesFolder))
        {
            return;
        }
        var       files          = Directory.GetFiles(tilesFolder, "*.vox");
        Texture2D terrainTexture = null;

        foreach (var file in files)
        {
            var name  = Path.GetFileNameWithoutExtension(file).ToLower();
            var model = new VOX.Model(file);

            if (terrainTexture == null)
            {
                scale          = 1.0f / model.sizeX;
                tileSize       = model.sizeX * scale;
                terrainTexture = VOX.Texture.FromModel(model, 16);
            }

            var mesh = VOX.Mesh.FromModel(model, scale, removeEdges, 1.0f / terrainTexture.width / 2.0f);
            voxModelsCache[name] = mesh;
            terIds[0]            = "t_null";
            int terId  = DDA.terId(name);
            int monId  = DDA.monId(name);
            int furnId = DDA.furnId(name);
            if (terId != 0)
            {
                terIds[terId] = name;
            }
            if (monId != -1)
            {
                monIds[monId] = name;
            }
            if (furnId != -1)
            {
                furnIds[furnId] = name;
            }
        }

        terrainMaterial = new UnityEngine.Material(Shader.Find("Standard"));
        terrainMaterial.SetTexture("_MainTex", terrainTexture);
        UpdateGrid();
        terrainMaterial.EnableKeyword("_SPECULARHIGHLIGHTS_OFF");
        terrainMaterial.SetFloat("_SpecularHighlights", 0f);
    }