Talos docs

SharedSplit

Since 0.7

{@link ViewsHandle.shared}'s split options: when the shared camera splits into one view per target, and when it merges back.

Plain text

Absent or invalid numbers keep the default.

Signature

export interface SharedSplit {
  /**
   * How two targets split the window: `"auto"` (the default) is `"left-right"` in a window wider than
   * it is tall and `"top-bottom"` otherwise. Three targets always split as `"three"`, four as `"grid"`.
   */
  layout?: "auto" | "left-right" | "top-bottom"
  /**
   * Split once the targets' spread (the widest distance between two of them, metres) is beyond this.
   * Default: the spread at which the shared camera reaches `maxDistance` (at `maxFov`, if given).
   */
  beyond?: number
  /** Merge once the spread is back under this, metres. Default: three quarters of `beyond`; never above it. */
  back?: number
  /** Seconds of game time a split's or a merge's condition must hold, unbroken, before it happens. Default 0.5. */
  hold?: number
}

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

Members

MemberSignatureDescription
layoutlayout?: "auto" | "left-right" | "top-bottom"How two targets split the window: "auto" (the default) is "left-right" in a window wider than it is tall and "top-bottom" otherwise. Three targets always split as "three", four as "grid".
beyondbeyond?: numberSplit once the targets' spread (the widest distance between two of them, metres) is beyond this. Default: the spread at which the shared camera reaches maxDistance (at maxFov, if given).
backback?: numberMerge once the spread is back under this, metres. Default: three quarters of beyond; never above it.
holdhold?: numberSeconds of game time a split's or a merge's condition must hold, unbroken, before it happens. Default 0.5.

Example

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

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

/**
 * A trigger volume that launches whatever walks onto it.
 *
 * The pad does not reach into the other entity: it says who entered and how hard to launch them,
 * and the character's own behaviour calls `ctx.controller.setVelocity`. So one pad works for the
 * player, an NPC or a crate with a controller, and a character that should not be launched simply
 * ignores the event. The same shape is a knockback volume, a geyser or a car's booster strip.
 */
interface Props {
  /** The velocity to give, m/s. Straight up by default. */
  velocity?: Vec3
}

export default {
  onTrigger(ctx, trigger) {
    if (!trigger.entering) return
    ctx.events.emit("launch", { target: trigger.other.id, velocity: ctx.props.velocity ?? [0, 9, 0] })
  },
} satisfies Behavior<Record<string, never>, Props>