Prevent drag of multiple DragControls at the same time

Hi all, I’m using DragControls to drag some objects, I’ve multiple DragControls since I’ve different ‘drag’ callback on different objects.

The problem is that when two elements are one behind the other in the current camera/OrbitControl settings both ‘drag’ callback are called.

I don’t want to drag an element if there’s another one in front of.
The effect is similar to this example, but I cannot use one single DragControls to all the elements since I’ve different ‘drag’ callbacks…

I hope I made myself clear :slight_smile: Any ideas?

Thanks!!

The controls are not designed to be instantiated multiple times. Why do you need different drag callbacks in your app? Maybe you can approach the problem differently and avoid the usage of multiple DragControls.

Ok so the best way is to use only one DragControls with one callback.

I think in the ‘drag’ callback I need to check the “type” of dragged object and perform custom logic if object is of type A, B or C…

3 Likes

Sounds good! :+1:

1 Like