StrokeField

← prev index next →

Abstract base class for stroke fields — value objects that operate on stroke-local coordinates (strokeCoord).

Remarks

Stroke fields extend SkenraAnimatable so their properties can be animated. They are NOT scene graph nodes — they have no transforms and no parent-child hierarchy.

All stroke fields return weight = 0 outside stroke context: on the CPU when strokeCoord is not provided, and on the GPU by emitting a constant return 0.0; body when generated for a surface, edge, or compute domain.

Because a stroke field is not a scene-graph node (it is not walked per frame), it participates in the scene only by being referenced from a consuming tonemap/material, which forwards StrokeField.registerSceneto it. That call registers the field's animations with the scene's default timeline, so .animate() on a referenced stroke field ticks like any other animatable.

Abstract base class — not instantiated directly. Construct one of its concrete subclasses; this class contributes the members below to them.

Properties

Other Properties

PropertyTypeDefaultDescriptionDeclared by
remapCurve SampledCurve | null Optional curve that reshapes this field's raw [0, 1] output. StrokeField
remapPhase number 0 Horizontal remap phase — an animatable scalar that translates a present StrokeField
enabled boolean true Whether this field is enabled. When disabled, evaluate() returns 0. StrokeField
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 field = new CrossStrokeField({ threshold: 0.5, softness: 0.1 });
field.evaluate([0, 0, 0], [0, 0.3]); // weight based on strokeCoord.y
field.evaluate([0, 0, 0]);            // 0 — no strokeCoord