Skip to content

<polytope-figure>

Scene-space figure: a collection's elements placed as the vertices of a polytope, rendered in WebGL (three.js). It emits a select CustomEvent when a vertex/face is clicked, so a host view can report the picked element back. See the Polytopes field guide for the mathematics.

This element carries the package's one heavier dependency, three, and takes its geometry as properties (fed from JS), so it isn't an attribute-only drop-in like the pure glyphs.

Properties

propertytypemeaning
verticesnumber[][]nD vertex coordinates
edges[number,number][]wireframe edges as vertex-index pairs
cellsCell[] | nullthe face poset (each face's spanning vertex indices, dim, rank, label)
labelsstring[]per-vertex labels
facesnumber[][]filled faces as vertex-index lists
selectednumber | nullthe currently highlighted vertex/face index
heightnumbercanvas height in px (default 460)
scalenumberzoom (default 0.6)

Emits selectevent.detail is the clicked cell index.

Where the data comes from

The geometry is read generically from the db by the client's polytope(collection, n) — vertices are the collection's dim-0 faces at their point_fn coordinate, edges its dim-1 faces. The registry that says which collection casts into which polytope is base_polytope in @enumeratio/data; list them with polytopeCollections().

ts
import { polytope } from '@enumeratio/client'

const p = await polytope('set_compositions', 4) // → permutahedron
const el = document.querySelector('polytope-figure')!
el.vertices = p.vertices
el.edges = p.edges
el.cells = p.cells
el.addEventListener('select', (e) => console.log('picked cell', (e as CustomEvent).detail))

Live view

The explorer's stateful Projective view is a Vue component built on top of this element (the web component owns the GL and picking; the framework owns the app state). Browse it there: set_compositions → the permutahedron, signed_subsets → the cross-polytope.