MattePatte Posted May 24, 2014 Share Posted May 24, 2014 Hello friends! I don't understand how to use engine.beginFrame(). It says in the documentation that it should measure the Frames Per Second but i don't understand how it works. If anyone could show me a example that would have been awesome. I have tried to measure the FPS by my self and it looks something like this.var lastCalledTime;var fps;var stop = 0; var renderLoop = function () { // Start new frame if(!lastCalledTime) { lastCalledTime = new Date().getTime(); fps = 0; BABYLON.Tools.QueueNewFrame(renderLoop); return; } delta = (new Date().getTime() - lastCalledTime)/1000; lastCalledTime = new Date().getTime(); fps = 1/delta; // a stop variable since it hard to se the fps when it's displayed 60 times per //second, if(stop == 30){ // a div element to display the fps fpsDiv.innerHTML = parseInt(fps); stop = 0; } engine.beginFrame(); scene.render(); // Present engine.endFrame(); // Register new frame BABYLON.Tools.QueueNewFrame(renderLoop); stop++;};It shows a frame rate between 60 and 0 but it's usually quite low around 16 FPS.I have a piece of shit computer so that doesn't surprise me, but i want to be sure that i really measure the fps. Thanks! Quote Link to comment Share on other sites More sharing options...
MattePatte Posted May 24, 2014 Author Share Posted May 24, 2014 Look what i found!! BABYLON.Tools.GetFps().toFixed(); It works perfect. gwenael, jerome and GameMonetize 3 Quote Link to comment Share on other sites More sharing options...
willemmulder Posted January 9, 2016 Share Posted January 9, 2016 I got here via Google but the accepted answer apparently is incorrect. As of version 2.2 you would use engine.getFps() Quote Link to comment Share on other sites More sharing options...
Convergence Posted January 9, 2016 Share Posted January 9, 2016 or a tad simpler:engine.fps; Quote Link to comment Share on other sites More sharing options...
jerome Posted January 9, 2016 Share Posted January 9, 2016 http://doc.babylonjs.com/classes/2.2/Tools#static-getfps-rarr-number http://doc.babylonjs.com/classes/2.2/Engine#getfps-rarr-number a better way than Google to find something : go here : http://doc.babylonjs.com/type "fps" in the search zone in the top right corner, and that's all Quote Link to comment Share on other sites More sharing options...
willemmulder Posted January 11, 2016 Share Posted January 11, 2016 a better way than Google to find something : go here : http://doc.babylonjs.com/type "fps" in the search zone in the top right corner, and that's all Maybe (although I never really like to restrict my search to just one site), but people do get here via Google so I think it's important to make sure the answers here are correct Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.