Picker example wrong with current version?

Hi,
I started a small project combining the framebuffer picking example with an orbit camera.
See:
https://playcanvas.com/editor/scene/2162463

I was using the default orbit scripts from the asset library and the picker_framebuffer script from the example-project here:
https://playcanvas.com/project/405856

Using it in this form resulted in an incorrect hit detection, after taking a look into the code and the picker documentation:

I changed following line in the picker_framebuffer.js code, which resulted in (probably) correct functionality.

var selected = picker.getSelection(
   Math.floor(event.x * (picker.width / canvasWidth)),
   // original code -> wrong? 
   //picker.height - Math.floor(event.y * (picker.height / canvasHeight))
        
   // my changed code -> correct?
   Math.floor(event.y * (picker.height / canvasHeight))
);

Had there been an api change (assuming as the old code seems to mimic a y coordinate from bottom) ?
If so, maybe the tutorial and/or example file should be updated as well.

Thanks for any heads up,

1 Like