Drives one property of a node from a field's weight at that node's position — the way to make position in space control a value like scale or opacity.
Declarative element:
<sk-field-constraint>
Not on the sk.* global — construct via the declarative element or a module import.
This is the field-reading member of the Constraint family: like every
constraint it drives its constrained
target by recomputing from live scene state each frame — here it samples a
SpatialField at the target's world position, turns the field weight into
a scalar, and writes it to one target property. It is a single-node,
CPU-evaluated constraint, distinct from its GPU per-clone counterpart.
Key attributes. field names the field to sample, by #id — any CPU-evaluable
field such as the SpatialField shapes (the GPU-only
sk-color-source-field has no effect here). target-property selects which property the
weight writes (e.g. s for uniform scale, opacity); the raw 0–1 weight can be
remapped into the value range that property needs. One field can drive several
field-constraints at once by sharing its #id.
Related. Consumes a SpatialField — the same field a material or
tonemap can also read, so one field can tint a surface and drive a property
together. Its GPU-parallel sibling is the sk-simple-point-constraint,
which applies a field weight to every clone of a Cloner at once rather
than to a single node.
constructor(config?: { field: Field; targetProperty: string; map: (weight: number) => number; priority?: number; composite?: CompositeOperation })
Inherited from: Constraint, SkenraAnimatable
— see those pages for inherited members.
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
fieldanimatable |
Field |
— | The field used for evaluation. null when no field is currently |
FieldConstraint |
targetProperty |
string |
— | The target property name. | FieldConstraint |
mapconfig-only |
(weight: number) => number |
— | Maps the normalized field weight to a property value. | FieldConstraintConfig |
priority |
number |
— | Gets the priority for this modifier in the effect stack. | Constraint |
compositeconfig-only |
CompositeOperation |
— | Composite operation for this modifier. | FieldConstraintConfig |
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
targetread-only |
SkenraAnimatable | null |
— | The node this constraint modifies. | Constraint |
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 |
| Method | Description | Declared 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 |
// Scale a sphere by its proximity to a spherical field.
sphere.constrain('field', {
field: proximityField,
targetProperty: 's',
map: (weight) => 5 * weight + 1,
});