Reusable 3D Earth globe widget (pure OCaml + WebGL)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

OCaml 95.8%
Standard ML 2.4%
HTML 0.4%
Dune 0.3%
Other 1.1%
64 1 0

Clone this repository

https://tangled.org/gazagnaire.org/ocaml-globe https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-globe
git@git.recoil.org:gazagnaire.org/ocaml-globe git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-globe

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

globe#

Reusable 3D Earth globe widget (pure OCaml + WebGL).

Interactive 3D globe with dot-cloud Earth rendering, satellite orbits, ground coverage footprints, coordinate grid, and star background. Pure OCaml compiled to JavaScript via js_of_ocaml, using WebGL2 for rendering and Brr for DOM interaction.

Installation#

Install with opam:

$ opam install globe

If opam cannot find the package, it may not yet be released in the public opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install globe

Usage#

This snippet links [brr] / WebGL primitives that only exist in the browser, so it is not executed by mdx.

(* Render a satellite from J2000 state vectors on a globe scene. *)
let render_satellite ~canvas_el ~pos ~vel ~t0 ~dt ~current_unix =
  let scene = Globe_webgl.Scene.v canvas_el in
  let sat =
    Globe.Satellite.v ~pos ~vel ~color:(Globe.Color.v 0.2 0.8 1.0 1.0)
      ~epoch_unix:t0 ()
  in
  Globe_webgl.Scene.set_satellites scene [ sat ];
  let frame = Globe_webgl.Scene.begin_frame scene dt in
  Globe_webgl.Scene.update_time scene current_unix;
  Globe_webgl.Scene.draw scene frame Globe_webgl.Scene.default_layers

API Overview#

Core (Globe)#

  • Sphere -- Dot-cloud generation via golden spiral with continent/coast brightness
  • Satellite -- Satellite state: cached Kepler elements, ghost orbits, trail positions
  • Math.Vec3 -- 3D vector operations
  • Color -- RGBA color type
  • Geometry, Raycast, Visibility -- Spatial computations

WebGL (Globe_webgl)#

  • Scene -- Canvas setup, satellite management, layer compositing, interaction
  • Camera -- Orbit camera with smooth zoom/pan
  • Earth, Stars, Grid, Orbit, Coverage -- Rendering layers
  • Shader -- WebGL2 shader compilation

License#

ISC