Talos docs

EnvironmentInfo

Since 0.6

The sky the scene is lit by.

Plain text

Read-only: a behavior that could set the sky would be a second author of it beside the scene file and POST /environment, and a hot reload is where that breaks first — the document's sky would fight the script's on every save. Reacting to the sky (dimming a torch at dusk, picking a footstep set for the weather) is what a behavior actually wants, and reacting only needs to read. Swap the sky from the scene file, from POST /environment, or from the editor. See docs/SKY.md.

Signature

export interface EnvironmentInfo {
  readonly kind: SkyKind
  /** The preset name for a procedural or atmosphere sky; null for the other kinds. */
  readonly preset: string | null
  /** Travel direction of the sun (sun -> scene), `[x, y, z]`. All zero when the sky has no sun. */
  readonly sunDirection: Vec3
  /** The sun's irradiance. 0 below the horizon, so `sunIntensity > 0` is "it is daytime". */
  readonly sunIntensity: number
  /** Scalar on the whole environment: background, diffuse and specular alike. */
  readonly intensity: number
  /** Yaw applied to the sky, radians. */
  readonly rotation: number
}

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

Members

MemberSignatureDescription
kindreadonly kind: SkyKind
presetreadonly preset: string | nullThe preset name for a procedural or atmosphere sky; null for the other kinds.
sunDirectionreadonly sunDirection: Vec3Travel direction of the sun (sun -> scene), [x, y, z]. All zero when the sky has no sun.
sunIntensityreadonly sunIntensity: numberThe sun's irradiance. 0 below the horizon, so sunIntensity > 0 is "it is daytime".
intensityreadonly intensity: numberScalar on the whole environment: background, diffuse and specular alike.
rotationreadonly rotation: numberYaw applied to the sky, radians.

Example

The tested fixture fixtures/recipes/jump-pad-and-elevator/scenes/behaviors/camera-zone.ts.

import type { Behavior } from "@argus/api"

/**
 * A trigger volume that retunes the camera while the player is inside it.
 *
 * The engine has no camera-zone concept and needs none: a volume, a `trigger` component and this.
 * Here the player's behaviour owns the camera (it re-sends its params when the view is turned), so
 * the zone tells it what to change rather than calling `ctx.camera.set` itself. In a scene where
 * nothing else writes the camera, the zone can call `ctx.camera.set(kind, params)` directly.
 */
interface Props {
  /** `ctx.camera.set` params to merge in on the way in, and on the way out. */
  inside?: Record<string, unknown>
  outside?: Record<string, unknown>
}

export default {
  onTrigger(ctx, trigger) {
    const params = trigger.entering ? ctx.props.inside : ctx.props.outside
    if (params) ctx.events.emit("camera-zone", { target: trigger.other.id, params })
  },
} satisfies Behavior<Record<string, never>, Props>