Talos docs

SpawnPlacement

Since 0.6

What both forms of {@link SpawnOptions} take.

Plain text

Signature

export interface SpawnPlacement {
  /**
   * Scene id for the new entity (a prefab copy's root); it must be free. Omitted, the engine derives
   * `"<like>#1"`, `"<like>#2"`, … or, for a prefab, `"<stem>#1"`, … from its file name
   * (`prefabs/imp.prefab.json` gives `imp#1`).
   */
  id?: string
  /** Local position, as {@link EntityHandle.position} is. Omitted, the source's (a prefab root's). */
  position?: Vec3
  /** Local rotation. Omitted, the source's (a prefab root's). */
  rotation?: Quat
}

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

Members

MemberSignatureDescription
idid?: stringScene id for the new entity (a prefab copy's root); it must be free. Omitted, the engine derives "<like>#1", "<like>#2", … or, for a prefab, "<stem>#1", … from its file name (prefabs/imp.prefab.json gives imp#1).
positionposition?: Vec3Local position, as {@link EntityHandle.position} is. Omitted, the source's (a prefab root's).
rotationrotation?: QuatLocal rotation. Omitted, the source's (a prefab root's).

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>