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 brightnessSatellite-- Satellite state: cached Kepler elements, ghost orbits, trail positionsMath.Vec3-- 3D vector operationsColor-- RGBA color typeGeometry,Raycast,Visibility-- Spatial computations
WebGL (Globe_webgl)#
Scene-- Canvas setup, satellite management, layer compositing, interactionCamera-- Orbit camera with smooth zoom/panEarth,Stars,Grid,Orbit,Coverage-- Rendering layersShader-- WebGL2 shader compilation
License#
ISC