Talos docs

UiPanelHit

Since next

One pointer ray's hit on a world-space UI panel, as of the last UI frame ({@link UiHandle.panelHits}).

Plain text

Signature

export interface UiPanelHit {
  /** The entity carrying the `uiPanel`. */
  readonly panel: EntityHandle
  /** The ray's source: `"mouse"`, `"hand-left"`, `"hand-right"`, or `"ray-<n>"`. */
  readonly pointer: string
  /** Where it landed, in the panel's pixels from its left (the space its screen lays out in). */
  readonly x: number
  /** And from its top. */
  readonly y: number
  /** Metres from the ray's origin. */
  readonly distance: number
  /** Whether the source's button (the mouse's left button, a hand's trigger) is held. */
  readonly pressed: boolean
}

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

Members

MemberSignatureDescription
panelreadonly panel: EntityHandleThe entity carrying the uiPanel.
pointerreadonly pointer: stringThe ray's source: "mouse", "hand-left", "hand-right", or "ray-<n>".
xreadonly x: numberWhere it landed, in the panel's pixels from its left (the space its screen lays out in).
yreadonly y: numberAnd from its top.
distancereadonly distance: numberMetres from the ray's origin.
pressedreadonly pressed: booleanWhether the source's button (the mouse's left button, a hand's trigger) is held.

Example

The tested fixture fixtures/app/agent.ts.

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

// Sends a nav agent to `props.target` once, then reports arrival through ctx.state so the
// test can read it without polling the crowd directly.
export default {
  init(ctx) {
    ctx.state.arrived = false
    ctx.nav?.goTo(ctx.props.target as [number, number, number])
  },
  update(ctx) {
    if (ctx.nav?.arrived) ctx.state.arrived = true
  },
} satisfies Behavior