Select the types of activity you want to include in your feed.
Add Scene.projection and Scene.view frame accessors
Allows custom renderers (e.g. conjunction markers) to access the per-frame projection and view matrices computed by begin_frame, without recomputing them.
···5566(** Globe scene: canvas setup, render loop, and layer compositing.
7788- Bundles the WebGL boilerplate that every globe app needs:
99- canvas/GL init, resize handling, camera, and the correct draw
1010- order for all layers (stars → earth → grid → orbits → coverage). *)
88+ Bundles the WebGL boilerplate that every globe app needs: canvas/GL init,
99+ resize handling, camera, and the correct draw order for all layers (stars →
1010+ earth → grid → orbits → coverage). *)
11111212open Brr
1313open Brr_canvas
···6464let camera t = t.camera
6565let orbit t = t.orbit
6666let coverage t = t.coverage
6767-6868-let set_grid_spacing t spacing =
6969- t.grid <- Some (Grid.v ~spacing t.gl)
6767+let set_grid_spacing t spacing = t.grid <- Some (Grid.v ~spacing t.gl)
70687169(* ------------------------------------------------------------------ *)
7270(* Per-frame matrices *)
···9088 in
9189 if projection_offset <> 0. then proj.(12) <- projection_offset;
9290 let projection = Globe.Math.Mat4.to_float_array proj in
9393- let view =
9494- Globe.Math.Mat4.to_float_array (Camera.view_matrix t.camera)
9595- in
9191+ let view = Globe.Math.Mat4.to_float_array (Camera.view_matrix t.camera) in
9692 Gl.clear t.gl (Gl.color_buffer_bit lor Gl.depth_buffer_bit);
9793 { projection; view; width = w; height = h }
98949595+let projection f = f.projection
9696+let view f = f.view
9797+9998(* ------------------------------------------------------------------ *)
10099(* Layer drawing with correct compositing order *)
101100(* ------------------------------------------------------------------ *)
···140139 if layers.show_earth then
141140 Earth.draw gl t.earth ~projection:p ~view:v ~dim:layers.earth_dim ();
142141 (* 3. Grid overlay *)
143143- if layers.show_grid then
144144- (match t.grid with
145145- | Some grid ->
146146- Grid.draw gl grid ~projection:p ~view:v ~color:layers.grid_color
147147- ~alpha:layers.grid_alpha ()
148148- | None -> ());
142142+ (if layers.show_grid then
143143+ match t.grid with
144144+ | Some grid ->
145145+ Grid.draw gl grid ~projection:p ~view:v ~color:layers.grid_color
146146+ ~alpha:layers.grid_alpha ()
147147+ | None -> ());
149148 (* 4. Orbit trails + satellite dots *)
150149 if layers.show_orbits then
151150 Orbit.draw gl t.orbit ~projection:p ~view:v ~dots:layers.orbit_dots;
+17-11
webgl/scene.mli
···11(** Globe scene: canvas setup, render loop, and layer compositing.
2233- Bundles the WebGL boilerplate that every globe app needs.
44- Create a scene from a canvas element, then call {!begin_frame}
55- and {!draw} each animation frame. *)
33+ Bundles the WebGL boilerplate that every globe app needs. Create a scene
44+ from a canvas element, then call {!begin_frame} and {!draw} each animation
55+ frame. *)
6677type t
88(** Opaque scene state: GL context + all renderers. *)
991010val v : ?num_points:int -> ?grid_spacing:float -> Brr.El.t -> t
1111-(** [v ?num_points ?grid_spacing canvas_el] initializes a globe scene
1212- from a canvas element. Sets up GL context, resize handler, camera,
1313- and all renderers. *)
1111+(** [v ?num_points ?grid_spacing canvas_el] initializes a globe scene from a
1212+ canvas element. Sets up GL context, resize handler, camera, and all
1313+ renderers. *)
14141515val gl : t -> Brr_canvas.Gl.t
1616(** [gl t] is the WebGL2 context. *)
···3333(** Per-frame projection and view matrices. *)
34343535val begin_frame : t -> ?projection_offset:float -> float -> frame
3636-(** [begin_frame t ?projection_offset dt] updates the camera by [dt]
3737- seconds, computes projection/view matrices, and clears the frame.
3838- [projection_offset] shifts the projection center (for sidebar). *)
3636+(** [begin_frame t ?projection_offset dt] updates the camera by [dt] seconds,
3737+ computes projection/view matrices, and clears the frame. [projection_offset]
3838+ shifts the projection center (for sidebar). *)
3939+4040+val projection : frame -> float array
4141+(** [projection frame] is the 4x4 projection matrix as a flat float array. *)
4242+4343+val view : frame -> float array
4444+(** [view frame] is the 4x4 view matrix as a flat float array. *)
39454046(** {1 Layer compositing} *)
4147···5763(** [default_layers] has stars and earth on, everything else off. *)
58645965val draw : t -> frame -> layers -> unit
6060-(** [draw t frame layers] renders all visible layers in the correct
6161- compositing order: stars → earth → grid → orbits → coverage. *)
6666+(** [draw t frame layers] renders all visible layers in the correct compositing
6767+ order: stars → earth → grid → orbits → coverage. *)