From fa8c183c2e4232a10f3f361942ecb619d0ee4595 Mon Sep 17 00:00:00 2001 From: ffreyer Date: Mon, 21 Oct 2024 22:08:20 +0200 Subject: [PATCH] try matching file without capitalization --- src/basic_recipes/mesh.jl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/basic_recipes/mesh.jl b/src/basic_recipes/mesh.jl index b116dc90332..1e23e64eab2 100644 --- a/src/basic_recipes/mesh.jl +++ b/src/basic_recipes/mesh.jl @@ -38,9 +38,22 @@ function plot!(p::Mesh{<: Tuple{<: GeometryBasics.MetaMesh}}) tex = if haskey(x, "image") x["image"] elseif haskey(x, "filename") - FileIO.load(x["filename"]) + if isfile(x["filename"]) + FileIO.load(x["filename"]) + else + # try to match filename + path, filename = splitdir(x["filename"]) + files = readdir(path) + idx = findfirst(f -> lowercase(f) == lowercase(filename), files) + if idx === nothing + @error "Failed to load texture from material $name - File $filename not found in $path." + fill(RGB{N0f8}(1,0,1), (1,1)) + else + FileIO.load(joinpath(path, files[idx])) + end + end else - fill(RGB{N0f8}(1,0,1)) + fill(RGB{N0f8}(1,0,1), (1,1)) end repeat = get(x, "clamp", false) ? (:clamp_to_edge) : (:repeat)