Selection

← prev index next →

Names a subset of a mesh's topology — the faces (triangles), and later edges or points, that authoring surfaces target.

Remarks

A <sk-selection> is a selection: a non-rendered, id-addressable data child of a mesh (a sk-cube, sk-sphere, sk-mesh, …) that names a subset of that mesh's topology, the way USD's GeomSubset names a subset of a mesh's faces. It renders nothing itself; instead a consumer — a sk-surface-paint via its selection attribute (and points-sources in a later slice) — references it to restrict what it paints or samples to exactly those elements. It sits as a child of the mesh it addresses, and resolves against that mesh's element-index space.

Key attributes. selection-type is the kind of element addressed — face (a triangle, the default and the only kind resolved today), edge, or point (the type name is reserved as the element discriminant). A leaf selection lists explicit indices as a range list ("0-1 4 6-7" — inclusive ranges and singletons over the mesh's faces; the empty string is the empty set, not "all"). A composite selection instead composes other selections via include/exclude, optionally filtered by a field above a threshold — these compositional forms are authored here but resolved in later slices. A selection carries a global id (so it is referenceable as #id) and/or a mesh-local name; a #id reference must point at a selection under the SAME mesh.

Related. Its parent is always a mesh (AbstractMeshNode); an unresolved or invalid selection resolves inert (draws/samples nothing) and never falls back to the whole mesh. Out-of-range or malformed indices are diagnosed, not silently clipped.

Constructor

constructor(config?: { id?: string; name?: string; selectionType?: SelectionType; indices?: string; include?: string; exclude?: string; field?: string; threshold?: number })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
idconfig-only string This selection's own unique identifier, for #id references. SelectionConfig
name string "" The mesh-local registry name for bare-token references. Selection
selectionType SelectionType "face" The kind of element addressed (face | edge | point). Selection
indices string "" The raw authored indices range-list string (leaf form). Selection
include string "" The raw authored include mixed-token list (composite form). Selection
exclude string "" The raw authored exclude mixed-token list (composite form). Selection
field string "" The field reference (#id) for the intersection filter. Selection
threshold number 0.5 The field-weight threshold an element must exceed to remain selected. Selection

Other Properties

PropertyTypeDefaultDescriptionDeclared by
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
resolve(): ResolvedSelection Resolves this selection against its owning mesh to a ResolvedSelection. Selection
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

const cube = new Cube({ size: 2, id: 'die' });
const accent = new Selection({ selectionType: 'face', indices: '4-7', id: 'accent' });
cube.appendChild(accent);