Generates clone placements from your own WGSL — a procedural point distribution written as a GPU function, for shapes no built-in source covers (a helix, a gyroid, a formula-defined swarm).
Declarative element:
<sk-custom-wgsl-points-source>
Global: available as sk.CustomWGSLPointsSource inside a scene <script>.
This is the fully custom member of the points-source family (see
ShaderFunctionPointsSource): a points-source defines the set of
positions at which a sk-cloner places copies of its content, so it lives
as a child of a <sk-cloner> and the cloner's other child is the template
cloned at each point. Where the built-in procedural sources encode a fixed shape
(sk-grid-points-source, sk-sphere-points-source, …), this one
runs an author-supplied getPointAtIndex(index) on the GPU, so every point's
local transform is whatever the WGSL computes — and, like the other procedural
sources, the placements never touch the CPU, so even large counts stay cheap.
Key attributes. point-count is how many points to generate — the WGSL is
evaluated once per index from 0 to point-count − 1. wgsl is the inline
shader body; it must define fn getPointAtIndex(index: u32) -> PointData and
set point.localMatrix (column 3 is the position, the +Y axis is the surface
normal). src loads that WGSL from an external .wgsl file instead, taking
precedence over inline wgsl (mirroring <script src>); on-load / on-error
fire when a src fetch resolves or fails. Author parameters are supplied as
<sk-wgsl-uniform> children and read in WGSL via the generated
skUniform_<name>() accessors.
Related. For placements a GPU compute pass produces into a buffer rather
than a per-index function, see sk-compute-buffer-points-source (which
pairs with a sk-compute-node). For built-in procedural shapes see
sk-grid-points-source, sk-sphere-points-source, and
sk-platonic-sphere-points-source; for object/data-driven placements see
sk-mesh-vertex-points-source, sk-mesh-surface-points-source,
sk-buffer-points-source, and sk-cloner-points-source. Its host
is always a sk-cloner.
constructor(config?: { pointCount: number; wgsl?: string; src?: string })
Inherited from: ShaderFunctionPointsSource, SkenraAnimatable
— see those pages for inherited members.
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
pointCount |
number |
1 |
Number of points to generate. | CustomWGSLPointsSource |
wgsl |
string |
"" |
Inline WGSL shader code. Ignored while src is set. |
CustomWGSLPointsSource |
src |
string |
— | External WGSL source URL (the src attribute), or null if none. |
CustomWGSLPointsSource |
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
configuredPointCountread-only |
number |
— | The configured point count, independent of the inert state. | CustomWGSLPointsSource |
hasEffectiveWGSLread-only |
boolean |
— | Whether usable effective WGSL is available. false while a src is set |
CustomWGSLPointsSource |
localMatricesread-only |
Float32Array<ArrayBufferLike> | null |
— | CPU-side local matrices. | ShaderFunctionPointsSource |
typeread-only |
PointsSourceType |
"shader-function" |
The type of this points source. | ShaderFunctionPointsSource |
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: CustomWGSLPointsSourceConfig): void |
Declarative configuration API. | CustomWGSLPointsSource |
addUniform(name: string, value: number): WGSLUniform |
Imperative twin of authoring a <sk-wgsl-uniform> child. |
CustomWGSLPointsSource |
addF32ArrayUniform(name: string, values: readonly number[]): WGSLF32ArrayUniform |
Imperative twin of authoring a <sk-wgsl-f32-array-uniform> child. |
CustomWGSLPointsSource |
addVec2Uniform(name: string, x: number, y: number): WGSLVec2Uniform |
Imperative twin of authoring a <sk-wgsl-vec2-uniform> child. |
CustomWGSLPointsSource |
addVec3Uniform(name: string, x: number, y: number, z: number): WGSLVec3Uniform |
Imperative twin of authoring a <sk-wgsl-vec3-uniform> child. |
CustomWGSLPointsSource |
addVec4Uniform(name: string, x: number, y: number, z: number, w: number): WGSLVec4Uniform |
Imperative twin of authoring a <sk-wgsl-vec4-uniform> child. |
CustomWGSLPointsSource |
addColorUniform(name: string, color: ColorInput): WGSLColorUniform |
Imperative twin of authoring a <sk-wgsl-color-uniform> child. |
CustomWGSLPointsSource |
getBoundsInSpace(fullTransform: Float32Array): { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number; } | null |
Computes the AABB in target space by transforming local bounds corners. | ShaderFunctionPointsSource |
setWorldReferenceNode(node: WorldReferenceNode | null): void |
Sets the reference node whose world matrix should be used for transforms. | ShaderFunctionPointsSource |
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 helixSource = new CustomWGSLPointsSource({
pointCount: 200,
wgsl: `
fn getPointAtIndex(index: u32) -> PointData {
var point: PointData;
let t = f32(index) / skUniform_count();
let angle = t * 6.283 * 4.0;
let pos = vec3<f32>(cos(angle) * skUniform_radius(), t * skUniform_pitch(), sin(angle) * skUniform_radius());
// Identity basis → +Y surface normal; position in column 3.
point.localMatrix = mat4x4<f32>(
vec4<f32>(1.0, 0.0, 0.0, 0.0),
vec4<f32>(0.0, 1.0, 0.0, 0.0),
vec4<f32>(0.0, 0.0, 1.0, 0.0),
vec4<f32>(pos, 1.0)
);
return point;
}
`,
});
// Parameters are <sk-wgsl-uniform> children (count/radius/pitch).