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