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 = engine.world;
  if (!identical(world, _world) ||
      _queriesVersion(world) != _structureVersion ||
      // Registering a provider changes what is drawn, no entity changed.
      providers.version != _providerVersion ||
      _dirty ||
      _pathsChanged()) {
    _rebuild(world);
  }
  _alpha = view.interpolation.clamp(0.0, 1.0);
  final aids = this.aids;
  _aided = aids != null && !aids.plainViews.contains(view);
  _checkCaptures(world);
  _follow();
  _followShapes();
  _followProviders();
  _applyAids();
  _extractLights(world);
  _extractEnvironment(world);

  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);
}