Names a subset of a mesh's topology — the faces (triangles), and later edges or points, that authoring surfaces target.
JavaScript API:
Selection
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.
Serve these docs to run the live example.
WebGPU needs a secure context — open this page via grunt serve
rather than double-clicking the file. The Markup tab works from disk.
<!-- A cube rendered as a die: each <sk-selection> names one face of a size-2
cube as a contiguous pair of triangles (a face is 2 triangles, emitted in
+X, -X, +Y, -Y, +Z, -Z order), and a selection-bound <sk-surface-paint>
fills that face with its own colour — six materials on ONE mesh, no per-face
child geometry. Each selection parses, validates its indices against the
cube's triangle count, and registers on the mesh; the paint's
selection="#id" resolves to exactly those triangles at draw time. -->
<sk-scene>
<sk-directional-light p="42deg" h="25deg" intensity="1.0"></sk-directional-light>
<sk-ambient-light intensity="0.4"></sk-ambient-light>
<sk-plain-material id="pips1" base-color="crimson"></sk-plain-material>
<sk-plain-material id="pips2" base-color="goldenrod"></sk-plain-material>
<sk-plain-material id="pips3" base-color="seagreen"></sk-plain-material>
<sk-plain-material id="pips4" base-color="steelblue"></sk-plain-material>
<sk-plain-material id="pips5" base-color="darkorange"></sk-plain-material>
<sk-plain-material id="pips6" base-color="rebeccapurple"></sk-plain-material>
<sk-cube size="2">
<sk-selection id="die-right" selection-type="face" indices="0-1"></sk-selection>
<sk-selection id="die-left" selection-type="face" indices="2-3"></sk-selection>
<sk-selection id="die-top" selection-type="face" indices="4-5"></sk-selection>
<sk-selection id="die-bottom" selection-type="face" indices="6-7"></sk-selection>
<sk-selection id="die-front" selection-type="face" indices="8-9"></sk-selection>
<sk-selection id="die-back" selection-type="face" indices="10-11"></sk-selection>
<sk-surface-paint selection="#die-top" material="#pips1"></sk-surface-paint>
<sk-surface-paint selection="#die-bottom" material="#pips6"></sk-surface-paint>
<sk-surface-paint selection="#die-front" material="#pips2"></sk-surface-paint>
<sk-surface-paint selection="#die-back" material="#pips5"></sk-surface-paint>
<sk-surface-paint selection="#die-left" material="#pips3"></sk-surface-paint>
<sk-surface-paint selection="#die-right" material="#pips4"></sk-surface-paint>
</sk-cube>
</sk-scene>
| Attribute | Type | Default | Description |
|---|---|---|---|
id |
<id> |
— | The element's unique identifier — the standard HTML global id attribute. |
name |
<string> |
"" |
The mesh-local registry name for bare-token references. |
selection-type |
<selection-type> ("face" | "edge" | "point") |
"face" |
The kind of topology addressed: face (default), edge, or point. |
indices |
<index-range-list> |
"" |
Explicit face indices as a range list ("0-1 4 6-7"); the leaf form. |
include |
<selection-token-list> |
"" |
Selections/names to union (composite form); absent or empty = all. |
exclude |
<selection-token-list> |
"" |
Selections/names to subtract from the base set (composite form). |
field |
<id-ref> |
"" |
A field reference (#id) that intersects the base set as a filter. reference by id |
threshold |
<number> |
0.5 |
The field-weight threshold an element must exceed to remain selected. |