private async Task <(string hash, GeometryInfo geoInfo, int resolution)> RebuildPreview( IFileSource source, string filePath, ConfigVector3?rotation, ConfigVector3?scale, string knownHash = null) { var fileName = Path.GetFileName(filePath); var fileBytes = await source .GetFileBytesAsync(filePath) .Timed("Reading file {0}", fileName); var(mesh, hash) = await StlImporter .ImportMeshAsync(fileName, fileBytes, computeHash : knownHash == null) .Timed("Imported {0}", fileName); var geoInfo = await GeometryInfo.FromMeshAsync(mesh, rotation, scale); var(previewData, resolution) = await _previewBuilder .GetPreviewImageDataAsync(mesh, rotation) .Timed("Building preview for {0}", fileName); StlImporter.Destroy(mesh); await _previewStore.StorePreviewAsync(hash ?? knownHash, previewData); return(hash, geoInfo, resolution); }
private void DestroyMesh(Mesh mesh) { if (_lookup.TryGetValue(mesh, out var gameObj)) { Destroy(gameObj); StlImporter.Destroy(mesh); _lookup.Remove(mesh); } }