Skip to content

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.

The get_view/set_view(ls, matrix) pair is meant for interactive use: rotate the scene by hand, call get_view(ax), and paste the printed matrix back into the script as a literal passed to set_view. This is the pattern used throughout this package's own tutorials to freeze a camera position found interactively. The set_view(ls, eye, lookat, up) and look_at! forms are the reproducible alternative, useful when the viewpoint should be derived from the scene's own geometry instead of copy-pasted.

Note

These helpers need an LScene. They do not work with an Axis3.

BeamletOptics.get_view Function
julia
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.

If no suitable backend is loaded, a MissingBackendError will be thrown.

source
BeamletOptics.set_view Function
julia
set_view(ls, view::AbstractMatrix)
set_view(ls, eye, lookat, up)

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.

If no suitable backend is loaded, a MissingBackendError will be thrown.

source
BeamletOptics.set_orthographic Function

Switches the camera of an LScene ls to an orthographic projection, if a suitable backend is loaded. If not, a MissingBackendError will be thrown.

source
BeamletOptics.hide_axis Function
julia
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. If no suitable backend is loaded, a MissingBackendError will be thrown.

source
BeamletOptics.look_at! Function
julia
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. If no suitable backend is loaded, a MissingBackendError will be thrown.

source
BeamletOptics.arrow! Function
julia
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, scaled to a fixed on-screen length (independent of dir's own norm) so it stays legible next to CAD geometry. If no suitable backend is loaded, a MissingBackendError will be thrown.

source
BeamletOptics.render_lcs! Function
julia
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 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. If no suitable backend is loaded, a MissingBackendError will be thrown.

source