scenePrePass method

void scenePrePass(
  1. double deltaSeconds, [
  2. bool ancestorsVisible = true
])

Walks this node's subtree once per frame to prepare it for rendering: ticks components and animation players and refreshes the RenderItems the render passes iterate.

Called by Scene.update and Scene.render; not normally called directly. deltaSeconds is the elapsed time since the previous tick. ancestorsVisible is whether every ancestor of this node is visible, and defaults to true for the root.

Implementation

void scenePrePass(double deltaSeconds, [bool ancestorsVisible = true]) {
  _effectiveVisible = ancestorsVisible && visible;

  // Components tick whenever the node is mounted, independent of visibility.
  // These loops stay closure-free while nothing mutates the lists; a
  // mutation hands the rest of the walk to [_visitMutable].
  for (var i = 0; i < _components.length; i++) {
    final component = _components[i];
    component.tick(deltaSeconds);
    if (i < _components.length && identical(_components[i], component)) {
      continue;
    }
    _tickComponentsFrom(i, component, deltaSeconds);
    break;
  }

  if (_effectiveVisible) {
    _animationPlayer?.update(deltaSeconds);
    for (final meshComponent in _meshComponents) {
      meshComponent.refreshRenderItems();
    }
    for (final instancedMeshComponent in _instancedMeshComponents) {
      instancedMeshComponent.refreshRenderItem();
    }
  } else {
    // Keep a hidden subtree's items out of the render passes.
    for (final meshComponent in _meshComponents) {
      meshComponent.hideRenderItems();
    }
    for (final instancedMeshComponent in _instancedMeshComponents) {
      instancedMeshComponent.hideRenderItem();
    }
  }
  for (var i = 0; i < children.length; i++) {
    final child = children[i];
    child.scenePrePass(deltaSeconds, _effectiveVisible);
    if (i < children.length && identical(children[i], child)) continue;
    _prePassChildrenFrom(i, child, deltaSeconds);
    break;
  }
}