We’ve only known ray picking since there was babylonJS. And a lot of work was put in to ensure it was usuable (still recall the days where the perf tanked while trying to pick triangles on the skull, heh).
Now that gpu picking is here, I’d like to add gpu picking as a pick option, implemented at scene level. Observables, action managers etc should all benefit from it. Off the top of my head, I think pointerConfiguration, inputManager etc
will need rework, scene.pick()
becomes await scene.gpu_pick()
, _pickMove()
becomes async _gpu_pickMove()
blah blah blah. You get the point.
Pseudocode
scene.useGPUPicking = true; // turns off ray picking
scene.setGPUPIckingList(); // defaults to all pickable meshes in scene
// crappy napkin idea for interfacing
BABYLON.Scene.prototype.setGPUPIckingList = function(arr){
if (this.useGPUPicking){
this.gpu_picker = new BABYLON.GPUPicker();
const list = arr? arr:this.meshes.filter(mesh=>mesh.isPickable);
this.gpu_picker.setPickingList(list);
} else {
// warn user
}
}
The larger problem here is that all ray pick codes were not async. Which means there is a need to async some of the major functions (attachControl
, processPointerMove/Pick/Up
etc). Do we want to do this now? Can we do this now? Will it break back-compat anywhere?