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-globe: skip mdx execution of browser-only example

The Usage block instantiates [Globe_webgl.Scene] and [Brr] primitives
that link to JS-only runtime values ([caml_pure_js_expr]). Linking
[globe.webgl] into the mdx bytecode runner therefore fails with
"Unimplemented Javascript primitive". Mark the snippet [<!-- $MDX
skip -->] (with a sentence explaining why) and drop [globe.webgl]
from the mdx libraries.

Also tighten the example: bind the ad-hoc [canvas_el] / [pos] / [vel]
/ [t0] / [dt] / [current_unix] free variables as a [render_satellite]
function so the snippet is at least syntactically self-contained.

+16 -16
+15 -13
README.md
··· 25 25 26 26 ## Usage 27 27 28 - ```ocaml 29 - (* Initialize a globe scene on a canvas element *) 30 - let scene = Globe_webgl.Scene.v canvas_el 31 - (* Add satellites from J2000 state vectors *) 32 - let sat = 33 - Globe.Satellite.v ~pos ~vel ~color:(Globe.Color.v 0.2 0.8 1.0 1.0) 34 - ~epoch_unix:t0 () 35 - in 36 - Globe_webgl.Scene.set_satellites scene [ sat ]; 28 + This snippet links [brr] / WebGL primitives that only exist in the 29 + browser, so it is not executed by mdx. 37 30 38 - (* Render loop *) 39 - let frame = Globe_webgl.Scene.begin_frame scene dt in 40 - Globe_webgl.Scene.update_time scene current_unix; 41 - Globe_webgl.Scene.draw scene frame Globe_webgl.Scene.default_layers 31 + <!-- $MDX skip --> 32 + ```ocaml 33 + (* Render a satellite from J2000 state vectors on a globe scene. *) 34 + let render_satellite ~canvas_el ~pos ~vel ~t0 ~dt ~current_unix = 35 + let scene = Globe_webgl.Scene.v canvas_el in 36 + let sat = 37 + Globe.Satellite.v ~pos ~vel ~color:(Globe.Color.v 0.2 0.8 1.0 1.0) 38 + ~epoch_unix:t0 () 39 + in 40 + Globe_webgl.Scene.set_satellites scene [ sat ]; 41 + let frame = Globe_webgl.Scene.begin_frame scene dt in 42 + Globe_webgl.Scene.update_time scene current_unix; 43 + Globe_webgl.Scene.draw scene frame Globe_webgl.Scene.default_layers 42 44 ``` 43 45 44 46 ## API Overview
+1 -3
dune
··· 3 3 (flags :standard %{dune-warnings}))) 4 4 5 5 (mdx 6 - (files 7 - README.md 8 - ) 6 + (files README.md) 9 7 (libraries globe))