Displaces every point of a host with a GPU kernel you write inline in WGSL — the escape hatch for any per-point deformation the built-in point-constraints don't cover.
Declarative element:
<sk-custom-wgsl-point-constraint>
Not on the sk.* global — construct via the declarative element or a module import.
This is the fully-programmable member of the PointConstraint family: like
every point-constraint it runs a GPU kernel over all of a host's points at once (a
mesh, a spline, or a sk-cloner). What is unique here is that you supply
the kernel body: the engine owns the scaffold (world-space sampling, the
field-weight range, per-target buffer I/O) and calls your computeDisplacement()
for each point, plus an optional computeGradient() when the result should also
recompute normals.
Key attributes. wgsl holds the kernel source — at minimum a
computeDisplacement(worldXZ) function returning a world-space offset. Its tunable
parameters come from sk-wgsl-uniform elements attached to it, read inside
the kernel through generated skUniform_<name>() accessors, so each is independently
animatable. affects-normals turns on the computeGradient() path so shading and
cloner orientation follow the deformed surface. max-displacement reports the
kernel's worst-case travel so bounds stay correct. It is the per-point cousin of
sk-compute-node, which produces whole output buffers that
compute-buffer sources consume by reference.
Related. For a ready-made wave there is
sk-ocean-displacement-point-constraint; for field-weighted
translate/scale/rotate there is sk-simple-point-constraint. Its single-node
CPU analogue is sk-field-constraint.
constructor(config?: { wgsl?: string; src?: string; affectsNormals?: boolean; maxDisplacement?: number; timeDependent?: boolean; show?: boolean; fieldWeightRange?: readonly [number, number] })
Inherited from: PointConstraint, SkenraAnimatable
— see those pages for inherited members.
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
wgsl |
string |
"" |
Inline WGSL shader code. Ignored while src is set. |
CustomWGSLPointConstraint |
src |
string |
— | External WGSL source URL (the src attribute), or null if none. |
CustomWGSLPointConstraint |
affectsNormalsread-only |
boolean |
false |
Whether the kernel recomputes normals / cloner orientation from the | CustomWGSLPointConstraint |
maxDisplacement |
number |
0 |
Analytic upper-bound displacement magnitude (world units), used to | CustomWGSLPointConstraint |
timeDependent |
boolean |
false |
Whether the kernel must be re-dispatched every frame. | CustomWGSLPointConstraint |
show |
boolean |
true |
Whether the constraint is active. | CustomWGSLPointConstraint |
fieldWeightRangeanimatable |
readonly [number, number] |
— | The [lo, hi] range the normalized field weight maps onto. |
PointConstraint |
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
hasEffectiveWGSLread-only |
boolean |
— | Whether usable effective WGSL is available. false while a src is set |
CustomWGSLPointConstraint |
targetread-only |
ConstrainablePointsHost | null |
— | The target host this modifier applies to, or null before |
PointConstraint |
fieldread-only |
Field | null |
— | The field used by this point constraint, if any. | 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 |
| Method | Description | Declared by |
|---|---|---|
configure(config: CustomWGSLPointConstraintConfig): void |
Declarative configuration API — sets the WGSL + params after the | CustomWGSLPointConstraint |
addUniform(name: string, value: number): WGSLUniform |
Imperative twin of authoring a <sk-wgsl-uniform> child. |
CustomWGSLPointConstraint |
addF32ArrayUniform(name: string, values: readonly number[]): WGSLF32ArrayUniform |
Imperative twin of authoring a <sk-wgsl-f32-array-uniform> child. |
CustomWGSLPointConstraint |
addVec2Uniform(name: string, x: number, y: number): WGSLVec2Uniform |
Imperative twin of authoring a <sk-wgsl-vec2-uniform> child. |
CustomWGSLPointConstraint |
addVec3Uniform(name: string, x: number, y: number, z: number): WGSLVec3Uniform |
Imperative twin of authoring a <sk-wgsl-vec3-uniform> child. |
CustomWGSLPointConstraint |
addVec4Uniform(name: string, x: number, y: number, z: number, w: number): WGSLVec4Uniform |
Imperative twin of authoring a <sk-wgsl-vec4-uniform> child. |
CustomWGSLPointConstraint |
addColorUniform(name: string, color: ColorInput): WGSLColorUniform |
Imperative twin of authoring a <sk-wgsl-color-uniform> child. |
CustomWGSLPointConstraint |
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 |
const sine = new CustomWGSLPointConstraint({
wgsl: SINE_WAVE_WGSL, // reads skUniform_amplitude() etc.
maxDisplacement: 50,
affectsNormals: true,
});
plane.addPointConstraint(sine);