How to use stats.js with speckle-viewer?

Hi @alex
I would like to compute FPS on my custom speckle viewer.
In pure three.js, I could use stats.js:

I was able to make the panel appear with:

import Stats from 'three/addons/libs/stats.module.js';

const stats = new Stats();
document.body.appendChild(stats.dom);

But the panel remains empty, as I have to add this code, but I don’t know where, as the function animate() is handled by the speckle-viewer library:

function animate() {
    stats.begin();

    renderer.render(scene, camera);

    stats.end();
    requestAnimationFrame(animate);
}

Thanks

Hi @RaphaelVouilloz

You should be able to use the provided extension callbacks and call stats.begin from either onEarlyUpdate or onLateUpdate and a stats.end from onRender. Depends on what exactly you want to capture

Cheers

1 Like

Thank @alex,
I have been able to achieve what I wanted

1 Like