API Reference · Scene and camera
Camera
public sealed class CameraAn orbit camera: a point it looks at, and a direction and distance it looks from.
Orbit rather than free-fly because this is a viewer control first — the overwhelmingly common thing to want is "show me this object, let me turn it round". A free-fly camera can be built on top by moving Camera.Target as well as the angles.
Properties
| Member | Description |
|---|---|
| How far the camera sits from |
| Far clip distance, or null to derive one from the scene's size. |
| Vertical field of view in degrees. |
| The unit vector the camera looks along. Comes from the angles rather than from |
| Near and far planes. Left null they are derived from |
| Elevation in radians, clamped just short of straight up and down. At exactly vertical the up vector and the view direction become parallel and the view matrix collapses. |
| Where the camera is in world space, derived from its target, distance, yaw and pitch. Assigning it leaves Assigning the target's own position does nothing, since a single point gives no direction to look from and there is no answer that would be less arbitrary than the one already there. |
| Screen-right in world space, as a unit vector. Turns with |
| Rotation about the view direction, in radians. Zero keeps world +Y upright, which is what an orbit camera does and what every scene got before this existed. Positive turns the camera clockwise about Not clamped, and not wrapped: a shot that rolls through several turns can just keep counting. |
| The point the camera looks at, in world space. |
| Screen-up in world space, as a unit vector. Turns with |
| The view matrix: from |
| Rotation about the world Y axis, in radians. |
Methods
| Member | Description |
|---|---|
| Frames The distance comes from the bounding sphere and the field of view, which is right for an object you want to look at and wrong for a building you want to stand inside. There is no way to tell those apart from geometry alone, so callers who know better should set |
| The perspective projection for a viewport of the given width-to-height ratio.
|
| Aims at |
| Puts the camera at It is exactly the two assignments in exactly this order, and the order is not optional: |
| Sets This is what a camera riding a banking aircraft wants: hand it the aircraft's own up axis and the horizon tips with the wings. Without it, using The result is kept continuous with the roll already there rather than being reduced to −π..π, so calling this every frame through a barrel roll counts up instead of snapping. A |