WGSLUniform

← prev index next →

Feeds a single animatable scalar into your custom WGSL shader — the simplest way to expose one live-tunable number (an amplitude, a mix factor, a time knob) to hand-written shader code.

Remarks

This is the scalar member of the shader-input family that belongs to the compute & custom-WGSL concept (AbstractComputeNode), and — modeled on ColorStop — it is itself a SkenraAnimatable. Unlike an inert keyframe, its value can change at runtime, set imperatively or driven by a nested <sk-animation>; each change notifies the owning host, which repacks that one slot of its GPU buffer with no shader rebuild (a value is shader DATA, while name and the set of uniforms are structural).

Key attributes. name is a non-animatable WGSL identifier, unique per host — changing it, or adding/removing/reordering uniforms, re-keys the shader. value is the animatable scalar. The host aggregates its uniform children in DOM order and generates a skUniform_<name>() -> f32 accessor, so the shader reads the value by name and the author never hand-counts lanes.

Related. It is a child of any custom-WGSL host — sk-custom-wgsl-color-source, sk-custom-wgsl-points-source, sk-custom-wgsl-point-constraint, sk-custom-wgsl-spline-source, or sk-compute-node. For non-scalar inputs use the sibling uniforms sk-wgsl-f32-array-uniform, sk-wgsl-vec2-uniform, sk-wgsl-vec3-uniform, sk-wgsl-vec4-uniform, and sk-wgsl-color-uniform (a colour authored as a string).

Constructor

constructor()

Properties

Other Properties

PropertyTypeDefaultDescriptionDeclared by
valueanimatable number 0 Gets the scalar value, returning the animated value when animating. WGSLUniform
baseValueread-only number Gets the base (non-animated) scalar value. WGSLUniform
name string "" Gets the WGSL identifier this member is addressed by. AbstractWGSLUniformMemberElement
sceneread-only any Gets the Scene this animatable belongs to, if any. SkenraAnimatable
animationsread-only SkenraAnimation[] Public getter for the animations affecting this target. SkenraAnimatable

Methods

MethodDescriptionDeclared by
animate(firstArg: TypedKeyframe<this>[] | TypedPropertyIndexedKeyframes<this> | Record<string, any> | globalThis.Keyframe[] | globalThis.PropertyIndexedKeyframes | null, secondArg?: number | KeyframeAnimationOptions | globalThis.KeyframeAnimationOptions): SkenraAnimation & Animation Creates a new SkenraAnimation for this target per Web Animations API. SkenraAnimatable
removeAnimation(animation: SkenraAnimation): boolean Removes a specific animation from this object. SkenraAnimatable
constrain(type: K, config: ConstraintConfigMap[K]): ConstraintReturnMap[K] Creates a constraint on this Animatable using a fluent API. SkenraAnimatable

Example

const u = document.createElement('sk-wgsl-uniform') as WGSLUniform;
u.name = 'amplitude';
u.value = 0.5;