ClonerPointsSource

← prev index next →

Reuses another cloner's placements as its own points — the way to stamp several different templates at one shared set of positions without recomputing them.

Remarks

This is the shared-positions 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. Instead of a formula or a mesh, this source takes its positions from a source cloner's already-computed transforms — so the consuming cloner places exactly as many instances as the source produced (its count is the source's count, not a product of the two). Its value is reuse: several consuming cloners can reference the same source and share that one transform buffer, so drawing K different templates at N shared positions costs N+K point sets of memory, not K independently-recomputed copies of N.

This is distinct from multiplicative nesting — placing a whole cloned group at every point of an outer cloner for an N×M "grid of grids". That is a separate mechanism: DOM-nest one <sk-cloner> inside another, each with its OWN points-source, and their counts multiply (see sk-cloner).

Key attributes. cloner references (by #id) the source cloner whose output supplies the points. That source cloner is typically declared with mode="object" — it just produces the set of positions and carries no visible template of its own — while each consuming cloner holds the template that gets stamped at those positions.

Related. For points that come from a mesh see sk-mesh-vertex-points-source and sk-mesh-surface-points-source; from an explicit buffer see sk-buffer-points-source; from the GPU see sk-compute-buffer-points-source and sk-custom-wgsl-points-source. For the built-in procedural shapes that commonly drive the source cloner, see sk-grid-points-source and sk-sphere-points-source. Its host — and the source it references — are both a sk-cloner.

Constructor

constructor(config?: { id?: string; cloner?: Cloner })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
idconfig-only string Optional element id. ClonerPointsSourceConfig
cloneranimatableconfig-only Cloner Optional parent Cloner instance whose output provides points. ClonerPointsSourceConfig

Other Properties

PropertyTypeDefaultDescriptionDeclared by
typeread-only PointsSourceType "hybrid" The type of this points source. ClonerPointsSource
parentClonerread-only Cloner The parent Cloner providing instance transforms. ClonerPointsSource
pointCountread-only number Number of points provided by this source. ClonerPointsSource
localMatricesread-only Float32Array<ArrayBufferLike> | null CPU-side local matrices. ClonerPointsSource
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
setCloner(parentCloner: Cloner): void Programmatic configure API. ClonerPointsSource
getTotalInstanceCount(): number Returns the total instance count for this points source. ClonerPointsSource
getBoundsInSpace(fullTransform: Float32Array): { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number; } | null Axis-aligned bounding box of the parent cloner's instances, expressed in the given target space, or null if there is no data yet. ClonerPointsSource
setWorldReferenceNode(node: WorldReferenceNode | null): void Sets the reference node whose world matrix should be used for transforms. ClonerPointsSource
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

// Source cloner: a lattice of positions, no visible template of its own.
const lattice = new Cloner({ id: 'lattice', mode: 'object',
    pointsSource: new GridPointsSource({
        dimensions: [10, 10, 10],
        spacing: [2, 2, 2]
    })
});

// Two consuming cloners share the SAME 1000 positions — each stamps its own
// template. Both read the lattice's one transform buffer (N+K memory).
const cubes = new Cloner({ id: 'cubes',
    pointsSource: new ClonerPointsSource({ cloner: lattice }) });
cubes.appendChild(cubeTemplate);

const spheres = new Cloner({ id: 'spheres',
    pointsSource: new ClonerPointsSource({ cloner: lattice }) });
spheres.appendChild(sphereTemplate);

// Each consuming cloner draws 1000 instances (NOT 1000 × 1000).