CameraRig

class CameraRig(topSpeed: Float, restSpeed: Float = topSpeed * 0.04f, shove: Float = topSpeed * 0.5f, sway: Float = 0.4f, swayUp: Float = sway * 0.9f, lean: Float = 0.25f, baseFov: Float = 70.0f, cuts: Boolean = false, seed: Int = 1)

One camera for every drawing that flies, so they all answer the music the same way.

  • Speed follows VizRenderState.drive, from a slow drift in a quiet passage up to topSpeed. It stands still while the player is paused or the audio is silent.

  • A kick shoves it forward through a spring. When the queued audio shows a kick coming, the camera first sinks back a little, and the shove goes in early enough that the surge peaks on the kick.

  • A snare nudges it sideways, a supported drop flings the lens wide for about two seconds, and it banks on noise that wanders faster when the middle of the spectrum is busy.

  • With cuts on, a supported section boundary can jump it to a new lane instead of sliding there.

Call advance once a frame, then read where the camera is.

Constructors

Link copied to clipboard
constructor(topSpeed: Float, restSpeed: Float = topSpeed * 0.04f, shove: Float = topSpeed * 0.5f, sway: Float = 0.4f, swayUp: Float = sway * 0.9f, lean: Float = 0.25f, baseFov: Float = 70.0f, cuts: Boolean = false, seed: Int = 1)

Properties

Link copied to clipboard
var eyeX: Float

Where the eye is across and up, in world units from the middle.

Link copied to clipboard
var eyeY: Float
Link copied to clipboard
var fov: Float

The lens for this frame, in degrees.

Link copied to clipboard

A point to look at, a little closer to the middle than the eye.

Link copied to clipboard
Link copied to clipboard

The sideways nudge alone, for drawings that steer the eye themselves.

Link copied to clipboard
var roll: Float

How far the camera is banked, in radians.

Link copied to clipboard

How far it has flown in all.

Functions

Link copied to clipboard
fun advance(state: VizRenderState, speedScale: Float = 1.0f, cruise: Float = -1f): Float

Moves the camera on by one frame and answers how far it went.

Link copied to clipboard
fun reset()