resolveSceneKey function

SceneKey? resolveSceneKey(
  1. SceneNode node,
  2. String key
)

Which SceneKey key is on node, or null when it names nothing the node can hold.

The grammar is row, row.part or a side's own flat name. A dotted key is a part of a property whose parts this table cannot list — an argument of the child a node stands for, an axis of whatever face it is set in — so the row's name carries them. A quad's four sides are flat instead, because that is what the constructor spells.

Implementation

SceneKey? resolveSceneKey(SceneNode node, String key) {
  var dot = key.indexOf('.');
  if (dot > 0) {
    var row = key.substring(0, dot);
    var part = key.substring(dot + 1);
    for (var p in sceneProps) {
      if (p.name == row && p.hasNamedParts && p.appliesTo(node)) {
        return ScenePartKey(p, part);
      }
    }
    return null;
  }
  for (var p in sceneProps) {
    if (!p.appliesTo(node)) continue;
    if (p.name == key) return ScenePropertyKey(p);
    if (p.sides?.contains(key) ?? false) return ScenePartKey(p, key);
  }
  return null;
}