Mesh picking detection and size limits

I cannot find any indications in the docs on limitations on mesh sizes when it comes to mouse selection. Can anyone give any help? I am having trouble selecting simple spheres at a distance. Increasing the size of the spheres above 2 or so seems to fix the issue. See screenshot.

In addition, is there a method or parameter to inhibit selection on Curve3 meshes (using them for a UI element)? I am finding that when clicking near the axis lines or the range circle meshes, they can be selected, and I do not wish this.

I can sadly give you no indication as to the proper size of a mesh. I would say - they should fit an entire pixel so that mouse selection will work correctly.

Regarding UI-picking - any mesh can be set “unpickable” using the isPickable member of any mesh. That is, if you use the default pick function. If you use a custom pick method, just define the predicate correctly to ignore the elements you dont wish to be picked.

Many of these objects are much larger than one pixel. There seems to be a distance limitation to the selection of meshes.

I will try to .isPickable=false these UI elements and give it another try. Thanks! (Yes, am using the default pick functionality).

.isPickable on the circles seems to have solved that part of the issue, but the mesh picking still seems to be either broken or defaults to values that expect much larger targets than what I am presenting.

Below is another snapshot, where the prominent star in the first range circle (SW of origin) is unpickable through many clicking attempts. As you can see, it is much larger in screen real estate than one pixel (as the glow should hint). These screen shots are not zoomed in.


Picking seems to be much more reliable the closer the camera is to the object (which of course makes sense), so it leads me to ask: Is there a ‘frustrum’ or ‘clip plane’ to picking? It seems unlikely, as I believe picking is ray-based, is it not? I think that there are internal criteria, probably outside the control of any settable parameters, that dictate what is pickable and what is not.

It is complicated to say precisely with no repro but I think it is related to float precision

If you are using a large scale scene, math will be less precise. There is no frustum or clipping but more a lack of precision inherent to JS

This is a thought that jives with the fact that, if I push up the sphere size, things are easier to select. However, from a scene perspective (this is a space game of stars), larger sizes mean greater grid distances between objects for the visual effect.

I will tinker with that idea and see what I can come up with.

I feel like you can attach impostors to your stars / planets and make them pickable (and not renderable)

This is the code that I’m using:

    scene.onPointerDown = function (evt, pickResult) {
  if (pickResult.hit) {
    console.log('pointerDown detected.')
    // Query the database storage by the ID of the Mesh, which matches the id: attribute of the object.
    let star = _.find(dataStars, { 'star_id':})

    if (!star) {
      console.log(`pickResult is not a star.`)
    } else {       
      // Center the camera on it.
      camera.useFramingBehavior = true;
  } else {
    console.log(`pointerDown detected, but no pickResult.hit`)

Nothing special, nothing crazy. I am getting ‘no pickResult.hit’ console logs when clicking on near stars, where the mouse pointer is clearly within the bounds of the image on the screen. It’s bizarre.

@deltakosh - Yes, that was going to be my next question - I shall look this up in the API/Docs and see what I can do. But it is clear that the default behavior does not work in this usecase/situation, sadly.

Hi, I have had luck using the GUI and placing markers on the Fullscreen Texture to keep them the same size always - I put together a quick demo. This uses linkWithMesh

1 Like

Agree. This is why we need to get impostors to get bigger picking windows