Taos API Reference
    Preparing search index...

    Type Alias Expr

    Expr:
        | { kind: "constF32"; value: number }
        | { kind: "constVec2"; value: [number, number] }
        | { kind: "constVec3"; value: [number, number, number] }
        | { kind: "constVec4"; value: [number, number, number, number] }
        | { kind: "attribute"; attr: ParticleAttribute }
        | { kind: "time" }
        | { kind: "deltaTime" }
        | { kind: "particleId" }
        | { kind: "emitterOrigin" }
        | {
            kind: "random";
            mode: RandomMode;
            min: number;
            max: number;
            seed: number;
        }
        | { kind: "variable"; name: string }
        | { kind: "unary"; op: UnaryOp; arg: Expr }
        | { kind: "binary"; op: BinaryOp; lhs: Expr; rhs: Expr }
        | { kind: "clamp"; value: Expr; min: Expr; max: Expr }
        | { kind: "mix"; a: Expr; b: Expr; t: Expr }
        | { kind: "smoothstep"; edge0: Expr; edge1: Expr; x: Expr }
        | { kind: "select"; cond: Expr; whenTrue: Expr; whenFalse: Expr }
        | { kind: "vec2"; x: Expr; y: Expr }
        | { kind: "vec3"; x: Expr; y: Expr; z: Expr }
        | { kind: "vec4"; x: Expr; y: Expr; z: Expr; w: Expr }
        | { kind: "swizzle"; arg: Expr; channels: string }

    Value-producing expression node. Recursive — operators take other Exprs as inputs. Each node produces a single value whose WGSL type is implied by its kind and inputs; mismatched types surface as WGSL compile errors at pipeline-creation time.

    Type Declaration

    • { kind: "constF32"; value: number }
    • { kind: "constVec2"; value: [number, number] }
    • { kind: "constVec3"; value: [number, number, number] }
    • { kind: "constVec4"; value: [number, number, number, number] }
    • { kind: "attribute"; attr: ParticleAttribute }

      Reads a particle attribute. Type matches the attribute (see ParticleAttribute).

    • { kind: "time" }

      Reads the engine time uniform (uniforms.time, seconds since pass start).

    • { kind: "deltaTime" }

      Reads the per-frame delta-time uniform (uniforms.dt, seconds).

    • { kind: "particleId" }

      Reads the particle's slot index as an f32 (handy as a per-particle constant).

    • { kind: "emitterOrigin" }

      Reads the emitter origin (world-space, after the GameObject transform). vec3.

    • { kind: "random"; mode: RandomMode; min: number; max: number; seed: number }

      Uniform random float in [min, max]. Seed source depends on RandomMode.

    • { kind: "variable"; name: string }

      Reference to a local variable declared in the same graph.

    • { kind: "unary"; op: UnaryOp; arg: Expr }
    • { kind: "binary"; op: BinaryOp; lhs: Expr; rhs: Expr }
    • { kind: "clamp"; value: Expr; min: Expr; max: Expr }
    • { kind: "mix"; a: Expr; b: Expr; t: Expr }
    • { kind: "smoothstep"; edge0: Expr; edge1: Expr; x: Expr }
    • { kind: "select"; cond: Expr; whenTrue: Expr; whenFalse: Expr }

      Branchless selection: returns whenTrue if cond is true, else whenFalse. Both branches are evaluated; for control-flow use action.if_.

    • { kind: "vec2"; x: Expr; y: Expr }
    • { kind: "vec3"; x: Expr; y: Expr; z: Expr }
    • { kind: "vec4"; x: Expr; y: Expr; z: Expr; w: Expr }
    • { kind: "swizzle"; arg: Expr; channels: string }

      WGSL swizzle: swizzle(v, 'xz'), swizzle(c, 'rgb'), etc. channels must be 1–4 of [xyzwrgba].