@@ -1737,6 +1737,8 @@ let target_orientation = ref Quaternion.identity
17371737let sensor_orientation = ref Quaternion. identity
17381738let last_screen_angle = ref 0.
17391739let locked_inclination = ref 0.
1740+ let fab_orientation = ref 0.
1741+ let fab_el : Brr.El.t option ref = ref None
17401742let is_dragging = ref false
17411743let velocity = ref (0. , 0. )
17421744let 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+
25422556let 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