PlatonicSpherePointsSource

← prev index next →

Distributes points very evenly over a sphere by subdividing a platonic solid — the way to scatter copies of an object across a ball with near-uniform spacing (no clustering at the poles).

Remarks

This is a procedural 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. The points come from subdividing a platonic solid and projecting the result onto the sphere, so the coverage stays far more uniform than a latitude/longitude sk-uv-sphere-points-source — and, being generated in the shader, a densely subdivided sphere costs the same few parameters as a coarse one.

Key attributes. solid-type picks the seed polyhedron — tetrahedron (4 base points), octahedron (6), hexahedron (cube, 8), or icosahedron (12) — with icosahedron giving the most uniform triangle distribution and being the usual choice. subdivisions refines the seed: each step splits every triangle into four, so the point count grows sharply (leave at 0 for just the solid's own vertices; 23 gives a dense, smooth sphere). radius sets the sphere size and center its position.

Related. For a sphere addressed by rings and segments instead of even coverage, see sk-uv-sphere-points-source and the general sk-sphere-points-source; other procedural shapes include sk-grid-points-source, sk-disc-points-source, and sk-torus-points-source. For positions taken from data or another object rather than a formula, 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

constructor(config?: { type?: PlatonicSolidType; subdivisions?: number; radius?: number; center?: [number, number, number] })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
typeread-only PlatonicSolidType "shader-function" The type of this points source. ShaderFunctionPointsSource
subdivisions number 0 Number of subdivision iterations. PlatonicSpherePointsSource
radius number 1.0 Sphere radius. PlatonicSpherePointsSource
center [number, number, number] [0, 0, 0] Sphere center position. PlatonicSpherePointsSource

Other Properties

PropertyTypeDefaultDescriptionDeclared by
solidTypeanimatable PlatonicSolidType "icosahedron" Platonic solid type. PlatonicSpherePointsSource
pointCountread-only number Number of points provided by this source. ShaderFunctionPointsSource
localMatricesread-only Float32Array<ArrayBufferLike> | null CPU-side local matrices. 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 an icosphere with 2 subdivisions
const icoSource = new PlatonicSpherePointsSource({
    type: 'icosahedron',
    subdivisions: 2,
    radius: 1.0
});

const cloner = new Cloner({ id: 'ico-cloner',
    pointsSource: icoSource,
    alignToNormal: true
});