Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D Camera Orientation Widget #2944

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9d8fb36
prototyping
ffreyer May 11, 2023
9516bfe
Navball prototype
ffreyer May 12, 2023
2437ed5
cleanup temp file
ffreyer May 12, 2023
e90ac45
cleanup
ffreyer May 12, 2023
43ca721
add texture (generation)
ffreyer May 16, 2023
4c216e9
mark snap region and add burnout timer for angle step
ffreyer May 16, 2023
79fae51
add floating variant
ffreyer May 22, 2023
d015da6
Merge branch 'master' into ff/3D_controller
ffreyer Jul 5, 2023
e618bc8
fix merge
ffreyer Jul 5, 2023
ac6e630
Merge branch 'master' into ff/3D_controller
SimonDanisch Jul 14, 2023
c1507b7
Merge branch 'master' into ff/3D_controller
ffreyer Jul 19, 2023
9143b0f
fix merge
ffreyer Jul 19, 2023
d03c0dd
update visuals and add manual mimap
ffreyer Jul 20, 2023
da63821
rename and move attributes
ffreyer Jul 20, 2023
03899da
add valign2num and halign2num
ffreyer Jul 20, 2023
66a0a1e
implement dragging
ffreyer Jul 20, 2023
c72193d
rename file
ffreyer Jul 20, 2023
1d4a3d4
remove prints
ffreyer Jul 20, 2023
33af4db
Merge branch 'master' into ff/3D_controller
ffreyer Jul 20, 2023
f78a71f
Merge branch 'master' into ff/3D_controller
ffreyer Jul 21, 2023
d45bd3d
use valign2num, halign2num more consistently & deprecate alignment2num
ffreyer Jul 21, 2023
5cd157d
Merge branch 'master' into ff/3D_controller
ffreyer Aug 21, 2023
17fe6f4
autoformat
ffreyer Aug 21, 2023
9117d7b
fix error on empty pick
ffreyer Aug 21, 2023
0bcbf35
minor cleanup
ffreyer Aug 21, 2023
94f91e7
tweak attribute names & docs
ffreyer Aug 21, 2023
6e1e88f
Merge branch 'master' into ff/3D_controller
ffreyer Aug 31, 2023
492f123
remove duplicate code
ffreyer Aug 31, 2023
73556bb
Merge branch 'master' into ff/3D_controller
ffreyer Oct 26, 2023
54a8775
add anisotropic filtering & simplify constructor
ffreyer Oct 26, 2023
ee124d7
rename block & reorder code
ffreyer Oct 27, 2023
f6c7189
add some docs
ffreyer Oct 27, 2023
e3acf66
Merge branch 'master' into ff/3D_controller
ffreyer Dec 7, 2023
5ad7696
get closer to working Sampler textures
ffreyer Dec 7, 2023
21e9cdb
fix error
ffreyer Dec 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added assets/ball_controller_200.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ball_controller_400.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ball_controller_800.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 1 addition & 7 deletions src/basic_recipes/text.jl
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,8 @@ function float_justification(ju, al)::Float32
else
0.5f0
end
elseif ju === :left
0.0f0
elseif ju === :right
1.0f0
elseif ju === :center
0.5f0
else
Float32(ju)
halign2num(ju, "Justification $ju not recognized. Should be :left, :center, :right, a Number or automatic.")
end
end

