[Babylon Lite] get FPS

Hi,
I am wondering if there is any equivalent to `Engine.getFps` in Babylon Lite? I did not find anything in engine, but I expect if implemented that this feature will not be part of Engine but some other dedicated entity.

Best regards,
Axel

Babylon Lite 1.8.0 has no direct Engine.getFps() equivalent.

Use the public onBeforeRender delta:

import { onBeforeRender } from "@babylonjs/lite";

let fps = 0;

onBeforeRender(scene, (deltaMs) => {
  if (deltaMs > 0) {
    fps = 1000 / deltaMs;
  }
});

For a stable displayed value, average several frames:

let averageDelta = 16.67;
let fps = 60;

onBeforeRender(scene, (deltaMs) => {
  if (deltaMs <= 0) return;

  averageDelta += (deltaMs - averageDelta) * 0.1;
  fps = 1000 / averageDelta;
});

This is a perfect example of the “no classes, pure data + functions” philosophy of Babylon Lite :slight_smile:

Thank you, implemented it in a starter project showing how to combine Angular and BabylonJS: