SpherePointsSource

← prev index next →

Scatters clones evenly over the surface of a sphere using a Fibonacci spiral — the way to spread copies across a ball with near-uniform spacing and no pole clustering.

Remarks

This is the sphere-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 million-point sphere costs the same handful of parameters as a hundred-point one.

Key attributes. count sets how many points are placed on the surface — the total clone count. radius sets the sphere's size; the points sit on that spherical shell. center offsets the sphere from the origin (defaults to the origin). distribution selects the placement algorithm — fibonacci (the only value, and the default) uses the golden-angle spiral, which gives the most even coverage and avoids the crowding at the poles that a latitude/longitude grid produces.

Related. For a UV (latitude/longitude) sphere — regular rings and the option of a single hemisphere — use sk-uv-sphere-points-source; for a geodesic subdivision use sk-platonic-sphere-points-source. Other closed surfaces include sk-cube-points-source, sk-capsule-points-source, and sk-torus-points-source; sk-grid-points-source fills a volume instead. To scatter over an arbitrary object's surface rather than an analytic shape, see sk-mesh-surface-points-source. Its host is always a sk-cloner.

Constructor

constructor(config?: { count: number; radius?: number; center?: [number, number, number]; distribution?: SphereDistribution })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
count number 1 Number of points (alias for pointCount). SpherePointsSource
radius number 1.0 Sphere radius. SpherePointsSource
center [number, number, number] [0, 0, 0] Sphere center position. SpherePointsSource
distribution SphereDistribution "fibonacci" Distribution method for points. SpherePointsSource

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 500 evenly distributed points on a unit sphere
const sphereSource = new SpherePointsSource({
    count: 500,
    radius: 1.0,
    distribution: 'fibonacci'
});

const cloner = new Cloner({ id: 'sphere-cloner',
    pointsSource: sphereSource,
    alignToNormal: true // Cubes point outward from sphere center
});
cloner.appendChild(cubeNode);