Skip to content

Commit 1d3616f

Browse files
committed
-
1 parent 7d6b968 commit 1d3616f

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/web/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@
7676
stroke: #4f46e5;
7777
}
7878

79+
.fab.rot90 {
80+
bottom: auto;
81+
top: calc(24px + env(safe-area-inset-top));
82+
}
83+
.fab.rot90 svg { transform: rotate(90deg); }
84+
85+
.fab.rot180 {
86+
bottom: auto; right: auto;
87+
top: calc(24px + env(safe-area-inset-top));
88+
left: calc(24px + env(safe-area-inset-left));
89+
}
90+
.fab.rot180 svg { transform: rotate(180deg); }
91+
92+
.fab.rot270 {
93+
right: auto;
94+
left: calc(24px + env(safe-area-inset-left));
95+
}
96+
.fab.rot270 svg { transform: rotate(270deg); }
97+
7998
.menu-overlay {
8099
position: fixed;
81100
top: 0;

src/web/viewer.ml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,8 @@ let target_orientation = ref Quaternion.identity
17371737
let sensor_orientation = ref Quaternion.identity
17381738
let last_screen_angle = ref 0.
17391739
let locked_inclination = ref 0.
1740+
let fab_orientation = ref 0.
1741+
let fab_el : Brr.El.t option ref = ref None
17401742
let is_dragging = ref false
17411743
let velocity = ref (0., 0.)
17421744
let last_input_time = ref 0.
@@ -2293,6 +2295,7 @@ let create_location_ui ~size =
22932295
Jv.set (Brr.El.to_jv el) "innerHTML"
22942296
(Jv.of_string
22952297
{|<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="1 6 1 22 8 18 16 22 23 18 23 2 16 6 8 2 1 6"></polygon><line x1="8" y1="2" x2="8" y2="18"></line><line x1="16" y1="6" x2="16" y2="22"></line></svg>|});
2298+
fab_el := Some el;
22962299
el
22972300
in
22982301
let overlay = Brr.El.div ~at:Brr.At.[ class' (Jstr.v "menu-overlay") ] [] in
@@ -2539,6 +2542,17 @@ let create_location_ui ~size =
25392542
Brr.El.set_inline_style (Jstr.v "display") disp current_loc_btn;
25402543
Brr.El.set_inline_style (Jstr.v "display") disp_header quick_select_header
25412544

2545+
let update_fab_orientation angle =
2546+
match !fab_el with
2547+
| None -> ()
2548+
| Some fab ->
2549+
let is_rot90 = Float.abs (angle -. (-.Float.pi /. 2.)) < 0.01 in
2550+
let is_rot180 = Float.abs (Float.abs angle -. Float.pi) < 0.01 in
2551+
let is_rot270 = Float.abs (angle -. Float.pi /. 2.) < 0.01 in
2552+
Brr.El.set_class (Jstr.v "rot90") is_rot90 fab;
2553+
Brr.El.set_class (Jstr.v "rot180") is_rot180 fab;
2554+
Brr.El.set_class (Jstr.v "rot270") is_rot270 fab
2555+
25422556
let setup_events canvas =
25432557
let deviceorientation =
25442558
Brr.Ev.Type.create (Jstr.v "deviceorientationabsolute")
@@ -2638,9 +2652,18 @@ let setup_events canvas =
26382652
{ x = 0.; y = 0.; z = 1.; w = 0. }
26392653
(-.screen_delta *. Float.pi /. 180.)
26402654
in
2641-
current_orientation := Quaternion.mult !current_orientation q_delta
2655+
current_orientation := Quaternion.mult !current_orientation q_delta;
2656+
fab_orientation := 0.;
2657+
update_fab_orientation 0.
26422658
end;
26432659
last_screen_angle := screen;
2660+
let new_fab_angle =
2661+
snap_inclination ~current_locked:!fab_orientation !sensor_orientation
2662+
in
2663+
if new_fab_angle <> !fab_orientation then begin
2664+
fab_orientation := new_fab_angle;
2665+
update_fab_orientation new_fab_angle
2666+
end;
26442667
if !input_mode = Sensor then begin
26452668
target_orientation := q;
26462669
match !state with

0 commit comments

Comments
 (0)