CubePointsSource

← prev index next →

Scatters clones over the six faces of a box — the way to array copies along a cube's or rectangular box's shell rather than through its interior.

Remarks

This is the box-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 box costs the same handful of parameters as the bare eight corners.

Key attributes. size sets a uniform edge length for all three axes; use the per-axis size-x / size-y / size-z instead to make a rectangular box. segments sets how finely each face is subdivided (points land on the cell grid of every face): the default 1 places just the eight corners, while higher values fill each face with a grid; use the per-axis segments-x / segments-y / segments-z to subdivide the axes independently. center offsets the box from the origin. Only the unique surface points are emitted — shared edges and corners are never double-counted.

Related. For a solid volume rather than just the shell use sk-grid-points-source; for a single flat face use sk-plane-points-source. Curved closed surfaces include sk-sphere-points-source, sk-capsule-points-source, and sk-torus-points-source. To scatter over an arbitrary object's surface rather than an analytic box, see sk-mesh-surface-points-source. Its host is always a sk-cloner.

Constructor

constructor(config?: { sizeX?: number; sizeY?: number; sizeZ?: number; size?: number; segmentsX?: number; segmentsY?: number; segmentsZ?: number; segments?: number; center?: [number, number, number] })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
sizeX number 2 Size along the X-axis. CubePointsSource
sizeY number 2 Size along the Y-axis. CubePointsSource
sizeZ number 2 Size along the Z-axis. CubePointsSource
sizeconfig-only number Uniform size for all axes (overrides individual sizes if provided). CubePointsSourceConfig
segmentsX number 1 Number of segments along the X-axis. CubePointsSource
segmentsY number 1 Number of segments along the Y-axis. CubePointsSource
segmentsZ number 1 Number of segments along the Z-axis. CubePointsSource
segmentsconfig-only number Uniform segments for all axes (overrides individual segments if provided). CubePointsSourceConfig
center [number, number, number] [0, 0, 0] Cube center position. CubePointsSource

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 for a 2x2x2 cube with default segments (8 corner points)
const cubeSource = new CubePointsSource({ size: 2 });

const cloner = new Cloner({ id: 'cube-cloner',
    pointsSource: cubeSource,
    alignToNormal: true // Clones point outward from cube surface
});
cloner.appendChild(sphereNode);