From 7041b7b10c32d72011a2f4a8f860759f11a7e875 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Tue, 22 Feb 2022 17:05:03 +0100 Subject: [PATCH] some more fixes --- CairoMakie/src/primitives.jl | 12 ++++++------ src/basic_recipes/axis.jl | 2 +- src/camera/camera3d.jl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CairoMakie/src/primitives.jl b/CairoMakie/src/primitives.jl index 0922b2bd610..88c49f24edf 100644 --- a/CairoMakie/src/primitives.jl +++ b/CairoMakie/src/primitives.jl @@ -689,9 +689,9 @@ function draw_mesh3D( @get_attribute(primitive, (color, shading, diffuse, specular, shininess, faceculling)) - colormap = get(primitive, :colormap, nothing) |> to_value |> to_colormap - colorrange = get(primitive, :colorrange, nothing) |> to_value - matcap = get(primitive, :matcap, nothing) |> to_value + colormap = to_colormap(to_value(get(primitive, :colormap, nothing))) + colorrange = to_value(get(primitive, :colorrange, nothing)) + matcap = to_value(get(primitive, :matcap, nothing)) # Priorize colors of the mesh if present color = hasproperty(mesh, :color) ? mesh.color : color @@ -700,7 +700,7 @@ function draw_mesh3D( model = primitive.model[] view = scene.camera.view[] projection = scene.camera.projection[] - i = SOneTo(3) + i = Vec(1, 2, 3) normalmatrix = transpose(inv(view[i, i] * model[i, i])) # Mesh data @@ -748,7 +748,7 @@ function draw_mesh3D( @inbounds begin p = (clip ./ clip[4])[Vec(1, 2)] p_yflip = Vec2f(p[1], -p[2]) - p_0_to_1 = (p_yflip .+ 1f0) / 2f0 + p_0_to_1 = (p_yflip .+ 1f0) ./ 2f0 end p = p_0_to_1 .* scene.camera.resolution[] return Vec3f(p[1], p[2], clip[3]) @@ -770,7 +770,7 @@ function draw_mesh3D( map(ns[f], vs[f], cols[k]) do N, v, c L = normalize(lightpos .- v[Vec(1,2,3)]) diff_coeff = max(dot(L, N), 0.0) - H = normalize(L + normalize(-v[SOneTo(3)])) + H = normalize(L + normalize(-v[Vec(1, 2, 3)])) spec_coeff = max(dot(H, N), 0.0)^shininess c = RGBA(c) new_c = (ambient .+ diff_coeff .* diffuse) .* Vec3f(c.r, c.g, c.b) .+ diff --git a/src/basic_recipes/axis.jl b/src/basic_recipes/axis.jl index f57704e2479..19de43f99e9 100644 --- a/src/basic_recipes/axis.jl +++ b/src/basic_recipes/axis.jl @@ -245,7 +245,7 @@ function draw_axis3d(textbuffer, linebuffer, scale, limits, ranges_labels, args. axisnames_size = (%) .* axisnames_size # index of the direction in which ticks and labels are drawn - offset_indices = [ifelse(i != 2, mod1(i + 1, N), 1) for i in 1:N] + offset_indices = Vec(ntuple(i-> ifelse(i != 2, mod1(i + 1, N), 1), N)) # These need the real limits, not (%), to be scale-aware titlegap = 0.01limit_widths[offset_indices] .* titlegap tgap = 0.01limit_widths[offset_indices] .* tgap diff --git a/src/camera/camera3d.jl b/src/camera/camera3d.jl index 505a23c9ed1..60daf5cb6f2 100644 --- a/src/camera/camera3d.jl +++ b/src/camera/camera3d.jl @@ -604,7 +604,7 @@ function update_cam!(scene::Scene, camera::Camera3D, area3d::Rect) @extractvalue camera (lookat, eyeposition, upvector) bb = Rect3f(area3d) width = widths(bb) - half_width = width/2f0 + half_width = width ./ 2f0 middle = maximum(bb) - half_width old_dir = normalize(eyeposition .- lookat) camera.lookat[] = middle