A starting viewpoint for a scene.
No splat format carries a camera. A .sog file is a list of gaussians and
nothing else, so a viewer that opens without one points wherever its default
happens to point — which, for most real captures, is at nothing.
SplatTools.prepare/3 derives one of these when it converts a capture, and
the right thing to do with it is store it beside the file. This struct is
what travels between the two.
Summary
Functions
Builds a camera from a map, accepting either atom or string keys.
Builds a camera, raising on anything invalid.
Renders a camera as the JSON the browser hook reads.
Types
Functions
Builds a camera from a map, accepting either atom or string keys.
Both because it arrives two ways: as a struct from splat_tools in the same
VM, or as JSON out of a database column, where the keys are strings and the
vectors are lists rather than tuples.
iex> SplatViewer.Camera.new(%{"position" => [1, 2, 3], "target" => [0, 0, 0]})
{:ok, %SplatViewer.Camera{position: {1, 2, 3}, target: {0, 0, 0}, fov: 50.0}}
Builds a camera, raising on anything invalid.
Renders a camera as the JSON the browser hook reads.
iex> camera = SplatViewer.Camera.new!(%{position: [2, 1, -2], target: [0, 0, 0]})
iex> camera |> SplatViewer.Camera.to_json() |> Jason.decode!()
%{"fov" => 50.0, "position" => [2, 1, -2], "target" => [0, 0, 0]}