of static method

The first image-based light on root or its subtree, breadth-first, or null when the model declared none.

Implementation

static ImageBasedLightComponent? of(Node root) {
  final own = root.getComponents<ImageBasedLightComponent>();
  if (own.isNotEmpty) return own.first;
  final queue = <Node>[...root.children];
  for (var i = 0; i < queue.length; i++) {
    final found = queue[i].getComponents<ImageBasedLightComponent>();
    if (found.isNotEmpty) return found.first;
    queue.addAll(queue[i].children);
  }
  return null;
}