Skip to content

Commit

Permalink
some more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Mar 2, 2022
1 parent a6cecd2 commit 7041b7b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions CairoMakie/src/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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])
Expand All @@ -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) .+
Expand Down
2 changes: 1 addition & 1 deletion src/basic_recipes/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/camera/camera3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7041b7b

Please sign in to comment.