vtkFPSMonitor

I want to use vtkFPSMonitor to display fps and I use setRenderWindow to pass my renderWindow to vtkFPSMonitor. The canvas in vtkFPSMonitor works well, but the info cannot be displayed.
This is function renderInfo():

function renderInfo() {

model.info.style.display = model.infoVisibility ? 'grid' : 'none';

if (!model.infoVisibility) {

  return;

}

const infoItems = [];

if (model.renderWindow) {

  const realView = model.renderWindow.getViews()[0];

  if (realView && realView.getSize) {

    infoItems.push(

      `<label class="${style.label}">Resolution</label><span class="${

        style.value

      }">${realView.getSize().join('x')}</span>`

    );

  }

I found that the model.renderWindow is always undefined, so I cannot get info. I hope someone can tell me what went wrong, thanks!

Can you share your code? Did you look at the example that was using it?

thank you for your replyļ¼This is my codeļ¼š

this.fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
rootContainer: geoViewer,
});
this.renderWindow = this.fullScreenRenderer.getRenderWindow();
let FPSContainer = document.getElementById(ā€œfpsā€);
this.FPSWidget = vtkFPSMonitor.newInstance();
this.FPSWidget.setContainer(FPSContainer);
this.FPSWidget.setRenderWindow(this.renderWindow);
this.FPSWidget.setOrientation(ā€˜verticalā€™);

By the way, I am sorry I didnā€™t find an example of vtkFPSMonitor in https://kitware.github.io/vtk-js/examples/index.html.

Here is an example using it

Does document.getElementById(ā€œfpsā€); properly resolve to a DOM element?

Thanks again! I think I know where the problem is. It looks like the this.FPSWidget.update() function function is not called. When I added this.FPSWidget.update() after the original code, it seemed to workā€¦

1 Like