Talos docs

CameraParams

Since 0.6Changed in 0.7

Settings for {@link CameraHandle.set}.

Plain text

Every key is optional and keeps its previous value when absent, except distance. Any other key is passed through to the rig.

Signature

export interface CameraParams {
  /**
   * Vertical field of view in degrees, for every kind. Sticky: it stands until another `set` names
   * one or `follow(null)`. `null` drops it, so the scene camera's `fov` is drawn again.
   */
  fov?: number | null
  /**
   * How far the camera sees, in metres, for every kind. Absent, the scene camera's `far` decides,
   * and failing that `meta.bounds`. A value under one metre is ignored.
   */
  far?: number
  /**
   * `"orthographic"` draws the view as a box instead of a pyramid (a 2D, isometric or top-down game); `fov` is
   * then ignored. `"perspective"` switches back. Absent keeps the scene camera's `projection`. Sticky, like
   * the three lens keys below, until `follow(null)`; each one lies over the scene camera's own value.
   */
  projection?: "perspective" | "orthographic"
  /** Orthographic: half the view's height in world units. Wins over `pixelsPerUnit`. Not above zero: ignored. */
  orthoSize?: number
  /** Orthographic: pixels per world unit in the 1920 x 1080 reference view; with no `orthoSize` from scene or script, sizes the box from it (1080 / (2 × ppu)). The window draws at a whole multiple of it. */
  pixelsPerUnit?: number
  /** Orthographic: round the eye to the drawn view's screen-pixel grid so pixel art holds still. */
  pixelSnap?: boolean
  /** Boom length in metres, for `third-person`, `orbit` and `lock` (default 4.5 on `lock`). */
  distance?: number
  /** Yaw in radians about world +Y, measured the way {@link EntityHandle.teleport} measures it. */
  yaw?: number
  /** Pitch in radians; positive looks up. On `"lock"`: the pitch at distance, default -0.25; it drops towards a view from above as the target comes close. */
  pitch?: number
  /** Radius of the sphere the boom sweeps to keep itself out of geometry. Sticky: omitting it keeps the last value. */
  probeRadius?: number
  /**
   * Metres up world +Y from the follow target to the eye — the eye itself in `first-person`, the
   * pivot the boom swings around in `third-person` and `orbit`.
   *
   * Defaults to 1.65, a standing character measured from the feet, so a character scene is
   * unchanged. `0` means the anchor the script named **is** the eye, which is what a vehicle
   * wants: a car has already authored `driver-eye` and `chase-anchor` at the height it wants,
   * and the default sat an extra standing person on the roof.
   *
   * Sticky, like `probeRadius` and unlike `distance`: omitting it keeps the last value rather
   * than returning to the default. A value that is not finite is ignored.
   */
  eyeHeight?: number
  /** `"fixed"` only: a world `[x, y, z]` the rig is bolted to — makes it live without a follow target. */
  position?: [number, number, number]
  /** `"fixed"` only: `[x, y, z]` from the followed entity (the isometric follow-cam). The alternative to `position`. */
  offset?: [number, number, number]
  /**
   * `"fixed"`: a world point to look at; without one it looks at the followed entity, else along yaw/pitch.
   *
   * `"lock"`: the entity (handle or scene id) or world point to keep in frame with the player; required to take
   * the lock, then sticky. The heading turns towards it; close up the eye lifts and slides aside so the player
   * never hides it. A despawned target ends the lock; another kind eases out of it.
   */
  target?: [number, number, number] | EntityHandle | string
  /** `"lock"` only: metres above the target entity's origin that the camera aims at (its chest). Default 1. Sticky. */
  height?: number
  /**
   * `"lock"` only: where the camera looks between the followed entity's pivot (0) and the target (1). Default 0.5,
   * which frames both. Sticky.
   */
  framing?: number
  /** `"lock"` only: the fastest the heading turns towards the target, degrees per second. Default 270. Sticky. */
  turnRateDeg?: number
  /**
   * Seconds without a steer before the rig swings back behind the followed entity — the way it visibly faces:
   * a character, or a car whose chase camera comes back round after the player stops turning the view. A `set`
   * that writes a different `yaw` is a steer. `null` or a negative number turns it off. Sticky.
   */
  recenterDelay?: number | null
  /** How fast the recenter swing turns, degrees per second; default 90. Sticky. */
  recenterSpeedDeg?: number
  /**
   * Seconds of the followed entity's horizontal travel the followed point leads by, so more of the way ahead is
   * on screen: 0.3 at 10 m/s is 3 m ahead. 0 (the default) is off. Never applied to the first-person eye. Sticky.
   */
  lookAhead?: number
  /** Longest the look-ahead lead may be, metres; default 2. Sticky. */
  lookAheadMax?: number
  /** How quickly the lead settles on a new direction, per second; default 3. Sticky. */
  lookAheadRate?: number
  /**
   * `third-person` and `orbit`: arm length, metres, below which the followed character starts to fade (a
   * screen-door dither), so an arm a wall has collapsed shows the world rather than the inside of the character.
   * Default 1; 0 turns fading off. Sticky, like every wall-handling key below.
   */
  fadeStart?: number
  /** Arm length, metres, at which the character is gone entirely. Default 0.45. */
  fadeFull?: number
  /** How quickly the fade follows the arm, per second. Default 12. */
  fadeRate?: number
  /**
   * How quickly the arm grows back once a wall clears, per second. Default 5; 0 snaps back. The arm always
   * shortens at once: easing into a wall is clipping through it.
   */
  recoverRate?: number
  /**
   * Metres to shift the pivot sideways, towards the side with room, while a wall has the arm short. Default 0 (off).
   *
   * On `"lock"` it is instead the eye's sideways shift, along the camera's right (85% of it at any range, all of it with the
   * target within about 1.2 m): default 1.0, negative for the left shoulder, 0 to turn it off.
   */
  shoulder?: number
  /**
   * Swing the yaw gently away from a wall that is shortening the arm, after `avoidDelay` seconds without a steer.
   * Default false: in a game with camera-relative controls, a camera that turns by itself also turns the player's
   * "forward", and a run along a wall curves off it.
   */
  avoidWalls?: boolean
  /** Fastest the avoid swing turns, degrees per second. Default 60. */
  avoidSpeedDeg?: number
  /** How far either side the avoid feelers look, degrees. Default 30. */
  avoidAngleDeg?: number
  /** Seconds after a steer before the avoid swing may act. Default 0.5. */
  avoidDelay?: number
  [key: string]: unknown
}

