How to display fps?


How to display FPS in my local development environment?

2 Likes

In .html:

<html><head><style>
            #fps {
                position: absolute;
                background-color: black;
                border: 2px solid red;
                text-align: center;
                font-size: 16px;
                color: white;
                top: 15px;
                right: 10px;
                width: 60px;
                height: 20px;
            }
</style></head><body>
        <div id="fps">0</div>
</body></html>

Initialize in code:

let divFps = document.getElementById("fps");

In the render loop:

divFps.innerHTML = engine.getFps().toFixed() + " fps";
20 Likes

Thank you very much,that’s the answer I need

1 Like