Scene and camera helpers
Alongside render!, a small set of LScene-specific helpers is provided for framing and annotating a 3D scene once a backend is loaded: get_view, set_view, set_orthographic, hide_axis, look_at!, arrow! and render_lcs!. Like render!, each throws a BeamletOptics.MissingBackendError if called before a suitable backend has been loaded. Refer to the Reference page for their full docstrings.
To freeze a camera position found interactively, use get_view and set_view; to derive the viewpoint from the scene's own geometry, use set_view with eye, look-at and up, or look_at!.
Note
These helpers need an LScene. They do not work with an Axis3.
BeamletOptics.get_view Function
get_view(ls)Returns the current camera view matrix of an LScene ls, if a suitable backend is loaded.
Handy at the REPL to freeze a view found interactively: rotate the scene by hand, call get_view(ax), and paste the printed matrix into the script as a literal passed to set_view.
Only an LScene has these camera controls, any other Makie axis, e.g. Axis3, throws an InvalidAxisError. If no suitable backend is loaded, a MissingBackendError will be thrown.
BeamletOptics.set_view Function
Sets the camera of an LScene ls, if a suitable backend is loaded, either directly from a view matrix (e.g. one obtained via get_view) or from an eye/lookat/up triple. See also look_at! to aim the camera at a known point instead of specifying the triple directly.
Any other Makie axis than an LScene throws an InvalidAxisError. If no suitable backend is loaded, a MissingBackendError will be thrown.
BeamletOptics.set_orthographic Function
set_orthographic(ls)Switches the camera of an LScene ls to an orthographic projection, if a suitable backend is loaded. Any other Makie axis throws an InvalidAxisError. If no suitable backend is loaded, a MissingBackendError will be thrown.
BeamletOptics.hide_axis Function
hide_axis(ls, hide::Bool=true)Hides the axis markers of an LScene ls, if a suitable backend is loaded. Can be toggled via hide. Any other Makie axis throws an InvalidAxisError. If no suitable backend is loaded, a MissingBackendError will be thrown.
BeamletOptics.look_at! Function
look_at!(ax, target, offset; up = [0, 0, 1])Aims the camera of ax at target from target + offset, if a suitable backend is loaded. A deterministic replacement for manually orbiting the scene to find a viewpoint, handy for reproducible close-up figures. ax must be an LScene, any other Makie axis throws an InvalidAxisError. If no suitable backend is loaded, a MissingBackendError will be thrown.
BeamletOptics.arrow! Function
arrow!(ax, pos, dir; scale=1, kwargs...)Draws a single 3D arrow from pos pointing along dir into ax, if a suitable backend is loaded. The arrow spans 5e-3 * scale * dir in world units [m], so a unit dir gives a 5 mm arrow that is legible next to CAD geometry. ax must be an LScene, any other Makie axis throws an InvalidAxisError. If no suitable backend is loaded, a MissingBackendError will be thrown.
BeamletOptics.render_lcs! Function
render_lcs!(ax, pos, lcs; scale = 10, show_labels = false)
render_lcs!(ax, object; scale = 10, show_labels = false)Draws the local coordinate system of an object or object group (or of an explicit pos/orientation pair) into ax as a red/green/yellow arrow triad, if a suitable backend is loaded. Useful to make the reference frame of an imported CAD mesh visible in the scene. ax must be an LScene, any other Makie axis throws an InvalidAxisError. If no suitable backend is loaded, a MissingBackendError will be thrown.