ShaderFunctionPointsSource

← prev index next →

The base concept for a points-source: the set of positions at which a Cloner places copies of its content.

Remarks

A points-source answers "where do the clones go?" — the surface of a sphere, a 3D grid, a mesh's vertices, or a GPU-computed distribution. A <sk-cloner> takes one points-source and stamps a copy of its other child content at every point, so a single small template becomes thousands of instances.

Structural relationship. A points-source belongs to a sk-cloner, alongside the content to clone. The procedural members generate their points on the GPU from a few parameters, so even very large counts cost almost no memory: sk-sphere-points-source, sk-cone-points-source, sk-cube-points-source, sk-disc-points-source, sk-plane-points-source, sk-torus-points-source, sk-capsule-points-source, sk-platonic-sphere-points-source, sk-uv-sphere-points-source, sk-grid-points-source, and sk-custom-wgsl-points-source. Other points-sources supply positions from explicit data or other objects: sk-buffer-points-source, sk-cloner-points-source, sk-compute-buffer-points-source, sk-mesh-surface-points-source, and sk-mesh-vertex-points-source.

The procedural members here generate their points on the GPU with O(1) memory, so counts of 100K–1M+ instances stay cheap; a subclass supplies the point count and uniform parameters and pairs them with a WGSL getPointAtIndex(index) function that returns each clone's local transform.

The example clones a small sphere across a 10×10 grid of points.

Abstract base class — not instantiated directly. Construct one of its concrete subclasses; this class contributes the members below to them.

Properties

Other Properties

PropertyTypeDefaultDescriptionDeclared by
pointCountread-only number Number of points provided by this source. ShaderFunctionPointsSource
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

Methods

MethodDescriptionDeclared by
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

Serve these docs to run the live example. WebGPU needs a secure context — open this page via grunt serve rather than double-clicking the file. The Markup tab works from disk.