Edited:Morphing code snippet help question

23 January 2018 19:02
Hello guys…isn’t it an awesome thing Blend 4 web???

Currently I am trying myself to get the morphing code snippet working for me. Since I don’t need a dual slider, all I need are sliders (0.0 – 1.0 range) and functions on which each one of the shape keys is named (am I right or wrong?) as the code has to be aware the shape keys exist.

But looking into the morphing code, not all the sliders name of this morphing project are present on it. That really confuses me!!!!

So since my project consists of a single “OBJECT" on which multiple shape keys exist, how do I go by having all the shape keys seen by the code?? One slider to each shape key….Im really trying to understand that.

Thank you for anyone helping me out with this!!
24 January 2018 14:04
The key function:
function create_interface(obj) {
    if (!m_geom.check_shape_keys(obj))
    create_dual_slider(obj, "fatten", "shrink", "Weight");
    var shape_keys_names = m_geom.get_shape_keys_names(obj);
    for (var i  = 0; i < shape_keys_names.length; i++) {
        if (shape_keys_names[i] == "fatten" || shape_keys_names[i] == "shrink")
        create_slider(obj, shape_keys_names[i], shape_keys_names[i]);

There two shapekeys are used for Weight slider one shapekey for the rest sliders. You can see that "shrink" and "fatten" are skipped in the cycle because they are used for creating of the "Weight" dual slider
Alexander (Blend4Web Team)
25 January 2018 06:56
thank you so much
06 February 2018 00:49
In the morphing.js,
The function load
Var obj = m_scenes.get_object_by_name ("name of object");

Well this is for only 1 object with a set of shape keys. What happens when i have 2 objects? Do i declare another variable for the second one?
06 February 2018 10:37
Yes, of course.
Or you can put the names into an array and then create an array of the objects from this array.
var names = ["obj1", "obj2"];
var objs = [];
for (var i = 0; i < names.length; i++) {
    objs.push(m_scenes.get_object_by_name (names[i]))

Then use check_shape_keys and get_shape_keys_names for each element. The question is more about the basics of programming with javascript, there is no Blend4Web specifics.
Alexander (Blend4Web Team)
Please register or log in to leave a reply.