Skip to main content

sim_lib_scene/
kinds.rs

1//! Scene node kinds.
2//!
3//! Scene node kinds are open metadata, never a closed kernel enum: a scene node
4//! is an `Expr::Map` carrying a `kind` entry whose value is a symbol in the
5//! `scene` namespace (for example `scene/graph`). This module lists the minimum
6//! baseline scene vocabulary and provides recognition helpers. New kinds can be
7//! added by libs without touching the kernel; the recognized set here is the
8//! baseline the universal lenses rely on.
9
10use sim_kernel::Symbol;
11
12/// The namespace every scene node `kind` symbol lives in.
13pub const SCENE_NAMESPACE: &str = "scene";
14
15/// The map key that tags a scene node with its kind.
16pub const KIND_KEY: &str = "kind";
17
18/// The baseline scene node kind names (the local part of the `scene/*` symbol).
19///
20/// The recognized baseline, not a closed universe: [`is_known_kind`] returns
21/// `false` for an unrecognized kind so a malformed scene fails closed, while
22/// libs may extend the runtime set through registration.
23pub const SCENE_KINDS: &[&str] = &[
24    "box",
25    "stack",
26    "grid",
27    "text",
28    "field",
29    "button",
30    "badge",
31    "badge-cluster",
32    "icon",
33    "tree",
34    "continuation",
35    "table",
36    "graph",
37    "glance",
38    "spatial",
39    "stereo",
40    "anchor",
41    "panel",
42    "gaze-cursor",
43    "hand-ray",
44    "world-plane",
45    "node",
46    "edge",
47    "plot",
48    "matrix",
49    "heatmap",
50    "knob",
51    "slider",
52    "meter",
53    "waveform",
54    "spectrum",
55    "timeline",
56    "keyboard",
57    "piano-roll",
58    "player-rack",
59    "object-roll",
60    "canvas",
61    "overlay",
62    "embed",
63    "patch",
64];
65
66/// The qualified symbol for a scene node kind name, e.g. `scene/graph`.
67pub fn scene_kind(name: &str) -> Symbol {
68    Symbol::qualified(SCENE_NAMESPACE, name)
69}
70
71/// Is `name` a recognized baseline scene node kind (local part only)?
72pub fn is_known_kind_name(name: &str) -> bool {
73    SCENE_KINDS.contains(&name)
74}
75
76/// Is `symbol` a recognized baseline scene node kind (`scene/<known>`)?
77pub fn is_known_kind(symbol: &Symbol) -> bool {
78    symbol.namespace.as_deref() == Some(SCENE_NAMESPACE) && is_known_kind_name(&symbol.name)
79}