Commits

Sebastien Mondet committed 9fe6266

webpdb: add 'pause' on double-click

  • Participants
  • Parent commits e41fa11

Comments (0)

Files changed (1)

     let last_draw = ref (get_time ()) in
     let draw_times = Queue.create () in
     let renderer = { gl; render = (fun () -> ()); prog} in
+    let interaction_mode = ref (`turning 0.) in
+    canvas##ondblclick <- Dom_html.handler (fun click_ev ->
+        begin match !interaction_mode with
+        | `turning f ->
+          interaction_mode := `stopped f;
+        | `stopped f ->
+          interaction_mode := `turning f;
+        end;
+        Js._true
+      );
+
     let rec f () =
-      let t = to_float (jsnew date_now ())##getTime() /. 1000. in
-      let mat' = Proj3D.mult mat (Proj3D.rotate_y (1. *. t)) in
-      gl##uniformMatrix4fv_typed(proj_loc, _false, Proj3D.array mat');
+      begin match !interaction_mode with
+      | `turning f ->
+        let mat' = Proj3D.mult mat (Proj3D.rotate_y (f)) in
+        gl##uniformMatrix4fv_typed(proj_loc, _false, Proj3D.array mat');
+        interaction_mode := `turning (f +. 0.1)
+      | `stopped _ -> ()
+      end;
 
       gl##clear(gl##_DEPTH_BUFFER_BIT_ lor gl##_COLOR_BUFFER_BIT_);
       renderer.render ();