It seems that
scene.drillPick is leaving some objects hidden. I’ve noticed similar issues with
scene.drillPickFromRay (specifically, the position of intersection is undefined or the object is not intersected at all). Notably, the issue is not present when replacing
It seems that
The order of picking function and where you are in the rendering cycle is significant to the results you get. In your sandcastle there’s a simple change of moving the drillPick() to after the pickPosition() that “resolves” your issue.
I don’t have all the details about this, but I know that a drillPick() does something to the rastrum / buffers (gleamed from tons of old Git issues) and pick() does not, so that a pickPosition() comes out wrong unless it’s forced to the beginning of the next rendering cycle (with whatever added time that takes). I also seem to remember that a drillPick() waits (enforces?) for the next rendering cycle (more on that later) while a pick() does not, which also adds to the complexities. Hopefully someone with better knowledge of the internals will fill us in better here.
Now, because I have to do a lot of complex stuff like this all at the same time from different part of a complex application (including correct picking for transparent models, terrain models (solid or transparent) and entities and especially pointClouds, transparent or not), through lots of experimentation what works for me is to put all my picking requests throughout my application through the same function with cached results (cache all by default, and only one place refresh it, possibly an event listener (see below));
- First entity picking, so do scene.pick()
- if I need a ray, return globe.pickRay() [ie. transparent terrain models AND transparent point clouds]
- if I have a transparent globe, return cameraPickEllipsoid() [just transparent terrain]
- then return scene.pickPosition() [and an added step if I have point clouds to do scatter-shot picking]
- if a drillPick() was needed, don’t do step 1. but do it here in step 5.
You can also experiment with using an event listener on scene.preUpdate and cache all picking requests. I think if you force pickPosition() to preRender (or possibly postRender, depending on what support you need for what kind of models and entities) the results might be a bit more consistent. I know that doing all picking in a specific order in preRender is a possible solution, but not if you also got transparent point-clouds at the same time you’ve got a transparent terrain/globe. It’s quite complicated.
Thanks for the info, @Alexander_Johannesen .
If it’s a render cycle issue, then can I resolve it by turning on
requestRenderMode (using this IRL anyway) and calling
requestRender at the appropriate times?
That doesn’t work, however, calling
render instead does.
I notice the docs for pickTranslucentDepth mention a need to call
render between picks.