How to pick through walls in PointerDragBehavoir and GizmoManager

Hey guys,

I try to combine my beloved PointerDragBehavoir and GizmoManager but struggle with some issues:

  1. I want to pick/drag only specific elements or through ‘walls’, so I think a ‘predicate’ function would do the job…

But I found no way to implement such behavoir in PointerDragBehavoirs…so I decided to use the scene.pickWithRay(). PointerDragBehavoirs theirself seems not to provide any way to assign/modify the ray/picking behavoir. The same goes for the GizmoManger, which uses a PointerDragBehavoir internally (source: Use Gizmos (eg. Drag arrow, Bounding box) - Babylon.js Documentation).

  1. I want the GizmoManger to attach specific Meshes through walls…

It is possible to use gizmoManager.attachableMeshes but the gizmoManager.usePointerToAttachGizmos still will not work through walls.

To summarize it would be nice if I could:

  • modify the rayPicking methods in the PointerDragBehavoir
  • modify the PointerDragBehavoir in the GizmoManger

Here an example PlayGround where I testet a crappy workaround:
https://www.babylonjs-playground.com/#4D2077

I mean if this is the right way to do it…ok, but with GizmoManger and PointerDragBehavoir…we have everything there, just need a bit more flexibility to prevent redundant code…
It worked all nice until I noticed, that I need to pick some stuff through walls (and do not want the wall to be picked/dragged/or a gizmo attached to…

Here a bonus Playground which shows you how easy you can use PointerDragBehavoirs for Dragging:
https://www.babylonjs-playground.com/#9UFEBE#47

Pinging @trevordev

I think your workaround solution is fine, the only comment I would have is to move the logic around that to a class instead of having global functions. The gizmoManager was only created for a single scenario and perpetually adding features to it for more use cases can lead to it getting pretty complicated (as can be seen with the vrHelper) instead I would recommend creating a custom gizmo manager class in your app for specific scenarios like yours that way you can strip out the pieces you don’t need like the current dragging behavior and other gizmos and expand on what it is missing like custom picking.

1 Like

@trevordev again many thanks to you trevor :slightly_smiling_face:
I tried my best and solved it the way you suggested in this PlayGround:
https://www.babylonjs-playground.com/#4D2077#1

Learned a lot about javascript classes and still might use them wrong :sweat_smile:
but I have what I wanted for now :slightly_smiling_face:

2 Likes