Unable to select object with Shape Keys

24 December 2016 15:00
When I add Shape Keys I'm unable to select object with pick_object method. Without Shape Keys pick_object method is working correctly.
You can reproduce this bug with morphing code snippet by adding mouse click handler.

function main_canvas_clicked_cb(e) {

        var x = m_mouse.get_coords_x(e);
        var y = m_mouse.get_coords_y(e);

        var localSelectedObj = m_scenes.pick_object(x, y);

pick_object is returning null. I was testing this with few different objects. Please find test blender project.
It is working correctly only with simple cube.

Enabled flags:
Enable Outlining
Outline on Select
Export Shape Keys
Force Dynamic Object
Dynamic Geometry

I was debugging pick_object method and discovered that
m_scenes.pick_color(main_scene, canvas_x, canvas_y)
is returning null. In the pick_color method subs_color_pick.do_render flag is false.
25 December 2016 21:22

Thank you for this thorough investigation. We'll have a look at this on Monday.
26 December 2016 12:57
Issue: bounding volume of shaped object with Shape Keys is not correct.
There are two solutions:
Blend4Web Team
30 December 2016 00:05
I was trying both workarounds without success.

function loaded_cb(data_id) {
        var objs = m_scenes.get_all_objects("ALL", data_id);
        for (var i = 0; i < objs.length; i++) {
            var obj = objs[i];
            if (m_obj.is_mesh(obj)) {

2) See attached screenshot

I have the same result. Perhaps I'm still doing something wrong.
Can you estimate when we can expect bug fix release?
30 December 2016 12:35
I wouldn't call this a bug, but a common problem. It also affects objects with skeletal animation.
Let me explain it a bit. The issue is when a shape key is applied, the object geometry and its bounding volumes are changed too. The engine needs them to be somewhat correct to perform correct selection.

1) So, the one of solutions is to call the "update_boundings" method every time right after applying a shape key via the "set_shape_key_value" method. But this can be slow - that's why the engine doesn't do it automatically.

2) Another solution is to override bounding volumes for the object in Blender. They should be expanded enough to enclose the object in its largest shape that can be obtained after applying different shape keys. Thus, the bounding volumes will always contain the object itself regardless of which shape keys are applied. This approach is more simple than the first one and it doesn't require additional calculations in real time - so, I'd prefer it in most cases.

3) You can also set the "Disable Frustum Culling" flag in the "Object->Rendering Properties" panel - this is the easiest workaround.

Can you estimate when we can expect bug fix release?
I can't tell you a concrete date, but we're planning to solve this issue somehow in the future.

Wow, I've made a test and found just now that there is a bug with overriding - it doesn't work for objects with shape keys at all . Thanks to you! We'll fix it prior to the January release. Anyway, the selection problem will be solved later on.
30 December 2016 15:37
Thanks for your answer. I used workaround 3. Works for me :)
Please register or log in to leave a reply.