Forum

[SOLVED]How to set the fps in B4W

25 July 2017 18:34
Hi, everyone, the default fps in my b4w html is 60, but sometimes the fps may jump to a low value, and when the fps jump to a low value, the bones animation may be played slowly .
So I want to set the fps to a static value, for example 24.
25 July 2017 19:06
Here is a post by Evgeny.
If I understand correctly, you set the FPS in Blender and it affects only the animation speed, not the rendered frames per second.
26 July 2017 05:08
Yes, but I still don't know how to set the fps in B4W, it changes in different devices.
26 July 2017 05:56
You can control the animations by setting the frame rate in Blender. This will determine how fast your animation plays in Blend4Web. The actual refresh rate is determined by how fast your device can process the scene. So if your application is bogging down on some devices the only solution is to lighten the processing burden on the device. There are a number of things you can do to optimize your project. Using the asset conversion ability in your Project Manager can help. (You might check out this post.)
26 July 2017 10:16
OK, thanks, dear Will. Can I get the fps value in the scene? Because I control the bones action with the function
set_bone_tsr_rel(armobj, bone_name, tsr)
, so the speed of action is relative with the fps value.
So I need to know the fps to change the speed of playing.
26 July 2017 10:36
Hi berdon,

there's the method set_fps_callback. The callback executes every frame and gives you the actual fps value:
var m_main = require("main");

m_main.set_fps_callback(function(fps_avg, phy_fps_avg) {
    console.log("current fps is", fps_avg);
});
26 July 2017 12:04
Reply to post of user Ivan Lyubovnikov
Hi berdon,

there's the method set_fps_callback. The callback executes every frame and gives you the actual fps value:
var m_main = require("main");

m_main.set_fps_callback(function(fps_avg, phy_fps_avg) {
    console.log("current fps is", fps_avg);
});
wow, I get it. Thanks, Ivan. And another question, can the fps be set?
26 July 2017 12:12
wow, I get it. Thanks, Ivan. And another question, can the fps be set?
you can try to limit the maximum fps like that:
m_config.set("max_fps", 10)

but this can be inaccurate, because it's mostly a debugging feature
26 July 2017 12:25
OK, it works, Thanks.
 
Please register or log in to leave a reply.