Talos docs

WritableComponents

Since 0.6

The component types {@link EntityHandle.set} can write, and the fields each one takes.

Plain text

Signature

export interface WritableComponents {
  /**
   * The material of this entity's mesh — a runtime tint, not the asset. Requires a `mesh`
   * component.
   */
  material: {
    /** Multiplies the material's own colour. Default `[1, 1, 1, 1]`, which is the asset as it is. */
    baseColor?: ColorValue
    /** Extra brightness, 0 for none. A gain on the surface, not a light: see {@link EntityHandle.set}. */
    emissive?: number
  }
  light: {
    intensity?: number
    color?: ColorValue
    /**
     * Off without forgetting how bright it was: `on: false` stops the light contributing and
     * `on: true` brings it back at whatever `intensity` says. Not a scene field — the contract
     * has no way to author a light that is off — so it defaults to true.
     */
    on?: boolean
  }
  mesh: {
    /** Drawn or not. Not a scene field: an entity the scene does not want drawn simply has no mesh. */
    visible?: boolean
  }
}

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

Members

MemberSignatureDescription
materialmaterial: {The material of this entity's mesh — a runtime tint, not the asset. Requires a mesh component.
baseColorbaseColor?: ColorValueMultiplies the material's own colour. Default [1, 1, 1, 1], which is the asset as it is.
emissiveemissive?: numberExtra brightness, 0 for none. A gain on the surface, not a light: see {@link EntityHandle.set}.
lightlight: {
intensityintensity?: number
colorcolor?: ColorValue
onon?: booleanOff without forgetting how bright it was: on: false stops the light contributing and on: true brings it back at whatever intensity says. Not a scene field — the contract has no way to author a light that is off — so it defaults to true.
meshmesh: {
visiblevisible?: booleanDrawn or not. Not a scene field: an entity the scene does not want drawn simply has no mesh.

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