SimplePointConstraint

← prev index next →

Displaces every point of a host by a per-point amount that follows a field's weight — translating, scaling, and rotating a cloner's clones, or displacing a mesh or spline's vertices — the general-purpose way to sculpt field-by-field.

Remarks

This is the general-purpose member of the PointConstraint family: like every point-constraint it runs a GPU kernel over all of its host's points at once — the clones of a sk-cloner, or the vertices of a mesh or spline — so it stays cheap at huge point counts. It samples a SpatialField at each point to get a weight in [0, 1], then applies animatable transform deltas scaled by that weight — with no field, the deltas apply at full strength everywhere.

Key attributes. field names the SpatialField to sample by #id. Each clone is then displaced by animatable deltas scaled by its field weight: translate dx/dy/dz (added × weight) and scale dsx/dsy/dsz (columns scaled by 1 + delta × weight) are the workhorses. Also available are rotation dh/dp/db (Euler heading / pitch / bank × weight), position-scale sx/sy/sz (push each point toward or away from the world origin, or a pivotNode when one is set), and field-weight-range, which remaps the raw weight before it scales the deltas. All deltas default to no-effect, so set only the ones you want — no mapping expressions needed, and every delta is animatable. On a cloner every delta applies; on a mesh or spline host, whose output carries only vertex positions, the position deltas (dx/dy/dz, sx/sy/sz) take effect while the per-clone rotate/scale deltas have no per-vertex slot.

Related. Sibling point-constraints specialise the kernel: sk-radial-push-point-constraint pushes clones from an origin, sk-target-at-point-constraint aims each clone at a node, and sk-custom-wgsl-point-constraint runs an arbitrary WGSL kernel. Its single-node CPU cousin is sk-field-constraint.

Constructor

constructor(config?: { field?: Field; dx?: number; dy?: number; dz?: number; dsx?: number; dsy?: number; dsz?: number; dh?: number; dp?: number; db?: number; sx?: number; sy?: number; sz?: number; dQuaternion?: Quaternion; pivotNode?: SceneNode | null; fieldWeightRange?: readonly [number, number] })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
fieldanimatableread-only Field The field used by this point constraint, if any. PointConstraint
dxanimatable number 0 Position delta X. SimplePointConstraint
dyanimatable number 0 Position delta Y. SimplePointConstraint
dzanimatable number 0 Position delta Z. SimplePointConstraint
dsxanimatable number 0 Scale delta X (additive: final scale factor = 1 + dsx × weight). SimplePointConstraint
dsyanimatable number 0 Scale delta Y (additive: final scale factor = 1 + dsy × weight). SimplePointConstraint
dszanimatable number 0 Scale delta Z (additive: final scale factor = 1 + dsz × weight). SimplePointConstraint
dhanimatable number 0 Rotation heading delta (radians). SimplePointConstraint
dpanimatable number 0 Rotation pitch delta (radians). SimplePointConstraint
dbanimatable number 0 Rotation bank delta (radians). SimplePointConstraint
sxanimatable number 1 Multiplicative position scale X (scale = 1 + (sx - 1) × weight). SimplePointConstraint
syanimatable number 1 Multiplicative position scale Y (scale = 1 + (sy - 1) × weight). SimplePointConstraint
szanimatable number 1 Multiplicative position scale Z (scale = 1 + (sz - 1) × weight). SimplePointConstraint
dQuaternionanimatable Quaternion Rotation delta as quaternion. Slerped by field weight in the compute shader. SimplePointConstraint
pivotNode SceneNode | null Optional SceneNode whose world position defines the pivot point for position scaling. SimplePointConstraint
fieldWeightRangeanimatable readonly [number, number] The [lo, hi] range the normalized field weight maps onto. PointConstraint

Other Properties

PropertyTypeDefaultDescriptionDeclared by
targetread-only ConstrainablePointsHost | null The target host this modifier applies to, or null before PointConstraint
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 modifier = new SimplePointConstraint({
    field: sphericalField,
    dy: 5,   // translate up to 5 units up where field weight = 1
    dsx: 2,  // grow X up to 3× (1 + 2) where field weight = 1
});
cloner.addPointConstraint(modifier);