Arcade.Camera
Types
Where the camera stands, what it looks at, and which way is up. up only has to be off the line of sight; the basis squares it up.
How the camera sees. Perspective takes the vertical field of view in degrees; Orthographic takes the visible height in world units at every depth (a top-down 2D game uses this one).
The drawing surface, in CSS pixels.
A rig ready to project onto one viewport: its basis, worked out once. half is tan(fov / 2) for a perspective lens and half the visible height for an orthographic one: either way the camera-space rise that reaches the top edge is half per unit of depth (perspective) or half (ortho).
A point in camera space: across, up, and depth along the view.
Functions
fn tan_half(n : Arcade.Numerics.Numerics, fov : Float) : Float needs () do Math.tan(fov *. n.pi /. 360.0) end
fn shake_jolt_at(amplitude : Float, clock : Float, x_rate : Float, y_rate : Float) : Vec3 needs () do vec3(Math.sin(clock . x_rate) . amplitude, Math.cos(clock . y_rate) . amplitude, 0.0) end
A pose leaned toward a focus point: the eye moves eye_share of the way there and the target target_share of the way. Up is kept.
fn fraction(n : Arcade.Numerics.Numerics, l : Projection, p : Vec3) : Arcade.Vec2.Vec2 needs () do fraction_of_seen(n, l, seen(l, p)) end
fn world_up() : Vec3 needs () do vec3(0.0, 1.0, 0.0) end
fn basis(p : Pose) : (Vec3, Vec3, Vec3) needs () do let f = normalized(sub(p.target, p.eye)) let r = normalized(cross(f, p.up)) (f, r, cross(r, f)) end
The ray through a screen position (fractions, y down): origin and unit direction. Perspective rays leave the eye; orthographic rays leave the point on the eye's plane under that position, all along forward.
Where a ray meets the plane through point with normal normal, in front of the origin. None when the ray runs within 0.00001 of parallel or the plane is behind it.
A shake offset at a clock time: sin and cos of the clock at 71 and 53 radians per second on world x and y, amplitude world units.