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!!
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
Hello!
The key function:
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
The key function:
function create_interface(obj) {
if (!m_geom.check_shape_keys(obj))
return;
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")
continue;
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)
twitter
06 February 2018 00:49
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.
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.
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)
twitter