Forum

control playback speed

03 May 2016 08:28
Is there a way to control animation playback speed with nodes or with javascript?
03 May 2016 16:44
This can be done with the following method: animation.set_speed()

Even a negative value can be used for speed.
04 May 2016 06:48
Thanks!

Another question.
How to make number input field?
I would like that the user can input a number and then the number is used in Blend4Web logic nodes and it affects animation.
04 May 2016 15:57

Thanks!

Another question.
How to make number input field?
I would like that the user can input a number and then the number is used in Blend4Web logic nodes and it affects animation.
Hello!

You can use standard HTML elements for user input.
For example:
 
<form>
  Aniamtion speed:<br>
  <input type="number" name="anim_speed" id="anim_speed"><br>
...
</form>


Then for example if you want to use this input value in node "JS Callback" you should register a callback before loading the scene:

var m_anim = require("anim");
var m_logn = require("logic_nodes");

...

function init_cb(canvas_elem, success) {
    //callback registration 
    m_logn.append_custom_callback("anim_speed", anim_speed_cb);
    load_scene();
}

...

function anim_speed_cb(in_params, out_params) {
    var inp_speed = document.getElementById("anim_speed").value;
    ...
    m_anim.set_speed(obj, inp_speed);
}


Then you can add a "JS callback" logic node to your tree and specify an id of your callback in it.


So this node will execute anim_speed_cb function.

Blend4Web Team - developer
Twitter
LinkedIn
05 May 2016 11:41
Thanks!

Is there any possibility to do the same with single html output?
Is it possible to keep JS file inside Blender's Text Editor?
05 May 2016 11:46

Is there any possibility to do the same with single html output?
Is it possible to keep JS file inside Blender's Text Editor?
No, for now this functionality can only be used in b4w applications with external JS.
Blend4Web Team - developer
Twitter
LinkedIn
 
Please register or log in to leave a reply.