BufferPointsSource

← prev index next →

Places clones at an explicit list of transforms you supply — the way to array copies at hand-authored or externally computed positions when no procedural shape fits.

Remarks

This is the raw data-driven 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. Where the procedural sources generate their points from a formula, this one takes them verbatim from a buffer of placement matrices you provide — one 4×4 matrix per clone, carrying its full position, rotation, and scale — which is the escape hatch for imported layouts or CPU-generated distributions that no built-in shape captures.

Key attributes. local-matrices is the placement buffer: a list of column-major mat4x4 frames (16 numbers each), one per clone, given as an array of 16-number arrays. Each matrix's translation column positions that clone; its upper-left basis orients and scales it (an identity basis with a position in the last column places a clone with no rotation). The clone count is simply the number of matrices supplied.

Related. For placements generated on the GPU instead of authored, see sk-compute-buffer-points-source and sk-custom-wgsl-points-source; for placements taken from a mesh see sk-mesh-vertex-points-source and sk-mesh-surface-points-source; for another cloner's output see sk-cloner-points-source. For built-in procedural shapes see sk-grid-points-source and sk-sphere-points-source. Its host is always a sk-cloner.

Constructor

constructor(config?: { id?: string; localMatrices?: Float32Array })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
idconfig-only string Unique identifier for the points source. BufferPointsSourceConfig
localMatrices Float32Array The per-element local matrices (16 floats per element, column-major). BufferPointsSource

Other Properties

PropertyTypeDefaultDescriptionDeclared by
pointCountread-only number 1 Number of points in this source. BufferPointsSource
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
setLocalMatrices(localMatrices: Float32Array): void Replaces the per-element local matrices on this source. Called by the BufferPointsSource
getBoundsInSpace(fullTransform: Float32Array): { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number; } | null Axis-aligned bounding box of the produced points, expressed in the given BufferPointsSource
setWorldReferenceNode(node: WorldReferenceNode | null): void Sets the reference node whose world matrix should be used for transforms. BufferPointsSource
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

import { matrixFromPositions } from '/js/skenra/scene-graph/cloner/local-matrix-packing.js';

// Three clones along X, built from positions.
const matrices = matrixFromPositions(new Float32Array([0, 0, 0, 1, 0, 0, 2, 0, 0]));
const source = new BufferPointsSource({ localMatrices: matrices });