diff --git a/GLMakie/src/drawing_primitives.jl b/GLMakie/src/drawing_primitives.jl index f6de625338d..a443639e33e 100644 --- a/GLMakie/src/drawing_primitives.jl +++ b/GLMakie/src/drawing_primitives.jl @@ -467,9 +467,7 @@ function mesh_inner(shader_cache, mesh, transfunc, gl_attributes) gl_attributes[:image] = Texture(const_lift(el32convert, color), minfilter = interp) gl_attributes[:color] = nothing elseif to_value(color) isa AbstractVector{<: Union{Number, Colorant}} - mesh = lift(mesh, color) do mesh, color - return GeometryBasics.pointmeta(mesh, color=el32convert(color)) - end + gl_attributes[:vertex_color] = lift(el32convert, color) else error("Unsupported color type: $(typeof(to_value(color)))") end diff --git a/GLMakie/src/glshaders/mesh.jl b/GLMakie/src/glshaders/mesh.jl index 9b58628620a..a327ce56e06 100644 --- a/GLMakie/src/glshaders/mesh.jl +++ b/GLMakie/src/glshaders/mesh.jl @@ -36,7 +36,7 @@ function draw_mesh(shader_cache, @nospecialize(mesh), data::Dict) @gen_defaults! data begin shading = true backlight = 0f0 - vertex_color = nothing + vertex_color = nothing => GLBuffer texturecoordinates = Vec2f(0) image = nothing => Texture matcap = nothing => Texture diff --git a/ReferenceTests/src/tests/refimages.jl b/ReferenceTests/src/tests/refimages.jl index 848851e994e..17cfca3cf54 100644 --- a/ReferenceTests/src/tests/refimages.jl +++ b/ReferenceTests/src/tests/refimages.jl @@ -31,3 +31,6 @@ end @testset "figures_and_makielayout.jl" begin include("figures_and_makielayout.jl") end +@testset "updating_plots" begin + include("updating.jl") +end diff --git a/ReferenceTests/src/tests/updating.jl b/ReferenceTests/src/tests/updating.jl new file mode 100644 index 00000000000..b6958ff17fc --- /dev/null +++ b/ReferenceTests/src/tests/updating.jl @@ -0,0 +1,42 @@ +using ReferenceTests +@reference_test "updating 2d primitives" begin + fig = Figure() + t = Observable(1) + text(fig[1, 1], lift(i-> map(j-> ("$j", Point2f(j*30, 0)), 1:i), t), axis=(limits=(0, 380, -10, 10),), textsize=50) + scatter(fig[1, 2], lift(i-> Point2f.((1:i).*30, 0), t), axis=(limits=(0, 330, -10, 10),), markersize=50) + linesegments(fig[2, 1], lift(i-> Point2f.((2:2:4i).*30, 0), t), axis=(limits=(30, 650, -10, 10),), linewidth=20) + lines(fig[2, 2], lift(i-> Point2f.((2:2:4i).*30, 0), t), axis=(limits=(30, 650, -10, 10),), linewidth=20) + + st = Stepper(fig) + + foreach(1:5) do i + t[] = i + Makie.step!(st) + end + + foreach(5:-1:1) do i + t[] = i + Makie.step!(st) + end + st +end + +@reference_test "updating multiple meshes" begin + points = Observable(Point3f[(1,0,0), (0,1,0), (0,0,1)]) + + meshes = map(p->Makie.normal_mesh(Sphere(p, 0.2)), points[]) + colors = map(p->RGBf(normalize(p)...), points[]) + + fig, ax, pl = mesh(meshes; color = colors) + st = Stepper(fig) + Makie.step!(st) + on(points) do pts + pl[1].val = map(p->Makie.normal_mesh(Sphere(p, 0.2)), points[]) + pl.color.val = map(p->RGBf(normalize(p)...), points[]) + notify(pl[1]) + end + + append!(points[], Point3f[(0,1,1), (1,0,1), (1,1,0)]) + notify(points) + Makie.step!(st) +end diff --git a/src/basic_recipes/contourf.jl b/src/basic_recipes/contourf.jl index eec960e0443..570c1566472 100644 --- a/src/basic_recipes/contourf.jl +++ b/src/basic_recipes/contourf.jl @@ -144,7 +144,6 @@ function Makie.plot!(c::Contourf{<:Tuple{<:AbstractVector{<:Real}, <:AbstractVec highs = levels[2:end] nbands = length(lows) - # zs needs to be transposed to match rest of makie isos = Isoband.isobands(xs, ys, zs', lows, highs) diff --git a/src/conversions.jl b/src/conversions.jl index 95491813309..4d748c1e7d1 100644 --- a/src/conversions.jl +++ b/src/conversions.jl @@ -760,7 +760,7 @@ function to_color(p::Palette) end to_color(c::Nothing) = c # for when color is not used -to_color(c::Number) = Float32(c) +to_color(c::Real) = Float32(c) to_color(c::Colorant) = convert(RGBA{Float32}, c) to_color(c::Symbol) = to_color(string(c)) to_color(c::String) = parse(RGBA{Float32}, c)