UVSpherePointsSource

← prev index next →

Scatters clones over a latitude/longitude sphere — the way to array copies on a ball in regular rings, or over just its top hemisphere for a dome.

Remarks

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

Key attributes. radius sets the sphere's size. lat-segments sets how many horizontal rings run from pole to pole (the vertical resolution) and lon-segments how many points sit around each ring (how many meridians) — together they lay down the regular grid of parallels and meridians that distinguishes this from the sk-sphere-points-source spiral. hemisphere keeps only the top half, giving a dome instead of a full ball. center offsets the sphere from the origin. Points are emitted once each — a single pole point, no seam duplicates.

Related. For the most even full-sphere coverage (no pole crowding) use sk-sphere-points-source; for a geodesic subdivision use sk-platonic-sphere-points-source. Related closed surfaces include sk-capsule-points-source and sk-torus-points-source. To scatter over an arbitrary object's surface rather than an analytic sphere, see sk-mesh-surface-points-source. Its host is always a sk-cloner.

Constructor

constructor(config?: { radius?: number; latSegments?: number; lonSegments?: number; hemisphere?: boolean; center?: [number, number, number] })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
radius number 1.0 Sphere radius. UVSpherePointsSource
latSegments number 8 Number of latitude segments. UVSpherePointsSource
lonSegments number 16 Number of longitude segments. UVSpherePointsSource
hemisphereanimatable boolean false Whether this generates only the top hemisphere. UVSpherePointsSource
center [number, number, number] [0, 0, 0] Sphere center position. UVSpherePointsSource

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 UV sphere
const sphereSource = new UVSpherePointsSource({
    radius: 1.0,
    latSegments: 16,
    lonSegments: 32
});

// Create points on a hemisphere
const hemiSource = new UVSpherePointsSource({
    radius: 1.0,
    latSegments: 16,
    lonSegments: 32,
    hemisphere: true
});