Expand Down
5 changes: 3 additions & 2 deletions src/camera/camera3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,14 @@ cam3d_cad!(scene; cad = true, zoom_shift_lookat = false, fixed_axis = false, kwa
Camera3D(scene, cad = cad, zoom_shift_lookat = zoom_shift_lookat, fixed_axis = fixed_axis; kwargs...)

function deselect_all_cameras!(scene)
cam = cameracontrols(scene)
cam isa Camera3D && (cam.attributes.selected[] = false)
deselect_camera!(cameracontrols(scene))
for child in scene.children
deselect_all_cameras!(child)
end
nothing
end
deselect_camera!(cam::Camera3D) = cam.attributes.selected[] = false
deselect_camera!(::AbstractCamera) = nothing


function add_translation!(scene, cam::Camera3D)
Expand Down
2 changes: 1 addition & 1 deletion src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ convert_attribute(c::VecTypes{N}, ::key"position") where N = Point{N, Float32}(c
"""
Text align, e.g.:
"""
to_align(x::Tuple{Symbol, Symbol}) = Vec2f(alignment2num.(x))
to_align(x::Tuple{Symbol, Symbol}) = Vec2f(halign2num(x[1]), valign2num(x[2]))
to_align(x::Vec2f) = x

const FONT_CACHE = Dict{String, NativeFont}()
Expand Down
40 changes: 3 additions & 37 deletions src/layouting/layouting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,8 @@ function glyph_collection(
else
0.5f0
end
elseif justification === :left
0.0f0
elseif justification === :right
1.0f0
elseif justification === :center
0.5f0
else
Float32(justification)
halign2num(justification, "Invalid justification $justification. Valid values are <:Number, :left, :center and :right.")
end

xs_justified = map(xs, width_differences) do xsgroup, wd
Expand All @@ -203,17 +197,7 @@ function glyph_collection(
ys = cumsum([0.0; -lineheights[2:end]])

# compute x values after left/center/right alignment
halign = if halign isa Number
Float32(halign)
elseif halign === :left
0.0f0
elseif halign === :center
0.5f0
elseif halign === :right
1.0f0
else
error("Invalid halign $halign. Valid values are <:Number, :left, :center and :right.")
end
halign = halign2num(halign)
xs_aligned = [xsgroup .- halign * maxwidth for xsgroup in xs_justified]

# for y alignment, we need the largest ascender of the first line
Expand All @@ -233,17 +217,7 @@ function glyph_collection(
ys_aligned = if valign === :baseline
ys .- first_line_ascender .+ overall_height .+ last_line_descender
else
va = if valign isa Number
Float32(valign)
elseif valign === :top
1f0
elseif valign === :bottom
0f0
elseif valign === :center
0.5f0
else
error("Invalid valign $valign. Valid values are <:Number, :bottom, :baseline, :top, and :center.")
end
va = valign2num(valign, "Invalid valign $valign. Valid values are <:Number, :bottom, :baseline, :top, and :center.")
ys .- first_line_ascender .+ (1 - va) .* overall_height
end

Expand Down Expand Up @@ -287,14 +261,6 @@ function padded_vcat(arrs::AbstractVector{T}, fillvalue) where T <: AbstractVect
arr
end

function alignment2num(x::Symbol)
(x === :center) && return 0.5f0
(x in (:left, :bottom)) && return 0.0f0
(x in (:right, :top)) && return 1.0f0
return 0.0f0 # 0 default, or better to error?
end
ffreyer marked this conversation as resolved.
Show resolved Hide resolved


# Backend data

_offset_to_vec(o::VecTypes) = to_ndim(Vec3f, o, 0)
Expand Down
1 change: 1 addition & 0 deletions src/makielayout/MakieLayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ include("blocks/legend.jl")
include("blocks/scene.jl")
include("blocks/menu.jl")
include("blocks/textbox.jl")
include("blocks/ballcontroller.jl")

export Axis
export Axis3
Expand Down
11 changes: 2 additions & 9 deletions src/makielayout/blocks/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,8 @@ function initialize_block!(ax::Axis; palette = nothing)
ignore_equal_values=true) do a,
titlegap, align, xaxisposition, xaxisprotrusion

x = if align === :center
a.origin[1] + a.widths[1] / 2
elseif align === :left
a.origin[1]
elseif align === :right
a.origin[1] + a.widths[1]
else
error("Title align $align not supported.")
end
align_factor = halign2num(align, "Title align $align not supported.")
x = a.origin[1] + align_factor * a.widths[1]

yoffset = top(a) + titlegap + (xaxisposition === :top ? xaxisprotrusion : 0f0)

Expand Down
11 changes: 2 additions & 9 deletions src/makielayout/blocks/axis3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,8 @@ function initialize_block!(ax::Axis3)

titlepos = lift(scene, scene.px_area, ax.titlegap, ax.titlealign) do a, titlegap, align

x = if align === :center
a.origin[1] + a.widths[1] / 2
elseif align === :left
a.origin[1]
elseif align === :right
a.origin[1] + a.widths[1]
else
error("Title align $align not supported.")
end
align_factor = halign2num(align, "Title align $align not supported.")
x = a.origin[1] + align_factor * a.widths[1]

yoffset = top(a) + titlegap

Expand Down