Taos API Reference
    Preparing search index...

    Variable exprConst

    expr: {
        constant: (v: number) => Expr;
        vec2: (x: Numlike, y: Numlike) => Expr;
        vec3: (x: Numlike, y: Numlike, z: Numlike) => Expr;
        vec4: (x: Numlike, y: Numlike, z: Numlike, w: Numlike) => Expr;
        constVec3: (v: [number, number, number]) => Expr;
        constVec4: (v: [number, number, number, number]) => Expr;
        attribute: (attr: ParticleAttribute) => Expr;
        time: () => Expr;
        deltaTime: () => Expr;
        particleId: () => Expr;
        emitterOrigin: () => Expr;
        random: (
            opts?: { mode?: RandomMode; min?: number; max?: number; seed?: number },
        ) => Expr;
        variable: (name: string) => Expr;
        neg: (a: Numlike) => Expr;
        abs: (a: Numlike) => Expr;
        sign: (a: Numlike) => Expr;
        sin: (a: Numlike) => Expr;
        cos: (a: Numlike) => Expr;
        tan: (a: Numlike) => Expr;
        asin: (a: Numlike) => Expr;
        acos: (a: Numlike) => Expr;
        atan: (a: Numlike) => Expr;
        exp: (a: Numlike) => Expr;
        log: (a: Numlike) => Expr;
        sqrt: (a: Numlike) => Expr;
        floor: (a: Numlike) => Expr;
        ceil: (a: Numlike) => Expr;
        fract: (a: Numlike) => Expr;
        saturate: (a: Numlike) => Expr;
        not: (a: Numlike) => Expr;
        add: (a: Numlike, b: Numlike) => Expr;
        sub: (a: Numlike, b: Numlike) => Expr;
        mul: (a: Numlike, b: Numlike) => Expr;
        div: (a: Numlike, b: Numlike) => Expr;
        mod: (a: Numlike, b: Numlike) => Expr;
        min: (a: Numlike, b: Numlike) => Expr;
        max: (a: Numlike, b: Numlike) => Expr;
        pow: (a: Numlike, b: Numlike) => Expr;
        atan2: (a: Numlike, b: Numlike) => Expr;
        step: (a: Numlike, b: Numlike) => Expr;
        length: (a: Expr) => Expr;
        normalize: (a: Expr) => Expr;
        dot: (a: Expr, b: Expr) => Expr;
        cross: (a: Expr, b: Expr) => Expr;
        swizzle: (arg: Expr, channels: string) => Expr;
        lt: (a: Numlike, b: Numlike) => Expr;
        le: (a: Numlike, b: Numlike) => Expr;
        gt: (a: Numlike, b: Numlike) => Expr;
        ge: (a: Numlike, b: Numlike) => Expr;
        eq: (a: Numlike, b: Numlike) => Expr;
        neq: (a: Numlike, b: Numlike) => Expr;
        and: (a: Numlike, b: Numlike) => Expr;
        or: (a: Numlike, b: Numlike) => Expr;
        clamp: (value: Numlike, mn: Numlike, mx: Numlike) => Expr;
        mix: (a: Numlike, b: Numlike, t: Numlike) => Expr;
        smoothstep: (edge0: Numlike, edge1: Numlike, x: Numlike) => Expr;
        select: (cond: Expr, whenTrue: Numlike, whenFalse: Numlike) => Expr;
        patchSample: (
            field: number,
            coord: Expr,
            filter?: "nearest" | "bilinear",
        ) => Expr;
        patchCell: (field: number, dx: number, dz: number) => Expr;
        patchMooreSum: (field: number) => Expr;
        patchVonNeumannSum: (field: number) => Expr;
        patchMooreCountGt: (field: number, threshold: number) => Expr;
        neighborCount: (radius: number) => Expr;
        neighborMeanPos: (radius: number) => Expr;
        neighborMeanVel: (radius: number) => Expr;
        neighborSep: (radius: number) => Expr;
        neighborNearest: (radius: number) => Expr;
        neighborConeCount: (radius: number, coneHalfAngle: number) => Expr;
        neighborCountBreed: (radius: number, breed: number) => Expr;
        neighborNearestBreed: (radius: number, breed: number) => Expr;
        linkCount: () => Expr;
        linkReduceMin: (attr: LinkAttr) => Expr;
        linkReduceMax: (attr: LinkAttr) => Expr;
        linkReduceSum: (attr: LinkAttr) => Expr;
        linkReduceMean: (attr: LinkAttr) => Expr;
        agentAttr: (idx: Expr, attr: ParticleAttribute) => Expr;
        linkSlot: (idx: Expr, slot: Expr) => Expr;
        scratchGet: (slot: Numlike) => Expr;
        scratchAt: (agent: Numlike, slot: Numlike) => Expr;
    } = ...

    Constructor helpers for Expr nodes. Equivalent to building the discriminated union by hand, but shorter and accepts plain numbers in any slot.

    Type Declaration

    • constant: (v: number) => Expr
    • vec2: (x: Numlike, y: Numlike) => Expr
    • vec3: (x: Numlike, y: Numlike, z: Numlike) => Expr
    • vec4: (x: Numlike, y: Numlike, z: Numlike, w: Numlike) => Expr
    • constVec3: (v: [number, number, number]) => Expr
    • constVec4: (v: [number, number, number, number]) => Expr
    • attribute: (attr: ParticleAttribute) => Expr
    • time: () => Expr
    • deltaTime: () => Expr
    • particleId: () => Expr
    • emitterOrigin: () => Expr
    • random: (
          opts?: { mode?: RandomMode; min?: number; max?: number; seed?: number },
      ) => Expr
    • variable: (name: string) => Expr
    • neg: (a: Numlike) => Expr
    • abs: (a: Numlike) => Expr
    • sign: (a: Numlike) => Expr
    • sin: (a: Numlike) => Expr
    • cos: (a: Numlike) => Expr
    • tan: (a: Numlike) => Expr
    • asin: (a: Numlike) => Expr
    • acos: (a: Numlike) => Expr
    • atan: (a: Numlike) => Expr
    • exp: (a: Numlike) => Expr
    • log: (a: Numlike) => Expr
    • sqrt: (a: Numlike) => Expr
    • floor: (a: Numlike) => Expr
    • ceil: (a: Numlike) => Expr
    • fract: (a: Numlike) => Expr
    • saturate: (a: Numlike) => Expr
    • not: (a: Numlike) => Expr
    • add: (a: Numlike, b: Numlike) => Expr
    • sub: (a: Numlike, b: Numlike) => Expr
    • mul: (a: Numlike, b: Numlike) => Expr
    • div: (a: Numlike, b: Numlike) => Expr
    • mod: (a: Numlike, b: Numlike) => Expr
    • min: (a: Numlike, b: Numlike) => Expr
    • max: (a: Numlike, b: Numlike) => Expr
    • pow: (a: Numlike, b: Numlike) => Expr
    • atan2: (a: Numlike, b: Numlike) => Expr
    • step: (a: Numlike, b: Numlike) => Expr
    • length: (a: Expr) => Expr
    • normalize: (a: Expr) => Expr
    • dot: (a: Expr, b: Expr) => Expr
    • cross: (a: Expr, b: Expr) => Expr
    • swizzle: (arg: Expr, channels: string) => Expr
    • lt: (a: Numlike, b: Numlike) => Expr
    • le: (a: Numlike, b: Numlike) => Expr
    • gt: (a: Numlike, b: Numlike) => Expr
    • ge: (a: Numlike, b: Numlike) => Expr
    • eq: (a: Numlike, b: Numlike) => Expr
    • neq: (a: Numlike, b: Numlike) => Expr
    • and: (a: Numlike, b: Numlike) => Expr
    • or: (a: Numlike, b: Numlike) => Expr
    • clamp: (value: Numlike, mn: Numlike, mx: Numlike) => Expr
    • mix: (a: Numlike, b: Numlike, t: Numlike) => Expr
    • smoothstep: (edge0: Numlike, edge1: Numlike, x: Numlike) => Expr
    • select: (cond: Expr, whenTrue: Numlike, whenFalse: Numlike) => Expr
    • patchSample: (field: number, coord: Expr, filter?: "nearest" | "bilinear") => Expr
    • patchCell: (field: number, dx: number, dz: number) => Expr

      Read a patch field at cell offset (dx, dz) from the current cell — PATCH (CA update) context only. (0, 0) reads this cell. See the 'patchCell' Expr kind.

    • patchMooreSum: (field: number) => Expr

      Sum of a patch field over the 8 Moore neighbors (PATCH/CA context).

    • patchVonNeumannSum: (field: number) => Expr

      Sum of a patch field over the 4 von Neumann neighbors (PATCH/CA context).

    • patchMooreCountGt: (field: number, threshold: number) => Expr

      Count of the 8 Moore neighbors whose field value exceeds threshold (PATCH/CA context). The basis for "count live/burning neighbors".

    • neighborCount: (radius: number) => Expr

      Neighbor reductions over agents within radius (needs config.spatialHash, update context). See the 'neighbor' Expr kind.

    • neighborMeanPos: (radius: number) => Expr
    • neighborMeanVel: (radius: number) => Expr
    • neighborSep: (radius: number) => Expr
    • neighborNearest: (radius: number) => Expr

      Offset vec3 to the nearest neighbor within radius (zero when none).

    • neighborConeCount: (radius: number, coneHalfAngle: number) => Expr

      Count of neighbors within radius and inside the forward cone of half-angle coneHalfAngle radians (AgentScript in-cone).

    • neighborCountBreed: (radius: number, breed: number) => Expr

      Count of neighbors of breed (color.a) within radius — breed-filtered in-radius (predator/prey: "is a predator nearby?").

    • neighborNearestBreed: (radius: number, breed: number) => Expr

      Offset vec3 to the nearest neighbor of breed within radius (zero when none) — chase/flee a specific breed.

    • linkCount: () => Expr

      Degree: number of live link-neighbors.

    • linkReduceMin: (attr: LinkAttr) => Expr

      Minimum of attr over link-neighbors (+1e30 when none) — the label-propagation / shortest-path building block.

    • linkReduceMax: (attr: LinkAttr) => Expr

      Maximum of attr over link-neighbors (-1e30 when none).

    • linkReduceSum: (attr: LinkAttr) => Expr

      Sum of attr over link-neighbors (0 when none).

    • linkReduceMean: (attr: LinkAttr) => Expr

      Mean of attr over link-neighbors (0 when none) — voter / opinion models.

    • agentAttr: (idx: Expr, attr: ParticleAttribute) => Expr

      Read agent idx's attr by index (random access into the agent buffer; update context). See the 'agentAttr' Expr kind.

    • linkSlot: (idx: Expr, slot: Expr) => Expr

      Read agent idx's link slot slot (linked index as f32, or -1; needs config.links, update context). See the 'linkSlot' Expr kind.

    • scratchGet: (slot: Numlike) => Expr

      Read this agent's own scratch slot (needs config.scratch, update context).

    • scratchAt: (agent: Numlike, slot: Numlike) => Expr

      Read agent agent's scratch slot — scratch[agent][slot] (needs config.scratch, update context).