CapsulePointsSource

← prev index next →

Scatters clones over the surface of a capsule — the way to array copies up a pill shape: a cylinder closed off by a rounded hemisphere at each end.

Remarks

This is the capsule-surface member of the points-source family: 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 that gets cloned at each point. Because the positions are generated procedurally in the shader (see ShaderFunctionPointsSource), a finely subdivided capsule costs the same handful of parameters as a coarse one.

Key attributes. radius is the capsule's tube and cap radius (its thickness), and height is the length of the straight cylindrical middle between the two rounded ends — the overall length is height plus a full radius cap at each end. height-segments sets how many rings run up the cylindrical body, cap-segments how many latitude rings make up each rounded cap (their roundness), and rotation-segments how many points sit around each ring (the angular resolution). orientation is the axis the capsule extends along — one of +x, -x, +y, -y, +z, -z. center offsets it from the origin. Only unique points are emitted — a single pole at each tip, no seam duplicates.

Related. For flat-capped tubes and cones use sk-cone-points-source; for a full donut use sk-torus-points-source, and for a plain ball use sk-sphere-points-source or sk-uv-sphere-points-source. To scatter over an arbitrary object's surface rather than an analytic capsule, see sk-mesh-surface-points-source. Its host is always a sk-cloner.

Constructor

constructor(config?: { radius?: number; height?: number; heightSegments?: number; capSegments?: number; rotationSegments?: number; orientation?: AxisOrientation; center?: [number, number, number] })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
radius number 1.0 Radius of the capsule. CapsulePointsSource
height number 1.0 Height of the cylindrical portion. CapsulePointsSource
heightSegments number 1 Number of height segments. CapsulePointsSource
capSegments number 4 Number of cap segments. CapsulePointsSource
rotationSegments number 8 Number of rotation segments. CapsulePointsSource
orientationanimatable AxisOrientation "+y" Axis along which the capsule extends. CapsulePointsSource
center [number, number, number] [0, 0, 0] Capsule center position. CapsulePointsSource

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

Example

// Create points on a standard capsule
const capsuleSource = new CapsulePointsSource({
    radius: 1.0,
    height: 2.0,
    heightSegments: 1,
    capSegments: 4,
    rotationSegments: 8
});

// Create points on a tall thin capsule
const pillSource = new CapsulePointsSource({
    radius: 0.3,
    height: 2.0,
    capSegments: 8,
    rotationSegments: 16
});