MeshVertexPointsSource

← prev index next →

Places one clone at every vertex of a mesh — the way to snap copies of an object exactly onto another shape's points, so the clones trace that shape's wireframe geometry.

Remarks

This is a mesh-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. Unlike the procedural sources — which compute their points from a formula — this one reads its positions from an existing sk-mesh (or any geometry primitive), one point per vertex, and uses each vertex normal to orient the clone. It follows the referenced mesh live: when the mesh regenerates, the clone set updates to match.

Key attributes. mesh references (by #id) the mesh whose vertices become the points; the referenced element is the geometry source, not something drawn at those points. deduplicate (on by default) merges vertices that share a position — meshes split a shared corner into several vertices with different normals to render hard edges, so without merging you would get several clones stacked at every such corner; the merged clone takes the averaged normal. Turn it off to place a clone at every raw vertex.

Related. To scatter clones across a mesh's surface (rather than exactly on its vertices), see sk-mesh-surface-points-source. For placements from an explicit buffer see sk-buffer-points-source; from the GPU see sk-compute-buffer-points-source and sk-custom-wgsl-points-source; from another cloner 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; mesh?: AbstractMeshNode; deduplicate?: boolean; deduplicationStrategy?: VertexDeduplicationStrategy; deduplicationTolerance?: number })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
idconfig-only string Optional element id. MeshVertexPointsSourceConfig
meshanimatableconfig-only AbstractMeshNode The source mesh INSTANCE for the imperative path. MeshVertexPointsSourceConfig
deduplicate boolean true Whether duplicate vertices at the same position are merged. MeshVertexPointsSource
deduplicationStrategyread-only VertexDeduplicationStrategy The deduplication strategy used to merge normals across vertices MeshVertexPointsSource
deduplicationToleranceread-only number 1e-6 The position-comparison tolerance used when deduplicating vertices. MeshVertexPointsSource

Other Properties

PropertyTypeDefaultDescriptionDeclared by
meshNoderead-only AbstractMeshNode The mesh node this source extracts vertices from. MeshVertexPointsSource
pointCountread-only number Number of points (unique vertices) in the mesh. MeshVertexPointsSource
localMatricesread-only Float32Array<ArrayBufferLike> Per-element local matrices materialized from the mesh vertices and normals. MeshVertexPointsSource
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
setMesh(meshNode: AbstractMeshNode, options: MeshVertexPointsSourceConfig = {}): void Programmatic configure API. MeshVertexPointsSource
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 target space, or null if there is no data yet. MeshVertexPointsSource
setWorldReferenceNode(node: WorldReferenceNode | null): void Sets the reference node whose world matrix should be used for transforms. MeshVertexPointsSource
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

// Place clones at sphere vertices (with default deduplication)
const sphere = new Sphere({ id: 'sphere', radius: 2, segments: 2 });
const source = new MeshVertexPointsSource({ mesh: sphere });

// Place clones at cube vertices with custom deduplication strategy
const cube = new Cube({ id: 'cube', size: 2 });
const source = new MeshVertexPointsSource({
    mesh: cube,
    deduplicate: true,
    deduplicationStrategy: myCustomStrategy
});

// Disable deduplication to get all raw vertices
const source = new MeshVertexPointsSource({ mesh, deduplicate: false });