diff --git a/src/geometry_primitives.jl b/src/geometry_primitives.jl index bdb4a3b8..bb077324 100644 --- a/src/geometry_primitives.jl +++ b/src/geometry_primitives.jl @@ -74,11 +74,12 @@ collect_with_eltype(::Type{T}, vec::Vector{T}) where {T} = vec collect_with_eltype(::Type{T}, vec::AbstractVector{T}) where {T} = collect(vec) function collect_with_eltype(::Type{T}, iter) where {T} + isempty(iter) && return T[] # We need to get `eltype` information from `iter`, it seems to be `Any` # most of the time so the eltype checks here don't actually work l = if Base.IteratorSize(iter) isa Union{Base.HasShape,Base.HasLength} if Base.IteratorEltype(iter) isa Base.HasEltype && isconcretetype(eltype(iter)) - # Work out the exact length + # Work out the exact length length(convert_simplex(T, first(iter))) * length(iter) else # We know it is at least the length of iter, diff --git a/test/runtests.jl b/test/runtests.jl index ebc45825..c2f369ca 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -458,6 +458,8 @@ end end @testset "decompose/triangulation" begin + @test isempty(decompose(Vec3f, [])) + @test decompose(Vec3f, []) isa Vector{Vec3f} primitive = Sphere(Point3f(0), 1) @test ndims(primitive) === 3 mesh = triangle_mesh(primitive)