update method

void update(
  1. FrameView view
)

Brings scene and the render view up to date with the world and view. render calls it; tests may call it alone.

Implementation

void update(FrameView view) {
  final world = this.world();
  _showHidden();
  final alpha = view.interpolation.clamp(0.0, 1.0);
  final frame = this.frame?.call();
  // Once a frame: a second view of the same frame, between the same two
  // steps, sees the world as the first did.
  if (frame == null ||
      frame != _lookedFrame ||
      alpha != _alpha ||
      !identical(world, _world)) {
    _lookedFrame = frame;
    _alpha = alpha;
    _refresh(world);
    _checkCaptures(world);
    _follow();
    _followShapes();
    _followProviders();
    _extractLights(world);
    _extractEnvironment(world);
  }
  final aids = this.aids;
  _aided = aids != null && !aids.plainViews.contains(view);
  _applyAids();

  final ratio =
      pixelRatio ??
      ui.PlatformDispatcher.instance.implicitView?.devicePixelRatio ??
      1.0;
  // Timed by the first view drawn (the game's): a second view drawn in
  // the same frame would halve the time seen between frames.
  if (identical(_timed ??= view, view)) {
    if (_clock.isRunning) {
      dynamicResolution.frame(_clock.elapsedMicroseconds / 1e6);
    }
    _clock
      ..reset()
      ..start();
  }
  final scale = ratio * renderScale * dynamicResolution.scale;
  _view
    ..width = math.max(
      1,
      math.min(8192, (view.viewportSize.width * scale).round()),
    )
    ..height = math.max(
      1,
      math.min(8192, (view.viewportSize.height * scale).round()),
    );
  _view.view.setFrom(view.view);
  _view.projection.setFrom(view.projection);
  _view.cameraPosition.setFrom(view.cameraPosition);
}