Skip to content

@modoki/engine / index / MaterialParamSource

Type Alias: MaterialParamSource

MaterialParamSource = { type: "constant"; value: number; } | { base?: "visual" | "sim"; speed?: number; type: "time"; wrap?: number; } | { default?: number; key: string; scale?: number; type: "store"; } | { driver: Exclude<MaterialParamSource, { type: "curve"; }>; points: CurvePoint[]; scale?: number; type: "curve"; }

MaterialInstance — Unity .material / Unreal Material Instance Dynamic.

Presence gives the entity a private, parameter-overridable view of its material whose parameters are DRIVEN at runtime from any MaterialParamSource (constant/time/store/curve) or tweaked per-instance. Each override names a parameter + the source that feeds it. Driven by materialInstanceSystem.

Two target kinds:

  • 'uniform' — a custom-shader TSL uniform. The value is written to each of the entity's drawable objects' userData[target]; the shader's uniform reads it per draw via .onObjectUpdate(({object}) => object.userData[target]). NO clone, NO recompile, and independent per entity even though the MATERIAL is shared. This is the path the stripe shader uses.
  • 'prop' — a standard material property (color/opacity/map*/…). Requires a per-entity material CLONE (see materialInstanceClones.ts); valid bases are a .mat.json material or a baked multi-material array.

Union Members

Type Literal

{ type: "constant"; value: number; }

A fixed value.

Traits

type

type: "constant"

value

value: number


Type Literal

{ base?: "visual" | "sim"; speed?: number; type: "time"; wrap?: number; }

A session-relative, pause-respecting, wrapped clock (seconds) — reproduces the stripe-shader lessons engine-wide. speed scales it, wrap bounds it to dodge the float32 precision cliff, base picks the gameplay (sim) or presentation (visual, default) delta.

Traits

base?

optional base?: "visual" | "sim"

speed?

optional speed?: number

type

type: "time"

wrap?

optional wrap?: number


Type Literal

{ default?: number; key: string; scale?: number; type: "store"; }

A live value read each frame from the read-source registry by key (the same registry UI readSource bindings use — registerReadSource). A real reading is coerced to a number and multiplied by scale. When the key is absent/non-numeric the output is the LITERAL default (or 0) — scale is NOT applied to the fallback.

Traits

default?

optional default?: number

key

key: string

scale?

optional scale?: number

type

type: "store"


Type Literal

{ driver: Exclude<MaterialParamSource, { type: "curve"; }>; points: CurvePoint[]; scale?: number; type: "curve"; }

A piecewise-linear curve (points, in the particle-curve shape) sampled by a driver value — e.g. a time driver with wrap:1 loops the curve once per second, a store driver remaps a gameplay value. The driver is any NON-curve source.

Traits

driver

driver: Exclude<MaterialParamSource, { type: "curve"; }>

points

points: CurvePoint[]

scale?

optional scale?: number

type

type: "curve"

Built with Modoki.