TrailSplineSource

← prev index next →

Draws the rolling trail left behind a moving node — the way to render a wake, comet tail, or motion streak that follows an object and fades out over the last N positions it visited.

Remarks

This is the motion-driven 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. Unlike the static sources, its curve is not authored — it is fed one new head position at a time. Each head position beyond a small distance threshold is prepended to a fixed-capacity ring buffer (oldest trimmed at the far end), and the buffer is re-evaluated as a Catmull-Rom curve, so the spline is a smooth polyline through the object's recent path. Every vertex has width 1.0; taper the trail with the host spline's width profile.

Key attributes. max-points is the trail length — the ring-buffer capacity (minimum 2); a larger value keeps a longer tail. head-pos is the current head position in world space and is what actually grows the trail: it is animatable, but the usual wiring is a child sk-follow-constraint mapping a moving node's pos onto this source's head-pos, so the trail tracks that node automatically. 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 trail 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-morph-spline-source, and the GPU sources sk-compute-buffer-spline-source / sk-custom-wgsl-spline-source. It is typically driven by a sk-follow-constraint; its host is a sk-spline, whose curve then draws with a stroke paint or carries an sk-align-to-spline-constraint.

Constructor

constructor(config?: { maxPoints: number })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
maxPoints number Maximum number of control points in the trail (minimum 2). TrailSplineSource

Other Properties

PropertyTypeDefaultDescriptionDeclared by
pointCountread-only number Cloner-facing point count. Tracks distribution: equals TrailSplineSource
localMatricesread-only Float32Array<ArrayBufferLike> | null Per-vertex [ T·width | N·width | B·width | P ] frame matrices, or null until data is available. TrailSplineSource
distribution SplineDistributionMode How clone points are placed along the trail — at the control points, at TrailSplineSource
distributionCount number The number of evenly spaced points to place when the distribution is TrailSplineSource
headPosanimatable Point3D [0, 0, 0] The head position of the trail (world space). TrailSplineSource
controlPointCountread-only number The number of control points currently in the buffer. TrailSplineSource
vertexCountread-only number Number of vertices in the linearized polyline. TrailSplineSource
isValidread-only boolean Whether the source initialized successfully and holds at least one vertex. TrailSplineSource
isClosedread-only boolean false Whether the spline forms a closed loop (last vertex joins the first). TrailSplineSource
polylineread-only readonly Readonly<SplinePoint>[] [] Read-only view of the internal 3D polyline points. TrailSplineSource
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
pointAt(t: number): SplinePoint | null Point on the trail at normalized arc-length position t in [0, 1], or null if empty. TrailSplineSource
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. TrailSplineSource
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 trailSource = new TrailSplineSource({ maxPoints: 64 });
const trailSpline = new Spline({ id: 'trail', source: trailSource });

// Link to a moving object
trailSource.constrain('follow', {
    source: sphere,
    mappings: [{ source: 'pos', target: 'headPos' }],
});