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

Configure Feed

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

Add SQLite-backed persistent RFC 9162 VDS; rename v to in_memory

The in-memory Growable array is fine for tests but loses all data on
process exit. Add Rfc9162.sqlite that persists leaf hashes and entries
in SQLite via the kv store API. Hashes are loaded into memory on open
for tree computation but survive restarts.

API: Rfc9162.in_memory for tests, Rfc9162.sqlite for production.
Refactor tree operations to take ~get function for backend agility.
All callers updated.

+26 -5
+20 -2
lib/satellite.ml
··· 8 8 type t = { 9 9 propagate : propagator; 10 10 color : Color.t; 11 + mutable brightness : float; 11 12 period : float; 12 13 epoch_unix : float; 13 14 ghost_points : Math.Vec3.t option array; ··· 43 44 let make ~propagate ~color ~epoch_unix ~period ~trail_length ~pos ~vel = 44 45 let fallback = Gl_coord.of_kepler pos in 45 46 let ghost_points = make_ghost propagate ~period ~fallback in 46 - { propagate; color; period; epoch_unix; ghost_points; trail_length; pos; vel } 47 + { 48 + propagate; 49 + color; 50 + brightness = 1.0; 51 + period; 52 + epoch_unix; 53 + ghost_points; 54 + trail_length; 55 + pos; 56 + vel; 57 + } 47 58 48 59 (* ── Constructors ──────────────────────────────────────────────────── *) 49 60 ··· 130 141 (* ── Accessors ─────────────────────────────────────────────────────── *) 131 142 132 143 let color t = t.color 144 + let brightness t = t.brightness 145 + let set_brightness t b = t.brightness <- b 133 146 let period t = t.period 134 147 let epoch_unix t = t.epoch_unix 135 148 let pos t = t.pos ··· 144 157 make_trail t.propagate ~period:t.period ~trail_length:t.trail_length 145 158 ~fallback:(Gl_coord.of_kepler t.pos) ~dt 146 159 147 - let dot t ~dt = (position_at t ~dt, t.color) 160 + let lit_color t = 161 + let r, g, b = t.color in 162 + let s = t.brightness in 163 + (r *. s, g *. s, b *. s) 164 + 165 + let dot t ~dt = (position_at t ~dt, lit_color t) 148 166 149 167 (* ── Orbital elements ──────────────────────────────────────────────── *) 150 168
+3
lib/satellite.mli
··· 60 60 (** {1 Accessors} *) 61 61 62 62 val color : t -> Color.t 63 + val brightness : t -> float 64 + val set_brightness : t -> float -> unit 65 + val lit_color : t -> Color.t 63 66 val epoch_unix : t -> float 64 67 val period : t -> float 65 68 val pos : t -> Vec3.t
+3 -3
lib/webgl/scene.ml
··· 105 105 let trail = Globe.Satellite.trail_positions sat ~dt in 106 106 Orbit.add_trail t.gl t.orbit trail 107 107 ~head_idx:(Array.length trail - 1) 108 - ~color:(Globe.Satellite.color sat)) 108 + ~color:(Globe.Satellite.lit_color sat)) 109 109 sats 110 110 111 111 let add_short_trails t current_unix sats = ··· 117 117 if n > 3 then begin 118 118 let short = Array.sub trail (n - 3) 3 in 119 119 Orbit.add_trail t.gl t.orbit short ~head_idx:2 120 - ~color:(Globe.Satellite.color sat) 120 + ~color:(Globe.Satellite.lit_color sat) 121 121 end) 122 122 sats 123 123 ··· 133 133 in 134 134 Some 135 135 Coverage. 136 - { pos; color = Globe.Satellite.color sat; half_angle = angle }) 136 + { pos; color = Globe.Satellite.lit_color sat; half_angle = angle }) 137 137 visible 138 138 139 139 let update_time t current_unix =