Import: import type { CameraParams } from "@argus/api"

Members

MemberSignatureDescription
fovfov?: number | nullVertical field of view in degrees, for every kind. Sticky: it stands until another set names one or follow(null). null drops it, so the scene camera's fov is drawn again.
farfar?: numberHow far the camera sees, in metres, for every kind. Absent, the scene camera's far decides, and failing that meta.bounds. A value under one metre is ignored.
projectionprojection?: "perspective" | "orthographic""orthographic" draws the view as a box instead of a pyramid (a 2D, isometric or top-down game); fov is then ignored. "perspective" switches back. Absent keeps the scene camera's projection. Sticky, like the three lens keys below, until follow(null); each one lies over the scene camera's own value.
orthoSizeorthoSize?: numberOrthographic: half the view's height in world units. Wins over pixelsPerUnit. Not above zero: ignored.
pixelsPerUnitpixelsPerUnit?: numberOrthographic: pixels per world unit in the 1920 x 1080 reference view; with no orthoSize from scene or script, sizes the box from it (1080 / (2 × ppu)). The window draws at a whole multiple of it.
pixelSnappixelSnap?: booleanOrthographic: round the eye to the drawn view's screen-pixel grid so pixel art holds still.
distancedistance?: numberBoom length in metres, for third-person, orbit and lock (default 4.5 on lock).
yawyaw?: numberYaw in radians about world +Y, measured the way {@link EntityHandle.teleport} measures it.
pitchpitch?: numberPitch in radians; positive looks up. On "lock": the pitch at distance, default -0.25; it drops towards a view from above as the target comes close.
probeRadiusprobeRadius?: numberRadius of the sphere the boom sweeps to keep itself out of geometry. Sticky: omitting it keeps the last value.
eyeHeighteyeHeight?: numberMetres up world +Y from the follow target to the eye — the eye itself in first-person, the pivot the boom swings around in third-person and orbit. Defaults to 1.65, a standing character measured from the feet, so a character scene is unchanged. 0 means the anchor the script named is the eye, which is what a vehicle wants: a car has already authored driver-eye and chase-anchor at the height it wants, and the default sat an extra standing person on the roof. Sticky, like probeRadius and unlike distance: omitting it keeps the last value rather than returning to the default. A value that is not finite is ignored.
positionposition?: [number, number, number]"fixed" only: a world [x, y, z] the rig is bolted to — makes it live without a follow target.
offsetoffset?: [number, number, number]"fixed" only: [x, y, z] from the followed entity (the isometric follow-cam). The alternative to position.
targettarget?: [number, number, number] | EntityHandle | string"fixed": a world point to look at; without one it looks at the followed entity, else along yaw/pitch. "lock": the entity (handle or scene id) or world point to keep in frame with the player; required to take the lock, then sticky. The heading turns towards it; close up the eye lifts and slides aside so the player never hides it. A despawned target ends the lock; another kind eases out of it.
heightheight?: number"lock" only: metres above the target entity's origin that the camera aims at (its chest). Default 1. Sticky.
framingframing?: number"lock" only: where the camera looks between the followed entity's pivot (0) and the target (1). Default 0.5, which frames both. Sticky.
turnRateDegturnRateDeg?: number"lock" only: the fastest the heading turns towards the target, degrees per second. Default 270. Sticky.
recenterDelayrecenterDelay?: number | nullSeconds without a steer before the rig swings back behind the followed entity — the way it visibly faces: a character, or a car whose chase camera comes back round after the player stops turning the view. A set that writes a different yaw is a steer. null or a negative number turns it off. Sticky.
recenterSpeedDegrecenterSpeedDeg?: numberHow fast the recenter swing turns, degrees per second; default 90. Sticky.
lookAheadlookAhead?: numberSeconds of the followed entity's horizontal travel the followed point leads by, so more of the way ahead is on screen: 0.3 at 10 m/s is 3 m ahead. 0 (the default) is off. Never applied to the first-person eye. Sticky.
lookAheadMaxlookAheadMax?: numberLongest the look-ahead lead may be, metres; default 2. Sticky.
lookAheadRatelookAheadRate?: numberHow quickly the lead settles on a new direction, per second; default 3. Sticky.
fadeStartfadeStart?: numberthird-person and orbit: arm length, metres, below which the followed character starts to fade (a screen-door dither), so an arm a wall has collapsed shows the world rather than the inside of the character. Default 1; 0 turns fading off. Sticky, like every wall-handling key below.
fadeFullfadeFull?: numberArm length, metres, at which the character is gone entirely. Default 0.45.
fadeRatefadeRate?: numberHow quickly the fade follows the arm, per second. Default 12.
recoverRaterecoverRate?: numberHow quickly the arm grows back once a wall clears, per second. Default 5; 0 snaps back. The arm always shortens at once: easing into a wall is clipping through it.
shouldershoulder?: numberMetres to shift the pivot sideways, towards the side with room, while a wall has the arm short. Default 0 (off). On "lock" it is instead the eye's sideways shift, along the camera's right (85% of it at any range, all of it with the target within about 1.2 m): default 1.0, negative for the left shoulder, 0 to turn it off.
avoidWallsavoidWalls?: booleanSwing the yaw gently away from a wall that is shortening the arm, after avoidDelay seconds without a steer. Default false: in a game with camera-relative controls, a camera that turns by itself also turns the player's "forward", and a run along a wall curves off it.
avoidSpeedDegavoidSpeedDeg?: numberFastest the avoid swing turns, degrees per second. Default 60.
avoidAngleDegavoidAngleDeg?: numberHow far either side the avoid feelers look, degrees. Default 30.
avoidDelayavoidDelay?: numberSeconds after a steer before the avoid swing may act. Default 0.5.

Example

The tested fixture fixtures/host/door.ts.

import type { Behavior } from "@argus/api"
// docs/API.md, "Joints": a door on a hinge that swings open while the player is near and closes
// behind them. Typechecked by packages/api's tests.
export default {
  update(ctx) {
    const player = ctx.world.find("player")
    const near = player !== null && ctx.entity.distanceTo(player) < 2
    ctx.joint?.setMotor(near ? Math.PI / 2 : 0, { mode: "position", maxForce: 200 })
  },
} satisfies Behavior