materialize method

void materialize(
  1. num currentTime,
  2. num deltaTime
)

This method is called by the RenderLoop where this Stage is added to. If this Stage is not added to a RenderLoop you could call this method on your own and therefore get full control of the rendering of this Stage.

Implementation

void materialize(num currentTime, num deltaTime) {
  if (renderMode == StageRenderMode.AUTO ||
      renderMode == StageRenderMode.AUTO_INVALID && _invalid ||
      renderMode == StageRenderMode.ONCE) {
    final stopwatch = Stopwatch()..start();

    _updateCanvasSize();
    _renderEvent.dispatch();
    _renderContext.reset();
    _renderContext.renderStatistics.reset();
    _renderContext.clear(backgroundColor);
    _renderState.reset(_stageTransformation);
    _renderState.currentTime = currentTime;
    _renderState.deltaTime = deltaTime;
    _renderState.renderObject(this);
    _renderState.flush();
    _invalid = false;

    final stats = _renderContext.renderStatistics;
    final frameTime = stopwatch.elapsedMilliseconds;
    _avgDrawCalls = _avgDrawCalls * 0.75 + stats.drawCount * 0.25;
    _avgVertexCount = _avgVertexCount * 0.75 + stats.vertexCount * 0.25;
    _avgIdexCount = _avgIdexCount * 0.75 + stats.indexCount * 0.25;
    _avgFrameTime = _avgFrameTime * 0.95 + frameTime * 0.05;

    if (_console.visible && _console.off == false) {
      _console.clear();
      _console
          .print('FRAMETIME${_avgFrameTime.round().toString().padLeft(6)}');
      _console
          .print('DRAWCALLS${_avgDrawCalls.round().toString().padLeft(6)}');
      _console
          .print('VERTICES${_avgVertexCount.round().toString().padLeft(7)}');
      _console.print('INDICES${_avgIdexCount.round().toString().padLeft(8)}');
      _renderState.reset(_consoleTransformation);
      _renderState.renderObject(_console);
      _renderState.flush();
    }
  }

  if (renderMode == StageRenderMode.ONCE) {
    renderMode = StageRenderMode.STOP;
  }
}