Skip to content
blotter

class · blotter.ts

UniformInterface

The live handle for one uniform: a type, a validated value, and an update event its owner listens to.

extends Emitter<{ update: [] }>

import { UniformInterface } from "blotter.ts";

Every entry in material.uniforms and scope.material.uniforms is one of these. You do not construct them; Blotter builds them from the descriptors you pass to a material. Writing to value is validated against the type (a "2f" uniform wants a two-number array) and forwarded to the shader on the next frame.

material.uniforms.uSpeed.value = 2;            // "1f"
material.uniforms.uCenter.value = [0.5, 0.5];  // "2f"

Members #

constructor constructor

new UniformInterface <K>( descriptor: { type: K; value: UniformValueMap[K] } , context?: string )

Internal. Instances are created from UniformDescriptors by the material that owns them.

type property

readonly uniformInterface. type : K

The GLSL vector size as a UniformType: "1f", "2f", "3f" or "4f". Fixed for the life of the uniform.

value get / set

uniformInterface. value : UniformValueMap[K]

The current value, shaped by type: a number for "1f", a tuple otherwise. Assigning validates, stores, and emits update; an invalid value throws.

toDescriptor method

uniformInterface. toDescriptor ( ): UniformDescriptor

The uniform as a plain { type, value } object, suitable for passing to another material.

Inherited #

on method inherited from Emitter

uniformInterface. on <K>( event: K , listener: Listener<{ update: [] }[K]> ): () => void

off method inherited from Emitter

uniformInterface. off <K>( event: K , listener: Listener<{ update: [] }[K]> ): void