Reusable 3D Earth globe widget (pure OCaml + WebGL)
OCaml 96.0%
Standard ML 2.5%
HTML 0.4%
Dune 0.2%
Other 0.9%
47 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#

opam install globe

Usage#

(* Initialize a globe scene on a canvas element *)
let scene = Globe_webgl.Scene.v canvas_el in

(* Add satellites from J2000 state vectors *)
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 ];

(* Render loop *)
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