Picker.getSelection from 1.68.0

Hi there, seems like there were significant changes in how picker works from 1.68.0+

Previous:

    var selected = picker.getSelection({
        x: Math.floor(event.x * (picker.width / canvasWidth)), 
        y: picker.height - Math.floor(event.y * (picker.height / canvasHeight))
    });

Current:

        var selected = picker.getSelection(
        Math.floor(event.x * (picker.width / canvasWidth)), 
        picker.height - Math.floor(event.y * (picker.height / canvasHeight))
    );

And I’m seeing a huge differences in picking accuracy, any ideas how to get identical functionality as with previous picker version? Using old syntax causes an error

ASSERT FAILED:

Picker.getSelection:param 'rect' is deprecated, use 'x, y, width, height' instead.

The only change I see was to remove the support for the deprecated parameter, which was deprecated for a couple of years. Nothing else seems to have changed there.

Somebody else mentioned something similar:

Seems like I have the same identical issue :thinking:

Same here.
The issue seems to be that y is no longer inverted (or is already inverted for us or something).

Anyway, my fix is

var selected = picker.getSelection(
    Math.floor(event.x * (picker.width / canvasWidth)), 
    Math.floor(event.y * (picker.height / canvasHeight))
);

Tutorial: Entity Picking (PlayCanvas 3D HTML5 Game Engine) actually has bug which is hidden because the scene is symmetrical.

1 Like