# aego/camera

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

Virtual cameras are components; this package switches between them and adds shake. Shake grows with trauma, which fades over time and is scaled by the accessibility setting. In the documentation sandbox nothing is drawn; the example logs how trauma fades. See [Cameras 2D](/camera.md).

## Example

```aes run
package demo

import (
    "aego/camera"
    "aego/log"
)

script Quake {
    @export var Strength float = 0.6

    var frames int

    func Ready() {
        camera.Shake(Strength)
        log.Info("trauma " + string(camera.Trauma()))
    }

    func Update(dt float) {
        frames++
        if frames % 20 == 0 {
            log.Info("trauma " + string(camera.Trauma()))
        }
        if frames == 60 {
            camera.Shake(0.3)
            log.Info("shaken again, trauma " + string(camera.Trauma()))
        }
    }
}
```

## Active

```
func Active() NodeRef
```

Returns the virtual camera that drives the main output, or nil.

## ActiveOn

```
func ActiveOn(output string) NodeRef
```

Returns the virtual camera that drives the named output.

## BlendTo

```
func BlendTo(camera NodeRef, seconds float) Handle<aego/camera.Blend>
```

Makes vc active over priorities and blends to it; seconds 0 uses its Blend Time. Release hands control back to priorities.

## Cut

```
func Cut(camera NodeRef)
```

Makes vc active at once, without a blend.

## LogicalPose

```
func LogicalPose() aego/camera.Pose
```

Returns the pose of the main output without shake and pixel snapping.

## Release

```
func Release(seconds float) Handle<aego/camera.Blend>
```

Ends BlendTo or Cut on the main output; priorities decide again, blending over seconds or the camera's Blend Time.

## RenderPose

```
func RenderPose() aego/camera.Pose
```

Returns the pose the main output was drawn with in the last frame.

## ScreenToWorld

```
func ScreenToWorld(point Vec2) Vec2
```

Converts output pixels to world units with the last drawn view of the main output.

## Shake

```
func Shake(trauma float)
```

Adds trauma to the main output; shake grows with trauma, which is capped at 1 and fades over time.

## ShakeOn

```
func ShakeOn(output string, trauma float)
```

Adds trauma to the named output.

## Trauma

```
func Trauma() float
```

Returns the current trauma of the main output, 0 to 1.

## WorldToScreen

```
func WorldToScreen(point Vec2) Vec2
```

Converts world units to output pixels with the last drawn view of the main output.
