Change accessibility of _dragPlane in PointerDragBehavior class to protected to make it more extendable

I have an attempt to implement a custom Bounding box gizmo. It is the regular Bounding box gizmo except that the draggable area is not just a single point but the whole face of a box, which means that I can drag on any place on the face of the box to resize the box. The problem I found is related to the PointerDragBehavior class that:

  1. If the face of a box is larger than the size of _dragPlane, I will have a chance to not be able to initiate the drag since the point I pick wouldn’t be on the _dragPlane. This is leading to the 2nd problem.
  2. How this class handles the _activeDragButton state. If we accidentally start dragging with the draggable area outside the _dragPlane, the result of trying to pick the _dragPlane will be null which will cause the _activeDragButton not to set the value back to -1. And I wouldn’t be able to initiate the drag ever again due to the condition _activeDragButton === -1 that is checked every time when trying to start a drag. As shown in Video 1.

Video 1, the black plane is the _dragPlane which has a limited size of 10,000. As you can see, it’s not covering the whole face of the box and thus I can’t always initiate the drag. And moreover, after the drag failed once, I couldn’t start the drag ever again as stated in 2.

I would like to suggest making the _dragPlane becoming more customizable, at least to be able to change its size from the inherited class. As well as resetting the state of _activeDragButton to -1 if the picking in _startDrag failed. Moreover, I would like to request that if we can return the whole information of the pointer that triggers the event as well instead of just pointerId to be able to identify whether this is a touch event or the event from the mouse.

If this idea sounds good, I am ready to make a contribution to this right away.

Thank you.

cc @Cedric

As long as it doesn’t break back compatibility, why not?
I’m not sure of the advantage of clicking anywhere in the face Vs clicking the sphere in the middle but I’m curious to test it :slight_smile:

Thank you for your comment.
I will start making changes to PointerDragBehavior class and open a PR soon.

The reason I want to customize it to a way that allows clicking anywhere on the face is that the application for this will be mainly used on the touch screen. A sphere in the middle makes it very hard to just touch and drag it.

1 Like