Generates a spline's polyline from inline WGSL you write — the way to describe a curve as a per-vertex formula (a parametric knot, a rose curve, a live time-varying shape) and have the GPU evaluate it every frame.
Declarative element:
<sk-custom-wgsl-spline-source>
Not on the sk.* global — construct via the declarative element or a module import.
This is the WGSL-authored member of the spline-source family: a spline-source
supplies the curve geometry for a AbstractSpline, so it lives as the
single geometry child of a sk-spline. You write only
fn getSplineVertex(index: u32) -> SplineVertex; the source runs its own
generation dispatch (one GPU thread per vertex, engine-owned fn main) into a
polyline the renderer consumes through the shared zero-copy + readback path.
A kernel that reads params.time (scene time in milliseconds) re-generates
every frame; a static kernel dispatches once per change. CPU-side queries
(pointAt, bounds, cloner matrices) come from the readback path and are null
until the first readback — as with sk-compute-buffer-spline-source.
Key attributes. vertex-count is how many polyline vertices to generate —
getSplineVertex is called once per index 0 … vertex-count-1. wgsl is the
inline kernel body; src loads the WGSL from an external file instead (and,
like <script src>, wins over inline wgsl), with on-load / on-error
handlers for the fetch. is-closed declares the generated polyline a closed
loop. Author parameters are `sk-wgsl-uniform children (and the vec/array
variants), read inside the kernel via the generated skUniform_<name>()
accessors; changing a uniform value re-uploads and re-dispatches without a
pipeline rebuild. Like every spline-source it also carries the family's
distribution / distribution-count` controls: a spline-source is itself a
points-source, so a sk-cloner given one places clones along the curve,
and these controls choose how it is sampled into those positions.
Related. It is one input modality of the spline-source family alongside
sk-svg-spline-source, sk-points-spline-source,
sk-trail-spline-source, sk-morph-spline-source, and its GPU
sibling sk-compute-buffer-spline-source (which reads a separate
sk-compute-node producer rather than owning the kernel). It parameterizes
the kernel with sk-wgsl-uniform children; its host is a
sk-spline, whose curve then draws with a stroke paint or carries an
sk-align-to-spline-constraint.
constructor(config?: { vertexCount: number; wgsl?: string; src?: string; isClosed?: boolean })
Inherited from: GPUPolylineSplineSource, SkenraAnimatable
— see those pages for inherited members.
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
vertexCount |
number |
1 |
Number of polyline vertices to generate. Setting it is structural | CustomWGSLSplineSource |
wgsl |
string |
"" |
Inline WGSL vertex function. Ignored while src is set. |
CustomWGSLSplineSource |
src |
string |
— | External WGSL source URL (the src attribute), or null if none. |
CustomWGSLSplineSource |
isClosedanimatable |
boolean |
false |
Whether the spline forms a closed loop (last vertex joins the first). | GPUPolylineSplineSource |
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
configuredVertexCountread-only |
number |
— | The configured vertex count, independent of the inert state (for | CustomWGSLSplineSource |
hasEffectiveWGSLread-only |
boolean |
— | Whether usable effective WGSL is available. false while a src is |
CustomWGSLSplineSource |
pointCountread-only |
number |
— | Cloner-facing point count. Tracks distribution; for a GPU source |
GPUPolylineSplineSource |
localMatricesread-only |
Float32Array<ArrayBufferLike> | null |
— | Per-vertex [ T·width | N·width | B·width | P ] frame matrices, or null until data is available. |
GPUPolylineSplineSource |
distributionanimatable |
SplineDistributionMode |
— | How clone points are placed along the spline — at the control points, at | GPUPolylineSplineSource |
distributionCount |
number |
— | The number of evenly spaced points to place when the distribution is | GPUPolylineSplineSource |
isValidread-only |
boolean |
— | Whether the source initialized successfully and holds at least one vertex. | GPUPolylineSplineSource |
polylineread-only |
readonly Readonly<SplinePoint>[] |
[] |
Read-only view of the internal 3D polyline points. | GPUPolylineSplineSource |
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 |
|---|---|---|
addUniform(name: string, value: number): WGSLUniform |
Imperative twin of authoring a <sk-wgsl-uniform> child. |
CustomWGSLSplineSource |
addF32ArrayUniform(name: string, values: readonly number[]): WGSLF32ArrayUniform |
Imperative twin of authoring a <sk-wgsl-f32-array-uniform> child. |
CustomWGSLSplineSource |
addVec2Uniform(name: string, x: number, y: number): WGSLVec2Uniform |
Imperative twin of authoring a <sk-wgsl-vec2-uniform> child. |
CustomWGSLSplineSource |
addVec3Uniform(name: string, x: number, y: number, z: number): WGSLVec3Uniform |
Imperative twin of authoring a <sk-wgsl-vec3-uniform> child. |
CustomWGSLSplineSource |
addVec4Uniform(name: string, x: number, y: number, z: number, w: number): WGSLVec4Uniform |
Imperative twin of authoring a <sk-wgsl-vec4-uniform> child. |
CustomWGSLSplineSource |
addColorUniform(name: string, color: ColorInput): WGSLColorUniform |
Imperative twin of authoring a <sk-wgsl-color-uniform> child. |
CustomWGSLSplineSource |
pointAt(t: number): SplinePoint | null |
Returns a point on the spline at normalized parameter t. | GPUPolylineSplineSource |
getBoundsInSpace(fullTransform: Float32Array): PolylineBounds | null |
Axis-aligned bounding box of the produced points, expressed in the given target space, or null if there is no data yet. |
GPUPolylineSplineSource |
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 |