-
-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow draggable groups #3549
Allow draggable groups #3549
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request, @voigta!
The method .draggable()
doing nothing on groups is indeed unexpected. So I tested your fix with the following example:
with ui.scene() as scene:
sphere = scene.sphere().draggable()
with scene.group().draggable():
scene.box().move(x=1)
scene.box().move(x=-1)
But just as mentioned in the documentation, the boxes are only draggable if the sphere isn't draggable. This isn't nice either.
I'll have to think about it. Maybe there's another way to get a more intuitive behavior. The drag handler in JavaScript could try to propagate the movement to the next group in its hierarchy. Otherwise raising a NotImplemented
exception in group.draggable
might be the better choice.
We see the following options:
What do you think, @voigta? |
Thanks for the feedback @falkoschindler. Solving the problem (i.e. option 3) would definitely be the cleanest solution. There have been updates of DragControls.js in three.js r162 that allow multiple draggable groups. However, the situation of a draggable group and a draggable object is still not nicely handled in the official repo. Therefore, I've added a small modification that should fix this problem and your example is now working as expected. |
1a4ee71
to
dd0a0f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update, @voigta!
The new solution looks really neat and it behaves just as expected! What a nice incidence that we just upgraded three.js.
I just moved the change into our npm.py script, so that it is automatically applied when updating third-party libraries.
Let's merge! 🚀
This PR allows groups to be draggable. Currently there is no effect when we call group.draggable().
As noted in the documentation of DragControls, this only works if the scene contains a single draggable group. This might lead to some confusion but ignoring the
.draggable()
call for groups is also confusing...😅 At least setting thetransformGroup
property to true only affects the behavior for groups and not for other objects.